@aixnn/aixautots 0.6.12 → 0.6.17

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 (51) hide show
  1. package/dist/{automation-queue-CvrWEOw2.d.ts → automation-queue-DO8fOG6l.d.ts} +2 -2
  2. package/dist/{chunk-PUEKOYSH.js → chunk-2KPZSPV6.js} +131 -3
  3. package/dist/{chunk-D7J4EQTA.js → chunk-3OBCSW2J.js} +1 -1
  4. package/dist/{chunk-UH5OYPXE.js → chunk-7BJPVSEZ.js} +205 -18
  5. package/dist/{chunk-SKTL6ACT.js → chunk-7RQTSTR6.js} +3 -3
  6. package/dist/{chunk-LO3XD4T5.js → chunk-FJPIY4YI.js} +124 -8
  7. package/dist/{chunk-SL6M6CC6.js → chunk-KASSYUGM.js} +3 -3
  8. package/dist/chunk-LOKPZ677.js +422 -0
  9. package/dist/{chunk-E7WMHM63.js → chunk-MBBVYSPD.js} +7 -0
  10. package/dist/{chunk-ROOOAG3E.js → chunk-NIEGPH3E.js} +51 -418
  11. package/dist/{chunk-7IXBWJHB.js → chunk-QEK25NUA.js} +5 -5
  12. package/dist/{chunk-QZLUQSLA.js → chunk-TJ2QIP5M.js} +352 -423
  13. package/dist/{chunk-LR5LJJNM.js → chunk-WOPEKCVC.js} +4 -4
  14. package/dist/chunk-ZCTAYVPK.js +1 -0
  15. package/dist/{chunk-XCYGBYFC.js → chunk-ZDCTHR7D.js} +215 -126
  16. package/dist/{config-BUH2EYHO.d.ts → config-CBUhr4Gl.d.ts} +173 -2
  17. package/dist/core/index.d.ts +29 -11
  18. package/dist/core/index.js +2 -2
  19. package/dist/{device-normalize-DzuVemCy.d.ts → device-normalize-Vl5JYbAI.d.ts} +7 -4
  20. package/dist/device-session-3XK2SZDF.js +1 -0
  21. package/dist/i18n/index.js +1 -1
  22. package/dist/{mirror-session-D2YY9mKf.d.ts → mirror-session-Y1InpkUY.d.ts} +14 -4
  23. package/dist/react/index.d.ts +9 -9
  24. package/dist/react/index.js +3 -3
  25. package/dist/{script-debugger-Csm4CrfY.d.ts → script-debugger-DoT02din.d.ts} +1 -1
  26. package/dist/{task-agent-runner-C4WfT77g.d.ts → task-agent-runner-Cl2ickJ1.d.ts} +3 -3
  27. package/dist/{types-BfIeUpsU.d.ts → types-Cp1ohbTb.d.ts} +35 -3
  28. package/dist/ui/billing.d.ts +2 -2
  29. package/dist/ui/billing.js +14 -8
  30. package/dist/ui/device-create.d.ts +5 -2
  31. package/dist/ui/device-create.js +8 -7
  32. package/dist/ui/device-mirror.js +7 -7
  33. package/dist/ui/devices.d.ts +5 -5
  34. package/dist/ui/devices.js +12 -11
  35. package/dist/ui/editor.d.ts +2 -2
  36. package/dist/ui/editor.js +7 -7
  37. package/dist/ui/index.d.ts +5 -4
  38. package/dist/ui/index.js +9 -7
  39. package/dist/ui/inspector.js +5 -5
  40. package/dist/ui/ip-commerce.d.ts +28 -0
  41. package/dist/ui/ip-commerce.js +8 -0
  42. package/dist/ui/market.js +4 -4
  43. package/dist/ui/mirror.d.ts +5 -4
  44. package/dist/ui/mirror.js +1 -1
  45. package/dist/ui/primitives/index.js +1 -1
  46. package/dist/ui/script-studio.js +6 -6
  47. package/dist/ui/scripts.d.ts +1 -1
  48. package/dist/ui/scripts.js +5 -5
  49. package/dist/ui/tasks.js +12 -11
  50. package/package.json +6 -2
  51. package/dist/device-session-7MKEJTIA.js +0 -1
@@ -1,8 +1,9 @@
1
- import { IosDeviceDiagnostics } from './chunk-SL6M6CC6.js';
1
+ import { IosDeviceDiagnostics } from './chunk-KASSYUGM.js';
2
+ import { IpCommercePanel } from './chunk-LOKPZ677.js';
2
3
  import { canConnectPhysicalDevice } from './chunk-ZB5ET67B.js';
3
- import { useAixT } from './chunk-LO3XD4T5.js';
4
- import { cn, Select, Dialog, Button, Input, Badge } from './chunk-SKTL6ACT.js';
5
- import { useNodes, useClient, useDevices } from './chunk-7IXBWJHB.js';
4
+ import { useAixT } from './chunk-FJPIY4YI.js';
5
+ import { cn, Select, Dialog, Button, Input, Badge } from './chunk-7RQTSTR6.js';
6
+ import { useNodes, useClient, useDevices } from './chunk-QEK25NUA.js';
6
7
  import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
7
8
  import { Server, RefreshCw, Smartphone, Usb, Wifi, Info } from 'lucide-react';
8
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -22,6 +23,15 @@ function availableVirtualImages(node, catalog, platform) {
22
23
  function availableVirtualPlatforms(node, catalog) {
23
24
  return ["android", "ios"].filter((platform) => availableVirtualImages(node, catalog, platform).length > 0);
24
25
  }
26
+ function availableVirtualVersions(node, catalog, platform) {
27
+ const versions = /* @__PURE__ */ new Map();
28
+ for (const image of availableVirtualImages(node, catalog, platform)) {
29
+ const key = JSON.stringify([image.platform, image.version, image.rooted]);
30
+ const previous = versions.get(key);
31
+ if (!previous || previous.image_tag.endsWith(":latest") && !image.image_tag.endsWith(":latest")) versions.set(key, image);
32
+ }
33
+ return [...versions.values()];
34
+ }
25
35
  var SCOPE_META = {
26
36
  platform: { label: "\u5E73\u53F0", order: 0 },
27
37
  project: { label: "\u9879\u76EE", order: 1 },
@@ -31,7 +41,7 @@ var CURRENCY_SYMBOL = { CNY: "\xA5", USD: "$" };
31
41
  function nodeMetric(n) {
32
42
  if (n.is_platform) {
33
43
  if (n.starting_price == null) return "\u5E73\u53F0\u8282\u70B9";
34
- const sym = CURRENCY_SYMBOL[n.price_currency ?? "CNY"] ?? "";
44
+ const sym = CURRENCY_SYMBOL[n.price_currency ?? "USD"] ?? "";
35
45
  return `${sym}${Number(n.starting_price)}/\u5C0F\u65F6 \u8D77`;
36
46
  }
37
47
  return `${n.device_count} devices`;
@@ -265,7 +275,7 @@ function VirtualSpecStep({ spec, onChange, nodeId, onValidityChange }) {
265
275
  alive = false;
266
276
  };
267
277
  }, [client]);
268
- const availableVersions = availableVirtualImages(selectedNode, versions, platform);
278
+ const availableVersions = availableVirtualVersions(selectedNode, versions, platform);
269
279
  const allowedPlatforms = availableVirtualPlatforms(selectedNode, versions);
270
280
  const platformOptions = PLATFORM_OPTIONS.filter((option) => allowedPlatforms.includes(option.value));
271
281
  const versionOptions = availableVersions.map((o) => ({ value: o.id, label: o.label }));
@@ -849,14 +859,18 @@ function deviceProxyCapabilities(device, node) {
849
859
  const custom = redroid && !!nodeId && node?.id === nodeId && cap?.supported === true;
850
860
  return { custom, managed: custom && cap?.revision_fencing === true };
851
861
  }
862
+ function usesAndroidSystemProxy(node) {
863
+ const cap = node?.reported_caps?.egress_proxy;
864
+ return cap?.supported === true && (cap.mode === "android_system" || cap.enforcement === "android_system");
865
+ }
852
866
  function proxyCapabilityReason(device) {
853
867
  if (device.platform !== "android" || device.meta?.provisioned !== true) {
854
- return "Per-device transparent proxy requires a provisioned virtual Android Redroid device.";
868
+ return "Per-device proxy requires a provisioned virtual Android Redroid device.";
855
869
  }
856
870
  if (typeof device.meta?.node_id !== "string" || !device.meta.node_id) {
857
871
  return "The owning node is unknown, so per-device proxy is unavailable.";
858
872
  }
859
- return "The owning node does not report per-device transparent proxy capability.";
873
+ return "The owning node does not report per-device proxy capability.";
860
874
  }
861
875
  function proxyProbeMessage(result) {
862
876
  const message = result.message ?? result.error;
@@ -895,7 +909,7 @@ var LOCALE_OPTIONS = [
895
909
  { value: "ja-JP", label: "\u65E5\u672C\u8A9E (ja-JP)" },
896
910
  { value: "ko-KR", label: "\uD55C\uAD6D\uC5B4 (ko-KR)" }
897
911
  ];
898
- function ProxySpoofStep({ spec, onChange, isReal, showProxy = !isReal }) {
912
+ function ProxySpoofStep({ spec, onChange, isReal, showProxy = !isReal, proxyDisabled = false, proxyAction }) {
899
913
  const proxy = spec.proxy ?? "";
900
914
  const locale = spec.config?.locale ?? "";
901
915
  const proxyInvalid = proxy.trim().length > 0 && !isSupportedProxyUrl(proxy.trim());
@@ -919,26 +933,21 @@ function ProxySpoofStep({ spec, onChange, isReal, showProxy = !isReal }) {
919
933
  showProxy && /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
920
934
  /* @__PURE__ */ jsx("p", { className: "text-label-caps text-muted-foreground", children: "\u4EE3\u7406 proxy" }),
921
935
  /* @__PURE__ */ jsxs("div", { children: [
922
- /* @__PURE__ */ jsx("label", { className: "text-[11px] text-muted-foreground", children: "\u4EE3\u7406\u5730\u5740 URL" }),
936
+ /* @__PURE__ */ jsx("label", { htmlFor: "creation-proxy-url", className: "text-sm text-muted-foreground", children: "\u4EE3\u7406\u5730\u5740 URL" }),
923
937
  /* @__PURE__ */ jsx(
924
938
  Input,
925
939
  {
940
+ id: "creation-proxy-url",
941
+ disabled: proxyDisabled,
926
942
  value: proxy,
927
943
  onChange: (e) => setProxy(e.target.value),
928
944
  placeholder: "http://host:8080 \u6216 http://user:password@host:8080",
929
945
  className: proxyInvalid ? "border-destructive" : void 0
930
946
  }
931
947
  ),
932
- /* @__PURE__ */ jsxs("p", { className: "mt-1 text-[11px] text-muted-foreground", children: [
933
- "\u53EF\u9009\u7684 HTTP CONNECT \u4EE3\u7406\uFF1A",
934
- /* @__PURE__ */ jsx("code", { children: "http://[\u7528\u6237:\u5BC6\u7801@]\u4E3B\u673A:\u7AEF\u53E3" }),
935
- "\u3002 \u5BC6\u7801\u4E2D\u7684 ",
936
- /* @__PURE__ */ jsx("code", { children: "@" }),
937
- "\u3001",
938
- /* @__PURE__ */ jsx("code", { children: ":" }),
939
- " \u7B49\u7279\u6B8A\u5B57\u7B26\u5FC5\u987B\u505A URL \u767E\u5206\u53F7\u7F16\u7801\uFF1BUDP/QUIC/DNS \u4E0D\u7ECF\u8FC7\u6B64\u4EE3\u7406\uFF0C\u4FDD\u6301\u76F4\u8FDE\u3002 \u7528\u6237\u540D\u548C\u5BC6\u7801\u53EF\u4E0D\u586B\uFF1B\u7559\u7A7A\u8868\u793A\u4E0D\u4F7F\u7528\u4EE3\u7406\u3002"
940
- ] }),
941
- proxyInvalid && /* @__PURE__ */ jsx("p", { className: "mt-1 text-[11px] text-destructive", children: "\u8BF7\u8F93\u5165 http://\u4E3B\u673A:\u7AEF\u53E3 \u6216 http://\u7528\u6237\u540D:\u5BC6\u7801@\u4E3B\u673A:\u7AEF\u53E3\uFF1B\u4E0D\u652F\u6301 socks/https\u3002" })
948
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: proxyDisabled ? "\u5F53\u524D\u8282\u70B9\u6682\u4E0D\u652F\u6301\u4EE3\u7406\uFF0C\u8BBE\u5907\u5C06\u4F7F\u7528\u8282\u70B9\u7F51\u7EDC\u3002" : "\u586B\u5199 HTTP \u4EE3\u7406\u5730\u5740\uFF1B\u7528\u6237\u540D\u548C\u5BC6\u7801\u53EF\u9009\u3002\u7559\u7A7A\u5219\u4F7F\u7528\u8282\u70B9\u7F51\u7EDC\u3002" }),
949
+ proxyInvalid && /* @__PURE__ */ jsx("p", { className: "mt-1 text-[11px] text-destructive", children: "\u8BF7\u8F93\u5165 http://\u4E3B\u673A:\u7AEF\u53E3 \u6216 http://\u7528\u6237\u540D:\u5BC6\u7801@\u4E3B\u673A:\u7AEF\u53E3\uFF1B\u4E0D\u652F\u6301 socks/https\u3002" }),
950
+ proxyAction
942
951
  ] })
943
952
  ] }),
944
953
  !isReal && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
@@ -957,374 +966,13 @@ function ProxySpoofStep({ spec, onChange, isReal, showProxy = !isReal }) {
957
966
  )
958
967
  ] })
959
968
  ] }),
960
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2 rounded-md border border-border bg-secondary px-3 py-2", children: [
969
+ isReal && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 rounded-md border border-border bg-secondary px-3 py-2", children: [
961
970
  /* @__PURE__ */ jsx(Info, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
962
971
  /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: isReal ? "\u6B64\u6B65\u9AA4\u4EC5\u767B\u8BB0\u771F\u673A\uFF0C\u4E0D\u4F1A\u5E94\u7528\u7CFB\u7EDF\u4EE3\u7406\u6216\u6307\u7EB9\u8BBE\u7F6E\u3002" : "\u4EE3\u7406\u4EC5\u7528\u4E8E\u5DF2\u62A5\u544A\u652F\u6301\u7684 Redroid \u8282\u70B9\u3002\u81EA\u5B9A\u4E49\u4EE3\u7406\u53EA\u63A5\u7BA1\u652F\u6301\u7684 TCP \u6D41\u91CF\uFF0CUDP/QUIC/DNS \u4E0D\u7ECF\u8FC7\u6B64\u4EE3\u7406\u3002" })
963
972
  ] })
964
973
  ] });
965
974
  }
966
975
 
967
- // src/ui/device-create/managed-creation-state.ts
968
- var creationStorageKey = (baseUrl, owner, project) => `aix-managed-creation:v1:${JSON.stringify([baseUrl, owner, project])}`;
969
- function readCreationRequest(key) {
970
- if (!key) return null;
971
- try {
972
- const value = JSON.parse(localStorage.getItem(key) ?? "null");
973
- return value && typeof value.request_id === "string" && typeof value.quote_id === "string" && Number.isSafeInteger(value.authorized_total_minor) && value.authorized_total_minor >= 0 && value.currency === "CNY" ? value : null;
974
- } catch {
975
- return null;
976
- }
977
- }
978
- function validCreationQuote(quote) {
979
- return !!quote && typeof quote.id === "string" && typeof quote.owner_user_id === "string" && typeof quote.project_id === "string" && Number.isSafeInteger(quote.total_minor) && quote.total_minor >= 0 && quote.currency === "CNY" && !!quote.product && quote.product.currency === "CNY" && quote.product.billing_mode === "one_time" && quote.product.auto_renew === false && quote.product.refund_policy === "no_refund_after_allocation" && Number.isSafeInteger(quote.product.fixed_cost_minor) && (quote.product.fixed_cost_minor ?? -1) >= 0 && Number.isSafeInteger(quote.product.quota_value) && quote.product.quota_value >= 0 && Number.isFinite(quote.product.rate_minor_per_gib) && (quote.product.rate_minor_per_gib ?? -1) >= 0 && quote.product.budget_accounting === "reserved_upper_bound" && (quote.product.reservation_bytes ?? 0) > 0 && (quote.product.handshake_reservation_bytes ?? 0) > 0 && !!quote.device_billing && ["personal_free", "metered"].includes(quote.device_billing.kind) && typeof quote.device_billing.rate_per_hour === "string" && Number.isFinite(Number(quote.device_billing.rate_per_hour)) && Number(quote.device_billing.rate_per_hour) >= 0 && typeof quote.device_billing.currency === "string" && Number.isFinite(Date.parse(quote.expires_at));
980
- }
981
- function creationReady(receipt) {
982
- return receipt?.creation_status === "ready" && receipt.proxy_order.status === "fulfilled" && receipt.proxy_order.apply_status === "applied";
983
- }
984
- function creationRejected(error) {
985
- return error?.requestState === "rejected";
986
- }
987
- var money = (minor) => `\xA5${(minor / 100).toFixed(2)}`;
988
- function ManagedCreationPanel(props) {
989
- const client = useClient();
990
- const t = useAixT();
991
- const translate = useRef(t);
992
- translate.current = t;
993
- const epoch = useRef(0);
994
- const [catalog, setCatalog] = useState(null);
995
- const [identity, setIdentity] = useState(null);
996
- const [request, setRequest] = useState(null);
997
- const [receipt, setReceipt] = useState(null);
998
- const [quote, setQuote] = useState(null);
999
- const [productId, setProductId] = useState("");
1000
- const [region, setRegion] = useState("");
1001
- const [kind, setKind] = useState("static");
1002
- const [error, setError] = useState("");
1003
- const [busy, setBusy] = useState(false);
1004
- const [loaded, setLoaded] = useState(false);
1005
- const [fresh, setFresh] = useState(false);
1006
- const [now, setNow] = useState(Date.now());
1007
- const active = useRef(true);
1008
- const inFlight = useRef(false);
1009
- const pollInFlight = useRef(null);
1010
- const requestRef = useRef(request);
1011
- const storageRef = useRef(null);
1012
- const identityClient = useRef(null);
1013
- const controllers = useRef(/* @__PURE__ */ new Set());
1014
- const propsRef = useRef(props);
1015
- propsRef.current = props;
1016
- const setPending = (value) => {
1017
- requestRef.current = value;
1018
- setRequest(value);
1019
- };
1020
- const scopeKey = identity ? creationStorageKey(client.cfg.baseUrl, identity.owner_user_id, identity.project_id) : null;
1021
- storageRef.current = scopeKey;
1022
- const run = useCallback(async (operation) => {
1023
- const controller = new AbortController();
1024
- controllers.current.add(controller);
1025
- const timer = setTimeout(() => controller.abort(), 3e4);
1026
- try {
1027
- return await operation(controller.signal);
1028
- } finally {
1029
- clearTimeout(timer);
1030
- controllers.current.delete(controller);
1031
- }
1032
- }, []);
1033
- const refresh = useCallback(async () => {
1034
- const generation = epoch.current;
1035
- if (pollInFlight.current === generation) return;
1036
- pollInFlight.current = generation;
1037
- try {
1038
- const context = await run((signal) => client.proxies.creations({ signal }));
1039
- if (!active.current || generation !== epoch.current) return;
1040
- if (!context || typeof context.owner_user_id !== "string" || typeof context.project_id !== "string" || !Array.isArray(context.items)) throw new Error(translate.current("creation.invalidService"));
1041
- const key = creationStorageKey(client.cfg.baseUrl, context.owner_user_id, context.project_id);
1042
- if (storageRef.current && storageRef.current !== key) {
1043
- controllers.current.forEach((controller) => controller.abort());
1044
- setQuote(null);
1045
- setReceipt(null);
1046
- setError("");
1047
- setBusy(false);
1048
- }
1049
- storageRef.current = key;
1050
- identityClient.current = client;
1051
- setIdentity(context);
1052
- setFresh(true);
1053
- let pending = readCreationRequest(key);
1054
- let found = pending ? context.items.find((item) => item.request_id === pending.request_id) : context.items[0];
1055
- if (pending && !found) {
1056
- try {
1057
- found = await run((signal) => client.proxies.creationByRequest(pending.request_id, { signal }));
1058
- } catch {
1059
- }
1060
- }
1061
- if (!active.current || generation !== epoch.current) return;
1062
- if (found && (!pending || pending.request_id === found.request_id)) {
1063
- if (!pending) {
1064
- pending = { request_id: found.request_id, quote_id: found.quote_id, authorized_total_minor: found.proxy_order.total_minor, currency: "CNY", uncertain: true };
1065
- localStorage.setItem(key, JSON.stringify(pending));
1066
- }
1067
- setReceipt(found);
1068
- } else setReceipt((previous) => previous?.request_id === pending?.request_id ? previous : null);
1069
- setPending(pending);
1070
- propsRef.current.onPendingChange(!!pending);
1071
- } catch (e) {
1072
- if (active.current && generation === epoch.current) {
1073
- setFresh(false);
1074
- setError(e.message);
1075
- }
1076
- } finally {
1077
- if (pollInFlight.current === generation) pollInFlight.current = null;
1078
- if (active.current && generation === epoch.current) setLoaded(true);
1079
- }
1080
- }, [client, run]);
1081
- useEffect(() => {
1082
- active.current = true;
1083
- const generation = ++epoch.current;
1084
- storageRef.current = null;
1085
- identityClient.current = null;
1086
- setIdentity(null);
1087
- setFresh(false);
1088
- setQuote(null);
1089
- setReceipt(null);
1090
- setPending(null);
1091
- setLoaded(false);
1092
- setBusy(false);
1093
- propsRef.current.onPendingChange(false);
1094
- let timer;
1095
- const poll = async () => {
1096
- if (!document.hidden) await refresh();
1097
- if (active.current && generation === epoch.current) timer = setTimeout(() => void poll(), requestRef.current ? 3e3 : 3e4);
1098
- };
1099
- void run((signal) => client.proxies.catalog({ signal })).then((value) => {
1100
- if (!value || typeof value.enabled !== "boolean" || !Array.isArray(value.products)) throw new Error(translate.current("creation.invalidService"));
1101
- if (active.current && generation === epoch.current) setCatalog(value);
1102
- }).catch((e) => {
1103
- if (active.current && generation === epoch.current) setError(e.message);
1104
- });
1105
- void poll();
1106
- const clock = setInterval(() => setNow(Date.now()), 1e3);
1107
- const visible = () => {
1108
- if (!document.hidden) void refresh();
1109
- };
1110
- const storage = (event) => {
1111
- if (event.key === storageRef.current) void refresh();
1112
- };
1113
- document.addEventListener("visibilitychange", visible);
1114
- window.addEventListener("storage", storage);
1115
- return () => {
1116
- active.current = false;
1117
- epoch.current++;
1118
- clearTimeout(timer);
1119
- clearInterval(clock);
1120
- controllers.current.forEach((c) => c.abort());
1121
- document.removeEventListener("visibilitychange", visible);
1122
- window.removeEventListener("storage", storage);
1123
- };
1124
- }, [client, refresh, run]);
1125
- const specKey = JSON.stringify(props.spec);
1126
- useEffect(() => {
1127
- setQuote(null);
1128
- }, [specKey, productId, kind, region, props.quantity, props.supported, scopeKey]);
1129
- const regions = [...new Set(catalog?.products.map((product) => product.region) ?? [])];
1130
- const selectedRegion = regions.includes(region) ? region : regions[0] ?? "";
1131
- const products = catalog?.products.filter((product) => product.kind === kind && product.region === selectedRegion) ?? [];
1132
- const selected = products.find((product) => product.id === productId) ?? products[0];
1133
- const disabled = !props.supported || props.quantity !== 1 || !catalog?.enabled || !identity || identityClient.current !== client || !loaded || !fresh || busy || !!request;
1134
- const expired = quote ? Date.parse(quote.expires_at) <= now : true;
1135
- const getQuote = async () => {
1136
- if (disabled || !selected || inFlight.current) return;
1137
- inFlight.current = true;
1138
- setBusy(true);
1139
- setError("");
1140
- setQuote(null);
1141
- const inputSnapshot = specKey;
1142
- const generation = epoch.current;
1143
- const key = scopeKey;
1144
- try {
1145
- const value = await run((signal) => client.proxies.creationQuote({ spec: props.spec, product_id: selected.id }, { signal }));
1146
- if (!active.current || generation !== epoch.current || storageRef.current !== key || JSON.stringify(propsRef.current.spec) !== inputSnapshot) return;
1147
- if (!validCreationQuote(value) || value.owner_user_id !== identity.owner_user_id || value.project_id !== identity.project_id || value.node_id !== props.spec.node_id || value.product.id !== selected.id) throw new Error(t("creation.invalidQuote"));
1148
- setQuote(value);
1149
- setNow(Date.now());
1150
- } catch (e) {
1151
- if (active.current && generation === epoch.current && storageRef.current === key) setError(e.message);
1152
- } finally {
1153
- inFlight.current = false;
1154
- if (active.current && generation === epoch.current && storageRef.current === key) setBusy(false);
1155
- }
1156
- };
1157
- const submit = async (input) => {
1158
- if (!scopeKey || inFlight.current || !request && disabled) return;
1159
- inFlight.current = true;
1160
- setBusy(true);
1161
- setError("");
1162
- const key = scopeKey;
1163
- const generation = epoch.current;
1164
- const current = () => active.current && generation === epoch.current && storageRef.current === key && identityClient.current === client;
1165
- const send = async () => {
1166
- if (!current()) return;
1167
- let uncertain = !!input.uncertain;
1168
- let sent = false;
1169
- try {
1170
- const previous = readCreationRequest(key);
1171
- if (previous && previous.request_id !== input.request_id) {
1172
- setPending(previous);
1173
- throw new Error(t("managed.otherRequest"));
1174
- }
1175
- uncertain ||= previous?.request_id === input.request_id || requestRef.current?.request_id === input.request_id;
1176
- const durable = { ...input, uncertain };
1177
- localStorage.setItem(key, JSON.stringify(durable));
1178
- setPending(durable);
1179
- propsRef.current.onPendingChange(true);
1180
- sent = true;
1181
- const value = await run((signal) => client.proxies.create({ request_id: input.request_id, quote_id: input.quote_id, authorized_total_minor: input.authorized_total_minor, currency: "CNY" }, { signal }));
1182
- if (value.request_id !== input.request_id || value.quote_id !== input.quote_id) throw new Error(translate.current("creation.invalidService"));
1183
- if (current()) {
1184
- setReceipt(value);
1185
- setQuote(null);
1186
- await refresh();
1187
- }
1188
- } catch (e) {
1189
- const stored = readCreationRequest(key);
1190
- uncertain ||= stored?.request_id === input.request_id && !!stored.uncertain;
1191
- if (sent && creationRejected(e) && !uncertain) {
1192
- if (stored?.request_id === input.request_id) localStorage.removeItem(key);
1193
- if (current()) {
1194
- setPending(null);
1195
- setQuote(null);
1196
- propsRef.current.onPendingChange(false);
1197
- }
1198
- } else if (sent) {
1199
- if (stored?.request_id === input.request_id) localStorage.setItem(key, JSON.stringify({ ...stored, uncertain: true }));
1200
- if (current()) await refresh();
1201
- }
1202
- if (current()) setError(e.message);
1203
- }
1204
- };
1205
- try {
1206
- if (typeof navigator.locks?.request === "function") {
1207
- await navigator.locks.request(key, { ifAvailable: true }, async (lock) => {
1208
- if (lock) await send();
1209
- else {
1210
- if (current()) setError(t("managed.otherRequest"));
1211
- await refresh();
1212
- }
1213
- });
1214
- } else await send();
1215
- } catch (e) {
1216
- if (current()) setError(e.message);
1217
- } finally {
1218
- inFlight.current = false;
1219
- if (current()) setBusy(false);
1220
- }
1221
- };
1222
- const acknowledge = () => {
1223
- if (!scopeKey || identityClient.current !== client || !receipt || !creationReady(receipt) && receipt.creation_status !== "failed") return;
1224
- if (readCreationRequest(scopeKey)?.request_id === receipt.request_id) localStorage.removeItem(scopeKey);
1225
- setPending(null);
1226
- propsRef.current.onPendingChange(false);
1227
- propsRef.current.onComplete(receipt.device_id, creationReady(receipt));
1228
- };
1229
- if (!props.visible && !request) return null;
1230
- return /* @__PURE__ */ jsxs("section", { className: "space-y-3 text-sm", "aria-label": t("creation.title"), children: [
1231
- error && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-destructive", children: error }),
1232
- !loaded && /* @__PURE__ */ jsx("p", { role: "status", children: t("creation.loading") }),
1233
- !fresh && loaded && /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => void refresh(), children: t("common.refresh") }),
1234
- request ? /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-md border border-border p-3", children: [
1235
- /* @__PURE__ */ jsx("p", { role: "status", className: "font-medium", children: creationReady(receipt) ? t("creation.ready") : t(`creation.status.${receipt?.creation_status ?? "unknown"}`) }),
1236
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("creation.recovery") }),
1237
- /* @__PURE__ */ jsxs("p", { className: "break-all", children: [
1238
- t("creation.request"),
1239
- ": ",
1240
- request.request_id
1241
- ] }),
1242
- receipt && /* @__PURE__ */ jsxs(Fragment, { children: [
1243
- /* @__PURE__ */ jsxs("p", { className: "break-all", children: [
1244
- t("creation.device"),
1245
- ": ",
1246
- receipt.device_id
1247
- ] }),
1248
- /* @__PURE__ */ jsxs("p", { children: [
1249
- t("managed.order"),
1250
- ": ",
1251
- receipt.proxy_order.id,
1252
- " \xB7 ",
1253
- t(`managed.status.${receipt.proxy_order.status}`)
1254
- ] }),
1255
- receipt.failure_reason && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-destructive", children: receipt.failure_reason }),
1256
- receipt.creation_status === "failed" && /* @__PURE__ */ jsx("p", { children: t("creation.failedTerms") })
1257
- ] }),
1258
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
1259
- /* @__PURE__ */ jsx(Button, { variant: "secondary", disabled: busy, onClick: () => void refresh(), children: t("common.refresh") }),
1260
- !receipt && /* @__PURE__ */ jsx(Button, { disabled: busy || !fresh, onClick: () => void submit(request), children: t("managed.retry") }),
1261
- (creationReady(receipt) || receipt?.creation_status === "failed") && /* @__PURE__ */ jsx(Button, { disabled: busy, onClick: acknowledge, children: t("creation.done") })
1262
- ] })
1263
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1264
- !props.supported && /* @__PURE__ */ jsx("p", { children: t("creation.unsupported") }),
1265
- props.quantity !== 1 && /* @__PURE__ */ jsx("p", { role: "status", children: t("creation.singleOnly") }),
1266
- catalog && !catalog.enabled && /* @__PURE__ */ jsxs("p", { role: "status", children: [
1267
- t("creation.unavailable"),
1268
- catalog.unavailable_reason ? ` \xB7 ${catalog.unavailable_reason}` : ""
1269
- ] }),
1270
- catalog?.enabled && props.supported && /* @__PURE__ */ jsxs(Fragment, { children: [
1271
- /* @__PURE__ */ jsxs("label", { className: "block space-y-1", children: [
1272
- /* @__PURE__ */ jsx("span", { children: t("creation.country") }),
1273
- /* @__PURE__ */ jsx("select", { className: "min-h-10 w-full rounded border border-border bg-background px-2", disabled, value: selectedRegion, onChange: (e) => {
1274
- setRegion(e.target.value);
1275
- setQuote(null);
1276
- }, children: regions.map((value) => /* @__PURE__ */ jsx("option", { children: value }, value)) })
1277
- ] }),
1278
- /* @__PURE__ */ jsx("div", { className: "flex gap-2", role: "group", "aria-label": t("managed.kind"), children: ["static", "dynamic"].map((value) => /* @__PURE__ */ jsx(Button, { variant: kind === value ? "primary" : "secondary", "aria-pressed": kind === value, disabled, onClick: () => {
1279
- setKind(value);
1280
- setQuote(null);
1281
- }, children: t(`managed.${value}`) }, value)) }),
1282
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t(`managed.${kind}Hint`) }),
1283
- selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
1284
- /* @__PURE__ */ jsxs("label", { className: "block space-y-1", children: [
1285
- /* @__PURE__ */ jsx("span", { children: t("managed.product") }),
1286
- /* @__PURE__ */ jsx("select", { className: "min-h-10 w-full rounded border border-border bg-background px-2", disabled, value: selected.id, onChange: (e) => {
1287
- setProductId(e.target.value);
1288
- setQuote(null);
1289
- }, children: products.map((product) => /* @__PURE__ */ jsxs("option", { value: product.id, children: [
1290
- product.name,
1291
- " \xB7 ",
1292
- t("managed.hours", { n: product.duration_seconds / 3600 }),
1293
- " \xB7 ",
1294
- money(product.cost_minor)
1295
- ] }, product.id)) })
1296
- ] }),
1297
- /* @__PURE__ */ jsx("p", { children: t("managed.budget", { amount: money(selected.quota_value) }) }),
1298
- /* @__PURE__ */ jsx(Button, { disabled, onClick: () => void getQuote(), children: t("managed.quote") })
1299
- ] }) : /* @__PURE__ */ jsx("p", { children: t("managed.emptyCatalog") })
1300
- ] }),
1301
- quote && /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-md border border-primary/40 p-3", children: [
1302
- /* @__PURE__ */ jsx("p", { className: "font-semibold", children: t("creation.ipTotal", { amount: money(quote.total_minor) }) }),
1303
- /* @__PURE__ */ jsxs("p", { children: [
1304
- quote.product.region,
1305
- " \xB7 ",
1306
- t(`managed.${quote.product.kind}`),
1307
- " \xB7 ",
1308
- t("managed.hours", { n: quote.product.duration_seconds / 3600 })
1309
- ] }),
1310
- /* @__PURE__ */ jsx("p", { children: t("managed.fixedCost", { amount: money(quote.product.fixed_cost_minor) }) }),
1311
- /* @__PURE__ */ jsx("p", { children: t("managed.budget", { amount: money(quote.product.quota_value) }) }),
1312
- quote.product.rate_minor_per_gib != null && /* @__PURE__ */ jsx("p", { children: t("managed.rate", { amount: money(quote.product.rate_minor_per_gib) }) }),
1313
- quote.product.budget_accounting === "reserved_upper_bound" && /* @__PURE__ */ jsx("p", { children: t("managed.reservations", { kib: (quote.product.reservation_bytes ?? 16384) / 1024 }) }),
1314
- quote.product.handshake_reservation_bytes != null && /* @__PURE__ */ jsx("p", { children: t("managed.handshakeReservation", { kib: quote.product.handshake_reservation_bytes / 1024 }) }),
1315
- /* @__PURE__ */ jsx("p", { children: t("managed.noRenew") }),
1316
- /* @__PURE__ */ jsx("p", { children: t("creation.failedTerms") }),
1317
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: t("creation.startupNetwork") }),
1318
- /* @__PURE__ */ jsx("p", { children: quote.device_billing.kind === "metered" ? t("creation.metered", { amount: quote.device_billing.rate_per_hour, currency: quote.device_billing.currency }) : t("creation.personalFree") }),
1319
- /* @__PURE__ */ jsx("p", { children: expired ? t("managed.quoteExpired") : t("managed.quoteExpiry", { at: new Date(quote.expires_at).toLocaleString() }) }),
1320
- /* @__PURE__ */ jsx(Button, { disabled: disabled || expired, onClick: () => {
1321
- if (Date.parse(quote.expires_at) > Date.now()) void submit({ request_id: crypto.randomUUID(), quote_id: quote.id, authorized_total_minor: quote.total_minor, currency: "CNY" });
1322
- }, children: t("creation.authorize", { amount: money(quote.total_minor) }) })
1323
- ] })
1324
- ] })
1325
- ] });
1326
- }
1327
-
1328
976
  // src/ui/device-create/create-proxy-capabilities.ts
1329
977
  function createProxyCapabilities(kind, spec, node) {
1330
978
  const cap = node?.reported_caps?.egress_proxy;
@@ -1347,9 +995,10 @@ function DeviceCreate({ open, onClose, onCreated }) {
1347
995
  const [busy, setBusy] = useState(false);
1348
996
  const [error, setError] = useState("");
1349
997
  const [quantity, setQuantity] = useState(1);
1350
- const [networkMode, setNetworkMode] = useState("none");
998
+ const [aixipsOpen, setAixipsOpen] = useState(false);
1351
999
  const [managedPending, setManagedPending] = useState(false);
1352
- const proxyCapabilities = createProxyCapabilities(kind, spec, nodes?.find((node) => node.id === nodeId));
1000
+ const selectedNode = nodes?.find((node) => node.id === nodeId);
1001
+ const proxyCapabilities = createProxyCapabilities(kind, spec, selectedNode);
1353
1002
  useEffect(() => {
1354
1003
  if (!open) return;
1355
1004
  setStep(0);
@@ -1361,10 +1010,10 @@ function DeviceCreate({ open, onClose, onCreated }) {
1361
1010
  setBusy(false);
1362
1011
  setError("");
1363
1012
  setQuantity(1);
1364
- setNetworkMode("none");
1013
+ setAixipsOpen(false);
1365
1014
  setManagedPending(false);
1366
1015
  }, [open]);
1367
- const proxyOk = networkMode !== "custom" || proxyCapabilities.custom && isSupportedProxyUrl(spec.proxy?.trim() ?? "");
1016
+ const proxyOk = kind !== "virtual" || !spec.proxy?.trim() || proxyCapabilities.custom && isSupportedProxyUrl(spec.proxy.trim());
1368
1017
  const canNext = (() => {
1369
1018
  if (step === 0) return true;
1370
1019
  if (step === 1) return !!nodeId;
@@ -1387,13 +1036,13 @@ function DeviceCreate({ open, onClose, onCreated }) {
1387
1036
  setError("\u8BF7\u9009\u62E9\u8BE5\u8282\u70B9\u5DF2\u5B89\u88C5\u7684\u7CFB\u7EDF\u7248\u672C\u540E\u518D\u521B\u5EFA\u3002");
1388
1037
  return;
1389
1038
  }
1390
- if (managedPending || networkMode === "managed") return;
1391
- if (networkMode === "custom" && !proxyCapabilities.custom) {
1039
+ if (managedPending) return;
1040
+ if (kind === "virtual" && spec.proxy?.trim() && !proxyCapabilities.custom) {
1392
1041
  setError(t("creation.unsupported"));
1393
1042
  return;
1394
1043
  }
1395
1044
  const provisionSpec = { ...spec, node_id: nodeId };
1396
- if (networkMode !== "custom") delete provisionSpec.proxy;
1045
+ if (kind !== "virtual" || !provisionSpec.proxy?.trim()) delete provisionSpec.proxy;
1397
1046
  setBusy(true);
1398
1047
  setError("");
1399
1048
  try {
@@ -1473,39 +1122,23 @@ function DeviceCreate({ open, onClose, onCreated }) {
1473
1122
  setVirtualSpecValid(false);
1474
1123
  }, hidePlatform: kind === "real", virtualOnly: kind === "virtual" }),
1475
1124
  step === 2 && (kind === "virtual" ? /* @__PURE__ */ jsx(VirtualSpecStep, { spec, onChange: setSpec, nodeId, onValidityChange: setVirtualSpecValid }) : /* @__PURE__ */ jsx(RealDiscoverStep, { nodeId, picked, onPick: setPicked })),
1476
- step === 3 && !managedPending && /* @__PURE__ */ jsxs(Fragment, { children: [
1477
- /* @__PURE__ */ jsxs("fieldset", { className: "space-y-2", children: [
1478
- /* @__PURE__ */ jsx("legend", { className: "text-sm font-medium", children: t("creation.network") }),
1479
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
1480
- proxyCapabilities.managed && /* @__PURE__ */ jsx(Button, { variant: networkMode === "managed" ? "primary" : "secondary", "aria-pressed": networkMode === "managed", disabled: busy, onClick: () => setNetworkMode("managed"), children: t("creation.managed") }),
1481
- proxyCapabilities.custom && /* @__PURE__ */ jsx(Button, { variant: networkMode === "custom" ? "primary" : "secondary", "aria-pressed": networkMode === "custom", disabled: busy, onClick: () => setNetworkMode("custom"), children: t("creation.custom") }),
1482
- /* @__PURE__ */ jsx(Button, { variant: networkMode === "none" ? "primary" : "secondary", "aria-pressed": networkMode === "none", disabled: busy, onClick: () => setNetworkMode("none"), children: t("creation.none") })
1483
- ] }),
1484
- !proxyCapabilities.custom && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("creation.unsupported") })
1485
- ] }),
1486
- /* @__PURE__ */ jsx(ProxySpoofStep, { spec, onChange: setSpec, isReal: kind === "real", showProxy: networkMode === "custom" && proxyCapabilities.custom })
1487
- ] }),
1488
- open && /* @__PURE__ */ jsx(
1489
- ManagedCreationPanel,
1125
+ step === 3 && !managedPending && proxyCapabilities.custom && usesAndroidSystemProxy(selectedNode) && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("proxy.androidSystemHint") }),
1126
+ /* @__PURE__ */ jsx(Dialog, { open: aixipsOpen, onClose: () => setAixipsOpen(false), title: t("creation.chooseManaged"), description: t("proxy.regionPurchaseHint"), maxWidth: "max-w-lg", children: aixipsOpen && (quantity === 1 ? /* @__PURE__ */ jsx(
1127
+ IpCommercePanel,
1490
1128
  {
1491
- visible: step === 3 && networkMode === "managed",
1129
+ regionOnly: true,
1492
1130
  supported: proxyCapabilities.managed,
1493
- quantity,
1494
- spec: { ...spec, proxy: void 0, node_id: nodeId },
1495
- onPendingChange: (pending) => {
1496
- setManagedPending(pending);
1497
- if (pending) {
1498
- setNetworkMode("managed");
1499
- setStep(3);
1500
- }
1501
- },
1502
- onComplete: (_deviceId, ready) => {
1131
+ creationSpec: { ...spec, proxy: void 0, node_id: nodeId },
1132
+ onPendingChange: setManagedPending,
1133
+ onCreated: () => {
1503
1134
  void fetchDevices();
1504
- if (ready) onCreated?.(null);
1135
+ onCreated?.(null);
1505
1136
  onClose();
1506
1137
  }
1507
1138
  }
1508
- ),
1139
+ ) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("creation.singleOnly") })) }),
1140
+ step === 3 && !managedPending && /* @__PURE__ */ jsx(ProxySpoofStep, { spec, onChange: setSpec, isReal: kind === "real", showProxy: kind === "virtual", proxyDisabled: !proxyCapabilities.custom, proxyAction: kind === "virtual" ? /* @__PURE__ */ jsx("button", { type: "button", className: "mt-2 min-h-11 text-sm text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-50", disabled: busy, onClick: () => setAixipsOpen(true), children: t("creation.chooseManaged") }) : void 0 }),
1141
+ step === 3 && kind === "virtual" && managedPending && /* @__PURE__ */ jsx("button", { type: "button", className: "min-h-11 text-sm text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary", onClick: () => setAixipsOpen(true), children: t("creation.chooseManaged") }),
1509
1142
  step === 3 && kind === "virtual" && !managedPending && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1510
1143
  /* @__PURE__ */ jsx("label", { className: "text-[11px] text-muted-foreground", children: "\u521B\u5EFA\u6570\u91CF" }),
1511
1144
  /* @__PURE__ */ jsx(
@@ -1523,7 +1156,7 @@ function DeviceCreate({ open, onClose, onCreated }) {
1523
1156
  ] }),
1524
1157
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t border-border pt-3", children: [
1525
1158
  /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: step === 0 || busy || managedPending, onClick: back, children: "\u4E0A\u4E00\u6B65" }),
1526
- step < 3 ? /* @__PURE__ */ jsx(Button, { size: "sm", disabled: !canNext || managedPending, onClick: next, children: "\u4E0B\u4E00\u6B65" }) : networkMode === "managed" || managedPending ? null : /* @__PURE__ */ jsx(
1159
+ step < 3 ? /* @__PURE__ */ jsx(Button, { size: "sm", disabled: !canNext || managedPending, onClick: next, children: "\u4E0B\u4E00\u6B65" }) : managedPending ? null : /* @__PURE__ */ jsx(
1527
1160
  Button,
1528
1161
  {
1529
1162
  size: "sm",
@@ -1585,4 +1218,4 @@ function TypeCard({
1585
1218
  );
1586
1219
  }
1587
1220
 
1588
- export { AddWirelessDeviceDialog, DeviceCreate, NodePicker, ProxySpoofStep, RealDiscoverStep, VirtualSpecStep, createProxyProbeGuard, deviceProxyCapabilities, isProxyApplyStatus, isProxyProbeUnsupported, isRedactedProxyUrl, isSupportedProxyUrl, proxyCapabilityReason, proxyProbeExitIp, proxyProbeMessage, proxySummaryFromDevice, redactProxyUrl };
1221
+ export { AddWirelessDeviceDialog, DeviceCreate, NodePicker, ProxySpoofStep, RealDiscoverStep, VirtualSpecStep, createProxyProbeGuard, deviceProxyCapabilities, isProxyApplyStatus, isProxyProbeUnsupported, isRedactedProxyUrl, isSupportedProxyUrl, proxyCapabilityReason, proxyProbeExitIp, proxyProbeMessage, proxySummaryFromDevice, redactProxyUrl, usesAndroidSystemProxy };
@@ -1,5 +1,5 @@
1
- import { DeviceChannel, ScriptDebugger, FlowRun, MirrorSession, normalizeDevices, submitBatch } from './chunk-UH5OYPXE.js';
2
- import { resolveConfig, AixClient, isFleetRunTerminal, joinUrl, AixAuthError, AixError, EnvRun, detectEnvOs, summarizeEnv, ReconnectingSocket, executionWsTicketUrl } from './chunk-PUEKOYSH.js';
1
+ import { DeviceChannel, ScriptDebugger, FlowRun, MirrorSession, normalizeDevices, submitBatch } from './chunk-7BJPVSEZ.js';
2
+ import { resolveConfig, AixClient, isFleetRunTerminal, joinUrl, AixAuthError, AixError, EnvRun, detectEnvOs, summarizeEnv, ReconnectingSocket, executionWsTicketUrl } from './chunk-2KPZSPV6.js';
3
3
  import React, { createContext, useContext, useState, useRef, useEffect, useCallback, useMemo, createElement } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
@@ -219,7 +219,7 @@ function useFlowRun() {
219
219
  }, []);
220
220
  return { taskId, events, done, error, submit, close };
221
221
  }
222
- function useMirror(sessionId) {
222
+ function useMirror(sessionId, options = {}) {
223
223
  const cfg = useAixConfig();
224
224
  const [session, setSession] = useState(null);
225
225
  const [stream, setStream] = useState(null);
@@ -241,7 +241,7 @@ function useMirror(sessionId) {
241
241
  if (!sessionId) return () => {
242
242
  mountedRef.current = false;
243
243
  };
244
- MirrorSession.join(cfg, sessionId, joining.signal).then((ms) => {
244
+ MirrorSession.join(cfg, sessionId, joining.signal, options).then((ms) => {
245
245
  if (cancelled) {
246
246
  ms.leave();
247
247
  return;
@@ -277,7 +277,7 @@ function useMirror(sessionId) {
277
277
  ref.current?.leave();
278
278
  ref.current = null;
279
279
  };
280
- }, [cfg, sessionId]);
280
+ }, [cfg, sessionId, options.permission]);
281
281
  const sendInput = useCallback((msg) => {
282
282
  ref.current?.sendInput(msg);
283
283
  }, []);