@xopcai/xopc 0.0.268 → 0.0.269

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 (207) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-Bhyy6ENz.js → activity-store-DcwCSY6s.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B9WObxjr.js → agent-avatar-dicebear-D0NBOWC4.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-J1YFNG26.js → agent-defaults-settings-panel-qKCezlBg.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-BMhnZKhP.js +1 -0
  7. package/dist/gateway/static/root/assets/{api-B2y7ZjZk.js → api-eaPO-mdr.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bbn9mDfL.js → app-management-settings-panel-E3xm2teY.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-Deo5EsIc.js → appearance-settings-CiZOjgls.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-DduJDWGY.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-CxJTU8MU.js → archive-plugin-D09yo_Hc.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-C71Cukgp.js → attachment-load-CNYb8Qru.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-_J7UZ55Q.js → automations-page-DsrfW5ii.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-X7hNHCjW.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-CX8fC8Zt.js → binary-plugins-OWlaGqlY.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-Ci9fjoQL.js → block-editor-CVND3M6r.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-s5I78Iko.js → browser-automation-inputs-D7IzVK_J.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-rDSx0ozx.js → browser-automations-page-CQ6cCpIv.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-BZ7nK_pN.js +8 -0
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-BfKvJO1C.js +7 -0
  21. package/dist/gateway/static/root/assets/channels-settings-D1UDxJuA.js +1 -0
  22. package/dist/gateway/static/root/assets/{channels-status-swr-_OsWr_vS.js → channels-status-swr-D4JrgJKa.js} +1 -1
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-DMSl8KxS.js → chat-terminal-dock-BUjnhT7C.js} +2 -2
  24. package/dist/gateway/static/root/assets/connectors-page-C2nuqs_O.js +2 -0
  25. package/dist/gateway/static/root/assets/{cron-expression-BByq6Uh8.js → cron-expression-DlyRIyUn.js} +1 -1
  26. package/dist/gateway/static/root/assets/{date-picker-m6JZCUEW.js → date-picker-CU-ij_yE.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-CwCAjbaJ.js → dependency-picker-Z6Nf0Wjq.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-DSmeEREd.js → desktop-pet-C0F5Iqnc.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-MfKceMoe.js → desktop-pet-settings-Bj_W6HL1.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-debug-page-CwvWy26h.js → extension-debug-page-Ba09EnAn.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-DLrbVBHM.js → extension-page-C88aGXJs.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-settings-page-BI6C4PM-.js → extension-settings-page-CMyt0A32.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-swr-OObCK8jM.js → gateway-config-swr-bjzk_4hn.js} +1 -1
  34. package/dist/gateway/static/root/assets/gateway-settings-ogv8ZbvG.js +1 -0
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-D_TxKN_A.js → gateway-startup-retry-DrbIzFyB.js} +1 -1
  36. package/dist/gateway/static/root/assets/{heartbeat-settings-CUl832Tb.js → heartbeat-settings-BnrMRKaZ.js} +1 -1
  37. package/dist/gateway/static/root/assets/home-page-CbcJCREd.js +1 -0
  38. package/dist/gateway/static/root/assets/{image-generation-api-fPU9yGsw.js → image-generation-api-CBWU9Ner.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-7PZ6jmhy.css +2 -0
  40. package/dist/gateway/static/root/assets/{index-wKE8Q2FX.js → index-CfyyA9-g.js} +47 -47
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-r4DCS19O.js → keyboard-shortcuts-settings-B8Z7kKQY.js} +1 -1
  42. package/dist/gateway/static/root/assets/local-app-workbench-page-D5XVZnK1.js +2 -0
  43. package/dist/gateway/static/root/assets/{local-apps-page-DkfCRLUh.js → local-apps-page-CLSfzkRp.js} +1 -1
  44. package/dist/gateway/static/root/assets/{locale-store-DFQX9kTl.js → locale-store-BQ2HKTWb.js} +1 -1
  45. package/dist/gateway/static/root/assets/logs-page-CWDU1AGN.js +2 -0
  46. package/dist/gateway/static/root/assets/{management-settings-Cfx4ATTa.js → management-settings-CuFNgQUy.js} +1 -1
  47. package/dist/gateway/static/root/assets/{markdown-view-D-5jHRWg.js → markdown-view-DIcfrLmG.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-DOLjWd3y.js → media-plugins-CSv6-xTA.js} +1 -1
  49. package/dist/gateway/static/root/assets/{messages-Dj8QuS6e.js → messages-BRjoarIr.js} +2 -2
  50. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-BGW9joAb.js → mobile-pairing-wizard-C7d_ztgp.js} +1 -1
  51. package/dist/gateway/static/root/assets/note-detail-panel-D5JuBLyt.js +5 -0
  52. package/dist/gateway/static/root/assets/notes-page-C5-ccCi4.js +8 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-_SGXMT2O.js → page-tabs-BfV-PQa5.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-lVetfCWk.js → preview-open-alternatives-DQS7NFpg.js} +1 -1
  55. package/dist/gateway/static/root/assets/proactive-page-fHjPigmx.js +1 -0
  56. package/dist/gateway/static/root/assets/{product-open-page-CIGLPFm7.js → product-open-page-BIhjZLKg.js} +1 -1
  57. package/dist/gateway/static/root/assets/project-detail-page-6v_khvEt.js +1 -0
  58. package/dist/gateway/static/root/assets/projects-page-CCy1aK4V.js +1 -0
  59. package/dist/gateway/static/root/assets/{registry-api-CsZLatKo.js → registry-api-CwveUfe8.js} +1 -1
  60. package/dist/gateway/static/root/assets/remote-access-hub-pkqKRnch.js +1 -0
  61. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BDqVrUEj.js → runtime-tools-settings-panel-DMQ0wpNg.js} +2 -2
  62. package/dist/gateway/static/root/assets/{schema-form-8RQgFJJO.js → schema-form-C91g2PRU.js} +1 -1
  63. package/dist/gateway/static/root/assets/sessions-page-Cr4E4cap.js +1 -0
  64. package/dist/gateway/static/root/assets/settings-advanced-gate-D1JRDRyL.js +1 -0
  65. package/dist/gateway/static/root/assets/{settings-form-section-j4UjGM-f.js → settings-form-section-Cem6L49Y.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-lMi50B_s.js → settings-page-afDUxqlV.js} +1 -1
  67. package/dist/gateway/static/root/assets/{setup-status-panel-Dx4Fy3rU.js → setup-status-panel-Cc_iP_vv.js} +1 -1
  68. package/dist/gateway/static/root/assets/{share-preview-page-aSyKRH5y.js → share-preview-page-CVEVHksg.js} +1 -1
  69. package/dist/gateway/static/root/assets/shares-settings-BrMECMAB.js +1 -0
  70. package/dist/gateway/static/root/assets/skill-reload-api-DuqIDYjc.js +1 -0
  71. package/dist/gateway/static/root/assets/{skills-page-C2_CAvxW.js → skills-page-CNrq1W6C.js} +1 -1
  72. package/dist/gateway/static/root/assets/{skills-page.utils-B00e4Q30.js → skills-page.utils-D1wGfm22.js} +1 -1
  73. package/dist/gateway/static/root/assets/{system-settings-panel-CulAkrsV.js → system-settings-panel-BLE8PxWE.js} +1 -1
  74. package/dist/gateway/static/root/assets/task-detail-page-m0oXUKl2.js +1 -0
  75. package/dist/gateway/static/root/assets/{theme-store-zRT6vaZc.js → theme-store-BejLVjIT.js} +1 -1
  76. package/dist/gateway/static/root/assets/{tunnel-api-C01xgCWR.js → tunnel-api-Dur80zSQ.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-autosave-DfSJ3c2p.js → use-autosave-DmgEA8Qb.js} +1 -1
  78. package/dist/gateway/static/root/assets/user-model-page-Dl10D_5q.js +2 -0
  79. package/dist/gateway/static/root/assets/{voice-api-key-field-9v-miN8o.js → voice-api-key-field-sZ0J83SF.js} +1 -1
  80. package/dist/gateway/static/root/assets/{voice-config-api-DpJEu2RQ.js → voice-config-api-BEbz3avx.js} +1 -1
  81. package/dist/gateway/static/root/assets/{work-discovery-overlay-CREYgh-1.js → work-discovery-overlay-BXnAlbmO.js} +1 -1
  82. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BkwFey0a.js +3 -0
  83. package/dist/gateway/static/root/assets/workflows-page-CswgoIFU.js +6 -0
  84. package/dist/gateway/static/root/index.html +10 -10
  85. package/dist/gateway/static/root/notification-sw.js +15 -0
  86. package/dist/package.js +1 -1
  87. package/dist/packages/gateway-contract/src/notifications.js +15 -1
  88. package/dist/packages/gateway-contract/src/proactive.js +104 -0
  89. package/dist/packages/realtime-protocol/src/voice.js +2 -1
  90. package/dist/src/agent/workflow/subagent-runner.d.ts +1 -0
  91. package/dist/src/agent/workflow/subagent-runner.js +2 -2
  92. package/dist/src/cli/commands/connectors.js +1 -1
  93. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  94. package/dist/src/connectors/connected-source-ingestion.js +1 -1
  95. package/dist/src/connectors/connection-recovery-service.js +1 -1
  96. package/dist/src/connectors/health.js +1 -1
  97. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  98. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  99. package/dist/src/gateway/hono/routes/index.js +0 -2
  100. package/dist/src/gateway/hono/routes/lazy-bundles.js +12 -0
  101. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  102. package/dist/src/gateway/hono/routes/proactive-control.d.ts +3 -0
  103. package/dist/src/gateway/hono/routes/proactive-control.js +161 -0
  104. package/dist/src/gateway/hono/routes/proactive.d.ts +1 -1
  105. package/dist/src/gateway/hono/routes/proactive.js +12 -5
  106. package/dist/src/gateway/hono/routes/voice.js +1 -1
  107. package/dist/src/gateway/security/gateway-scopes.js +5 -0
  108. package/dist/src/gateway/service.d.ts +0 -1
  109. package/dist/src/gateway/service.js +24 -26
  110. package/dist/src/notifications/planner.js +4 -3
  111. package/dist/src/notifications/proactive-channel.d.ts +8 -0
  112. package/dist/src/notifications/proactive-channel.js +57 -0
  113. package/dist/src/notifications/proactive-policy.d.ts +3 -0
  114. package/dist/src/notifications/proactive-policy.js +32 -0
  115. package/dist/src/notifications/service.d.ts +78 -0
  116. package/dist/src/notifications/service.js +71 -13
  117. package/dist/src/notifications/store.d.ts +2 -0
  118. package/dist/src/notifications/store.js +8 -1
  119. package/dist/src/notifications/web-push.d.ts +19 -0
  120. package/dist/src/notifications/web-push.js +182 -0
  121. package/dist/src/proactive/actions/service.js +10 -2
  122. package/dist/src/proactive/actions/workflow.d.ts +15 -0
  123. package/dist/src/proactive/actions/workflow.js +88 -0
  124. package/dist/src/proactive/execution/agent-executor.d.ts +5 -0
  125. package/dist/src/proactive/execution/agent-executor.js +21 -0
  126. package/dist/src/proactive/execution/authorization.d.ts +3 -0
  127. package/dist/src/proactive/execution/authorization.js +23 -0
  128. package/dist/src/proactive/execution/context.js +2 -11
  129. package/dist/src/proactive/execution/insight.d.ts +7 -0
  130. package/dist/src/proactive/execution/insight.js +33 -2
  131. package/dist/src/proactive/execution/repository.d.ts +2 -0
  132. package/dist/src/proactive/execution/repository.js +38 -4
  133. package/dist/src/proactive/execution/types.d.ts +5 -0
  134. package/dist/src/proactive/execution/worker.js +38 -7
  135. package/dist/src/proactive/inbox/cards.d.ts +21 -0
  136. package/dist/src/proactive/inbox/cards.js +237 -0
  137. package/dist/src/proactive/inbox/delivery.d.ts +6 -0
  138. package/dist/src/proactive/inbox/delivery.js +52 -0
  139. package/dist/src/proactive/inbox/digest.d.ts +8 -0
  140. package/dist/src/proactive/inbox/digest.js +112 -0
  141. package/dist/src/proactive/inbox/lifecycle.d.ts +4 -0
  142. package/dist/src/proactive/inbox/lifecycle.js +58 -0
  143. package/dist/src/proactive/inbox/notification-policy.d.ts +1 -0
  144. package/dist/src/proactive/inbox/notification-policy.js +20 -0
  145. package/dist/src/proactive/inbox/repository.d.ts +1 -0
  146. package/dist/src/proactive/inbox/repository.js +68 -11
  147. package/dist/src/proactive/inbox/types.d.ts +9 -1
  148. package/dist/src/proactive/inbox/worker.js +9 -3
  149. package/dist/src/proactive/index.js +1 -1
  150. package/dist/src/proactive/maintenance.js +7 -0
  151. package/dist/src/proactive/metrics.d.ts +10 -0
  152. package/dist/src/proactive/metrics.js +27 -0
  153. package/dist/src/proactive/policy/presence.d.ts +2 -0
  154. package/dist/src/proactive/policy/presence.js +27 -0
  155. package/dist/src/proactive/policy/service.d.ts +53 -0
  156. package/dist/src/proactive/policy/service.js +122 -0
  157. package/dist/src/proactive/routing/matcher.js +3 -2
  158. package/dist/src/proactive/scenarios/control.d.ts +90 -0
  159. package/dist/src/proactive/scenarios/control.js +109 -0
  160. package/dist/src/proactive/scenarios/preview.d.ts +13 -0
  161. package/dist/src/proactive/scenarios/preview.js +81 -0
  162. package/dist/src/proactive/scenarios/prompt-composer.js +2 -2
  163. package/dist/src/proactive/scenarios/repository.js +5 -1
  164. package/dist/src/proactive/temporal/schedule.d.ts +3 -0
  165. package/dist/src/proactive/temporal/schedule.js +67 -0
  166. package/dist/src/proactive/temporal/worker.js +8 -4
  167. package/dist/src/storage/sqlite/migrations/159_proactive_controls.sql +68 -0
  168. package/dist/src/storage/sqlite/migrations/160_proactive_web_push.sql +27 -0
  169. package/dist/src/storage/sqlite/migrations/161_proactive_delivery_and_lifecycle.sql +51 -0
  170. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  171. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  172. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  173. package/dist/src/storage/sqlite/schema.js +1 -1
  174. package/dist/src/tui/tui-startup-resources.js +1 -1
  175. package/dist/src/voice/realtime/runtime.d.ts +2 -1
  176. package/dist/src/voice/realtime/runtime.js +21 -5
  177. package/dist/src/workflows/domain/run.d.ts +1 -0
  178. package/dist/src/workflows/index.js +2 -2
  179. package/dist/src/workflows/service/workflow-run-service.d.ts +3 -0
  180. package/dist/src/workflows/service/workflow-run-service.js +26 -5
  181. package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -0
  182. package/package.json +6 -4
  183. package/dist/gateway/static/root/assets/agents-BJuTIRPD.js +0 -1
  184. package/dist/gateway/static/root/assets/apps-page-Cz4d7ErX.js +0 -1
  185. package/dist/gateway/static/root/assets/automations-workspace-Bn8nwUOL.js +0 -6
  186. package/dist/gateway/static/root/assets/browser-settings-page-B9RA6x4x.js +0 -8
  187. package/dist/gateway/static/root/assets/capabilities-settings-panel-C1GUih8m.js +0 -7
  188. package/dist/gateway/static/root/assets/channels-settings-CEhVLJNa.js +0 -1
  189. package/dist/gateway/static/root/assets/connectors-page-IQAQDSmO.js +0 -2
  190. package/dist/gateway/static/root/assets/gateway-settings-B3H7Vfbh.js +0 -1
  191. package/dist/gateway/static/root/assets/home-page-CT4JL2jm.js +0 -1
  192. package/dist/gateway/static/root/assets/index-CRJrO4GI.css +0 -2
  193. package/dist/gateway/static/root/assets/local-app-workbench-page-qwLuir8A.js +0 -2
  194. package/dist/gateway/static/root/assets/logs-page-DrNaaPWc.js +0 -2
  195. package/dist/gateway/static/root/assets/note-detail-panel-Dbj5OvXE.js +0 -5
  196. package/dist/gateway/static/root/assets/notes-page-5hRB3WXc.js +0 -8
  197. package/dist/gateway/static/root/assets/project-detail-page-CblWLA8k.js +0 -1
  198. package/dist/gateway/static/root/assets/projects-page-CGk-kzqs.js +0 -1
  199. package/dist/gateway/static/root/assets/remote-access-hub-Du8PweyU.js +0 -1
  200. package/dist/gateway/static/root/assets/sessions-page-BFm94dJC.js +0 -1
  201. package/dist/gateway/static/root/assets/settings-advanced-gate-C0H-cToA.js +0 -1
  202. package/dist/gateway/static/root/assets/shares-settings-CqF9s0pl.js +0 -1
  203. package/dist/gateway/static/root/assets/skill-reload-api-BBL_ZUSC.js +0 -1
  204. package/dist/gateway/static/root/assets/task-detail-page-D1FmRFIn.js +0 -1
  205. package/dist/gateway/static/root/assets/user-model-page-BGC_5baJ.js +0 -2
  206. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BfCWdw8F.js +0 -3
  207. package/dist/gateway/static/root/assets/workflows-page-CvmKQkD0.js +0 -6
@@ -147,6 +147,7 @@ var VoiceRealtimeRuntime = class {
147
147
  preauthBudget = createPreauthConnectionBudget();
148
148
  socketsByPrincipal = /* @__PURE__ */ new Map();
149
149
  conversationReservations = /* @__PURE__ */ new Map();
150
+ activeSessions = /* @__PURE__ */ new Map();
150
151
  closed = false;
151
152
  constructor(options) {
152
153
  this.options = options;
@@ -263,7 +264,9 @@ var VoiceRealtimeRuntime = class {
263
264
  };
264
265
  }
265
266
  handleUpgrade(req, socket, head) {
266
- if (new URL(req.url ?? "/", "http://gateway.local").pathname !== "/api/voice/realtime/v3/ws") return false;
267
+ const url = new URL(req.url ?? "/", "http://gateway.local");
268
+ const pathAndQuery = `${url.pathname}${url.search}`;
269
+ if (url.pathname !== "/api/voice/realtime/v3/ws" && pathAndQuery !== "/api/realtime/v1/ws?transport=voice-v3") return false;
267
270
  if (this.closed || this.wss.clients.size >= MAX_CONNECTIONS) {
268
271
  socket.destroy();
269
272
  return true;
@@ -285,12 +288,17 @@ var VoiceRealtimeRuntime = class {
285
288
  this.pruneTickets(Date.now());
286
289
  return this.conversationReservations.has(sessionKey);
287
290
  }
288
- cancelSession(sessionId, ticket, principalId) {
291
+ async cancelSession(sessionId, ticket, principalId) {
289
292
  const key = ticketKey(ticket);
290
293
  const claim = this.tickets.get(key);
291
- if (!claim || claim.sessionId !== sessionId || claim.principalId !== principalId) return false;
292
- this.tickets.delete(key);
293
- this.releaseConversationReservation(claim);
294
+ if (claim && claim.sessionId === sessionId && claim.principalId === principalId) {
295
+ this.tickets.delete(key);
296
+ this.releaseConversationReservation(claim);
297
+ return true;
298
+ }
299
+ const active = this.activeSessions.get(sessionId);
300
+ if (!active || active.principalId !== principalId || active.ticketKey !== key) return false;
301
+ await active.shutdown();
294
302
  return true;
295
303
  }
296
304
  close() {
@@ -298,6 +306,7 @@ var VoiceRealtimeRuntime = class {
298
306
  this.closed = true;
299
307
  for (const client of this.wss.clients) client.close(1001, "Gateway stopping");
300
308
  this.tickets.clear();
309
+ this.activeSessions.clear();
301
310
  this.wss.close();
302
311
  this.socketsByPrincipal.clear();
303
312
  this.conversationReservations.clear();
@@ -362,6 +371,7 @@ var VoiceRealtimeRuntime = class {
362
371
  const shutdown = async (reason, notify) => {
363
372
  if (closed) return;
364
373
  closed = true;
374
+ if (claim && this.activeSessions.get(claim.sessionId)?.socket === socket) this.activeSessions.delete(claim.sessionId);
365
375
  unsubscribeMemory?.();
366
376
  unsubscribeSession?.();
367
377
  clearTimeout(startTimer);
@@ -418,6 +428,12 @@ var VoiceRealtimeRuntime = class {
418
428
  return;
419
429
  }
420
430
  claim = consumed;
431
+ this.activeSessions.set(consumed.sessionId, {
432
+ principalId: consumed.principalId,
433
+ socket,
434
+ ticketKey: ticketKey(message.payload.ticket),
435
+ shutdown: () => shutdown("cancelled", false)
436
+ });
421
437
  principalSockets.add(socket);
422
438
  this.socketsByPrincipal.set(consumed.principalId, principalSockets);
423
439
  clearTimeout(startTimer);
@@ -20,6 +20,7 @@ export interface WorkflowRun {
20
20
  completedAtMs?: number;
21
21
  }
22
22
  export interface WorkflowRunMetadata {
23
+ preparationOnly?: boolean;
23
24
  sessionKey: string;
24
25
  triggerSource: WorkflowRunSource['kind'];
25
26
  agentId?: string;
@@ -10,10 +10,10 @@ import { WorkflowEngine } from "./engine/workflow-engine.js";
10
10
  import "./engine/index.js";
11
11
  import { WorkflowEventStore, createWorkflowEventStore } from "./store/event-store.js";
12
12
  import { WorkflowRunStore, createWorkflowRunStore } from "./store/run-store.js";
13
- import { WorkflowRunService, buildWorkflowRunDefinitionSnapshot, buildWorkflowRunInputEnvelope, buildWorkflowRunMetadata, extractWorkflowRunSessionKey, resolveWorkflowReplayTargets } from "./service/workflow-run-service.js";
13
+ import { WorkflowRunService, buildWorkflowRunDefinitionSnapshot, buildWorkflowRunInputEnvelope, buildWorkflowRunMetadata, extractWorkflowRunSessionKey, preparationDefinition, resolveWorkflowReplayTargets } from "./service/workflow-run-service.js";
14
14
  import { runViewToSnapshot } from "./service/run-view-to-snapshot.js";
15
15
  import { buildWorkflowRunSessionKey, readWorkflowRunIdFromSessionCustomData } from "./service/workflow-session-key.js";
16
16
  import { WORKFLOW_RUN_LINK_CONTEXT_KIND, WORKFLOW_SESSION_TYPE, WorkflowSessionBridge, formatParentRunLinkText } from "./service/workflow-session-bridge.js";
17
17
  import "./registry/index.js";
18
18
  import { resolveWorkflowRootDir, resolveWorkflowRunArtifactsDir, resolveWorkflowRunDir, resolveWorkflowRunsDir } from "./store/paths.js";
19
- export { CatalogWorkflowDefinitionRegistry, DEFAULT_WORKFLOW_CONCURRENCY, DEFAULT_WORKFLOW_MAX_SUBAGENTS, DEFAULT_WORKFLOW_TIMEOUT_SEC, GraphWorkflowRuntime, WORKFLOW_RUN_LINK_CONTEXT_KIND, WORKFLOW_SESSION_TYPE, WorkflowEngine, WorkflowEventStore, WorkflowRunService, WorkflowRunStore, WorkflowSessionBridge, buildWorkflowDefinition, buildWorkflowRunDefinitionSnapshot, buildWorkflowRunInputEnvelope, buildWorkflowRunMetadata, buildWorkflowRunSessionKey, createGraphWorkflowRuntime, createWorkflowEventStore, createWorkflowRunStore, deriveWorkflowPhases, extractWorkflowRunSessionKey, formatParentRunLinkText, hashWorkflowStableValue, isTerminalWorkflowRunStatus, normalizeWorkflowDefinitionId, projectWorkflowRunView, readWorkflowRunIdFromSessionCustomData, renderWorkflowTemplate, resolveWorkflowReplayTargets, resolveWorkflowRootDir, resolveWorkflowRunArtifactsDir, resolveWorkflowRunDir, resolveWorkflowRunsDir, runViewToSnapshot, toWorkflowDefinitionTitle, validateWorkflowDefinitionInput, validateWorkflowGraph, validateWorkflowJsonSchema };
19
+ export { CatalogWorkflowDefinitionRegistry, DEFAULT_WORKFLOW_CONCURRENCY, DEFAULT_WORKFLOW_MAX_SUBAGENTS, DEFAULT_WORKFLOW_TIMEOUT_SEC, GraphWorkflowRuntime, WORKFLOW_RUN_LINK_CONTEXT_KIND, WORKFLOW_SESSION_TYPE, WorkflowEngine, WorkflowEventStore, WorkflowRunService, WorkflowRunStore, WorkflowSessionBridge, buildWorkflowDefinition, buildWorkflowRunDefinitionSnapshot, buildWorkflowRunInputEnvelope, buildWorkflowRunMetadata, buildWorkflowRunSessionKey, createGraphWorkflowRuntime, createWorkflowEventStore, createWorkflowRunStore, deriveWorkflowPhases, extractWorkflowRunSessionKey, formatParentRunLinkText, hashWorkflowStableValue, isTerminalWorkflowRunStatus, normalizeWorkflowDefinitionId, preparationDefinition, projectWorkflowRunView, readWorkflowRunIdFromSessionCustomData, renderWorkflowTemplate, resolveWorkflowReplayTargets, resolveWorkflowRootDir, resolveWorkflowRunArtifactsDir, resolveWorkflowRunDir, resolveWorkflowRunsDir, runViewToSnapshot, toWorkflowDefinitionTitle, validateWorkflowDefinitionInput, validateWorkflowGraph, validateWorkflowJsonSchema };
@@ -37,6 +37,7 @@ export declare class WorkflowRunService {
37
37
  }
38
38
  export declare function buildWorkflowRunInputEnvelope(input: unknown, goal?: string): WorkflowRunInputEnvelope;
39
39
  export declare function buildWorkflowRunMetadata(params: {
40
+ preparationOnly?: boolean;
40
41
  definition: WorkflowDefinition;
41
42
  agentId: string;
42
43
  taskRunId?: string;
@@ -57,3 +58,5 @@ export declare function resolveWorkflowReplayTargets(view: WorkflowRunView, scop
57
58
  };
58
59
  export declare function buildWorkflowRunDefinitionSnapshot(definition: WorkflowDefinition): WorkflowRunDefinitionSnapshot;
59
60
  export declare function extractWorkflowRunSessionKey(source: WorkflowRunSource): string | null;
61
+ /** Preparation runs can only transform supplied context into a reviewable result. */
62
+ export declare function preparationDefinition(original: WorkflowDefinition): WorkflowDefinition;
@@ -97,13 +97,14 @@ var WorkflowRunService = class {
97
97
  message: `Workflow "${params.definitionId}" is not allowed for this agent`,
98
98
  httpStatus: 409
99
99
  };
100
- const definition = await this.loadDefinition(params.definitionId);
100
+ let definition = await this.loadDefinition(params.definitionId);
101
101
  if (!definition) return {
102
102
  ok: false,
103
103
  code: "definition_not_found",
104
104
  message: "Workflow definition not found",
105
105
  httpStatus: 404
106
106
  };
107
+ if (params.preparationOnly) definition = preparationDefinition(definition);
107
108
  const connectorPreflight = preflightWorkflowConnectors({
108
109
  definition,
109
110
  config: this.options.service.currentConfig,
@@ -174,7 +175,7 @@ var WorkflowRunService = class {
174
175
  const contextRefs = resolvedContext ? [...resolvedContext.refs, ...passiveContextRefs] : requestedContextRefs;
175
176
  let writebackPolicy;
176
177
  try {
177
- writebackPolicy = resolveWorkflowWritebackPolicy(params.writebackPolicy, {
178
+ writebackPolicy = resolveWorkflowWritebackPolicy(params.preparationOnly ? { targets: [] } : params.writebackPolicy, {
178
179
  projectId,
179
180
  taskId
180
181
  });
@@ -252,6 +253,7 @@ var WorkflowRunService = class {
252
253
  source,
253
254
  metadata: buildWorkflowRunMetadata({
254
255
  definition,
256
+ preparationOnly: params.preparationOnly,
255
257
  agentId: params.agentId,
256
258
  taskRunId: params.taskRunId,
257
259
  projectId,
@@ -299,6 +301,7 @@ var WorkflowRunService = class {
299
301
  return this.startWorkflowRun({
300
302
  agentId: params.agentId,
301
303
  definitionId: existing.run.definitionId,
304
+ preparationOnly: existing.run.metadata?.preparationOnly,
302
305
  taskRunId: existing.run.metadata?.taskRunId,
303
306
  projectId,
304
307
  contextRefs: existing.run.metadata?.contextRefs,
@@ -320,14 +323,18 @@ var WorkflowRunService = class {
320
323
  message: "Workflow run not found",
321
324
  httpStatus: 404
322
325
  };
323
- const definition = await this.loadDefinition(existing.run.definitionId);
326
+ let definition = await this.loadDefinition(existing.run.definitionId);
324
327
  if (!definition) return {
325
328
  ok: false,
326
329
  code: "definition_not_found",
327
330
  message: "Workflow definition not found",
328
331
  httpStatus: 404
329
332
  };
333
+ if (existing.run.metadata?.preparationOnly) definition = preparationDefinition(definition);
330
334
  const targets = resolveWorkflowReplayTargets(existing, params.scope);
335
+ if (existing.run.metadata?.preparationOnly) {
336
+ for (const target of targets.targets) if (target.invocation) target.invocation.toolset = [];
337
+ }
331
338
  if (targets.targets.length === 0) return {
332
339
  ok: false,
333
340
  code: "invalid_state",
@@ -412,6 +419,7 @@ var WorkflowRunService = class {
412
419
  source,
413
420
  metadata: buildWorkflowRunMetadata({
414
421
  definition,
422
+ preparationOnly: existing.run.metadata?.preparationOnly,
415
423
  agentId: params.agentId,
416
424
  taskRunId,
417
425
  projectId,
@@ -637,12 +645,13 @@ function buildWorkflowRunMetadata(params) {
637
645
  taskId,
638
646
  source: params.source
639
647
  });
640
- const writebackPolicy = resolveWorkflowWritebackPolicy(params.writebackPolicy, {
648
+ const writebackPolicy = resolveWorkflowWritebackPolicy(params.preparationOnly ? { targets: [] } : params.writebackPolicy, {
641
649
  projectId,
642
650
  taskId
643
651
  });
644
652
  return {
645
653
  sessionKey: params.sessionKey,
654
+ ...params.preparationOnly ? { preparationOnly: true } : {},
646
655
  triggerSource: params.source.kind,
647
656
  agentId: params.agentId,
648
657
  projectId,
@@ -791,5 +800,17 @@ function isWorkflowRunInputEnvelope(input) {
791
800
  if (!input || typeof input !== "object" || Array.isArray(input)) return false;
792
801
  return "payload" in input || "variables" in input || "context" in input;
793
802
  }
803
+ /** Preparation runs can only transform supplied context into a reviewable result. */
804
+ function preparationDefinition(original) {
805
+ const definition = structuredClone(original);
806
+ for (const node of definition.graph.nodes) if (node.kind === "agent") node.config.toolset = [];
807
+ definition.permissions = {
808
+ tools: [],
809
+ network: false,
810
+ fileSystem: "none"
811
+ };
812
+ definition.connectors = [];
813
+ return definition;
814
+ }
794
815
  //#endregion
795
- export { WorkflowRunService, buildWorkflowRunDefinitionSnapshot, buildWorkflowRunInputEnvelope, buildWorkflowRunMetadata, extractWorkflowRunSessionKey, resolveWorkflowReplayTargets };
816
+ export { WorkflowRunService, buildWorkflowRunDefinitionSnapshot, buildWorkflowRunInputEnvelope, buildWorkflowRunMetadata, extractWorkflowRunSessionKey, preparationDefinition, resolveWorkflowReplayTargets };
@@ -1,5 +1,6 @@
1
1
  import type { WorkflowRunInputEnvelope, WorkflowRunContextRef, WorkflowRunReplayScope, WorkflowRunSource, WorkflowRunWritebackPolicy, WorkflowRunView } from '../domain/index.js';
2
2
  export interface StartWorkflowRunServiceParams {
3
+ preparationOnly?: boolean;
3
4
  agentId: string;
4
5
  definitionId: string;
5
6
  taskRunId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xopcai/xopc",
3
- "version": "0.0.268",
3
+ "version": "0.0.269",
4
4
  "description": "Local-first personal AI assistant with reviewable user understanding, durable tasks, workflows, automations, and local or cloud models.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -104,6 +104,7 @@
104
104
  "thread-stream": "^4.2.0",
105
105
  "undici": "^8.9.0",
106
106
  "uuid": "^14.0.0",
107
+ "web-push": "^3.6.7",
107
108
  "ws": "^8.21.0",
108
109
  "zod": "^4.4.3"
109
110
  },
@@ -138,6 +139,7 @@
138
139
  "@types/markdown-it": "^14.1.2",
139
140
  "@types/node": "^25.9.1",
140
141
  "@types/qrcode-terminal": "^0.12.2",
142
+ "@types/web-push": "^3.6.4",
141
143
  "@types/ws": "^8.18.1",
142
144
  "@vitejs/plugin-react-swc": "^4.3.1",
143
145
  "cross-env": "^10.1.0",
@@ -164,10 +166,10 @@
164
166
  "vitest": "4.1.5",
165
167
  "vue": "^3.5.35",
166
168
  "@xopcai/browser-control-contract": "0.1.0",
167
- "@xopcai/gateway-contract": "0.0.0",
168
169
  "@xopcai/endpoint-tools-protocol": "0.0.0",
169
- "@xopcai/realtime-protocol": "0.0.0",
170
- "@xopcai/realtime-client": "0.0.0"
170
+ "@xopcai/gateway-contract": "0.0.0",
171
+ "@xopcai/realtime-client": "0.0.0",
172
+ "@xopcai/realtime-protocol": "0.0.0"
171
173
  },
172
174
  "scripts": {
173
175
  "assets:brand": "node scripts/generate-brand-assets.mjs",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./plus-Q2yW6OE7.js";import{t as m}from"./x-B_N4OPjy.js";import{n as h,s as g}from"./locale-store-DFQX9kTl.js";import{t as _}from"./cn-JdwAhgNB.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-B11EPpor.js";import{t as b}from"./skeleton-BwbyijEw.js";import{i as x,o as S}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as C}from"./settings-shell-layer-context-DCp6ykjQ.js";import{El as w,Is as T,P as E,Uc as D,Vs as O,_c as k,in as A,nc as j,nn as M,rn as N,ro as P,tn as F,ya as I,yu as L}from"./index-wKE8Q2FX.js";import{r as R}from"./settings-page-layout-DYelDcMV.js";var z=n(),B=e(t(),1),V=r(),ee=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],H=`w-full rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function U(e){return[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))]}function W(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function G(e){let t=(0,z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,V.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[10px] font-medium text-accent`,children:n}),t[0]=n,t[1]=r),r}function K(e){let t=(0,z.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,V.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,V.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,V.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==i||t[8]!==s?(c=(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[s,i]}),t[7]=i,t[8]=s,t[9]=c):c=t[9],c}function q(e){let t=(0,z.c)(10),{label:n,value:r,detail:i}=e,a;t[0]===n?a=t[1]:(a=(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,V.jsx)(`p`,{className:`mt-2 truncate text-sm font-semibold text-fg`,title:r,children:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,V.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function J(e){let t=(0,z.c)(56),{label:n,inherited:r,value:i,zh:a,allowChatFallback:o,allowDisabled:s,onChange:c}=e,l=o===void 0?!1:o,u=s===void 0?!1:s,d=i!=null,f;t[0]===n?f=t[1]:(f=(0,V.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=f);let p;t[2]!==i||t[3]!==a?(p=i===void 0?(0,V.jsx)(G,{children:a?`继承`:`Inherited`}):null,t[2]=i,t[3]=a,t[4]=p):p=t[4];let m;t[5]!==u||t[6]!==i||t[7]!==a?(m=i===null?(0,V.jsx)(G,{children:u?a?`已禁用`:`Disabled`:a?`使用 Chat`:`Uses Chat`}):null,t[5]=u,t[6]=i,t[7]=a,t[8]=m):m=t[8];let h;t[9]!==f||t[10]!==p||t[11]!==m?(h=(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,p,m]}),t[9]=f,t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]!==r?.primary||t[14]!==i||t[15]!==a?(g=i===void 0?(0,V.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-muted`,children:r?.primary??(a?`全局未配置`:`Not configured globally`)}):null,t[13]=r?.primary,t[14]=i,t[15]=a,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==c||t[21]!==i||t[22]!==a?(v=i===void 0?null:(0,V.jsx)(y,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>c(void 0),children:a?`继承`:`Inherit`}),t[20]=c,t[21]=i,t[22]=a,t[23]=v):v=t[23];let b;t[24]!==l||t[25]!==c||t[26]!==i||t[27]!==a?(b=l&&i!==null?(0,V.jsx)(y,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>c(null),children:a?`使用 Chat`:`Use Chat`}):null,t[24]=l,t[25]=c,t[26]=i,t[27]=a,t[28]=b):b=t[28];let x;t[29]!==u||t[30]!==c||t[31]!==i||t[32]!==a?(x=u&&i!==null?(0,V.jsx)(y,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>c(null),children:a?`禁用`:`Disable`}):null,t[29]=u,t[30]=c,t[31]=i,t[32]=a,t[33]=x):x=t[33];let S;t[34]!==d||t[35]!==r?.fallbacks||t[36]!==r?.primary||t[37]!==c||t[38]!==a?(S=d?null:(0,V.jsx)(y,{className:`px-2 py-1 text-xs`,onClick:()=>c({primary:r?.primary??``,fallbacks:[...r?.fallbacks??[]]}),children:a?`自定义`:`Customize`}),t[34]=d,t[35]=r?.fallbacks,t[36]=r?.primary,t[37]=c,t[38]=a,t[39]=S):S=t[39];let C;t[40]!==b||t[41]!==x||t[42]!==S||t[43]!==v?(C=(0,V.jsxs)(`div`,{className:`flex gap-1`,children:[v,b,x,S]}),t[40]=b,t[41]=x,t[42]=S,t[43]=v,t[44]=C):C=t[44];let w;t[45]!==C||t[46]!==_?(w=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[_,C]}),t[45]=C,t[46]=_,t[47]=w):w=t[47];let T;t[48]!==d||t[49]!==c||t[50]!==i||t[51]!==a?(T=d?(0,V.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,0.8fr)]`,children:[(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[a?`主模型`:`Primary model`,(0,V.jsx)(`input`,{className:`${H} mt-1.5 font-mono`,value:i.primary,onChange:e=>c({...i,primary:e.target.value})})]}),(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[a?`回退模型`:`Fallbacks`,(0,V.jsx)(`input`,{className:`${H} mt-1.5 font-mono`,value:i.fallbacks.join(`, `),onChange:e=>c({...i,fallbacks:U(e.target.value)}),placeholder:a?`逗号分隔`:`Comma separated`})]})]}):null,t[48]=d,t[49]=c,t[50]=i,t[51]=a,t[52]=T):T=t[52];let E;return t[53]!==w||t[54]!==T?(E=(0,V.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[w,T]}),t[53]=w,t[54]=T,t[55]=E):E=t[55],E}function Y(e){return Object.values(e).some(e=>e!==void 0)?e:void 0}function X({agent:e,toolIds:t,zh:n,externalError:r,onDirtyChange:i,onClose:a,onOpenDefaults:o,onChat:s,onDelete:c}){let[l,u]=(0,B.useState)(`overview`),[d,f]=(0,B.useState)(()=>structuredClone(e.override)),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),v=JSON.stringify(d)!==JSON.stringify(e.override),b=[d.models?.chat,...Object.values(d.models?.intents??{}),d.models?.imageUnderstanding,d.models?.imageGeneration].some(e=>e!=null&&!e.primary.trim());(0,B.useEffect)(()=>i(v),[v,i]);let x=(0,B.useMemo)(()=>[...new Set([...t,...Object.keys(e.effective.tools),...Object.keys(d.tools??{})])].sort(),[e.effective.tools,d.tools,t]),S=[d.models?n?`模型`:`Models`:null,d.skills?n?`技能`:`Skills`:null,d.tools?n?`工具权限`:`Tool access`:null,d.runtime||d.workflows?n?`运行限制`:`Runtime`:null].filter(e=>!!e),C=Object.values(e.effective.tools).filter(e=>e.mode===`deny`).length,E=e.effective.skills.mode===`selected`?n?`${e.effective.skills.include.length} 个已选技能`:`${e.effective.skills.include.length} selected skills`:n?`所有已启用技能`:`All enabled skills`,M=async()=>{m(!0),g(null);try{let t=(await A(e.id,{workspace:d.workspace??null,profile:d.profile,models:d.models??null,skills:d.skills??null,tools:d.tools??null,workflows:d.workflows??null,runtime:d.runtime??null})).agents.find(t=>t.id===e.id);t&&f(structuredClone(t.override))}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},N=async()=>{m(!0),g(null);try{await A(e.id,{setDefault:!0})}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},P=(e,t)=>{let n={...d.tools??{}};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},f({...d,tools:Object.keys(n).length>0?n:void 0})},F=(e,t)=>{let n={...d.models??{}},r={...n.intents??{}};t===void 0?delete r[e]:r[e]=t,Object.keys(r).length>0?n.intents=r:delete n.intents,f({...d,models:Object.keys(n).length>0?n:void 0})};return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row`,children:[(0,V.jsx)(`aside`,{className:`shrink-0 overflow-x-auto border-b border-edge px-3 py-3 sm:w-52 sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-3 sm:py-4`,children:(0,V.jsx)(`nav`,{className:`flex gap-1 sm:flex-col`,children:[{id:`overview`,label:n?`概览`:`Overview`,icon:w},{id:`profile`,label:n?`个性`:`Profile`,icon:T},{id:`models`,label:n?`模型`:`Models`,icon:j},{id:`capabilities`,label:n?`技能与工具`:`Skills & tools`,icon:L},{id:`runtime`,label:n?`运行限制`:`Runtime`,icon:w},{id:`danger`,label:n?`危险区`:`Danger zone`,icon:O}].map(({id:e,label:t,icon:n})=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:_(`flex shrink-0 items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm font-medium transition-colors`,l===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,V.jsx)(n,{className:`size-4`}),t]},e))})}),(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,V.jsxs)(`main`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:[h||r?(0,V.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h??r}):null,l===`overview`?(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(K,{title:n?`配置概览`:`Configuration overview`,description:n?`查看当前真正生效的配置。未覆盖的部分会持续跟随全局默认值。`:`Review what actually takes effect. Anything not overridden keeps following global defaults.`,action:(0,V.jsxs)(y,{onClick:s,children:[(0,V.jsx)(D,{className:`size-4`}),n?`开始对话`:`Start chat`]})}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-accent/20 bg-accent/5 p-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:S.length>0?n?`已自定义:${S.join(`、`)}`:`Customized: ${S.join(`, `)}`:n?`能力配置使用全局默认`:`Capabilities use global defaults`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:S.length>0?n?`其他能力会继续跟随全局默认配置。`:`All other capabilities continue to follow global defaults.`:n?`修改全局默认配置后,这个智能体会自动同步。`:`This agent updates automatically when global defaults change.`})]}),(0,V.jsx)(y,{onClick:o,children:n?`查看全局默认配置`:`View global defaults`})]}),(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(q,{label:n?`对话模型`:`Chat model`,value:e.effective.models.chat.primary,detail:d.models?.chat?n?`单独设置`:`Agent override`:n?`继承全局`:`Inherited globally`}),(0,V.jsx)(q,{label:n?`技能`:`Skills`,value:E,detail:d.skills?n?`单独设置`:`Agent override`:n?`继承全局`:`Inherited globally`}),(0,V.jsx)(q,{label:n?`工具权限`:`Tool access`,value:C>0?n?`${C} 个禁用`:`${C} denied`:n?`全部可用`:`All available`,detail:d.tools?n?`${Object.keys(d.tools).length} 个本地覆盖`:`${Object.keys(d.tools).length} local overrides`:n?`继承全局`:`Inherited globally`}),(0,V.jsx)(q,{label:n?`工作区`:`Workspace`,value:e.effective.workspace,detail:d.workspace?n?`单独设置`:`Agent specific`:n?`自动工作区`:`Automatic workspace`})]}),e.isDefault?null:(0,V.jsx)(y,{onClick:()=>void N(),disabled:p,children:n?`设为默认智能体`:`Make default agent`})]}):null,l===`profile`?(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(K,{title:n?`个性与工作区`:`Profile and workspace`,description:n?`只设置这个智能体独有的身份、表达方式和工作目录。`:`Keep only this agent’s identity, behavior, and workspace here.`}),(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`名称`:`Name`,(0,V.jsx)(`input`,{className:`${H} mt-1.5`,value:d.profile?.name??``,onChange:e=>f({...d,profile:{name:e.target.value,...d.profile?.instructions?{instructions:d.profile.instructions}:{}}})})]}),(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[n?`工作区`:`Workspace`,d.workspace?null:(0,V.jsx)(G,{children:n?`自动`:`Automatic`})]}),(0,V.jsx)(`input`,{className:`${H} mt-1.5 font-mono`,value:d.workspace??``,placeholder:e.effective.workspace,onChange:e=>f({...d,workspace:e.target.value||void 0})})]})]}),(0,V.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n?`个性指令`:`Personality instructions`,(0,V.jsx)(`textarea`,{rows:10,className:`${H} mt-1.5 resize-y leading-6`,value:d.profile?.instructions??``,onChange:t=>f({...d,profile:{name:d.profile?.name||e.name,instructions:t.target.value||void 0}}),placeholder:n?`描述角色、语气、判断偏好和工作方式`:`Describe the role, tone, judgment preferences, and working style`})]})]}):null,l===`models`?(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(K,{title:n?`模型路由`:`Model routing`,description:n?`日常对话使用 Chat;固定意图只在对应任务中生效。默认继承全局。`:`Chat handles normal turns; fixed intents apply only to matching work. Everything inherits by default.`,action:d.models?(0,V.jsxs)(y,{variant:`ghost`,onClick:()=>f({...d,models:void 0}),children:[(0,V.jsx)(k,{className:`size-4`}),n?`全部继承`:`Inherit all`]}):void 0}),(0,V.jsx)(J,{label:`Chat`,inherited:e.effective.models.chat,value:d.models?.chat,zh:n,onChange:e=>{let t={...d.models??{}};e?t.chat=e:delete t.chat,f({...d,models:Object.keys(t).length>0?t:void 0})}}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n?`固定意图`:`Fixed intents`}),(0,V.jsx)(`div`,{className:`space-y-3`,children:ee.map(t=>(0,V.jsx)(J,{label:t,inherited:e.effective.models.intents[t]??e.effective.models.chat,value:d.models?.intents?.[t],zh:n,allowChatFallback:!0,onChange:e=>F(t,e)},t))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n?`图片能力`:`Image capabilities`}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(J,{label:n?`图片理解`:`Image understanding`,inherited:e.effective.models.imageUnderstanding,value:d.models?.imageUnderstanding,zh:n,allowDisabled:!0,onChange:e=>{let t={...d.models??{}};e===void 0?delete t.imageUnderstanding:t.imageUnderstanding=e,f({...d,models:Object.keys(t).length>0?t:void 0})}}),(0,V.jsx)(J,{label:n?`图片生成`:`Image generation`,inherited:e.effective.models.imageGeneration,value:d.models?.imageGeneration,zh:n,allowDisabled:!0,onChange:t=>{let n={...d.models??{}};t===void 0?delete n.imageGeneration:t===null?n.imageGeneration=null:n.imageGeneration={...t,timeoutMs:d.models?.imageGeneration?.timeoutMs??e.effective.models.imageGeneration?.timeoutMs,autoProviderFallback:d.models?.imageGeneration?.autoProviderFallback??e.effective.models.imageGeneration?.autoProviderFallback??!0},f({...d,models:Object.keys(n).length>0?n:void 0})}}),d.models?.imageGeneration?(0,V.jsxs)(`div`,{className:`grid gap-4 rounded-2xl border border-edge bg-surface-base p-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,V.jsx)(`input`,{type:`number`,min:1,className:`${H} mt-1.5`,value:d.models.imageGeneration.timeoutMs??``,onChange:e=>f({...d,models:{...d.models,imageGeneration:{...d.models.imageGeneration,timeoutMs:W(e.target.value)}}})})]}),(0,V.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,V.jsx)(`span`,{children:n?`提供商自动回退`:`Automatic provider fallback`}),(0,V.jsx)(`div`,{className:`mt-1.5 flex rounded-xl bg-surface-hover p-1`,children:[!0,!1].map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>f({...d,models:{...d.models,imageGeneration:{...d.models.imageGeneration,autoProviderFallback:e}}}),className:_(`flex-1 rounded-lg px-3 py-2 text-xs font-medium`,d.models?.imageGeneration?.autoProviderFallback===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted`),children:e?n?`开启`:`On`:n?`关闭`:`Off`},String(e)))})]})]}):null]})]})]}):null,l===`capabilities`?(0,V.jsxs)(`div`,{className:`space-y-7`,children:[(0,V.jsx)(K,{title:n?`技能与工具`:`Skills and tools`,description:n?`默认继承全局能力;只设置确实不同的部分。`:`Keep inheritance for global capabilities; override only agents that genuinely differ.`}),(0,V.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`技能策略`:`Skill policy`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:d.skills?n?`当前使用单独设置`:`Using an agent override`:n?`当前继承全局`:`Currently inherited globally`})]}),d.skills?(0,V.jsxs)(y,{variant:`ghost`,onClick:()=>f({...d,skills:void 0}),children:[(0,V.jsx)(k,{className:`size-4`}),n?`继承`:`Inherit`]}):null]}),(0,V.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,V.jsx)(y,{variant:d.skills?.mode===`merge`?`primary`:`secondary`,onClick:()=>f({...d,skills:{mode:`merge`,add:[],remove:[]}}),children:`Merge`}),(0,V.jsx)(y,{variant:d.skills?.mode===`replace`?`primary`:`secondary`,onClick:()=>f({...d,skills:{mode:`replace`,include:[]}}),children:`Replace`})]}),d.skills?.mode===`merge`?(0,V.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`新增技能`:`Add skills`,(0,V.jsx)(`input`,{className:`${H} mt-1.5`,value:d.skills.add.join(`, `),onChange:e=>f({...d,skills:{mode:`merge`,add:U(e.target.value),remove:d.skills?.mode===`merge`?d.skills.remove:[]}})})]}),(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`移除技能`:`Remove skills`,(0,V.jsx)(`input`,{className:`${H} mt-1.5`,value:d.skills.remove.join(`, `),onChange:e=>f({...d,skills:{mode:`merge`,add:d.skills?.mode===`merge`?d.skills.add:[],remove:U(e.target.value)}})})]})]}):null,d.skills?.mode===`replace`?(0,V.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[n?`仅启用这些技能`:`Enable only these skills`,(0,V.jsx)(`input`,{className:`${H} mt-1.5`,value:d.skills.include.join(`, `),onChange:e=>f({...d,skills:{mode:`replace`,include:U(e.target.value)}})})]}):null]}),(0,V.jsxs)(`section`,{children:[(0,V.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`工具权限`:`Tool permissions`}),d.tools?(0,V.jsxs)(y,{variant:`ghost`,onClick:()=>f({...d,tools:void 0}),children:[(0,V.jsx)(k,{className:`size-4`}),n?`全部继承`:`Inherit all`]}):null]}),(0,V.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-2xl border border-edge bg-surface-base`,children:x.map(t=>{let r=d.tools?.[t]?.mode,i=e.effective.tools[t]?.mode??`allow`;return(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`code`,{className:`text-xs text-fg`,children:t}),(0,V.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:r?n?`单独设置`:`Agent override`:`${n?`继承`:`Inherits`} ${i}`})]}),(0,V.jsx)(`div`,{className:`flex rounded-xl bg-surface-hover p-1`,children:[`inherit`,`allow`,`ask`,`deny`].map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>P(t,e),className:_(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,(e===`inherit`?!r:r===e)?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),children:e},e))})]},t)})})]})]}):null,l===`runtime`?(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(K,{title:n?`运行限制`:`Runtime limits`,description:n?`留空即继承全局限制。`:`Leave blank to inherit global limits. Use overrides only to tighten or relax a specialist agent.`,action:d.runtime||d.workflows?(0,V.jsxs)(y,{variant:`ghost`,onClick:()=>f({...d,runtime:void 0,workflows:void 0}),children:[(0,V.jsx)(k,{className:`size-4`}),n?`全部继承`:`Inherit all`]}):void 0}),(0,V.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[[`maxTurns`,n?`单次最大轮数`:`Maximum turns`],[`timeoutMs`,n?`单轮超时(毫秒)`:`Turn timeout (ms)`],[`maxToolFailuresPerTurn`,n?`最大工具失败次数`:`Maximum tool failures`]].map(([t,r])=>(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r,d.runtime?.[t]===void 0?(0,V.jsx)(G,{children:n?`继承`:`Inherited`}):null]}),(0,V.jsx)(`input`,{type:`number`,min:1,className:`${H} mt-1.5`,value:d.runtime?.[t]??``,placeholder:String(e.effective.runtime[t]??``),onChange:e=>{let n=Y({...d.runtime??{},[t]:W(e.target.value)});f({...d,runtime:n})}})]},t))}),(0,V.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`工作流`:`Workflows`}),(0,V.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`默认工作流`:`Default workflow`,(0,V.jsx)(`input`,{className:`${H} mt-1.5`,value:d.workflows?.default??``,placeholder:e.effective.workflows.default,onChange:e=>{let t=Y({...d.workflows??{},default:e.target.value||void 0});f({...d,workflows:t})}})]}),(0,V.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`允许的工作流`:`Allowed workflows`,(0,V.jsx)(`input`,{className:`${H} mt-1.5`,value:d.workflows?.allowed?.join(`, `)??``,placeholder:e.effective.workflows.allowed?.join(`, `),onChange:e=>{let t=U(e.target.value),n=Y({...d.workflows??{},allowed:t.length>0?t:void 0});f({...d,workflows:n})}})]})]})]}),(0,V.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`提示词缓存`:`Prompt cache`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:d.runtime?.promptCache?n?`使用单独设置`:`Using agent override`:n?`继承全局`:`Inherited globally`})]}),d.runtime?.promptCache?(0,V.jsxs)(y,{variant:`ghost`,onClick:()=>{let e=Y({...d.runtime??{},promptCache:void 0});f({...d,runtime:e})},children:[(0,V.jsx)(k,{className:`size-4`}),n?`继承`:`Inherit`]}):null]}),d.runtime?.promptCache?(0,V.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,V.jsx)(`span`,{children:n?`模式`:`Mode`}),(0,V.jsx)(`div`,{className:`mt-1.5 flex rounded-xl bg-surface-hover p-1`,children:[`auto`,`off`].map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>f({...d,runtime:{...d.runtime,promptCache:{...d.runtime.promptCache,mode:e}}}),className:_(`flex-1 rounded-lg px-3 py-2 text-xs font-medium`,d.runtime?.promptCache?.mode===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted`),children:e},e))})]}),(0,V.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,V.jsx)(`span`,{children:n?`缓存周期`:`Lifetime`}),(0,V.jsx)(`div`,{className:`mt-1.5 flex rounded-xl bg-surface-hover p-1`,children:[`short`,`long`].map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>f({...d,runtime:{...d.runtime,promptCache:{...d.runtime.promptCache,lifetime:e}}}),className:_(`flex-1 rounded-lg px-3 py-2 text-xs font-medium`,d.runtime?.promptCache?.lifetime===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted`),children:e},e))})]})]}):(0,V.jsx)(y,{className:`mt-4`,onClick:()=>f({...d,runtime:{...d.runtime,promptCache:{...e.effective.runtime.promptCache??{mode:`auto`,lifetime:`short`}}}}),children:n?`自定义缓存策略`:`Customize cache policy`})]})]}):null,l===`danger`?(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(K,{title:n?`危险区`:`Danger zone`,description:n?`这些操作会改变默认路由或移除智能体。`:`These actions change default routing or remove the agent.`}),e.isDefault?null:(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`设为默认智能体`:`Make default agent`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`新会话和未指定路由将使用这个智能体。`:`New sessions and unspecified routes will use this agent.`})]}),(0,V.jsx)(y,{disabled:p,onClick:()=>void N(),children:n?`设为默认`:`Make default`})]}),e.isDefault?(0,V.jsx)(`p`,{className:`rounded-2xl bg-surface-base p-4 text-sm text-fg-muted`,children:n?`默认智能体不能删除,请先将其他智能体设为默认。`:`The default agent cannot be deleted. Make another agent the default first.`}):(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-2xl border border-red-500/25 bg-red-500/5 p-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-red-600`,children:n?`删除智能体`:`Delete agent`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`配置条目会被移除,删除前仍会再次确认。`:`The configuration entry will be removed after confirmation.`})]}),(0,V.jsxs)(y,{variant:`ghost`,className:`text-red-600`,onClick:c,children:[(0,V.jsx)(O,{className:`size-4`}),n?`删除`:`Delete`]})]})]}):null]}),(0,V.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge bg-surface-panel px-5 py-3`,children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:b?n?`请补全自定义模型`:`Complete the custom model reference`:v?n?`有未保存的更改`:`Unsaved changes`:n?`所有更改已保存`:`All changes saved`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(y,{onClick:a,children:n?`关闭`:`Close`}),(0,V.jsx)(y,{variant:`primary`,disabled:p||!v||b||d.profile!==void 0&&!d.profile.name.trim(),onClick:()=>void M(),children:p?n?`保存中…`:`Saving…`:n?`保存更改`:`Save changes`})]})]})]})]})}function te(e){let t=(0,z.c)(29),{agent:n,open:r,onOpenChange:i,children:a}=e,[p,h]=(0,B.useState)(null),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,V.jsx)(o,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim`,S)}),t[0]=g):g=t[0];let v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=_(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover`,x,`inset-3 h-[calc(100dvh-1.5rem)] min-h-0 sm:inset-auto sm:left-1/2 sm:top-1/2`,`sm:h-[min(88vh,48rem)] sm:w-[min(94vw,62rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=v):v=t[1];let y;t[2]!==n.avatar||t[3]!==n.id?(y=(0,V.jsx)(E,{agentId:n.id,avatar:n.avatar,size:42,className:`size-11 shrink-0`}),t[2]=n.avatar,t[3]=n.id,t[4]=y):y=t[4];let b;t[5]===n.name?b=t[6]:(b=(0,V.jsx)(d,{className:`truncate text-base font-semibold text-fg`,children:n.name}),t[5]=n.name,t[6]=b);let w;t[7]===n.id?w=t[8]:(w=(0,V.jsx)(s,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,children:n.id}),t[7]=n.id,t[8]=w);let T;t[9]!==b||t[10]!==w?(T=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[b,w]}),t[9]=b,t[10]=w,t[11]=T):T=t[11];let D;t[12]===n.isDefault?D=t[13]:(D=n.isDefault?(0,V.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent`,children:`DEFAULT`}):null,t[12]=n.isDefault,t[13]=D);let O;t[14]!==y||t[15]!==T||t[16]!==D?(O=(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[y,T,D]}),t[14]=y,t[15]=T,t[16]=D,t[17]=O):O=t[17];let k;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,V.jsx)(c,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`Close`,children:(0,V.jsx)(m,{className:`size-4`})})}),t[18]=k):k=t[18];let A;t[19]===O?A=t[20]:(A=(0,V.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-4 border-b border-edge px-5 py-4`,children:[O,k]}),t[19]=O,t[20]=A);let j;t[21]!==a||t[22]!==p||t[23]!==A?(j=(0,V.jsxs)(l,{children:[g,(0,V.jsx)(u,{ref:h,className:v,onOpenAutoFocus:Z,children:(0,V.jsxs)(C,{layer:`modal`,portalContainer:p,children:[A,a]})})]}),t[21]=a,t[22]=p,t[23]=A,t[24]=j):j=t[24];let M;return t[25]!==i||t[26]!==r||t[27]!==j?(M=(0,V.jsx)(f,{open:r,onOpenChange:i,children:j}),t[25]=i,t[26]=r,t[27]=j,t[28]=M):M=t[28],M}function Z(e){return e.preventDefault()}function Q(e){let t=(0,z.c)(13),{agents:n,busy:r,zh:i,onOpen:a,onChat:o}=e,s;if(t[0]!==n||t[1]!==r||t[2]!==o||t[3]!==a||t[4]!==i){let e;t[6]!==r||t[7]!==o||t[8]!==a||t[9]!==i?(e=e=>(0,V.jsx)(`li`,{className:`min-h-0`,children:(0,V.jsxs)(`article`,{className:_(`group relative flex min-h-52 flex-col rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,`transition-[transform,background-color,border-color] duration-200 ease-out hover:-translate-y-0.5 hover:border-accent/30 hover:bg-surface-hover/35 active:scale-[0.99] motion-reduce:transform-none`),children:[(0,V.jsx)(`button`,{type:`button`,disabled:r,"aria-label":i?`配置 ${e.name}`:`Configure ${e.name}`,onClick:()=>a(e.id),className:`absolute inset-0 z-0 rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,V.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,V.jsx)(E,{agentId:e.id,avatar:e.avatar,size:48,className:`size-12 shrink-0`}),(0,V.jsx)(`div`,{className:`min-w-0`,children:(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:e.name})})]}),(0,V.jsx)(`span`,{className:_(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.isDefault?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`),children:e.isDefault?i?`默认`:`Default`:i?`自定义`:`Custom`})]}),(0,V.jsx)(`p`,{className:`pointer-events-none relative z-10 mt-5 line-clamp-2 min-h-10 text-sm leading-5 text-fg-muted`,children:e.description||e.override.profile?.instructions||(i?`使用全局配置`:`Uses global settings`)}),(0,V.jsxs)(`div`,{className:`pointer-events-none relative z-10 mt-4 rounded-xl bg-surface-base px-3 py-2.5`,children:[(0,V.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:i?`当前模型`:`Current model`}),(0,V.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg`,children:e.effective.models.chat.primary})]}),(0,V.jsx)(`div`,{className:`relative z-10 mt-auto pt-4`,children:(0,V.jsxs)(y,{className:`w-full`,disabled:r,onClick:t=>{t.stopPropagation(),o(e.id)},children:[(0,V.jsx)(D,{className:`size-4`}),i?`与这个智能体对话`:`Chat with this agent`]})})]})},e.id),t[6]=r,t[7]=o,t[8]=a,t[9]=i,t[10]=e):e=t[10],s=n.map(e),t[0]=n,t[1]=r,t[2]=o,t[3]=a,t[4]=i,t[5]=s}else s=t[5];let c;return t[11]===s?c=t[12]:(c=(0,V.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:s}),t[11]=s,t[12]=c),c}var ne=`w-full rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function $(e){let t=(0,z.c)(59),{open:n,busy:r,error:i,name:a,instructions:p,zh:h,onNameChange:g,onInstructionsChange:v,onCreate:b,onOpenChange:C}=e,w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,V.jsx)(o,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim`,S)}),t[0]=w):w=t[0];let T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=_(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(92vw,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover`,x),t[1]=T):T=t[1];let E=h?`新建智能体`:`Create agent`,D;t[2]===E?D=t[3]:(D=(0,V.jsx)(d,{className:`text-base font-semibold text-fg`,children:E}),t[2]=E,t[3]=D);let O=h?`只设置身份即可开始,所有能力自动继承全局配置。`:`Set its identity and start. Every capability inherits globally.`,k;t[4]===O?k=t[5]:(k=(0,V.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:O}),t[4]=O,t[5]=k);let A;t[6]!==D||t[7]!==k?(A=(0,V.jsxs)(`div`,{children:[D,k]}),t[6]=D,t[7]=k,t[8]=A):A=t[8];let j;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,V.jsx)(c,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover`,"aria-label":`Close`,children:(0,V.jsx)(m,{className:`size-4`})})}),t[9]=j):j=t[9];let M;t[10]===A?M=t[11]:(M=(0,V.jsxs)(`header`,{className:`flex items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[A,j]}),t[10]=A,t[11]=M);let N;t[12]===i?N=t[13]:(N=i?(0,V.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:i}):null,t[12]=i,t[13]=N);let P=h?`名称`:`Name`,F=h?`智能体名称`:`Agent name`,I;t[14]===g?I=t[15]:(I=e=>g(e.target.value),t[14]=g,t[15]=I);let L=h?`例如:数据分析师`:`For example: Data analyst`,R;t[16]!==a||t[17]!==F||t[18]!==I||t[19]!==L?(R=(0,V.jsx)(`input`,{id:`create-agent-name`,"aria-label":F,className:`${ne} mt-1.5`,value:a,onChange:I,placeholder:L}),t[16]=a,t[17]=F,t[18]=I,t[19]=L,t[20]=R):R=t[20];let B;t[21]!==P||t[22]!==R?(B=(0,V.jsxs)(`label`,{htmlFor:`create-agent-name`,className:`block text-xs font-medium text-fg-muted`,children:[P,R]}),t[21]=P,t[22]=R,t[23]=B):B=t[23];let ee=h?`个性与工作方式(可选)`:`Personality and working style (optional)`,H=h?`个性与工作方式`:`Personality and working style`,U;t[24]===v?U=t[25]:(U=e=>v(e.target.value),t[24]=v,t[25]=U);let W=h?`描述角色、语气和偏好的工作方式`:`Describe its role, tone, and preferred way of working`,G;t[26]!==p||t[27]!==H||t[28]!==U||t[29]!==W?(G=(0,V.jsx)(`textarea`,{id:`create-agent-instructions`,"aria-label":H,rows:4,className:`${ne} mt-1.5 resize-none`,value:p,onChange:U,placeholder:W}),t[26]=p,t[27]=H,t[28]=U,t[29]=W,t[30]=G):G=t[30];let K;t[31]!==ee||t[32]!==G?(K=(0,V.jsxs)(`label`,{htmlFor:`create-agent-instructions`,className:`block text-xs font-medium text-fg-muted`,children:[ee,G]}),t[31]=ee,t[32]=G,t[33]=K):K=t[33];let q;t[34]!==N||t[35]!==B||t[36]!==K?(q=(0,V.jsxs)(`div`,{className:`space-y-4 p-5`,children:[N,B,K]}),t[34]=N,t[35]=B,t[36]=K,t[37]=q):q=t[37];let J=h?`取消`:`Cancel`,Y;t[38]!==r||t[39]!==J?(Y=(0,V.jsx)(c,{asChild:!0,children:(0,V.jsx)(y,{disabled:r,children:J})}),t[38]=r,t[39]=J,t[40]=Y):Y=t[40];let X;t[41]!==r||t[42]!==a?(X=r||!a.trim(),t[41]=r,t[42]=a,t[43]=X):X=t[43];let te=r?h?`创建中…`:`Creating…`:h?`创建智能体`:`Create agent`,Z;t[44]!==b||t[45]!==X||t[46]!==te?(Z=(0,V.jsx)(y,{variant:`primary`,disabled:X,onClick:b,children:te}),t[44]=b,t[45]=X,t[46]=te,t[47]=Z):Z=t[47];let Q;t[48]!==Y||t[49]!==Z?(Q=(0,V.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[Y,Z]}),t[48]=Y,t[49]=Z,t[50]=Q):Q=t[50];let $;t[51]!==q||t[52]!==Q||t[53]!==M?($=(0,V.jsxs)(l,{children:[w,(0,V.jsxs)(u,{className:T,children:[M,q,Q]})]}),t[51]=q,t[52]=Q,t[53]=M,t[54]=$):$=t[54];let re;return t[55]!==C||t[56]!==n||t[57]!==$?(re=(0,V.jsx)(f,{open:n,onOpenChange:C,children:$}),t[55]=C,t[56]=n,t[57]=$,t[58]=re):re=t[58],re}function re(){let e=(0,z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(b,{className:`h-7 w-28`}),(0,V.jsx)(b,{className:`h-4 w-80 max-w-full`})]}),(0,V.jsx)(b,{className:`h-9 w-28`})]}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,V.jsxs)(R,{gap:`gap-5`,children:[t,(0,V.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(ie)})]}),e[1]=n):n=e[1],n}function ie(e){return(0,V.jsx)(b,{className:`h-64 rounded-2xl`},e)}function ae(){let e=g(e=>e.token),t=h(e=>e.language)===`zh`,n=i(),{agentId:r}=a(),{data:o,error:s,isLoading:c,mutate:l}=v(e?`settings-gateway-agents`:null,N),u=P(e=>e.setPageHeader),d=P(e=>e.clearPageHeader),[f,m]=(0,B.useState)({open:!1,name:``,instructions:``}),[_,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),C=(0,B.useRef)(!1),w=o?.agents.find(e=>e.id===r),T=(0,B.useMemo)(()=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(y,{onClick:()=>n(`/settings/agent-defaults`),children:t?`全局默认配置`:`Global defaults`}),(0,V.jsxs)(y,{variant:`primary`,onClick:()=>{S(null),m(e=>({...e,open:!0}))},children:[(0,V.jsx)(p,{className:`size-4`}),t?`新建智能体`:`New agent`]})]}),[n,t]);(0,B.useLayoutEffect)(()=>(u({startExtra:null,main:(0,V.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t?`智能体`:`Agents`}),end:T}),()=>d()),[d,T,u,t]);let E=async()=>{b(!0),S(null);try{let e=await F({profile:{name:f.name.trim(),...f.instructions.trim()?{instructions:f.instructions.trim()}:{}}});m({open:!1,name:``,instructions:``}),n(`/agents/${e.createdAgentId}`)}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}},D=async e=>{if(window.confirm(t?`删除 ${e.name}?此操作无法撤销。`:`Delete ${e.name}? This cannot be undone.`)){b(!0),S(null);try{await M(e.id),n(`/agents`)}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}},O=e=>{I(e),n(`/chat/new`)},k=e=>{C.current=!1,window.setTimeout(()=>n(`/agents/${e}`),0)},A=()=>{C.current&&!window.confirm(t?`放弃未保存的更改?`:`Discard unsaved changes?`)||(C.current=!1,n(`/agents`))},j=()=>{C.current&&!window.confirm(t?`放弃未保存的更改?`:`Discard unsaved changes?`)||(C.current=!1,n(`/settings/agent-defaults`))},L=(0,B.useCallback)(e=>{C.current=e},[]);return e?s&&!o?(0,V.jsxs)(R,{children:[(0,V.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:String(s)}),(0,V.jsx)(y,{onClick:()=>void l(),children:t?`重试`:`Retry`})]}):c||!o?(0,V.jsx)(re,{}):(0,V.jsxs)(R,{gap:`gap-5`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(s||x)&&!w?(0,V.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:x??String(s)}):null,(0,V.jsx)(Q,{agents:o.agents,busy:_,zh:t,onOpen:k,onChat:O}),w?(0,V.jsx)(te,{agent:w,open:!0,onOpenChange:e=>{e||A()},children:(0,V.jsx)(X,{agent:w,toolIds:o.builtinToolIds,zh:t,externalError:x,onDirtyChange:L,onClose:A,onOpenDefaults:j,onChat:()=>O(w.id),onDelete:()=>void D(w)},w.id)}):null,(0,V.jsx)($,{open:f.open,busy:_,error:x,name:f.name,instructions:f.instructions,zh:t,onNameChange:e=>m(t=>({...t,name:e})),onInstructionsChange:e=>m(t=>({...t,instructions:e})),onCreate:()=>void E(),onOpenChange:e=>{_||(m(t=>({...t,open:e})),e||S(null))}})]}):(0,V.jsx)(R,{children:(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`需要本机服务令牌。`:`Local service token required.`})})}export{ae as AgentsSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as o,i as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{t as f}from"./check-DUBLcKHA.js";import{t as p}from"./external-link-DjqjBmc3.js";import{t as m}from"./markdown-view-D-5jHRWg.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./messages-Dj8QuS6e.js";import{a as y,i as b,n as x,r as S,s as C}from"./locale-store-DFQX9kTl.js";import{t as w}from"./cn-JdwAhgNB.js";import{a as T,i as E}from"./vendor-swr-BIWyz7Rc.js";import{t as D}from"./button-B11EPpor.js";import{t as O}from"./skeleton-BwbyijEw.js";import{Au as k,Ca as A,Fa as j,Fc as M,Hs as ee,Ia as N,La as P,Na as F,Ra as I,Va as L,Vs as te,cu as R,lc as z,pc as B,ro as V,sc as ne,vu as H}from"./index-wKE8Q2FX.js";import{t as U}from"./page-tabs-_SGXMT2O.js";var W=e(t(),1),G=n();function K(e){return e===`builtin`||e===`user`?e:`marketplace`}async function q(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function re(e){let t=await b(S(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await b(S(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function Y(e){let t=await b(S(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function X(e){let t=await b(S(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Z=r();function ie(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Q={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function $({className:e}){let t=v(x(e=>e.language)).extensionsPage,n=C(e=>!!e.token),r=j(),{mutate:i}=T(),[a,o]=(0,W.useReducer)(A,Q),{q:s,debounced:c,detailPkg:l,rowBusy:u,actionError:d,restartHint:f}=a,p=n?`marketplace-${c}`:null;(0,W.useEffect)(()=>{let e=window.setTimeout(()=>o({type:`patch`,patch:{debounced:s.trim()}}),300);return()=>window.clearTimeout(e)},[s]);let{data:m,isLoading:g,error:_}=E(p,async()=>y(c.length>0?S(`/api/marketplace?q=${encodeURIComponent(c)}`):S(`/api/marketplace`)),{revalidateOnFocus:!1}),b=(0,W.useCallback)(()=>{i(`gateway-extensions-list`),L()},[i]),D=(0,W.useCallback)(async(e,n)=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await J({name:e,overwrite:n});b(),r.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,b]),k=(0,W.useCallback)(async e=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await X(e);b(),n.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,b]),N=m?.extensions??[];return(0,Z.jsxs)(`div`,{className:w(`flex flex-col gap-4`,e),children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(B,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:s,onChange:e=>o({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),_?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_ instanceof Error?_.message:t.marketplaceLoadFailed}):null,d?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,f?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}):null,g&&!m?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,Z.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,Z.jsx)(O,{className:`h-5 w-40`}),(0,Z.jsx)(O,{className:`h-4 w-full max-w-xl`}),(0,Z.jsx)(O,{className:`h-4 w-2/3 max-w-md`})]}),(0,Z.jsx)(O,{className:`h-8 w-20`})]})},e))}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:N.length===0?(0,Z.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):N.map(e=>{let n=ie(r,e.id),i=u===e.id;return(0,Z.jsx)(`li`,{className:`list-none`,children:(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o({type:`patch`,patch:{detailPkg:e.id}}))},className:w(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Z.jsx)(R,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(M,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Z.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&k(e.id).catch(()=>{})},className:w(`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,Z.jsx)(h,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),className:w(`inline-flex w-full 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:t.marketplaceReview})})]})},e.id)})}),l?(0,Z.jsx)(ae,{packageName:l,copy:t,extensions:r,onClose:()=>o({type:`patch`,patch:{detailPkg:null}}),onInstall:D,onUninstall:k}):null]})}function ae(e){let t=(0,G.c)(102),{packageName:n,copy:r,extensions:i,onClose:s,onInstall:f,onUninstall:p}=e,[g,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!1),x=C(ue)?`ext-mp-detail-${n}`:null,S;t[0]===n?S=t[1]:(S=async()=>re(n),t[0]=n,t[1]=S);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[2]=T):T=t[2];let{data:D,error:A,isLoading:j}=E(x,S,T),M;t[3]!==i||t[4]!==n?(M=ie(i,n),t[3]=i,t[4]=n,t[5]=M):M=t[5];let N=M,P=N===`user`,F=D?.manifest?.permissions,I,L,R,z,B,V,H,U,K,q,J;if(t[6]!==r.detailBack||t[7]!==r.detailClose||t[8]!==r.marketplaceAuthor||t[9]!==r.marketplaceCodeRisk||t[10]!==r.marketplaceDependencies||t[11]!==r.marketplaceDetailLoadFailed||t[12]!==r.marketplaceDetailReadmeHeading||t[13]!==r.marketplaceDetailTitle||t[14]!==r.marketplaceDownloads||t[15]!==r.marketplaceIntegrity||t[16]!==r.marketplaceIntegrityVerified||t[17]!==r.marketplaceLifecycleScripts||t[18]!==r.marketplaceLoadFailed||t[19]!==r.marketplaceLoading||t[20]!==r.marketplaceNoReadme||t[21]!==r.marketplacePermissions||t[22]!==r.marketplacePermissionsNone||t[23]!==r.marketplaceRiskConfirm||t[24]!==r.marketplaceRiskTitle||t[25]!==r.marketplaceUnavailableBody||t[26]!==r.marketplaceUnavailableTitle||t[27]!==r.marketplaceVersion||t[28]!==D||t[29]!==A||t[30]!==N||t[31]!==j||t[32]!==s||t[33]!==F||t[34]!==y){let e=F&&typeof F==`object`&&!Array.isArray(F)?Object.entries(F):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==D?(n=D?.readme?.trim()||(D?.description?.trim()?`### ${D.name}\n\n${D.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=D,t[48]=n):n=t[48];let i=n;R=d,z=!0,t[49]===s?B=t[50]:(B=e=>!e&&s(),t[49]=s,t[50]=B),L=c,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=J):J=t[51],I=l,U=`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-panel shadow-elevated`,K=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(k,{className:`size-5`}),t[52]=a):a=t[52];let f;t[53]!==r.detailBack||t[54]!==s?(f=(0,Z.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":r.detailBack,children:a}),t[53]=r.detailBack,t[54]=s,t[55]=f):f=t[55];let p;t[56]===r.marketplaceDetailTitle?p=t[57]:(p=(0,Z.jsx)(u,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=p);let h;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(_,{className:`size-5`}),t[58]=h):h=t[58];let g;t[59]!==r.detailClose||t[60]!==s?(g=(0,Z.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":r.detailClose,children:h}),t[59]=r.detailClose,t[60]=s,t[61]=g):g=t[61],t[62]!==f||t[63]!==p||t[64]!==g?(q=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[f,p,g]}),t[62]=f,t[63]=p,t[64]=g,t[65]=q):q=t[65],V=`min-h-0 flex-1 overflow-y-auto p-5`,H=j&&!D?(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,Z.jsx)(O,{className:`h-6 w-48`}),(0,Z.jsx)(O,{className:`h-4 w-28`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(O,{className:`h-12`}),(0,Z.jsx)(O,{className:`h-12`})]}),(0,Z.jsx)(O,{className:`h-28 w-full`}),(0,Z.jsx)(O,{className:`h-36 w-full`})]}):A?(0,Z.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,Z.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:A instanceof Error?A.message:r.marketplaceLoadFailed})]}):D?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:D.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:D.id})}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Z.jsx)(`dd`,{children:D.author.username})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Z.jsx)(`dd`,{children:D.latestVersion.version})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Z.jsx)(`dd`,{children:D.downloads})]})]}),N===`bundled`?null:(0,Z.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[D.installability.available?(0,Z.jsx)(ne,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:D.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:D.installability.available?r.marketplaceCodeRisk:D.installability.reason??r.marketplaceUnavailableBody})]})]}),D.installability.available?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,Z.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,Z.jsx)(`dd`,{children:D.packageSummary?.dependencyCount??0})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,Z.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(D.packageSummary?.lifecycleScripts.length??0)>0?(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,D.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,Z.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),D.readme?.trim()?(0,Z.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Z.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Z.jsx)(m,{content:i})})]}):null,t[6]=r.detailBack,t[7]=r.detailClose,t[8]=r.marketplaceAuthor,t[9]=r.marketplaceCodeRisk,t[10]=r.marketplaceDependencies,t[11]=r.marketplaceDetailLoadFailed,t[12]=r.marketplaceDetailReadmeHeading,t[13]=r.marketplaceDetailTitle,t[14]=r.marketplaceDownloads,t[15]=r.marketplaceIntegrity,t[16]=r.marketplaceIntegrityVerified,t[17]=r.marketplaceLifecycleScripts,t[18]=r.marketplaceLoadFailed,t[19]=r.marketplaceLoading,t[20]=r.marketplaceNoReadme,t[21]=r.marketplacePermissions,t[22]=r.marketplacePermissionsNone,t[23]=r.marketplaceRiskConfirm,t[24]=r.marketplaceRiskTitle,t[25]=r.marketplaceUnavailableBody,t[26]=r.marketplaceUnavailableTitle,t[27]=r.marketplaceVersion,t[28]=D,t[29]=A,t[30]=N,t[31]=j,t[32]=s,t[33]=F,t[34]=y,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=B,t[40]=V,t[41]=H,t[42]=U,t[43]=K,t[44]=q,t[45]=J}else I=t[35],L=t[36],R=t[37],z=t[38],B=t[39],V=t[40],H=t[41],U=t[42],K=t[43],q=t[44],J=t[45];let Y;t[66]!==V||t[67]!==H?(Y=(0,Z.jsx)(`div`,{className:V,children:H}),t[66]=V,t[67]=H,t[68]=Y):Y=t[68];let X;t[69]!==g||t[70]!==r.marketplaceBuiltinGoBuiltin||t[71]!==r.marketplaceBuiltinManageHint||t[72]!==r.marketplaceInstall||t[73]!==r.marketplaceReinstall||t[74]!==r.marketplaceReinstallConfirm||t[75]!==r.marketplaceUninstall||t[76]!==r.marketplaceUninstallConfirm||t[77]!==D||t[78]!==N||t[79]!==s||t[80]!==f||t[81]!==p||t[82]!==n||t[83]!==y||t[84]!==P?(X=D?(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:N===`bundled`?(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Z.jsx)(a,{to:`/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:r.marketplaceBuiltinGoBuiltin})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:g||!D.installability.available||!y,onClick:()=>{P&&!window.confirm(r.marketplaceReinstallConfirm)||(v(!0),f(n,P).catch(se).finally(()=>v(!1)))},className:w(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white 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:[g?(0,Z.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,P?r.marketplaceReinstall:r.marketplaceInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,disabled:g,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(v(!0),p(n).then(()=>s()).catch(oe).finally(()=>v(!1)))},className:w(`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,Z.jsx)(ee,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=g,t[70]=r.marketplaceBuiltinGoBuiltin,t[71]=r.marketplaceBuiltinManageHint,t[72]=r.marketplaceInstall,t[73]=r.marketplaceReinstall,t[74]=r.marketplaceReinstallConfirm,t[75]=r.marketplaceUninstall,t[76]=r.marketplaceUninstallConfirm,t[77]=D,t[78]=N,t[79]=s,t[80]=f,t[81]=p,t[82]=n,t[83]=y,t[84]=P,t[85]=X):X=t[85];let Q;t[86]!==I||t[87]!==Y||t[88]!==X||t[89]!==U||t[90]!==K||t[91]!==q?(Q=(0,Z.jsxs)(I,{className:U,onOpenAutoFocus:K,children:[q,Y,X]}),t[86]=I,t[87]=Y,t[88]=X,t[89]=U,t[90]=K,t[91]=q,t[92]=Q):Q=t[92];let $;t[93]!==L||t[94]!==Q||t[95]!==J?($=(0,Z.jsxs)(L,{children:[J,Q]}),t[93]=L,t[94]=Q,t[95]=J,t[96]=$):$=t[96];let ae;return t[97]!==R||t[98]!==z||t[99]!==B||t[100]!==$?(ae=(0,Z.jsx)(R,{defaultOpen:z,onOpenChange:B,children:$}),t[97]=R,t[98]=z,t[99]=B,t[100]=$,t[101]=ae):ae=t[101],ae}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,Z.jsxs)(`li`,{className:`break-words`,children:[(0,Z.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.token}function de(){let e=x(e=>e.language),t=v(e),n=V(e=>e.setPageHeader),r=V(e=>e.clearPageHeader),o=j(),s=N(),[c,l]=i(),u=K(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,W.useState)(u),[m,h]=(0,W.useState)(d),[_,y]=(0,W.useState)(null),b=c.toString(),S=(0,W.useRef)(b);if(S.current!==b){S.current=b;let e=K(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,W.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let C=(0,W.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),w=(0,W.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),T=f===`builtin`?C:w,E=(0,W.useMemo)(()=>{let t=m.trim().toLowerCase(),n=T;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[T,m,e]);if((0,W.useEffect)(()=>{y(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?fe(e)===fe(t)&&e.active===t.active?e:t:null})},[o]),(0,W.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(D,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,Z.jsx)(H,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,Z.jsx)(D,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps/new`,children:[(0,Z.jsx)(g,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&f!==`marketplace`)return(0,Z.jsx)(ye,{});let O=f!==`marketplace`&&T.length>0;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,Z.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 border-b border-edge-subtle pb-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsx)(U,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:C.length},{id:`user`,label:t.extensionsPage.tabUser,count:w.length}],activeTab:f,onChange:p,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),O?(0,Z.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Z.jsx)(B,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.extensionsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,Z.jsx)($,{}):f===`builtin`&&C.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):f===`user`&&w.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyUser}):E.length===0?(0,Z.jsx)(`p`,{className:`px-3 py-14 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,Z.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:f===`user`,onOpen:()=>y(e)},e.id))})]}),_?(0,Z.jsx)(_e,{extension:_,copy:t.extensionsPage,onClose:()=>y(null)},_.id):null]})}function fe(e){return e.activationEligible??e.active}function pe(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function me(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function he(e,t){let n=fe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function ge(e){let t=(0,G.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=fe(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=w(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let p;t[5]===d?p=t[6]:(p=(0,Z.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:d}),t[5]=d,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let _;t[11]!==m||t[12]!==h?(_=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=_):_=t[13];let v;t[14]!==r.statusEnabled||t[15]!==s?(v=s?(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,Z.jsx)(f,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,Z.jsx)(g,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=v):v=t[16];let y;t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[_,v]}),t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==r.cardNoDescription||t[21]!==n.description?(b=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=b):b=t[22];let x;t[23]===b?x=t[24]:(x=(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:b}),t[23]=b,t[24]=x);let S=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==S||t[26]!==c?(C=(0,Z.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:S}),t[25]=S,t[26]=c,t[27]=C):C=t[27];let T;t[28]!==r||t[29]!==n||t[30]!==i?(T=n.source===`bundled`?(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,Z.jsx)(`span`,{title:pe(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:me(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=T):T=t[31];let E;t[32]!==C||t[33]!==T?(E=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,T]}),t[32]=C,t[33]=T,t[34]=E):E=t[34];let D;t[35]!==y||t[36]!==x||t[37]!==E?(D=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x,E]}),t[35]=y,t[36]=x,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==p?(O=(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[p,D]}),t[39]=D,t[40]=p,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:l,children:O}),t[42]=a,t[43]=O,t[44]=k):k=t[44],k}function _e({extension:e,copy:t,onClose:n}){let{mutate:r}=T(),[i,f]=(0,W.useState)(!1),[m,g]=(0,W.useState)(null),[v,y]=(0,W.useState)(!1),b=e.activationEligible===!0,x=(0,W.useCallback)(async()=>{if(e.source===`bundled`){g(null),y(!1),f(!0);try{let{requiresGatewayRestart:t}=await Y({extensionId:e.id,enabled:!b});await r(`gateway-extensions-list`),L(),y(t)}catch(e){g(e instanceof Error?e.message:t.builtinToggleFailed)}finally{f(!1)}}},[b,t.builtinToggleFailed,e.id,e.source,r]),S=e.ui?.contributions?.pages??[],C=e.ui?.contributions?.settingsPanels??[],E=e.ui?.contributions?.chatWidgets??[],O=e.ui?.contributions?.sidebarPanels??[],A=S.find(e=>e.showInNav)??S[0],j=C[0],M=A?F(e.id,A):null,ee=j?`/settings/ext/${e.id}/${j.id}`:e.hasConfigSchema||P(e)?`/settings/ext/${e.id}`:null;return(0,Z.jsx)(d,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Z.jsxs)(l,{className:`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-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Z.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,Z.jsx)(k,{className:`size-5`})}),(0,Z.jsx)(u,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Z.jsxs)(s,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Z.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,Z.jsx)(_,{className:`size-5`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Z.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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}),(0,Z.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void x(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):b?t.builtinToggleDisable:t.builtinToggleEnable})]}),m?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:m}):null,v?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Z.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.cliManageHint}),e.hasUi&&(S.length>0||C.length>0||E.length>0)?(0,Z.jsxs)(`section`,{className:`mt-8`,children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Z.jsx)(ve,{template:t.badgePages,count:S.length,hidden:S.length===0}),(0,Z.jsx)(ve,{template:t.badgeSettings,count:C.length,hidden:C.length===0}),(0,Z.jsx)(ve,{template:t.badgeWidgets,count:E.length,hidden:E.length===0}),(0,Z.jsx)(ve,{template:t.badgeSidebar,count:O.length,hidden:O.length===0})]})]}):null,I(e)&&(M||ee)?(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[M?(0,Z.jsxs)(a,{to:M,onClick:n,className:w(`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,Z.jsx)(p,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,ee?(0,Z.jsxs)(a,{to:ee,onClick:n,className:w(`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,Z.jsx)(z,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Z.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,G.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,Z.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 ye(){let e=(0,G.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Z.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Z.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(be)})]})}),e[4]=a):a=e[4],a}function be(e){return(0,Z.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function xe(e){let t=(0,G.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.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,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{de as ExtensionsPage};