@blade-hq/agent-react 2612.0.0-beta.67 → 2612.0.0-beta.69

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 (91) hide show
  1. package/README.md +2 -0
  2. package/dist/{chunk-MAFNMG2O.js → chunk-2DPLLZOU.js} +18 -13
  3. package/dist/{chunk-MAFNMG2O.js.map → chunk-2DPLLZOU.js.map} +1 -1
  4. package/dist/{chunk-N576N2XO.js → chunk-7MCGQH34.js} +12 -9
  5. package/dist/chunk-7MCGQH34.js.map +1 -0
  6. package/dist/{chunk-UC7SY3G5.js → chunk-HCW7SI5Q.js} +333 -269
  7. package/dist/chunk-HCW7SI5Q.js.map +1 -0
  8. package/dist/{chunk-X66C66OQ.js → chunk-J72ZLILV.js} +287 -67
  9. package/dist/chunk-J72ZLILV.js.map +1 -0
  10. package/dist/{chunk-HS5G33FO.js → chunk-QIR73CES.js} +1031 -8
  11. package/dist/chunk-QIR73CES.js.map +1 -0
  12. package/dist/{chunk-VSIUEXGV.js → chunk-WRIMPZPN.js} +12 -962
  13. package/dist/chunk-WRIMPZPN.js.map +1 -0
  14. package/dist/{chunk-XV6AO37F.js → chunk-XJ6ZA6LN.js} +9 -9
  15. package/dist/{chunk-U3RHQHI6.js → chunk-XP6T6SHZ.js} +48 -48
  16. package/dist/components/AccountConnectors.d.ts +1 -1
  17. package/dist/components/ManagedConnection.d.ts +0 -1
  18. package/dist/components/McpAppFrame.d.ts +17 -0
  19. package/dist/components/SessionPluginIcon.d.ts +1 -0
  20. package/dist/connectors.js +2 -2
  21. package/dist/index.js +7 -7
  22. package/dist/internal.d.ts +2 -0
  23. package/dist/internal.js +10 -8
  24. package/dist/internal.js.map +1 -1
  25. package/dist/questions.js +4 -5
  26. package/dist/questions.js.map +1 -1
  27. package/dist/rich-input.js +20 -20
  28. package/dist/style.full.css +1 -1
  29. package/dist/tool-details.js +4 -4
  30. package/node_modules/@modelcontextprotocol/ext-apps/LICENSE +216 -0
  31. package/node_modules/@modelcontextprotocol/ext-apps/README.md +284 -0
  32. package/node_modules/@modelcontextprotocol/ext-apps/dist/docs/patterns.d.ts +9 -0
  33. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.d.ts +1348 -0
  34. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.examples.d.ts +9 -0
  35. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js +39 -0
  36. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.test.d.ts +1 -0
  37. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-with-deps.js +82 -0
  38. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.d.ts +1214 -0
  39. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.examples.d.ts +9 -0
  40. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.js +39 -0
  41. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.test.d.ts +1 -0
  42. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/constants.d.ts +65 -0
  43. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.d.ts +47 -0
  44. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.test.d.ts +1 -0
  45. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.d.ts +1047 -0
  46. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.json +6170 -0
  47. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.test.d.ts +41 -0
  48. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/interop-v1.test.d.ts +1 -0
  49. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.d.ts +66 -0
  50. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.test.d.ts +1 -0
  51. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.d.ts +126 -0
  52. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.examples.d.ts +9 -0
  53. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.test.d.ts +1 -0
  54. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.d.ts +37 -0
  55. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.examples.d.ts +6 -0
  56. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.js +39 -0
  57. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/react-with-deps.js +82 -0
  58. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.d.ts +115 -0
  59. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.examples.d.ts +6 -0
  60. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.d.ts +54 -0
  61. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.examples.d.ts +6 -0
  62. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.d.ts +44 -0
  63. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.examples.d.ts +6 -0
  64. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.d.ts +113 -0
  65. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.examples.d.ts +6 -0
  66. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.d.ts +381 -0
  67. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.examples.d.ts +9 -0
  68. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js +1 -0
  69. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.test.d.ts +1 -0
  70. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/spec.types.d.ts +698 -0
  71. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/standard-schema.d.ts +23 -0
  72. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.d.ts +184 -0
  73. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.examples.d.ts +9 -0
  74. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/types.d.ts +33 -0
  75. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/wire-compat.test.d.ts +1 -0
  76. package/node_modules/@modelcontextprotocol/ext-apps/package.json +144 -0
  77. package/node_modules/@standard-schema/spec/LICENSE +21 -0
  78. package/node_modules/@standard-schema/spec/README.md +198 -0
  79. package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
  80. package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
  81. package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
  82. package/node_modules/@standard-schema/spec/dist/index.js +0 -0
  83. package/node_modules/@standard-schema/spec/package.json +52 -0
  84. package/package.json +6 -2
  85. package/dist/chunk-HS5G33FO.js.map +0 -1
  86. package/dist/chunk-N576N2XO.js.map +0 -1
  87. package/dist/chunk-UC7SY3G5.js.map +0 -1
  88. package/dist/chunk-VSIUEXGV.js.map +0 -1
  89. package/dist/chunk-X66C66OQ.js.map +0 -1
  90. /package/dist/{chunk-XV6AO37F.js.map → chunk-XJ6ZA6LN.js.map} +0 -0
  91. /package/dist/{chunk-U3RHQHI6.js.map → chunk-XP6T6SHZ.js.map} +0 -0
@@ -1,10 +1,15 @@
1
1
  import {
2
2
  Button,
3
+ LoaderCircle,
3
4
  cn,
4
- dist_exports3 as dist_exports,
5
+ cva,
6
+ dist_exports,
7
+ dist_exports4 as dist_exports2,
8
+ dist_exports5 as dist_exports3,
9
+ dist_exports7 as dist_exports4,
5
10
  loopTabInShadowRoot,
6
11
  useOverlayRoot
7
- } from "./chunk-HS5G33FO.js";
12
+ } from "./chunk-QIR73CES.js";
8
13
 
9
14
  // src/components/DeviceConnection.tsx
10
15
  import { useEffect, useRef, useState } from "react";
@@ -1116,19 +1121,19 @@ import { jsx, jsxs } from "react/jsx-runtime";
1116
1121
  function AlertDialog({
1117
1122
  ...props
1118
1123
  }) {
1119
- return /* @__PURE__ */ jsx(dist_exports.Root, { "data-slot": "alert-dialog", ...props });
1124
+ return /* @__PURE__ */ jsx(dist_exports2.Root, { "data-slot": "alert-dialog", ...props });
1120
1125
  }
1121
1126
  function AlertDialogTrigger({
1122
1127
  ...props
1123
1128
  }) {
1124
- return /* @__PURE__ */ jsx(dist_exports.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
1129
+ return /* @__PURE__ */ jsx(dist_exports2.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
1125
1130
  }
1126
1131
  function AlertDialogOverlay({
1127
1132
  className,
1128
1133
  ...props
1129
1134
  }) {
1130
1135
  return /* @__PURE__ */ jsx(
1131
- dist_exports.Overlay,
1136
+ dist_exports2.Overlay,
1132
1137
  {
1133
1138
  "data-slot": "alert-dialog-overlay",
1134
1139
  className: cn(
@@ -1139,12 +1144,44 @@ function AlertDialogOverlay({
1139
1144
  }
1140
1145
  );
1141
1146
  }
1147
+ function AlertDialogHeader({
1148
+ className,
1149
+ ...props
1150
+ }) {
1151
+ return /* @__PURE__ */ jsx(
1152
+ "div",
1153
+ {
1154
+ "data-slot": "alert-dialog-header",
1155
+ className: cn(
1156
+ "grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
1157
+ className
1158
+ ),
1159
+ ...props
1160
+ }
1161
+ );
1162
+ }
1163
+ function AlertDialogFooter({
1164
+ className,
1165
+ ...props
1166
+ }) {
1167
+ return /* @__PURE__ */ jsx(
1168
+ "div",
1169
+ {
1170
+ "data-slot": "alert-dialog-footer",
1171
+ className: cn(
1172
+ "-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
1173
+ className
1174
+ ),
1175
+ ...props
1176
+ }
1177
+ );
1178
+ }
1142
1179
  function AlertDialogTitle({
1143
1180
  className,
1144
1181
  ...props
1145
1182
  }) {
1146
1183
  return /* @__PURE__ */ jsx(
1147
- dist_exports.Title,
1184
+ dist_exports2.Title,
1148
1185
  {
1149
1186
  "data-slot": "alert-dialog-title",
1150
1187
  className: cn(
@@ -1160,7 +1197,7 @@ function AlertDialogDescription({
1160
1197
  ...props
1161
1198
  }) {
1162
1199
  return /* @__PURE__ */ jsx(
1163
- dist_exports.Description,
1200
+ dist_exports2.Description,
1164
1201
  {
1165
1202
  "data-slot": "alert-dialog-description",
1166
1203
  className: cn(
@@ -1178,7 +1215,7 @@ function AlertDialogAction({
1178
1215
  ...props
1179
1216
  }) {
1180
1217
  return /* @__PURE__ */ jsx(Button, { variant, size, asChild: true, children: /* @__PURE__ */ jsx(
1181
- dist_exports.Action,
1218
+ dist_exports2.Action,
1182
1219
  {
1183
1220
  "data-slot": "alert-dialog-action",
1184
1221
  className: cn(className),
@@ -1193,7 +1230,7 @@ function AlertDialogCancel({
1193
1230
  ...props
1194
1231
  }) {
1195
1232
  return /* @__PURE__ */ jsx(Button, { variant, size, asChild: true, children: /* @__PURE__ */ jsx(
1196
- dist_exports.Cancel,
1233
+ dist_exports2.Cancel,
1197
1234
  {
1198
1235
  "data-slot": "alert-dialog-cancel",
1199
1236
  className: cn(className),
@@ -1212,10 +1249,10 @@ function AlertDialogContent({
1212
1249
  ...props
1213
1250
  }) {
1214
1251
  const overlayRoot = useOverlayRoot();
1215
- return /* @__PURE__ */ jsxs2(dist_exports.Portal, { "data-slot": "alert-dialog-portal", container: overlayRoot, children: [
1252
+ return /* @__PURE__ */ jsxs2(dist_exports2.Portal, { "data-slot": "alert-dialog-portal", container: overlayRoot, children: [
1216
1253
  /* @__PURE__ */ jsx2(AlertDialogOverlay, { className: overlayClassName }),
1217
1254
  /* @__PURE__ */ jsx2(
1218
- dist_exports.Content,
1255
+ dist_exports2.Content,
1219
1256
  {
1220
1257
  onKeyDown: (event) => {
1221
1258
  onKeyDown?.(event);
@@ -1626,9 +1663,12 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1626
1663
  }
1627
1664
  }
1628
1665
  const start = (retryIDs) => {
1629
- let focus = retryIDs ?? defaultCapabilities(view?.capabilities ?? []);
1630
- if (!view?.app_id && !focus.length) focus = view?.selected_capabilities?.length ? view.selected_capabilities : capabilities.filter((item) => item.default && item.status !== "unsupported").map((item) => item.id);
1631
- const target = [.../* @__PURE__ */ new Set([...view?.selected_capabilities ?? [], ...focus])];
1666
+ let focus = retryIDs ?? defaultCapabilities((view?.capabilities ?? []).filter((item) => view?.app_id || item.identity === "bot"));
1667
+ if (!view?.app_id && !focus.length) {
1668
+ focus = capabilities.filter((item) => item.identity === "bot" && item.default && item.status !== "unsupported").map((item) => item.id);
1669
+ if (!focus.length && view?.catalog_unavailable) focus = (view.selected_capabilities ?? []).filter((id) => ["bot_send", "bot_receive_p2p", "bot_receive_at", "bot_receive_group"].includes(id));
1670
+ }
1671
+ const target = [.../* @__PURE__ */ new Set([...view?.app_id ? view.selected_capabilities ?? [] : [], ...focus])];
1632
1672
  if (!view?.app_id) {
1633
1673
  linking.current = false;
1634
1674
  flow.current = { enable: true, capabilities: target, focus };
@@ -1969,22 +2009,117 @@ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = fa
1969
2009
  }
1970
2010
 
1971
2011
  // src/components/ManagedConnection.tsx
1972
- import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
1973
- import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1974
- function managedAuthorizationURL(view) {
1975
- if (!view?.authorization_url || !view.connection_id) return null;
1976
- try {
1977
- const url = new URL(view.authorization_url);
1978
- return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash && url.pathname === `/connections/${encodeURIComponent(view.connection_id)}/authorize` ? url.href : null;
1979
- } catch {
1980
- return null;
2012
+ import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState2 } from "react";
2013
+
2014
+ // ../ui/src/components/badge.tsx
2015
+ import { jsx as jsx8 } from "react/jsx-runtime";
2016
+ var badgeVariants = cva(
2017
+ "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
2018
+ {
2019
+ variants: {
2020
+ variant: {
2021
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
2022
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
2023
+ destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
2024
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
2025
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
2026
+ link: "text-primary underline-offset-4 hover:underline"
2027
+ }
2028
+ },
2029
+ defaultVariants: {
2030
+ variant: "default"
2031
+ }
1981
2032
  }
2033
+ );
2034
+ function Badge({
2035
+ className,
2036
+ variant = "default",
2037
+ asChild = false,
2038
+ ...props
2039
+ }) {
2040
+ const Comp = asChild ? dist_exports.Root : "span";
2041
+ return /* @__PURE__ */ jsx8(
2042
+ Comp,
2043
+ {
2044
+ "data-slot": "badge",
2045
+ "data-variant": variant,
2046
+ className: cn(badgeVariants({ variant }), className),
2047
+ ...props
2048
+ }
2049
+ );
1982
2050
  }
1983
- var button2 = "rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] px-3 py-2 text-sm disabled:opacity-50";
2051
+
2052
+ // ../ui/src/components/input.tsx
2053
+ import { jsx as jsx9 } from "react/jsx-runtime";
2054
+ function Input({ className, type, ...props }) {
2055
+ return /* @__PURE__ */ jsx9(
2056
+ "input",
2057
+ {
2058
+ type,
2059
+ "data-slot": "input",
2060
+ className: cn(
2061
+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
2062
+ className
2063
+ ),
2064
+ ...props
2065
+ }
2066
+ );
2067
+ }
2068
+
2069
+ // ../ui/src/components/label.tsx
2070
+ import { jsx as jsx10 } from "react/jsx-runtime";
2071
+ function Label({
2072
+ className,
2073
+ ...props
2074
+ }) {
2075
+ return /* @__PURE__ */ jsx10(
2076
+ dist_exports3.Root,
2077
+ {
2078
+ "data-slot": "label",
2079
+ className: cn(
2080
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
2081
+ className
2082
+ ),
2083
+ ...props
2084
+ }
2085
+ );
2086
+ }
2087
+
2088
+ // ../ui/src/components/separator.tsx
2089
+ import { jsx as jsx11 } from "react/jsx-runtime";
2090
+ function Separator({
2091
+ className,
2092
+ orientation = "horizontal",
2093
+ decorative = true,
2094
+ ...props
2095
+ }) {
2096
+ return /* @__PURE__ */ jsx11(
2097
+ dist_exports4.Root,
2098
+ {
2099
+ "data-slot": "separator",
2100
+ decorative,
2101
+ orientation,
2102
+ className: cn(
2103
+ "shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
2104
+ className
2105
+ ),
2106
+ ...props
2107
+ }
2108
+ );
2109
+ }
2110
+
2111
+ // src/components/ManagedConnection.tsx
2112
+ import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
2113
+ var field = "h-10 focus-visible:ring-1 focus-visible:ring-foreground/30 focus-visible:border-foreground/70";
2114
+ var deliveryFailure = (reason) => `\u90AE\u7BB1\u5DF2\u8FDE\u63A5\uFF0C\u63A5\u5165\u52A9\u624B\u6D88\u606F\u672A\u5B8C\u6210${reason ? `\uFF1A${reason}` : "\uFF0C\u53EF\u70B9\u51FB\u91CD\u8BD5\u3002"}`;
1984
2115
  function ManagedConnection({ read, act, onChanged, bindDelivery, onDisable }) {
1985
2116
  const [view, setView] = useState2(null);
1986
2117
  const [busy, setBusy] = useState2(true);
1987
2118
  const [failure, setFailure] = useState2("");
2119
+ const [email, setEmail] = useState2("");
2120
+ const [code, setCode] = useState2("");
2121
+ const [editing, setEditing] = useState2(false);
2122
+ const formId = useId();
1988
2123
  const callbacks = useRef2({ read, act, onChanged, onDisable });
1989
2124
  callbacks.current = { read, act, onChanged, onDisable };
1990
2125
  const alive = useRef2(false);
@@ -1992,7 +2127,10 @@ function ManagedConnection({ read, act, onChanged, bindDelivery, onDisable }) {
1992
2127
  alive.current = true;
1993
2128
  let cancelled = false;
1994
2129
  callbacks.current.read().then((value) => {
1995
- if (!cancelled) setView(value);
2130
+ if (!cancelled) {
2131
+ setView(value);
2132
+ setFailure(value.error?.message || "");
2133
+ }
1996
2134
  }).catch(() => {
1997
2135
  if (!cancelled) setFailure("\u8FDE\u63A5\u72B6\u6001\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u8BD5");
1998
2136
  }).finally(() => {
@@ -2004,6 +2142,7 @@ function ManagedConnection({ read, act, onChanged, bindDelivery, onDisable }) {
2004
2142
  };
2005
2143
  }, []);
2006
2144
  const perform = async (action) => {
2145
+ if (busy) return;
2007
2146
  setBusy(true);
2008
2147
  setFailure("");
2009
2148
  try {
@@ -2014,56 +2153,137 @@ function ManagedConnection({ read, act, onChanged, bindDelivery, onDisable }) {
2014
2153
  } else if (action === "refresh") next = await callbacks.current.read();
2015
2154
  else next = await callbacks.current.act(action, {
2016
2155
  ...view?.connection_id ? { expected_connection_id: view.connection_id } : {},
2017
- ...action === "finish" ? { enable: true } : {}
2156
+ ...action === "finish" ? { enable: true } : {},
2157
+ ...action === "credentials" ? { email: email.trim(), authorization_code: code } : {}
2018
2158
  });
2019
2159
  if (!alive.current) return;
2160
+ if (action === "bind" && next.error) {
2161
+ setFailure(deliveryFailure(next.error.message));
2162
+ return;
2163
+ }
2020
2164
  setView(next);
2021
2165
  if (next.error) setFailure(next.error.message);
2166
+ else if (action === "credentials" && next.connected) {
2167
+ setEmail("");
2168
+ setCode("");
2169
+ setEditing(false);
2170
+ if (bindDelivery && next.subscription_state !== "paused" && !next.delivery_bound) {
2171
+ try {
2172
+ const bound = await callbacks.current.act("bind", { expected_connection_id: next.connection_id });
2173
+ if (!alive.current) return;
2174
+ if (bound.error) {
2175
+ setFailure(deliveryFailure(bound.error.message));
2176
+ return;
2177
+ }
2178
+ setView(bound);
2179
+ } catch (error) {
2180
+ if (!alive.current) return;
2181
+ setFailure(deliveryFailure(error instanceof Error ? error.message : void 0));
2182
+ return;
2183
+ }
2184
+ }
2185
+ }
2022
2186
  await callbacks.current.onChanged();
2023
- } catch {
2024
- if (alive.current) setFailure("\u64CD\u4F5C\u5C1A\u672A\u5B8C\u6210\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5");
2187
+ } catch (error) {
2188
+ if (alive.current) setFailure(action === "bind" ? deliveryFailure(error instanceof Error ? error.message : void 0) : error instanceof Error ? error.message : "\u64CD\u4F5C\u5C1A\u672A\u5B8C\u6210\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5");
2025
2189
  } finally {
2026
2190
  if (alive.current) setBusy(false);
2027
2191
  }
2028
2192
  };
2029
- const url = managedAuthorizationURL(view);
2030
- return /* @__PURE__ */ jsxs8("section", { "aria-label": "\u8FDE\u63A5\u90AE\u7BB1", className: "space-y-3 text-sm", children: [
2031
- /* @__PURE__ */ jsx8("p", { children: view?.label || "\u5728 SuperWork \u9875\u9762\u8FDE\u63A5\u90AE\u7BB1\uFF0C\u5B8C\u6210\u540E\u8FD4\u56DE\u6838\u9A8C\u3002" }),
2032
- /* @__PURE__ */ jsx8("p", { children: view?.enabled && view.connected ? "\u90AE\u7BB1\u5DF2\u8FDE\u63A5\uFF0C\u53EF\u5728\u5BF9\u8BDD\u4E2D\u4F7F\u7528\u3002" : "\u90AE\u7BB1\u5C1A\u672A\u542F\u7528\u3002" }),
2033
- failure && /* @__PURE__ */ jsx8("p", { role: "alert", children: failure }),
2034
- /* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-2", children: [
2035
- !view?.connection_id && /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, onClick: () => {
2036
- void perform("authorize");
2037
- }, children: "\u8FDE\u63A5\u90AE\u7BB1" }),
2038
- url && /* @__PURE__ */ jsx8("a", { className: button2, href: url, target: "_blank", rel: "noopener noreferrer", children: "\u524D\u5F80\u8FDE\u63A5\u90AE\u7BB1" }),
2039
- view?.authorization_url && !url && /* @__PURE__ */ jsx8("p", { role: "alert", children: "\u8FDE\u63A5\u9875\u9762\u5730\u5740\u65E0\u6548\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u68C0\u67E5\u3002" }),
2040
- view?.connection_id && /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, onClick: () => {
2041
- void perform("finish");
2042
- }, children: "\u8FD4\u56DE\u540E\u6838\u9A8C" }),
2043
- /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, onClick: () => {
2044
- void perform("refresh");
2045
- }, children: busy ? "\u6B63\u5728\u5904\u7406\u2026" : "\u5237\u65B0\u72B6\u6001" }),
2046
- bindDelivery && view?.connected && /* @__PURE__ */ jsxs8(Fragment2, { children: [
2047
- /* @__PURE__ */ jsx8("span", { children: view.subscription_state === "paused" ? "\u5411\u52A9\u624B\u63A8\u9001\u5DF2\u6682\u505C" : view.delivery_bound ? "\u5DF2\u63A5\u5165\u52A9\u624B\u6D88\u606F" : "\u5C1A\u672A\u63A5\u5165\u52A9\u624B\u6D88\u606F" }),
2048
- !view.delivery_bound && view.subscription_state !== "paused" && /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, onClick: () => {
2049
- void perform("bind");
2050
- }, children: "\u63A5\u5165\u52A9\u624B\u6D88\u606F" }),
2051
- (view.delivery_bound || view.subscription_state === "paused") && /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, onClick: () => {
2052
- void perform(view.subscription_state === "paused" ? "resume" : "pause");
2053
- }, children: view.subscription_state === "paused" ? "\u6062\u590D\u63A8\u9001" : "\u6682\u505C\u63A8\u9001" })
2193
+ const showForm = view && (!view.connected || editing);
2194
+ const brand = view?.provider === "netease-mail" ? "\u7F51\u6613\u90AE\u7BB1" : "QQ \u90AE\u7BB1";
2195
+ const paused = view?.subscription_state === "paused";
2196
+ return /* @__PURE__ */ jsxs8("section", { "aria-label": "\u8FDE\u63A5\u90AE\u7BB1", "aria-busy": busy, className: "managed-mail-connection min-w-0 space-y-5 text-left text-sm text-foreground", children: [
2197
+ view ? /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between gap-3", children: [
2198
+ /* @__PURE__ */ jsx12("p", { className: "min-w-0 break-all text-xs text-muted-foreground", children: view.connected ? view.label : "\u8FDE\u63A5\u540E\uFF0C\u52A9\u624B\u53EF\u4EE5\u5E2E\u4F60\u5904\u7406\u90AE\u4EF6\u3002" }),
2199
+ /* @__PURE__ */ jsx12(Badge, { className: "shrink-0", variant: view.connected ? "secondary" : "outline", children: paused ? "\u63A8\u9001\u5DF2\u6682\u505C" : view.connected ? "\u5DF2\u8FDE\u63A5" : "\u672A\u8FDE\u63A5" })
2200
+ ] }) : busy && /* @__PURE__ */ jsx12("output", { className: "text-muted-foreground", children: "\u6B63\u5728\u8BFB\u53D6\u90AE\u7BB1\u72B6\u6001\u2026" }),
2201
+ failure && /* @__PURE__ */ jsx12("p", { role: "alert", className: "break-words rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2.5 text-sm text-destructive", children: failure }),
2202
+ showForm && /* @__PURE__ */ jsxs8("form", { className: "space-y-4", "aria-label": `\u8FDE\u63A5${brand}`, onSubmit: (event) => {
2203
+ event.preventDefault();
2204
+ void perform("credentials");
2205
+ }, children: [
2206
+ /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
2207
+ /* @__PURE__ */ jsx12(Label, { htmlFor: `${formId}-email`, children: "\u90AE\u7BB1\u5730\u5740" }),
2208
+ /* @__PURE__ */ jsx12(Input, { className: field, id: `${formId}-email`, type: "email", autoComplete: "username", placeholder: view.provider === "netease-mail" ? "\u4F8B\u5982 name@163.com" : "\u4F8B\u5982 name@qq.com", maxLength: 254, required: true, disabled: busy, value: email, onChange: (event) => setEmail(event.target.value) })
2209
+ ] }),
2210
+ /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
2211
+ /* @__PURE__ */ jsx12(Label, { htmlFor: `${formId}-code`, children: "\u6388\u6743\u7801" }),
2212
+ /* @__PURE__ */ jsx12(Input, { className: field, id: `${formId}-code`, type: "password", autoComplete: "off", placeholder: "\u586B\u5199\u90AE\u7BB1\u63D0\u4F9B\u7684\u6388\u6743\u7801", "aria-describedby": `${formId}-help`, maxLength: 256, required: true, disabled: busy, value: code, onChange: (event) => setCode(event.target.value) }),
2213
+ /* @__PURE__ */ jsxs8("div", { id: `${formId}-help`, className: "rounded-lg bg-muted/50 px-3 py-2.5 text-xs leading-relaxed text-muted-foreground", children: [
2214
+ /* @__PURE__ */ jsx12("p", { className: "mb-1 font-medium text-foreground", children: "\u5982\u4F55\u83B7\u53D6\u6388\u6743\u7801" }),
2215
+ /* @__PURE__ */ jsxs8("ol", { className: "list-decimal space-y-1 pl-4", children: [
2216
+ /* @__PURE__ */ jsxs8("li", { children: [
2217
+ "\u5728\u7F51\u9875\u7248",
2218
+ brand,
2219
+ "\u4E2D\u6253\u5F00\u201C\u8BBE\u7F6E\u201D\u3002"
2220
+ ] }),
2221
+ /* @__PURE__ */ jsx12("li", { children: view.provider === "netease-mail" ? "\u8FDB\u5165\u201CPOP3/SMTP/IMAP\u201D\uFF0C\u5F00\u542F IMAP/SMTP \u670D\u52A1\u3002" : "\u8FDB\u5165\u201C\u8D26\u53F7\u201D\uFF0C\u5F00\u542F IMAP/SMTP \u670D\u52A1\u3002" }),
2222
+ /* @__PURE__ */ jsx12("li", { children: "\u6309\u90AE\u7BB1\u63D0\u793A\u751F\u6210\u6388\u6743\u7801\uFF0C\u590D\u5236\u5230\u4E0A\u65B9\u3002" })
2223
+ ] })
2224
+ ] })
2054
2225
  ] }),
2055
- onDisable && view?.enabled && /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, onClick: () => {
2226
+ /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
2227
+ /* @__PURE__ */ jsx12(Button, { className: "w-full", type: "submit", disabled: busy || !email.trim() || !code.trim(), children: busy ? /* @__PURE__ */ jsxs8(Fragment2, { children: [
2228
+ /* @__PURE__ */ jsx12(LoaderCircle, { className: "animate-spin" }),
2229
+ "\u6B63\u5728\u8FDE\u63A5\u2026"
2230
+ ] }) : "\u8FDE\u63A5\u90AE\u7BB1" }),
2231
+ editing && /* @__PURE__ */ jsx12(Button, { className: "w-full", variant: "ghost", type: "button", disabled: busy, onClick: () => {
2232
+ setCode("");
2233
+ setEditing(false);
2234
+ setFailure("");
2235
+ }, children: "\u53D6\u6D88" })
2236
+ ] })
2237
+ ] }),
2238
+ view?.connected && !editing && /* @__PURE__ */ jsxs8(Fragment2, { children: [
2239
+ !view.enabled && /* @__PURE__ */ jsxs8("div", { className: "space-y-2 rounded-lg border border-border p-3", children: [
2240
+ /* @__PURE__ */ jsx12("p", { className: "text-xs text-muted-foreground", children: "\u90AE\u7BB1\u5DF2\u8FDE\u63A5\uFF0C\u542F\u7528\u540E\u53EF\u5728\u5BF9\u8BDD\u4E2D\u4F7F\u7528\u3002" }),
2241
+ /* @__PURE__ */ jsx12(Button, { type: "button", disabled: busy, onClick: () => {
2242
+ void perform("finish");
2243
+ }, children: "\u542F\u7528\u90AE\u7BB1" })
2244
+ ] }),
2245
+ bindDelivery && /* @__PURE__ */ jsxs8("div", { className: "space-y-3 rounded-xl border border-border bg-muted/30 p-4", "aria-label": "\u52A9\u624B\u6D88\u606F", children: [
2246
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between gap-2", children: [
2247
+ /* @__PURE__ */ jsx12("h4", { className: "font-medium", children: "\u52A9\u624B\u6D88\u606F" }),
2248
+ /* @__PURE__ */ jsx12("span", { className: "text-xs text-muted-foreground", children: paused ? "\u5411\u52A9\u624B\u63A8\u9001\u5DF2\u6682\u505C" : view.delivery_bound ? "\u5DF2\u63A5\u5165\u52A9\u624B\u6D88\u606F" : "\u5C1A\u672A\u63A5\u5165" })
2249
+ ] }),
2250
+ /* @__PURE__ */ jsx12("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "\u65B0\u90AE\u4EF6\u4F1A\u63A8\u9001\u7ED9\u52A9\u624B\uFF0C\u7531\u52A9\u624B\u5224\u65AD\u662F\u5426\u9700\u8981\u63D0\u9192\u4F60" }),
2251
+ /* @__PURE__ */ jsxs8(Button, { className: "w-full", variant: view.delivery_bound && !paused ? "outline" : "default", type: "button", disabled: busy, onClick: () => {
2252
+ void perform(paused ? "resume" : view.delivery_bound ? "pause" : "bind");
2253
+ }, children: [
2254
+ busy && /* @__PURE__ */ jsx12(LoaderCircle, { className: "animate-spin" }),
2255
+ paused ? "\u6062\u590D\u63A8\u9001" : view.delivery_bound ? "\u6682\u505C\u63A8\u9001" : "\u63A5\u5165\u52A9\u624B\u6D88\u606F"
2256
+ ] })
2257
+ ] })
2258
+ ] }),
2259
+ !editing && /* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap items-center justify-between gap-1 text-muted-foreground", children: [
2260
+ view?.connected && /* @__PURE__ */ jsx12(Button, { type: "button", variant: "ghost", size: "xs", disabled: busy, onClick: () => {
2261
+ setEmail(view.label || "");
2262
+ setFailure("");
2263
+ setEditing(true);
2264
+ }, children: "\u91CD\u65B0\u8FDE\u63A5\u90AE\u7BB1" }),
2265
+ /* @__PURE__ */ jsx12(Button, { type: "button", variant: "ghost", size: "xs", disabled: busy, onClick: () => {
2266
+ void perform("refresh");
2267
+ }, children: "\u5237\u65B0\u72B6\u6001" }),
2268
+ onDisable && view?.enabled && /* @__PURE__ */ jsx12(Button, { type: "button", variant: "ghost", size: "xs", disabled: busy, onClick: () => {
2056
2269
  void perform("disable");
2057
- }, children: "\u505C\u7528\u6B64\u8FDE\u63A5" }),
2058
- view?.connection_id && /* @__PURE__ */ jsxs8(AlertDialog, { children: [
2059
- /* @__PURE__ */ jsx8(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx8("button", { type: "button", className: button2, disabled: busy, children: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5" }) }),
2060
- /* @__PURE__ */ jsxs8(AlertDialogContent, { children: [
2061
- /* @__PURE__ */ jsx8(AlertDialogTitle, { children: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5\uFF1F" }),
2062
- /* @__PURE__ */ jsx8(AlertDialogDescription, { children: "\u79FB\u9664\u540E\u5C06\u505C\u6B62\u63A5\u6536\u548C\u63A8\u9001\uFF0C\u5E76\u6E05\u9664 SuperWork \u4FDD\u5B58\u7684\u90AE\u7BB1\u51ED\u636E\u3002\u5DF2\u6709\u6D88\u606F\u548C\u6587\u4EF6\u4FDD\u7559\u3002" }),
2063
- /* @__PURE__ */ jsx8(AlertDialogCancel, { children: "\u53D6\u6D88" }),
2064
- /* @__PURE__ */ jsx8(AlertDialogAction, { onClick: () => {
2065
- void perform("remove");
2066
- }, children: "\u786E\u8BA4\u79FB\u9664" })
2270
+ }, children: "\u505C\u7528\u6B64\u8FDE\u63A5" })
2271
+ ] }),
2272
+ view?.connection_id && !editing && /* @__PURE__ */ jsxs8("div", { className: "space-y-3", children: [
2273
+ /* @__PURE__ */ jsx12(Separator, {}),
2274
+ /* @__PURE__ */ jsxs8(AlertDialog, { children: [
2275
+ /* @__PURE__ */ jsx12(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx12(Button, { type: "button", variant: "destructive", size: "sm", disabled: busy, children: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5" }) }),
2276
+ /* @__PURE__ */ jsxs8(AlertDialogContent, { className: "managed-mail-connection", children: [
2277
+ /* @__PURE__ */ jsxs8(AlertDialogHeader, { children: [
2278
+ /* @__PURE__ */ jsx12(AlertDialogTitle, { children: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5\uFF1F" }),
2279
+ /* @__PURE__ */ jsx12(AlertDialogDescription, { children: "\u79FB\u9664\u540E\u5C06\u505C\u6B62\u63A5\u6536\u548C\u63A8\u9001\uFF0C\u5E76\u6E05\u9664\u5DF2\u4FDD\u5B58\u7684\u90AE\u7BB1\u5730\u5740\u548C\u6388\u6743\u7801\u3002\u5DF2\u6709\u6D88\u606F\u548C\u6587\u4EF6\u4FDD\u7559\u3002" })
2280
+ ] }),
2281
+ /* @__PURE__ */ jsxs8(AlertDialogFooter, { children: [
2282
+ /* @__PURE__ */ jsx12(AlertDialogCancel, { type: "button", children: "\u53D6\u6D88" }),
2283
+ /* @__PURE__ */ jsx12(AlertDialogAction, { type: "button", variant: "destructive", onClick: () => {
2284
+ void perform("remove");
2285
+ }, children: "\u786E\u8BA4\u79FB\u9664" })
2286
+ ] })
2067
2287
  ] })
2068
2288
  ] })
2069
2289
  ] })
@@ -2071,9 +2291,9 @@ function ManagedConnection({ read, act, onChanged, bindDelivery, onDisable }) {
2071
2291
  }
2072
2292
 
2073
2293
  // src/components/ConnectorConnection.tsx
2074
- import { jsx as jsx9 } from "react/jsx-runtime";
2294
+ import { jsx as jsx13 } from "react/jsx-runtime";
2075
2295
  function ConnectorConnection({ type, ...props }) {
2076
- return type === "managed" ? /* @__PURE__ */ jsx9(ManagedConnection, { ...props }) : /* @__PURE__ */ jsx9(DeviceConnection, { ...props });
2296
+ return type === "managed" ? /* @__PURE__ */ jsx13(ManagedConnection, { ...props }) : /* @__PURE__ */ jsx13(DeviceConnection, { ...props });
2077
2297
  }
2078
2298
 
2079
2299
  export {
@@ -2094,4 +2314,4 @@ qrcode.react/lib/esm/index.js:
2094
2314
  * SPDX-License-Identifier: ISC
2095
2315
  *)
2096
2316
  */
2097
- //# sourceMappingURL=chunk-X66C66OQ.js.map
2317
+ //# sourceMappingURL=chunk-J72ZLILV.js.map