@stigmer/react 3.1.6 → 3.1.8

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 (224) hide show
  1. package/agent/AgentDetailView.d.ts +9 -1
  2. package/agent/AgentDetailView.d.ts.map +1 -1
  3. package/agent/AgentDetailView.js +15 -4
  4. package/agent/AgentDetailView.js.map +1 -1
  5. package/environment/EnvironmentListPanel.d.ts.map +1 -1
  6. package/environment/EnvironmentListPanel.js +11 -3
  7. package/environment/EnvironmentListPanel.js.map +1 -1
  8. package/environment/EnvironmentVariableEditor.d.ts.map +1 -1
  9. package/environment/EnvironmentVariableEditor.js +9 -3
  10. package/environment/EnvironmentVariableEditor.js.map +1 -1
  11. package/environment/index.d.ts +1 -0
  12. package/environment/index.d.ts.map +1 -1
  13. package/environment/index.js +1 -0
  14. package/environment/index.js.map +1 -1
  15. package/environment/shareRestriction.d.ts +13 -0
  16. package/environment/shareRestriction.d.ts.map +1 -0
  17. package/environment/shareRestriction.js +15 -0
  18. package/environment/shareRestriction.js.map +1 -0
  19. package/execution/ToolCallItem.d.ts.map +1 -1
  20. package/execution/ToolCallItem.js +12 -0
  21. package/execution/ToolCallItem.js.map +1 -1
  22. package/execution/ToolRunGroup.js +4 -0
  23. package/execution/ToolRunGroup.js.map +1 -1
  24. package/execution/WriteBackCard.d.ts +14 -5
  25. package/execution/WriteBackCard.d.ts.map +1 -1
  26. package/execution/WriteBackCard.js +103 -32
  27. package/execution/WriteBackCard.js.map +1 -1
  28. package/execution/WriteBacksWidget.d.ts +1 -1
  29. package/execution/WriteBacksWidget.js +2 -2
  30. package/execution/WriteBacksWidget.js.map +1 -1
  31. package/execution/index.d.ts +2 -0
  32. package/execution/index.d.ts.map +1 -1
  33. package/execution/index.js +1 -0
  34. package/execution/index.js.map +1 -1
  35. package/execution/write-back-utils.d.ts +57 -0
  36. package/execution/write-back-utils.d.ts.map +1 -0
  37. package/execution/write-back-utils.js +81 -0
  38. package/execution/write-back-utils.js.map +1 -0
  39. package/index.d.ts +6 -2
  40. package/index.d.ts.map +1 -1
  41. package/index.js +6 -1
  42. package/index.js.map +1 -1
  43. package/internal/dev/dom-counter.d.ts.map +1 -1
  44. package/internal/dev/dom-counter.js +2 -2
  45. package/internal/dev/dom-counter.js.map +1 -1
  46. package/internal/dev/enabled.d.ts +7 -0
  47. package/internal/dev/enabled.d.ts.map +1 -0
  48. package/internal/dev/enabled.js +38 -0
  49. package/internal/dev/enabled.js.map +1 -0
  50. package/internal/dev/profiler-wrapper.d.ts +3 -3
  51. package/internal/dev/profiler-wrapper.d.ts.map +1 -1
  52. package/internal/dev/profiler-wrapper.js +5 -5
  53. package/internal/dev/profiler-wrapper.js.map +1 -1
  54. package/internal/dev/use-key-stability.d.ts.map +1 -1
  55. package/internal/dev/use-key-stability.js +2 -2
  56. package/internal/dev/use-key-stability.js.map +1 -1
  57. package/internal/dev/use-render-tracer.d.ts +2 -2
  58. package/internal/dev/use-render-tracer.d.ts.map +1 -1
  59. package/internal/dev/use-render-tracer.js +4 -4
  60. package/internal/dev/use-render-tracer.js.map +1 -1
  61. package/internal/dev/use-stream-rate.d.ts +2 -1
  62. package/internal/dev/use-stream-rate.d.ts.map +1 -1
  63. package/internal/dev/use-stream-rate.js +4 -3
  64. package/internal/dev/use-stream-rate.js.map +1 -1
  65. package/library/ResourceVisibilityControl.d.ts +3 -0
  66. package/library/ResourceVisibilityControl.d.ts.map +1 -1
  67. package/library/ResourceVisibilityControl.js +22 -8
  68. package/library/ResourceVisibilityControl.js.map +1 -1
  69. package/library/useUpdateVisibility.d.ts +5 -3
  70. package/library/useUpdateVisibility.d.ts.map +1 -1
  71. package/library/useUpdateVisibility.js +7 -2
  72. package/library/useUpdateVisibility.js.map +1 -1
  73. package/library/visibilityLevels.d.ts +17 -0
  74. package/library/visibilityLevels.d.ts.map +1 -1
  75. package/library/visibilityLevels.js +32 -0
  76. package/library/visibilityLevels.js.map +1 -1
  77. package/mcp-server/McpServerConnectDialog.d.ts.map +1 -1
  78. package/mcp-server/McpServerConnectDialog.js +7 -3
  79. package/mcp-server/McpServerConnectDialog.js.map +1 -1
  80. package/mcp-server/McpServerDetailView.d.ts.map +1 -1
  81. package/mcp-server/McpServerDetailView.js +6 -3
  82. package/mcp-server/McpServerDetailView.js.map +1 -1
  83. package/mcp-server/McpServerPicker.d.ts.map +1 -1
  84. package/mcp-server/McpServerPicker.js +3 -1
  85. package/mcp-server/McpServerPicker.js.map +1 -1
  86. package/mcp-server/OAuthRequiredNotice.d.ts +29 -0
  87. package/mcp-server/OAuthRequiredNotice.d.ts.map +1 -0
  88. package/mcp-server/OAuthRequiredNotice.js +29 -0
  89. package/mcp-server/OAuthRequiredNotice.js.map +1 -0
  90. package/mcp-server/StdioSandboxNotice.d.ts +43 -0
  91. package/mcp-server/StdioSandboxNotice.d.ts.map +1 -0
  92. package/mcp-server/StdioSandboxNotice.js +45 -0
  93. package/mcp-server/StdioSandboxNotice.js.map +1 -0
  94. package/mcp-server/useMcpServerCredentials.d.ts +12 -0
  95. package/mcp-server/useMcpServerCredentials.d.ts.map +1 -1
  96. package/mcp-server/useMcpServerCredentials.js +12 -4
  97. package/mcp-server/useMcpServerCredentials.js.map +1 -1
  98. package/package.json +4 -4
  99. package/session/NewSessionViewer.d.ts +11 -1
  100. package/session/NewSessionViewer.d.ts.map +1 -1
  101. package/session/NewSessionViewer.js +28 -8
  102. package/session/NewSessionViewer.js.map +1 -1
  103. package/session/SessionViewer.d.ts +9 -2
  104. package/session/SessionViewer.d.ts.map +1 -1
  105. package/session/SessionViewer.js +26 -12
  106. package/session/SessionViewer.js.map +1 -1
  107. package/session/audience.d.ts +12 -4
  108. package/session/audience.d.ts.map +1 -1
  109. package/session/facets/ChangesTab.d.ts.map +1 -1
  110. package/session/facets/ChangesTab.js +3 -1
  111. package/session/facets/ChangesTab.js.map +1 -1
  112. package/session/useNewSessionFlow.d.ts +12 -0
  113. package/session/useNewSessionFlow.d.ts.map +1 -1
  114. package/session/useNewSessionFlow.js +13 -1
  115. package/session/useNewSessionFlow.js.map +1 -1
  116. package/session/useSessionPageFlow.d.ts +13 -0
  117. package/session/useSessionPageFlow.d.ts.map +1 -1
  118. package/session/useSessionPageFlow.js +7 -2
  119. package/session/useSessionPageFlow.js.map +1 -1
  120. package/sharing/ShareAgentDialog.d.ts +55 -0
  121. package/sharing/ShareAgentDialog.d.ts.map +1 -0
  122. package/sharing/ShareAgentDialog.js +393 -0
  123. package/sharing/ShareAgentDialog.js.map +1 -0
  124. package/sharing/SharedAgentChat.d.ts +84 -0
  125. package/sharing/SharedAgentChat.d.ts.map +1 -0
  126. package/sharing/SharedAgentChat.js +80 -0
  127. package/sharing/SharedAgentChat.js.map +1 -0
  128. package/sharing/index.d.ts +16 -0
  129. package/sharing/index.d.ts.map +1 -0
  130. package/sharing/index.js +11 -0
  131. package/sharing/index.js.map +1 -0
  132. package/sharing/useRotateShareLink.d.ts +42 -0
  133. package/sharing/useRotateShareLink.d.ts.map +1 -0
  134. package/sharing/useRotateShareLink.js +55 -0
  135. package/sharing/useRotateShareLink.js.map +1 -0
  136. package/sharing/useShareAgent.d.ts +68 -0
  137. package/sharing/useShareAgent.d.ts.map +1 -0
  138. package/sharing/useShareAgent.js +41 -0
  139. package/sharing/useShareAgent.js.map +1 -0
  140. package/sharing/useShareToolReadiness.d.ts +48 -0
  141. package/sharing/useShareToolReadiness.d.ts.map +1 -0
  142. package/sharing/useShareToolReadiness.js +93 -0
  143. package/sharing/useShareToolReadiness.js.map +1 -0
  144. package/sharing/useSharedAgentProfile.d.ts +84 -0
  145. package/sharing/useSharedAgentProfile.d.ts.map +1 -0
  146. package/sharing/useSharedAgentProfile.js +72 -0
  147. package/sharing/useSharedAgentProfile.js.map +1 -0
  148. package/sharing/useUpdateAgentSharing.d.ts +86 -0
  149. package/sharing/useUpdateAgentSharing.d.ts.map +1 -0
  150. package/sharing/useUpdateAgentSharing.js +81 -0
  151. package/sharing/useUpdateAgentSharing.js.map +1 -0
  152. package/src/agent/AgentDetailView.tsx +28 -3
  153. package/src/environment/EnvironmentListPanel.tsx +47 -18
  154. package/src/environment/EnvironmentVariableEditor.tsx +27 -17
  155. package/src/environment/__tests__/shareRestriction.test.ts +35 -0
  156. package/src/environment/index.ts +5 -0
  157. package/src/environment/shareRestriction.ts +22 -0
  158. package/src/execution/ToolCallItem.tsx +19 -1
  159. package/src/execution/ToolRunGroup.tsx +4 -0
  160. package/src/execution/WriteBackCard.tsx +285 -88
  161. package/src/execution/WriteBacksWidget.tsx +5 -5
  162. package/src/execution/__tests__/ToolCallItem.test.tsx +51 -0
  163. package/src/execution/__tests__/ToolRunGroup.test.tsx +22 -0
  164. package/src/execution/__tests__/WriteBackCard.test.tsx +64 -10
  165. package/src/execution/__tests__/write-back-utils.test.ts +135 -0
  166. package/src/execution/index.ts +7 -0
  167. package/src/execution/write-back-utils.ts +107 -0
  168. package/src/index.ts +34 -0
  169. package/src/internal/dev/__tests__/use-key-stability.test.ts +4 -0
  170. package/src/internal/dev/__tests__/use-render-tracer.test.ts +4 -0
  171. package/src/internal/dev/dom-counter.ts +2 -3
  172. package/src/internal/dev/enabled.ts +39 -0
  173. package/src/internal/dev/profiler-wrapper.tsx +5 -6
  174. package/src/internal/dev/use-key-stability.ts +2 -3
  175. package/src/internal/dev/use-render-tracer.ts +4 -5
  176. package/src/internal/dev/use-stream-rate.ts +4 -4
  177. package/src/library/ResourceVisibilityControl.tsx +23 -7
  178. package/src/library/__tests__/visibilityLevels.test.ts +33 -0
  179. package/src/library/useUpdateVisibility.ts +9 -3
  180. package/src/library/visibilityLevels.ts +36 -0
  181. package/src/mcp-server/McpServerConnectDialog.tsx +23 -11
  182. package/src/mcp-server/McpServerDetailView.tsx +22 -9
  183. package/src/mcp-server/McpServerPicker.tsx +12 -9
  184. package/src/mcp-server/OAuthRequiredNotice.tsx +77 -0
  185. package/src/mcp-server/StdioSandboxNotice.tsx +98 -0
  186. package/src/mcp-server/__tests__/OAuthRequiredNotice.test.tsx +25 -0
  187. package/src/mcp-server/__tests__/StdioSandboxNotice.test.tsx +71 -0
  188. package/src/mcp-server/useMcpServerCredentials.ts +25 -4
  189. package/src/session/NewSessionViewer.tsx +67 -31
  190. package/src/session/SessionViewer.tsx +67 -36
  191. package/src/session/__tests__/audienceWiring.test.tsx +99 -0
  192. package/src/session/__tests__/useNewSessionFlow.test.tsx +75 -1
  193. package/src/session/__tests__/useSessionPageFlow.guest.test.tsx +112 -0
  194. package/src/session/audience.ts +12 -4
  195. package/src/session/facets/ChangesTab.tsx +6 -4
  196. package/src/session/useNewSessionFlow.ts +26 -1
  197. package/src/session/useSessionPageFlow.ts +24 -2
  198. package/src/sharing/ShareAgentDialog.tsx +1255 -0
  199. package/src/sharing/SharedAgentChat.tsx +283 -0
  200. package/src/sharing/__tests__/ShareAgentDialog.test.tsx +745 -0
  201. package/src/sharing/__tests__/SharedAgentChat.test.tsx +222 -0
  202. package/src/sharing/__tests__/useRotateShareLink.test.tsx +96 -0
  203. package/src/sharing/__tests__/useShareAgent.test.tsx +127 -0
  204. package/src/sharing/__tests__/useShareToolReadiness.test.tsx +182 -0
  205. package/src/sharing/__tests__/useSharedAgentProfile.test.tsx +201 -0
  206. package/src/sharing/__tests__/useUpdateAgentSharing.test.tsx +200 -0
  207. package/src/sharing/index.ts +30 -0
  208. package/src/sharing/useRotateShareLink.ts +76 -0
  209. package/src/sharing/useShareAgent.tsx +106 -0
  210. package/src/sharing/useShareToolReadiness.ts +129 -0
  211. package/src/sharing/useSharedAgentProfile.ts +131 -0
  212. package/src/sharing/useUpdateAgentSharing.ts +151 -0
  213. package/src/switch/Switch.tsx +92 -0
  214. package/src/switch/__tests__/Switch.test.tsx +88 -0
  215. package/src/switch/index.ts +2 -0
  216. package/styles.css +1 -1
  217. package/switch/Switch.d.ts +47 -0
  218. package/switch/Switch.d.ts.map +1 -0
  219. package/switch/Switch.js +36 -0
  220. package/switch/Switch.js.map +1 -0
  221. package/switch/index.d.ts +3 -0
  222. package/switch/index.d.ts.map +1 -0
  223. package/switch/index.js +2 -0
  224. package/switch/index.js.map +1 -0
@@ -143,6 +143,42 @@ export const INSTANCE_VISIBILITY_LEVELS: readonly VisibilityLevelOption[] = [
143
143
  },
144
144
  ];
145
145
 
146
+ /**
147
+ * The levels an environment selector offers, in escalation order:
148
+ * Private / Organization. Broader levels are structurally absent —
149
+ * secret values never leave the org boundary (the backend rejects
150
+ * public/platform via the kind's VisibilityConfig).
151
+ *
152
+ * Org sharing on an environment carries credential semantics, so the
153
+ * copy names both effects: members get redacted view, and executions
154
+ * in the org (teammate-run agents AND shared-agent visitors) can use
155
+ * the values at runtime. Secret reveal stays creator-only at every
156
+ * level.
157
+ *
158
+ * In `local` mode (OSS Go backend, single-user) sharing has no
159
+ * enforcement meaning, so no interactive levels are offered —
160
+ * {@link ResourceVisibilityControl} degrades to a read-only badge.
161
+ */
162
+ export function environmentVisibilityLevels(
163
+ deploymentMode: "cloud" | "local",
164
+ ): readonly VisibilityLevelOption[] {
165
+ if (deploymentMode === "local") {
166
+ return [PRIVATE_OPTION];
167
+ }
168
+ return [
169
+ {
170
+ ...PRIVATE_OPTION,
171
+ description: "Only you can view and use these credentials",
172
+ },
173
+ {
174
+ ...ORG_OPTION,
175
+ description:
176
+ "Agents run in your org — including shared-agent visitors — can use these credentials. Members see names only; secret values stay hidden.",
177
+ confirmPrompt: "Let agents run in your org use these credentials?",
178
+ },
179
+ ];
180
+ }
181
+
146
182
  /**
147
183
  * Canonical option for a visibility value, independent of any kind's offered
148
184
  * list. Used to render the current level even when it is not offerable in
@@ -11,6 +11,8 @@ import { useMcpServerConnect } from "./useMcpServerConnect.js";
11
11
  import { useDisconnectOAuth } from "./useDisconnectOAuth.js";
12
12
  import { EnvVarForm } from "../environment/EnvVarForm.js";
13
13
  import { ErrorMessage } from "../error/ErrorMessage.js";
14
+ import { StdioSandboxNotice } from "./StdioSandboxNotice.js";
15
+ import { OAuthRequiredNotice } from "./OAuthRequiredNotice.js";
14
16
 
15
17
  /** Props for {@link McpServerConnectDialog}. */
16
18
  export interface McpServerConnectDialogProps {
@@ -276,6 +278,9 @@ function ConnectDialogContent({
276
278
  </p>
277
279
  )}
278
280
 
281
+ <StdioSandboxNotice serverType={mcpServer.spec?.serverType} className="mb-4" />
282
+ <OAuthRequiredNotice oauthOnly={mcpServer.spec?.auth?.oauthOnly} className="mb-4" />
283
+
279
284
  {activeError && (
280
285
  <div className="mb-4">
281
286
  <ErrorMessage
@@ -295,7 +300,11 @@ function ConnectDialogContent({
295
300
  phase={oauth.phase}
296
301
  onSignIn={handleOAuthSignIn}
297
302
  isVendorApprovalBlocked={creds.isVendorApprovalBlocked}
298
- onSwitchToManual={() => creds.setManualOverride(true)}
303
+ onSwitchToManual={
304
+ creds.manualEntrySupported
305
+ ? () => creds.setManualOverride(true)
306
+ : undefined
307
+ }
299
308
  disabled={isConnectingPhase}
300
309
  />
301
310
  )}
@@ -408,7 +417,8 @@ function OAuthSection({
408
417
  readonly phase: OAuthConnectPhase;
409
418
  readonly onSignIn: () => void;
410
419
  readonly isVendorApprovalBlocked: boolean;
411
- readonly onSwitchToManual: () => void;
420
+ /** When omitted (e.g. `oauth_only` servers), no manual-entry link is shown. */
421
+ readonly onSwitchToManual?: () => void;
412
422
  readonly disabled?: boolean;
413
423
  }) {
414
424
  if (isConnected) {
@@ -445,19 +455,21 @@ function OAuthSection({
445
455
  {isInProgress && <LoadingSpinner size="sm" />}
446
456
  {isInProgress ? (phaseLabel[phase] ?? "Connecting...") : "Sign in with OAuth"}
447
457
  </button>
448
- {isVendorApprovalBlocked && (
458
+ {isVendorApprovalBlocked && onSwitchToManual && (
449
459
  <p className="text-xs text-muted-foreground">
450
460
  OAuth sign-in is pending vendor approval. You can enter your token manually instead.
451
461
  </p>
452
462
  )}
453
- <button
454
- type="button"
455
- onClick={onSwitchToManual}
456
- disabled={disabled || isInProgress}
457
- className="text-xs text-muted-foreground underline hover:text-foreground"
458
- >
459
- Enter token manually
460
- </button>
463
+ {onSwitchToManual && (
464
+ <button
465
+ type="button"
466
+ onClick={onSwitchToManual}
467
+ disabled={disabled || isInProgress}
468
+ className="text-xs text-muted-foreground underline hover:text-foreground"
469
+ >
470
+ Enter token manually
471
+ </button>
472
+ )}
461
473
  </div>
462
474
  );
463
475
  }
@@ -20,6 +20,8 @@ import { useMcpServerConnect } from "./useMcpServerConnect.js";
20
20
  import { useMcpServerCredentials } from "./useMcpServerCredentials.js";
21
21
  import { useMcpServerOAuthConnect } from "./useMcpServerOAuthConnect.js";
22
22
  import type { OAuthConnectPhase } from "./useMcpServerOAuthConnect.js";
23
+ import { StdioSandboxNotice } from "./StdioSandboxNotice.js";
24
+ import { OAuthRequiredNotice } from "./OAuthRequiredNotice.js";
23
25
  import { useDisconnectOAuth } from "./useDisconnectOAuth.js";
24
26
  import { useOrgOAuthApp } from "./useOrgOAuthApp.js";
25
27
  import { OAuthAppForm } from "./OAuthAppForm.js";
@@ -488,7 +490,10 @@ export function McpServerDetailView({
488
490
  )}
489
491
 
490
492
  <Section title="Connection">
493
+ <StdioSandboxNotice serverType={spec?.serverType} className="mb-3" />
494
+ <OAuthRequiredNotice oauthOnly={spec?.auth?.oauthOnly} className="mb-3" />
491
495
  <ConnectBar
496
+ manualEntrySupported={credentials.manualEntrySupported}
492
497
  isConnecting={connection.isConnecting || oauth.isInProgress}
493
498
  connectionError={combinedError}
494
499
  onConnect={handleConnectClick}
@@ -709,6 +714,7 @@ function ConnectBar({
709
714
  isRemovingOrgApp,
710
715
  removeOrgAppError,
711
716
  onClearRemoveOrgAppError,
717
+ manualEntrySupported,
712
718
  manualOverride,
713
719
  onManualOverride,
714
720
  onBackToOAuth,
@@ -742,6 +748,8 @@ function ConnectBar({
742
748
  readonly isRemovingOrgApp: boolean;
743
749
  readonly removeOrgAppError: Error | null;
744
750
  readonly onClearRemoveOrgAppError: () => void;
751
+ /** `false` for `oauth_only` servers — the manual-entry link is suppressed. */
752
+ readonly manualEntrySupported: boolean;
745
753
  readonly manualOverride: boolean;
746
754
  readonly onManualOverride: () => void;
747
755
  readonly onBackToOAuth: () => void;
@@ -1047,8 +1055,11 @@ function ConnectBar({
1047
1055
  </div>
1048
1056
  )}
1049
1057
 
1050
- {/* Secondary actions: manual entry, BYOA, back to OAuth */}
1051
- {authMode === "oauth" && !isOAuthConnected && !isOAuthBusy && !isConnecting && (
1058
+ {/* Secondary actions: manual entry, BYOA, back to OAuth. Suppressed
1059
+ entirely for oauth_only servers with no BYOA option, so no empty
1060
+ action bar renders. */}
1061
+ {authMode === "oauth" && !isOAuthConnected && !isOAuthBusy && !isConnecting &&
1062
+ (manualOverride || manualEntrySupported || canBringOwnApp) && (
1052
1063
  <div className="flex items-center gap-3 border-t border-border px-3 py-1.5">
1053
1064
  {manualOverride ? (
1054
1065
  <button
@@ -1060,13 +1071,15 @@ function ConnectBar({
1060
1071
  </button>
1061
1072
  ) : (
1062
1073
  <>
1063
- <button
1064
- type="button"
1065
- onClick={onManualOverride}
1066
- className="text-[11px] text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground hover:decoration-foreground"
1067
- >
1068
- Enter token manually
1069
- </button>
1074
+ {manualEntrySupported && (
1075
+ <button
1076
+ type="button"
1077
+ onClick={onManualOverride}
1078
+ className="text-[11px] text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground hover:decoration-foreground"
1079
+ >
1080
+ Enter token manually
1081
+ </button>
1082
+ )}
1070
1083
  {canBringOwnApp && !isVendorApprovalBlocked && (
1071
1084
  <button
1072
1085
  type="button"
@@ -404,6 +404,8 @@ export function McpServerPicker({
404
404
  const auth = entry.mcpServer.spec?.auth;
405
405
  const oauthTargetEnvVar = auth?.targetEnvVar || null;
406
406
  const hasOAuth = !!auth;
407
+ // oauth_only endpoints reject static tokens — never offer manual entry.
408
+ const manualEntrySupported = !auth?.oauthOnly;
407
409
  const isManualOverride = manualOverrideKeys.has(view.serverKey);
408
410
 
409
411
  const entryMissingVars =
@@ -454,15 +456,16 @@ export function McpServerPicker({
454
456
  }
455
457
  : undefined;
456
458
 
457
- const handleSwitchToManual = hasOAuth
458
- ? () => {
459
- setManualOverrideKeys((prev) => {
460
- const next = new Set(prev);
461
- next.add(view.serverKey);
462
- return next;
463
- });
464
- }
465
- : undefined;
459
+ const handleSwitchToManual =
460
+ hasOAuth && manualEntrySupported
461
+ ? () => {
462
+ setManualOverrideKeys((prev) => {
463
+ const next = new Set(prev);
464
+ next.add(view.serverKey);
465
+ return next;
466
+ });
467
+ }
468
+ : undefined;
466
469
 
467
470
  const handleSwitchToOAuth =
468
471
  hasOAuth && isManualOverride
@@ -0,0 +1,77 @@
1
+ "use client";
2
+
3
+ import { cn } from "@stigmer/theme";
4
+
5
+ /** Props for {@link OAuthRequiredNotice}. */
6
+ export interface OAuthRequiredNoticeProps {
7
+ /**
8
+ * The server's `spec.auth.oauth_only` flag. When `true`, the endpoint
9
+ * rejects manually-entered static tokens and OAuth is the only path.
10
+ */
11
+ readonly oauthOnly: boolean | undefined;
12
+ /** Additional CSS class names for the root container. */
13
+ readonly className?: string;
14
+ }
15
+
16
+ /**
17
+ * Sets accurate expectations for connecting an **OAuth-only** MCP server —
18
+ * one whose hosted endpoint rejects manually-entered static tokens
19
+ * (`spec.auth.oauth_only`, e.g. Notion, Monday).
20
+ *
21
+ * Without this notice a user might expect the (now-hidden) manual token
22
+ * option and wonder why only "Sign in" is offered. It explains, in one line,
23
+ * that OAuth is required and a pasted API token would be rejected — turning a
24
+ * silent constraint into a clear one (Nielsen: visibility of system status).
25
+ *
26
+ * Self-gating: renders `null` unless the server is `oauth_only`. Callers
27
+ * render it unconditionally next to their Connect action, mirroring
28
+ * {@link StdioSandboxNotice}.
29
+ *
30
+ * All visual properties flow through `--stgm-*` design tokens. No
31
+ * Console-specific dependencies — safe for platform-builder embedding.
32
+ */
33
+ export function OAuthRequiredNotice({
34
+ oauthOnly,
35
+ className,
36
+ }: OAuthRequiredNoticeProps) {
37
+ if (!oauthOnly) return null;
38
+
39
+ return (
40
+ <div
41
+ role="status"
42
+ className={cn(
43
+ "bg-muted-subtle text-muted-foreground flex items-start gap-2.5 rounded-lg border border-transparent px-4 py-3",
44
+ className,
45
+ )}
46
+ >
47
+ <KeyIcon className="mt-0.5 size-4 shrink-0" />
48
+ <p className="text-xs leading-relaxed">
49
+ This server requires OAuth. Sign in to connect — its hosted endpoint
50
+ rejects manually-entered API tokens, so a pasted token won&apos;t work
51
+ here.
52
+ </p>
53
+ </div>
54
+ );
55
+ }
56
+
57
+ function KeyIcon({ className }: { className?: string }) {
58
+ return (
59
+ <svg
60
+ width="16"
61
+ height="16"
62
+ viewBox="0 0 16 16"
63
+ fill="none"
64
+ stroke="currentColor"
65
+ strokeWidth="1.5"
66
+ strokeLinecap="round"
67
+ strokeLinejoin="round"
68
+ className={className}
69
+ aria-hidden="true"
70
+ >
71
+ <circle cx="5" cy="11" r="2.5" />
72
+ <path d="M6.8 9.2 13 3" />
73
+ <path d="M11 5l1.5 1.5" />
74
+ <path d="M9 7l1.5 1.5" />
75
+ </svg>
76
+ );
77
+ }
@@ -0,0 +1,98 @@
1
+ "use client";
2
+
3
+ import { cn } from "@stigmer/theme";
4
+ import type { DeploymentMode } from "@stigmer/sdk";
5
+ import type { McpServerSpec } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/spec_pb";
6
+ import { useDeploymentMode } from "../deployment-mode.js";
7
+
8
+ /** The `server_type` oneof discriminator from an MCP server's spec. */
9
+ type McpServerType = McpServerSpec["serverType"];
10
+
11
+ /**
12
+ * Whether an MCP server's transport is stdio while connected to Stigmer Cloud.
13
+ *
14
+ * stdio servers run as a subprocess inside an isolated Daytona sandbox in the
15
+ * cloud — not on the user's own computer. This predicate identifies exactly
16
+ * that combination so the connect UI can set accurate expectations. HTTP
17
+ * servers and any transport in local mode return `false`.
18
+ *
19
+ * Pure and framework-free so it can be unit-tested without rendering.
20
+ */
21
+ export function isStdioInCloud(
22
+ mode: DeploymentMode,
23
+ serverType: McpServerType | undefined,
24
+ ): boolean {
25
+ return mode === "cloud" && serverType?.case === "stdio";
26
+ }
27
+
28
+ /** Props for {@link StdioSandboxNotice}. */
29
+ export interface StdioSandboxNoticeProps {
30
+ /** The MCP server's `spec.serverType` oneof. */
31
+ readonly serverType: McpServerType | undefined;
32
+ /** Additional CSS class names for the root container. */
33
+ readonly className?: string;
34
+ }
35
+
36
+ /**
37
+ * Sets accurate expectations for connecting an **stdio** MCP server from
38
+ * **Stigmer Cloud**.
39
+ *
40
+ * stdio servers are a supported cloud capability — Stigmer runs them in an
41
+ * isolated Daytona sandbox. But that sandbox is not the user's own machine,
42
+ * so a server that expects access to local files, applications, or a private
43
+ * network (e.g. a filesystem server) won't behave as the user intends. This
44
+ * notice explains that up front; Connect itself stays enabled because
45
+ * self-contained servers work fine.
46
+ *
47
+ * Self-gating: reads the deployment mode from context and renders `null`
48
+ * unless the server is stdio and the backend is cloud. Callers render it
49
+ * unconditionally next to their Connect action.
50
+ *
51
+ * All visual properties flow through `--stgm-*` design tokens. No
52
+ * Console-specific dependencies — safe for platform-builder embedding.
53
+ */
54
+ export function StdioSandboxNotice({
55
+ serverType,
56
+ className,
57
+ }: StdioSandboxNoticeProps) {
58
+ const mode = useDeploymentMode();
59
+ if (!isStdioInCloud(mode, serverType)) return null;
60
+
61
+ return (
62
+ <div
63
+ role="status"
64
+ className={cn(
65
+ "bg-muted-subtle text-muted-foreground flex items-start gap-2.5 rounded-lg border border-transparent px-4 py-3",
66
+ className,
67
+ )}
68
+ >
69
+ <SandboxIcon className="mt-0.5 size-4 shrink-0" />
70
+ <p className="text-xs leading-relaxed">
71
+ This stdio server runs in an isolated cloud sandbox, not on your own
72
+ computer. Tools that need access to your local files, applications, or
73
+ private network won&apos;t be available here.
74
+ </p>
75
+ </div>
76
+ );
77
+ }
78
+
79
+ function SandboxIcon({ className }: { className?: string }) {
80
+ return (
81
+ <svg
82
+ width="16"
83
+ height="16"
84
+ viewBox="0 0 16 16"
85
+ fill="none"
86
+ stroke="currentColor"
87
+ strokeWidth="1.5"
88
+ strokeLinecap="round"
89
+ strokeLinejoin="round"
90
+ className={className}
91
+ aria-hidden="true"
92
+ >
93
+ <path d="M2 5.5 8 2.5l6 3-6 3-6-3Z" />
94
+ <path d="M2 5.5v5l6 3 6-3v-5" />
95
+ <path d="M8 8.5v5" />
96
+ </svg>
97
+ );
98
+ }
@@ -0,0 +1,25 @@
1
+ import { describe, it, expect, afterEach } from "vitest";
2
+ import { render, screen, cleanup } from "@testing-library/react";
3
+ import { OAuthRequiredNotice } from "../OAuthRequiredNotice";
4
+
5
+ afterEach(cleanup);
6
+
7
+ describe("OAuthRequiredNotice", () => {
8
+ it("renders the OAuth-required caveat when oauth_only is true", () => {
9
+ render(<OAuthRequiredNotice oauthOnly={true} />);
10
+ expect(screen.getByRole("status")).toBeTruthy();
11
+ expect(screen.getByText(/requires OAuth/i)).toBeTruthy();
12
+ // It explains why manual entry is gone, not just that OAuth is used.
13
+ expect(screen.getByText(/rejects manually-entered API tokens/i)).toBeTruthy();
14
+ });
15
+
16
+ it("renders nothing when oauth_only is false", () => {
17
+ const { container } = render(<OAuthRequiredNotice oauthOnly={false} />);
18
+ expect(container.firstChild).toBeNull();
19
+ });
20
+
21
+ it("renders nothing when oauth_only is undefined", () => {
22
+ const { container } = render(<OAuthRequiredNotice oauthOnly={undefined} />);
23
+ expect(container.firstChild).toBeNull();
24
+ });
25
+ });
@@ -0,0 +1,71 @@
1
+ import { describe, it, expect, afterEach } from "vitest";
2
+ import { render, screen, cleanup } from "@testing-library/react";
3
+ import type { ReactNode } from "react";
4
+ import type { McpServerSpec } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/spec_pb";
5
+ import { DeploymentModeContext } from "../../deployment-mode";
6
+ import { StdioSandboxNotice, isStdioInCloud } from "../StdioSandboxNotice";
7
+
8
+ type McpServerType = McpServerSpec["serverType"];
9
+
10
+ const STDIO = { case: "stdio" } as McpServerType;
11
+ const HTTP = { case: "http" } as McpServerType;
12
+ const UNSET = { case: undefined } as McpServerType;
13
+
14
+ afterEach(cleanup);
15
+
16
+ describe("isStdioInCloud", () => {
17
+ it("is true only for stdio transport in cloud mode", () => {
18
+ expect(isStdioInCloud("cloud", STDIO)).toBe(true);
19
+ });
20
+
21
+ it("is false for stdio transport in local mode", () => {
22
+ expect(isStdioInCloud("local", STDIO)).toBe(false);
23
+ });
24
+
25
+ it("is false for http transport in cloud mode", () => {
26
+ expect(isStdioInCloud("cloud", HTTP)).toBe(false);
27
+ });
28
+
29
+ it("is false when the transport oneof is unset", () => {
30
+ expect(isStdioInCloud("cloud", UNSET)).toBe(false);
31
+ });
32
+
33
+ it("is false when serverType is undefined", () => {
34
+ expect(isStdioInCloud("cloud", undefined)).toBe(false);
35
+ });
36
+ });
37
+
38
+ function withMode(mode: "cloud" | "local", children: ReactNode) {
39
+ return (
40
+ <DeploymentModeContext.Provider value={mode}>
41
+ {children}
42
+ </DeploymentModeContext.Provider>
43
+ );
44
+ }
45
+
46
+ describe("StdioSandboxNotice", () => {
47
+ it("renders the sandbox-isolation caveat for stdio in cloud", () => {
48
+ render(withMode("cloud", <StdioSandboxNotice serverType={STDIO} />));
49
+ expect(screen.getByRole("status")).toBeTruthy();
50
+ expect(screen.getByText(/isolated cloud sandbox/i)).toBeTruthy();
51
+ });
52
+
53
+ it("does not suggest the CLI (avoids inaccurate guidance)", () => {
54
+ render(withMode("cloud", <StdioSandboxNotice serverType={STDIO} />));
55
+ expect(screen.queryByText(/stigmer connect/i)).toBeNull();
56
+ });
57
+
58
+ it("renders nothing for http servers in cloud", () => {
59
+ const { container } = render(
60
+ withMode("cloud", <StdioSandboxNotice serverType={HTTP} />),
61
+ );
62
+ expect(container.firstChild).toBeNull();
63
+ });
64
+
65
+ it("renders nothing for stdio servers in local mode", () => {
66
+ const { container } = render(
67
+ withMode("local", <StdioSandboxNotice serverType={STDIO} />),
68
+ );
69
+ expect(container.firstChild).toBeNull();
70
+ });
71
+ });
@@ -153,6 +153,18 @@ export interface UseMcpServerCredentialsReturn {
153
153
  * link (when vendor approval is granted).
154
154
  */
155
155
  readonly canBringOwnApp: boolean;
156
+ /**
157
+ * `true` when a manually-entered static token is a valid way to
158
+ * authenticate this server. `false` for `oauth_only` servers whose
159
+ * hosted endpoint rejects static tokens (`spec.auth.oauth_only`), where
160
+ * OAuth is the sole credential path.
161
+ *
162
+ * Connect surfaces use this to decide whether to offer the "enter token
163
+ * manually" affordance — offering it on an `oauth_only` server would send
164
+ * the user down a path that cannot succeed. Always `true` for manual-only
165
+ * and PAT-capable servers.
166
+ */
167
+ readonly manualEntrySupported: boolean;
156
168
  /**
157
169
  * When `true`, the user has opted to bypass OAuth and enter the
158
170
  * `target_env_var` token manually. In this state:
@@ -251,6 +263,14 @@ export function useMcpServerCredentials(
251
263
  const oauthTargetEnvVar = auth?.targetEnvVar || null;
252
264
  const tokenLifetimeHint = auth?.tokenLifetimeHint || null;
253
265
 
266
+ // A static token is a valid credential for every server except those whose
267
+ // endpoint declares it rejects them (`oauth_only`). This is the single source
268
+ // of truth the connect surfaces consult before offering manual entry.
269
+ const manualEntrySupported = !auth?.oauthOnly;
270
+ // Defensively force manual override off for oauth_only servers so no surface
271
+ // can enter a dead-end manual-entry state, even if a stale toggle is set.
272
+ const effectiveManualOverride = manualOverride && manualEntrySupported;
273
+
254
274
  const oauthStatus = mcpServer?.status?.oauthStatus;
255
275
  const isVendorApprovalPending =
256
276
  authMode === "oauth" &&
@@ -298,15 +318,15 @@ export function useMcpServerCredentials(
298
318
  );
299
319
 
300
320
  const missingVariables = useMemo(() => {
301
- if (!oauthTargetEnvVar || manualOverride) return requiredMissing;
321
+ if (!oauthTargetEnvVar || effectiveManualOverride) return requiredMissing;
302
322
  return requiredMissing.filter((v) => v.key !== oauthTargetEnvVar);
303
- }, [requiredMissing, oauthTargetEnvVar, manualOverride]);
323
+ }, [requiredMissing, oauthTargetEnvVar, effectiveManualOverride]);
304
324
 
305
325
  const isReady =
306
326
  !personalEnv.isLoading &&
307
327
  !grantStatus.isLoading &&
308
328
  missingVariables.length === 0 &&
309
- (authMode === "manual" || manualOverride || isOAuthConnected);
329
+ (authMode === "manual" || effectiveManualOverride || isOAuthConnected);
310
330
 
311
331
  const saveCredentials = useCallback(
312
332
  async (values: Record<string, EnvVarInput>): Promise<void> => {
@@ -335,6 +355,7 @@ export function useMcpServerCredentials(
335
355
  effectiveOAuthSource,
336
356
  isOrgOAuthApp,
337
357
  canBringOwnApp,
358
+ manualEntrySupported,
338
359
  missingVariables,
339
360
  isReady,
340
361
  isLoading: personalEnv.isLoading || grantStatus.isLoading,
@@ -342,7 +363,7 @@ export function useMcpServerCredentials(
342
363
  saveCredentials,
343
364
  isSaving: personalEnv.isMutating,
344
365
  refetch,
345
- manualOverride,
366
+ manualOverride: effectiveManualOverride,
346
367
  setManualOverride,
347
368
  };
348
369
  }