@xopcai/xopc 0.0.57 → 0.0.58

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 (166) hide show
  1. package/README.md +6 -0
  2. package/README.zh-CN.md +6 -0
  3. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  4. package/dist/extensions/telegram/src/plugin.js +1 -1
  5. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/extensions/weixin/src/api/api.js +2 -2
  8. package/dist/extensions/weixin/src/auth/accounts.js +1 -1
  9. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  10. package/dist/extensions/weixin/src/media/data-url.js +1 -1
  11. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  12. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  13. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  14. package/dist/extensions/weixin/src/plugin.js +1 -1
  15. package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
  16. package/dist/gateway/static/root/assets/{agents-DEL6G6-C.js → agents-kfTaZM98.js} +2 -2
  17. package/dist/gateway/static/root/assets/{agents-DEL6G6-C.js.map → agents-kfTaZM98.js.map} +1 -1
  18. package/dist/gateway/static/root/assets/{apps-page-DXlDJBf0.js → apps-page-DD4Y41az.js} +2 -2
  19. package/dist/gateway/static/root/assets/{apps-page-DXlDJBf0.js.map → apps-page-DD4Y41az.js.map} +1 -1
  20. package/dist/gateway/static/root/assets/{channels-settings-IWwRmmCH.js → channels-settings-CzQhBqZZ.js} +2 -2
  21. package/dist/gateway/static/root/assets/{channels-settings-IWwRmmCH.js.map → channels-settings-CzQhBqZZ.js.map} +1 -1
  22. package/dist/gateway/static/root/assets/{cron-dreaming-jobs-DIwTeQzu.js → cron-dreaming-jobs-Bw0WqucT.js} +2 -2
  23. package/dist/gateway/static/root/assets/{cron-dreaming-jobs-DIwTeQzu.js.map → cron-dreaming-jobs-Bw0WqucT.js.map} +1 -1
  24. package/dist/gateway/static/root/assets/{cron-page-CcRCqnzx.js → cron-page-DzdhjVlI.js} +2 -2
  25. package/dist/gateway/static/root/assets/{cron-page-CcRCqnzx.js.map → cron-page-DzdhjVlI.js.map} +1 -1
  26. package/dist/gateway/static/root/assets/{dist-CgucsbDd.js → dist-CwfwOj0f.js} +2 -2
  27. package/dist/gateway/static/root/assets/{dist-CgucsbDd.js.map → dist-CwfwOj0f.js.map} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-BX1pf7rr.js → extension-debug-page-6MugjoYl.js} +2 -2
  29. package/dist/gateway/static/root/assets/{extension-debug-page-BX1pf7rr.js.map → extension-debug-page-6MugjoYl.js.map} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-page-DPm5vzVN.js → extension-page-DG6W4O_G.js} +2 -2
  31. package/dist/gateway/static/root/assets/{extension-page-DPm5vzVN.js.map → extension-page-DG6W4O_G.js.map} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-settings-page-DAly-C6g.js → extension-settings-page-DmmeUN--.js} +2 -2
  33. package/dist/gateway/static/root/assets/{extension-settings-page-DAly-C6g.js.map → extension-settings-page-DmmeUN--.js.map} +1 -1
  34. package/dist/gateway/static/root/assets/{heartbeat-config-api-SijGy10-.js → heartbeat-config-api-BzwYrxvL.js} +2 -2
  35. package/dist/gateway/static/root/assets/{heartbeat-config-api-SijGy10-.js.map → heartbeat-config-api-BzwYrxvL.js.map} +1 -1
  36. package/dist/gateway/static/root/assets/{index-DHte7V8E.js → index-BDiwAtHo.js} +4 -4
  37. package/dist/gateway/static/root/assets/{index-DHte7V8E.js.map → index-BDiwAtHo.js.map} +1 -1
  38. package/dist/gateway/static/root/assets/{logs-page-DEnawdQ8.js → logs-page-BaOXC1YZ.js} +2 -2
  39. package/dist/gateway/static/root/assets/{logs-page-DEnawdQ8.js.map → logs-page-BaOXC1YZ.js.map} +1 -1
  40. package/dist/gateway/static/root/assets/{sessions-page-CGn5wKzh.js → sessions-page-C_VA9TOA.js} +2 -2
  41. package/dist/gateway/static/root/assets/{sessions-page-CGn5wKzh.js.map → sessions-page-C_VA9TOA.js.map} +1 -1
  42. package/dist/gateway/static/root/assets/{settings-page-BV20X-TN.js → settings-page-DMjZKSwv.js} +2 -2
  43. package/dist/gateway/static/root/assets/{settings-page-BV20X-TN.js.map → settings-page-DMjZKSwv.js.map} +1 -1
  44. package/dist/gateway/static/root/assets/{skills-page-C1Ns0BHu.js → skills-page-vObv6AB7.js} +2 -2
  45. package/dist/gateway/static/root/assets/{skills-page-C1Ns0BHu.js.map → skills-page-vObv6AB7.js.map} +1 -1
  46. package/dist/gateway/static/root/assets/{use-image-provider-credentials-BZqTDErY.js → use-image-provider-credentials-CoM2HUB_.js} +2 -2
  47. package/dist/gateway/static/root/assets/{use-image-provider-credentials-BZqTDErY.js.map → use-image-provider-credentials-CoM2HUB_.js.map} +1 -1
  48. package/dist/gateway/static/root/index.html +1 -1
  49. package/dist/package.js +1 -1
  50. package/dist/src/agent/agent-manager.js +6 -6
  51. package/dist/src/agent/context/workspace-seed.js +2 -2
  52. package/dist/src/agent/embedded/run-turn.js +2 -0
  53. package/dist/src/agent/embedded/run-turn.js.map +1 -1
  54. package/dist/src/agent/embedded/xopc-auth-storage.d.ts +11 -0
  55. package/dist/src/agent/embedded/xopc-auth-storage.js +26 -0
  56. package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -0
  57. package/dist/src/agent/goals/goal-run-store.js +4 -4
  58. package/dist/src/agent/goals/post-turn.js +2 -2
  59. package/dist/src/agent/image/load-image-media.js +1 -1
  60. package/dist/src/agent/ipc/bus.js +1 -1
  61. package/dist/src/agent/ipc/inbox.js +2 -2
  62. package/dist/src/agent/ipc/socket.js +1 -1
  63. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  64. package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
  65. package/dist/src/agent/memory/dreaming/events.js +1 -1
  66. package/dist/src/agent/memory/dreaming/last-run.js +1 -1
  67. package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
  68. package/dist/src/agent/memory/dreaming/preview.js +1 -1
  69. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  70. package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
  71. package/dist/src/agent/memory/dreaming/utils.js +1 -1
  72. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  73. package/dist/src/agent/models/manager.js +1 -1
  74. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  75. package/dist/src/agent/service.js +5 -5
  76. package/dist/src/agent/skills/config.js +1 -1
  77. package/dist/src/agent/skills/hub-hash.js +2 -2
  78. package/dist/src/agent/skills/hub-lock.js +1 -1
  79. package/dist/src/agent/skills/hub-pull.js +1 -1
  80. package/dist/src/agent/skills/index.js +1 -1
  81. package/dist/src/agent/skills/managed-store.js +1 -1
  82. package/dist/src/agent/skills/scanner.js +1 -1
  83. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  84. package/dist/src/agent/skills/skill-manager.js +1 -1
  85. package/dist/src/agent/tools/dreaming-tool.js +1 -1
  86. package/dist/src/agent/tools/factory.js +1 -1
  87. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  88. package/dist/src/agent/tools/send-media.js +1 -1
  89. package/dist/src/agent/tools/skill-manage-tool.js +1 -1
  90. package/dist/src/agent/tools/write.js +1 -1
  91. package/dist/src/auth/credentials.js +3 -3
  92. package/dist/src/auth/profiles/store.js +1 -1
  93. package/dist/src/auth/sync-provider-auth.js +1 -1
  94. package/dist/src/channels/attachments/inbound-persist.js +1 -1
  95. package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
  96. package/dist/src/channels/outbound/persist-store.js +1 -1
  97. package/dist/src/channels/pairing/allow-from-file.js +1 -1
  98. package/dist/src/channels/pairing/pairing-store.js +2 -2
  99. package/dist/src/chat-commands/builtins/config.js +2 -2
  100. package/dist/src/chat-commands/context.js +1 -1
  101. package/dist/src/cli/commands/agent.js +1 -1
  102. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
  103. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  104. package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -1
  105. package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
  106. package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
  107. package/dist/src/cli/commands/extension-dev.js +1 -1
  108. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  109. package/dist/src/cli/commands/extension-pack.js +1 -1
  110. package/dist/src/cli/commands/image.js +1 -1
  111. package/dist/src/cli/commands/init.js +4 -4
  112. package/dist/src/cli/commands/onboard.js +1 -1
  113. package/dist/src/cli/utils/init-workspace.js +2 -2
  114. package/dist/src/config/index.js +3 -3
  115. package/dist/src/config/loader.js +2 -2
  116. package/dist/src/config/models-json.js +2 -2
  117. package/dist/src/config/profile.js +2 -2
  118. package/dist/src/cron/executor.js +2 -2
  119. package/dist/src/cron/persistence.js +1 -1
  120. package/dist/src/cron/run-log-store.js +1 -1
  121. package/dist/src/daemon/launchd.js +2 -2
  122. package/dist/src/daemon/systemd.js +2 -2
  123. package/dist/src/extensions/health.js +1 -1
  124. package/dist/src/extensions/loader.js +1 -1
  125. package/dist/src/extensions/lockfile.js +2 -2
  126. package/dist/src/gateway/agents-admin.js +2 -2
  127. package/dist/src/gateway/hono/lib/extension-store.js +1 -1
  128. package/dist/src/gateway/hono/lib/static-ui.js +1 -1
  129. package/dist/src/gateway/hono/oauth.js +1 -1
  130. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  131. package/dist/src/gateway/hono/routes/config.js +1 -1
  132. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  133. package/dist/src/gateway/hono/routes/host-fs.js +1 -1
  134. package/dist/src/gateway/hono/routes/models.js +1 -1
  135. package/dist/src/gateway/hono/routes/workspace.js +3 -3
  136. package/dist/src/gateway/hono/sse.js +2 -2
  137. package/dist/src/gateway/lock.js +2 -2
  138. package/dist/src/gateway/service/run-gateway-agent.js +2 -2
  139. package/dist/src/gateway/service.js +5 -5
  140. package/dist/src/gateway/workspace-fs-file-list.js +1 -1
  141. package/dist/src/gateway/workspace-heartbeat-path.js +1 -1
  142. package/dist/src/infra/update-check.js +1 -1
  143. package/dist/src/infra/update-lock.js +3 -3
  144. package/dist/src/infra/update-runner.js +1 -1
  145. package/dist/src/infra/update-startup.js +2 -2
  146. package/dist/src/infra/write-file-atomic.js +2 -2
  147. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  148. package/dist/src/providers/index.js +2 -2
  149. package/dist/src/providers/model-registry.js +1 -1
  150. package/dist/src/session/config-store.js +2 -2
  151. package/dist/src/session/parity/jsonl-transcript-io.js +2 -2
  152. package/dist/src/session/parity/sessions-json-file.js +1 -1
  153. package/dist/src/session/parity/transcript-file-lock.js +2 -2
  154. package/dist/src/session/parity/transcript-paths.js +1 -1
  155. package/dist/src/session/search-index-cache.js +1 -1
  156. package/dist/src/session/search-index.js +1 -1
  157. package/dist/src/session/session-title.js +1 -1
  158. package/dist/src/session/store.js +4 -4
  159. package/dist/src/tui/backends/embedded-backend.js +1 -1
  160. package/dist/src/tui/tui.js +1 -1
  161. package/dist/src/utils/logger/audit.js +1 -1
  162. package/dist/src/utils/logger/log-store.js +1 -1
  163. package/dist/src/utils/logger/rotation.js +1 -1
  164. package/dist/src/voice/tts/audio.js +1 -1
  165. package/dist/src/voice/tts/providers/edge-speech.js +1 -1
  166. package/package.json +1 -1
package/README.md CHANGED
@@ -113,6 +113,12 @@ pnpm run build # Node + web console → dist/
113
113
 
114
114
  ---
115
115
 
116
+ ## Demo
117
+
118
+ [![asciinema](https://asciinema.org/a/PlH1sYqOiV3malzu.svg)](https://asciinema.org/a/PlH1sYqOiV3malzu)
119
+
120
+ ---
121
+
116
122
  <a id="electron-desktop"></a>
117
123
 
118
124
  ## Electron desktop app
package/README.zh-CN.md CHANGED
@@ -106,6 +106,12 @@ pnpm run build # 构建发布:Node + 网页 → d
106
106
 
107
107
  ---
108
108
 
109
+ ## 演示
110
+
111
+ [![asciinema](https://asciinema.org/a/PlH1sYqOiV3malzu.svg)](https://asciinema.org/a/PlH1sYqOiV3malzu)
112
+
113
+ ---
114
+
109
115
  <a id="electron-desktop"></a>
110
116
 
111
117
  ## Electron 桌面版
@@ -1,8 +1,8 @@
1
1
  import { getWorkspacePath, init_schema } from "../../../../src/config/schema.js";
2
2
  import { checkFileSafety } from "../../../../src/agent/prompt/safety.js";
3
3
  import { getMimeType } from "../../../../src/channels/media.js";
4
- import path from "node:path";
5
4
  import { promises } from "node:fs";
5
+ import path from "node:path";
6
6
  import { Readable } from "node:stream";
7
7
  //#region extensions/feishu/src/outbound/media-load.ts
8
8
  init_schema();
@@ -1,6 +1,6 @@
1
- import { TelegramConfigSchema, init_config_schema } from "./config-schema.js";
2
1
  import { createLogger } from "../../../src/utils/logger/index.js";
3
2
  import { init_logger } from "../../../src/utils/logger.js";
3
+ import { TelegramConfigSchema, init_config_schema } from "./config-schema.js";
4
4
  import { generateSessionKey } from "../../../src/chat-commands/session-key.js";
5
5
  import { submitClarifyChoiceFromChannel } from "../../../src/gateway/clarify-runtime.js";
6
6
  import { resolveStandardPairingPath } from "../../../src/channels/pairing/paths.js";
@@ -1,7 +1,7 @@
1
- import { buildSessionKey } from "../../../src/routing/session-key.js";
2
- import { applyIdentityLinks, resolveRoute } from "../../../src/routing/resolve-route.js";
3
1
  import { createLogger } from "../../../src/utils/logger/index.js";
4
2
  import { init_logger } from "../../../src/utils/logger.js";
3
+ import { buildSessionKey } from "../../../src/routing/session-key.js";
4
+ import { applyIdentityLinks, resolveRoute } from "../../../src/routing/resolve-route.js";
5
5
  //#region extensions/telegram/src/routing-integration.ts
6
6
  init_logger();
7
7
  const log = createLogger("TelegramRouting");
@@ -2,7 +2,7 @@
2
2
  "id": "telegram",
3
3
  "name": "Telegram Channel",
4
4
  "description": "Bundled Telegram Bot channel (private workspace sources; ships inside @xopcai/xopc dist/)",
5
- "version": "0.0.57",
5
+ "version": "0.0.58",
6
6
  "kind": "channel",
7
7
  "main": "src/index.ts",
8
8
  "channels": ["telegram"],
@@ -1,8 +1,8 @@
1
1
  import { logger } from "../util/logger.js";
2
2
  import { redactBody, redactUrl } from "../util/redact.js";
3
- import path from "node:path";
4
- import fsSync from "node:fs";
5
3
  import crypto from "node:crypto";
4
+ import fsSync from "node:fs";
5
+ import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { Agent, fetch as fetch$1 } from "undici";
8
8
  //#region extensions/weixin/src/api/api.ts
@@ -1,8 +1,8 @@
1
1
  import { logger } from "../util/logger.js";
2
2
  import { normalizeWeixinAccountId } from "./weixin-account-id.js";
3
3
  import { resolveWeixinRootDir } from "../storage/state-dir.js";
4
- import path from "node:path";
5
4
  import fsSync from "node:fs";
5
+ import path from "node:path";
6
6
  //#region extensions/weixin/src/auth/accounts.ts
7
7
  const DEFAULT_BASE_URL = "https://ilinkai.weixin.qq.com";
8
8
  const CDN_BASE_URL = "https://novac2c.cdn.weixin.qq.com/c2c";
@@ -6,9 +6,9 @@ import { getUploadUrl } from "../api/api.js";
6
6
  import { getExtensionFromContentTypeOrUrl } from "../media/mime.js";
7
7
  import { aesEcbPaddedSize } from "./aes-ecb.js";
8
8
  import { uploadBufferToCdn } from "./cdn-upload.js";
9
- import path from "node:path";
10
9
  import crypto from "node:crypto";
11
10
  import fs from "node:fs/promises";
11
+ import path from "node:path";
12
12
  //#region extensions/weixin/src/cdn/upload.ts
13
13
  /**
14
14
  * Download a remote media URL (image, video, file) to a local temp file in destDir.
@@ -1,7 +1,7 @@
1
1
  import { getExtensionFromMime } from "./mime.js";
2
- import path from "node:path";
3
2
  import { randomBytes } from "node:crypto";
4
3
  import fs from "node:fs/promises";
4
+ import path from "node:path";
5
5
  //#region extensions/weixin/src/media/data-url.ts
6
6
  /**
7
7
  * Parse `data:mime;base64,...` into buffer (aligned with Telegram `parseDataUrl`).
@@ -1,7 +1,7 @@
1
1
  import { logger } from "../util/logger.js";
2
2
  import { resolveWeixinRootDir } from "../storage/state-dir.js";
3
- import path from "node:path";
4
3
  import fsSync from "node:fs";
4
+ import path from "node:path";
5
5
  //#region extensions/weixin/src/messaging/debug-mode.ts
6
6
  /**
7
7
  * Per-bot debug mode toggle, persisted to disk so it survives gateway restarts.
@@ -3,8 +3,8 @@ import { generateId } from "../util/random.js";
3
3
  import { MessageItemType } from "../api/types.js";
4
4
  import { canonicalWeixinPeerId, normalizeWeixinAccountId } from "../auth/weixin-account-id.js";
5
5
  import { resolveWeixinRootDir } from "../storage/state-dir.js";
6
- import path from "node:path";
7
6
  import fsSync from "node:fs";
7
+ import path from "node:path";
8
8
  //#region extensions/weixin/src/messaging/inbound.ts
9
9
  /**
10
10
  * contextToken is issued per-message by the Weixin getupdates API and must
@@ -11,9 +11,9 @@ import { downloadMediaFromItem } from "../media/media-download.js";
11
11
  import { isDebugMode } from "./debug-mode.js";
12
12
  import { sendMessageWeixin } from "./send.js";
13
13
  import { handleSlashCommand } from "./slash-commands.js";
14
- import path from "node:path";
15
14
  import { randomBytes } from "node:crypto";
16
15
  import { mkdir, readFile, writeFile } from "node:fs/promises";
16
+ import path from "node:path";
17
17
  //#region extensions/weixin/src/messaging/process-message.ts
18
18
  function extractTextBody(itemList) {
19
19
  if (!itemList?.length) return "";
@@ -1,6 +1,6 @@
1
- import { WeixinConfigSchema, init_config_schema } from "./config-schema.js";
2
1
  import { createLogger } from "../../../src/utils/logger/index.js";
3
2
  import { init_logger } from "../../../src/utils/logger.js";
3
+ import { WeixinConfigSchema, init_config_schema } from "./config-schema.js";
4
4
  import { evaluateAccess, resolveDmPolicy } from "../../../src/channels/security.js";
5
5
  import { restoreContextTokens } from "./messaging/inbound.js";
6
6
  import { listWeixinAccountIds, resolveWeixinAccount } from "./auth/accounts.js";
@@ -1,6 +1,6 @@
1
1
  import { resolveWeixinRootDir } from "./state-dir.js";
2
- import path from "node:path";
3
2
  import fsSync from "node:fs";
3
+ import path from "node:path";
4
4
  //#region extensions/weixin/src/storage/sync-buf.ts
5
5
  function resolveAccountsDir() {
6
6
  return path.join(resolveWeixinRootDir(), "accounts");
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{i as r}from"./vendor-swr-B5fPo7KK.js";import{$ as i,$n as a,A as o,Ai as s,An as c,At as l,Bn as u,Br as d,Bt as f,Cn as p,Cr as m,Ct as h,D as g,Dn as _,E as v,Ei as y,Er as b,F as x,Gn as S,Gr as C,Hn as w,I as T,Jn as ee,Jr as E,Kn as te,L as D,Ln as O,Lt as k,M as A,Mn as j,Mr as ne,Mt as M,N as re,Nr as ie,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,Qn as N,Rn as P,Rr as de,Rt as fe,Sn as F,St as pe,T as me,Un as he,Ur as ge,Wn as _e,Xr as ve,Z as ye,_n as be,_r as xe,a as Se,ai as I,at as L,bi as Ce,bn as we,c as R,cr as z,ct as B,d as Te,dn as V,f as Ee,gn as H,gr as De,hn as Oe,hr as ke,ii as Ae,it as je,j as Me,ji as Ne,jn as Pe,jt as Fe,k as Ie,ki as Le,kn as Re,kt as ze,li as Be,lr as Ve,lt as He,mr as Ue,ni as We,nr as Ge,nt as Ke,o as qe,oi as Je,ot as U,pr as W,qn as G,rt as K,s as Ye,st as Xe,tr as Ze,u as Qe,ur as $e,ut as et,vi as tt,vn as nt,w as rt,wi as it,xr as at,zn as ot,zt as st}from"./index-DHte7V8E.js";import{E as ct,S as lt,_ as ut,a as dt,f as ft,n as pt,p as mt,s as ht,t as gt}from"./cron-dreaming-jobs-DIwTeQzu.js";var q=n();function _t({open:e,onOpenChange:t,busy:n,deletePurge:r,deleteTarget:i,deleteConfirmText:a,onDeleteConfirmTextChange:o,onConfirm:s,onCancel:c,a:u}){return(0,q.jsx)(ae,{open:e,onOpenChange:t,children:(0,q.jsxs)(M,{children:[(0,q.jsx)(Fe,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ze,{className:O(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsx)(le,{className:`text-base font-semibold text-fg`,children:r?u.purgeDisk:u.removeFromConfig}),(0,q.jsx)(l,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:r?u.confirmDeletePurge:u.confirmDelete}),r&&i?(0,q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:u.purgeConfirmLabel}),(0,q.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:O(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:u.purgeConfirmPlaceholder.replace(`{{agentId}}`,i.id),value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:u.purgeConfirmHint.replace(`{{agentId}}`,i.id)})]}):null,(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,q.jsx)(j,{type:`button`,variant:`ghost`,disabled:n,onClick:c,children:u.createModalCancel}),(0,q.jsx)(j,{type:`button`,variant:`secondary`,className:r?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,disabled:n||!i||r&&a.trim().toLowerCase()!==i.id.toLowerCase(),onClick:s,children:r?u.purgeDisk:u.removeFromConfig})]})]})]})})}var vt=[{id:`overview`,labelKey:`navIdentity`,icon:w},{id:`profile`,labelKey:`navProfile`,icon:Be},{id:`tools`,labelKey:`navTools`,icon:u},{id:`skills`,labelKey:`navSkills`,icon:Ue},{id:`files`,labelKey:`navCoreFiles`,icon:E}],yt=[{id:`channels`,labelKey:`tabChannels`,icon:De},{id:`cron`,labelKey:`tabCron`,icon:Je}];function bt(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:O(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,n===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,q.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,q.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:vt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,q.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:yt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function xt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:c,footerSaveDisabled:u,footerSavedFlash:d,busy:f,children:p}=e;return(0,q.jsx)(ae,{open:t,onOpenChange:n,children:(0,q.jsxs)(M,{children:[(0,q.jsx)(Fe,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,R)}),(0,q.jsxs)(ze,{className:O(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,qe,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,q.jsx)(le,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,q.jsx)(l,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,q.jsx)(se,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.closeDialogAria,children:(0,q.jsx)(ot,{className:`size-4`,"aria-hidden":!0})})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,q.jsx)(bt,{a:r,panel:o,onPanelChange:s})}),(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:p}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[d?(0,q.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,r.personaSaved]}):u?(0,q.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:r.footerSaveNotApplicable}):null,(0,q.jsx)(j,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:f||u,onClick:()=>void c(),children:r.save})]})]})]})]})]})})}function St(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function J({children:e,className:t}){return(0,q.jsx)(`section`,{className:O(St(),t),children:e})}var Ct=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function Y({icon:e,title:t,subtitle:n,trailing:r,className:i,iconInteractive:a,iconLeading:o}){let s=o??(0,q.jsx)(e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),c=o?O(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`):O(Ct,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),l=!!(a&&o);return(0,q.jsxs)(`div`,{className:O(`mb-5 flex items-start gap-3`,i),children:[a?l?(0,q.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,q.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}),(0,q.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,q.jsx)(at,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,q.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}):(0,q.jsx)(`div`,{className:O(o?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:Ct),"aria-hidden":!o,children:s}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,q.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function X(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,c,`dark:border-edge`)}function wt(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function Tt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function Et(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var Dt=O(Re,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Ot(e){let{a:t,busy:n,bindingsLoading:r,agentBindings:i,onRemoveBinding:a,onAddBinding:o,channelStatuses:s,channelsStatusLoading:c,useManualChannel:l,newBindChannel:u,setNewBindChannel:d,bindSessionChats:f,sessionsLoading:p,newBindSessionIdx:m,setNewBindSessionIdx:h,newBindCustomPeer:g,setNewBindCustomPeer:_,onRefreshSessions:v,lastActiveLabels:y,selectRecipient:b}=e,x=!c&&(l||s.length>0);return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:ne,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,q.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs`,children:Tt(e.match)}),(0,q.jsx)(j,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,q.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,q.jsx)(`input`,{className:X(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,q.jsx)(`select`,{className:O(X(),`py-2`),value:u,onChange:e=>{d(e.target.value),h(null),_(``)},children:s.map(e=>(0,q.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),x&&u.trim()?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,q.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||p||!u.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>v(),children:[(0,q.jsx)(W,{className:O(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,q.jsxs)(`select`,{className:O(X(),`py-2`),value:m==null?``:String(m),disabled:n||!u.trim()||!!g.trim(),onChange:e=>{let t=e.target.value;h(t===``?null:Number(t))},children:[(0,q.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,q.jsx)(`option`,{value:String(t),children:lt(e,y)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,q.jsx)(`input`,{type:`text`,className:O(X(),`min-w-0 w-full sm:flex-1`),value:g,onChange:e=>{_(e.target.value),e.target.value.trim()&&h(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,q.jsxs)(`select`,{className:Dt,value:g,onChange:e=>{let t=e.target.value;_(t||``),h(null)},children:[(0,q.jsx)(`option`,{value:``,children:b}),f.map(e=>(0,q.jsx)(`option`,{value:e.chatId,children:lt(e,y)},`${e.channel}-${e.chatId}`))]})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,q.jsx)(`div`,{children:(0,q.jsx)(j,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function kt(e){let t=e.kind===`cron`?ct(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):pt(e.valueMs,e.locale,e.presetLabels);return(0,q.jsx)(`span`,{className:e.className,children:t})}function At(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e,s=p(e=>e.language),c=Pe(s),l=s===`zh`?`zh-CN`:`en-US`,u=c.cron.scheduleBadge;return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:it,title:t.cronTitle,subtitle:t.cronHint}),i?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,q.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,q.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(kt,{kind:`cron`,expression:e.schedule,locale:l,labels:u,timezone:e.timezone,nextRun:e.next_run,className:`text-sm font-medium text-fg`}),(0,q.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:e.schedule,children:e.schedule})]})}),(0,q.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:dt(e),children:dt(e)}),(0,q.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,q.jsxs)(`select`,{className:O(X(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,q.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function jt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,filesViewMode:o,setFilesViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,profileFileLoading:d,profileEditorNonce:f}=e,p=F(e=>e.resolved===`dark`);return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":t.navCoreFiles,children:r.files.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:O(`-mb-px shrink-0 border-b-2 border-transparent px-3 py-2 text-left font-mono text-xs whitespace-nowrap transition-colors`,i===e.name?`border-accent text-fg`:`text-fg-muted hover:border-edge-subtle hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>a(e.name),children:[e.name,e.missing?` (${t.missing})`:``]},e.name))}),(0,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${t.filesMarkdownEdit} / ${t.filesMarkdownPreview}`,children:[(0,q.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`edit`),children:[(0,q.jsx)(N,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownEdit]}),(0,q.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`preview`),children:[(0,q.jsx)(ve,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownPreview]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,q.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,q.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,q.jsx)(`div`,{className:O(X(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,q.jsx)(ue,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,q.jsx)(`div`,{className:O(X(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,q.jsx)(ye,{content:c,className:`text-sm`})})]}):(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var Z=e(t(),1);function Mt(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function Nt(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,p]=(0,Z.useState)(!1),m=(0,Z.useMemo)(()=>{let e=et(n.trim());return e&&He(e.styleId)?e.styleId:L[0]??`adventurer`},[n]),h=(0,Z.useCallback)(async(e,n)=>{try{await g(t)}catch{}r(Xe(e,n)),p(!1)},[t,r]),_=(0,Z.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await D(t,n),r(U)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),v=(e,t)=>{let r=et(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,q.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void _(e)}),(0,q.jsxs)(j,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,q.jsx)(_e,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:L.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>void h(e,je[0]??t),className:O(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,m===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Mt(e,i)},e))}),(0,q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[je.map(e=>(0,q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:O(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,v(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,q.jsx)(`img`,{src:B(m,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,q.jsxs)(st,{open:d,onOpenChange:p,children:[(0,q.jsx)(f,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,children:i.avatarMore})}),(0,q.jsx)(fe,{children:(0,q.jsxs)(k,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,q.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:Mt(m,i)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(e=>(0,q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:O(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,v(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,q.jsx)(`img`,{src:B(m,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,q.jsx)(Ke,{agentId:t,avatar:n,size:40}),n.trim()&&!et(n.trim())&&n.trim()!==`xopc:custom`?(0,q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var Pt={name:``,creature:``,emoji:``,avatar:``};function Ft(e){let t={...Pt};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{i as t,t as n}from"./vendor-react-DbimaAId.js";import{i as r}from"./vendor-swr-B5fPo7KK.js";import{$ as i,$n as a,A as o,Ai as s,An as c,At as l,Bn as u,Br as d,Bt as f,Cn as p,Cr as m,Ct as h,D as g,Dn as _,E as v,Ei as y,Er as b,F as x,Gn as S,Gr as C,Hn as w,I as T,Jn as ee,Jr as E,Kn as te,L as D,Ln as O,Lt as k,M as A,Mn as j,Mr as ne,Mt as M,N as re,Nr as ie,Nt as ae,O as oe,Ot as se,P as ce,Pt as le,Q as ue,Qn as N,Rn as P,Rr as de,Rt as fe,Sn as F,St as pe,T as me,Un as he,Ur as ge,Wn as _e,Xr as ve,Z as ye,_n as be,_r as xe,a as Se,ai as I,at as L,bi as Ce,bn as we,c as R,cr as z,ct as B,d as Te,dn as V,f as Ee,gn as H,gr as De,hn as Oe,hr as ke,ii as Ae,it as je,j as Me,ji as Ne,jn as Pe,jt as Fe,k as Ie,ki as Le,kn as Re,kt as ze,li as Be,lr as Ve,lt as He,mr as Ue,ni as We,nr as Ge,nt as Ke,o as qe,oi as Je,ot as U,pr as W,qn as G,rt as K,s as Ye,st as Xe,tr as Ze,u as Qe,ur as $e,ut as et,vi as tt,vn as nt,w as rt,wi as it,xr as at,zn as ot,zt as st}from"./index-BDiwAtHo.js";import{E as ct,S as lt,_ as ut,a as dt,f as ft,n as pt,p as mt,s as ht,t as gt}from"./cron-dreaming-jobs-Bw0WqucT.js";var q=n();function _t({open:e,onOpenChange:t,busy:n,deletePurge:r,deleteTarget:i,deleteConfirmText:a,onDeleteConfirmTextChange:o,onConfirm:s,onCancel:c,a:u}){return(0,q.jsx)(ae,{open:e,onOpenChange:t,children:(0,q.jsxs)(M,{children:[(0,q.jsx)(Fe,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,q.jsxs)(ze,{className:O(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsx)(le,{className:`text-base font-semibold text-fg`,children:r?u.purgeDisk:u.removeFromConfig}),(0,q.jsx)(l,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:r?u.confirmDeletePurge:u.confirmDelete}),r&&i?(0,q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,q.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:u.purgeConfirmLabel}),(0,q.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:O(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:u.purgeConfirmPlaceholder.replace(`{{agentId}}`,i.id),value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:u.purgeConfirmHint.replace(`{{agentId}}`,i.id)})]}):null,(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,q.jsx)(j,{type:`button`,variant:`ghost`,disabled:n,onClick:c,children:u.createModalCancel}),(0,q.jsx)(j,{type:`button`,variant:`secondary`,className:r?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,disabled:n||!i||r&&a.trim().toLowerCase()!==i.id.toLowerCase(),onClick:s,children:r?u.purgeDisk:u.removeFromConfig})]})]})]})})}var vt=[{id:`overview`,labelKey:`navIdentity`,icon:w},{id:`profile`,labelKey:`navProfile`,icon:Be},{id:`tools`,labelKey:`navTools`,icon:u},{id:`skills`,labelKey:`navSkills`,icon:Ue},{id:`files`,labelKey:`navCoreFiles`,icon:E}],yt=[{id:`channels`,labelKey:`tabChannels`,icon:De},{id:`cron`,labelKey:`tabCron`,icon:Je}];function bt(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:O(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,n===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,q.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,q.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:vt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,q.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:yt.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function xt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:c,footerSaveDisabled:u,footerSavedFlash:d,busy:f,children:p}=e;return(0,q.jsx)(ae,{open:t,onOpenChange:n,children:(0,q.jsxs)(M,{children:[(0,q.jsx)(Fe,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,R)}),(0,q.jsxs)(ze,{className:O(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,qe,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,q.jsx)(le,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,q.jsx)(l,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,q.jsx)(se,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.closeDialogAria,children:(0,q.jsx)(ot,{className:`size-4`,"aria-hidden":!0})})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,q.jsx)(bt,{a:r,panel:o,onPanelChange:s})}),(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:p}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[d?(0,q.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,r.personaSaved]}):u?(0,q.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:r.footerSaveNotApplicable}):null,(0,q.jsx)(j,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:f||u,onClick:()=>void c(),children:r.save})]})]})]})]})]})})}function St(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function J({children:e,className:t}){return(0,q.jsx)(`section`,{className:O(St(),t),children:e})}var Ct=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function Y({icon:e,title:t,subtitle:n,trailing:r,className:i,iconInteractive:a,iconLeading:o}){let s=o??(0,q.jsx)(e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),c=o?O(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`):O(Ct,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),l=!!(a&&o);return(0,q.jsxs)(`div`,{className:O(`mb-5 flex items-start gap-3`,i),children:[a?l?(0,q.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,q.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}),(0,q.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,q.jsx)(at,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,q.jsx)(`button`,{type:`button`,id:a.id,onClick:a.onClick,"aria-label":a.ariaLabel,className:c,children:s}):(0,q.jsx)(`div`,{className:O(o?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:Ct),"aria-hidden":!o,children:s}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]}),r?(0,q.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function X(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,c,`dark:border-edge`)}function wt(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function Tt(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function Et(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var Dt=O(Re,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function Ot(e){let{a:t,busy:n,bindingsLoading:r,agentBindings:i,onRemoveBinding:a,onAddBinding:o,channelStatuses:s,channelsStatusLoading:c,useManualChannel:l,newBindChannel:u,setNewBindChannel:d,bindSessionChats:f,sessionsLoading:p,newBindSessionIdx:m,setNewBindSessionIdx:h,newBindCustomPeer:g,setNewBindCustomPeer:_,onRefreshSessions:v,lastActiveLabels:y,selectRecipient:b}=e,x=!c&&(l||s.length>0);return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:ne,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,q.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`font-mono text-xs`,children:Tt(e.match)}),(0,q.jsx)(j,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,q.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,q.jsx)(`input`,{className:X(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,q.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,q.jsx)(`select`,{className:O(X(),`py-2`),value:u,onChange:e=>{d(e.target.value),h(null),_(``)},children:s.map(e=>(0,q.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),x&&u.trim()?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,q.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||p||!u.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>v(),children:[(0,q.jsx)(W,{className:O(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,q.jsxs)(`select`,{className:O(X(),`py-2`),value:m==null?``:String(m),disabled:n||!u.trim()||!!g.trim(),onChange:e=>{let t=e.target.value;h(t===``?null:Number(t))},children:[(0,q.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,q.jsx)(`option`,{value:String(t),children:lt(e,y)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,q.jsx)(`input`,{type:`text`,className:O(X(),`min-w-0 w-full sm:flex-1`),value:g,onChange:e=>{_(e.target.value),e.target.value.trim()&&h(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,q.jsxs)(`select`,{className:Dt,value:g,onChange:e=>{let t=e.target.value;_(t||``),h(null)},children:[(0,q.jsx)(`option`,{value:``,children:b}),f.map(e=>(0,q.jsx)(`option`,{value:e.chatId,children:lt(e,y)},`${e.channel}-${e.chatId}`))]})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,q.jsx)(`div`,{children:(0,q.jsx)(j,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function kt(e){let t=e.kind===`cron`?ct(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):pt(e.valueMs,e.locale,e.presetLabels);return(0,q.jsx)(`span`,{className:e.className,children:t})}function At(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e,s=p(e=>e.language),c=Pe(s),l=s===`zh`?`zh-CN`:`en-US`,u=c.cron.scheduleBadge;return(0,q.jsxs)(J,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,q.jsx)(Y,{className:`shrink-0`,icon:it,title:t.cronTitle,subtitle:t.cronHint}),i?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,q.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,q.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,q.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(kt,{kind:`cron`,expression:e.schedule,locale:l,labels:u,timezone:e.timezone,nextRun:e.next_run,className:`text-sm font-medium text-fg`}),(0,q.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:e.schedule,children:e.schedule})]})}),(0,q.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:dt(e),children:dt(e)}),(0,q.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,q.jsx)(`td`,{className:`py-2 pr-3`,children:(0,q.jsxs)(`select`,{className:O(X(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,q.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.id},e.id))]})})]},e.id)})})]})})]})}function jt(e){let{a:t,filesLoading:n,files:r,activeFile:i,setActiveFile:a,filesViewMode:o,setFilesViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,profileFileLoading:d,profileEditorNonce:f}=e,p=F(e=>e.resolved===`dark`);return(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,q.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":t.navCoreFiles,children:r.files.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:O(`-mb-px shrink-0 border-b-2 border-transparent px-3 py-2 text-left font-mono text-xs whitespace-nowrap transition-colors`,i===e.name?`border-accent text-fg`:`text-fg-muted hover:border-edge-subtle hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>a(e.name),children:[e.name,e.missing?` (${t.missing})`:``]},e.name))}),(0,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${t.filesMarkdownEdit} / ${t.filesMarkdownPreview}`,children:[(0,q.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`edit`),children:[(0,q.jsx)(N,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownEdit]}),(0,q.jsxs)(`button`,{type:`button`,className:O(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,o===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>s(`preview`),children:[(0,q.jsx)(ve,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesMarkdownPreview]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,q.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,q.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,q.jsx)(`div`,{className:O(X(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,q.jsx)(ue,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,q.jsx)(`div`,{className:O(X(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,q.jsx)(ye,{content:c,className:`text-sm`})})]}):(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,q.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}var Z=e(t(),1);function Mt(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function Nt(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,p]=(0,Z.useState)(!1),m=(0,Z.useMemo)(()=>{let e=et(n.trim());return e&&He(e.styleId)?e.styleId:L[0]??`adventurer`},[n]),h=(0,Z.useCallback)(async(e,n)=>{try{await g(t)}catch{}r(Xe(e,n)),p(!1)},[t,r]),_=(0,Z.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await D(t,n),r(U)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),v=(e,t)=>{let r=et(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,q.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void _(e)}),(0,q.jsxs)(j,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,q.jsx)(_e,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:L.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>void h(e,je[0]??t),className:O(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,m===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:Mt(e,i)},e))}),(0,q.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[je.map(e=>(0,q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:O(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,v(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,q.jsx)(`img`,{src:B(m,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,q.jsxs)(st,{open:d,onOpenChange:p,children:[(0,q.jsx)(f,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,children:i.avatarMore})}),(0,q.jsx)(fe,{children:(0,q.jsxs)(k,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,q.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:Mt(m,i)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(e=>(0,q.jsx)(`button`,{type:`button`,title:e,onClick:()=>void h(m,e),className:O(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,v(m,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,q.jsx)(`img`,{src:B(m,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,q.jsx)(Ke,{agentId:t,avatar:n,size:40}),n.trim()&&!et(n.trim())&&n.trim()!==`xopc:custom`?(0,q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var Pt={name:``,creature:``,emoji:``,avatar:``};function Ft(e){let t={...Pt};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
2
2
  `)){let e=r.match(/^[-*]\s+\*\*(\w+):\*\*\s*(.*)/i);if(!e)continue;let i=n[e[1].toLowerCase()];if(!i)continue;let a=e[2].trim();/^_\(.*\)_$/.test(a)&&(a=``),t[i]=a}return t}function It(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
3
3
  `)}var Lt={callName:``,pronouns:``,timezone:``,notes:``};function Rt(e){let t={...Lt};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
4
4
  `),i=-1;for(let e=0;e<r.length;e++){let a=r[e];if(/^##\s+Context/i.test(a)){i=e+1;continue}let o=a.match(/^[-*]\s+\*\*(.+?):\*\*\s*(.*)/i);if(!o)continue;let s=n[o[1].toLowerCase().trim()];if(!s)continue;let c=o[2].trim();/^_\(.*\)_$/.test(c)&&(c=``),t[s]=c}if(i>0){let e=r.slice(i).join(`
@@ -213,4 +213,4 @@ Analytical, clear, and methodical. Like a good data scientist — lets the numbe
213
213
 
214
214
  Bold, aesthetic, and thoughtful. Like a creative director who has opinions but listens — pushes for better while respecting what the client actually needs.
215
215
  `}];function _n({existingAgentIds:e,onComplete:t,onSkip:n}){let r=p(e=>e.language),i=Pe(r).agentsSettings,o=(0,Z.useMemo)(()=>gn.filter(t=>!e.has(t.id)),[e]),[s,c]=(0,Z.useState)(()=>new Set(gn.map(e=>e.id))),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{o.length===0&&t()},[o,t]);let g=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=async()=>{let e=o.filter(e=>s.has(e.id));if(e.length===0){t();return}u(!0),h(null),f({current:0,total:e.length});for(let t=0;t<e.length;t++){let n=e[t];f({current:t+1,total:e.length});try{await v({name:n.name,id:n.id,workspace:`~/.xopc/workspace/${n.id}`,description:r===`zh`?n.descriptionZh:n.descriptionEn}),await x(n.id,`IDENTITY.md`,n.identityMd),await x(n.id,`SOUL.md`,n.soulMd);let e=n.toolsDisable;e&&e.length>0&&await T(n.id,{toolsDisable:e})}catch(e){let t=e instanceof Error?e.message:String(e);if(t.toLowerCase().includes(`already exists`))continue;h(i.presetCreateFailed.replace(`{{name}}`,n.name).replace(`{{message}}`,t)),u(!1);return}}u(!1),t()};return o.length===0?null:(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center gap-6 px-4 py-12`,children:[(0,q.jsxs)(`div`,{className:`text-center`,children:[(0,q.jsxs)(`div`,{className:`mb-3 inline-flex items-center gap-2 rounded-full bg-accent/10 px-3 py-1.5 text-sm font-medium text-accent`,children:[(0,q.jsx)(a,{className:`size-4`,"aria-hidden":!0}),i.presetSetupBadge]}),(0,q.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:i.presetSetupTitle}),(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i.presetSetupSubtitle})]}),(0,q.jsx)(`div`,{className:`w-full space-y-3`,children:o.map(e=>(0,q.jsx)(vn,{preset:e,checked:s.has(e.id),disabled:l,language:r,onToggle:()=>g(e.id)},e.id))}),m?(0,q.jsx)(`div`,{role:`alert`,className:`w-full rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:m}):null,d&&l?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.presetCreatingProgress.replace(`{{current}}`,String(d.current)).replace(`{{total}}`,String(d.total))}):null,(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between border-t border-edge-subtle pt-4`,children:[(0,q.jsxs)(j,{type:`button`,variant:`ghost`,className:`gap-2 text-fg-muted`,disabled:l,onClick:()=>{localStorage.setItem(hn,`true`),n()},children:[(0,q.jsx)(Ge,{className:`size-4`,"aria-hidden":!0}),i.presetSkip]}),(0,q.jsxs)(j,{type:`button`,variant:`primary`,className:`gap-2`,disabled:l||s.size===0,onClick:()=>void _(),children:[(0,q.jsx)(a,{className:`size-4`,"aria-hidden":!0}),l?i.presetCreating:i.presetCreateSelected.replace(`{{count}}`,String(s.size))]})]})]})}function vn(e){let{preset:t,checked:n,disabled:r,language:i,onToggle:a}=e,o=i===`zh`?t.descriptionZh:t.descriptionEn;return(0,q.jsxs)(`label`,{className:O(`flex cursor-pointer items-start gap-3 rounded-xl border px-4 py-3 transition-colors`,n?`border-accent/50 bg-accent/5`:`border-edge-subtle bg-surface-panel/40`,r&&`pointer-events-none opacity-50`),children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:n,disabled:r,onChange:a,className:`mt-1 shrink-0 accent-accent`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:t.emoji}),(0,q.jsx)(`span`,{className:`font-medium text-fg`,children:t.name})]}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:o})]})]})}var yn=`main`,bn=/^[a-z0-9][a-z0-9_-]{0,63}$/i,xn=/[^a-z0-9_-]+/g,Sn=/^-+/,Cn=/-+$/,wn=/^[a-z0-9][a-z0-9_-]{0,63}$/,Tn=new Set([`con`,`prn`,`aux`,`nul`,`com1`,`com2`,`com3`,`com4`,`com5`,`com6`,`com7`,`com8`,`com9`,`lpt1`,`lpt2`,`lpt3`,`lpt4`,`lpt5`,`lpt6`,`lpt7`,`lpt8`,`lpt9`]);function En(e){let t=e.trim();if(!t)return yn;let n=t.toLowerCase();return bn.test(t)?n:n.replace(xn,`-`).replace(Sn,``).replace(Cn,``).slice(0,64)||yn}function Dn(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return wn.test(e)?e===yn?{ok:!1,error:`"${yn}" is reserved`}:Tn.has(e)?{ok:!1,error:`Agent id "${e}" is reserved (Windows device name).`}:{ok:!0,agentId:e}:{ok:!1,error:`Invalid agent id: use 1–64 characters; letters, digits, underscores, and hyphens only; start with a letter or digit.`}}let r=En(t.trim());return r===yn?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:Tn.has(r)?{ok:!1,error:`That display name resolves to "${r}", which is reserved. Use a different display name or set an explicit Agent id.`}:wn.test(r)?{ok:!0,agentId:r}:{ok:!1,error:`Could not derive a folder-safe agent id from the display name. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}}function On(e){let t=e.trim();return t?`~/.xopc/workspace/${En(t)}`:``}function kn(){return V(`/api/dreaming`)}async function An(){let e=await H(kn());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function jn(e){await H(V(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function Mn(e=`deep`){let t=await H(V(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})}),n=!!t.payload?.triggered,r=typeof t.payload?.jobId==`string`?t.payload.jobId:``;if(!n||!r)throw Error(`Failed to trigger`);return{triggered:n,jobId:r,phase:e}}async function Nn(e){let t=await H(V(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function Pn(e=50){return(await H(V(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function Fn({language:e,a:t,busy:n,sleeping:r,listSearchQuery:i,onListSearchQueryChange:a,onSleep:o,onAddAgent:s}){return(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,q.jsxs)(j,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,disabled:n||r,onClick:()=>void o(),"aria-label":e===`zh`?`让智能体进入睡眠流程`:`Trigger agent sleep sequence`,title:e===`zh`?`由浅入深:Light → Deep → REM`:`Light → Deep → REM`,children:[(0,q.jsx)(m,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e===`zh`?r?`睡眠中…`:`睡眠`:r?`Sleeping…`:`Sleep`]}),(0,q.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[(0,q.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,q.jsx)(`input`,{type:`search`,role:`searchbox`,enterKeyHint:`search`,value:i,onChange:e=>a(e.target.value),placeholder:t.listSearchPlaceholder,autoComplete:`off`,spellCheck:!1,"aria-label":t.listSearchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),(0,q.jsxs)(j,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":t.addAgentAria,disabled:n,onClick:()=>s(),children:[(0,q.jsx)(ke,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t.addAgent]})]})}function In(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:a,saveErrorMessage:s,setError:c}=e,[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`edit`),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(0),ee=(0,Z.useRef)(h);ee.current=h;let E=(0,Z.useRef)(n);E.current=n;let te=(0,Z.useRef)(p);te.current=p;let D=(0,Z.useRef)(null),O=(0,Z.useRef)(``),k=(0,Z.useRef)(``),A=i(async()=>{let e=E.current,t=te.current;if(!e||!t||`${e}:${t}`!==O.current)return;let n=ee.current;if(n!==k.current){v(!0),c(null);try{await x(e,t,n),k.current=n,u(n=>!n||n.agentId!==e?n:{...n,files:n.files.map(e=>e.name===t?{...e,missing:!1}:e)})}catch(e){c(e instanceof Error?e.message:s)}finally{v(!1)}}},800),j=(0,Z.useRef)(A.flush);return j.current=A.flush,(0,Z.useEffect)(()=>()=>{j.current()},[]),(0,Z.useEffect)(()=>{if(t!==`files`||!n||!r)return;let e=!1;return f(!0),o(n).then(t=>{e||u(t)}).catch(()=>{e||u(null)}).finally(()=>{e||f(!1)}),()=>{e=!0}},[t,n,r,a]),(0,Z.useEffect)(()=>{if(!p||!n||!r)return;let e=!1;return A.flush(),C(!0),Ie(n,p).then(t=>{e||(O.current=`${n}:${p}`,k.current=t,g(t),T(e=>e+1))}).catch(()=>{e||(O.current=`${n}:${p}`,k.current=``,g(``),T(e=>e+1))}).finally(()=>{e||C(!1)}),()=>{e=!0}},[p,n,r,A]),(0,Z.useEffect)(()=>{!p||!n||S||A()},[h,p,n,S,A]),(0,Z.useEffect)(()=>{if(t===`files`)return()=>{A.flush()}},[t,A]),(0,Z.useEffect)(()=>{b(`edit`)},[p,n]),{files:l,setFiles:u,filesLoading:d,activeFile:p,setActiveFile:m,fileDraft:h,setFileDraft:g,fileSaving:_,filesViewMode:y,setFilesViewMode:b,profileFileLoading:S,profileEditorNonce:w,overviewSaveProfileMarkdownRef:D,saveProfileMarkdownDebounced:A}}function Ln(e){let{panel:t,hasToken:n,bindingsFromConfig:r,gatewayCfgLoading:i,selected:a,saveErrorMessage:o,setBusy:s,setError:c}=e,[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(``),T=(0,Z.useMemo)(()=>a?l.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[l,a?.id]);(0,Z.useEffect)(()=>{t!==`channels`||!n||u(r)},[t,n,r]),(0,Z.useEffect)(()=>{if(t!==`channels`||!n)return;let e=!1;return g(!0),ht().then(t=>{e||m(t)}).catch(()=>{e||m([])}).finally(()=>{e||g(!1)}),()=>{e=!0}},[t,n]),(0,Z.useEffect)(()=>{h||t!==`channels`||p.length===0||f(e=>e&&p.some(t=>t.name===e)?e:p[0].name)},[h,t,p]),(0,Z.useEffect)(()=>{if(t!==`channels`||!n)return;let e=d.trim();if(!e){v([]);return}let r=!1;return S(null),b(!0),ft(e).then(e=>{r||v(e)}).catch(()=>{r||v([])}).finally(()=>{r||b(!1)}),()=>{r=!0}},[t,n,d]);let ee=(0,Z.useCallback)(()=>{let e=d.trim();e&&(b(!0),ft(e).then(e=>{v(e),S(t=>t!=null&&t<e.length?t:null)}).catch(()=>{v([]),S(null)}).finally(()=>{b(!1)}))},[d]),E=!h&&p.length===0,te=t===`channels`&&n&&i,D=(0,Z.useCallback)(async e=>{s(!0),c(null);try{let t=l.filter(t=>t!==e);await ce(t),u(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[l,o,s,c]);return{agentBindings:T,allBindings:l,bindChannelStatuses:p,bindChannelsLoading:h,bindSessionChats:_,bindSessionsLoading:y,bindingsLoading:te,newBindChannel:d,setNewBindChannel:f,newBindSessionIdx:x,setNewBindSessionIdx:S,newBindCustomPeer:C,setNewBindCustomPeer:w,onAddBinding:(0,Z.useCallback)(async e=>{if(e.preventDefault(),!a||!d.trim())return;let t=Et(d,C,x,_),n=[...l,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await ce(n),u(n),S(null),w(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[l,_,d,C,x,o,a,s,c]),onRemoveBinding:D,refreshBindSessions:ee,useManualChannel:E}}function Rn(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!1),f=(0,Z.useMemo)(()=>!r||!i?[]:c.filter(e=>!gt(e)&&wt(e,i.id,r.defaultId)),[c,r,i]);(0,Z.useEffect)(()=>{if(t!==`cron`||!n)return;let e=!1;return d(!0),mt().then(t=>{e||l(t)}).catch(()=>{e||l([])}).finally(()=>{e||d(!1)}),()=>{e=!0}},[t,n]);async function p(e,t){o(!0),s(null);try{await ut(e.id,{agentId:t===``?null:t}),l(await mt())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:f,cronJobs:c,cronLoading:u,onSetCronJobAgent:p}}function zn(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),o=(0,Z.useMemo)(()=>n.filter(e=>e.enabled!==!1),[n]);return(0,Z.useEffect)(()=>{if(!e||!t)return;let n=!1;return a(!0),A().then(e=>{n||r(e)}).catch(()=>{n||r([])}).finally(()=>{n||a(!1)}),()=>{n=!0}},[e,t]),{catalogForPick:o,skillCatalog:n,skillsCatalogLoading:i}}function Bn(e){return zn(e.panel===`skills`,e.hasToken)}function Vn(e){let{panel:t,selected:n}=e,[r,i]=(0,Z.useState)(()=>new Set),[a,o]=(0,Z.useState)(()=>new Set),[s,c]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{!n||t!==`tools`||i(new Set(n.tools.entryDisable))},[t,n]),(0,Z.useEffect)(()=>{if(!n||t!==`skills`)return;let e=n.skills.entry===void 0;if(c(e),e){let e=n.skills.effectiveAllowlist;o(new Set(e??[]))}else o(new Set(n.skills.entry??[]))},[t,n]),{toolEntryDisable:r,setToolEntryDisable:i,skillsPick:a,setSkillsPick:o,skillsInherit:s,setSkillsInherit:c}}function Hn(){let e=p(e=>e.language),t=Pe(e),n=t.agentsSettings,[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),m=t.cron,g=t.chat,_=!!nt(e=>e.token),[y,b]=Ne(),x=Le(),{agentId:S}=s(),C=be(e=>e.setPageHeader),w=be(e=>e.clearPageHeader),{data:ee,error:E,isLoading:te,mutate:D}=r(_?`settings-gateway-agents`:null,Me,{revalidateOnFocus:!1}),{data:O}=h(_),k=(0,Z.useMemo)(()=>re(O?.payload?.config??{}),[O]),A=ee??null,j=!!(_&&te),[ne,M]=(0,Z.useState)(null),ie=E instanceof Error?E.message:E?n.loadError:null,ae=ne??ie,[se,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(`overview`),[de,fe]=(0,Z.useState)(``),[F,pe]=(0,Z.useState)(``),[he,ge]=(0,Z.useState)(``),[_e,ve]=(0,Z.useState)(``),[ye,xe]=(0,Z.useState)(``),[Se,I]=(0,Z.useState)(null),[L,Ce]=(0,Z.useState)(!1),we=(0,Z.useRef)(``),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(!1),[H,De]=(0,Z.useState)(``),[Oe,ke]=(0,Z.useState)(``),[Ae,je]=(0,Z.useState)(``),[Fe,Ie]=(0,Z.useState)(``),[Re,ze]=(0,Z.useState)(``),Be=(0,Z.useRef)(null),[Ve,He]=(0,Z.useState)(!1),[Ue,We]=(0,Z.useState)(!1),[Ge,Ke]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(A){if(S&&A.agents.some(e=>e.id===S)){ce(S);return}ce(e=>e&&A.agents.some(t=>t.id===e)?e:A.defaultId)}},[A,S]),(0,Z.useEffect)(()=>{if(!A||j)return;let e=A.agents.length<=1&&A.agents.every(e=>e.id===A.defaultId),t=localStorage.getItem(hn)===`true`;ue(e&&!t)},[A,j]);let qe=(0,Z.useCallback)(()=>{ue(!1),D()},[D]),Je=(0,Z.useCallback)(()=>{ue(!1)},[]);(0,Z.useEffect)(()=>{!A||!S||A.agents.some(e=>e.id===S)||x(Te,{replace:!0})},[A,S,x]),(0,Z.useEffect)(()=>{S&&P(`overview`)},[S]),(0,Z.useEffect)(()=>{y.get(`panel`)===`defaults`&&x(`/settings/agent-chat`,{replace:!0,state:{[Qe]:Te}})},[y,x]),(0,Z.useEffect)(()=>{if(y.get(`focus`)!==`avatar`||!S||(P(`overview`),j||!A?.agents.some(e=>e.id===S)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),b(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[y,S,j,A,b]);let U=(0,Z.useMemo)(()=>A?.agents.find(e=>e.id===se)??null,[A,se]),W=In({panel:N,selectedId:se,hasToken:_,dataAgentsLength:A?.agents.length,saveErrorMessage:n.saveError,setError:M}),G=Vn({panel:N,selected:U}),K=Ln({panel:N,hasToken:_,bindingsFromConfig:k,gatewayCfgLoading:O===void 0,selected:U,saveErrorMessage:n.saveError,setBusy:z,setError:M}),Ye=Rn({panel:N,hasToken:_,data:A,selected:U,saveErrorMessage:n.saveError,setBusy:z,setError:M}),Xe=Bn({panel:N,hasToken:_});(0,Z.useEffect)(()=>{if(!U){ke(``),je(``),Ie(``),ze(``);return}ke(U.workspace),je(U.model?.primary??``),Ie(me(U,Pe(e).agentsSettings)),ze(U.description?.trim()??``)},[U?.id,e]);let Ze=(0,Z.useCallback)(()=>{let e=On(F.trim()||de);ve(t=>t===``||t===we.current?(we.current=e,e):t)},[F,de]),$e=(0,Z.useCallback)(()=>{we.current=``,fe(``),pe(``),ge(``),ve(``),xe(``),I(null),Ce(!0)},[]),et=(0,Z.useCallback)(e=>new Promise(t=>window.setTimeout(t,e)),[]),tt=(0,Z.useCallback)(async()=>{if(B||R)return;V(!0),M(null);let e=[`light`,`deep`,`rem`];try{(async()=>{for(let t of e)try{await Mn(t)}catch{}})();for(let t=0;t<e.length;t++){let n=e[t];window.dispatchEvent(new CustomEvent(`dreaming-phase-start`,{detail:{phase:n,source:`ui`}})),await et(n===`light`?7e3:n===`deep`?9e3:8e3),t===e.length-1&&(window.__xopcDreamingIgnoreSseUntil=Date.now()+6e4,window.dispatchEvent(new CustomEvent(`dreaming-phase-end`,{detail:{phase:n,source:`ui`}})))}}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{V(!1)}},[n.saveError,R,B,et]),rt=(0,Z.useMemo)(()=>(0,q.jsx)(Fn,{language:e,a:n,busy:R,sleeping:B,listSearchQuery:H,onListSearchQueryChange:De,onSleep:()=>void tt(),onAddAgent:()=>$e()}),[n,R,e,H,$e,B,tt]);(0,Z.useLayoutEffect)(()=>_?(C({startExtra:null,main:null,end:rt}),()=>w()):(w(),()=>w()),[rt,w,_,C]);async function it(e){e.preventDefault();let t=de.trim();if(!t)return;let r=Dn(F,t);if(r.ok===!1){I(r.error);return}let i=_e.trim()||On(F.trim()||t);if(i){z(!0),I(null);try{let e=he.trim(),{createdAgentId:n,...r}=await v({name:t,workspace:i,...F.trim()?{id:F.trim()}:{},...ye.trim()?{model:ye.trim()}:{},...e?{description:e}:{}});D(r,{revalidate:!1}),fe(``),pe(``),ge(``),ve(``),xe(``),I(null),Ce(!1),ce(n),x(Ee(n))}catch(e){I(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function at(){if(U){z(!0),M(null);try{let e=Re.trim();D(await T(U.id,{name:Fe.trim()||void 0,description:e.length>0?e:null,workspace:Oe.trim()||void 0,model:Ae.trim()||null}),{revalidate:!1})}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function ot(e){z(!0),M(null);try{D(await T(e.id,{setDefault:!0}),{revalidate:!1}),ce(e.id)}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}async function st(e,t){z(!0),M(null);try{let n=await oe(e.id,t);D(n,{revalidate:!1}),ce(n.defaultId),P(`overview`),S===e.id&&x(Te,{replace:!0}),a(!1),c(null),f(``)}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}function ct(e,t){e.id!==`main`&&(c(e),u(t),f(``),a(!0))}async function lt(){if(U){z(!0),M(null);try{let e=[...G.toolEntryDisable].sort((e,t)=>e.localeCompare(t));D(await T(U.id,{toolsDisable:e}),{revalidate:!1})}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function ut(){if(U){z(!0),M(null);try{D(await T(U.id,{toolsDisable:null}),{revalidate:!1}),G.setToolEntryDisable(new Set)}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}async function dt(){if(U){z(!0),M(null);try{D(await T(U.id,{skills:G.skillsInherit?null:[...G.skillsPick].sort((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){M(e instanceof Error?e.message:n.saveError)}finally{z(!1)}}}let ft=N===`channels`||N===`cron`,pt=(()=>{if(!U||N!==`overview`)return!1;let e=me(U,n),t=U.description?.trim()??``,r=U.workspace,i=U.model?.primary??``;return Fe.trim()!==e||Re.trim()!==t||Oe.trim()!==r||Ae.trim()!==i})(),mt=(()=>{if(ft)return!1;switch(N){case`overview`:return pt||Ve;case`profile`:return Ue;default:return!0}})(),ht=ft||!mt;function gt(){Ke(!0),setTimeout(()=>Ke(!1),2e3)}async function _t(){switch(N){case`overview`:await Promise.all([at(),W.overviewSaveProfileMarkdownRef.current?.()??Promise.resolve()]),gt();break;case`profile`:await Be.current?.(),gt();break;case`tools`:await lt(),gt();break;case`skills`:await dt(),gt();break;case`files`:W.saveProfileMarkdownDebounced.flush(),gt();break;default:break}}function vt(e){e||x(Te)}return{hasToken:_,a:n,chat:g,language:e,data:A,loading:j,displayError:ae,navigate:x,routeAgentId:S,showPresetSetup:le,onPresetSetupComplete:qe,onPresetSetupSkip:Je,busy:R,listSearchQuery:H,openAddAgentModal:$e,panel:N,setPanel:P,modalTitle:U?Fe.trim()||me(U,n):S??``,modalSubtitle:U?.id??S??``,footerSaveDisabled:ht,savedFlash:Ge,handleModalFooterSave:_t,onAgentModalOpenChange:vt,addAgentModalOpen:L,setAddAgentModalOpen:Ce,createWorkspaceSuggestedRef:we,createModalError:Se,setCreateModalError:I,createDisplayName:de,setCreateDisplayName:fe,createAgentId:F,setCreateAgentId:pe,createDescription:he,setCreateDescription:ge,createWorkspace:_e,setCreateWorkspace:ve,createModel:ye,setCreateModel:xe,onCreate:it,applyCreateWorkspaceSuggestion:Ze,deleteDialogOpen:i,setDeleteDialogOpen:a,deletePurge:l,deleteTarget:o,setDeleteTarget:c,deleteConfirmText:d,setDeleteConfirmText:f,performDelete:st,editorPanelProps:{a:n,chat:g,cCron:m,selected:U,panel:N,data:A,busy:R,editName:Fe,setEditName:Ie,editDescription:Re,setEditDescription:ze,editWorkspace:Oe,setEditWorkspace:ke,editModel:Ae,setEditModel:je,onSetDefault:()=>{U&&ot(U)},onSaveAgentEdits:()=>void at(),onDelete:e=>{U&&ct(U,e)},overviewSaveProfileMarkdownRef:W.overviewSaveProfileMarkdownRef,profileSaveRef:Be,setOverviewProfileMarkdownDirty:He,setProfileDirty:We,filesLoading:W.filesLoading,files:W.files,activeFile:W.activeFile,setActiveFile:W.setActiveFile,filesViewMode:W.filesViewMode,setFilesViewMode:W.setFilesViewMode,fileDraft:W.fileDraft,setFileDraft:W.setFileDraft,fileSaving:W.fileSaving,profileFileLoading:W.profileFileLoading,profileEditorNonce:W.profileEditorNonce,toolEntryDisable:G.toolEntryDisable,setToolEntryDisable:G.setToolEntryDisable,onSaveTools:()=>void lt(),onClearToolsEntry:()=>void ut(),skillsCatalogLoading:Xe.skillsCatalogLoading,catalogForPick:Xe.catalogForPick,skillsInherit:G.skillsInherit,setSkillsInherit:G.setSkillsInherit,skillsPick:G.skillsPick,setSkillsPick:G.setSkillsPick,onSaveSkills:()=>void dt(),bindingsLoading:K.bindingsLoading,agentBindings:K.agentBindings,bindChannelStatuses:K.bindChannelStatuses,bindChannelsLoading:K.bindChannelsLoading,useManualChannel:K.useManualChannel,newBindChannel:K.newBindChannel,setNewBindChannel:K.setNewBindChannel,bindSessionChats:K.bindSessionChats,bindSessionsLoading:K.bindSessionsLoading,newBindSessionIdx:K.newBindSessionIdx,setNewBindSessionIdx:K.setNewBindSessionIdx,newBindCustomPeer:K.newBindCustomPeer,setNewBindCustomPeer:K.setNewBindCustomPeer,refreshBindSessions:K.refreshBindSessions,onRemoveBinding:e=>void K.onRemoveBinding(e),onAddBinding:K.onAddBinding,cronLoading:Ye.cronLoading,agentCronJobs:Ye.agentCronJobs,onSetCronJobAgent:(e,t)=>void Ye.onSetCronJobAgent(e,t)}}}function Un(){let e=Hn();return e.hasToken?e.showPresetSetup&&e.data?(0,q.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col px-4 py-8`,children:(0,q.jsx)(_n,{existingAgentIds:new Set(e.data.agents.map(e=>e.id)),onComplete:e.onPresetSetupComplete,onSkip:e.onPresetSetupSkip})}):(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,q.jsx)(pn,{a:e.a}),e.displayError?(0,q.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:e.displayError}):null,e.loading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):e.data?(0,q.jsx)(fn,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(Ee(t)),onChatWithAgent:t=>e.navigate(`/chat/new`,{state:{agentId:t.trim().toLowerCase()}}),onNewAgent:e.openAddAgentModal,busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,q.jsx)(xt,{open:!!e.routeAgentId,onOpenChange:e.onAgentModalOpenChange,a:e.a,title:e.modalTitle,subtitle:e.modalSubtitle,panel:e.panel,onPanelChange:e.setPanel,onFooterSave:()=>void e.handleModalFooterSave(),footerSaveDisabled:e.footerSaveDisabled,footerSavedFlash:e.savedFlash,busy:e.busy,children:e.loading||!e.data?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):(0,q.jsx)(ln,{...e.editorPanelProps})}):null,(0,q.jsx)(mn,{open:e.addAgentModalOpen,onOpenChange:t=>{e.setAddAgentModalOpen(t),t||(e.createWorkspaceSuggestedRef.current=``,e.setCreateDisplayName(``),e.setCreateAgentId(``),e.setCreateDescription(``),e.setCreateWorkspace(``),e.setCreateModel(``),e.setCreateModalError(null))},a:e.a,chat:e.chat,busy:e.busy,modalError:e.createModalError,createDisplayName:e.createDisplayName,setCreateDisplayName:e.setCreateDisplayName,createAgentId:e.createAgentId,setCreateAgentId:e.setCreateAgentId,createDescription:e.createDescription,setCreateDescription:e.setCreateDescription,createWorkspace:e.createWorkspace,setCreateWorkspace:e.setCreateWorkspace,createModel:e.createModel,setCreateModel:e.setCreateModel,onCreate:e.onCreate,onSuggestWorkspace:()=>e.applyCreateWorkspaceSuggestion()}),(0,q.jsx)(_t,{open:e.deleteDialogOpen,onOpenChange:t=>{e.setDeleteDialogOpen(t),t||(e.setDeleteTarget(null),e.setDeleteConfirmText(``))},busy:e.busy,deletePurge:e.deletePurge,deleteTarget:e.deleteTarget,deleteConfirmText:e.deleteConfirmText,onDeleteConfirmTextChange:e.setDeleteConfirmText,onConfirm:()=>{e.deleteTarget&&e.performDelete(e.deleteTarget,e.deletePurge)},onCancel:()=>e.setDeleteDialogOpen(!1),a:e.a})]}):(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,q.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]})}function $({label:e,description:t,children:n}){return(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}var Wn=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`adaptive`];function Gn(e){let{a:t,chat:n,form:r,update:i}=e;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:We,title:t.cardModelsTitle,subtitle:t.label.model}),(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsx)($,{label:t.label.model,description:t.desc.model,children:(0,q.jsx)(Se,{value:r.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({model:e})})})})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Ze,title:t.cardGenerationTitle,subtitle:t.cardGenerationSubtitle}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.maxTokens,description:t.desc.maxTokens,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),value:r.maxTokens,min:1,onChange:e=>i({maxTokens:Number.parseInt(e.target.value,10)||0})})}),(0,q.jsx)($,{label:t.label.temperature,description:t.desc.temperature,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),value:r.temperature,min:0,max:2,step:.1,onChange:e=>i({temperature:Number.parseFloat(e.target.value)||0})})}),(0,q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,q.jsx)($,{label:t.label.maxToolIterations,description:t.desc.maxToolIterations,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),value:r.maxToolIterations,min:1,onChange:e=>i({maxToolIterations:Number.parseInt(e.target.value,10)||0})})})})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:P,title:t.cardBehaviorTitle,subtitle:t.cardBehaviorSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:t.label.thinkingDefault,description:t.desc.thinkingDefault,children:(0,q.jsx)(`select`,{className:en(),value:r.thinkingDefault,onChange:e=>i({thinkingDefault:e.target.value}),children:Wn.map(e=>(0,q.jsx)(`option`,{value:e,children:n.thinkingLevels[e]},e))})}),(0,q.jsx)($,{label:t.label.reasoningDefault,description:t.desc.reasoningDefault,children:(0,q.jsxs)(`select`,{className:en(),value:r.reasoningDefault,onChange:e=>i({reasoningDefault:e.target.value}),children:[(0,q.jsx)(`option`,{value:`off`,children:t.reasoning.off}),(0,q.jsx)(`option`,{value:`on`,children:t.reasoning.on}),(0,q.jsx)(`option`,{value:`stream`,children:t.reasoning.stream})]})}),(0,q.jsx)($,{label:t.label.verboseDefault,description:t.desc.verboseDefault,children:(0,q.jsxs)(`select`,{className:en(),value:r.verboseDefault,onChange:e=>i({verboseDefault:e.target.value}),children:[(0,q.jsx)(`option`,{value:`off`,children:t.verbose.off}),(0,q.jsx)(`option`,{value:`on`,children:t.verbose.on}),(0,q.jsx)(`option`,{value:`full`,children:t.verbose.full})]})})]})]})]})}function Kn(e,t,n){let[r,i]=(0,Z.useState)(e?`unknown`:`off`);(0,Z.useEffect)(()=>{i(e?`unknown`:`off`)},[e]);let a=(0,Z.useCallback)(async()=>{if(!e){i(`off`);return}let r=new URLSearchParams({probe:`1`});t&&r.set(`host`,t),n!==void 0&&r.set(`port`,String(n));try{let e=await Oe(V(`/api/browser/extension-status?${r}`),{signal:AbortSignal.timeout(3e3)});if(!e.ok){i(`off`);return}let t=await e.json();t.running?i(t.connected?`connected`:`waiting`):i(`off`)}catch{i(`off`)}},[e,t,n]);return(0,Z.useEffect)(()=>{a();let e=setInterval(()=>void a(),5e3);return()=>clearInterval(e)},[a]),r}function qn({status:e,messages:t}){let{icon:n,color:r,label:i}={connected:{icon:xe,color:`text-green-500`,label:t.browserExtensionConnected},waiting:{icon:De,color:`text-amber-500`,label:t.browserExtensionWaiting},off:{icon:S,color:`text-fg-muted`,label:t.browserExtensionServerOff},unknown:{icon:S,color:`text-fg-muted`,label:`…`}}[e];return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs ${r}`,children:[(0,q.jsx)(n,{className:`size-3.5`}),(0,q.jsx)(`span`,{children:i})]})}function Jn(e){let{a:t,form:n,update:r}=e,i=Kn(n.browserBackend===`extension`,n.browserExtensionHost,n.browserExtensionPort);return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:ge,title:t.cardBrowserTitle,subtitle:t.cardBrowserSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.browserEnabled,description:t.desc.browserEnabled,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserEnabled,onChange:e=>r({browserEnabled:e.target.checked})}),(0,q.jsx)(`span`,{children:t.browserEnabledOn})]})}),(0,q.jsx)($,{label:t.label.browserHeadless,description:t.desc.browserHeadless,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserHeadless,onChange:e=>r({browserHeadless:e.target.checked})}),(0,q.jsx)(`span`,{children:t.browserHeadlessOn})]})}),(0,q.jsx)($,{label:t.label.browserAllowPrivateUrls,description:t.desc.browserAllowPrivateUrls,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.browserAllowPrivateUrls,onChange:e=>r({browserAllowPrivateUrls:e.target.checked})}),(0,q.jsx)(`span`,{children:t.browserAllowPrivateOn})]})}),(0,q.jsx)($,{label:t.label.browserCommandTimeout,description:t.desc.browserCommandTimeout,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:5,value:n.browserCommandTimeout??``,placeholder:`30`,onChange:e=>{let t=e.target.value;r({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})}})})]}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:t.label.browserBackend,description:t.desc.browserBackend,children:(0,q.jsxs)(`select`,{className:en(),value:n.browserBackend,onChange:e=>r({browserBackend:e.target.value}),children:[(0,q.jsx)(`option`,{value:`local`,children:t.browserBackendLocal}),(0,q.jsx)(`option`,{value:`cdp`,children:t.browserBackendCdp}),(0,q.jsx)(`option`,{value:`cloud`,children:t.browserBackendCloud}),(0,q.jsx)(`option`,{value:`extension`,children:t.browserBackendExtension})]})}),(0,q.jsx)($,{label:t.label.browserDialogPolicy,description:t.desc.browserDialogPolicy,children:(0,q.jsxs)(`select`,{className:en(),value:n.browserDialogPolicy,onChange:e=>r({browserDialogPolicy:e.target.value}),children:[(0,q.jsx)(`option`,{value:`must_respond`,children:t.browserDialogPolicyMustRespond}),(0,q.jsx)(`option`,{value:`auto_dismiss`,children:t.browserDialogPolicyAutoDismiss}),(0,q.jsx)(`option`,{value:`auto_accept`,children:t.browserDialogPolicyAutoAccept})]})})]}),n.browserBackend===`cloud`&&(0,q.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:(0,q.jsx)($,{label:t.label.browserCloudProvider,description:t.desc.browserCloudProvider,children:(0,q.jsxs)(`select`,{className:en(),value:n.browserCloudProvider,onChange:e=>r({browserCloudProvider:e.target.value}),children:[(0,q.jsx)(`option`,{value:`browserbase`,children:t.browserCloudProviderBrowserbase}),(0,q.jsx)(`option`,{value:`browser-use`,children:t.browserCloudProviderBrowserUse})]})})}),n.browserBackend===`cdp`&&(0,q.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:(0,q.jsx)($,{label:t.label.browserCdpUrl,description:t.desc.browserCdpUrl,children:(0,q.jsx)(`input`,{type:`text`,className:Q(),value:n.browserCdpUrl,placeholder:`ws://localhost:9222`,onChange:e=>r({browserCdpUrl:e.target.value}),autoComplete:`off`})})}),n.browserBackend===`extension`&&(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-edge bg-surface-raised px-4 py-3`,children:[(0,q.jsx)(qn,{status:i,messages:t}),(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`ws://127.0.0.1:19820/browser-ext`})]}),(0,q.jsx)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:(0,q.jsx)($,{label:t.label.browserDialogTimeout,description:t.desc.browserDialogTimeout,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:n.browserDialogTimeout??``,placeholder:`300`,onChange:e=>{let t=e.target.value;r({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})}})})})]})]})})}function Yn(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e||!t)return;let n=!1;return a(!0),Me().then(e=>{n||r(Array.isArray(e.builtinToolIds)?e.builtinToolIds:[])}).catch(()=>{n||r([])}).finally(()=>{n||a(!1)}),()=>{n=!0}},[e,t]),{builtinToolIds:n,loading:i}}function Xn(e){let{a:t,form:n,update:r}=e,i=t.advanced,a=Pe(p(e=>e.language)).agentsSettings,o=!!nt(e=>e.token),{builtinToolIds:s,loading:c}=Yn(!0,o),l=(0,Z.useMemo)(()=>new Set(n.toolsDisable.map(e=>e.trim()).filter(Boolean)),[n.toolsDisable]),d=(0,Z.useMemo)(()=>n.toolsDisable.map(e=>e.trim()).filter(Boolean).filter(e=>!s.includes(e)).sort((e,t)=>e.localeCompare(t)),[n.toolsDisable,s]),f=(0,Z.useCallback)(e=>{r({toolsDisable:on(e)})},[r]),m=a.toolsDisableGroups,h=(0,Z.useCallback)(e=>m[e],[m]),g=(0,Z.useCallback)(e=>e in a.toolDescriptions?a.toolDescriptions[e]:``,[a.toolDescriptions]);return(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:u,title:i.cardToolsDisableTitle,subtitle:i.cardToolsDisableSubtitle}),(0,q.jsx)($,{label:i.toolsDisableFieldLabel,description:i.toolsDisableHint,children:(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:o?(0,q.jsx)(sn,{mode:`defaults`,builtinToolIds:s,loading:c,disableSet:l,onDisableSetChange:f,unknownDisabledIds:d,getToolDescription:g,getGroupTitle:h,quickActionsDisabled:c,labels:{loadingBuiltin:i.toolsDisableLoadingBuiltin,emptyBuiltin:i.toolsDisableEmptyBuiltin,quickActionsLabel:i.toolsDisableQuickActionsLabel,quickEnableAll:i.toolsDisableQuickEnableAll,quickDisableAll:i.toolsDisableQuickDisableAll,quickReadOnlyWorkspace:i.toolsDisableQuickReadOnlyWorkspace,quickHighRiskOff:i.toolsDisableQuickHighRiskOff,quickNoOutbound:i.toolsDisableQuickNoOutbound,notInBuiltin:i.toolsDisableNotInBuiltin,lockedByDefaults:a.toolsLockedByDefaults}}):(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.needToken})})})]})}function Zn(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:E,title:a.cardWebExtractTitle,subtitle:a.cardWebExtractSubtitle}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,q.jsx)($,{label:a.webExtractModel,description:a.webExtractModelDesc,children:(0,q.jsx)(Se,{value:r.webExtract.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({webExtract:{...r.webExtract,model:e}})})})}),(0,q.jsx)($,{label:a.webExtractMaxLength,description:a.webExtractMaxLengthDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:r.webExtract.maxLength??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({webExtract:{...r.webExtract,maxLength:t===``?void 0:Number.parseInt(t,10)}})}})})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:I,title:a.cardDelegateTitle,subtitle:a.cardDelegateSubtitle}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:a.delegateEnabled,description:a.delegateEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.delegate.enabled,onChange:e=>i({delegate:{...r.delegate,enabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:a.delegateEnabledOn})]})}),(0,q.jsx)($,{label:a.executeCodeEnabled,description:a.executeCodeEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.executeCode.enabled,onChange:e=>i({executeCode:{...r.executeCode,enabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:a.executeCodeEnabledOn})]})})]})]}),(0,q.jsx)(Xn,{...e})]})}function Qn(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:ee,title:i.cardLimitsTitle,subtitle:i.cardLimitsSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:i.maxTaskDurationMs,description:i.maxTaskDurationMsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,max:240,step:1,value:n.maxTaskDurationMinutes??``,placeholder:i.maxTaskDurationPlaceholder,onChange:e=>{let t=e.target.value;if(t===``){r({maxTaskDurationMinutes:void 0});return}let n=Number.parseInt(t,10);Number.isNaN(n)||r({maxTaskDurationMinutes:Math.min(240,Math.max(1,n))})}})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:i.maxRequestsPerTurn,description:i.maxRequestsPerTurnDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:10,max:200,value:n.maxRequestsPerTurn,onChange:e=>r({maxRequestsPerTurn:Number.parseInt(e.target.value,10)||50})})}),(0,q.jsx)($,{label:i.maxToolFailuresPerTurn,description:i.maxToolFailuresPerTurnDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,max:20,value:n.maxToolFailuresPerTurn,onChange:e=>r({maxToolFailuresPerTurn:Number.parseInt(e.target.value,10)||3})})})]})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:de,title:i.cardCompactionTitle,subtitle:i.cardCompactionSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:i.compactionEnabled,description:i.compactionEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.compaction.enabled,onChange:e=>r({compaction:{...n.compaction,enabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:i.compactionEnabledOn})]})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:i.compactionMode,description:i.compactionModeDesc,children:(0,q.jsxs)(`select`,{className:en(),value:n.compaction.mode,onChange:e=>r({compaction:{...n.compaction,mode:e.target.value}}),children:[(0,q.jsx)(`option`,{value:`default`,children:i.compactionModeDefault}),(0,q.jsx)(`option`,{value:`safeguard`,children:i.compactionModeSafeguard})]})}),(0,q.jsx)($,{label:i.reserveTokens,description:i.reserveTokensDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1e3,value:n.compaction.reserveTokens,onChange:e=>r({compaction:{...n.compaction,reserveTokens:Number.parseInt(e.target.value,10)||0}})})}),(0,q.jsx)($,{label:i.triggerThreshold,description:i.triggerThresholdDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:.5,max:.95,step:.05,value:n.compaction.triggerThreshold,onChange:e=>r({compaction:{...n.compaction,triggerThreshold:Number.parseFloat(e.target.value)||.8}})})}),(0,q.jsx)($,{label:i.minMessagesBeforeCompact,description:i.minMessagesBeforeCompactDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:n.compaction.minMessagesBeforeCompact,onChange:e=>r({compaction:{...n.compaction,minMessagesBeforeCompact:Number.parseInt(e.target.value,10)||10}})})}),(0,q.jsx)($,{label:i.keepRecentMessages,description:i.keepRecentMessagesDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,value:n.compaction.keepRecentMessages,onChange:e=>r({compaction:{...n.compaction,keepRecentMessages:Number.parseInt(e.target.value,10)||5}})})}),(0,q.jsx)($,{label:i.evictionWindow,description:i.evictionWindowDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:.1,max:.5,step:.05,value:n.compaction.evictionWindow,onChange:e=>r({compaction:{...n.compaction,evictionWindow:Number.parseFloat(e.target.value)||.2}})})}),(0,q.jsx)($,{label:i.retentionWindow,description:i.retentionWindowDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:3,max:20,value:n.compaction.retentionWindow,onChange:e=>r({compaction:{...n.compaction,retentionWindow:Number.parseInt(e.target.value,10)||6}})})})]})]})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:$e,title:i.cardPruningTitle,subtitle:i.cardPruningSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:i.pruningEnabled,description:i.pruningEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:n.pruning.enabled,onChange:e=>r({pruning:{...n.pruning,enabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:i.pruningEnabledOn})]})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:i.maxToolResultChars,description:i.maxToolResultCharsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1e3,value:n.pruning.maxToolResultChars,onChange:e=>r({pruning:{...n.pruning,maxToolResultChars:Number.parseInt(e.target.value,10)||1e4}})})}),(0,q.jsx)($,{label:i.headKeepRatio,description:i.headKeepRatioDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,max:1,step:.05,value:n.pruning.headKeepRatio,onChange:e=>r({pruning:{...n.pruning,headKeepRatio:Number.parseFloat(e.target.value)||.3}})})}),(0,q.jsx)($,{label:i.tailKeepRatio,description:i.tailKeepRatioDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,max:1,step:.05,value:n.pruning.tailKeepRatio,onChange:e=>r({pruning:{...n.pruning,tailKeepRatio:Number.parseFloat(e.target.value)||.3}})})})]})]})]})]})}function $n(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Je,title:i.cardParamsTitle,subtitle:i.cardParamsSubtitle}),(0,q.jsx)($,{label:i.paramsJson,description:i.paramsJsonDesc,children:(0,q.jsx)(`textarea`,{className:O(Q(),`min-h-[88px] resize-y font-mono text-xs`),value:n.paramsJson,placeholder:`{}`,onChange:e=>r({paramsJson:e.target.value})})})]})})}function er(e){let{a:t,chat:n,form:r,update:i}=e,o=t.advanced;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:tt,title:o.cardMemoryTitle,subtitle:o.cardMemorySubtitle}),(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:o.memoryEnabled,description:o.memoryEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.memory.enabled,onChange:e=>i({memory:{...r.memory,enabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:o.memoryEnabledOn})]})}),(0,q.jsx)($,{label:o.useEnhancedSystem,description:o.useEnhancedSystemDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.memory.useEnhancedSystem,onChange:e=>i({memory:{...r.memory,useEnhancedSystem:e.target.checked}})}),(0,q.jsx)(`span`,{children:o.useEnhancedSystemOn})]})}),(0,q.jsx)($,{label:o.userProfileEnabled,description:o.userProfileEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.memory.userProfileEnabled,onChange:e=>i({memory:{...r.memory,userProfileEnabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:o.userProfileEnabledOn})]})}),(0,q.jsx)($,{label:o.memoryProvider,description:o.memoryProviderDesc,children:(0,q.jsxs)(`select`,{className:en(),value:r.memory.provider,onChange:e=>i({memory:{...r.memory,provider:e.target.value}}),children:[(0,q.jsx)(`option`,{value:``,children:o.memoryProviderUnset}),(0,q.jsx)(`option`,{value:`none`,children:`none`}),(0,q.jsx)(`option`,{value:`stub`,children:`stub`})]})}),(0,q.jsx)($,{label:o.injectionFrequency,description:o.injectionFrequencyDesc,children:(0,q.jsxs)(`select`,{className:en(),value:r.memory.injectionFrequency,onChange:e=>i({memory:{...r.memory,injectionFrequency:e.target.value}}),children:[(0,q.jsx)(`option`,{value:``,children:o.injectionFrequencyUnset}),(0,q.jsx)(`option`,{value:`every-turn`,children:o.injectionEveryTurn}),(0,q.jsx)(`option`,{value:`first-turn`,children:o.injectionFirstTurn})]})}),(0,q.jsx)($,{label:o.memoryCharLimit,description:o.memoryCharLimitDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:r.memory.memoryCharLimit??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,memoryCharLimit:t===``?void 0:Number.parseInt(t,10)}})}})}),(0,q.jsx)($,{label:o.userCharLimit,description:o.userCharLimitDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:r.memory.userCharLimit??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,userCharLimit:t===``?void 0:Number.parseInt(t,10)}})}})}),(0,q.jsx)($,{label:o.contextCadence,description:o.contextCadenceDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:r.memory.contextCadence??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,contextCadence:t===``?void 0:Number.parseInt(t,10)}})}})}),(0,q.jsx)($,{label:o.dialecticCadence,description:o.dialecticCadenceDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,value:r.memory.dialecticCadence??``,placeholder:`—`,onChange:e=>{let t=e.target.value;i({memory:{...r.memory,dialecticCadence:t===``?void 0:Number.parseInt(t,10)}})}})})]})})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:z,title:o.cardSessionSearchTitle,subtitle:o.cardSessionSearchSubtitle}),(0,q.jsx)($,{label:o.sessionSearchSummaryModel,description:o.sessionSearchSummaryModelDesc,children:(0,q.jsx)(Se,{value:r.sessionSearch.summaryModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({sessionSearch:{...r.sessionSearch,summaryModel:e}})})})]}),(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:a,title:o.cardReviewTitle,subtitle:o.cardReviewSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:o.reviewEnabled,description:o.reviewEnabledDesc,children:(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.backgroundReview.enabled,onChange:e=>i({backgroundReview:{...r.backgroundReview,enabled:e.target.checked}})}),(0,q.jsx)(`span`,{children:o.reviewEnabledOn})]})}),(0,q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:o.memoryNudgeInterval,description:o.memoryNudgeIntervalDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,value:r.backgroundReview.memoryNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,memoryNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,q.jsx)($,{label:o.skillNudgeInterval,description:o.skillNudgeIntervalDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:0,value:r.backgroundReview.skillNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,skillNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,q.jsx)($,{label:o.reviewMaxToolRounds,description:o.reviewMaxToolRoundsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:1,max:32,value:r.backgroundReview.maxToolRounds,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxToolRounds:Number.parseInt(e.target.value,10)||8}})})}),(0,q.jsx)($,{label:o.reviewMaxHistoryMessages,description:o.reviewMaxHistoryMessagesDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:10,max:200,value:r.backgroundReview.maxHistoryMessages,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxHistoryMessages:Number.parseInt(e.target.value,10)||80}})})}),(0,q.jsx)($,{label:o.reviewMaxDurationMs,description:o.reviewMaxDurationMsDesc,children:(0,q.jsx)(`input`,{type:`number`,className:Q(),min:30,max:600,step:1,value:Math.round((r.backgroundReview.maxDurationMs??12e4)/1e3),onChange:e=>i({backgroundReview:{...r.backgroundReview,maxDurationMs:(Number.parseInt(e.target.value,10)||120)*1e3}})})})]})]})]})]})}function tr(e){return(e.name||e.directoryId).trim()}function nr(e,t){let n=[];for(let r of t)e.has(r)&&n.push(r);let r=[...e].filter(e=>!t.includes(e)).sort();return[...n,...r]}function rr(e){let{a:t,form:n,update:r}=e,i=t.advanced,a=Pe(p(e=>e.language)).agentsSettings,o=!!nt(e=>e.token),{catalogForPick:s,skillsCatalogLoading:c}=zn(!0,o),l=(0,Z.useMemo)(()=>s.map(tr),[s]),u=n.skillsAllowlist.length>0,d=(0,Z.useMemo)(()=>new Set(n.skillsAllowlist.map(e=>e.trim()).filter(Boolean)),[n.skillsAllowlist]),f=(0,Z.useMemo)(()=>n.skillsAllowlist.filter(e=>e.trim()&&!l.includes(e.trim())),[n.skillsAllowlist,l]),m=(0,Z.useMemo)(()=>f.map(e=>({name:e.trim(),directoryId:e.trim()})),[f]),h=(0,Z.useMemo)(()=>[...m,...s],[m,s]),g=(0,Z.useCallback)(()=>{r({skillsAllowlist:[]})},[r]),_=(0,Z.useCallback)(()=>{r({skillsAllowlist:[...l]})},[r,l]),v=(0,Z.useCallback)((e,t)=>{let i=new Set(n.skillsAllowlist.map(e=>e.trim()).filter(Boolean));if(t?i.add(e):i.delete(e),i.size===0){r({skillsAllowlist:[]});return}r({skillsAllowlist:nr(i,l)})},[n.skillsAllowlist,l,r]);return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:ie,title:i.cardSkillsTitle,subtitle:i.cardSkillsSubtitle}),(0,q.jsx)($,{label:i.skillsAllowlist,description:i.skillsAllowlistDesc,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`secondary`,className:tn,onClick:g,children:i.skillsAllowlistModeAll}),(0,q.jsx)(j,{type:`button`,variant:`secondary`,className:tn,disabled:!u&&l.length===0,onClick:()=>{u||_()},children:i.skillsAllowlistModeRestrict})]}),(0,q.jsx)(y,{to:we(`skills`),className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:a.skillsLibraryLink})]}),o?c?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.skillsCatalogLoading}):h.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.skillsEmptyCatalog}):(0,q.jsx)(`div`,{className:O(`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,!u&&`pointer-events-none opacity-50`),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,role:`list`,children:h.filter(e=>tr(e)).map(e=>{let t=tr(e),n=u&&d.has(t),r=typeof e.description==`string`?e.description.trim():``,o=r||a.skillsNoDescription,s=!l.includes(t);return(0,q.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,q.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:!u,onChange:()=>v(t,!n)}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:[t,s?(0,q.jsxs)(`span`,{className:`ml-1.5 font-sans text-[10px] font-normal text-fg-muted`,children:[`(`,i.skillsAllowlistNotInCatalog,`)`]}):null]}),(0,q.jsx)(`p`,{className:O(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!r&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})}):(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.needToken})]})})]})})}function ir(e){let{a:t,form:n,update:r}=e,i=t.advanced;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:Ve,title:i.cardSystemPromptTitle,subtitle:i.cardSystemPromptSubtitle}),(0,q.jsx)($,{label:i.systemPromptOverride,description:i.systemPromptOverrideDesc,children:(0,q.jsx)(`textarea`,{className:O(Q(),`min-h-[140px] resize-y font-mono text-xs`),value:n.systemPromptOverride,placeholder:i.systemPromptPlaceholder,onChange:e=>r({systemPromptOverride:e.target.value})})})]})})}function ar(e){let{a:t,form:n,update:r}=e;return(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,q.jsxs)(J,{children:[(0,q.jsx)(Y,{icon:C,title:t.cardWorkspaceTitle,subtitle:t.cardWorkspaceSubtitle}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,q.jsx)($,{label:t.label.workspace,description:t.desc.workspace,children:(0,q.jsx)(`input`,{type:`text`,className:Q(),value:n.workspace,onChange:e=>r({workspace:e.target.value}),autoComplete:`off`})}),(0,q.jsx)($,{label:t.label.mediaMaxMb,description:t.desc.mediaMaxMb,children:(0,q.jsx)(`input`,{type:`number`,min:1,step:1,className:Q(),value:n.mediaMaxMb??``,placeholder:`20`,onChange:e=>{let t=e.target.value;r({mediaMaxMb:t===``?void 0:Number(t)})}})})]})]})})}function or(e){let{sectionId:t,intro:n,vm:r,children:i}=e,a=Pe(p(e=>e.language)),o=a.agentSettings,s=a.settingsSections[t]??t;return r.hasToken?r.loading?(0,q.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,q.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,q.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:a.logs.loading})]}):r.form?(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,q.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:s}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.sectionDesc})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[r.saveOk?(0,q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:o.saved}):null,(0,q.jsx)(j,{type:`button`,variant:`secondary`,disabled:!r.dirty||r.saving,onClick:r.discard,children:o.discard}),(0,q.jsx)(j,{type:`button`,variant:`primary`,disabled:!r.dirty||r.saving,onClick:()=>void r.save(),children:r.saving?o.saving:o.save})]})]}),r.error?(0,q.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:r.error}):null,(0,q.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i})]}):(0,q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.error??r.fetchError??o.loadError}),(0,q.jsx)(j,{type:`button`,variant:`secondary`,onClick:()=>void r.mutate(),children:a.logs.refresh})]}):(0,q.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,q.jsx)(We,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:s}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o.needToken})]})]})})}var sr={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},cr={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},lr={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},ur={summaryModel:``},dr={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},fr={model:``,maxLength:void 0};function pr(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&e&&`primary`in e){let t=e.primary;return typeof t==`string`?t:``}return``}function mr(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function hr(e){if(!e||typeof e!=`object`)return;let t=e,n=t.payload;if(n&&typeof n==`object`&&`config`in n)return n.config;if(`config`in t)return t.config}function gr(e){return e===!0||e===`true`||e===1}function _r(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`local`,browserCloudProvider:`local`,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=gr(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=gr(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`cdp`||c===`cloud`||c===`extension`?c:`local`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cdpUrl==`string`?n.cdpUrl:``,p=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},m=typeof p.port==`number`&&Number.isFinite(p.port)&&p.port>=1024&&p.port<=65535?Math.floor(p.port):void 0,h=typeof p.host==`string`&&p.host?p.host:`127.0.0.1`,g=n.dialogPolicy;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCdpUrl:f,browserExtensionPort:m,browserExtensionHost:h,browserDialogPolicy:g===`must_respond`||g===`auto_accept`?g:`auto_dismiss`,browserDialogTimeout:typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0}}function vr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...sr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:sr.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):sr.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:sr.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):sr.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):sr.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:sr.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):sr.retentionWindow}}function yr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...cr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:cr.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):cr.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:cr.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:cr.tailKeepRatio}}function br(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...lr};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:lr.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:lr.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:lr.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function xr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...ur};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Sr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...dr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:dr.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):dr.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):dr.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):dr.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):dr.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):dr.maxDurationMs}}function Cr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...fr};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function wr(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Tr(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Er(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Dr(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Or(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function kr(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`agents`in e?e.agents:void 0,n=t&&typeof t==`object`&&!Array.isArray(t)&&`defaults`in t?t.defaults:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n:{},i=r.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:mr(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:mr(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:mr(r.imageGenerationModel),u=_r(r),d=typeof r.maxTaskDurationMs==`number`&&Number.isFinite(r.maxTaskDurationMs)?r.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:pr(r.model),modelFallbacks:a,imageModel:pr(r.imageModel),imageModelFallbacks:s,imageGenerationModel:pr(r.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Dr(r),imageGenerationModelAutoProviderFallback:Or(r),mediaMaxMb:typeof r.mediaMaxMb==`number`&&!Number.isNaN(r.mediaMaxMb)?r.mediaMaxMb:void 0,maxTokens:typeof r.maxTokens==`number`?r.maxTokens:8192,temperature:typeof r.temperature==`number`?r.temperature:.7,maxToolIterations:typeof r.maxToolIterations==`number`?r.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof r.maxRequestsPerTurn==`number`?r.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof r.maxToolFailuresPerTurn==`number`?r.maxToolFailuresPerTurn:3,workspace:typeof r.workspace==`string`?r.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof r.thinkingDefault==`string`?r.thinkingDefault:`medium`,reasoningDefault:typeof r.reasoningDefault==`string`?r.reasoningDefault:`stream`,verboseDefault:typeof r.verboseDefault==`string`?r.verboseDefault:`full`,compaction:vr(r.compaction),pruning:yr(r.pruning),memory:br(r.memory),sessionSearch:xr(r.sessionSearch),backgroundReview:Sr(r.backgroundReview),webExtract:Cr(r.webExtract),delegate:wr(r.delegate,!1),executeCode:wr(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:Tr(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return Tr(t)})(),paramsJson:Er(r.params)}}function Ar(e){let t={enabled:e.enabled,useEnhancedSystem:e.useEnhancedSystem,userProfileEnabled:e.userProfileEnabled};return e.provider===`none`||e.provider===`stub`?t.provider=e.provider:t.provider=null,e.injectionFrequency===`every-turn`||e.injectionFrequency===`first-turn`?t.injectionFrequency=e.injectionFrequency:t.injectionFrequency=null,t.memoryCharLimit=e.memoryCharLimit??null,t.userCharLimit=e.userCharLimit??null,t.contextCadence=e.contextCadence??null,t.dialecticCadence=e.dialecticCadence??null,t}function jr(e){let t=e.trim();if(!t)return null;let n=JSON.parse(t);if(n===null)return null;if(typeof n!=`object`||Array.isArray(n))throw Error(`params must be a JSON object`);return n}async function Mr(){return kr(hr(await H(V(`/api/config`)))??{})}async function Nr(e){let t=e.modelFallbacks.map(e=>e.trim()).filter(Boolean),n=t.length>0?{primary:e.model,fallbacks:t}:e.model,r=e.imageModelFallbacks.map(e=>e.trim()).filter(Boolean),i=r.length>0&&e.imageModel.trim()?{primary:e.imageModel.trim(),fallbacks:r}:e.imageModel||``,a=e.imageGenerationModelFallbacks.map(e=>e.trim()).filter(Boolean),o=e.imageGenerationModel.trim(),s=typeof e.imageGenerationModelTimeoutMs==`number`&&e.imageGenerationModelTimeoutMs>0?Math.floor(e.imageGenerationModelTimeoutMs):null,c=e.imageGenerationModelAutoProviderFallback===!0,l=(()=>{let e={};return o&&(e.primary=o),a.length>0&&(e.fallbacks=a),s&&(e.timeoutMs=s),c&&(e.autoProviderFallback=!0),Object.keys(e).length===0?``:Object.keys(e).length===1&&typeof e.primary==`string`?e.primary:e})(),u=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),d=e.skillsAllowlist.map(e=>e.trim()).filter(Boolean),f=e.toolsDisable.map(e=>e.trim()).filter(Boolean),p=jr(e.paramsJson),m=p===null||Object.keys(p).length===0?null:p,h={model:n,imageModel:i,imageGenerationModel:l,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:u,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,commandTimeout:e.browserCommandTimeout??null,backend:e.browserBackend===`local`?null:e.browserBackend,cloudProvider:e.browserCloudProvider===`local`?null:e.browserCloudProvider,cdpUrl:e.browserCdpUrl.trim()||null,extension:e.browserBackend===`extension`?{port:e.browserExtensionPort??null,host:e.browserExtensionHost===`127.0.0.1`?null:e.browserExtensionHost}:null,dialogPolicy:e.browserDialogPolicy===`auto_dismiss`?null:e.browserDialogPolicy,dialogTimeoutSeconds:e.browserDialogTimeout??null},thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:Ar(e.memory),sessionSearch:{summaryModel:e.sessionSearch.summaryModel.trim()||null},backgroundReview:{enabled:e.backgroundReview.enabled,memoryNudgeInterval:e.backgroundReview.memoryNudgeInterval,skillNudgeInterval:e.backgroundReview.skillNudgeInterval,maxToolRounds:e.backgroundReview.maxToolRounds,maxHistoryMessages:e.backgroundReview.maxHistoryMessages,maxDurationMs:e.backgroundReview.maxDurationMs},webExtract:{model:e.webExtract.model.trim()||null,maxLength:e.webExtract.maxLength??null},delegate:{enabled:e.delegate.enabled},executeCode:{enabled:e.executeCode.enabled},systemPromptOverride:e.systemPromptOverride.trim()||null,skills:d.length>0?d:null,tools:{disable:f.length>0?f:null},params:m};await H(V(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:h}})}),pe()}function Pr(e){let t=!!nt(e=>e.token),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(!1),{data:p,error:m,isLoading:g,mutate:_}=h(t),v=(0,Z.useMemo)(()=>p?.payload?.config===void 0?null:kr(p.payload.config),[p]);(0,Z.useEffect)(()=>{if(!t){r(null),a(null),f.current=!1;return}if(v!==null&&!f.current){let e=structuredClone(v);r(e),a(structuredClone(e))}},[t,v]);let y=!!(t&&g&&p===void 0&&!m),b=m instanceof Error?m.message:m?String(m):null,x=(0,Z.useMemo)(()=>!n||!i?!1:JSON.stringify(n)!==JSON.stringify(i),[n,i]);return{hasToken:t,loading:y,fetchError:b,form:n,update:(0,Z.useCallback)(e=>{f.current=!0,r(t=>t?{...t,...e}:null)},[]),dirty:x,saving:o,saveOk:u,error:c,setError:l,save:(0,Z.useCallback)(async()=>{if(!n||o)return!1;s(!0),l(null),d(!1);try{try{jr(n.paramsJson)}catch(t){return l(t instanceof SyntaxError?e.advanced.paramsInvalidJson:t instanceof Error?t.message:e.advanced.paramsInvalidJson),!1}return await Nr(n),f.current=!1,a(structuredClone(n)),d(!0),window.setTimeout(()=>d(!1),2500),!0}catch(t){return l(t instanceof Error?t.message:e.saveError),!1}finally{s(!1)}},[n,o,e.saveError,e.advanced]),discard:(0,Z.useCallback)(()=>{i&&(f.current=!1,r(structuredClone(i)),l(null),d(!1))},[i]),mutate:_}}function Fr(){let e=Pe(p(e=>e.language)),t=e.agentSettings,n=e.chat,r=Pr(t);return{vm:r,pp:(0,Z.useMemo)(()=>r.form?{form:r.form,update:r.update,a:t,chat:n}:null,[r.form,r.update,t,n]),a:t}}function Ir(){let{vm:e,pp:t,a:n}=Fr();return(0,q.jsx)(or,{sectionId:`agent-chat`,intro:n.routeIntro.chat,vm:e,children:t?(0,q.jsx)(Gn,{...t}):null})}function Lr(){let{vm:e,pp:t,a:n}=Fr();return(0,q.jsx)(or,{sectionId:`agent-workspace`,intro:n.routeIntro.workspace,vm:e,children:t?(0,q.jsx)(ar,{...t}):null})}function Rr(){let{vm:e,pp:t,a:n}=Fr();return(0,q.jsx)(or,{sectionId:`agent-browser`,intro:n.routeIntro.browser,vm:e,children:t?(0,q.jsx)(Jn,{...t}):null})}function zr(){let{vm:e,pp:t,a:n}=Fr();return(0,q.jsx)(or,{sectionId:`agent-runtime`,intro:n.routeIntro.runtime,vm:e,children:t?(0,q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,q.jsx)(Qn,{...t}),(0,q.jsx)(er,{...t})]}):null})}function Br(){let{vm:e,pp:t,a:n}=Fr();return(0,q.jsx)(or,{sectionId:`agent-tools`,intro:n.routeIntro.tools,vm:e,children:t?(0,q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,q.jsx)(Zn,{...t}),(0,q.jsx)(rr,{...t}),(0,q.jsx)($n,{...t})]}):null})}function Vr(){let{vm:e,pp:t,a:n}=Fr();return(0,q.jsx)(or,{sectionId:`agent-system-prompt`,intro:n.routeIntro.systemPrompt,vm:e,children:t?(0,q.jsx)(ir,{...t}):null})}export{Un as AgentsSettingsPanel,Mn as _,Br as a,Y as b,Mr as c,$ as d,kn as f,jn as g,An as h,Vr as i,jr as l,Nn as m,Ir as n,Lr as o,Pn as p,zr as r,Pr as s,Rr as t,Nr as u,kt as v,St as x,J as y};
216
- //# sourceMappingURL=agents-DEL6G6-C.js.map
216
+ //# sourceMappingURL=agents-kfTaZM98.js.map