@agent-native/core 0.107.0 → 0.107.1

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 (131) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +10 -0
  3. package/corpus/core/docs/content/integrations.mdx +27 -27
  4. package/corpus/core/package.json +1 -1
  5. package/corpus/core/src/agent/production-agent.ts +19 -0
  6. package/corpus/core/src/agent/run-store.ts +98 -2
  7. package/corpus/core/src/client/AssistantChat.tsx +13 -0
  8. package/corpus/core/src/client/CommandMenu.tsx +5 -0
  9. package/corpus/core/src/client/active-run-state.ts +34 -0
  10. package/corpus/core/src/client/agent-chat-adapter.ts +4 -0
  11. package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +41 -11
  12. package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +27 -9
  13. package/corpus/core/src/client/resources/mcp-integration-catalog.ts +45 -0
  14. package/corpus/core/src/client/sharing/ShareButton.tsx +30 -9
  15. package/corpus/core/src/client/use-agent-chat-home-handoff.ts +2 -2
  16. package/corpus/core/src/localization/default-messages.ts +4 -1
  17. package/corpus/core/src/secrets/register-framework-secrets.ts +28 -0
  18. package/corpus/core/src/server/agent-chat-plugin.ts +29 -1
  19. package/corpus/core/src/vite/client.ts +24 -0
  20. package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +29 -21
  21. package/corpus/templates/analytics/AGENTS.md +8 -0
  22. package/corpus/templates/analytics/actions/dashboard-mutation-api.ts +1 -1
  23. package/corpus/templates/analytics/actions/update-dashboard.ts +6 -2
  24. package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +35 -7
  25. package/corpus/templates/analytics/app/components/layout/Layout.tsx +1 -3
  26. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +11 -1
  27. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/extension-slot.ts +11 -0
  28. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +27 -0
  29. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +6 -0
  30. package/corpus/templates/analytics/changelog/2026-07-17-dashboard-extension-boxes.md +6 -0
  31. package/corpus/templates/analytics/server/lib/agent-readable-resource-context.ts +8 -0
  32. package/corpus/templates/analytics/server/plugins/agent-chat.ts +1 -0
  33. package/corpus/templates/assets/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  34. package/corpus/templates/brain/app/hooks/use-navigation-state.ts +6 -1
  35. package/corpus/templates/brain/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  36. package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +1 -1
  37. package/corpus/templates/calendar/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  38. package/corpus/templates/chat/app/hooks/use-navigation-state.ts +4 -1
  39. package/corpus/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  40. package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
  41. package/corpus/templates/clips/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  42. package/corpus/templates/content/actions/_content-space-access.ts +45 -2
  43. package/corpus/templates/content/actions/create-content-database.ts +41 -7
  44. package/corpus/templates/content/app/components/layout/Layout.tsx +1 -1
  45. package/corpus/templates/content/app/root.tsx +1 -10
  46. package/corpus/templates/content/changelog/2026-07-17-creating-a-database-now-completes-reliably-in-hosted-workspa.md +6 -0
  47. package/corpus/templates/content/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  48. package/corpus/templates/dispatch/app/hooks/use-navigation-state.ts +4 -1
  49. package/corpus/templates/dispatch/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  50. package/corpus/templates/forms/app/components/layout/Layout.tsx +2 -4
  51. package/corpus/templates/forms/app/components/ui/popover.tsx +25 -1
  52. package/corpus/templates/forms/app/hooks/use-navigation-state.ts +6 -1
  53. package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +13 -10
  54. package/corpus/templates/forms/app/root.tsx +6 -1
  55. package/corpus/templates/forms/changelog/2026-07-17-form-builder-popovers-stay-within-the-viewport.md +6 -0
  56. package/corpus/templates/forms/changelog/2026-07-17-form-editor-loading-matches-current-sidebar-free-layout.md +6 -0
  57. package/corpus/templates/forms/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  58. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +1 -1
  59. package/corpus/templates/mail/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  60. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +14 -3
  61. package/corpus/templates/plan/app/hooks/use-navigation-state.ts +8 -1
  62. package/corpus/templates/plan/app/root.tsx +0 -2
  63. package/corpus/templates/plan/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  64. package/corpus/templates/slides/app/components/layout/Layout.tsx +1 -1
  65. package/corpus/templates/slides/app/context/DeckContext.tsx +23 -23
  66. package/corpus/templates/slides/changelog/2026-07-17-duplicated-slides-now-stay-in-the-deck.md +6 -0
  67. package/corpus/templates/slides/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  68. package/corpus/templates/tasks/app/components/layout/Layout.tsx +2 -13
  69. package/corpus/templates/tasks/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it.md +6 -0
  70. package/dist/agent/production-agent.d.ts.map +1 -1
  71. package/dist/agent/production-agent.js +13 -1
  72. package/dist/agent/production-agent.js.map +1 -1
  73. package/dist/agent/run-store.d.ts +17 -0
  74. package/dist/agent/run-store.d.ts.map +1 -1
  75. package/dist/agent/run-store.js +84 -2
  76. package/dist/agent/run-store.js.map +1 -1
  77. package/dist/client/AssistantChat.d.ts.map +1 -1
  78. package/dist/client/AssistantChat.js +10 -1
  79. package/dist/client/AssistantChat.js.map +1 -1
  80. package/dist/client/CommandMenu.d.ts.map +1 -1
  81. package/dist/client/CommandMenu.js +4 -0
  82. package/dist/client/CommandMenu.js.map +1 -1
  83. package/dist/client/active-run-state.d.ts +7 -0
  84. package/dist/client/active-run-state.d.ts.map +1 -1
  85. package/dist/client/active-run-state.js +28 -0
  86. package/dist/client/active-run-state.js.map +1 -1
  87. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  88. package/dist/client/agent-chat-adapter.js +4 -1
  89. package/dist/client/agent-chat-adapter.js.map +1 -1
  90. package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -1
  91. package/dist/client/resources/McpConnectionSuggestion.js +27 -8
  92. package/dist/client/resources/McpConnectionSuggestion.js.map +1 -1
  93. package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
  94. package/dist/client/resources/McpIntegrationDialog.js +4 -2
  95. package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
  96. package/dist/client/resources/mcp-integration-catalog.d.ts +6 -0
  97. package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
  98. package/dist/client/resources/mcp-integration-catalog.js +33 -0
  99. package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
  100. package/dist/client/sharing/ShareButton.d.ts.map +1 -1
  101. package/dist/client/sharing/ShareButton.js +15 -12
  102. package/dist/client/sharing/ShareButton.js.map +1 -1
  103. package/dist/client/use-agent-chat-home-handoff.d.ts +1 -1
  104. package/dist/client/use-agent-chat-home-handoff.d.ts.map +1 -1
  105. package/dist/client/use-agent-chat-home-handoff.js +1 -1
  106. package/dist/client/use-agent-chat-home-handoff.js.map +1 -1
  107. package/dist/collab/awareness.d.ts +2 -2
  108. package/dist/collab/awareness.d.ts.map +1 -1
  109. package/dist/collab/routes.d.ts +1 -1
  110. package/dist/collab/struct-routes.d.ts +1 -1
  111. package/dist/localization/default-messages.d.ts +2 -0
  112. package/dist/localization/default-messages.d.ts.map +1 -1
  113. package/dist/localization/default-messages.js +3 -1
  114. package/dist/localization/default-messages.js.map +1 -1
  115. package/dist/observability/routes.d.ts +5 -5
  116. package/dist/secrets/register-framework-secrets.d.ts.map +1 -1
  117. package/dist/secrets/register-framework-secrets.js +25 -0
  118. package/dist/secrets/register-framework-secrets.js.map +1 -1
  119. package/dist/secrets/routes.d.ts +9 -9
  120. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  121. package/dist/server/agent-chat-plugin.js +23 -1
  122. package/dist/server/agent-chat-plugin.js.map +1 -1
  123. package/dist/templates/chat/app/hooks/use-navigation-state.ts +4 -1
  124. package/dist/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  125. package/dist/vite/client.d.ts.map +1 -1
  126. package/dist/vite/client.js +20 -0
  127. package/dist/vite/client.js.map +1 -1
  128. package/docs/content/integrations.mdx +27 -27
  129. package/package.json +1 -1
  130. package/src/templates/chat/app/hooks/use-navigation-state.ts +4 -1
  131. package/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
@@ -1 +1 @@
1
- {"version":3,"file":"McpConnectionSuggestion.d.ts","sourceRoot":"","sources":["../../../src/client/resources/McpConnectionSuggestion.tsx"],"names":[],"mappings":"AAwBA,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,UAAU,CAAC;AAErE,UAAU,4BAA4B;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,8BAA8B,CAAC;CAC1C;AAuCD,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,WAAgB,EAChB,OAAoB,GACrB,EAAE,4BAA4B,sCAsK9B"}
1
+ {"version":3,"file":"McpConnectionSuggestion.d.ts","sourceRoot":"","sources":["../../../src/client/resources/McpConnectionSuggestion.tsx"],"names":[],"mappings":"AA0BA,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,UAAU,CAAC;AAErE,UAAU,4BAA4B;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,8BAA8B,CAAC;CAC1C;AA6CD,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,WAAgB,EAChB,OAAoB,GACrB,EAAE,4BAA4B,sCA4L9B"}
@@ -2,8 +2,9 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { IconArrowUpRight, IconLoader2, IconPlugConnected, IconX, } from "@tabler/icons-react";
3
3
  import { useEffect, useMemo, useState } from "react";
4
4
  import { agentNativePath } from "../api-path.js";
5
+ import { openAgentSettings } from "../CommandMenu.js";
5
6
  import { useT } from "../i18n.js";
6
- import { buildMcpOAuthStartUrl, findMcpIntegrationForText, getDefaultMcpIntegrations, isMcpConnectionFailureText, } from "./mcp-integration-catalog.js";
7
+ import { buildMcpOAuthStartUrl, findMcpIntegrationForText, getMcpIntegrationApiFallback, getDefaultMcpIntegrations, isMcpConnectionFailureText, } from "./mcp-integration-catalog.js";
7
8
  import { McpIntegrationDialog } from "./McpIntegrationDialog.js";
8
9
  import { useCreateMcpServer, useMcpServers, } from "./use-mcp-servers.js";
9
10
  function compareUrl(value) {
@@ -31,6 +32,9 @@ function canStartOAuth(integration) {
31
32
  integration.connectionMode === "oauth" &&
32
33
  integration.availability === "ready");
33
34
  }
35
+ function hasApiFallback(apiFallback) {
36
+ return Boolean(apiFallback);
37
+ }
34
38
  export function McpConnectionSuggestion({ text, contextText = "", variant = "composer", }) {
35
39
  const t = useT();
36
40
  const mcpServersQuery = useMcpServers();
@@ -48,6 +52,9 @@ export function McpConnectionSuggestion({ text, contextText = "", variant = "com
48
52
  textIntegration.id !== contextIntegration.id
49
53
  ? null
50
54
  : (textIntegration ?? contextIntegration);
55
+ const apiFallback = integration
56
+ ? getMcpIntegrationApiFallback(integration)
57
+ : null;
51
58
  const servers = useMemo(() => [
52
59
  ...(mcpServersQuery.data?.user ?? []),
53
60
  ...(mcpServersQuery.data?.org ?? []),
@@ -68,6 +75,10 @@ export function McpConnectionSuggestion({ text, contextText = "", variant = "com
68
75
  if (!integration || connecting)
69
76
  return;
70
77
  setError(null);
78
+ if (apiFallback) {
79
+ openAgentSettings(`secrets:${apiFallback.secretKey}`);
80
+ return;
81
+ }
71
82
  if (canStartOAuth(integration)) {
72
83
  window.location.assign(agentNativePath(buildMcpOAuthStartUrl({
73
84
  name: integration.name,
@@ -100,16 +111,24 @@ export function McpConnectionSuggestion({ text, contextText = "", variant = "com
100
111
  }
101
112
  setDialogOpen(true);
102
113
  };
103
- const actionLabel = canStartOAuth(integration)
104
- ? t("mcpIntegrations.connectWithOAuth")
105
- : integration.availability === "client-restricted" ||
106
- integration.availability === "provider-setup"
107
- ? t("mcpIntegrations.viewSetup")
108
- : t("mcpIntegrations.connect");
114
+ const actionLabel = hasApiFallback(apiFallback)
115
+ ? t("mcpIntegrations.useApiToken")
116
+ : canStartOAuth(integration)
117
+ ? t("mcpIntegrations.connectWithOAuth")
118
+ : integration.availability === "client-restricted" ||
119
+ integration.availability === "provider-setup"
120
+ ? t("mcpIntegrations.viewSetup")
121
+ : t("mcpIntegrations.connect");
109
122
  return (_jsxs(_Fragment, { children: [_jsxs("div", { className: variant === "response"
110
123
  ? "mt-3 flex max-w-[520px] items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[12px]"
111
124
  : "mx-auto mb-2 flex w-[min(100%,680px)] items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[12px]", "data-mcp-connection-suggestion": integration.id, children: [_jsxs("div", { className: "relative flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-background text-[10px] font-semibold text-muted-foreground", children: [_jsx("span", { "aria-hidden": "true", children: integration.name.slice(0, 1) }), integration.logoUrl && (_jsx("img", { src: integration.logoUrl, alt: "", className: "absolute h-5 w-5 object-contain", onError: (event) => {
112
125
  event.currentTarget.hidden = true;
113
- } }))] }), _jsx("span", { className: "min-w-0 flex-1 leading-snug text-foreground", children: t("mcpIntegrations.connectSuggestion", { name: integration.name }) }), _jsxs("button", { type: "button", onClick: () => void connect(), disabled: connecting, className: "inline-flex shrink-0 items-center gap-1 rounded-md bg-primary px-2.5 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-60", children: [connecting && _jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }), !connecting && canStartOAuth(integration) && (_jsx(IconPlugConnected, { className: "h-3 w-3" })), actionLabel, !connecting && !canStartOAuth(integration) && (_jsx(IconArrowUpRight, { className: "h-3 w-3" }))] }), _jsx("button", { type: "button", onClick: () => setDismissedId(integration.id), className: "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground", "aria-label": t("mcpIntegrations.dismissSuggestion"), children: _jsx(IconX, { className: "h-3.5 w-3.5" }) })] }), error && (_jsx("div", { className: "mx-auto mb-2 w-[min(100%,680px)] text-[11px] text-destructive", children: error })), _jsx(McpIntegrationDialog, { open: dialogOpen, onOpenChange: setDialogOpen, initialIntegrationId: integration.id, defaultScope: "user", canCreateOrgMcp: false, hasOrg: Boolean(mcpServersQuery.data?.orgId), onCreateMcpServer: (args) => createMcpServer.mutateAsync(args), onCreated: () => setDismissedId(integration.id) })] }));
126
+ } }))] }), _jsx("span", { className: "min-w-0 flex-1 leading-snug text-foreground", children: t(hasApiFallback(apiFallback)
127
+ ? "mcpIntegrations.connectSuggestionWithApiToken"
128
+ : "mcpIntegrations.connectSuggestion", { name: integration.name }) }), _jsxs("button", { type: "button", onClick: () => void connect(), disabled: connecting, className: "inline-flex shrink-0 items-center gap-1 rounded-md bg-primary px-2.5 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-60", children: [connecting && _jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }), !connecting &&
129
+ canStartOAuth(integration) &&
130
+ !hasApiFallback(apiFallback) && (_jsx(IconPlugConnected, { className: "h-3 w-3" })), !connecting && hasApiFallback(apiFallback) && (_jsx(IconPlugConnected, { className: "h-3 w-3" })), actionLabel, !connecting &&
131
+ !canStartOAuth(integration) &&
132
+ !hasApiFallback(apiFallback) && (_jsx(IconArrowUpRight, { className: "h-3 w-3" }))] }), _jsx("button", { type: "button", onClick: () => setDismissedId(integration.id), className: "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground", "aria-label": t("mcpIntegrations.dismissSuggestion"), children: _jsx(IconX, { className: "h-3.5 w-3.5" }) })] }), error && (_jsx("div", { className: "mx-auto mb-2 w-[min(100%,680px)] text-[11px] text-destructive", children: error })), _jsx(McpIntegrationDialog, { open: dialogOpen, onOpenChange: setDialogOpen, initialIntegrationId: integration.id, defaultScope: "user", canCreateOrgMcp: false, hasOrg: Boolean(mcpServersQuery.data?.orgId), onCreateMcpServer: (args) => createMcpServer.mutateAsync(args), onCreated: () => setDismissedId(integration.id) })] }));
114
133
  }
115
134
  //# sourceMappingURL=McpConnectionSuggestion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpConnectionSuggestion.js","sourceRoot":"","sources":["../../../src/client/resources/McpConnectionSuggestion.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,KAAK,GACN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,yB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AAe,EAAE,KAAK,EACtB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,EAC5C,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,EAC9D,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,GAC/C,IACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconArrowUpRight,\n IconLoader2,\n IconPlugConnected,\n IconX,\n} from \"@tabler/icons-react\";\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { agentNativePath } from \"../api-path.js\";\nimport { useT } from \"../i18n.js\";\nimport {\n buildMcpOAuthStartUrl,\n findMcpIntegrationForText,\n getDefaultMcpIntegrations,\n isMcpConnectionFailureText,\n type DefaultMcpIntegration,\n} from \"./mcp-integration-catalog.js\";\nimport { McpIntegrationDialog } from \"./McpIntegrationDialog.js\";\nimport {\n useCreateMcpServer,\n useMcpServers,\n type McpServer,\n} from \"./use-mcp-servers.js\";\n\nexport type McpConnectionSuggestionVariant = \"composer\" | \"response\";\n\ninterface McpConnectionSuggestionProps {\n text: string;\n contextText?: string;\n variant?: McpConnectionSuggestionVariant;\n}\n\nfunction compareUrl(value: string): string {\n try {\n const url = new URL(value.trim());\n url.hash = \"\";\n return url.toString().replace(/\\/+$/, \"\");\n } catch {\n return value.trim().replace(/\\/+$/, \"\");\n }\n}\n\nfunction isConnected(\n integration: DefaultMcpIntegration,\n servers: McpServer[],\n): boolean {\n const targetUrl = compareUrl(integration.url);\n return servers.some(\n (server) =>\n server.status.state === \"connected\" &&\n compareUrl(server.url) === targetUrl,\n );\n}\n\nfunction returnUrl(): string {\n if (typeof window === \"undefined\") return \"/\";\n return (\n window.location.pathname + window.location.search + window.location.hash\n );\n}\n\nfunction canStartOAuth(integration: DefaultMcpIntegration): boolean {\n return (\n integration.authMode === \"oauth\" &&\n integration.connectionMode === \"oauth\" &&\n integration.availability === \"ready\"\n );\n}\n\nexport function McpConnectionSuggestion({\n text,\n contextText = \"\",\n variant = \"composer\",\n}: McpConnectionSuggestionProps) {\n const t = useT();\n const mcpServersQuery = useMcpServers();\n const createMcpServer = useCreateMcpServer();\n const [dialogOpen, setDialogOpen] = useState(false);\n const [dismissedId, setDismissedId] = useState<string | null>(null);\n const [connecting, setConnecting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const integrations = useMemo(() => getDefaultMcpIntegrations(), []);\n const textIntegration = useMemo(\n () => findMcpIntegrationForText(text, integrations),\n [integrations, text],\n );\n const contextIntegration = useMemo(\n () =>\n contextText ? findMcpIntegrationForText(contextText, integrations) : null,\n [contextText, integrations],\n );\n const integration =\n variant === \"response\" &&\n textIntegration &&\n contextIntegration &&\n textIntegration.id !== contextIntegration.id\n ? null\n : (textIntegration ?? contextIntegration);\n const servers = useMemo(\n () => [\n ...(mcpServersQuery.data?.user ?? []),\n ...(mcpServersQuery.data?.org ?? []),\n ],\n [mcpServersQuery.data],\n );\n const connected = integration ? isConnected(integration, servers) : false;\n const shouldSuggest =\n mcpServersQuery.isSuccess &&\n integration &&\n !connected &&\n dismissedId !== integration.id &&\n (variant === \"composer\" || isMcpConnectionFailureText(text));\n\n useEffect(() => {\n setError(null);\n setConnecting(false);\n }, [integration?.id, variant]);\n\n if (!shouldSuggest) return null;\n\n const connect = async () => {\n if (!integration || connecting) return;\n setError(null);\n\n if (canStartOAuth(integration)) {\n window.location.assign(\n agentNativePath(\n buildMcpOAuthStartUrl({\n name: integration.name,\n url: integration.url,\n description: integration.description,\n scope: \"user\",\n returnUrl: returnUrl(),\n }),\n ),\n );\n return;\n }\n\n if (\n integration.authMode === \"none\" &&\n integration.connectionMode === \"direct\"\n ) {\n setConnecting(true);\n try {\n await createMcpServer.mutateAsync({\n scope: \"user\",\n name: integration.name,\n url: integration.url,\n description: integration.description,\n });\n setDismissedId(integration.id);\n } catch (cause) {\n setError(\n cause instanceof Error ? cause.message : t(\"mcpIntegrations.failed\"),\n );\n } finally {\n setConnecting(false);\n }\n return;\n }\n\n setDialogOpen(true);\n };\n\n const actionLabel = canStartOAuth(integration)\n ? t(\"mcpIntegrations.connectWithOAuth\")\n : integration.availability === \"client-restricted\" ||\n integration.availability === \"provider-setup\"\n ? t(\"mcpIntegrations.viewSetup\")\n : t(\"mcpIntegrations.connect\");\n\n return (\n <>\n <div\n className={\n variant === \"response\"\n ? \"mt-3 flex max-w-[520px] items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[12px]\"\n : \"mx-auto mb-2 flex w-[min(100%,680px)] items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[12px]\"\n }\n data-mcp-connection-suggestion={integration.id}\n >\n <div className=\"relative flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-background text-[10px] font-semibold text-muted-foreground\">\n <span aria-hidden=\"true\">{integration.name.slice(0, 1)}</span>\n {integration.logoUrl && (\n <img\n src={integration.logoUrl}\n alt=\"\"\n className=\"absolute h-5 w-5 object-contain\"\n onError={(event) => {\n event.currentTarget.hidden = true;\n }}\n />\n )}\n </div>\n <span className=\"min-w-0 flex-1 leading-snug text-foreground\">\n {t(\"mcpIntegrations.connectSuggestion\", { name: integration.name })}\n </span>\n <button\n type=\"button\"\n onClick={() => void connect()}\n disabled={connecting}\n className=\"inline-flex shrink-0 items-center gap-1 rounded-md bg-primary px-2.5 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-60\"\n >\n {connecting && <IconLoader2 className=\"h-3 w-3 animate-spin\" />}\n {!connecting && canStartOAuth(integration) && (\n <IconPlugConnected className=\"h-3 w-3\" />\n )}\n {actionLabel}\n {!connecting && !canStartOAuth(integration) && (\n <IconArrowUpRight className=\"h-3 w-3\" />\n )}\n </button>\n <button\n type=\"button\"\n onClick={() => setDismissedId(integration.id)}\n className=\"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground\"\n aria-label={t(\"mcpIntegrations.dismissSuggestion\")}\n >\n <IconX className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n {error && (\n <div className=\"mx-auto mb-2 w-[min(100%,680px)] text-[11px] text-destructive\">\n {error}\n </div>\n )}\n <McpIntegrationDialog\n open={dialogOpen}\n onOpenChange={setDialogOpen}\n initialIntegrationId={integration.id}\n defaultScope=\"user\"\n canCreateOrgMcp={false}\n hasOrg={Boolean(mcpServersQuery.data?.orgId)}\n onCreateMcpServer={(args) => createMcpServer.mutateAsync(args)}\n onCreated={() => setDismissedId(integration.id)}\n />\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"McpConnectionSuggestion.js","sourceRoot":"","sources":["../../../src/client/resources/McpConnectionSuggestion.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,KAAK,GACN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,GAE3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,aAAa,GAEd,MAAM,sBAAsB,CAAC;AAU9B,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAClC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;QACd,OA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,CAAC,CAAC,mCAAmC,CAAC,YAElD,KAAC,KAAK,IAAC,SAAS,EAAC,aAAa,GAAG,GAC1B,IACL,EACL,KAAK,IAAI,CACR,cAAK,SAAS,EAAC,+DAA+D,YAC3E,KAAK,GACF,CACP,EACD,KAAC,oBAAoB,IACnB,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,aAAa,EAC3B,oBAAoB,EAAE,WAAW,CAAC,EAAE,EACpC,YAAY,EAAC,MAAM,EACnB,eAAe,EAAE,KAAK,EACtB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,EAC5C,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,EAC9D,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,GAC/C,IACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconArrowUpRight,\n IconLoader2,\n IconPlugConnected,\n IconX,\n} from \"@tabler/icons-react\";\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { agentNativePath } from \"../api-path.js\";\nimport { openAgentSettings } from \"../CommandMenu.js\";\nimport { useT } from \"../i18n.js\";\nimport {\n buildMcpOAuthStartUrl,\n findMcpIntegrationForText,\n getMcpIntegrationApiFallback,\n getDefaultMcpIntegrations,\n isMcpConnectionFailureText,\n type DefaultMcpIntegration,\n} from \"./mcp-integration-catalog.js\";\nimport { McpIntegrationDialog } from \"./McpIntegrationDialog.js\";\nimport {\n useCreateMcpServer,\n useMcpServers,\n type McpServer,\n} from \"./use-mcp-servers.js\";\n\nexport type McpConnectionSuggestionVariant = \"composer\" | \"response\";\n\ninterface McpConnectionSuggestionProps {\n text: string;\n contextText?: string;\n variant?: McpConnectionSuggestionVariant;\n}\n\nfunction compareUrl(value: string): string {\n try {\n const url = new URL(value.trim());\n url.hash = \"\";\n return url.toString().replace(/\\/+$/, \"\");\n } catch {\n return value.trim().replace(/\\/+$/, \"\");\n }\n}\n\nfunction isConnected(\n integration: DefaultMcpIntegration,\n servers: McpServer[],\n): boolean {\n const targetUrl = compareUrl(integration.url);\n return servers.some(\n (server) =>\n server.status.state === \"connected\" &&\n compareUrl(server.url) === targetUrl,\n );\n}\n\nfunction returnUrl(): string {\n if (typeof window === \"undefined\") return \"/\";\n return (\n window.location.pathname + window.location.search + window.location.hash\n );\n}\n\nfunction canStartOAuth(integration: DefaultMcpIntegration): boolean {\n return (\n integration.authMode === \"oauth\" &&\n integration.connectionMode === \"oauth\" &&\n integration.availability === \"ready\"\n );\n}\n\nfunction hasApiFallback(\n apiFallback: DefaultMcpIntegration[\"apiFallback\"] | null,\n): boolean {\n return Boolean(apiFallback);\n}\n\nexport function McpConnectionSuggestion({\n text,\n contextText = \"\",\n variant = \"composer\",\n}: McpConnectionSuggestionProps) {\n const t = useT();\n const mcpServersQuery = useMcpServers();\n const createMcpServer = useCreateMcpServer();\n const [dialogOpen, setDialogOpen] = useState(false);\n const [dismissedId, setDismissedId] = useState<string | null>(null);\n const [connecting, setConnecting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const integrations = useMemo(() => getDefaultMcpIntegrations(), []);\n const textIntegration = useMemo(\n () => findMcpIntegrationForText(text, integrations),\n [integrations, text],\n );\n const contextIntegration = useMemo(\n () =>\n contextText ? findMcpIntegrationForText(contextText, integrations) : null,\n [contextText, integrations],\n );\n const integration =\n variant === \"response\" &&\n textIntegration &&\n contextIntegration &&\n textIntegration.id !== contextIntegration.id\n ? null\n : (textIntegration ?? contextIntegration);\n const apiFallback = integration\n ? getMcpIntegrationApiFallback(integration)\n : null;\n const servers = useMemo(\n () => [\n ...(mcpServersQuery.data?.user ?? []),\n ...(mcpServersQuery.data?.org ?? []),\n ],\n [mcpServersQuery.data],\n );\n const connected = integration ? isConnected(integration, servers) : false;\n const shouldSuggest =\n mcpServersQuery.isSuccess &&\n integration &&\n !connected &&\n dismissedId !== integration.id &&\n (variant === \"composer\" || isMcpConnectionFailureText(text));\n\n useEffect(() => {\n setError(null);\n setConnecting(false);\n }, [integration?.id, variant]);\n\n if (!shouldSuggest) return null;\n\n const connect = async () => {\n if (!integration || connecting) return;\n setError(null);\n\n if (apiFallback) {\n openAgentSettings(`secrets:${apiFallback.secretKey}`);\n return;\n }\n\n if (canStartOAuth(integration)) {\n window.location.assign(\n agentNativePath(\n buildMcpOAuthStartUrl({\n name: integration.name,\n url: integration.url,\n description: integration.description,\n scope: \"user\",\n returnUrl: returnUrl(),\n }),\n ),\n );\n return;\n }\n\n if (\n integration.authMode === \"none\" &&\n integration.connectionMode === \"direct\"\n ) {\n setConnecting(true);\n try {\n await createMcpServer.mutateAsync({\n scope: \"user\",\n name: integration.name,\n url: integration.url,\n description: integration.description,\n });\n setDismissedId(integration.id);\n } catch (cause) {\n setError(\n cause instanceof Error ? cause.message : t(\"mcpIntegrations.failed\"),\n );\n } finally {\n setConnecting(false);\n }\n return;\n }\n\n setDialogOpen(true);\n };\n\n const actionLabel = hasApiFallback(apiFallback)\n ? t(\"mcpIntegrations.useApiToken\")\n : canStartOAuth(integration)\n ? t(\"mcpIntegrations.connectWithOAuth\")\n : integration.availability === \"client-restricted\" ||\n integration.availability === \"provider-setup\"\n ? t(\"mcpIntegrations.viewSetup\")\n : t(\"mcpIntegrations.connect\");\n\n return (\n <>\n <div\n className={\n variant === \"response\"\n ? \"mt-3 flex max-w-[520px] items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[12px]\"\n : \"mx-auto mb-2 flex w-[min(100%,680px)] items-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[12px]\"\n }\n data-mcp-connection-suggestion={integration.id}\n >\n <div className=\"relative flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-background text-[10px] font-semibold text-muted-foreground\">\n <span aria-hidden=\"true\">{integration.name.slice(0, 1)}</span>\n {integration.logoUrl && (\n <img\n src={integration.logoUrl}\n alt=\"\"\n className=\"absolute h-5 w-5 object-contain\"\n onError={(event) => {\n event.currentTarget.hidden = true;\n }}\n />\n )}\n </div>\n <span className=\"min-w-0 flex-1 leading-snug text-foreground\">\n {t(\n hasApiFallback(apiFallback)\n ? \"mcpIntegrations.connectSuggestionWithApiToken\"\n : \"mcpIntegrations.connectSuggestion\",\n { name: integration.name },\n )}\n </span>\n <button\n type=\"button\"\n onClick={() => void connect()}\n disabled={connecting}\n className=\"inline-flex shrink-0 items-center gap-1 rounded-md bg-primary px-2.5 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-60\"\n >\n {connecting && <IconLoader2 className=\"h-3 w-3 animate-spin\" />}\n {!connecting &&\n canStartOAuth(integration) &&\n !hasApiFallback(apiFallback) && (\n <IconPlugConnected className=\"h-3 w-3\" />\n )}\n {!connecting && hasApiFallback(apiFallback) && (\n <IconPlugConnected className=\"h-3 w-3\" />\n )}\n {actionLabel}\n {!connecting &&\n !canStartOAuth(integration) &&\n !hasApiFallback(apiFallback) && (\n <IconArrowUpRight className=\"h-3 w-3\" />\n )}\n </button>\n <button\n type=\"button\"\n onClick={() => setDismissedId(integration.id)}\n className=\"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-background hover:text-foreground\"\n aria-label={t(\"mcpIntegrations.dismissSuggestion\")}\n >\n <IconX className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n {error && (\n <div className=\"mx-auto mb-2 w-[min(100%,680px)] text-[11px] text-destructive\">\n {error}\n </div>\n )}\n <McpIntegrationDialog\n open={dialogOpen}\n onOpenChange={setDialogOpen}\n initialIntegrationId={integration.id}\n defaultScope=\"user\"\n canCreateOrgMcp={false}\n hasOrg={Boolean(mcpServersQuery.data?.orgId)}\n onCreateMcpServer={(args) => createMcpServer.mutateAsync(args)}\n onCreated={() => setDismissedId(integration.id)}\n />\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"McpIntegrationDialog.d.ts","sourceRoot":"","sources":["../../../src/client/resources/McpIntegrationDialog.tsx"],"names":[],"mappings":"AAkCA,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAI9B,UAAU,yBAAyB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,cAAc,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAgCD,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,oBAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,SAAS,GACV,EAAE,yBAAyB,sCAirB3B"}
1
+ {"version":3,"file":"McpIntegrationDialog.d.ts","sourceRoot":"","sources":["../../../src/client/resources/McpIntegrationDialog.tsx"],"names":[],"mappings":"AAoCA,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAI9B,UAAU,yBAAyB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,YAAY,EAAE,cAAc,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAgCD,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,oBAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,SAAS,GACV,EAAE,yBAAyB,sCAisB3B"}
@@ -3,11 +3,12 @@ import { IconArrowLeft, IconCheck, IconExternalLink, IconLoader2, IconSearch, }
3
3
  import { useEffect, useMemo, useRef, useState } from "react";
4
4
  import { AgentAskPopover } from "../AgentAskPopover.js";
5
5
  import { agentNativePath } from "../api-path.js";
6
+ import { openAgentSettings } from "../CommandMenu.js";
6
7
  import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "../components/ui/dialog.js";
7
8
  import { Tooltip, TooltipContent, TooltipTrigger, } from "../components/ui/tooltip.js";
8
9
  import { useT } from "../i18n.js";
9
10
  import { cn } from "../utils.js";
10
- import { buildMcpOAuthStartUrl, createMcpIntegrationFormDefaults, filterMcpIntegrations, getDefaultMcpIntegrations, isCustomMcpIntegrationEnabled, resolveMcpIntegrationScope, } from "./mcp-integration-catalog.js";
11
+ import { buildMcpOAuthStartUrl, createMcpIntegrationFormDefaults, filterMcpIntegrations, getMcpIntegrationApiFallback, getDefaultMcpIntegrations, isCustomMcpIntegrationEnabled, resolveMcpIntegrationScope, } from "./mcp-integration-catalog.js";
11
12
  import { formatMcpServerError, getMcpUrlValidationError, testMcpServerUrl, useMcpServers, } from "./use-mcp-servers.js";
12
13
  function parseHeaderLines(text) {
13
14
  const out = {};
@@ -261,6 +262,7 @@ export function McpIntegrationDialog({ open, onOpenChange, initialIntegrationId
261
262
  if (!showCatalog && !customIntegrationEnabled)
262
263
  return null;
263
264
  return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { className: "flex max-h-[min(820px,calc(100vh-32px))] w-[calc(100vw-24px)] max-w-[760px] flex-col gap-0 p-0 sm:w-[min(760px,calc(100vw-48px))]", children: mode === "catalog" ? (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { className: "shrink-0 px-7 pb-5 pe-14 pt-6", children: [_jsx(DialogTitle, { children: t("mcpIntegrations.title") }), _jsx(DialogDescription, { children: t("mcpIntegrations.description") })] }), _jsxs("div", { className: "flex shrink-0 flex-col gap-3 px-7 pb-5 sm:flex-row", children: [_jsxs("label", { className: "relative min-w-0 flex-1", children: [_jsx(IconSearch, { className: "pointer-events-none absolute start-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }), _jsx("input", { value: query, onChange: (event) => setQuery(event.target.value), className: "h-9 w-full rounded-md border border-border bg-background pe-3 ps-8 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring", placeholder: t("mcpIntegrations.searchPlaceholder") })] }), _jsx("button", { type: "button", onClick: () => openForm(null), className: cn("inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-3 text-[12px] font-medium text-foreground hover:bg-accent", !customIntegrationEnabled && "hidden"), children: t("mcpIntegrations.addYourOwn") }), _jsx(AgentAskPopover, { label: t("mcpIntegrations.addSomething"), title: t("mcpIntegrations.addSomethingTitle"), placeholder: t("mcpIntegrations.addSomethingPlaceholder"), prompt: "", context: "The user wants to add an MCP or provider integration that is not in the current directory. Research the provider's official remote MCP endpoint and OAuth, client-registration, or allowlist requirements. Prefer Streamable HTTP endpoints over legacy SSE, reuse an existing provider OAuth connector when appropriate, and never ask the user to paste credentials into a prompt. If this should become a reusable preset, update the integration catalog, official docs link, bundled logo, localization, and tests.", className: "h-9 whitespace-nowrap border-dashed px-3 text-[12px] font-medium" })] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto px-7 pb-7", children: [error && (_jsx("div", { className: "mb-3 rounded-md border border-red-500/20 bg-red-500/5 px-3 py-2 text-[12px] leading-relaxed text-red-600 dark:text-red-400", children: error })), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: filteredIntegrations.map((integration) => {
265
+ const apiFallback = getMcpIntegrationApiFallback(integration);
264
266
  const connected = connectedUrls.has(compareUrl(integration.url));
265
267
  const requiresHeaders = integration.authMode === "headers";
266
268
  const setupOnly = integration.connectionMode === "manual" ||
@@ -277,7 +279,7 @@ export function McpIntegrationDialog({ open, onOpenChange, initialIntegrationId
277
279
  ? t("mcpIntegrations.status.verified")
278
280
  : integration.verification === "restricted"
279
281
  ? t("mcpIntegrations.status.restricted")
280
- : t("mcpIntegrations.status.preflightOnly") })] })] }), _jsx("p", { className: "mt-1 line-clamp-2 flex-1 text-[12px] leading-relaxed text-muted-foreground", children: t(integration.descriptionKey) }), integration.setupNoteKey && (_jsx("p", { className: "mt-2 line-clamp-3 text-[10px] leading-relaxed text-amber-700 dark:text-amber-300", children: t(integration.setupNoteKey) })), _jsxs("div", { className: "mt-3 flex items-center gap-2", children: [connected ? (_jsx("button", { type: "button", disabled: true, className: "inline-flex h-8 flex-1 cursor-not-allowed items-center justify-center gap-1.5 rounded-md border border-border bg-muted px-2.5 text-[12px] font-medium text-muted-foreground opacity-70", children: t("mcpIntegrations.connected") })) : setupOnly ? (_jsxs("a", { href: integration.docsUrl, target: "_blank", rel: "noopener noreferrer", className: "inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-[12px] font-medium text-foreground hover:bg-accent", children: [t("mcpIntegrations.viewSetup"), _jsx(IconExternalLink, { className: "h-3.5 w-3.5" })] })) : (_jsxs("button", { type: "button", onClick: () => quickConnect(integration), disabled: busy, className: cn("inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90", busy && "cursor-not-allowed opacity-70"), children: [quickBusyId === integration.id ? (_jsx(IconLoader2, { className: "h-3.5 w-3.5 animate-spin" })) : null, integration.authMode === "oauth"
282
+ : t("mcpIntegrations.status.preflightOnly") })] })] }), _jsx("p", { className: "mt-1 line-clamp-2 flex-1 text-[12px] leading-relaxed text-muted-foreground", children: t(integration.descriptionKey) }), integration.setupNoteKey && (_jsx("p", { className: "mt-2 line-clamp-3 text-[10px] leading-relaxed text-amber-700 dark:text-amber-300", children: t(integration.setupNoteKey) })), _jsxs("div", { className: "mt-3 flex items-center gap-2", children: [connected ? (_jsx("button", { type: "button", disabled: true, className: "inline-flex h-8 flex-1 cursor-not-allowed items-center justify-center gap-1.5 rounded-md border border-border bg-muted px-2.5 text-[12px] font-medium text-muted-foreground opacity-70", children: t("mcpIntegrations.connected") })) : setupOnly ? (_jsxs(_Fragment, { children: [apiFallback && (_jsx("button", { type: "button", onClick: () => openAgentSettings(`secrets:${apiFallback.secretKey}`), className: "inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90", children: t("mcpIntegrations.useApiToken") })), _jsxs("a", { href: integration.docsUrl, target: "_blank", rel: "noopener noreferrer", className: "inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-[12px] font-medium text-foreground hover:bg-accent", children: [t("mcpIntegrations.viewSetup"), _jsx(IconExternalLink, { className: "h-3.5 w-3.5" })] })] })) : (_jsxs("button", { type: "button", onClick: () => quickConnect(integration), disabled: busy, className: cn("inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90", busy && "cursor-not-allowed opacity-70"), children: [quickBusyId === integration.id ? (_jsx(IconLoader2, { className: "h-3.5 w-3.5 animate-spin" })) : null, integration.authMode === "oauth"
281
283
  ? t("mcpIntegrations.connectWithOAuth")
282
284
  : requiresHeaders
283
285
  ? t("mcpIntegrations.configure")
@@ -1 +1 @@
1
- {"version":3,"file":"McpIntegrationDialog.js","sourceRoot":"","sources":["../../../src/client/resources/McpIntegrationDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,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AAqN,aAE9N,IAAI,IAAI,KAAC,WAAW,IAAC,SAAS,EAAC,0BAA0B,GAAG,EAC5D,CAAC,CAAC,yBAAyB,CAAC,IACtB,CACV,IACG,IACL,CACJ,GACa,GACT,CACV,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconArrowLeft,\n IconCheck,\n IconExternalLink,\n IconLoader2,\n IconSearch,\n} from \"@tabler/icons-react\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { AgentAskPopover } from \"../AgentAskPopover.js\";\nimport { agentNativePath } from \"../api-path.js\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"../components/ui/dialog.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { useT } from \"../i18n.js\";\nimport { cn } from \"../utils.js\";\nimport {\n buildMcpOAuthStartUrl,\n createMcpIntegrationFormDefaults,\n filterMcpIntegrations,\n getDefaultMcpIntegrations,\n isCustomMcpIntegrationEnabled,\n resolveMcpIntegrationScope,\n type DefaultMcpIntegration,\n} from \"./mcp-integration-catalog.js\";\nimport {\n formatMcpServerError,\n getMcpUrlValidationError,\n testMcpServerUrl,\n useMcpServers,\n type CreateMcpServerArgs,\n type McpServerScope,\n} from \"./use-mcp-servers.js\";\n\ntype DialogMode = \"catalog\" | \"form\";\n\ninterface McpIntegrationDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n initialIntegrationId?: string | null;\n defaultScope: McpServerScope;\n canCreateOrgMcp: boolean;\n hasOrg: boolean;\n onCreateMcpServer: (args: CreateMcpServerArgs) => Promise<unknown>;\n onCreated?: () => void;\n}\n\ninterface TestResult {\n ok: boolean;\n message: string;\n}\n\nfunction parseHeaderLines(text: string): Record<string, string> | undefined {\n const out: Record<string, string> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const idx = trimmed.indexOf(\":\");\n if (idx <= 0) continue;\n const key = trimmed.slice(0, idx).trim();\n const value = trimmed.slice(idx + 1).trim();\n if (!key || !value) continue;\n out[key] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction compareUrl(value: string): string {\n try {\n const url = new URL(value.trim());\n url.hash = \"\";\n return url.toString().replace(/\\/+$/, \"\");\n } catch {\n return value.trim().replace(/\\/+$/, \"\");\n }\n}\n\nexport function McpIntegrationDialog({\n open,\n onOpenChange,\n initialIntegrationId = null,\n defaultScope,\n canCreateOrgMcp,\n hasOrg,\n onCreateMcpServer,\n onCreated,\n}: McpIntegrationDialogProps) {\n const t = useT();\n const [mode, setMode] = useState<DialogMode>(\"catalog\");\n const [query, setQuery] = useState(\"\");\n const [selected, setSelected] = useState<DefaultMcpIntegration | null>(null);\n const safeDefaultScope = resolveMcpIntegrationScope(\n defaultScope,\n hasOrg,\n canCreateOrgMcp,\n );\n const [scope, setScope] = useState<McpServerScope>(safeDefaultScope);\n const [name, setName] = useState(\"\");\n const [url, setUrl] = useState(\"\");\n const [description, setDescription] = useState(\"\");\n const [headersText, setHeadersText] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const [quickBusyId, setQuickBusyId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n const [testResult, setTestResult] = useState<TestResult | null>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const mcpServersQuery = useMcpServers();\n const defaultIntegrations = useMemo(() => getDefaultMcpIntegrations(), []);\n const customIntegrationEnabled = useMemo(\n () => isCustomMcpIntegrationEnabled(),\n [],\n );\n const showCatalog = defaultIntegrations.length > 0;\n\n const connectedUrls = useMemo(() => {\n const servers = [\n ...(mcpServersQuery.data?.user ?? []),\n ...(mcpServersQuery.data?.org ?? []),\n ];\n // A saved server is not necessarily a working connection. The settings\n // page reports failed and unknown health states separately, so only mark\n // catalog entries as connected after the health probe succeeds.\n return new Set(\n servers\n .filter((server) => server.status.state === \"connected\")\n .map((server) => compareUrl(server.url)),\n );\n }, [mcpServersQuery.data]);\n\n const filteredIntegrations = useMemo(\n () => filterMcpIntegrations(query, defaultIntegrations),\n [defaultIntegrations, query],\n );\n\n const selectedRequiresSetup = Boolean(\n selected &&\n (selected.connectionMode === \"manual\" ||\n selected.availability === \"provider-setup\" ||\n selected.availability === \"client-restricted\"),\n );\n\n useEffect(() => {\n if (!open) return;\n const initialIntegration = initialIntegrationId\n ? defaultIntegrations.find(\n (integration) => integration.id === initialIntegrationId,\n )\n : null;\n const initialDefaults =\n createMcpIntegrationFormDefaults(initialIntegration);\n setMode(initialIntegration || !showCatalog ? \"form\" : \"catalog\");\n setQuery(\"\");\n setSelected(initialIntegration ?? null);\n setScope(safeDefaultScope);\n setName(initialDefaults.name);\n setUrl(initialDefaults.url);\n setDescription(initialDefaults.description);\n setHeadersText(initialDefaults.headersText);\n setBusy(false);\n setQuickBusyId(null);\n setError(null);\n setTestResult(null);\n }, [\n defaultIntegrations,\n initialIntegrationId,\n open,\n safeDefaultScope,\n showCatalog,\n ]);\n\n useEffect(() => {\n if (open && mode === \"form\") {\n const timer = window.setTimeout(() => inputRef.current?.focus(), 60);\n return () => window.clearTimeout(timer);\n }\n }, [mode, open]);\n\n const clearFeedback = () => {\n setError(null);\n setTestResult(null);\n };\n\n const openForm = (integration?: DefaultMcpIntegration | null) => {\n const defaults = createMcpIntegrationFormDefaults(integration);\n setSelected(integration ?? null);\n setScope(safeDefaultScope);\n setName(defaults.name);\n setUrl(defaults.url);\n setDescription(defaults.description);\n setHeadersText(defaults.headersText);\n setError(null);\n setTestResult(null);\n setMode(\"form\");\n };\n\n const beginOAuth = (args: {\n name: string;\n url: string;\n description: string;\n }) => {\n const validationError = getMcpUrlValidationError(args.url);\n if (validationError) {\n setError(validationError);\n setTestResult(null);\n return;\n }\n const returnUrl =\n typeof window === \"undefined\"\n ? \"/\"\n : window.location.pathname +\n window.location.search +\n window.location.hash;\n window.location.assign(\n agentNativePath(\n buildMcpOAuthStartUrl({\n name: args.name,\n url: args.url,\n description: args.description,\n scope: safeDefaultScope,\n returnUrl,\n }),\n ),\n );\n };\n\n const connectWithOAuth = (integration: DefaultMcpIntegration) =>\n beginOAuth({\n name: integration.name,\n url: integration.url,\n description: integration.description,\n });\n\n const connectCustomWithOAuth = () => {\n if (!name.trim()) {\n setError(t(\"mcpIntegrations.serverNameRequired\"));\n return;\n }\n beginOAuth({\n name: name.trim(),\n url: url.trim(),\n description: description.trim(),\n });\n };\n\n const createServer = async (\n args: CreateMcpServerArgs,\n options?: { quickId?: string },\n ) => {\n const validationError = getMcpUrlValidationError(args.url);\n if (validationError) {\n setError(validationError);\n setTestResult(null);\n return;\n }\n\n if (options?.quickId) setQuickBusyId(options.quickId);\n setBusy(true);\n setError(null);\n try {\n await onCreateMcpServer(args);\n onOpenChange(false);\n onCreated?.();\n } catch (err) {\n setError(formatMcpServerError(err));\n } finally {\n setBusy(false);\n setQuickBusyId(null);\n }\n };\n\n const submitForm = () => {\n const trimmedName = name.trim();\n const trimmedUrl = url.trim();\n if (!trimmedName || !trimmedUrl || busy) return;\n void createServer({\n scope,\n name: trimmedName,\n url: trimmedUrl,\n headers: parseHeaderLines(headersText),\n description: description.trim() || undefined,\n });\n };\n\n const quickConnect = (integration: DefaultMcpIntegration) => {\n if (\n integration.connectionMode === \"manual\" ||\n integration.availability === \"provider-setup\"\n ) {\n return;\n }\n if (integration.authMode === \"oauth\") {\n connectWithOAuth(integration);\n return;\n }\n if (integration.authMode === \"headers\") {\n openForm(integration);\n return;\n }\n void createServer(\n {\n scope: safeDefaultScope,\n name: integration.name,\n url: integration.url,\n description: integration.description,\n },\n { quickId: integration.id },\n );\n };\n\n const runTest = async () => {\n const trimmedUrl = url.trim();\n if (!trimmedUrl || busy) return;\n const validationError = getMcpUrlValidationError(trimmedUrl);\n if (validationError) {\n setTestResult({ ok: false, message: validationError });\n setError(null);\n return;\n }\n setBusy(true);\n setError(null);\n setTestResult(null);\n try {\n const res = await testMcpServerUrl(\n trimmedUrl,\n parseHeaderLines(headersText),\n );\n setTestResult(\n res.ok\n ? {\n ok: true,\n message: t(\"mcpIntegrations.toolsAvailable\", {\n count: res.toolCount ?? 0,\n }),\n }\n : { ok: false, message: res.error ?? t(\"mcpIntegrations.failed\") },\n );\n } catch (err) {\n setTestResult({ ok: false, message: formatMcpServerError(err) });\n } finally {\n setBusy(false);\n }\n };\n\n const renderScopeSelector = () => {\n const orgTooltip = !hasOrg\n ? t(\"mcpIntegrations.orgNoOrg\")\n : !canCreateOrgMcp\n ? t(\"mcpIntegrations.orgAdminOnly\")\n : null;\n\n return (\n <div className=\"flex gap-1 rounded-md border border-border bg-background p-0.5\">\n <button\n type=\"button\"\n onClick={() => setScope(\"user\")}\n className={cn(\n \"flex-1 rounded px-2 py-1.5 text-[11px] font-medium\",\n scope === \"user\"\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\",\n )}\n >\n {t(\"mcpIntegrations.personal\")}\n </button>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => hasOrg && canCreateOrgMcp && setScope(\"org\")}\n disabled={!hasOrg || !canCreateOrgMcp}\n className={cn(\n \"flex-1 rounded px-2 py-1.5 text-[11px] font-medium\",\n scope === \"org\"\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\",\n (!hasOrg || !canCreateOrgMcp) &&\n \"cursor-not-allowed opacity-50 hover:text-muted-foreground\",\n )}\n >\n {t(\"mcpIntegrations.organization\")}\n </button>\n </TooltipTrigger>\n {orgTooltip && <TooltipContent>{orgTooltip}</TooltipContent>}\n </Tooltip>\n </div>\n );\n };\n\n if (!showCatalog && !customIntegrationEnabled) return null;\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"flex max-h-[min(820px,calc(100vh-32px))] w-[calc(100vw-24px)] max-w-[760px] flex-col gap-0 p-0 sm:w-[min(760px,calc(100vw-48px))]\">\n {mode === \"catalog\" ? (\n <>\n <DialogHeader className=\"shrink-0 px-7 pb-5 pe-14 pt-6\">\n <DialogTitle>{t(\"mcpIntegrations.title\")}</DialogTitle>\n <DialogDescription>\n {t(\"mcpIntegrations.description\")}\n </DialogDescription>\n </DialogHeader>\n <div className=\"flex shrink-0 flex-col gap-3 px-7 pb-5 sm:flex-row\">\n <label className=\"relative min-w-0 flex-1\">\n <IconSearch className=\"pointer-events-none absolute start-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground\" />\n <input\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n className=\"h-9 w-full rounded-md border border-border bg-background pe-3 ps-8 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.searchPlaceholder\")}\n />\n </label>\n <button\n type=\"button\"\n onClick={() => openForm(null)}\n className={cn(\n \"inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-3 text-[12px] font-medium text-foreground hover:bg-accent\",\n !customIntegrationEnabled && \"hidden\",\n )}\n >\n {t(\"mcpIntegrations.addYourOwn\")}\n </button>\n <AgentAskPopover\n label={t(\"mcpIntegrations.addSomething\")}\n title={t(\"mcpIntegrations.addSomethingTitle\")}\n placeholder={t(\"mcpIntegrations.addSomethingPlaceholder\")}\n prompt=\"\"\n context=\"The user wants to add an MCP or provider integration that is not in the current directory. Research the provider's official remote MCP endpoint and OAuth, client-registration, or allowlist requirements. Prefer Streamable HTTP endpoints over legacy SSE, reuse an existing provider OAuth connector when appropriate, and never ask the user to paste credentials into a prompt. If this should become a reusable preset, update the integration catalog, official docs link, bundled logo, localization, and tests.\"\n className=\"h-9 whitespace-nowrap border-dashed px-3 text-[12px] font-medium\"\n />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-7 pb-7\">\n {error && (\n <div className=\"mb-3 rounded-md border border-red-500/20 bg-red-500/5 px-3 py-2 text-[12px] leading-relaxed text-red-600 dark:text-red-400\">\n {error}\n </div>\n )}\n <div className=\"grid gap-3 sm:grid-cols-2\">\n {filteredIntegrations.map((integration) => {\n const connected = connectedUrls.has(\n compareUrl(integration.url),\n );\n const requiresHeaders = integration.authMode === \"headers\";\n const setupOnly =\n integration.connectionMode === \"manual\" ||\n integration.availability === \"provider-setup\" ||\n integration.availability === \"client-restricted\";\n return (\n <article\n key={integration.id}\n className=\"flex min-h-[128px] flex-col rounded-md border border-border bg-card p-4 transition-colors hover:border-border/80 hover:bg-accent/20\"\n >\n <div className=\"flex items-center gap-3\">\n <div className=\"relative flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-background text-[11px] font-semibold text-muted-foreground\">\n <span aria-hidden=\"true\">\n {integration.name.slice(0, 1)}\n </span>\n <img\n src={integration.logoUrl}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"absolute inset-1 h-6 w-6 object-contain\"\n onError={(event) => {\n event.currentTarget.hidden = true;\n }}\n />\n </div>\n <div className=\"min-w-0\">\n <h3 className=\"truncate text-[13px] font-semibold text-foreground\">\n {integration.name}\n </h3>\n {integration.availability !== \"ready\" && (\n <span className=\"mt-0.5 inline-flex rounded-full border border-amber-500/20 bg-amber-500/5 px-1.5 py-0.5 text-[9px] font-medium text-amber-700 dark:text-amber-300\">\n {integration.availability === \"beta\"\n ? t(\"mcpIntegrations.status.beta\")\n : integration.availability ===\n \"client-restricted\"\n ? t(\"mcpIntegrations.status.clientRestricted\")\n : t(\"mcpIntegrations.status.setupRequired\")}\n </span>\n )}\n <span className=\"ms-1 mt-0.5 inline-flex rounded-full border border-border/70 bg-muted/40 px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground\">\n {integration.verification === \"verified\"\n ? t(\"mcpIntegrations.status.verified\")\n : integration.verification === \"restricted\"\n ? t(\"mcpIntegrations.status.restricted\")\n : t(\"mcpIntegrations.status.preflightOnly\")}\n </span>\n </div>\n </div>\n <p className=\"mt-1 line-clamp-2 flex-1 text-[12px] leading-relaxed text-muted-foreground\">\n {t(integration.descriptionKey)}\n </p>\n {integration.setupNoteKey && (\n <p className=\"mt-2 line-clamp-3 text-[10px] leading-relaxed text-amber-700 dark:text-amber-300\">\n {t(integration.setupNoteKey)}\n </p>\n )}\n <div className=\"mt-3 flex items-center gap-2\">\n {connected ? (\n <button\n type=\"button\"\n disabled\n className=\"inline-flex h-8 flex-1 cursor-not-allowed items-center justify-center gap-1.5 rounded-md border border-border bg-muted px-2.5 text-[12px] font-medium text-muted-foreground opacity-70\"\n >\n {t(\"mcpIntegrations.connected\")}\n </button>\n ) : setupOnly ? (\n <a\n href={integration.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-[12px] font-medium text-foreground hover:bg-accent\"\n >\n {t(\"mcpIntegrations.viewSetup\")}\n <IconExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={() => quickConnect(integration)}\n disabled={busy}\n className={cn(\n \"inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90\",\n busy && \"cursor-not-allowed opacity-70\",\n )}\n >\n {quickBusyId === integration.id ? (\n <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" />\n ) : null}\n {integration.authMode === \"oauth\"\n ? t(\"mcpIntegrations.connectWithOAuth\")\n : requiresHeaders\n ? t(\"mcpIntegrations.configure\")\n : t(\"mcpIntegrations.connect\")}\n </button>\n )}\n {integration.docsUrl && (\n <Tooltip>\n <TooltipTrigger asChild>\n <a\n href={integration.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground hover:bg-accent hover:text-foreground\"\n aria-label={t(\"mcpIntegrations.docsLabel\", {\n name: integration.name,\n })}\n >\n <IconExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </TooltipTrigger>\n <TooltipContent>\n {t(\"mcpIntegrations.docsLabel\", {\n name: integration.name,\n })}\n </TooltipContent>\n </Tooltip>\n )}\n </div>\n </article>\n );\n })}\n </div>\n {filteredIntegrations.length === 0 && (\n <div className=\"rounded-md border border-dashed border-border p-6 text-center text-[12px] text-muted-foreground\">\n {t(\"mcpIntegrations.noMatches\")}\n </div>\n )}\n </div>\n </>\n ) : (\n <>\n <DialogHeader className=\"shrink-0 border-b border-border px-7 pb-5 pe-14 pt-6\">\n <button\n type=\"button\"\n onClick={() => {\n clearFeedback();\n setMode(\"catalog\");\n }}\n className={cn(\n \"mb-1 inline-flex w-fit items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground\",\n !showCatalog && \"hidden\",\n )}\n >\n <IconArrowLeft className=\"h-3 w-3 rtl:-scale-x-100\" />\n {t(\"mcpIntegrations.backToIntegrations\")}\n </button>\n <DialogTitle>\n {selected\n ? t(\"mcpIntegrations.configureTitle\", {\n name: selected.name,\n })\n : t(\"mcpIntegrations.customTitle\")}\n </DialogTitle>\n <DialogDescription>\n {selected\n ? selected.authMode === \"none\"\n ? t(\"mcpIntegrations.presetNoAuthDescription\")\n : t(\"mcpIntegrations.presetAuthDescription\")\n : t(\"mcpIntegrations.customDescription\")}\n </DialogDescription>\n </DialogHeader>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-7 py-5\">\n <div className=\"space-y-3\">\n {renderScopeSelector()}\n {selected?.setupNoteKey && (\n <div className=\"rounded-md border border-amber-500/20 bg-amber-500/5 px-3 py-2 text-[11px] leading-relaxed text-amber-700 dark:text-amber-300\">\n {t(selected.setupNoteKey)}\n </div>\n )}\n {selected?.authMode === \"oauth\" && (\n <div className=\"rounded-md border border-blue-500/20 bg-blue-500/5 px-3 py-2 text-[11px] leading-relaxed text-blue-700 dark:text-blue-300\">\n {t(\"mcpIntegrations.oauthNotice\")}\n </div>\n )}\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.serverName\")}\n </span>\n <input\n ref={inputRef}\n value={name}\n onChange={(event) => {\n setName(event.target.value);\n clearFeedback();\n }}\n className=\"w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.serverNamePlaceholder\")}\n />\n </label>\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.url\")}\n </span>\n <input\n value={url}\n onChange={(event) => {\n setUrl(event.target.value);\n clearFeedback();\n }}\n className=\"w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.urlPlaceholder\")}\n />\n </label>\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.fieldDescription\")}\n </span>\n <input\n value={description}\n onChange={(event) => {\n setDescription(event.target.value);\n clearFeedback();\n }}\n className=\"w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.descriptionPlaceholder\")}\n />\n </label>\n {selected?.authMode !== \"oauth\" && (\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.headers\")}\n </span>\n <textarea\n value={headersText}\n onChange={(event) => {\n setHeadersText(event.target.value);\n clearFeedback();\n }}\n rows={3}\n className=\"w-full resize-y rounded-md border border-border bg-background px-2.5 py-1.5 text-[12px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n style={{\n fontFamily:\n 'ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, monospace',\n }}\n placeholder={\n selected?.headerPlaceholder ??\n t(\"mcpIntegrations.headersPlaceholder\")\n }\n />\n </label>\n )}\n {selected?.docsUrl && (\n <a\n href={selected.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1 text-[11px] text-muted-foreground underline hover:text-foreground\"\n >\n {t(\"mcpIntegrations.openSetupDocs\")}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n )}\n {testResult && (\n <div\n className={cn(\n \"flex items-start gap-1 rounded-md px-3 py-2 text-[11px] leading-snug\",\n testResult.ok\n ? \"bg-green-500/5 text-green-600 dark:text-green-400\"\n : \"bg-red-500/5 text-red-600 dark:text-red-400\",\n )}\n >\n {testResult.ok && (\n <IconCheck className=\"mt-0.5 h-3 w-3 shrink-0\" />\n )}\n <span className=\"min-w-0 break-words\">\n {testResult.message}\n </span>\n </div>\n )}\n {error && (\n <div className=\"break-words rounded-md bg-red-500/5 px-3 py-2 text-[11px] leading-snug text-red-600 dark:text-red-400\">\n {error}\n </div>\n )}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-t border-border px-7 py-4\">\n <button\n type=\"button\"\n onClick={runTest}\n disabled={!url.trim() || busy}\n className=\"rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n >\n {t(\"mcpIntegrations.test\")}\n </button>\n {selected?.authMode === \"oauth\" && !selectedRequiresSetup ? (\n <button\n type=\"button\"\n onClick={() => connectWithOAuth(selected)}\n disabled={!name.trim() || !url.trim() || busy}\n className=\"rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n >\n {t(\"mcpIntegrations.connectWithOAuth\")}\n </button>\n ) : !selected ? (\n <button\n type=\"button\"\n onClick={connectCustomWithOAuth}\n disabled={!name.trim() || !url.trim() || busy}\n className=\"rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n >\n {t(\"mcpIntegrations.connectWithOAuth\")}\n </button>\n ) : null}\n {selectedRequiresSetup ? (\n selected?.docsUrl ? (\n <a\n href={selected.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90\"\n >\n {t(\"mcpIntegrations.viewSetup\")}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n ) : null\n ) : (\n <button\n type=\"button\"\n onClick={submitForm}\n disabled={!name.trim() || !url.trim() || busy}\n className=\"inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-40\"\n >\n {busy && <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" />}\n {t(\"mcpIntegrations.connect\")}\n </button>\n )}\n </div>\n </>\n )}\n </DialogContent>\n </Dialog>\n );\n}\n"]}
1
+ {"version":3,"file":"McpIntegrationDialog.js","sourceRoot":"","sources":["../../../src/client/resources/McpIntegrationDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE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,yBAAyB,CAAC,IACtB,CACV,IACG,IACL,CACJ,GACa,GACT,CACV,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconArrowLeft,\n IconCheck,\n IconExternalLink,\n IconLoader2,\n IconSearch,\n} from \"@tabler/icons-react\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { AgentAskPopover } from \"../AgentAskPopover.js\";\nimport { agentNativePath } from \"../api-path.js\";\nimport { openAgentSettings } from \"../CommandMenu.js\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"../components/ui/dialog.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { useT } from \"../i18n.js\";\nimport { cn } from \"../utils.js\";\nimport {\n buildMcpOAuthStartUrl,\n createMcpIntegrationFormDefaults,\n filterMcpIntegrations,\n getMcpIntegrationApiFallback,\n getDefaultMcpIntegrations,\n isCustomMcpIntegrationEnabled,\n resolveMcpIntegrationScope,\n type DefaultMcpIntegration,\n} from \"./mcp-integration-catalog.js\";\nimport {\n formatMcpServerError,\n getMcpUrlValidationError,\n testMcpServerUrl,\n useMcpServers,\n type CreateMcpServerArgs,\n type McpServerScope,\n} from \"./use-mcp-servers.js\";\n\ntype DialogMode = \"catalog\" | \"form\";\n\ninterface McpIntegrationDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n initialIntegrationId?: string | null;\n defaultScope: McpServerScope;\n canCreateOrgMcp: boolean;\n hasOrg: boolean;\n onCreateMcpServer: (args: CreateMcpServerArgs) => Promise<unknown>;\n onCreated?: () => void;\n}\n\ninterface TestResult {\n ok: boolean;\n message: string;\n}\n\nfunction parseHeaderLines(text: string): Record<string, string> | undefined {\n const out: Record<string, string> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const idx = trimmed.indexOf(\":\");\n if (idx <= 0) continue;\n const key = trimmed.slice(0, idx).trim();\n const value = trimmed.slice(idx + 1).trim();\n if (!key || !value) continue;\n out[key] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction compareUrl(value: string): string {\n try {\n const url = new URL(value.trim());\n url.hash = \"\";\n return url.toString().replace(/\\/+$/, \"\");\n } catch {\n return value.trim().replace(/\\/+$/, \"\");\n }\n}\n\nexport function McpIntegrationDialog({\n open,\n onOpenChange,\n initialIntegrationId = null,\n defaultScope,\n canCreateOrgMcp,\n hasOrg,\n onCreateMcpServer,\n onCreated,\n}: McpIntegrationDialogProps) {\n const t = useT();\n const [mode, setMode] = useState<DialogMode>(\"catalog\");\n const [query, setQuery] = useState(\"\");\n const [selected, setSelected] = useState<DefaultMcpIntegration | null>(null);\n const safeDefaultScope = resolveMcpIntegrationScope(\n defaultScope,\n hasOrg,\n canCreateOrgMcp,\n );\n const [scope, setScope] = useState<McpServerScope>(safeDefaultScope);\n const [name, setName] = useState(\"\");\n const [url, setUrl] = useState(\"\");\n const [description, setDescription] = useState(\"\");\n const [headersText, setHeadersText] = useState(\"\");\n const [busy, setBusy] = useState(false);\n const [quickBusyId, setQuickBusyId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n const [testResult, setTestResult] = useState<TestResult | null>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const mcpServersQuery = useMcpServers();\n const defaultIntegrations = useMemo(() => getDefaultMcpIntegrations(), []);\n const customIntegrationEnabled = useMemo(\n () => isCustomMcpIntegrationEnabled(),\n [],\n );\n const showCatalog = defaultIntegrations.length > 0;\n\n const connectedUrls = useMemo(() => {\n const servers = [\n ...(mcpServersQuery.data?.user ?? []),\n ...(mcpServersQuery.data?.org ?? []),\n ];\n // A saved server is not necessarily a working connection. The settings\n // page reports failed and unknown health states separately, so only mark\n // catalog entries as connected after the health probe succeeds.\n return new Set(\n servers\n .filter((server) => server.status.state === \"connected\")\n .map((server) => compareUrl(server.url)),\n );\n }, [mcpServersQuery.data]);\n\n const filteredIntegrations = useMemo(\n () => filterMcpIntegrations(query, defaultIntegrations),\n [defaultIntegrations, query],\n );\n\n const selectedRequiresSetup = Boolean(\n selected &&\n (selected.connectionMode === \"manual\" ||\n selected.availability === \"provider-setup\" ||\n selected.availability === \"client-restricted\"),\n );\n\n useEffect(() => {\n if (!open) return;\n const initialIntegration = initialIntegrationId\n ? defaultIntegrations.find(\n (integration) => integration.id === initialIntegrationId,\n )\n : null;\n const initialDefaults =\n createMcpIntegrationFormDefaults(initialIntegration);\n setMode(initialIntegration || !showCatalog ? \"form\" : \"catalog\");\n setQuery(\"\");\n setSelected(initialIntegration ?? null);\n setScope(safeDefaultScope);\n setName(initialDefaults.name);\n setUrl(initialDefaults.url);\n setDescription(initialDefaults.description);\n setHeadersText(initialDefaults.headersText);\n setBusy(false);\n setQuickBusyId(null);\n setError(null);\n setTestResult(null);\n }, [\n defaultIntegrations,\n initialIntegrationId,\n open,\n safeDefaultScope,\n showCatalog,\n ]);\n\n useEffect(() => {\n if (open && mode === \"form\") {\n const timer = window.setTimeout(() => inputRef.current?.focus(), 60);\n return () => window.clearTimeout(timer);\n }\n }, [mode, open]);\n\n const clearFeedback = () => {\n setError(null);\n setTestResult(null);\n };\n\n const openForm = (integration?: DefaultMcpIntegration | null) => {\n const defaults = createMcpIntegrationFormDefaults(integration);\n setSelected(integration ?? null);\n setScope(safeDefaultScope);\n setName(defaults.name);\n setUrl(defaults.url);\n setDescription(defaults.description);\n setHeadersText(defaults.headersText);\n setError(null);\n setTestResult(null);\n setMode(\"form\");\n };\n\n const beginOAuth = (args: {\n name: string;\n url: string;\n description: string;\n }) => {\n const validationError = getMcpUrlValidationError(args.url);\n if (validationError) {\n setError(validationError);\n setTestResult(null);\n return;\n }\n const returnUrl =\n typeof window === \"undefined\"\n ? \"/\"\n : window.location.pathname +\n window.location.search +\n window.location.hash;\n window.location.assign(\n agentNativePath(\n buildMcpOAuthStartUrl({\n name: args.name,\n url: args.url,\n description: args.description,\n scope: safeDefaultScope,\n returnUrl,\n }),\n ),\n );\n };\n\n const connectWithOAuth = (integration: DefaultMcpIntegration) =>\n beginOAuth({\n name: integration.name,\n url: integration.url,\n description: integration.description,\n });\n\n const connectCustomWithOAuth = () => {\n if (!name.trim()) {\n setError(t(\"mcpIntegrations.serverNameRequired\"));\n return;\n }\n beginOAuth({\n name: name.trim(),\n url: url.trim(),\n description: description.trim(),\n });\n };\n\n const createServer = async (\n args: CreateMcpServerArgs,\n options?: { quickId?: string },\n ) => {\n const validationError = getMcpUrlValidationError(args.url);\n if (validationError) {\n setError(validationError);\n setTestResult(null);\n return;\n }\n\n if (options?.quickId) setQuickBusyId(options.quickId);\n setBusy(true);\n setError(null);\n try {\n await onCreateMcpServer(args);\n onOpenChange(false);\n onCreated?.();\n } catch (err) {\n setError(formatMcpServerError(err));\n } finally {\n setBusy(false);\n setQuickBusyId(null);\n }\n };\n\n const submitForm = () => {\n const trimmedName = name.trim();\n const trimmedUrl = url.trim();\n if (!trimmedName || !trimmedUrl || busy) return;\n void createServer({\n scope,\n name: trimmedName,\n url: trimmedUrl,\n headers: parseHeaderLines(headersText),\n description: description.trim() || undefined,\n });\n };\n\n const quickConnect = (integration: DefaultMcpIntegration) => {\n if (\n integration.connectionMode === \"manual\" ||\n integration.availability === \"provider-setup\"\n ) {\n return;\n }\n if (integration.authMode === \"oauth\") {\n connectWithOAuth(integration);\n return;\n }\n if (integration.authMode === \"headers\") {\n openForm(integration);\n return;\n }\n void createServer(\n {\n scope: safeDefaultScope,\n name: integration.name,\n url: integration.url,\n description: integration.description,\n },\n { quickId: integration.id },\n );\n };\n\n const runTest = async () => {\n const trimmedUrl = url.trim();\n if (!trimmedUrl || busy) return;\n const validationError = getMcpUrlValidationError(trimmedUrl);\n if (validationError) {\n setTestResult({ ok: false, message: validationError });\n setError(null);\n return;\n }\n setBusy(true);\n setError(null);\n setTestResult(null);\n try {\n const res = await testMcpServerUrl(\n trimmedUrl,\n parseHeaderLines(headersText),\n );\n setTestResult(\n res.ok\n ? {\n ok: true,\n message: t(\"mcpIntegrations.toolsAvailable\", {\n count: res.toolCount ?? 0,\n }),\n }\n : { ok: false, message: res.error ?? t(\"mcpIntegrations.failed\") },\n );\n } catch (err) {\n setTestResult({ ok: false, message: formatMcpServerError(err) });\n } finally {\n setBusy(false);\n }\n };\n\n const renderScopeSelector = () => {\n const orgTooltip = !hasOrg\n ? t(\"mcpIntegrations.orgNoOrg\")\n : !canCreateOrgMcp\n ? t(\"mcpIntegrations.orgAdminOnly\")\n : null;\n\n return (\n <div className=\"flex gap-1 rounded-md border border-border bg-background p-0.5\">\n <button\n type=\"button\"\n onClick={() => setScope(\"user\")}\n className={cn(\n \"flex-1 rounded px-2 py-1.5 text-[11px] font-medium\",\n scope === \"user\"\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\",\n )}\n >\n {t(\"mcpIntegrations.personal\")}\n </button>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => hasOrg && canCreateOrgMcp && setScope(\"org\")}\n disabled={!hasOrg || !canCreateOrgMcp}\n className={cn(\n \"flex-1 rounded px-2 py-1.5 text-[11px] font-medium\",\n scope === \"org\"\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\",\n (!hasOrg || !canCreateOrgMcp) &&\n \"cursor-not-allowed opacity-50 hover:text-muted-foreground\",\n )}\n >\n {t(\"mcpIntegrations.organization\")}\n </button>\n </TooltipTrigger>\n {orgTooltip && <TooltipContent>{orgTooltip}</TooltipContent>}\n </Tooltip>\n </div>\n );\n };\n\n if (!showCatalog && !customIntegrationEnabled) return null;\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"flex max-h-[min(820px,calc(100vh-32px))] w-[calc(100vw-24px)] max-w-[760px] flex-col gap-0 p-0 sm:w-[min(760px,calc(100vw-48px))]\">\n {mode === \"catalog\" ? (\n <>\n <DialogHeader className=\"shrink-0 px-7 pb-5 pe-14 pt-6\">\n <DialogTitle>{t(\"mcpIntegrations.title\")}</DialogTitle>\n <DialogDescription>\n {t(\"mcpIntegrations.description\")}\n </DialogDescription>\n </DialogHeader>\n <div className=\"flex shrink-0 flex-col gap-3 px-7 pb-5 sm:flex-row\">\n <label className=\"relative min-w-0 flex-1\">\n <IconSearch className=\"pointer-events-none absolute start-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground\" />\n <input\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n className=\"h-9 w-full rounded-md border border-border bg-background pe-3 ps-8 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.searchPlaceholder\")}\n />\n </label>\n <button\n type=\"button\"\n onClick={() => openForm(null)}\n className={cn(\n \"inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-3 text-[12px] font-medium text-foreground hover:bg-accent\",\n !customIntegrationEnabled && \"hidden\",\n )}\n >\n {t(\"mcpIntegrations.addYourOwn\")}\n </button>\n <AgentAskPopover\n label={t(\"mcpIntegrations.addSomething\")}\n title={t(\"mcpIntegrations.addSomethingTitle\")}\n placeholder={t(\"mcpIntegrations.addSomethingPlaceholder\")}\n prompt=\"\"\n context=\"The user wants to add an MCP or provider integration that is not in the current directory. Research the provider's official remote MCP endpoint and OAuth, client-registration, or allowlist requirements. Prefer Streamable HTTP endpoints over legacy SSE, reuse an existing provider OAuth connector when appropriate, and never ask the user to paste credentials into a prompt. If this should become a reusable preset, update the integration catalog, official docs link, bundled logo, localization, and tests.\"\n className=\"h-9 whitespace-nowrap border-dashed px-3 text-[12px] font-medium\"\n />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-7 pb-7\">\n {error && (\n <div className=\"mb-3 rounded-md border border-red-500/20 bg-red-500/5 px-3 py-2 text-[12px] leading-relaxed text-red-600 dark:text-red-400\">\n {error}\n </div>\n )}\n <div className=\"grid gap-3 sm:grid-cols-2\">\n {filteredIntegrations.map((integration) => {\n const apiFallback = getMcpIntegrationApiFallback(integration);\n const connected = connectedUrls.has(\n compareUrl(integration.url),\n );\n const requiresHeaders = integration.authMode === \"headers\";\n const setupOnly =\n integration.connectionMode === \"manual\" ||\n integration.availability === \"provider-setup\" ||\n integration.availability === \"client-restricted\";\n return (\n <article\n key={integration.id}\n className=\"flex min-h-[128px] flex-col rounded-md border border-border bg-card p-4 transition-colors hover:border-border/80 hover:bg-accent/20\"\n >\n <div className=\"flex items-center gap-3\">\n <div className=\"relative flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-background text-[11px] font-semibold text-muted-foreground\">\n <span aria-hidden=\"true\">\n {integration.name.slice(0, 1)}\n </span>\n <img\n src={integration.logoUrl}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"absolute inset-1 h-6 w-6 object-contain\"\n onError={(event) => {\n event.currentTarget.hidden = true;\n }}\n />\n </div>\n <div className=\"min-w-0\">\n <h3 className=\"truncate text-[13px] font-semibold text-foreground\">\n {integration.name}\n </h3>\n {integration.availability !== \"ready\" && (\n <span className=\"mt-0.5 inline-flex rounded-full border border-amber-500/20 bg-amber-500/5 px-1.5 py-0.5 text-[9px] font-medium text-amber-700 dark:text-amber-300\">\n {integration.availability === \"beta\"\n ? t(\"mcpIntegrations.status.beta\")\n : integration.availability ===\n \"client-restricted\"\n ? t(\"mcpIntegrations.status.clientRestricted\")\n : t(\"mcpIntegrations.status.setupRequired\")}\n </span>\n )}\n <span className=\"ms-1 mt-0.5 inline-flex rounded-full border border-border/70 bg-muted/40 px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground\">\n {integration.verification === \"verified\"\n ? t(\"mcpIntegrations.status.verified\")\n : integration.verification === \"restricted\"\n ? t(\"mcpIntegrations.status.restricted\")\n : t(\"mcpIntegrations.status.preflightOnly\")}\n </span>\n </div>\n </div>\n <p className=\"mt-1 line-clamp-2 flex-1 text-[12px] leading-relaxed text-muted-foreground\">\n {t(integration.descriptionKey)}\n </p>\n {integration.setupNoteKey && (\n <p className=\"mt-2 line-clamp-3 text-[10px] leading-relaxed text-amber-700 dark:text-amber-300\">\n {t(integration.setupNoteKey)}\n </p>\n )}\n <div className=\"mt-3 flex items-center gap-2\">\n {connected ? (\n <button\n type=\"button\"\n disabled\n className=\"inline-flex h-8 flex-1 cursor-not-allowed items-center justify-center gap-1.5 rounded-md border border-border bg-muted px-2.5 text-[12px] font-medium text-muted-foreground opacity-70\"\n >\n {t(\"mcpIntegrations.connected\")}\n </button>\n ) : setupOnly ? (\n <>\n {apiFallback && (\n <button\n type=\"button\"\n onClick={() =>\n openAgentSettings(\n `secrets:${apiFallback.secretKey}`,\n )\n }\n className=\"inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90\"\n >\n {t(\"mcpIntegrations.useApiToken\")}\n </button>\n )}\n <a\n href={integration.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-[12px] font-medium text-foreground hover:bg-accent\"\n >\n {t(\"mcpIntegrations.viewSetup\")}\n <IconExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </>\n ) : (\n <button\n type=\"button\"\n onClick={() => quickConnect(integration)}\n disabled={busy}\n className={cn(\n \"inline-flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90\",\n busy && \"cursor-not-allowed opacity-70\",\n )}\n >\n {quickBusyId === integration.id ? (\n <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" />\n ) : null}\n {integration.authMode === \"oauth\"\n ? t(\"mcpIntegrations.connectWithOAuth\")\n : requiresHeaders\n ? t(\"mcpIntegrations.configure\")\n : t(\"mcpIntegrations.connect\")}\n </button>\n )}\n {integration.docsUrl && (\n <Tooltip>\n <TooltipTrigger asChild>\n <a\n href={integration.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground hover:bg-accent hover:text-foreground\"\n aria-label={t(\"mcpIntegrations.docsLabel\", {\n name: integration.name,\n })}\n >\n <IconExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </TooltipTrigger>\n <TooltipContent>\n {t(\"mcpIntegrations.docsLabel\", {\n name: integration.name,\n })}\n </TooltipContent>\n </Tooltip>\n )}\n </div>\n </article>\n );\n })}\n </div>\n {filteredIntegrations.length === 0 && (\n <div className=\"rounded-md border border-dashed border-border p-6 text-center text-[12px] text-muted-foreground\">\n {t(\"mcpIntegrations.noMatches\")}\n </div>\n )}\n </div>\n </>\n ) : (\n <>\n <DialogHeader className=\"shrink-0 border-b border-border px-7 pb-5 pe-14 pt-6\">\n <button\n type=\"button\"\n onClick={() => {\n clearFeedback();\n setMode(\"catalog\");\n }}\n className={cn(\n \"mb-1 inline-flex w-fit items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground\",\n !showCatalog && \"hidden\",\n )}\n >\n <IconArrowLeft className=\"h-3 w-3 rtl:-scale-x-100\" />\n {t(\"mcpIntegrations.backToIntegrations\")}\n </button>\n <DialogTitle>\n {selected\n ? t(\"mcpIntegrations.configureTitle\", {\n name: selected.name,\n })\n : t(\"mcpIntegrations.customTitle\")}\n </DialogTitle>\n <DialogDescription>\n {selected\n ? selected.authMode === \"none\"\n ? t(\"mcpIntegrations.presetNoAuthDescription\")\n : t(\"mcpIntegrations.presetAuthDescription\")\n : t(\"mcpIntegrations.customDescription\")}\n </DialogDescription>\n </DialogHeader>\n <div className=\"min-h-0 flex-1 overflow-y-auto px-7 py-5\">\n <div className=\"space-y-3\">\n {renderScopeSelector()}\n {selected?.setupNoteKey && (\n <div className=\"rounded-md border border-amber-500/20 bg-amber-500/5 px-3 py-2 text-[11px] leading-relaxed text-amber-700 dark:text-amber-300\">\n {t(selected.setupNoteKey)}\n </div>\n )}\n {selected?.authMode === \"oauth\" && (\n <div className=\"rounded-md border border-blue-500/20 bg-blue-500/5 px-3 py-2 text-[11px] leading-relaxed text-blue-700 dark:text-blue-300\">\n {t(\"mcpIntegrations.oauthNotice\")}\n </div>\n )}\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.serverName\")}\n </span>\n <input\n ref={inputRef}\n value={name}\n onChange={(event) => {\n setName(event.target.value);\n clearFeedback();\n }}\n className=\"w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.serverNamePlaceholder\")}\n />\n </label>\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.url\")}\n </span>\n <input\n value={url}\n onChange={(event) => {\n setUrl(event.target.value);\n clearFeedback();\n }}\n className=\"w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.urlPlaceholder\")}\n />\n </label>\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.fieldDescription\")}\n </span>\n <input\n value={description}\n onChange={(event) => {\n setDescription(event.target.value);\n clearFeedback();\n }}\n className=\"w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-[13px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n placeholder={t(\"mcpIntegrations.descriptionPlaceholder\")}\n />\n </label>\n {selected?.authMode !== \"oauth\" && (\n <label className=\"block\">\n <span className=\"mb-1 block text-[10px] font-medium text-muted-foreground\">\n {t(\"mcpIntegrations.headers\")}\n </span>\n <textarea\n value={headersText}\n onChange={(event) => {\n setHeadersText(event.target.value);\n clearFeedback();\n }}\n rows={3}\n className=\"w-full resize-y rounded-md border border-border bg-background px-2.5 py-1.5 text-[12px] text-foreground outline-none placeholder:text-muted-foreground/50 focus:ring-1 focus:ring-ring\"\n style={{\n fontFamily:\n 'ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, Consolas, monospace',\n }}\n placeholder={\n selected?.headerPlaceholder ??\n t(\"mcpIntegrations.headersPlaceholder\")\n }\n />\n </label>\n )}\n {selected?.docsUrl && (\n <a\n href={selected.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1 text-[11px] text-muted-foreground underline hover:text-foreground\"\n >\n {t(\"mcpIntegrations.openSetupDocs\")}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n )}\n {testResult && (\n <div\n className={cn(\n \"flex items-start gap-1 rounded-md px-3 py-2 text-[11px] leading-snug\",\n testResult.ok\n ? \"bg-green-500/5 text-green-600 dark:text-green-400\"\n : \"bg-red-500/5 text-red-600 dark:text-red-400\",\n )}\n >\n {testResult.ok && (\n <IconCheck className=\"mt-0.5 h-3 w-3 shrink-0\" />\n )}\n <span className=\"min-w-0 break-words\">\n {testResult.message}\n </span>\n </div>\n )}\n {error && (\n <div className=\"break-words rounded-md bg-red-500/5 px-3 py-2 text-[11px] leading-snug text-red-600 dark:text-red-400\">\n {error}\n </div>\n )}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-t border-border px-7 py-4\">\n <button\n type=\"button\"\n onClick={runTest}\n disabled={!url.trim() || busy}\n className=\"rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n >\n {t(\"mcpIntegrations.test\")}\n </button>\n {selected?.authMode === \"oauth\" && !selectedRequiresSetup ? (\n <button\n type=\"button\"\n onClick={() => connectWithOAuth(selected)}\n disabled={!name.trim() || !url.trim() || busy}\n className=\"rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n >\n {t(\"mcpIntegrations.connectWithOAuth\")}\n </button>\n ) : !selected ? (\n <button\n type=\"button\"\n onClick={connectCustomWithOAuth}\n disabled={!name.trim() || !url.trim() || busy}\n className=\"rounded-md border border-border bg-background px-3 py-1.5 text-[12px] font-medium text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n >\n {t(\"mcpIntegrations.connectWithOAuth\")}\n </button>\n ) : null}\n {selectedRequiresSetup ? (\n selected?.docsUrl ? (\n <a\n href={selected.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90\"\n >\n {t(\"mcpIntegrations.viewSetup\")}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n ) : null\n ) : (\n <button\n type=\"button\"\n onClick={submitForm}\n disabled={!name.trim() || !url.trim() || busy}\n className=\"inline-flex min-w-[92px] items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-40\"\n >\n {busy && <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" />}\n {t(\"mcpIntegrations.connect\")}\n </button>\n )}\n </div>\n </>\n )}\n </DialogContent>\n </Dialog>\n );\n}\n"]}
@@ -19,6 +19,11 @@ export interface DefaultMcpIntegration {
19
19
  logoUrl: string;
20
20
  docsUrl?: string;
21
21
  setupNoteKey?: string;
22
+ apiFallback?: {
23
+ secretKey: string;
24
+ docsUrl: string;
25
+ templateUses?: readonly string[];
26
+ };
22
27
  headerPlaceholder?: string;
23
28
  keywords: string[];
24
29
  }
@@ -36,6 +41,7 @@ export interface McpOAuthStartParams {
36
41
  returnUrl: string;
37
42
  }
38
43
  export declare const DEFAULT_MCP_INTEGRATIONS: DefaultMcpIntegration[];
44
+ export declare function getMcpIntegrationApiFallback(integration: DefaultMcpIntegration, templateName?: string | null): DefaultMcpIntegration["apiFallback"] | null;
39
45
  export declare function getDefaultMcpIntegrations(config?: McpIntegrationsConfigInput | NormalizedMcpIntegrationsConfig): DefaultMcpIntegration[];
40
46
  export declare function isCustomMcpIntegrationEnabled(config?: McpIntegrationsConfigInput | NormalizedMcpIntegrationsConfig): boolean;
41
47
  export declare function isMcpIntegrationCatalogAvailable(config?: McpIntegrationsConfigInput | NormalizedMcpIntegrationsConfig): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-integration-catalog.d.ts","sourceRoot":"","sources":["../../../src/client/resources/mcp-integration-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACrC,MAAM,wCAAwC,CAAC;AAGhD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,4BAA4B,GACpC,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,CAAC;AACb,MAAM,MAAM,0BAA0B,GAClC,OAAO,GACP,MAAM,GACN,gBAAgB,GAChB,mBAAmB,CAAC;AACxB,MAAM,MAAM,0BAA0B,GAClC,UAAU,GACV,gBAAgB,GAChB,YAAY,CAAC;AAMjB,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,sBAAsB,CAAC;IACjC,cAAc,EAAE,4BAA4B,CAAC;IAC7C,YAAY,EAAE,0BAA0B,CAAC;IACzC,YAAY,EAAE,0BAA0B,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,C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B,CACvC,IAAI,EAAE,MAAM,EACZ,YAAY,GAAE,qBAAqB,EAAgC,GAClE,qBAAqB,GAAG,IAAI,CA2B9B;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED,wBAAgB,gCAAgC,CAC9C,WAAW,CAAC,EAAE,qBAAqB,GAAG,IAAI,GACzC,0BAA0B,CAe5B"}
1
+ {"version":3,"file":"mcp-integration-catalog.d.ts","sourceRoot":"","sources":["../../../src/client/resources/mcp-integration-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACrC,MAAM,wCAAwC,CAAC;AAGhD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,4BAA4B,GACpC,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,CAAC;AACb,MAAM,MAAM,0BAA0B,GAClC,OAAO,GACP,MAAM,GACN,gBAAgB,GAChB,mBAAmB,CAAC;AACxB,MAAM,MAAM,0BAA0B,GAClC,UAAU,GACV,gBAAgB,GAChB,YAAY,CAAC;AAOjB,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,sBAAsB,CAAC;IACjC,cAAc,EAAE,4BAA4B,CAAC;IAC7C,YAAY,EAAE,0BAA0B,CAAC;IACzC,YAAY,EAAE,0BAA0B,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IAC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,YAAY,EAAE,MAAM,GAAG,KAAK,EAC5B,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,OAAO,GACvB,MAAM,GAAG,KAAK,CAEhB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,YAAY,GAAE,qBAAqB,EAAgC,GAClE,qBAAqB,EAAE,CAgBzB;AAuCD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,YAAY,GAAE,qBAAqB,EAAgC,GAClE,qBAAqB,GAAG,IAAI,CA2B9B;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED,wBAAgB,gCAAgC,CAC9C,WAAW,CAAC,EAAE,qBAAqB,GAAG,IAAI,GACzC,0BAA0B,CAe5B"}
@@ -209,6 +209,11 @@ export const DEFAULT_MCP_INTEGRATIONS = [
209
209
  logoUrl: mcpIntegrationLogo("figma"),
210
210
  docsUrl: "https://developers.figma.com/docs/figma-mcp-server/",
211
211
  setupNoteKey: "mcpIntegrations.catalog.figma.setupNote",
212
+ apiFallback: {
213
+ secretKey: "FIGMA_ACCESS_TOKEN",
214
+ docsUrl: "https://developers.figma.com/docs/rest-api/personal-access-tokens/",
215
+ templateUses: ["design"],
216
+ },
212
217
  keywords: ["design", "figjam", "components", "variables", "canvas"],
213
218
  },
214
219
  {
@@ -458,6 +463,34 @@ function readRuntimeMcpIntegrationsConfig() {
458
463
  }
459
464
  return normalizeMcpIntegrationsConfig();
460
465
  }
466
+ function normalizeTemplateName(value) {
467
+ if (typeof value !== "string")
468
+ return null;
469
+ const normalized = value.trim().toLowerCase();
470
+ return normalized || null;
471
+ }
472
+ function getActiveTemplateName() {
473
+ try {
474
+ const compiledTemplate = normalizeTemplateName(__AGENT_NATIVE_TEMPLATE__);
475
+ if (compiledTemplate)
476
+ return compiledTemplate;
477
+ }
478
+ catch {
479
+ // Test and non-Vite contexts may not define the compile-time constant.
480
+ }
481
+ const runtimeConfig = globalThis.__AGENT_NATIVE_CONFIG__;
482
+ return normalizeTemplateName(runtimeConfig?.template);
483
+ }
484
+ export function getMcpIntegrationApiFallback(integration, templateName = getActiveTemplateName()) {
485
+ const fallback = integration.apiFallback;
486
+ if (!fallback)
487
+ return null;
488
+ if (!fallback.templateUses?.length)
489
+ return fallback;
490
+ if (!templateName)
491
+ return null;
492
+ return fallback.templateUses.includes(templateName) ? fallback : null;
493
+ }
461
494
  function normalizePresetConfig(config) {
462
495
  if (config === undefined)
463
496
  return readRuntimeMcpIntegrationsConfig();