@xopcai/xopc 0.0.462 → 0.0.463

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 (80) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +1 -0
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +1 -0
  3. package/dist/browser-ext/dist/assets/{auth-CQmxIyWw.js → auth-YPMDpWOW.js} +32 -1
  4. package/dist/browser-ext/dist/background.js +24 -19
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +7 -7
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/telegram/xopc.extension.json +1 -1
  9. package/dist/gateway/static/root/assets/agent-plugin-dialog-C_rlXuEe.js +1 -0
  10. package/dist/gateway/static/root/assets/{apps-page-QLOYw2QR.js → apps-page-D1qzENN_.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-DpKnqajR.js → automations-page-HYFnPiNG.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-workspace-BXT_EDON.js → automations-workspace-JCQ1IXFk.js} +2 -2
  13. package/dist/gateway/static/root/assets/{capabilities-page-CnU0htlO.js → capabilities-page-kPv2dOzf.js} +2 -2
  14. package/dist/gateway/static/root/assets/{chat-page-U2a7d6wP.js → chat-page-CalELOKj.js} +6 -6
  15. package/dist/gateway/static/root/assets/{connectors-page-Bs29RvXz.js → connectors-page-B9mpz_Rt.js} +1 -1
  16. package/dist/gateway/static/root/assets/{index-CEBDMkde.js → index-DUo6H0PC.js} +4 -4
  17. package/dist/gateway/static/root/assets/mcp-conversation-setup-page-DCIEL5bA.js +1 -0
  18. package/dist/gateway/static/root/assets/{note-detail-panel-D_l5jkV9.js → note-detail-panel-DsXb1qjW.js} +2 -2
  19. package/dist/gateway/static/root/assets/{notes-page-R4uJroeD.js → notes-page-BTpiOw67.js} +1 -1
  20. package/dist/gateway/static/root/assets/{personal-page-BsONyPfQ.js → personal-page-I3IGVSJh.js} +1 -1
  21. package/dist/gateway/static/root/assets/{plugin-details-dialog-nSDw8sfo.js → plugin-details-dialog-F08k_k2u.js} +1 -1
  22. package/dist/gateway/static/root/assets/{project-detail-page-xNSy6SAv.js → project-detail-page-Dy46uSEt.js} +1 -1
  23. package/dist/gateway/static/root/assets/{route-preload-Dwb_N8L-.js → route-preload-ChTaYgpA.js} +2 -2
  24. package/dist/gateway/static/root/assets/{service-recommendation-list-DDlMyPvC.js → service-recommendation-list-BmRtbJz2.js} +1 -1
  25. package/dist/gateway/static/root/assets/{settings-page-8MiJzbbl.js → settings-page-C39lKVRv.js} +1 -1
  26. package/dist/gateway/static/root/assets/{task-detail-page-DxKXoBbE.js → task-detail-page-D1dNWTnP.js} +1 -1
  27. package/dist/gateway/static/root/assets/{work-discovery-overlay-UvWbDUXi.js → work-discovery-overlay-BJ15p4rH.js} +1 -1
  28. package/dist/gateway/static/root/assets/{work-discovery-page-BM1HsYz6.js → work-discovery-page-8XciWNs5.js} +1 -1
  29. package/dist/gateway/static/root/index.html +6 -6
  30. package/dist/package.js +1 -1
  31. package/dist/src/agent/embedded/session-runner.js +2 -2
  32. package/dist/src/agent/external-tools/gateway-tools.js +8 -1
  33. package/dist/src/agent/mcp/connection-setup.js +46 -42
  34. package/dist/src/agent/mcp/conversation-setup.js +13 -8
  35. package/dist/src/agent/mcp/discovery.d.ts +22 -1
  36. package/dist/src/agent/mcp/discovery.js +19 -3
  37. package/dist/src/agent/mcp/managed-discovery.d.ts +8 -0
  38. package/dist/src/agent/mcp/managed-discovery.js +77 -0
  39. package/dist/src/agent/mcp/tool-catalog.js +1 -1
  40. package/dist/src/agent/prompt/conversational-configuration-guide.js +1 -1
  41. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +6 -2
  42. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +10 -7
  43. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
  44. package/dist/src/agent/tool-manuals/xopc-configuration.js +12 -4
  45. package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
  46. package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
  47. package/dist/src/cli/commands/update.js +1 -1
  48. package/dist/src/connectors/connection-recovery-service.js +38 -5
  49. package/dist/src/connectors/excluded-connectors.d.ts +1 -0
  50. package/dist/src/connectors/excluded-connectors.js +5 -1
  51. package/dist/src/connectors/plugin-connection.d.ts +10 -0
  52. package/dist/src/connectors/plugin-connection.js +105 -0
  53. package/dist/src/extensions/agent-plugins/setup.js +1 -1
  54. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  55. package/dist/src/gateway/hono/middleware/auth.js +1 -1
  56. package/dist/src/gateway/hono/routes/agent-plugins.js +2 -2
  57. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  58. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  59. package/dist/src/gateway/hono/routes/desktop-host.js +1 -1
  60. package/dist/src/gateway/hono/routes/home.js +1 -1
  61. package/dist/src/gateway/hono/routes/imports.js +1 -1
  62. package/dist/src/gateway/hono/routes/personal-agent.js +3 -3
  63. package/dist/src/gateway/hono/routes/update.js +2 -2
  64. package/dist/src/gateway/index.js +1 -1
  65. package/dist/src/gateway/run-loop.js +2 -2
  66. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  67. package/dist/src/gateway/service/agent-runner.js +1 -1
  68. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  69. package/dist/src/gateway/service.js +11 -11
  70. package/dist/src/home-intelligence/host.js +5 -5
  71. package/dist/src/infra/gateway-processes.js +1 -1
  72. package/dist/src/infra/update-restart.js +2 -2
  73. package/dist/src/infra/update-runner.js +2 -2
  74. package/dist/src/infra/update-startup.js +1 -1
  75. package/dist/src/notifications/service.js +2 -2
  76. package/dist/src/phone/stream-gateway.js +1 -1
  77. package/dist/src/tui/tui-management.js +2 -2
  78. package/package.json +1 -1
  79. package/dist/gateway/static/root/assets/agent-plugin-dialog-CikzCYAG.js +0 -1
  80. package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CsTSmjmX.js +0 -1
@@ -236,6 +236,7 @@
236
236
  "noMatchingModels": {"message": "No matching models"},
237
237
  "commandsAndSkills": {"message": "Commands and skills"},
238
238
  "loadingCommands": {"message": "Loading commands"},
239
+ "commandsLoadFailed": {"message": "Could not load commands and skills. Close and reopen the menu to retry."},
239
240
  "noMatchingCommands": {"message": "No matching commands or skills"},
240
241
  "skillUnavailable": {"message": "Unavailable for this agent"},
241
242
  "voiceInput": {"message": "Voice input"},
@@ -236,6 +236,7 @@
236
236
  "noMatchingModels": {"message": "没有匹配的模型"},
237
237
  "commandsAndSkills": {"message": "命令与技能"},
238
238
  "loadingCommands": {"message": "正在加载命令"},
239
+ "commandsLoadFailed": {"message": "无法加载命令和技能,请关闭菜单后重试。"},
239
240
  "noMatchingCommands": {"message": "没有匹配的命令或技能"},
240
241
  "skillUnavailable": {"message": "当前 Agent 不可用"},
241
242
  "voiceInput": {"message": "语音输入"},
@@ -8279,6 +8279,37 @@ function wait(milliseconds) {
8279
8279
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
8280
8280
  }
8281
8281
  async function pairGateway(invitation, onApproval, requestedOrigin) {
8282
+ const originalProfile = await readProfile();
8283
+ return withPairingLock(async () => {
8284
+ const current = await readProfile();
8285
+ if (!originalProfile && current?.gatewayId === parseBrowserPairingInvitation(invitation, true).gatewayId) return current;
8286
+ return completeGatewayPairing(invitation, onApproval, requestedOrigin);
8287
+ });
8288
+ }
8289
+ function withPairingLock(operation) {
8290
+ const locks = globalThis.navigator?.locks;
8291
+ if (!locks) return operation();
8292
+ return new Promise((resolve, reject) => {
8293
+ void locks.request("xopc.browser.pairing", () => operation().then(resolve, reject)).catch(reject);
8294
+ });
8295
+ }
8296
+ async function autoConnectLocalGateway() {
8297
+ return withPairingLock(async () => {
8298
+ const profile = await readProfile();
8299
+ if (profile) return profile;
8300
+ if (!await isAutoConnectEnabled()) return void 0;
8301
+ const pending = await readPendingBrowserPairing();
8302
+ if (pending) {
8303
+ const payload = parseBrowserPairingInvitation(pending.invitation, true);
8304
+ if (pending.nextOrigin || !payload.routes.every((route) => route.kind === "local-browser")) return void 0;
8305
+ return completeGatewayPairing(pending.invitation, () => void 0);
8306
+ }
8307
+ const local = await discoverLocalGateway();
8308
+ if (!local) return void 0;
8309
+ return completeGatewayPairing(local.invitation, () => void 0, new URL(local.gatewayUrl).origin);
8310
+ });
8311
+ }
8312
+ async function completeGatewayPairing(invitation, onApproval, requestedOrigin) {
8282
8313
  const payload = parseBrowserPairingInvitation(invitation, true);
8283
8314
  const origins = [...new Set(payload.routes.map((route) => new URL(route.url).origin))];
8284
8315
  const selectedOrigin = requestedOrigin && origins.includes(requestedOrigin) ? requestedOrigin : origins[0];
@@ -8613,4 +8644,4 @@ async function revokeAndForgetProfile() {
8613
8644
  }
8614
8645
  }
8615
8646
 
8616
- export { providerCatalogSchema as A, providerEndpointDescriptor as B, readPendingBrowserPairing as C, readProfile as D, ENDPOINT_PROTOCOL_VERSION as E, record as F, registerBrowserEndpoint as G, revokeAndForgetProfile as H, runWithTabSiteAccess as I, saveExtensionLocalePreference as J, setAutoConnectEnabled as K, strictObject as L, MAX_BROWSER_CONTEXTS_PER_TURN as M, string as N, t as O, PENDING_CONTEXT_KEY as P, union as Q, REALTIME_PROTOCOL_VERSION as R, unknown as S, TAB_BINDING_PREFIX as T, _enum as _, RealtimeClient as a, activeTabId as b, array as c, assertProviderSchemaBudget as d, boolean as e, browserPageContextsInputSchema as f, cancelPendingBrowserPairing as g, canonicalJson as h, capabilityProviderSchema as i, captureContextMenuSelection as j, captureTabWithPermission as k, createBrowserEndpointHello as l, createBrowserRequestProof as m, currentTabDescriptor as n, discoverLocalGateway as o, discriminatedUnion as p, endpointToolContentSchema as q, extensionLocale as r, gatewayFetch as s, getAccessProfile as t, literal as u, loadExtensionLocalePreference as v, number as w, object as x, openDatabase as y, pairGateway as z };
8647
+ export { openDatabase as A, pairGateway as B, providerCatalogSchema as C, providerEndpointDescriptor as D, ENDPOINT_PROTOCOL_VERSION as E, readPendingBrowserPairing as F, readProfile as G, record as H, registerBrowserEndpoint as I, revokeAndForgetProfile as J, runWithTabSiteAccess as K, saveExtensionLocalePreference as L, MAX_BROWSER_CONTEXTS_PER_TURN as M, setAutoConnectEnabled as N, strictObject as O, PENDING_CONTEXT_KEY as P, string as Q, REALTIME_PROTOCOL_VERSION as R, t as S, TAB_BINDING_PREFIX as T, union as U, unknown as V, _enum as _, RealtimeClient as a, activeTabId as b, array as c, assertProviderSchemaBudget as d, autoConnectLocalGateway as e, boolean as f, browserPageContextsInputSchema as g, cancelPendingBrowserPairing as h, canonicalJson as i, capabilityProviderSchema as j, captureContextMenuSelection as k, captureTabWithPermission as l, createBrowserEndpointHello as m, createBrowserRequestProof as n, currentTabDescriptor as o, discoverLocalGateway as p, discriminatedUnion as q, endpointToolContentSchema as r, extensionLocale as s, gatewayFetch as t, getAccessProfile as u, isAutoConnectEnabled as v, literal as w, loadExtensionLocalePreference as x, number as y, object as z };
@@ -1,4 +1,4 @@
1
- import { w as number, N as string, L as strictObject, e as boolean, c as array, _ as _enum, u as literal, i as capabilityProviderSchema, B as providerEndpointDescriptor, d as assertProviderSchemaBudget, A as providerCatalogSchema, q as endpointToolContentSchema, E as ENDPOINT_PROTOCOL_VERSION, h as canonicalJson, T as TAB_BINDING_PREFIX, j as captureContextMenuSelection, P as PENDING_CONTEXT_KEY, O as t, D as readProfile, s as gatewayFetch, G as registerBrowserEndpoint, t as getAccessProfile, a as RealtimeClient, l as createBrowserEndpointHello, R as REALTIME_PROTOCOL_VERSION, m as createBrowserRequestProof } from './assets/auth-CQmxIyWw.js';
1
+ import { y as number, Q as string, O as strictObject, f as boolean, c as array, _ as _enum, w as literal, j as capabilityProviderSchema, D as providerEndpointDescriptor, d as assertProviderSchemaBudget, C as providerCatalogSchema, r as endpointToolContentSchema, E as ENDPOINT_PROTOCOL_VERSION, i as canonicalJson, T as TAB_BINDING_PREFIX, k as captureContextMenuSelection, P as PENDING_CONTEXT_KEY, S as t, t as gatewayFetch, G as readProfile, v as isAutoConnectEnabled, e as autoConnectLocalGateway, I as registerBrowserEndpoint, u as getAccessProfile, a as RealtimeClient, m as createBrowserEndpointHello, R as REALTIME_PROTOCOL_VERSION, n as createBrowserRequestProof } from './assets/auth-YPMDpWOW.js';
2
2
 
3
3
  async function browserDom(input) {
4
4
  const root = globalThis;
@@ -1725,7 +1725,7 @@ function fitBrowserControlResultToFrame(result, maxBytes = MAX_BROWSER_CONTROL_R
1725
1725
  const log = createLogger("Background");
1726
1726
  const BACKGROUND_CLIENT_ID_KEY = "xopc.browser.background-client-id";
1727
1727
  const RECONNECT_ALARM = "xopc.browser.reconnect";
1728
- const RECONNECT_DELAY_MINUTES = 1;
1728
+ const RECONNECT_DELAY_MINUTES = 0.5;
1729
1729
  let realtime;
1730
1730
  let endpointClaim;
1731
1731
  let lastConnectionError;
@@ -1753,8 +1753,13 @@ function clearReconnectAlarm() {
1753
1753
  void chrome.alarms.clear(RECONNECT_ALARM);
1754
1754
  }
1755
1755
  function scheduleReconnectAlarm() {
1756
- if (endpointClaim) return;
1757
- chrome.alarms.create(RECONNECT_ALARM, { delayInMinutes: RECONNECT_DELAY_MINUTES });
1756
+ void chrome.alarms.get(RECONNECT_ALARM).then((alarm) => {
1757
+ if (alarm?.periodInMinutes === RECONNECT_DELAY_MINUTES) return;
1758
+ return chrome.alarms.create(RECONNECT_ALARM, {
1759
+ delayInMinutes: RECONNECT_DELAY_MINUTES,
1760
+ periodInMinutes: RECONNECT_DELAY_MINUTES
1761
+ });
1762
+ }).catch((error) => log.warn("Could not schedule browser reconnect", { error: String(error) }));
1758
1763
  }
1759
1764
  const browserToolRegistry = new EndpointToolRegistry([{
1760
1765
  descriptor: BROWSER_CONTROL_ENDPOINT_DESCRIPTOR,
@@ -1789,7 +1794,14 @@ async function backgroundClientId() {
1789
1794
  return value;
1790
1795
  }
1791
1796
  async function connect(generation) {
1792
- if (realtime || !await readProfile()) return;
1797
+ if (realtime) return;
1798
+ if (await readProfile() || await isAutoConnectEnabled()) scheduleReconnectAlarm();
1799
+ else {
1800
+ clearReconnectAlarm();
1801
+ return;
1802
+ }
1803
+ if (!await autoConnectLocalGateway()) return;
1804
+ if (generation !== connectionGeneration) return;
1793
1805
  await registerBrowserEndpoint();
1794
1806
  const profile = await getAccessProfile();
1795
1807
  const compatibility = await gatewayFetch("/api/endpoint-tools/compatibility", {}, profile);
@@ -1838,7 +1850,6 @@ async function connect(generation) {
1838
1850
  endpointClaim = { endpointId, token: turnToken };
1839
1851
  if (environmentSupported) contextPublisher.start(endpointClaim);
1840
1852
  lastConnectionError = void 0;
1841
- clearReconnectAlarm();
1842
1853
  endpointHost.connect((message) => client.sendEndpointMessage(message));
1843
1854
  void chrome.runtime.sendMessage({ type: "browser/endpoint-ready", claim: endpointClaim }).catch(() => void 0);
1844
1855
  log.info("Browser control connected through Gateway Realtime", { endpointId });
@@ -1935,25 +1946,19 @@ chrome.runtime.onInstalled.addListener(() => {
1935
1946
  chrome.runtime.onStartup.addListener(connectWithLogging);
1936
1947
  chrome.alarms.onAlarm.addListener((alarm) => {
1937
1948
  if (alarm.name !== RECONNECT_ALARM) return;
1938
- void readProfile().then((profile) => {
1939
- if (!profile) {
1940
- clearReconnectAlarm();
1941
- return;
1942
- }
1943
- if (endpointClaim) {
1944
- clearReconnectAlarm();
1945
- return;
1946
- }
1947
- disconnect();
1948
- connectWithLogging();
1949
- });
1949
+ if (endpointClaim || connectTask) return;
1950
+ disconnect();
1951
+ connectWithLogging();
1950
1952
  });
1951
1953
  chrome.storage.onChanged.addListener((changes, area) => {
1952
1954
  if (area === "local" && changes["xopc.browser.profile"]) {
1955
+ const { oldValue, newValue } = changes["xopc.browser.profile"];
1956
+ if (oldValue && newValue && oldValue.gatewayId === newValue.gatewayId && oldValue.deviceId === newValue.deviceId && oldValue.gatewayPublicKey === newValue.gatewayPublicKey && oldValue.gatewayUrl === newValue.gatewayUrl) return;
1953
1957
  disconnect();
1954
- if (changes["xopc.browser.profile"].newValue) connectWithLogging();
1958
+ if (newValue) connectWithLogging();
1955
1959
  else clearReconnectAlarm();
1956
1960
  }
1961
+ if (area === "local" && changes["xopc.browser.auto-connect"]) connectWithLogging();
1957
1962
  });
1958
1963
  void chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true });
1959
1964
  connectWithLogging();
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>xopc</title>
7
7
  <script type="module" crossorigin src="./sidepanel.js"></script>
8
- <link rel="modulepreload" crossorigin href="./assets/auth-CQmxIyWw.js">
8
+ <link rel="modulepreload" crossorigin href="./assets/auth-YPMDpWOW.js">
9
9
  <link rel="stylesheet" crossorigin href="./assets/sidepanel-lpBGVKwZ.css">
10
10
  </head>
11
11
  <body>
@@ -1,4 +1,4 @@
1
- import { L as strictObject, c as array, Q as union, u as literal, N as string, p as discriminatedUnion, w as number, e as boolean, _ as _enum, x as object, f as browserPageContextsInputSchema, F as record$1, S as unknown, O as t, M as MAX_BROWSER_CONTEXTS_PER_TURN, s as gatewayFetch, r as extensionLocale, y as openDatabase, a as RealtimeClient, R as REALTIME_PROTOCOL_VERSION, b as activeTabId, n as currentTabDescriptor, T as TAB_BINDING_PREFIX, t as getAccessProfile, D as readProfile, I as runWithTabSiteAccess, P as PENDING_CONTEXT_KEY, k as captureTabWithPermission, z as pairGateway, K as setAutoConnectEnabled, C as readPendingBrowserPairing, o as discoverLocalGateway, J as saveExtensionLocalePreference, H as revokeAndForgetProfile, g as cancelPendingBrowserPairing, v as loadExtensionLocalePreference } from './assets/auth-CQmxIyWw.js';
1
+ import { O as strictObject, c as array, U as union, w as literal, Q as string, q as discriminatedUnion, y as number, f as boolean, _ as _enum, z as object, g as browserPageContextsInputSchema, H as record$1, V as unknown, S as t, M as MAX_BROWSER_CONTEXTS_PER_TURN, t as gatewayFetch, s as extensionLocale, A as openDatabase, a as RealtimeClient, R as REALTIME_PROTOCOL_VERSION, b as activeTabId, o as currentTabDescriptor, T as TAB_BINDING_PREFIX, u as getAccessProfile, G as readProfile, K as runWithTabSiteAccess, P as PENDING_CONTEXT_KEY, l as captureTabWithPermission, B as pairGateway, N as setAutoConnectEnabled, F as readPendingBrowserPairing, p as discoverLocalGateway, L as saveExtensionLocalePreference, J as revokeAndForgetProfile, h as cancelPendingBrowserPairing, x as loadExtensionLocalePreference } from './assets/auth-YPMDpWOW.js';
2
2
 
3
3
  const id = string().regex(/^[A-Za-z0-9_-]{1,64}$/);
4
4
  const choice = strictObject({ id, label: string().trim().min(1).max(120), description: string().max(500).optional() });
@@ -45218,6 +45218,7 @@ function ChatPanel({ gatewayId, deviceId }) {
45218
45218
  const [commandsOpen, setCommandsOpen] = reactExports.useState(false);
45219
45219
  const [commands, setCommands] = reactExports.useState([]);
45220
45220
  const [commandsLoading, setCommandsLoading] = reactExports.useState(false);
45221
+ const [commandsFailed, setCommandsFailed] = reactExports.useState(false);
45221
45222
  const [commandIndex, setCommandIndex] = reactExports.useState(0);
45222
45223
  const commandRange = commandsOpen ? findCommand(draft, cursor) : void 0;
45223
45224
  const commandItems = commandRange ? commands.filter((item) => matchesCommandQuery(item, commandRange.query)).slice(0, 12) : [];
@@ -45404,14 +45405,13 @@ function ChatPanel({ gatewayId, deviceId }) {
45404
45405
  reactExports.useEffect(() => {
45405
45406
  if (!commandsOpen) return;
45406
45407
  let active = true;
45408
+ setCommands([]);
45407
45409
  setCommandsLoading(true);
45410
+ setCommandsFailed(false);
45408
45411
  void loadComposerCommands(snapshot.conversationId).then((items) => {
45409
45412
  if (active) setCommands(items);
45410
- }).catch((cause) => {
45411
- if (active) {
45412
- setCommands([]);
45413
- setError(String(cause));
45414
- }
45413
+ }).catch(() => {
45414
+ if (active) setCommandsFailed(true);
45415
45415
  }).finally(() => {
45416
45416
  if (active) setCommandsLoading(false);
45417
45417
  });
@@ -45948,7 +45948,7 @@ ${pageContext.context.selection ?? pageContext.context.text ?? ""}` }), children
45948
45948
  item.disabled ? ` · ${t("skillUnavailable")}` : ""
45949
45949
  ] })
45950
45950
  ] }, item.id)),
45951
- !commandsLoading && !commandItems.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "tab-mention-empty", children: t("noMatchingCommands") }) : null
45951
+ !commandsLoading && !commandItems.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "tab-mention-empty", children: t(commandsFailed ? "commandsLoadFailed" : "noMatchingCommands") }) : null
45952
45952
  ] }) : null,
45953
45953
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "composer-input-row", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
45954
45954
  "textarea",
@@ -3,7 +3,7 @@
3
3
  "minimum_chrome_version": "120",
4
4
  "default_locale": "en",
5
5
  "name": "__MSG_appName__",
6
- "version": "0.0.462",
6
+ "version": "0.0.463",
7
7
  "description": "__MSG_appDescription__",
8
8
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqnpr4vpLC/nmvy+wiOWk3SWlp2nEZkFijfk8ivGw7StNZgCK90nOMvwhdEtlkk3GOWDvdVnq8HxCsM3UNQ8FnGUyerpH1FJXqXuradxeHf8ZxFjiQU/mIWfnKbUuONWQORon3/pigyoXoK/VUXgg0Wbm/rbVwsS0bv+25R6m+mZgBspOLeKuoH7ivhL+48WV6POtMBsFPZweY26477EM7ukh+56Ff5ENevB8ymxBBn7qK5ZoeZd2a23U8ioX5TsHfe6fnrjitPWjIxD8G0NoKQxcaa/Mo+xs+T6UiLKxP0wjz5bm7jB5H+CXtkRJqzBWUB0h+RSLJckzZfA8BAJrRwIDAQAB",
9
9
  "permissions": [
@@ -2,7 +2,7 @@
2
2
  "id": "telegram",
3
3
  "name": "Telegram Channel",
4
4
  "description": "Bundled Telegram Bot channel (private workspace sources; ships inside @xopcai/xopc dist/)",
5
- "version": "0.0.462",
5
+ "version": "0.0.463",
6
6
  "kind": "channel",
7
7
  "main": "src/index.js",
8
8
  "channels": [
@@ -0,0 +1 @@
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{l as a,t as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as c,n as l,o as u}from"./locale-store-Dy1EByeG.js";import{t as d}from"./messages-BAnhwALN.js";import{a as f,i as p,o as m,r as h,s as g,t as ee}from"./dist-CY7CS_D3.js";import{t as _}from"./arrow-left-D880xG-P.js";import{t as v}from"./chevron-down-ccbiQQz_.js";import{t as y}from"./working-directory-picker-modal-BGZduAXV.js";import{t as te}from"./circle-alert-BEjgurr2.js";import{t as ne}from"./circle-check-C23XjkUj.js";import{t as re}from"./circle-BoO4YvTx.js";import{t as b}from"./file-archive-DanfQJNe.js";import{t as x}from"./folder-open-CyzJ19I9.js";import{t as ie}from"./loader-circle-CifKLtgG.js";import{t as S}from"./package-wATCyihJ.js";import{t as C}from"./shield-check-BU58siTV.js";import{t as w}from"./upload-rrb46c3c.js";import{t as T}from"./cn-0WouolD0.js";import{t as ae}from"./skeleton-DzdOeGYz.js";import{a as E}from"./vendor-swr-CdRzEUwF.js";import{t as D}from"./button-Cc4hUNTt.js";import{t as O}from"./capability-links-MZdYfPKx.js";import{t as oe}from"./browser-BLJWD7WI.js";import{t as k}from"./capability-icon-CmvCZOJX.js";var A=r(),j=i();function se(e){let t=(0,A.c)(30),{data:n,zh:r}=e,i=r?`插件内容与范围`:`Contents and access`,a;t[0]===i?a=t[1]:(a=(0,j.jsx)(`h4`,{className:`font-medium text-fg`,children:i}),t[0]=i,t[1]=a);let o=r?`新增技能:`:`Skills: `,s;t[2]!==n.latestVersion.componentIndex?.skills||t[3]!==r?(s=n.latestVersion.componentIndex?.skills.join(`, `)||(r?`目录未提供清单`:`Not listed in catalog`),t[2]=n.latestVersion.componentIndex?.skills,t[3]=r,t[4]=s):s=t[4];let c;t[5]!==o||t[6]!==s?(c=(0,j.jsxs)(`p`,{children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l=r?`工具连接:`:`Tool connections: `,u;t[8]!==n.latestVersion.componentIndex?.mcpServers||t[9]!==r?(u=n.latestVersion.componentIndex?.mcpServers.map(M).join(`, `)||(r?`目录未提供清单`:`Not listed in catalog`),t[8]=n.latestVersion.componentIndex?.mcpServers,t[9]=r,t[10]=u):u=t[10];let d;t[11]!==l||t[12]!==u?(d=(0,j.jsxs)(`p`,{children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13];let f=r?`运行范围:`:`Runtime scope: `,p=n.latestVersion.riskTier===`local-exec`?r?`包含本机代码执行,可能访问本机文件或网络`:`Includes local code execution; may access local files or networks`:n.latestVersion.riskTier===`network`?r?`包含网络服务调用;数据范围取决于账号授权`:`Includes network service calls; data scope depends on authorization`:n.latestVersion.riskTier===`content`?r?`目录标记为内容能力`:`Catalog classifies this as content capabilities`:r?`目录未声明,请查看说明与来源`:`Not declared; review documentation and source`,m;t[14]!==p||t[15]!==f?(m=(0,j.jsxs)(`p`,{children:[f,p]}),t[14]=p,t[15]=f,t[16]=m):m=t[16];let h=r?`授权与来源`:`Authorization and source`,g;t[17]===h?g=t[18]:(g=(0,j.jsx)(`summary`,{className:`w-fit cursor-pointer rounded focus-visible:outline-accent`,children:h}),t[17]=h,t[18]=g);let ee=r?`发布者认证只验证来源,不授予操作权限。账号授权与依赖需另行设置。未列出权限不代表没有文件或外部访问。`:`Publisher verification does not grant permissions. Accounts and dependencies require separate setup. Missing scope metadata does not mean no file or external access.`,_;t[19]===ee?_=t[20]:(_=(0,j.jsx)(`p`,{className:`mt-2 leading-5`,children:ee}),t[19]=ee,t[20]=_);let v;t[21]!==g||t[22]!==_?(v=(0,j.jsxs)(`details`,{className:`text-xs`,children:[g,_]}),t[21]=g,t[22]=_,t[23]=v):v=t[23];let y;return t[24]!==m||t[25]!==v||t[26]!==a||t[27]!==c||t[28]!==d?(y=(0,j.jsxs)(`section`,{className:`mt-4 space-y-2 rounded-lg border border-edge p-4 text-sm text-fg-muted`,children:[a,c,d,m,v]}),t[24]=m,t[25]=v,t[26]=a,t[27]=c,t[28]=d,t[29]=y):y=t[29],y}function M(e){return`${e.name} (${e.transport})`}var N=e(oe(),1),P=e(n(),1);function F(e){let t=(0,A.c)(6),{fields:n,values:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Object.entries(n),t[0]=n,t[1]=a);let o;return t[2]!==i||t[3]!==a||t[4]!==r?(o=(0,j.jsx)(j.Fragment,{children:a.map(e=>{let[t,n]=e;return(0,j.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,j.jsxs)(`span`,{children:[n.title,n.required?` *`:``]}),n.type===`boolean`?(0,j.jsx)(`input`,{type:`checkbox`,checked:r[t]===!0,onChange:e=>i({...r,[t]:e.target.checked})}):(0,j.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,type:n.sensitive?`password`:n.type===`number`?`number`:`text`,required:n.required,autoComplete:`off`,value:String(r[t]??``),onChange:e=>i({...r,[t]:n.type===`number`?Number(e.target.value):e.target.value})})]},t)})}),t[2]=i,t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function I(e){let t=(0,A.c)(62),{account:n,fields:r,zh:i,busy:a,attempt:o,initialMethod:s,onBack:c,onConnect:l,onSave:u,onRedirect:d,onSkip:f}=e,[p,m]=(0,P.useState)(s&&n.methods.some(e=>e.id===s)?s:n.methods[0]?.id??``),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[0]=h):h=t[0];let[g,ee]=(0,P.useState)(h),[v,y]=(0,P.useState)(``),[te,ne]=(0,P.useState)(),re;t[1]===p?re=t[2]:(re=e=>e.id===p,t[1]=p,t[2]=re);let b=n.methods.find(re),x;t[3]===i?x=t[4]:(x=(e,t)=>i?e:t,t[3]=i,t[4]=x);let S=x,C=o?.challenge?.type===`qr`?o.challenge.url:void 0,w,T;t[5]===C?(w=t[6],T=t[7]):(w=()=>{let e=!1;return ne(void 0),C&&N.toDataURL(C,{width:240,margin:2}).then(t=>{e||ne(t)}).catch(R),()=>{e=!0}},T=[C],t[5]=C,t[6]=w,t[7]=T),(0,P.useEffect)(w,T);let E;t[8]===o?E=t[9]:(E=o&&![`cancelled`,`error`,`connected`].includes(o.state),t[8]=o,t[9]=E);let O=E,oe=o?.authorizationUrl??o?.challenge?.url,k=`连接 ${n.title}`,se=`Connect ${n.title}`,M;t[10]!==S||t[11]!==k||t[12]!==se?(M=S(k,se),t[10]=S,t[11]=k,t[12]=se,t[13]=M):M=t[13];let I;t[14]===S?I=t[15]:(I=S(`返回插件详情`,`Back to plugin details`),t[14]=S,t[15]=I);let z;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,j.jsx)(_,{className:`size-4`}),t[16]=z):z=t[16];let B;t[17]!==c||t[18]!==I?(B=(0,j.jsx)(D,{variant:`ghost`,className:`shrink-0`,onClick:c,"aria-label":I,children:z}),t[17]=c,t[18]=I,t[19]=B):B=t[19];let V;t[20]===S?V=t[21]:(V=S(`连接 `,`Connect `),t[20]=S,t[21]=V);let H;t[22]!==n.title||t[23]!==V?(H=(0,j.jsxs)(`h3`,{className:`text-base font-semibold`,children:[V,n.title]}),t[22]=n.title,t[23]=V,t[24]=H):H=t[24];let U;t[25]!==n.description||t[26]!==S?(U=n.description??S(`完成授权后自动检查连接。也可以稍后在详情页继续。`,`The connection is checked after authorization. You can also continue later in plugin details.`),t[25]=n.description,t[26]=S,t[27]=U):U=t[27];let W;t[28]===U?W=t[29]:(W=(0,j.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:U}),t[28]=U,t[29]=W);let G;t[30]!==H||t[31]!==W?(G=(0,j.jsxs)(`div`,{children:[H,W]}),t[30]=H,t[31]=W,t[32]=G):G=t[32];let K;t[33]!==B||t[34]!==G?(K=(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,G]}),t[33]=B,t[34]=G,t[35]=K):K=t[35];let q;t[36]!==n.methods||t[37]!==O||t[38]!==a||t[39]!==p||t[40]!==S?(q=n.methods.length>1?(0,j.jsx)(`div`,{role:`tablist`,"aria-label":S(`授权方式`,`Authorization methods`),className:`flex flex-wrap gap-2 rounded-lg bg-surface-inset p-1.5`,children:n.methods.map(e=>(0,j.jsx)(`button`,{role:`tab`,type:`button`,"aria-selected":p===e.id,className:`min-h-10 rounded-md px-3 text-sm ${p===e.id?`bg-surface-panel font-medium text-fg`:`text-fg-muted`}`,disabled:a||!!O,onClick:()=>{m(e.id),ee({})},children:e.title},e.id))}):null,t[36]=n.methods,t[37]=O,t[38]=a,t[39]=p,t[40]=S,t[41]=q):q=t[41];let ce=b?.instructions?.length||b?.helpUrl?(0,j.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[b.instructions?.length?(0,j.jsx)(`ol`,{className:`list-decimal space-y-2 pl-5`,children:b.instructions.map(L)}):null,b.helpUrl?(0,j.jsx)(`a`,{className:`text-accent underline`,href:b.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:S(`打开官方配置说明`,`Open setup instructions`)}):null]}):null,J=(b?.type===`form`||b?.fields?.length)&&!O?(0,j.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),u(b.id,g)},children:[(0,j.jsx)(F,{fields:Object.fromEntries((b.fields??[]).filter(e=>r[e]).map(e=>[e,{...r[e],required:!0}])),values:g,onChange:ee}),(0,j.jsxs)(D,{type:`submit`,disabled:a||!b.fields?.every(e=>g[e]!==void 0&&g[e]!==``),children:[a?(0,j.jsx)(ie,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,S(`保存并连接`,`Save and connect`)]})]}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[O?null:(0,j.jsx)(D,{disabled:a,onClick:()=>l(p),children:S(`连接账号`,`Connect account`)}),O?(0,j.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:o.challenge?.message??(o.state===`preparing`?S(`正在准备登录…`,`Preparing sign-in…`):S(`请完成登录,返回后会自动继续。`,`Finish signing in. Installation continues automatically.`))}):null,C&&O?te?(0,j.jsx)(`img`,{src:te,alt:S(`使用 ${n.title} 扫码授权`,`Scan to authorize ${n.title}`),className:`mx-auto size-60 max-w-full rounded-lg`}):(0,j.jsx)(ae,{className:`mx-auto size-60`}):null,oe&&O?(0,j.jsx)(`a`,{href:oe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-block text-sm text-accent underline`,children:C?S(`也可以打开授权页面`,`Or open the authorization page`):S(`打开登录页面`,`Open sign-in page`)}):null,o?.expiresAt&&O?(0,j.jsxs)(`p`,{className:`text-center text-xs text-fg-muted`,children:[S(`本次授权有效期至 `,`This sign-in expires at `),new Date(o.expiresAt).toLocaleTimeString()]}):null,o?.error?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:o.error}):null,o?.acceptsRedirect&&O?(0,j.jsxs)(`details`,{className:`text-sm`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:S(`登录后没有自动返回?`,`Did sign-in not return automatically?`)}),(0,j.jsxs)(`form`,{className:`mt-3 space-y-3`,onSubmit:e=>{e.preventDefault(),d(v)},children:[(0,j.jsxs)(`label`,{children:[S(`登录回调地址`,`Sign-in callback URL`),(0,j.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),className:`mt-1 w-full rounded-lg border border-edge bg-surface-inset p-2`})]}),(0,j.jsx)(D,{type:`submit`,disabled:a||!v,children:S(`继续登录`,`Continue sign-in`)})]})]}):null]}),Y;t[42]===S?Y=t[43]:(Y=S(`暂时跳过`,`Skip for now`),t[42]=S,t[43]=Y);let X;t[44]!==a||t[45]!==f||t[46]!==Y?(X=(0,j.jsx)(D,{variant:`secondary`,disabled:a,onClick:f,children:Y}),t[44]=a,t[45]=f,t[46]=Y,t[47]=X):X=t[47];let Z;t[48]===S?Z=t[49]:(Z=S(`相关功能暂不可用,可随时在插件详情中授权。`,`Features requiring this account stay unavailable. Connect later in plugin details.`),t[48]=S,t[49]=Z);let le;t[50]===Z?le=t[51]:(le=(0,j.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Z}),t[50]=Z,t[51]=le);let Q;t[52]!==X||t[53]!==le?(Q=(0,j.jsxs)(`div`,{className:`border-t border-edge pt-4`,children:[X,le]}),t[52]=X,t[53]=le,t[54]=Q):Q=t[54];let ue;return t[55]!==M||t[56]!==K||t[57]!==q||t[58]!==ce||t[59]!==J||t[60]!==Q?(ue=(0,j.jsxs)(`section`,{className:`space-y-5`,"aria-label":M,children:[K,q,ce,J,Q]}),t[55]=M,t[56]=K,t[57]=q,t[58]=ce,t[59]=J,t[60]=Q,t[61]=ue):ue=t[61],ue}function L(e,t){return(0,j.jsx)(`li`,{children:e},t)}function R(){}async function z(e,t=`GET`,n){let r=await u(c(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function B({extension:e,zh:t,onChanged:n,onStart:r,onInstalled:i,initialConnect:a=!1,connectionFlow:s=!1}){let c=`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)({}),[p,m]=(0,P.useState)(!1),[h,g]=(0,P.useState)(``),[ee,_]=(0,P.useState)({}),[v,y]=(0,P.useState)(null),[b,x]=(0,P.useState)(``),[S,C]=(0,P.useState)(null),[w,T]=(0,P.useState)(!1),E=(0,P.useRef)(!1),O=(0,P.useRef)(new Set),oe=(0,P.useRef)(new Set),k=(0,P.useRef)(void 0),A=(0,P.useRef)(null),se=(0,P.useRef)(new Set),M=(e,n)=>t?e:n,N=e.setup?.authorizations??[],L=new Set(N.flatMap(e=>e.servers)),R=[...N,...(l?.connections??[]).filter(t=>!L.has(t.name)&&(e.components?.mcp.find(e=>e.name===t.name)?.type!==`stdio`||t.state===`token_required`)).map(t=>{let n=t.state===`token_required`||t.state===`auth_unknown`||e.components?.mcp.find(e=>e.name===t.name)?.connectionAuth?.mode===`api-key`;return{id:t.name,title:t.name,servers:[t.name],methods:[{id:n?`api-key`:`oauth`,title:n?M(`访问令牌`,`Access token`):M(`浏览器登录`,`Browser sign-in`),type:n?`form`:`oauth`,...n?{fields:[`__apiKey`]}:{server:t.name}}]}})],B=e=>e.servers.every(e=>l?.connections.find(t=>t.name===e)?.state===`connected`)&&(!N.some(t=>t.id===e.id)||l?.authorizations?.find(t=>t.id===e.id)?.state===`connected`),V=(l?.authorizations??[]).flatMap(e=>(e.issues??[]).map(t=>({...t,account:R.find(t=>t.id===e.id)}))),H=R.filter(e=>!B(e)),U=l?.installed||l?.state===`completed`,W=e.setup?.userConfig??{},G=new Set(N.flatMap(e=>e.methods.flatMap(e=>e.fields??[]))),K=Object.fromEntries(Object.entries(W).filter(([e])=>!G.has(e))),q=l?.error===`Connection verification failed. Check the credentials or login status and try again.`?M(`连接验证未通过,请检查凭据或登录状态后重试。`,l.error):l?.error,ce=Object.fromEntries(Object.entries(W).filter(([e])=>l?.missingConfig?.includes(e))),J=p||l?.state===`running`,Y=R.find(e=>e.id===S);(0,P.useEffect)(()=>{let e=!1;return z(`${c}/setup`).then(t=>{e||u(t)}).catch(t=>{e||(u(null),g(String(t)))}),()=>{e=!0}},[c]),(0,P.useEffect)(()=>{if(l?.state!==`running`)return;let e=!1,t=!1,r=setInterval(()=>{t||(t=!0,z(`${c}/setup`).then(t=>{e||(u(t),t?.state!==`running`&&n())}).catch(t=>{e||g(String(t))}).finally(()=>{t=!1}))},750);return()=>{e=!0,clearInterval(r)}},[c,l?.state]),(0,P.useEffect)(()=>{if(!l||!l.connections.some(e=>[`oauth_required`,`error`].includes(e.state)))return;let e=!1;return z(`${c}/setup/reusable`).then(t=>{e||_(t)}).catch(()=>{e||_({})}),()=>{e=!0}},[c,l?.revision]),(0,P.useEffect)(()=>{if(!b||l?.state===`completed`)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await z(`${c}/setup/auth/${encodeURIComponent(b)}`);e||y(t)}catch(t){e||g(String(t))}finally{t=!1}}};n();let r=setInterval(()=>void n(),1500),i=()=>void n();return window.addEventListener(`focus`,i),()=>{e=!0,clearInterval(r),window.removeEventListener(`focus`,i)}},[c,b,l?.state]),(0,P.useEffect)(()=>{let e=v?.authorizationUrl??(v?.challenge?.type===`url`?v.challenge.url:void 0);if(!v)return;if(v.error||[`cancelled`,`error`,`connected`].includes(v.state)){A.current?.close(),A.current=null;return}if(!e){v.challenge?.type===`qr`&&(A.current?.close(),A.current=null);return}let t=`${v.id}:${e}`;if(se.current.has(t))return;se.current.add(t);let n=A.current;A.current=null,n&&!n.closed?n.location.replace(e):window.open(e,`_blank`,`noopener,noreferrer`)},[v]);async function X(e,t={},r=l?.revision){m(!0),g(``);try{let a=await z(`${c}/setup`,`POST`,{action:e,expectedRevision:r,...e===`start`?{}:{idempotencyKey:crypto.randomUUID()},...t}),o=e===`configure`&&N.find(e=>e.id===t.authorization)?.methods.some(e=>e.id===t.method&&e.type===`cli`);return([`reuse`,`start`].includes(e)||e===`configure`&&!o)&&(f({}),T(!1),a=await z(`${c}/setup`,`POST`,{action:`prepare`,expectedRevision:a.revision,idempotencyKey:crypto.randomUUID()})),u(a),await n(),[`complete`,`defer`].includes(e)&&(C(null),y(null),x(``),A.current?.close(),A.current=null,i?.()),a}catch(e){g(e instanceof Error?e.message:String(e));try{u(await z(`${c}/setup`))}catch{}return null}finally{m(!1)}}(0,P.useEffect)(()=>{if(!l||J||h||[`cancelled`,`running`,`failed`].includes(l.state))return;if(l.state===`completed`){s&&!E.current&&(E.current=!0,X(`prepare`));return}E.current=!0;let e,t=``;if(l.state===`pending`?(e=`prepare`,t=`prepare:${c}:${l.revision}`):v?.state===`connected`&&(e=`prepare`,t=`auth:${c}:${v.id}`),e&&!O.current.has(t)){O.current.add(t),X(e);return}l.resources===`ready`&&!l.missingConfig?.length&&!l.partial&&l.connections.every(e=>e.state===`connected`)&&(l.authorizations??[]).every(e=>e.state===`connected`)&&(t=`complete:${c}:${l.revision}`,O.current.has(t)||(O.current.add(t),X(`complete`)))},[l,v,J,h,c,s]),(0,P.useEffect)(()=>{J||!l||l.state===`cancelled`||(Y&&l.revision!==k.current&&B(Y)?(C(null),y(null),x(``)):(!U||a)&&l.resources===`ready`&&(!l.missingConfig?.length||a&&!l.missingConfig.some(e=>e in K))&&!S&&H[0]&&!oe.current.has(H[0].id)&&(oe.current.add(H[0].id),k.current=l.revision,C(H[0].id)))},[l,J,U,S,a]);function Z(e,t){let n=e.methods.find(e=>e.id===t),r=n?.type===`oauth`||n?.type===`cli`?window.open(`about:blank`,`_blank`):null;r&&(r.opener=null),A.current=r,y(null),X(`authorize`,{server:e.id,...N.some(t=>t.id===e.id)?{method:t}:{}}).then(t=>{t?x(e.id):(r?.close(),A.current=null)})}async function le(t,n,r){if(n===`api-key`&&!N.some(e=>e.id===t.id)){m(!0),g(``);try{let n=e.components?.mcp.find(e=>e.name===t.id);await z(`${c}/mcp/${encodeURIComponent(t.id)}/auth`,`PUT`,{mode:`api-key`,secrets:[{target:n.type===`stdio`?`env`:`headers`,key:n.connectionAuth?.headerName??(n.type===`stdio`?`API_KEY`:`Authorization`),prefix:n.connectionAuth?.prefix??(n.type===`stdio`?``:`Bearer `),value:r.__apiKey}]});let i=await z(`${c}/setup`);u(i),m(!1),await X(`prepare`,{},i.revision);return}catch(e){g(String(e)),m(!1);return}m(!1)}else if(t.methods.find(e=>e.id===n)?.type===`cli`){let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null),A.current=e,y(null);let i=await X(`configure`,{authorization:t.id,method:n,values:r},l?.revision);i&&await X(`authorize`,{server:t.id,method:n},i.revision)?x(t.id):(e?.close(),A.current=null)}else await X(`configure`,{authorization:t.id,method:n,values:r})}if(l===void 0)return(0,j.jsx)(ae,{className:`h-40 w-full`});let Q=()=>{X(`defer`)};return Y?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsx)(I,{initialMethod:l?.authorizations?.find(e=>e.id===Y.id)?.method,account:Y,fields:{...W,__apiKey:{type:`string`,title:M(`访问令牌`,`Access token`),required:!0,sensitive:!0}},zh:t,busy:J,attempt:v,onBack:()=>C(null),onConnect:e=>Z(Y,e),onSave:(e,t)=>void le(Y,e,t),onRedirect:e=>{m(!0),z(`${c}/setup/auth/${encodeURIComponent(b)}/redirect`,`POST`,{url:e}).catch(e=>g(String(e))).finally(()=>m(!1))},onSkip:Q},`${Y.id}:${l?.authorizations?.find(e=>e.id===Y.id)?.method??``}`),ee[Y.id]?.map(e=>(0,j.jsxs)(D,{disabled:J,variant:`secondary`,onClick:()=>void X(`reuse`,{server:Y.id,sourceServerId:e.id}),children:[M(`使用已登录账号:`,`Use signed-in account: `),e.name]},e.id)),h||q&&Y.servers.some(e=>l?.connections.find(t=>t.name===e)?.state===`error`)?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:h||q}):null]}):(0,j.jsxs)(`section`,{className:`space-y-5`,"aria-label":M(`插件安装与授权`,`Plugin setup`),children:[U?(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`font-medium`,children:M(`安装完成`,`Installation complete`)}),(0,j.jsx)(`p`,{role:`status`,className:`mt-1 text-sm text-fg-muted`,children:e.activationEligible===!1?M(`插件已停用。`,`Plugin is disabled.`):l?.partial||H.length||V.length||l?.missingConfig?.length?M(`插件已安装,部分功能仍需要授权。`,`Plugin installed. Some features still need authorization.`):M(`所有 Agent 均可使用。可在 Agent 设置中单独调整。`,`Available to all agents. Customize individual agents in Agent settings.`)})]}):(0,j.jsxs)(`div`,{className:`rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`h3`,{className:`font-medium`,children:M(`安装准备`,`Installation setup`)}),(0,j.jsx)(`ol`,{className:`mt-4 space-y-4 text-sm`,"aria-live":`polite`,children:[{name:M(`准备资源`,`Prepare resources`),done:l?.resources===`ready`,running:J&&l?.resources!==`ready`},{name:M(`授权账号`,`Authorize accounts`),done:l?.resources===`ready`&&!l?.missingConfig?.length&&H.length===0,running:!1},{name:M(`加载可用工具`,`Load available tools`),done:!1,running:J&&l?.resources===`ready`}].map(e=>(0,j.jsxs)(`li`,{className:`flex items-center gap-3`,children:[e.done?(0,j.jsx)(ne,{className:`size-5 text-accent`,"aria-hidden":!0}):e.running?(0,j.jsx)(ie,{className:`size-5 animate-spin text-accent`,"aria-hidden":!0}):(0,j.jsx)(re,{className:`size-5 text-fg-muted`,"aria-hidden":!0}),e.name]},e.name))}),(0,j.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:M(`安装后所有 Agent 均可使用,可在各自的设置中调整。`,`Available to all agents after installation. Customize individual agents in Agent settings.`)})]}),!l||l.state===`cancelled`?(0,j.jsx)(D,{disabled:p||e.readiness===`blocked`,onClick:()=>void X(`start`),children:M(`继续安装`,`Continue installation`)}):(0,j.jsxs)(j.Fragment,{children:[l.missingConfig?.length||w?(0,j.jsxs)(`form`,{className:`space-y-4 rounded-xl border border-edge p-4`,onSubmit:e=>{e.preventDefault(),X(`configure`,{values:d})},children:[(0,j.jsx)(`h4`,{className:`font-medium`,children:M(`补充配置`,`Required configuration`)}),(0,j.jsx)(F,{fields:w?K:ce,values:d,onChange:f}),(0,j.jsx)(D,{type:`submit`,disabled:J||!Object.keys(d).length,children:M(`继续`,`Continue`)})]}):null,U&&(H.length||l.missingConfig?.length)?(0,j.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,j.jsx)(te,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`font-medium`,children:M(`需要授权`,`Authorization required`)}),(0,j.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:M(`授权后即可使用相关功能。已就绪的功能可继续使用。`,`Connect these accounts to use their features. Ready features remain available.`)})]})]}):null,V.length?(0,j.jsx)(`div`,{className:`space-y-3`,"aria-label":M(`需要补充权限`,`Additional permissions required`),children:V.map(e=>(0,j.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,j.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,j.jsx)(`p`,{className:`text-fg-muted`,children:M(`账号已连接,以下权限尚未就绪;其他已授权功能可继续使用。`,`Account connected. These permissions are not ready; other authorized features remain available.`)}),e.scopes.length?(0,j.jsx)(`p`,{className:`break-all font-mono text-xs`,children:e.scopes.join(`, `)}):null,(0,j.jsx)(`ol`,{className:`list-inside list-decimal space-y-1 text-fg-muted`,children:e.instructions.map(e=>(0,j.jsx)(`li`,{children:e},e))}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.helpUrl?(0,j.jsx)(D,{variant:`secondary`,asChild:!0,children:(0,j.jsx)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:M(`前往开通应用权限`,`Open application permissions`)})}):null,e.method&&e.account?(0,j.jsx)(D,{disabled:J,onClick:()=>{k.current=l.revision,C(e.account.id),Z(e.account,e.method)},children:M(`补充授权`,`Grant missing permissions`)}):null,(0,j.jsx)(D,{variant:`secondary`,disabled:J,onClick:()=>void X(`prepare`),children:M(`重新检查权限`,`Check permissions again`)})]})]},`${e.account?.id}:${e.id}`))}):null,R.length?(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(`h4`,{className:`text-sm font-medium`,children:M(`账号与连接`,`Accounts and connections`)}),R.map(e=>(0,j.jsxs)(`div`,{role:`group`,"aria-label":e.title,className:`flex items-center justify-between gap-3 rounded-lg border border-edge p-3`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{className:`text-sm font-medium`,children:e.title}),(0,j.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:B(e)?M(`已连接`,`Connected`):M(`需要授权`,`Authorization required`)})]}),(0,j.jsx)(D,{variant:B(e)?`secondary`:`primary`,disabled:J||l.resources!==`ready`,onClick:()=>{y(null),x(``),k.current=l.revision,C(e.id)},children:B(e)?M(`重新授权`,`Reconnect`):M(`连接账号`,`Connect account`)})]},e.id))]}):null,!U&&l.resources===`ready`?(0,j.jsxs)(`div`,{children:[(0,j.jsx)(D,{variant:`secondary`,disabled:J,onClick:Q,children:M(`暂时跳过`,`Skip for now`)}),(0,j.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:M(`先完成安装,稍后在详情页授权。未授权的功能暂不可用。`,`Finish installation and connect later in plugin details. Unauthenticated features remain unavailable.`)})]}):null,U&&Object.keys(K).length&&!w?(0,j.jsx)(D,{variant:`ghost`,disabled:J,onClick:()=>T(!0),children:M(`修改插件配置`,`Edit plugin configuration`)}):null,U&&!V.length&&N.some(e=>e.methods.some(e=>e.type===`cli`))?(0,j.jsx)(D,{variant:`secondary`,disabled:J,onClick:()=>void X(`prepare`),children:M(`检查连接与权限`,`Check connection and permissions`)}):null,!J&&(h||[`failed`,`interrupted`].includes(l.state)||l.connections.some(e=>e.state===`error`))?(0,j.jsx)(D,{variant:`secondary`,onClick:()=>void X(`prepare`),children:M(`重试检查`,`Retry checks`)}):null,U?null:(0,j.jsx)(D,{variant:`ghost`,disabled:p,onClick:()=>void X(`cancel`),children:M(`取消安装`,`Cancel installation`)}),!s&&U&&!H.length&&!l.missingConfig?.length?e.setup?.tasks?.map(t=>(0,j.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-inset p-4 text-sm`,children:[(0,j.jsx)(`p`,{children:t}),(0,j.jsx)(D,{asChild:!0,disabled:!e.active,children:(0,j.jsx)(o,{to:`/chat/new?${new URLSearchParams({draft:t,projectScope:`none`})}`,state:{forceNewChat:!0},onClick:t=>{e.active?r?.():t.preventDefault()},children:M(`开始这个任务`,`Start this task`)})})]},t)):null]}),J?(0,j.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:M(`正在准备,可关闭后继续。`,`Preparing. You can close this window and resume.`)}):null,l?.error&&!l.deferred&&!l.missingConfig?.length?(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q}):null,h?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:h}):null]})}var V=t({AgentPluginDialog:()=>K}),H=`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;function U(e,t){if(e.startsWith(`content.skills:`)){let n=e.slice(15);return t?`提供技能:${n}`:`Add skill: ${n}`}if(e.startsWith(`runtime.mcp.stdio:`)){let n=e.slice(18).split(`:`,1)[0];return t?`在 Gateway 上运行工具服务:${n}`:`Run a tool service on the Gateway: ${n}`}if(e.startsWith(`network.mcp:`)){let n=e.slice(12).split(`:`,1)[0];return t?`连接外部工具服务:${n}`:`Connect to an external tool service: ${n}`}return e.startsWith(`runtime.capability-access:`)?t?`按账号授权启用相关技能和工具`:`Enable skills and tools according to account authorization`:e.startsWith(`runtime.authorization:`)?t?`在本机运行账号登录程序:${e.split(`:`)[1]}`:`Run account sign-in locally: ${e.split(`:`)[1]}`:e.startsWith(`runtime.resource:`)?t?`下载可执行资源:${e.split(`:`)[1]}`:`Download executable resource: ${e.split(`:`)[1]}`:e.startsWith(`network.resource:`)?t?`下载并校验资源:${e.split(`:`)[1]}`:`Download and verify resource: ${e.split(`:`)[1]}`:e}function W(e,t){return t?.publisher?.verification!==`verified`||t.latestVersion.riskTier&&t.latestVersion.riskTier!==`content`?!0:e.addedCapabilities.some(e=>!e.startsWith(`content.skills:`))}async function G(e,t,n){let r=await u(c(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function K({extension:e,onClose:t,onUninstalled:n,initialSource:r=``,marketplace:i,autoInstall:o=!1,connectionFlow:c=!1}){let u=l(e=>e.language),_=u.startsWith(`zh`),te=i?.localizations?.[_?`zh-CN`:`en`],re=te?.displayName??i?.name,ae=te?.description??i?.description,oe=(0,P.useId)(),{mutate:A}=E(),[M,N]=(0,P.useState)(e),[F,I]=(0,P.useState)(r||e?.installationSource||``),[L,R]=(0,P.useState)(null),[z,V]=(0,P.useState)([]),[K,q]=(0,P.useState)(!1),[ce,J]=(0,P.useState)(``),[Y,X]=(0,P.useState)(!1),[Z,le]=(0,P.useState)(!1),[Q,ue]=(0,P.useState)(!1),[de,fe]=(0,P.useState)(!1),[pe,me]=(0,P.useState)(!1),[he,ge]=(0,P.useState)(!1),_e=s(),ve=a(),[ye,be]=(0,P.useState)(!1),xe=(0,P.useRef)(!1),Se=`/api/extensions/agent-plugins/${encodeURIComponent(M?.pluginId??``)}`,Ce=F.trim().startsWith(`store:`),we=()=>A(`gateway-extensions-list`);async function $(e){q(!0),J(``);try{await e()}catch(e){J(e instanceof Error?e.message:String(e))}finally{q(!1)}}function Te(e){I(e),R(null),V([]),J(``)}let Ee=typeof window<`u`?window.electronAPI?.file:void 0,De=/^(?:\/|[A-Za-z]:[\\/])/.test(F.trim())?F.trim():void 0;async function Oe(){if(!Ee?.openDirectory){me(!0);return}let e=await Ee.openDirectory(De?{defaultPath:De}:void 0);e&&Te(e)}async function ke(){if(!Ee?.openFile){me(!0);return}let e=await Ee.openFile({...De?{defaultPath:De}:{},extensions:[`zip`]});e&&Te(e)}function Ae(e){return[...e.dataTransfer.types].some(e=>e===`Files`||e===`text/plain`||e===`text/uri-list`)}function je(e){if(!Ae(e))return;e.preventDefault(),fe(!1);let t=Array.from(e.dataTransfer.files);if(t.length){if(t.length>1){J(_?`一次只能选择一个插件目录或 ZIP。`:`Choose one plugin directory or ZIP at a time.`);return}let e=Ee?.getPathForFile?.(t[0]);e?Te(e):J(_?`浏览器无法读取本机文件路径,请使用“选择文件或目录”选择安装包。`:`The browser cannot read local file paths. Use Choose file or folder to select the package.`);return}let n=e.dataTransfer.getData(`text/uri-list`)||e.dataTransfer.getData(`text/plain`);n.trim()&&Te(n.trim().split(/\r?\n/)[0])}async function Me(e){let t=await G(`${Se}/activation`,`POST`,{enabled:e});N(t),await we()}async function Ne(e){let t=!M,n=await G(t?`/api/extensions/install`:`${Se}/update`,`POST`,{source:F,reviewHash:e.reviewHash,...e.layout?{setup:!0}:{}});N(n),await we(),!e.layout&&t&&!n.activationEligible&&n.readiness!==`blocked`&&n.pluginId&&(n=await G(`/api/extensions/agent-plugins/${encodeURIComponent(n.pluginId)}/activation`,`POST`,{enabled:!0}),N(n),await we()),R(null),be(!e.layout&&t&&n.activationEligible===!0)}async function Pe(){let e=await G(`/api/extensions/inspect`,`POST`,{source:F});if(W(e,i)){R(e);return}await Ne(e)}(0,P.useEffect)(()=>{e&&!e.setup&&N(e)},[e]),(0,P.useEffect)(()=>{if(!e?.setup||!e.pluginId)return;let t=!1;return G(`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,`GET`).then(e=>{t||N(e)}).catch(()=>{}),()=>{t=!0}},[e?.pluginId]),(0,P.useEffect)(()=>{!o||M||!Ce||xe.current||(xe.current=!0,$(Pe))},[o,M,Ce]);let Fe=o&&!M&&Ce&&!xe.current;return(0,j.jsx)(ee,{defaultOpen:!0,onOpenChange:e=>!e&&t(),children:(0,j.jsxs)(m,{children:[(0,j.jsx)(f,{className:`fixed inset-0 z-[130] bg-scrim`}),(0,j.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(38rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,j.jsx)(k,{iconUrl:M?.branding?.iconUrl??i?.branding?.iconUrl,fallback:S}),(0,j.jsx)(g,{className:`font-semibold`,children:M?.name??re??(_?`安装插件`:`Install plugin`)})]}),(0,j.jsx)(D,{variant:`ghost`,onClick:t,children:_?`关闭`:`Close`})]}),(0,j.jsx)(p,{className:`sr-only`,children:_?`安装、组件、账号连接和权限`:`Installation, components, connections and permissions`}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-auto space-y-4 overflow-y-auto overscroll-contain p-4`,children:[!M&&Ce?(0,j.jsxs)(`section`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,j.jsx)(C,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{className:`font-medium text-fg`,children:re??L?.manifest.name??F.slice(6)}),ae?(0,j.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ae}):null,(0,j.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i?.publisher?.verification===`verified`?_?`已认证发布者 · 安装后所有智能体均可使用`:`Verified publisher · available to all agents after installation`:_?`安装前会检查来源和所需权限`:`Source and required permissions are checked before installation`})]})]}),i?(0,j.jsx)(se,{data:i,zh:_}):null,L?null:(0,j.jsxs)(D,{className:`w-full`,disabled:K||Fe,onClick:()=>void $(Pe),children:[K||Fe?(0,j.jsx)(ie,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,K||Fe?_?`正在安全检查并安装…`:`Checking and installing…`:_?`一键安装`:`Install`]})]}):null,M?(0,j.jsxs)(j.Fragment,{children:[ye?(0,j.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-4`,children:[(0,j.jsx)(ne,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`font-medium text-fg`,children:_?`插件已安装并启用`:`Plugin installed and enabled`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?`请继续检查账号连接、依赖与可用状态,再在对话中试用。`:`It is ready to use in your conversations.`})]})]}):null,(!M.setup||M.readiness!==`setup_required`)&&!M.activationEligible?(0,j.jsxs)(`div`,{role:`status`,className:`space-y-3 rounded-lg border border-accent/25 bg-accent-soft p-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`font-medium text-accent-fg`,children:_?`插件已安装,当前尚未启用`:`Plugin installed. It is not enabled yet.`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_?`启用后,Skills 和 MCP 才会加入 Agent 运行时。`:`Enable it to make its skills and MCP servers available to the Agent runtime.`})]}),(0,j.jsx)(D,{disabled:K||M.readiness===`blocked`,onClick:()=>void $(()=>Me(!0)),children:_?`启用插件`:`Enable plugin`})]}):null,M.setup?(0,j.jsx)(B,{extension:M,zh:_,onStart:t,initialConnect:c,connectionFlow:c,onInstalled:()=>{t(),c||_e(O(M.pluginId,`installed`,!1,ve.pathname+ve.search))},onChanged:async()=>{let e=await G(`${Se}`,`GET`);N(e),await we()}}):null,(0,j.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:_?`插件详情`:`Plugin details`}),(0,j.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,j.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[_?`插件`:`Plugin`,` · `,M.version,` · `,M.readiness&&{ready:_?`已就绪`:`Ready`,setup_required:_?`待连接`:`Setup required`,degraded:_?`部分不可用`:`Partially available`,blocked:_?`已阻止`:`Blocked`}[M.readiness]]}),M.provenance?(0,j.jsxs)(`p`,{className:`break-words text-xs text-fg-muted`,children:[M.provenance.publisherVerification===`verified`?_?`已认证发布者`:`Verified publisher`:_?`社区发布者`:`Community publisher`,` · `,M.provenance.packageName,`@`,M.provenance.version,` · SHA-256 `,M.provenance.sha256.slice(0,12),`…`,M.provenance.riskTier?` · ${M.provenance.riskTier}`:``]}):null,(0,j.jsx)(`p`,{className:`text-sm`,children:M.description}),M.installationSource?(0,j.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[_?`来源:`:`Source: `,M.installationSource,M.resolvedCommit?` · ${M.resolvedCommit.slice(0,12)}`:``]}):null,M.activationEligible?(0,j.jsx)(D,{disabled:K,variant:`secondary`,onClick:()=>void $(()=>Me(!1)),children:_?`停用`:`Disable`}):null,M.canRollback?(0,j.jsx)(D,{disabled:K,variant:`secondary`,onClick:()=>void $(async()=>{N(await G(`${Se}/rollback`,`POST`)),await we()}),children:_?`回滚上一版本`:`Roll back`}):null]})]}),M.diagnostics?.map((e,t)=>(0,j.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.component,`: `,e.message]},t))]}):null,M?(0,j.jsxs)(D,{variant:`ghost`,className:`px-0`,"aria-expanded":he,onClick:()=>ge(e=>!e),children:[(0,j.jsx)(v,{className:T(`size-4 transition-transform motion-reduce:transition-none`,he&&`rotate-180`),"aria-hidden":!0}),_?`高级操作`:`Advanced actions`]}):null,!M&&!Ce||he?(0,j.jsxs)(`form`,{className:T(`space-y-3`,M&&`border-t border-edge pt-4`),onSubmit:e=>{e.preventDefault(),$(async()=>{let e=await G(`/api/extensions/inspect`,`POST`,{source:F});e.candidates?(V(e.candidates),R(null)):(V([]),R(e))})},children:[(0,j.jsxs)(`div`,{"data-testid":`plugin-source-dropzone`,className:T(`rounded-xl border border-dashed p-3 transition-colors`,de?`border-accent bg-accent-soft`:`border-edge bg-surface-inset/40`),onDragEnter:e=>{Ae(e)&&(e.preventDefault(),fe(!0))},onDragOver:e=>{Ae(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,fe(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||fe(!1)},onDrop:je,children:[(0,j.jsxs)(`div`,{className:`mb-2 flex items-start gap-2`,children:[(0,j.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:oe,className:`block text-sm font-medium`,children:M?_?`更新包来源`:`Update package source`:_?`安装包来源`:`Package source`}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:_?`输入 github:组织/仓库、Git / ZIP 地址或宿主目录;marketplace 可选择插件。`:`Enter github:owner/repo, a Git / ZIP URL or a Gateway directory. Marketplaces let you choose a plugin.`})]})]}),(0,j.jsx)(`input`,{id:oe,className:H,value:F,onChange:e=>Te(e.target.value),placeholder:_?`/插件目录/或/插件.zip`:`/plugin/folder/or/plugin.zip`,autoComplete:`off`,spellCheck:!1,required:!0}),(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Ee?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(D,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>void $(Oe),children:[(0,j.jsx)(x,{className:`size-4`,"aria-hidden":!0}),_?`选择目录`:`Choose directory`]}),(0,j.jsxs)(D,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>void $(ke),children:[(0,j.jsx)(b,{className:`size-4`,"aria-hidden":!0}),_?`选择 ZIP`:`Choose ZIP`]})]}):(0,j.jsxs)(D,{type:`button`,variant:`secondary`,disabled:K,onClick:()=>me(!0),children:[(0,j.jsx)(x,{className:`size-4`,"aria-hidden":!0}),_?`选择文件或目录`:`Choose file or folder`]})})]}),(0,j.jsx)(D,{type:`submit`,variant:`secondary`,disabled:K||!F,children:_?`检查安装包`:`Inspect package`})]}):null,z.length?(0,j.jsx)(`div`,{className:`space-y-2`,"aria-label":_?`选择插件`:`Choose a plugin`,children:z.map(e=>(0,j.jsx)(D,{variant:`secondary`,className:`w-full justify-start`,onClick:()=>{Te(e.source),$(async()=>R(await G(`/api/extensions/inspect`,`POST`,{source:e.source})))},children:e.name},e.source))}):null,L?(0,j.jsxs)(`div`,{role:`region`,"aria-labelledby":`plugin-authorization-title`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(C,{className:`mt-0.5 size-5 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{id:`plugin-authorization-title`,className:`font-medium text-fg`,children:_?`需要你的授权`:`Your authorization is required`}),(0,j.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:_?`此插件需要以下新增能力。确认后自动准备资源,按需登录账号,所有智能体均可使用。`:`Review these capabilities. Resources are prepared automatically; sign in if needed. Available to all agents.`})]})]}),(0,j.jsx)(`ul`,{tabIndex:0,"aria-label":_?`插件新增能力`:`Added plugin capabilities`,className:`max-h-[min(28vh,14rem)] space-y-2 overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-panel p-3 break-words focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:L.addedCapabilities.map(e=>(0,j.jsxs)(`li`,{className:`flex gap-2`,children:[(0,j.jsx)(`span`,{"aria-hidden":!0,children:`•`}),(0,j.jsx)(`span`,{children:U(e,_)})]},e))}),L.diagnostics.map((e,t)=>(0,j.jsxs)(`p`,{children:[e.component,`: `,e.message]},t))]}):null,M&&he?(0,j.jsx)(`div`,{className:`border-t border-edge pt-4`,children:Q?(0,j.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,j.jsx)(`p`,{children:_?`卸载保留账号凭据;服务端授权需到相应服务撤销。`:`Credentials are retained. Revoke provider authorization in the service itself.`}),(0,j.jsxs)(`label`,{className:`flex gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>X(e.target.checked)}),_?`同时删除插件数据`:`Also delete plugin data`]}),(0,j.jsxs)(`label`,{className:`flex gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:Z,onChange:e=>le(e.target.checked)}),_?`同时删除本地凭据`:`Also delete local credentials`]}),(0,j.jsx)(D,{disabled:K,onClick:()=>void $(async()=>{await G(Se,`DELETE`,{removeData:Y,removeCredentials:Z}),await we(),(n??t)()}),children:_?`确认卸载`:`Confirm uninstall`})]}):(0,j.jsx)(D,{variant:`ghost`,disabled:K,onClick:()=>ue(!0),children:_?`卸载插件`:`Uninstall`})}):null,ce?(0,j.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:ce}):null]}),L?(0,j.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,j.jsx)(D,{variant:`ghost`,disabled:K,onClick:()=>R(null),children:_?`取消`:`Cancel`}),(0,j.jsxs)(D,{disabled:K||!!M&&L.manifest.name!==M.name,onClick:()=>void $(()=>Ne(L)),children:[K?(0,j.jsx)(ie,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,_?`授权并安装`:`Authorize and install`]})]}):null]}),Ee?null:(0,j.jsx)(y,{open:pe,onOpenChange:me,initialAbsolutePath:De,onConfirm:async e=>Te(e),wd:d(u).chat.workingDirectory,selectKind:`file-or-directory`,fileExtensions:[`zip`],title:_?`选择插件安装包`:`Choose plugin package`,description:_?`选择插件目录或 ZIP 文件。`:`Choose a plugin directory or ZIP file.`,confirmLabel:_?`使用此来源`:`Use this source`,nested:!0})]})})}export{se as i,V as n,B as r,K as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,m as a,t as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{l as c,n as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{a as d,i as f,o as p,r as m,s as h,t as g}from"./dist-CY7CS_D3.js";import{t as _}from"./arrow-left-D880xG-P.js";import{t as v}from"./box-DvYoGszj.js";import{n as y,t as b}from"./extension-paths-DvuaZJuy.js";import{t as x}from"./ellipsis-0k4rZLoy.js";import{t as S}from"./external-link-DjqjBmc3.js";import{t as C}from"./loader-circle-CifKLtgG.js";import{t as w}from"./markdown-view-CNJaAdNN.js";import{t as T}from"./package-wATCyihJ.js";import{t as E}from"./plus-Q2yW6OE7.js";import{t as D}from"./settings-uiTATseT.js";import{t as O}from"./shield-check-BU58siTV.js";import{t as k}from"./trash-2-DusmjVPV.js";import{t as A}from"./triangle-alert-2JXFNNKU.js";import{t as j}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-DzdOeGYz.js";import{a as P,i as F}from"./vendor-swr-CdRzEUwF.js";import{o as I}from"./gateway-realtime-DIs1pjkQ.js";import{t as L}from"./button-Cc4hUNTt.js";import{n as R}from"./interaction-BdhHBbYa.js";import{t as z}from"./page-tabs-oeTY7z3_.js";import{t as B}from"./page-header-store-Bm8oxpFR.js";import{i as V,o as H,r as U,s as W}from"./extension-provider-D-LolObs.js";import{r as G}from"./settings-form-draft-Dy10ldo8.js";import{l as K,m as ee,o as te,r as q,t as ne}from"./dist-ZrL34Ps4.js";import{r as re,t as ie}from"./agent-plugin-dialog-CikzCYAG.js";import{n as J,t as Y}from"./capability-links-MZdYfPKx.js";import{t as X}from"./capability-icon-CmvCZOJX.js";import{a as Z,i as ae,n as oe,r as se,t as ce}from"./extension-marketplace-api-BIzkukYp.js";import{n as le,t as ue}from"./capability-header-actions-BxMYfQ8y.js";import{n as de,r as fe,t as pe}from"./plugin-presentation-CO5BFDGW.js";var me=n(),he=`grid auto-rows-fr grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-stretch gap-4`,ge=`relative h-full min-w-0 rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:border-edge-strong hover:bg-surface-hover/30`,_e=`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,Q=e(t(),1);function ve(e){return e===`builtin`||e===`user`?e:`marketplace`}var $=r();function ye(e,t){let n=e.find(e=>e.id===t||e.pluginId===t||e.provenance?.packageName===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var be={debounced:``,detailPkg:null,quickInstallPkg:null,rowBusy:null,actionError:null,restartHint:null};function xe({className:e,query:t}){let n=s(),r=i(),a=l(e=>e.language),o=u(a).extensionsPage,d=c(e=>!!e.conversationId),f=U(),{mutate:p}=P(),[m,h]=(0,Q.useReducer)(G,be),{debounced:g,detailPkg:_,quickInstallPkg:v,rowBusy:b,actionError:x,restartHint:S}=m,w=d?`marketplace-${g}`:null;(0,Q.useEffect)(()=>{let e=window.setTimeout(()=>h({type:`patch`,patch:{debounced:t.trim()}}),300);return()=>window.clearTimeout(e)},[t]);let{data:E,isLoading:D,error:O}=F(w,()=>ce(g),{revalidateOnFocus:!1}),A=(0,Q.useCallback)(()=>{p(`gateway-extensions-list`),I()},[p]),j=(0,Q.useCallback)(async(e,t)=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await se({name:e,overwrite:t});A(),n.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:o.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:o.marketplaceInstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[o.marketplaceInstallFailed,o.marketplaceRestartHint,A]),L=(0,Q.useCallback)(async e=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let t=await Z(e);A(),t.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:o.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:o.marketplaceUninstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[o.marketplaceRestartHint,o.marketplaceUninstallFailed,A]),R=E??[];return(0,$.jsxs)(`div`,{className:M(`flex flex-col gap-4`,e),children:[O?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:O instanceof Error?O.message:o.marketplaceLoadFailed}):null,x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null,S?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:S}):null,D&&!E?(0,$.jsx)(`ul`,{className:he,"aria-label":o.marketplaceLoading,children:[0,1,2,3,4,5].map(e=>(0,$.jsxs)(`li`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(N,{className:`size-10 shrink-0 rounded-xl`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(N,{className:`h-5 w-full`}),(0,$.jsx)(N,{className:`h-3 w-2/3`})]}),(0,$.jsx)(N,{className:`h-9 w-16 shrink-0 rounded-lg`})]}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(N,{className:`h-4 w-full`}),(0,$.jsx)(N,{className:`h-4 w-full`}),(0,$.jsx)(N,{className:`h-4 w-2/3`})]})]},e))}):(0,$.jsx)(`ul`,{className:he,children:R.length===0?(0,$.jsx)(`li`,{className:`col-span-full text-sm text-fg-muted`,children:o.marketplaceEmpty}):R.map(e=>{let t=ye(f,e.id),i=b===e.id,s=f.find(t=>t.pluginId===e.id||t.provenance?.packageName===e.id),c=e.localizations?.[a.startsWith(`zh`)?`zh-CN`:`en`],l=c?.displayName??e.name,u=c?.description??e.description;return(0,$.jsxs)(`li`,{className:ge,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${l}, ${o.marketplaceDetailTitle}`,onClick:()=>s?.pluginId?n(Y(s.pluginId,`installed`,!1,r.pathname+r.search)):h({type:`patch`,patch:{detailPkg:e.id}}),className:_e}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-3`,children:[(0,$.jsx)(X,{iconUrl:e.branding?.iconUrl,fallback:T}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,$.jsx)(`h3`,{className:`line-clamp-2 break-words font-semibold leading-snug text-fg`,title:l,children:l}),e.verified?(0,$.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[e.version?(0,$.jsxs)(`span`,{children:[`v`,e.version]}):null,t===`user`?(0,$.jsx)(`span`,{className:s&&fe(s)?`text-amber-700 dark:text-amber-400`:`text-fg-muted`,children:s&&fe(s)?a.startsWith(`zh`)?`需要授权`:`Authorization required`:o.marketplaceInstalled}):null]})]}),(0,$.jsx)(`div`,{role:`group`,className:`pointer-events-auto relative z-10 flex max-w-[45%] shrink-0 items-start`,children:t===`bundled`?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:o.marketplaceBuiltin}):t===`user`?(0,$.jsx)($.Fragment,{children:e.packageType===`plugin`?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s?.pluginId&&pe(s)?n(J(l,a.startsWith(`zh`),s.pluginId)):s?.pluginId?n(Y(s.pluginId,`installed`,fe(s),r.pathname+r.search)):h({type:`patch`,patch:{detailPkg:e.id,quickInstallPkg:null}}),className:M(`inline-flex items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:s&&fe(s)?a.startsWith(`zh`)?`去授权`:`Connect account`:s&&pe(s)?a.startsWith(`zh`)?`开始使用`:`Start using`:a.startsWith(`zh`)?`管理插件`:`Manage plugin`}):(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(o.marketplaceUninstallConfirm)&&L(e.id).catch(()=>{})},className:M(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,$.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(k,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),o.marketplaceUninstall]})}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>h({type:`patch`,patch:(e.packageType,{detailPkg:e.id,quickInstallPkg:null})}),className:M(`inline-flex min-w-16 items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:e.packageType===`plugin`?a.startsWith(`zh`)?`安装`:`Install`:o.marketplaceReview})})]}),u?(0,$.jsx)(`p`,{className:`pointer-events-none relative mt-3 line-clamp-3 text-sm leading-relaxed text-fg-muted`,children:u}):null,(e.categories?.length??0)>0?(0,$.jsx)(`div`,{className:`pointer-events-none relative mt-3 flex flex-wrap gap-1.5`,children:e.categories?.map(e=>(0,$.jsx)(`span`,{className:`max-w-full truncate rounded-md border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]},e.id)})}),_?(0,$.jsx)(Se,{packageName:_,autoInstall:v===_,copy:o,extensions:f,onClose:()=>h({type:`patch`,patch:{detailPkg:null,quickInstallPkg:null}}),onInstall:j,onUninstall:L}):null]})}function Se(e){let t=(0,me.c)(99),{packageName:n,autoInstall:r,copy:i,extensions:a,onClose:s,onInstall:u,onUninstall:f}=e,[v,y]=(0,Q.useState)(!1),b=l(Oe),[x,S]=(0,Q.useState)(!1),T=c(De)?`ext-mp-detail-${n}`:null,E;t[0]===n?E=t[1]:(E=async()=>oe(n),t[0]=n,t[1]=E);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},t[2]=D):D=t[2];let{data:P,error:I,isLoading:L}=F(T,E,D),R;t[3]!==a||t[4]!==n?(R=ye(a,n),t[3]=a,t[4]=n,t[5]=R):R=t[5];let z=R,B=z===`user`,V=P?.manifest?.permissions,H,U,W,G,K,ee,te,q,ne,J,Y,X;if(t[6]!==r||t[7]!==i||t[8]!==P||t[9]!==I||t[10]!==a||t[11]!==z||t[12]!==L||t[13]!==b||t[14]!==s||t[15]!==n||t[16]!==V||t[17]!==x){ee=Symbol.for(`react.early_return_sentinel`);bb0:{let e=V&&typeof V==`object`&&!Array.isArray(V)?Object.entries(V):[],o;t[30]!==i||t[31]!==P?(o=P?.readme?.trim()||(P?.description?.trim()?`### ${P.name}\n\n${P.description}`:`*${i.marketplaceNoReadme}*`),t[30]=i,t[31]=P,t[32]=o):o=t[32];let c=o;if(P?.format===`agent-plugin`){let e;if(t[33]!==P||t[34]!==a||t[35]!==n){let r;t[37]!==P||t[38]!==n?(r=e=>e.provenance?.packageName===n||e.pluginId===P.manifest?.name,t[37]=P,t[38]=n,t[39]=r):r=t[39],e=a.find(r),t[33]=P,t[34]=a,t[35]=n,t[36]=e}else e=t[36];let i=`store:${n}`,o;t[40]!==r||t[41]!==P||t[42]!==s||t[43]!==e||t[44]!==i?(o=(0,$.jsx)(ie,{extension:e,initialSource:i,marketplace:P,autoInstall:r,onClose:s}),t[40]=r,t[41]=P,t[42]=s,t[43]=e,t[44]=i,t[45]=o):o=t[45],ee=o;break bb0}W=g,G=!0,t[46]===s?K=t[47]:(K=e=>!e&&s(),t[46]=s,t[47]=K),U=p,t[48]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[48]=X):X=t[48],H=m,ne=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,J=Ee;let l;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(_,{className:`size-5`}),t[49]=l):l=t[49];let u;t[50]!==i.detailBack||t[51]!==s?(u=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i.detailBack,children:l}),t[50]=i.detailBack,t[51]=s,t[52]=u):u=t[52];let f;t[53]===i.marketplaceDetailTitle?f=t[54]:(f=(0,$.jsx)(h,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:i.marketplaceDetailTitle}),t[53]=i.marketplaceDetailTitle,t[54]=f);let v;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(j,{className:`size-5`}),t[55]=v):v=t[55];let y;t[56]!==i.detailClose||t[57]!==s?(y=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i.detailClose,children:v}),t[56]=i.detailClose,t[57]=s,t[58]=y):y=t[58],t[59]!==u||t[60]!==f||t[61]!==y?(Y=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[u,f,y]}),t[59]=u,t[60]=f,t[61]=y,t[62]=Y):Y=t[62],te=`min-h-0 flex-1 overflow-y-auto p-5`,q=L&&!P?(0,$.jsxs)(`div`,{className:`space-y-4`,"aria-label":i.marketplaceLoading,children:[(0,$.jsx)(N,{className:`h-6 w-48`}),(0,$.jsx)(N,{className:`h-4 w-28`}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(N,{className:`h-12`}),(0,$.jsx)(N,{className:`h-12`})]}),(0,$.jsx)(N,{className:`h-28 w-full`}),(0,$.jsx)(N,{className:`h-36 w-full`})]}):I?(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,$.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:i.marketplaceDetailLoadFailed}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:I instanceof Error?I.message:i.marketplaceLoadFailed})]}):P?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:P.name}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:P.id})}),(0,$.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceAuthor}),(0,$.jsx)(`dd`,{children:P.author.username})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceVersion}),(0,$.jsx)(`dd`,{children:P.latestVersion.version})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceDownloads}),(0,$.jsx)(`dd`,{children:P.downloads})]})]}),(0,$.jsx)(re,{data:P,zh:b===`zh`}),z===`bundled`?null:(0,$.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[P.installability.available?(0,$.jsx)(O,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,$.jsx)(A,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:P.installability.available?i.marketplaceRiskTitle:i.marketplaceUnavailableTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:P.installability.available?i.marketplaceCodeRisk:P.installability.reason??i.marketplaceUnavailableBody})]})]}),P.installability.available?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceIntegrity}),(0,$.jsx)(`dd`,{children:i.marketplaceIntegrityVerified})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceDependencies}),(0,$.jsx)(`dd`,{children:P.packageSummary?.dependencyCount??0})]})]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.marketplacePermissions}),e.length>0?(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(Te)}):(0,$.jsx)(`p`,{className:`mt-1`,children:i.marketplacePermissionsNone})]}),(P.packageSummary?.lifecycleScripts.length??0)>0?(0,$.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[i.marketplaceLifecycleScripts,`: `,P.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,$.jsx)(`span`,{children:i.marketplaceRiskConfirm})]})]}):null]}),P.readme?.trim()?(0,$.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:i.marketplaceDetailReadmeHeading}):null,(0,$.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,$.jsx)(w,{content:c})})]}):null}t[6]=r,t[7]=i,t[8]=P,t[9]=I,t[10]=a,t[11]=z,t[12]=L,t[13]=b,t[14]=s,t[15]=n,t[16]=V,t[17]=x,t[18]=H,t[19]=U,t[20]=W,t[21]=G,t[22]=K,t[23]=ee,t[24]=te,t[25]=q,t[26]=ne,t[27]=J,t[28]=Y,t[29]=X}else H=t[18],U=t[19],W=t[20],G=t[21],K=t[22],ee=t[23],te=t[24],q=t[25],ne=t[26],J=t[27],Y=t[28],X=t[29];if(ee!==Symbol.for(`react.early_return_sentinel`))return ee;let Z;t[63]!==te||t[64]!==q?(Z=(0,$.jsx)(`div`,{className:te,children:q}),t[63]=te,t[64]=q,t[65]=Z):Z=t[65];let ae;t[66]!==v||t[67]!==i.marketplaceBuiltinGoBuiltin||t[68]!==i.marketplaceBuiltinManageHint||t[69]!==i.marketplaceInstall||t[70]!==i.marketplaceReinstall||t[71]!==i.marketplaceReinstallConfirm||t[72]!==i.marketplaceUninstall||t[73]!==i.marketplaceUninstallConfirm||t[74]!==P||t[75]!==z||t[76]!==s||t[77]!==u||t[78]!==f||t[79]!==n||t[80]!==x||t[81]!==B?(ae=P?(0,$.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:z===`bundled`?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:i.marketplaceBuiltinManageHint}),(0,$.jsx)(o,{to:`/capabilities/extensions?tab=builtin`,onClick:s,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:i.marketplaceBuiltinGoBuiltin})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:v||!P.installability.available||!x,onClick:()=>{B&&!window.confirm(i.marketplaceReinstallConfirm)||(y(!0),u(n,B).catch(we).finally(()=>y(!1)))},className:M(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-on-accent shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[v?(0,$.jsx)(C,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,B?i.marketplaceReinstall:i.marketplaceInstall]}),B?(0,$.jsxs)(`button`,{type:`button`,disabled:v,onClick:()=>{window.confirm(i.marketplaceUninstallConfirm)&&(y(!0),f(n).then(()=>s()).catch(Ce).finally(()=>y(!1)))},className:M(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,$.jsx)(k,{className:`size-4 shrink-0`,"aria-hidden":!0}),i.marketplaceUninstall]}):null]})}):null,t[66]=v,t[67]=i.marketplaceBuiltinGoBuiltin,t[68]=i.marketplaceBuiltinManageHint,t[69]=i.marketplaceInstall,t[70]=i.marketplaceReinstall,t[71]=i.marketplaceReinstallConfirm,t[72]=i.marketplaceUninstall,t[73]=i.marketplaceUninstallConfirm,t[74]=P,t[75]=z,t[76]=s,t[77]=u,t[78]=f,t[79]=n,t[80]=x,t[81]=B,t[82]=ae):ae=t[82];let se;t[83]!==H||t[84]!==Z||t[85]!==ae||t[86]!==ne||t[87]!==J||t[88]!==Y?(se=(0,$.jsxs)(H,{className:ne,onOpenAutoFocus:J,children:[Y,Z,ae]}),t[83]=H,t[84]=Z,t[85]=ae,t[86]=ne,t[87]=J,t[88]=Y,t[89]=se):se=t[89];let ce;t[90]!==U||t[91]!==se||t[92]!==X?(ce=(0,$.jsxs)(U,{children:[X,se]}),t[90]=U,t[91]=se,t[92]=X,t[93]=ce):ce=t[93];let le;return t[94]!==W||t[95]!==G||t[96]!==K||t[97]!==ce?(le=(0,$.jsx)(W,{defaultOpen:G,onOpenChange:K,children:ce}),t[94]=W,t[95]=G,t[96]=K,t[97]=ce,t[98]=le):le=t[98],le}function Ce(){}function we(){}function Te(e){let[t,n]=e;return(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function Ee(e){return e.preventDefault()}function De(e){return!!e.conversationId}function Oe(e){return e.language}function ke({embedded:e=!1,onHeaderActionChange:t}){let n=s(),r=i(),c=l(e=>e.language),d=u(c),f=B(e=>e.setPageHeader),p=B(e=>e.clearPageHeader),m=U(),h=V(),[g,_]=a(),y=ve(g.get(`tab`)??(m.some(e=>e.source!==`bundled`)?`user`:null)),b=(0,Q.useRef)(!1),S=g.get(`q`)??``,[C,w]=(0,Q.useState)(y),[T,D]=(0,Q.useState)(S),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),N=g.toString(),P=(0,Q.useRef)(N);if(P.current!==N){P.current=N;let e=ve(g.get(`tab`)),t=g.get(`q`)??``;w(t=>t===e?t:e),D(e=>e===t?e:t)}(0,Q.useEffect)(()=>{_(e=>{let t=new URLSearchParams(e),n=T.trim();return n?t.set(`q`,n):t.delete(`q`),C===`marketplace`?t.delete(`tab`):t.set(`tab`,C),t.toString()===e.toString()?e:t},{replace:!0})},[C,T,_]);let F=(0,Q.useMemo)(()=>m.filter(e=>e.source===`bundled`),[m]),I=(0,Q.useMemo)(()=>m.filter(e=>e.source!==`bundled`),[m]);(0,Q.useEffect)(()=>{h||b.current||(b.current=!0,!g.has(`tab`)&&I.length&&w(`user`))},[h,g,I.length]);let H=C===`builtin`?F:I,W=(0,Q.useMemo)(()=>{let e=T.trim().toLowerCase(),t=H;return e&&(t=t.filter(t=>(t.name??``).toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e))),t.toSorted((e,t)=>e.hasUi===t.hasUi?(e.name||e.id).localeCompare(t.name||t.id,c):e.hasUi?-1:1)},[H,T,c]);(0,Q.useEffect)(()=>{k(e=>{if(!e)return e;let t=m.find(t=>t.id===e.id);return t?Ae(e)===Ae(t)&&e.active===t.active&&JSON.stringify(e)===JSON.stringify(t)?e:t:null})},[m]);let G=(0,Q.useMemo)(()=>({searchLabel:C===`marketplace`?d.extensionsPage.marketplaceSearchPlaceholder:d.extensionsPage.searchPlaceholder,search:(0,$.jsx)(le,{value:T,onChange:D,placeholder:C===`marketplace`?d.extensionsPage.marketplaceSearchPlaceholder:d.extensionsPage.searchPlaceholder}),overflow:(0,$.jsxs)(K,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(L,{variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d.capabilitiesHub.moreActions,title:d.capabilitiesHub.moreActions,children:(0,$.jsx)(x,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(te,{children:(0,$.jsxs)(ne,{align:`end`,sideOffset:6,className:`z-50 min-w-48 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(q,{className:M(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,R.transition),onSelect:()=>j(!0),children:[(0,$.jsx)(E,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),c.startsWith(`zh`)?`安装插件`:`Install plugin`]}),(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(o,{to:`/local-apps`,className:M(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,R.transition),children:[(0,$.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),d.extensionsPage.openLocalApps]})})]})})]}),primary:(0,$.jsx)(L,{asChild:!0,variant:`primary`,className:`h-9 shrink-0`,children:(0,$.jsxs)(o,{to:`/local-apps/new`,"aria-label":d.extensionsPage.createLocalApp,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:d.extensionsPage.createLocalApp})]})})}),[c,d.capabilitiesHub.moreActions,d.extensionsPage,C,T]);(0,Q.useLayoutEffect)(()=>e?(t?.(G),()=>t?.(null)):(f({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:d.extensionsPage.title})}),end:(0,$.jsx)(ue,{contribution:G})}),()=>p()),[p,e,G,d.extensionsPage.title,t,f]);let re=[{id:`user`,label:d.extensionsPage.tabUser,count:h?void 0:I.length},{id:`marketplace`,label:d.extensionsPage.tabMarketplace},{id:`builtin`,label:d.extensionsPage.tabBuiltin,count:h?void 0:F.length}];return(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:M(`mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8`,`pb-7 pt-3 lg:pb-9 lg:pt-4`),children:[(0,$.jsx)(`div`,{className:`mb-6 border-b border-edge-subtle pb-3`,children:(0,$.jsx)(z,{items:re,activeTab:C,onChange:w,ariaLabel:d.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`})}),C===`marketplace`?(0,$.jsx)(xe,{query:T}):h?(0,$.jsx)(Le,{}):C===`builtin`&&F.length===0?(0,$.jsx)(ze,{message:d.extensionsPage.emptyBuiltin}):C===`user`&&I.length===0?(0,$.jsx)(ze,{message:d.extensionsPage.emptyUser}):W.length===0?(0,$.jsx)(`p`,{className:`px-3 py-14 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:d.extensionsPage.noSearchResults}):(0,$.jsx)(`div`,{className:he,children:W.map(e=>(0,$.jsx)(Ne,{extension:e,copy:d.extensionsPage,onOpen:()=>e.pluginId?n(Y(e.pluginId,`installed`,!1,r.pathname+r.search)):k(e)},e.id))})]}),O?O.format===`agent-plugin`?(0,$.jsx)(ie,{extension:O,onClose:()=>k(null)},O.id):(0,$.jsx)(Fe,{extension:O,copy:d.extensionsPage,onClose:()=>k(null)},O.id):null,A?(0,$.jsx)(ie,{onClose:()=>j(!1)}):null]})}function Ae(e){return e.activationEligible??e.active}function je(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function Me(e,t){let n=Ae(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function Ne(e){let t=(0,me.c)(56),{extension:n,copy:r,onOpen:a}=e,o=l(Pe),c,u;t[0]!==n||t[1]!==o?(u=o.startsWith(`zh`),c=de(n,u),t[0]=n,t[1]=o,t[2]=c,t[3]=u):(c=t[2],u=t[3]);let d=c,f;t[4]===n?f=t[5]:(f=fe(n),t[4]=n,t[5]=f);let p=f,m=n.localizations?.[u?`zh-CN`:`en`]?.description??n.description,h=s(),g=i(),_;t[6]===n?_=t[7]:(_=!!n.pluginId&&pe(n),t[6]=n,t[7]=_);let b=_,x=p?u?`去授权`:`Connect account`:b?u?`开始使用`:`Start using`:u?`管理插件`:`Manage plugin`,S;t[8]!==b||t[9]!==n.pluginId||t[10]!==g||t[11]!==d||t[12]!==h||t[13]!==p||t[14]!==a||t[15]!==u?(S=()=>{b?h(J(d,u,n.pluginId)):p&&n.pluginId?h(Y(n.pluginId,`installed`,!0,g.pathname+g.search)):a()},t[8]=b,t[9]=n.pluginId,t[10]=g,t[11]=d,t[12]=h,t[13]=p,t[14]=a,t[15]=u,t[16]=S):S=t[16];let C=S,w=`${d}, ${r.marketplaceDetailTitle}`,T;t[17]!==a||t[18]!==w?(T=(0,$.jsx)(`button`,{type:`button`,"aria-label":w,onClick:a,className:_e}),t[17]=a,t[18]=w,t[19]=T):T=t[19];let E=n.branding?.iconUrl,D;t[20]===E?D=t[21]:(D=(0,$.jsx)(X,{iconUrl:E,fallback:v}),t[20]=E,t[21]=D);let O;t[22]===d?O=t[23]:(O=(0,$.jsx)(`h2`,{className:`line-clamp-2 break-words font-semibold leading-snug text-fg`,title:d,children:d}),t[22]=d,t[23]=O);let k;t[24]===n.provenance?.publisherVerification?k=t[25]:(k=n.provenance?.publisherVerification===`verified`?(0,$.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,t[24]=n.provenance?.publisherVerification,t[25]=k);let A;t[26]!==O||t[27]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[O,k]}),t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]===n.version?j=t[30]:(j=n.version?(0,$.jsxs)(`span`,{children:[`v`,n.version]}):null,t[29]=n.version,t[30]=j);let M=p?`text-amber-700 dark:text-amber-400`:`text-fg-muted`,N=p?u?`需要授权`:`Authorization required`:Ae(n)?r.statusEnabled:r.runStateOff,P;t[31]!==M||t[32]!==N?(P=(0,$.jsx)(`span`,{className:M,children:N}),t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;t[34]!==j||t[35]!==P?(F=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[j,P]}),t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==A||t[38]!==F?(I=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,F]}),t[37]=A,t[38]=F,t[39]=I):I=t[39];let L;t[40]!==x||t[41]!==C?(L=(0,$.jsx)(`div`,{className:`pointer-events-auto relative z-10 flex max-w-[45%] shrink-0 items-start`,children:(0,$.jsx)(`button`,{type:`button`,onClick:C,className:`inline-flex items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg transition-colors hover:bg-surface-hover active:scale-[0.98] active:bg-surface-hover/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:x})}),t[40]=x,t[41]=C,t[42]=L):L=t[42];let R;t[43]!==I||t[44]!==L||t[45]!==D?(R=(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-3`,children:[D,I,L]}),t[43]=I,t[44]=L,t[45]=D,t[46]=R):R=t[46];let z;t[47]!==r.cardNoDescription||t[48]!==m?(z=m?.trim()||r.cardNoDescription,t[47]=r.cardNoDescription,t[48]=m,t[49]=z):z=t[49];let B;t[50]===z?B=t[51]:(B=(0,$.jsx)(`p`,{className:`pointer-events-none relative mt-3 line-clamp-3 text-sm leading-relaxed text-fg-muted`,children:z}),t[50]=z,t[51]=B);let V;return t[52]!==R||t[53]!==B||t[54]!==T?(V=(0,$.jsxs)(`article`,{className:ge,children:[T,R,B]}),t[52]=R,t[53]=B,t[54]=T,t[55]=V):V=t[55],V}function Pe(e){return e.language}function Fe({extension:e,copy:t,onClose:n}){let{mutate:r}=P(),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),v=e.activationEligible===!0,y=(0,Q.useCallback)(async()=>{c(null),u(!1),a(`toggle`);try{let{requiresGatewayRestart:t}=await ae({extensionId:e.id,enabled:!v});await r(`gateway-extensions-list`),I(),u(t)}catch(e){c(e instanceof Error?e.message:t.extensionToggleFailed)}finally{a(null)}},[v,t.extensionToggleFailed,e.id,r]),x=(0,Q.useCallback)(async()=>{if(!(e.source===`bundled`||!window.confirm(t.extensionUninstallConfirm))){c(null),u(!1),a(`uninstall`);try{await Z(e.id),await r(`gateway-extensions-list`),I(),n()}catch(e){c(e instanceof Error?e.message:t.marketplaceUninstallFailed),a(null)}}},[t.extensionUninstallConfirm,t.marketplaceUninstallFailed,e.id,e.source,r,n]),w=e.ui?.contributions?.pages??[],T=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=w.find(e=>e.showInNav)??w[0],A=T[0],N=O?b(e.id,O):null,F=A?`/settings/ext/${e.id}/${A.id}`:e.hasConfigSchema||H(e)?`/settings/ext/${e.id}`:null;return(0,$.jsx)(g,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(p,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,$.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,$.jsx)(_,{className:`size-5`})}),(0,$.jsx)(h,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,$.jsxs)(f,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,$.jsx)(j,{className:`size-5`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,$.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,je(e,t)]}),e.version?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,$.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Me(e,t)}),e.source===`bundled`?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}):null,(0,$.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,$.jsx)(L,{type:`button`,variant:`secondary`,disabled:i!==null,onClick:()=>void y(),className:`shrink-0 py-1.5 text-xs`,children:i===`toggle`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(C,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):v?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null,e.source===`bundled`?null:(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,$.jsxs)(L,{type:`button`,variant:`ghost`,disabled:i!==null,onClick:()=>void x(),className:`text-danger hover:bg-danger-soft hover:text-danger`,children:[i===`uninstall`?(0,$.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceUninstall]})})]}),e.hasUi&&(w.length>0||T.length>0||E.length>0)?(0,$.jsxs)(`section`,{className:`mt-8`,children:[(0,$.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,$.jsx)(Ie,{template:t.badgePages,count:w.length,hidden:w.length===0}),(0,$.jsx)(Ie,{template:t.badgeSettings,count:T.length,hidden:T.length===0}),(0,$.jsx)(Ie,{template:t.badgeWidgets,count:E.length,hidden:E.length===0})]})]}):null,W(e)&&(N||F)?(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[N?(0,$.jsxs)(o,{to:N,onClick:n,className:M(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(S,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,F?(0,$.jsxs)(o,{to:F,onClick:n,className:M(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(D,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,$.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function Ie(e){let t=(0,me.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function Le(){let e=(0,me.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:he,"aria-busy":`true`,children:Array.from({length:6},Re)}),e[0]=t):t=e[0],t}function Re(e,t){return(0,$.jsx)(N,{className:`h-32 rounded-xl`},t)}function ze(e){let t=(0,me.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ke as ExtensionsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,m as a,t as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{l as c,n as l}from"./locale-store-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.js";import{a as d,i as f,o as p,r as m,s as h,t as g}from"./dist-CY7CS_D3.js";import{t as _}from"./arrow-left-D880xG-P.js";import{t as v}from"./box-DvYoGszj.js";import{n as y,t as b}from"./extension-paths-DvuaZJuy.js";import{t as x}from"./ellipsis-0k4rZLoy.js";import{t as S}from"./external-link-DjqjBmc3.js";import{t as C}from"./loader-circle-CifKLtgG.js";import{t as w}from"./markdown-view-CNJaAdNN.js";import{t as T}from"./package-wATCyihJ.js";import{t as E}from"./plus-Q2yW6OE7.js";import{t as D}from"./settings-uiTATseT.js";import{t as O}from"./shield-check-BU58siTV.js";import{t as k}from"./trash-2-DusmjVPV.js";import{t as A}from"./triangle-alert-2JXFNNKU.js";import{t as j}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-DzdOeGYz.js";import{a as P,i as F}from"./vendor-swr-CdRzEUwF.js";import{o as I}from"./gateway-realtime-DIs1pjkQ.js";import{t as L}from"./button-Cc4hUNTt.js";import{n as R}from"./interaction-BdhHBbYa.js";import{t as z}from"./page-tabs-oeTY7z3_.js";import{t as B}from"./page-header-store-Bm8oxpFR.js";import{i as V,o as H,r as U,s as W}from"./extension-provider-D-LolObs.js";import{r as G}from"./settings-form-draft-Dy10ldo8.js";import{l as K,m as ee,o as te,r as q,t as ne}from"./dist-ZrL34Ps4.js";import{i as re,t as ie}from"./agent-plugin-dialog-C_rlXuEe.js";import{n as J,t as Y}from"./capability-links-MZdYfPKx.js";import{t as X}from"./capability-icon-CmvCZOJX.js";import{a as Z,i as ae,n as oe,r as se,t as ce}from"./extension-marketplace-api-BIzkukYp.js";import{n as le,t as ue}from"./capability-header-actions-BxMYfQ8y.js";import{n as de,r as fe,t as pe}from"./plugin-presentation-CO5BFDGW.js";var me=n(),he=`grid auto-rows-fr grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-stretch gap-4`,ge=`relative h-full min-w-0 rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:border-edge-strong hover:bg-surface-hover/30`,_e=`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,Q=e(t(),1);function ve(e){return e===`builtin`||e===`user`?e:`marketplace`}var $=r();function ye(e,t){let n=e.find(e=>e.id===t||e.pluginId===t||e.provenance?.packageName===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var be={debounced:``,detailPkg:null,quickInstallPkg:null,rowBusy:null,actionError:null,restartHint:null};function xe({className:e,query:t}){let n=s(),r=i(),a=l(e=>e.language),o=u(a).extensionsPage,d=c(e=>!!e.conversationId),f=U(),{mutate:p}=P(),[m,h]=(0,Q.useReducer)(G,be),{debounced:g,detailPkg:_,quickInstallPkg:v,rowBusy:b,actionError:x,restartHint:S}=m,w=d?`marketplace-${g}`:null;(0,Q.useEffect)(()=>{let e=window.setTimeout(()=>h({type:`patch`,patch:{debounced:t.trim()}}),300);return()=>window.clearTimeout(e)},[t]);let{data:E,isLoading:D,error:O}=F(w,()=>ce(g),{revalidateOnFocus:!1}),A=(0,Q.useCallback)(()=>{p(`gateway-extensions-list`),I()},[p]),j=(0,Q.useCallback)(async(e,t)=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await se({name:e,overwrite:t});A(),n.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:o.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:o.marketplaceInstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[o.marketplaceInstallFailed,o.marketplaceRestartHint,A]),L=(0,Q.useCallback)(async e=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let t=await Z(e);A(),t.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:o.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:o.marketplaceUninstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[o.marketplaceRestartHint,o.marketplaceUninstallFailed,A]),R=E??[];return(0,$.jsxs)(`div`,{className:M(`flex flex-col gap-4`,e),children:[O?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:O instanceof Error?O.message:o.marketplaceLoadFailed}):null,x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null,S?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:S}):null,D&&!E?(0,$.jsx)(`ul`,{className:he,"aria-label":o.marketplaceLoading,children:[0,1,2,3,4,5].map(e=>(0,$.jsxs)(`li`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(N,{className:`size-10 shrink-0 rounded-xl`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(N,{className:`h-5 w-full`}),(0,$.jsx)(N,{className:`h-3 w-2/3`})]}),(0,$.jsx)(N,{className:`h-9 w-16 shrink-0 rounded-lg`})]}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(N,{className:`h-4 w-full`}),(0,$.jsx)(N,{className:`h-4 w-full`}),(0,$.jsx)(N,{className:`h-4 w-2/3`})]})]},e))}):(0,$.jsx)(`ul`,{className:he,children:R.length===0?(0,$.jsx)(`li`,{className:`col-span-full text-sm text-fg-muted`,children:o.marketplaceEmpty}):R.map(e=>{let t=ye(f,e.id),i=b===e.id,s=f.find(t=>t.pluginId===e.id||t.provenance?.packageName===e.id),c=e.localizations?.[a.startsWith(`zh`)?`zh-CN`:`en`],l=c?.displayName??e.name,u=c?.description??e.description;return(0,$.jsxs)(`li`,{className:ge,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${l}, ${o.marketplaceDetailTitle}`,onClick:()=>s?.pluginId?n(Y(s.pluginId,`installed`,!1,r.pathname+r.search)):h({type:`patch`,patch:{detailPkg:e.id}}),className:_e}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-3`,children:[(0,$.jsx)(X,{iconUrl:e.branding?.iconUrl,fallback:T}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,$.jsx)(`h3`,{className:`line-clamp-2 break-words font-semibold leading-snug text-fg`,title:l,children:l}),e.verified?(0,$.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[e.version?(0,$.jsxs)(`span`,{children:[`v`,e.version]}):null,t===`user`?(0,$.jsx)(`span`,{className:s&&fe(s)?`text-amber-700 dark:text-amber-400`:`text-fg-muted`,children:s&&fe(s)?a.startsWith(`zh`)?`需要授权`:`Authorization required`:o.marketplaceInstalled}):null]})]}),(0,$.jsx)(`div`,{role:`group`,className:`pointer-events-auto relative z-10 flex max-w-[45%] shrink-0 items-start`,children:t===`bundled`?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:o.marketplaceBuiltin}):t===`user`?(0,$.jsx)($.Fragment,{children:e.packageType===`plugin`?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s?.pluginId&&pe(s)?n(J(l,a.startsWith(`zh`),s.pluginId)):s?.pluginId?n(Y(s.pluginId,`installed`,fe(s),r.pathname+r.search)):h({type:`patch`,patch:{detailPkg:e.id,quickInstallPkg:null}}),className:M(`inline-flex items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:s&&fe(s)?a.startsWith(`zh`)?`去授权`:`Connect account`:s&&pe(s)?a.startsWith(`zh`)?`开始使用`:`Start using`:a.startsWith(`zh`)?`管理插件`:`Manage plugin`}):(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(o.marketplaceUninstallConfirm)&&L(e.id).catch(()=>{})},className:M(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,$.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(k,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),o.marketplaceUninstall]})}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>h({type:`patch`,patch:(e.packageType,{detailPkg:e.id,quickInstallPkg:null})}),className:M(`inline-flex min-w-16 items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:e.packageType===`plugin`?a.startsWith(`zh`)?`安装`:`Install`:o.marketplaceReview})})]}),u?(0,$.jsx)(`p`,{className:`pointer-events-none relative mt-3 line-clamp-3 text-sm leading-relaxed text-fg-muted`,children:u}):null,(e.categories?.length??0)>0?(0,$.jsx)(`div`,{className:`pointer-events-none relative mt-3 flex flex-wrap gap-1.5`,children:e.categories?.map(e=>(0,$.jsx)(`span`,{className:`max-w-full truncate rounded-md border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]},e.id)})}),_?(0,$.jsx)(Se,{packageName:_,autoInstall:v===_,copy:o,extensions:f,onClose:()=>h({type:`patch`,patch:{detailPkg:null,quickInstallPkg:null}}),onInstall:j,onUninstall:L}):null]})}function Se(e){let t=(0,me.c)(99),{packageName:n,autoInstall:r,copy:i,extensions:a,onClose:s,onInstall:u,onUninstall:f}=e,[v,y]=(0,Q.useState)(!1),b=l(Oe),[x,S]=(0,Q.useState)(!1),T=c(De)?`ext-mp-detail-${n}`:null,E;t[0]===n?E=t[1]:(E=async()=>oe(n),t[0]=n,t[1]=E);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D={revalidateOnFocus:!1},t[2]=D):D=t[2];let{data:P,error:I,isLoading:L}=F(T,E,D),R;t[3]!==a||t[4]!==n?(R=ye(a,n),t[3]=a,t[4]=n,t[5]=R):R=t[5];let z=R,B=z===`user`,V=P?.manifest?.permissions,H,U,W,G,K,ee,te,q,ne,J,Y,X;if(t[6]!==r||t[7]!==i||t[8]!==P||t[9]!==I||t[10]!==a||t[11]!==z||t[12]!==L||t[13]!==b||t[14]!==s||t[15]!==n||t[16]!==V||t[17]!==x){ee=Symbol.for(`react.early_return_sentinel`);bb0:{let e=V&&typeof V==`object`&&!Array.isArray(V)?Object.entries(V):[],o;t[30]!==i||t[31]!==P?(o=P?.readme?.trim()||(P?.description?.trim()?`### ${P.name}\n\n${P.description}`:`*${i.marketplaceNoReadme}*`),t[30]=i,t[31]=P,t[32]=o):o=t[32];let c=o;if(P?.format===`agent-plugin`){let e;if(t[33]!==P||t[34]!==a||t[35]!==n){let r;t[37]!==P||t[38]!==n?(r=e=>e.provenance?.packageName===n||e.pluginId===P.manifest?.name,t[37]=P,t[38]=n,t[39]=r):r=t[39],e=a.find(r),t[33]=P,t[34]=a,t[35]=n,t[36]=e}else e=t[36];let i=`store:${n}`,o;t[40]!==r||t[41]!==P||t[42]!==s||t[43]!==e||t[44]!==i?(o=(0,$.jsx)(ie,{extension:e,initialSource:i,marketplace:P,autoInstall:r,onClose:s}),t[40]=r,t[41]=P,t[42]=s,t[43]=e,t[44]=i,t[45]=o):o=t[45],ee=o;break bb0}W=g,G=!0,t[46]===s?K=t[47]:(K=e=>!e&&s(),t[46]=s,t[47]=K),U=p,t[48]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[48]=X):X=t[48],H=m,ne=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,J=Ee;let l;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(_,{className:`size-5`}),t[49]=l):l=t[49];let u;t[50]!==i.detailBack||t[51]!==s?(u=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i.detailBack,children:l}),t[50]=i.detailBack,t[51]=s,t[52]=u):u=t[52];let f;t[53]===i.marketplaceDetailTitle?f=t[54]:(f=(0,$.jsx)(h,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:i.marketplaceDetailTitle}),t[53]=i.marketplaceDetailTitle,t[54]=f);let v;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(j,{className:`size-5`}),t[55]=v):v=t[55];let y;t[56]!==i.detailClose||t[57]!==s?(y=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i.detailClose,children:v}),t[56]=i.detailClose,t[57]=s,t[58]=y):y=t[58],t[59]!==u||t[60]!==f||t[61]!==y?(Y=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[u,f,y]}),t[59]=u,t[60]=f,t[61]=y,t[62]=Y):Y=t[62],te=`min-h-0 flex-1 overflow-y-auto p-5`,q=L&&!P?(0,$.jsxs)(`div`,{className:`space-y-4`,"aria-label":i.marketplaceLoading,children:[(0,$.jsx)(N,{className:`h-6 w-48`}),(0,$.jsx)(N,{className:`h-4 w-28`}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(N,{className:`h-12`}),(0,$.jsx)(N,{className:`h-12`})]}),(0,$.jsx)(N,{className:`h-28 w-full`}),(0,$.jsx)(N,{className:`h-36 w-full`})]}):I?(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,$.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:i.marketplaceDetailLoadFailed}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:I instanceof Error?I.message:i.marketplaceLoadFailed})]}):P?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:P.name}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:P.id})}),(0,$.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceAuthor}),(0,$.jsx)(`dd`,{children:P.author.username})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceVersion}),(0,$.jsx)(`dd`,{children:P.latestVersion.version})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceDownloads}),(0,$.jsx)(`dd`,{children:P.downloads})]})]}),(0,$.jsx)(re,{data:P,zh:b===`zh`}),z===`bundled`?null:(0,$.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[P.installability.available?(0,$.jsx)(O,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,$.jsx)(A,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:P.installability.available?i.marketplaceRiskTitle:i.marketplaceUnavailableTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:P.installability.available?i.marketplaceCodeRisk:P.installability.reason??i.marketplaceUnavailableBody})]})]}),P.installability.available?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceIntegrity}),(0,$.jsx)(`dd`,{children:i.marketplaceIntegrityVerified})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceDependencies}),(0,$.jsx)(`dd`,{children:P.packageSummary?.dependencyCount??0})]})]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.marketplacePermissions}),e.length>0?(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(Te)}):(0,$.jsx)(`p`,{className:`mt-1`,children:i.marketplacePermissionsNone})]}),(P.packageSummary?.lifecycleScripts.length??0)>0?(0,$.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[i.marketplaceLifecycleScripts,`: `,P.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,$.jsx)(`span`,{children:i.marketplaceRiskConfirm})]})]}):null]}),P.readme?.trim()?(0,$.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:i.marketplaceDetailReadmeHeading}):null,(0,$.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,$.jsx)(w,{content:c})})]}):null}t[6]=r,t[7]=i,t[8]=P,t[9]=I,t[10]=a,t[11]=z,t[12]=L,t[13]=b,t[14]=s,t[15]=n,t[16]=V,t[17]=x,t[18]=H,t[19]=U,t[20]=W,t[21]=G,t[22]=K,t[23]=ee,t[24]=te,t[25]=q,t[26]=ne,t[27]=J,t[28]=Y,t[29]=X}else H=t[18],U=t[19],W=t[20],G=t[21],K=t[22],ee=t[23],te=t[24],q=t[25],ne=t[26],J=t[27],Y=t[28],X=t[29];if(ee!==Symbol.for(`react.early_return_sentinel`))return ee;let Z;t[63]!==te||t[64]!==q?(Z=(0,$.jsx)(`div`,{className:te,children:q}),t[63]=te,t[64]=q,t[65]=Z):Z=t[65];let ae;t[66]!==v||t[67]!==i.marketplaceBuiltinGoBuiltin||t[68]!==i.marketplaceBuiltinManageHint||t[69]!==i.marketplaceInstall||t[70]!==i.marketplaceReinstall||t[71]!==i.marketplaceReinstallConfirm||t[72]!==i.marketplaceUninstall||t[73]!==i.marketplaceUninstallConfirm||t[74]!==P||t[75]!==z||t[76]!==s||t[77]!==u||t[78]!==f||t[79]!==n||t[80]!==x||t[81]!==B?(ae=P?(0,$.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:z===`bundled`?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:i.marketplaceBuiltinManageHint}),(0,$.jsx)(o,{to:`/capabilities/extensions?tab=builtin`,onClick:s,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:i.marketplaceBuiltinGoBuiltin})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:v||!P.installability.available||!x,onClick:()=>{B&&!window.confirm(i.marketplaceReinstallConfirm)||(y(!0),u(n,B).catch(we).finally(()=>y(!1)))},className:M(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-on-accent shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[v?(0,$.jsx)(C,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,B?i.marketplaceReinstall:i.marketplaceInstall]}),B?(0,$.jsxs)(`button`,{type:`button`,disabled:v,onClick:()=>{window.confirm(i.marketplaceUninstallConfirm)&&(y(!0),f(n).then(()=>s()).catch(Ce).finally(()=>y(!1)))},className:M(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,$.jsx)(k,{className:`size-4 shrink-0`,"aria-hidden":!0}),i.marketplaceUninstall]}):null]})}):null,t[66]=v,t[67]=i.marketplaceBuiltinGoBuiltin,t[68]=i.marketplaceBuiltinManageHint,t[69]=i.marketplaceInstall,t[70]=i.marketplaceReinstall,t[71]=i.marketplaceReinstallConfirm,t[72]=i.marketplaceUninstall,t[73]=i.marketplaceUninstallConfirm,t[74]=P,t[75]=z,t[76]=s,t[77]=u,t[78]=f,t[79]=n,t[80]=x,t[81]=B,t[82]=ae):ae=t[82];let se;t[83]!==H||t[84]!==Z||t[85]!==ae||t[86]!==ne||t[87]!==J||t[88]!==Y?(se=(0,$.jsxs)(H,{className:ne,onOpenAutoFocus:J,children:[Y,Z,ae]}),t[83]=H,t[84]=Z,t[85]=ae,t[86]=ne,t[87]=J,t[88]=Y,t[89]=se):se=t[89];let ce;t[90]!==U||t[91]!==se||t[92]!==X?(ce=(0,$.jsxs)(U,{children:[X,se]}),t[90]=U,t[91]=se,t[92]=X,t[93]=ce):ce=t[93];let le;return t[94]!==W||t[95]!==G||t[96]!==K||t[97]!==ce?(le=(0,$.jsx)(W,{defaultOpen:G,onOpenChange:K,children:ce}),t[94]=W,t[95]=G,t[96]=K,t[97]=ce,t[98]=le):le=t[98],le}function Ce(){}function we(){}function Te(e){let[t,n]=e;return(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function Ee(e){return e.preventDefault()}function De(e){return!!e.conversationId}function Oe(e){return e.language}function ke({embedded:e=!1,onHeaderActionChange:t}){let n=s(),r=i(),c=l(e=>e.language),d=u(c),f=B(e=>e.setPageHeader),p=B(e=>e.clearPageHeader),m=U(),h=V(),[g,_]=a(),y=ve(g.get(`tab`)??(m.some(e=>e.source!==`bundled`)?`user`:null)),b=(0,Q.useRef)(!1),S=g.get(`q`)??``,[C,w]=(0,Q.useState)(y),[T,D]=(0,Q.useState)(S),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),N=g.toString(),P=(0,Q.useRef)(N);if(P.current!==N){P.current=N;let e=ve(g.get(`tab`)),t=g.get(`q`)??``;w(t=>t===e?t:e),D(e=>e===t?e:t)}(0,Q.useEffect)(()=>{_(e=>{let t=new URLSearchParams(e),n=T.trim();return n?t.set(`q`,n):t.delete(`q`),C===`marketplace`?t.delete(`tab`):t.set(`tab`,C),t.toString()===e.toString()?e:t},{replace:!0})},[C,T,_]);let F=(0,Q.useMemo)(()=>m.filter(e=>e.source===`bundled`),[m]),I=(0,Q.useMemo)(()=>m.filter(e=>e.source!==`bundled`),[m]);(0,Q.useEffect)(()=>{h||b.current||(b.current=!0,!g.has(`tab`)&&I.length&&w(`user`))},[h,g,I.length]);let H=C===`builtin`?F:I,W=(0,Q.useMemo)(()=>{let e=T.trim().toLowerCase(),t=H;return e&&(t=t.filter(t=>(t.name??``).toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e))),t.toSorted((e,t)=>e.hasUi===t.hasUi?(e.name||e.id).localeCompare(t.name||t.id,c):e.hasUi?-1:1)},[H,T,c]);(0,Q.useEffect)(()=>{k(e=>{if(!e)return e;let t=m.find(t=>t.id===e.id);return t?Ae(e)===Ae(t)&&e.active===t.active&&JSON.stringify(e)===JSON.stringify(t)?e:t:null})},[m]);let G=(0,Q.useMemo)(()=>({searchLabel:C===`marketplace`?d.extensionsPage.marketplaceSearchPlaceholder:d.extensionsPage.searchPlaceholder,search:(0,$.jsx)(le,{value:T,onChange:D,placeholder:C===`marketplace`?d.extensionsPage.marketplaceSearchPlaceholder:d.extensionsPage.searchPlaceholder}),overflow:(0,$.jsxs)(K,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(L,{variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d.capabilitiesHub.moreActions,title:d.capabilitiesHub.moreActions,children:(0,$.jsx)(x,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(te,{children:(0,$.jsxs)(ne,{align:`end`,sideOffset:6,className:`z-50 min-w-48 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(q,{className:M(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,R.transition),onSelect:()=>j(!0),children:[(0,$.jsx)(E,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),c.startsWith(`zh`)?`安装插件`:`Install plugin`]}),(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(o,{to:`/local-apps`,className:M(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,R.transition),children:[(0,$.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),d.extensionsPage.openLocalApps]})})]})})]}),primary:(0,$.jsx)(L,{asChild:!0,variant:`primary`,className:`h-9 shrink-0`,children:(0,$.jsxs)(o,{to:`/local-apps/new`,"aria-label":d.extensionsPage.createLocalApp,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:d.extensionsPage.createLocalApp})]})})}),[c,d.capabilitiesHub.moreActions,d.extensionsPage,C,T]);(0,Q.useLayoutEffect)(()=>e?(t?.(G),()=>t?.(null)):(f({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:d.extensionsPage.title})}),end:(0,$.jsx)(ue,{contribution:G})}),()=>p()),[p,e,G,d.extensionsPage.title,t,f]);let re=[{id:`user`,label:d.extensionsPage.tabUser,count:h?void 0:I.length},{id:`marketplace`,label:d.extensionsPage.tabMarketplace},{id:`builtin`,label:d.extensionsPage.tabBuiltin,count:h?void 0:F.length}];return(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:M(`mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8`,`pb-7 pt-3 lg:pb-9 lg:pt-4`),children:[(0,$.jsx)(`div`,{className:`mb-6 border-b border-edge-subtle pb-3`,children:(0,$.jsx)(z,{items:re,activeTab:C,onChange:w,ariaLabel:d.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`})}),C===`marketplace`?(0,$.jsx)(xe,{query:T}):h?(0,$.jsx)(Le,{}):C===`builtin`&&F.length===0?(0,$.jsx)(ze,{message:d.extensionsPage.emptyBuiltin}):C===`user`&&I.length===0?(0,$.jsx)(ze,{message:d.extensionsPage.emptyUser}):W.length===0?(0,$.jsx)(`p`,{className:`px-3 py-14 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:d.extensionsPage.noSearchResults}):(0,$.jsx)(`div`,{className:he,children:W.map(e=>(0,$.jsx)(Ne,{extension:e,copy:d.extensionsPage,onOpen:()=>e.pluginId?n(Y(e.pluginId,`installed`,!1,r.pathname+r.search)):k(e)},e.id))})]}),O?O.format===`agent-plugin`?(0,$.jsx)(ie,{extension:O,onClose:()=>k(null)},O.id):(0,$.jsx)(Fe,{extension:O,copy:d.extensionsPage,onClose:()=>k(null)},O.id):null,A?(0,$.jsx)(ie,{onClose:()=>j(!1)}):null]})}function Ae(e){return e.activationEligible??e.active}function je(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function Me(e,t){let n=Ae(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function Ne(e){let t=(0,me.c)(56),{extension:n,copy:r,onOpen:a}=e,o=l(Pe),c,u;t[0]!==n||t[1]!==o?(u=o.startsWith(`zh`),c=de(n,u),t[0]=n,t[1]=o,t[2]=c,t[3]=u):(c=t[2],u=t[3]);let d=c,f;t[4]===n?f=t[5]:(f=fe(n),t[4]=n,t[5]=f);let p=f,m=n.localizations?.[u?`zh-CN`:`en`]?.description??n.description,h=s(),g=i(),_;t[6]===n?_=t[7]:(_=!!n.pluginId&&pe(n),t[6]=n,t[7]=_);let b=_,x=p?u?`去授权`:`Connect account`:b?u?`开始使用`:`Start using`:u?`管理插件`:`Manage plugin`,S;t[8]!==b||t[9]!==n.pluginId||t[10]!==g||t[11]!==d||t[12]!==h||t[13]!==p||t[14]!==a||t[15]!==u?(S=()=>{b?h(J(d,u,n.pluginId)):p&&n.pluginId?h(Y(n.pluginId,`installed`,!0,g.pathname+g.search)):a()},t[8]=b,t[9]=n.pluginId,t[10]=g,t[11]=d,t[12]=h,t[13]=p,t[14]=a,t[15]=u,t[16]=S):S=t[16];let C=S,w=`${d}, ${r.marketplaceDetailTitle}`,T;t[17]!==a||t[18]!==w?(T=(0,$.jsx)(`button`,{type:`button`,"aria-label":w,onClick:a,className:_e}),t[17]=a,t[18]=w,t[19]=T):T=t[19];let E=n.branding?.iconUrl,D;t[20]===E?D=t[21]:(D=(0,$.jsx)(X,{iconUrl:E,fallback:v}),t[20]=E,t[21]=D);let O;t[22]===d?O=t[23]:(O=(0,$.jsx)(`h2`,{className:`line-clamp-2 break-words font-semibold leading-snug text-fg`,title:d,children:d}),t[22]=d,t[23]=O);let k;t[24]===n.provenance?.publisherVerification?k=t[25]:(k=n.provenance?.publisherVerification===`verified`?(0,$.jsx)(y,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,t[24]=n.provenance?.publisherVerification,t[25]=k);let A;t[26]!==O||t[27]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[O,k]}),t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]===n.version?j=t[30]:(j=n.version?(0,$.jsxs)(`span`,{children:[`v`,n.version]}):null,t[29]=n.version,t[30]=j);let M=p?`text-amber-700 dark:text-amber-400`:`text-fg-muted`,N=p?u?`需要授权`:`Authorization required`:Ae(n)?r.statusEnabled:r.runStateOff,P;t[31]!==M||t[32]!==N?(P=(0,$.jsx)(`span`,{className:M,children:N}),t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;t[34]!==j||t[35]!==P?(F=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[j,P]}),t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==A||t[38]!==F?(I=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,F]}),t[37]=A,t[38]=F,t[39]=I):I=t[39];let L;t[40]!==x||t[41]!==C?(L=(0,$.jsx)(`div`,{className:`pointer-events-auto relative z-10 flex max-w-[45%] shrink-0 items-start`,children:(0,$.jsx)(`button`,{type:`button`,onClick:C,className:`inline-flex items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg transition-colors hover:bg-surface-hover active:scale-[0.98] active:bg-surface-hover/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:x})}),t[40]=x,t[41]=C,t[42]=L):L=t[42];let R;t[43]!==I||t[44]!==L||t[45]!==D?(R=(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-3`,children:[D,I,L]}),t[43]=I,t[44]=L,t[45]=D,t[46]=R):R=t[46];let z;t[47]!==r.cardNoDescription||t[48]!==m?(z=m?.trim()||r.cardNoDescription,t[47]=r.cardNoDescription,t[48]=m,t[49]=z):z=t[49];let B;t[50]===z?B=t[51]:(B=(0,$.jsx)(`p`,{className:`pointer-events-none relative mt-3 line-clamp-3 text-sm leading-relaxed text-fg-muted`,children:z}),t[50]=z,t[51]=B);let V;return t[52]!==R||t[53]!==B||t[54]!==T?(V=(0,$.jsxs)(`article`,{className:ge,children:[T,R,B]}),t[52]=R,t[53]=B,t[54]=T,t[55]=V):V=t[55],V}function Pe(e){return e.language}function Fe({extension:e,copy:t,onClose:n}){let{mutate:r}=P(),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),v=e.activationEligible===!0,y=(0,Q.useCallback)(async()=>{c(null),u(!1),a(`toggle`);try{let{requiresGatewayRestart:t}=await ae({extensionId:e.id,enabled:!v});await r(`gateway-extensions-list`),I(),u(t)}catch(e){c(e instanceof Error?e.message:t.extensionToggleFailed)}finally{a(null)}},[v,t.extensionToggleFailed,e.id,r]),x=(0,Q.useCallback)(async()=>{if(!(e.source===`bundled`||!window.confirm(t.extensionUninstallConfirm))){c(null),u(!1),a(`uninstall`);try{await Z(e.id),await r(`gateway-extensions-list`),I(),n()}catch(e){c(e instanceof Error?e.message:t.marketplaceUninstallFailed),a(null)}}},[t.extensionUninstallConfirm,t.marketplaceUninstallFailed,e.id,e.source,r,n]),w=e.ui?.contributions?.pages??[],T=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=w.find(e=>e.showInNav)??w[0],A=T[0],N=O?b(e.id,O):null,F=A?`/settings/ext/${e.id}/${A.id}`:e.hasConfigSchema||H(e)?`/settings/ext/${e.id}`:null;return(0,$.jsx)(g,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(p,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,$.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,$.jsx)(_,{className:`size-5`})}),(0,$.jsx)(h,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,$.jsxs)(f,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,$.jsx)(j,{className:`size-5`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,$.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,je(e,t)]}),e.version?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,$.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Me(e,t)}),e.source===`bundled`?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}):null,(0,$.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,$.jsx)(L,{type:`button`,variant:`secondary`,disabled:i!==null,onClick:()=>void y(),className:`shrink-0 py-1.5 text-xs`,children:i===`toggle`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(C,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):v?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null,e.source===`bundled`?null:(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,$.jsxs)(L,{type:`button`,variant:`ghost`,disabled:i!==null,onClick:()=>void x(),className:`text-danger hover:bg-danger-soft hover:text-danger`,children:[i===`uninstall`?(0,$.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceUninstall]})})]}),e.hasUi&&(w.length>0||T.length>0||E.length>0)?(0,$.jsxs)(`section`,{className:`mt-8`,children:[(0,$.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,$.jsx)(Ie,{template:t.badgePages,count:w.length,hidden:w.length===0}),(0,$.jsx)(Ie,{template:t.badgeSettings,count:T.length,hidden:T.length===0}),(0,$.jsx)(Ie,{template:t.badgeWidgets,count:E.length,hidden:E.length===0})]})]}):null,W(e)&&(N||F)?(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[N?(0,$.jsxs)(o,{to:N,onClick:n,className:M(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(S,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,F?(0,$.jsxs)(o,{to:F,onClick:n,className:M(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(D,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,$.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function Ie(e){let t=(0,me.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function Le(){let e=(0,me.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:he,"aria-busy":`true`,children:Array.from({length:6},Re)}),e[0]=t):t=e[0],t}function Re(e,t){return(0,$.jsx)(N,{className:`h-32 rounded-xl`},t)}function ze(e){let t=(0,me.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ke as ExtensionsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./automations-workspace-BXT_EDON.js";var r=e(),i=t();function a(){let e=(0,r.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,i.jsx)(n,{}),e[0]=t):t=e[0],t}export{a as AutomationsPage};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./automations-workspace-JCQ1IXFk.js";var r=e(),i=t();function a(){let e=(0,r.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,i.jsx)(n,{}),e[0]=t):t=e[0],t}export{a as AutomationsPage};