@xopcai/xopc 0.0.8 → 0.0.11
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.
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/gateway/static/root/assets/{agents-BSNzJWbQ.js → agents-BdC4Y-HX.js} +2 -2
- package/dist/gateway/static/root/assets/agents-BdC4Y-HX.js.map +1 -0
- package/dist/gateway/static/root/assets/{apps-page-BKk9SB4D.js → apps-page-C-oaSHkm.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-BKk9SB4D.js.map → apps-page-C-oaSHkm.js.map} +1 -1
- package/dist/gateway/static/root/assets/attachment-load-BDDlItdE.js +1 -0
- package/dist/gateway/static/root/assets/{channels-settings-_J6cQN6G.js → channels-settings-BqEUppPO.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-_J6cQN6G.js.map → channels-settings-BqEUppPO.js.map} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-DPb_0O8M.js → chat-agents-api-BhqjQ7iL.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-agents-api-DPb_0O8M.js.map → chat-agents-api-BhqjQ7iL.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-BUJOuuKX.js → cron-page-Cli49RKR.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-BUJOuuKX.js.map → cron-page-Cli49RKR.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-utils-Cn0YVg8x.js → cron-utils-Dkj-Ldpf.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-utils-Cn0YVg8x.js.map → cron-utils-Dkj-Ldpf.js.map} +1 -1
- package/dist/gateway/static/root/assets/{electron-env-D9bm1FIu.js → electron-env-BDtJw9AY.js} +2 -2
- package/dist/gateway/static/root/assets/{electron-env-D9bm1FIu.js.map → electron-env-BDtJw9AY.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DTz4O5Ua.js → extension-debug-page-BMcZlaxF.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-DTz4O5Ua.js.map → extension-debug-page-BMcZlaxF.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-Cs1Kde9o.js → extension-iframe-host-D5HEF0KR.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-iframe-host-Cs1Kde9o.js.map → extension-iframe-host-D5HEF0KR.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-G52iX0Bo.js → extension-page-CXdCSSPl.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-G52iX0Bo.js.map → extension-page-CXdCSSPl.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-CO2jxBA9.js → extension-provider-DZCZgQE2.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-provider-CO2jxBA9.js.map → extension-provider-DZCZgQE2.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D9Ul8uSt.js → extension-settings-page-CX6STpx3.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-D9Ul8uSt.js.map → extension-settings-page-CX6STpx3.js.map} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Bc8SVD15.js → gateway-config-swr-Cph02QZn.js} +2 -2
- package/dist/gateway/static/root/assets/{gateway-config-swr-Bc8SVD15.js.map → gateway-config-swr-Cph02QZn.js.map} +1 -1
- package/dist/gateway/static/root/assets/index-Bty3m0mS.css +2 -0
- package/dist/gateway/static/root/assets/{index-BXUJbteW.js → index-iTUyfzNr.js} +10 -10
- package/dist/gateway/static/root/assets/index-iTUyfzNr.js.map +1 -0
- package/dist/gateway/static/root/assets/{logs-page-5V25JkQY.js → logs-page-B9O5l3I8.js} +2 -2
- package/dist/gateway/static/root/assets/{logs-page-5V25JkQY.js.map → logs-page-B9O5l3I8.js.map} +1 -1
- package/dist/gateway/static/root/assets/{model-selector-he3aQfme.js → model-selector-BLiY_O25.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-he3aQfme.js.map → model-selector-BLiY_O25.js.map} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-BFpnFTed.js +2 -0
- package/dist/gateway/static/root/assets/{page-header-store-DJHD9Ean.js.map → page-header-store-BFpnFTed.js.map} +1 -1
- package/dist/gateway/static/root/assets/{session-api-n-4O5d9U.js → session-api-DEhQXWJg.js} +2 -2
- package/dist/gateway/static/root/assets/{session-api-n-4O5d9U.js.map → session-api-DEhQXWJg.js.map} +1 -1
- package/dist/gateway/static/root/assets/{session-working-directory-control-B6dHLvbr.js → session-working-directory-control-DKOtWs3-.js} +2 -2
- package/dist/gateway/static/root/assets/{session-working-directory-control-B6dHLvbr.js.map → session-working-directory-control-DKOtWs3-.js.map} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-rBUfTdm3.js → sessions-page-BYlWP1ep.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-rBUfTdm3.js.map → sessions-page-BYlWP1ep.js.map} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B3QrJm-E.js → settings-page-oCnIavdg.js} +2 -2
- package/dist/gateway/static/root/assets/settings-page-oCnIavdg.js.map +1 -0
- package/dist/gateway/static/root/assets/{skill-api-vxtE8kI6.js → skill-api-DWrn8Az0.js} +2 -2
- package/dist/gateway/static/root/assets/{skill-api-vxtE8kI6.js.map → skill-api-DWrn8Az0.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-D36_O2Ub.js → skills-page-C59WQpM1.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-D36_O2Ub.js.map → skills-page-C59WQpM1.js.map} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CmiSsYBd.js → theme-store-CywXkKml.js} +2 -2
- package/dist/gateway/static/root/assets/{theme-store-CmiSsYBd.js.map → theme-store-CywXkKml.js.map} +1 -1
- package/dist/gateway/static/root/assets/url-D7yWllI8.js +2 -0
- package/dist/gateway/static/root/assets/url-D7yWllI8.js.map +1 -0
- package/dist/gateway/static/root/assets/{useTranslation-DYORQ7x6.js → useTranslation-CACj0DBJ.js} +2 -2
- package/dist/gateway/static/root/assets/{useTranslation-DYORQ7x6.js.map → useTranslation-CACj0DBJ.js.map} +1 -1
- package/dist/gateway/static/root/index.html +15 -15
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +20 -12
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/background-review/run-background-review.js +2 -0
- package/dist/src/agent/background-review/run-background-review.js.map +1 -1
- package/dist/src/agent/child-agent-factory.js +2 -0
- package/dist/src/agent/child-agent-factory.js.map +1 -1
- package/dist/src/agent/context/expand-at-file-mentions.d.ts +4 -0
- package/dist/src/agent/context/expand-at-file-mentions.js +69 -0
- package/dist/src/agent/context/expand-at-file-mentions.js.map +1 -0
- package/dist/src/agent/context/workspace-seed.js +1 -1
- package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/memory/compaction.d.ts +1 -1
- package/dist/src/agent/memory/compaction.js +38 -11
- package/dist/src/agent/memory/compaction.js.map +1 -1
- package/dist/src/agent/messaging/command-handler.d.ts +13 -0
- package/dist/src/agent/messaging/command-handler.js +14 -2
- package/dist/src/agent/messaging/command-handler.js.map +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +6 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
- package/dist/src/agent/service.d.ts +16 -1
- package/dist/src/agent/service.js +178 -20
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/skills/format-skills-prompt.js.map +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/scanner.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js.map +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/browser/tools.js.map +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-tool.js.map +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/channels/attachments/inbound-persist.js +1 -1
- package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
- package/dist/src/channels/index.d.ts +1 -1
- package/dist/src/channels/index.js +2 -2
- package/dist/src/channels/pipeline.d.ts +8 -1
- package/dist/src/channels/pipeline.js +49 -4
- package/dist/src/channels/pipeline.js.map +1 -1
- package/dist/src/chat-commands/builtins/config.d.ts +4 -0
- package/dist/src/chat-commands/builtins/config.js +197 -0
- package/dist/src/chat-commands/builtins/config.js.map +1 -0
- package/dist/src/chat-commands/builtins/context.d.ts +4 -0
- package/dist/src/chat-commands/builtins/context.js +44 -0
- package/dist/src/chat-commands/builtins/context.js.map +1 -0
- package/dist/src/chat-commands/builtins/session.js +111 -0
- package/dist/src/chat-commands/builtins/session.js.map +1 -1
- package/dist/src/chat-commands/builtins/thinking.js +49 -21
- package/dist/src/chat-commands/builtins/thinking.js.map +1 -1
- package/dist/src/chat-commands/config-paths.d.ts +10 -0
- package/dist/src/chat-commands/config-paths.js +45 -0
- package/dist/src/chat-commands/config-paths.js.map +1 -0
- package/dist/src/chat-commands/config-value.d.ts +12 -0
- package/dist/src/chat-commands/config-value.js +53 -0
- package/dist/src/chat-commands/config-value.js.map +1 -0
- package/dist/src/chat-commands/context.d.ts +24 -1
- package/dist/src/chat-commands/context.js +41 -0
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/index.d.ts +2 -0
- package/dist/src/chat-commands/index.js +5 -1
- package/dist/src/chat-commands/index.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +33 -1
- package/dist/src/cli/commands/agent/interactive.js +1 -1
- package/dist/src/cli/commands/agent/interactive.js.map +1 -1
- package/dist/src/cli/commands/agent.js +22 -10
- package/dist/src/cli/commands/agent.js.map +1 -1
- package/dist/src/cli/commands/auth.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/extension.js +10 -0
- package/dist/src/cli/commands/extension.js.map +1 -1
- package/dist/src/cli/commands/init.js +3 -4
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/session/utils.js.map +1 -1
- package/dist/src/cli/commands/update.d.ts +1 -0
- package/dist/src/cli/commands/update.js +171 -0
- package/dist/src/cli/commands/update.js.map +1 -0
- package/dist/src/cli/index.d.ts +1 -1
- package/dist/src/cli/index.js +3 -1
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/config/index.d.ts +1 -0
- package/dist/src/config/index.js +5 -4
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/paths.js.map +1 -1
- package/dist/src/config/profile.js +2 -2
- package/dist/src/config/runtime-overrides.d.ts +8 -0
- package/dist/src/config/runtime-overrides.js +40 -0
- package/dist/src/config/runtime-overrides.js.map +1 -0
- package/dist/src/config/schema.d.ts +35 -0
- package/dist/src/config/schema.js +19 -3
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/cron/persistence.js +1 -1
- package/dist/src/cron/run-log-store.js +1 -1
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/loader.d.ts +1 -1
- package/dist/src/extensions/loader.js +6 -9
- package/dist/src/extensions/loader.js.map +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/extensions/sdk/index.js +6 -1
- package/dist/src/extensions/sdk/index.js.map +1 -0
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/hono/oauth.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/index.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +64 -11
- package/dist/src/gateway/hono/routes/models.js.map +1 -1
- package/dist/src/gateway/hono/routes/public-gateway.js +10 -0
- package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
- package/dist/src/gateway/hono/routes/update.d.ts +3 -0
- package/dist/src/gateway/hono/routes/update.js +141 -0
- package/dist/src/gateway/hono/routes/update.js.map +1 -0
- package/dist/src/gateway/hono/routes/workspace.js +84 -4
- package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
- package/dist/src/gateway/hono/sse.js +2 -2
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +16 -4
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/workspace-fs-file-list.d.ts +5 -0
- package/dist/src/gateway/workspace-fs-file-list.js +56 -0
- package/dist/src/gateway/workspace-fs-file-list.js.map +1 -0
- package/dist/src/gateway/workspace-heartbeat-path.js +1 -1
- package/dist/src/gateway/workspace-ripgrep.d.ts +5 -0
- package/dist/src/gateway/workspace-ripgrep.js +88 -4
- package/dist/src/gateway/workspace-ripgrep.js.map +1 -1
- package/dist/src/infra/update-channels.d.ts +14 -0
- package/dist/src/infra/update-channels.js +30 -0
- package/dist/src/infra/update-channels.js.map +1 -0
- package/dist/src/infra/update-check.d.ts +53 -0
- package/dist/src/infra/update-check.js +155 -0
- package/dist/src/infra/update-check.js.map +1 -0
- package/dist/src/infra/update-runner.d.ts +18 -0
- package/dist/src/infra/update-runner.js +112 -0
- package/dist/src/infra/update-runner.js.map +1 -0
- package/dist/src/infra/update-startup.d.ts +20 -0
- package/dist/src/infra/update-startup.js +246 -0
- package/dist/src/infra/update-startup.js.map +1 -0
- package/dist/src/providers/extension-stream-bridge.d.ts +3 -0
- package/dist/src/providers/extension-stream-bridge.js +239 -0
- package/dist/src/providers/extension-stream-bridge.js.map +1 -0
- package/dist/src/providers/index.d.ts +7 -2
- package/dist/src/providers/index.js +77 -14
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/plugin-registry.js +92 -87
- package/dist/src/providers/plugin-registry.js.map +1 -1
- package/dist/src/session/chat-export.d.ts +5 -0
- package/dist/src/session/chat-export.js +35 -0
- package/dist/src/session/chat-export.js.map +1 -0
- package/dist/src/session/config-store.js +1 -1
- package/dist/src/session/manager.d.ts +1 -1
- package/dist/src/session/manager.js +2 -2
- package/dist/src/session/manager.js.map +1 -1
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.d.ts +1 -1
- package/dist/src/session/store.js +5 -5
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/package.json +2 -1
- package/dist/gateway/static/root/assets/agents-BSNzJWbQ.js.map +0 -1
- package/dist/gateway/static/root/assets/attachment-load-DXcJLSWT.js +0 -1
- package/dist/gateway/static/root/assets/index-BXUJbteW.js.map +0 -1
- package/dist/gateway/static/root/assets/index-CQLMxWSA.css +0 -2
- package/dist/gateway/static/root/assets/page-header-store-DJHD9Ean.js +0 -2
- package/dist/gateway/static/root/assets/settings-page-B3QrJm-E.js.map +0 -1
- package/dist/gateway/static/root/assets/url-CtSqjF9J.js +0 -2
- package/dist/gateway/static/root/assets/url-CtSqjF9J.js.map +0 -1
|
@@ -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 { createInboundDebouncer } from "../../../src/infra/debounce.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");
|
|
@@ -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,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{i as t,t as n}from"./vendor-react-QAsRxa6t.js";import{l as r,n as i,o as a,r as o,s,t as c}from"./url-CtSqjF9J.js";import{r as l}from"./vendor-swr-8rdcElid.js";import{d as u,l as d,t as f,u as p}from"./chunk-QFMPRPBF-DOYp8d2p.js";import{n as m,t as h}from"./cn-DPF56z7S.js";import{C as g,S as _,_ as v,a as y,b,c as x,d as S,f as ee,g as C,h as te,i as w,l as ne,m as T,n as re,o as ie,p as ae,r as oe,s as E,t as se,u as ce,v as le,x as D,y as ue}from"./settings-nav-state-BSa0kz44.js";import{n as de,r as fe,t as O}from"./sparkles-BG1XFBU0.js";import{t as pe}from"./check-CDc_K89l.js";import{c as me,d as he,n as ge,t as k,u as _e}from"./model-selector-he3aQfme.js";import{i as ve,n as ye,r as be}from"./gateway-config-swr-Bc8SVD15.js";import{t as A}from"./file-text-CVBsYEv2.js";import{t as xe}from"./folder-BZ5toHcH.js";import{n as Se,t as Ce}from"./zap-C4SJDlFg.js";import{t as we}from"./plus-CBODkzSX.js";import{t as j}from"./refresh-cw-D7hzzeQ5.js";import{t as Te}from"./search-DoMetBR0.js";import{t as M}from"./trash-2-D9v5oysq.js";import{a as Ee,i as De,n as Oe,o as ke,r as Ae,s as je,t as Me}from"./dist-Db1dcLr9.js";import{t as N}from"./button-CRQ9eQGX.js";import{a as Ne,i as Pe,n as Fe,o as Ie,r as Le,s as Re}from"./form-field-width-BlpNwrfn.js";import{i as ze}from"./theme-store-CmiSsYBd.js";import{t as Be}from"./page-header-store-DJHD9Ean.js";import{a as P,i as Ve,o as He,r as Ue}from"./dist-CpMMntuC.js";import{t as We}from"./markdown-view-BpEqr7_J.js";import{n as Ge}from"./interaction-C4gx-xSs.js";import{C as Ke,a as qe,d as Je,p as Ye,v as Xe,y as Ze}from"./cron-utils-Cn0YVg8x.js";var F=e(t(),1);function I(e){return{...e,skills:e.skills??{defaults:[]},tools:e.tools??{defaultsDisable:[],entryDisable:[],effectiveDisable:[]}}}async function Qe(){let e=(await o(c(`/api/agents`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(I),builtinToolIds:t}}async function $e(e){let t=await o(c(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(I),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function et(e,t){let n=(await o(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function tt(e,t){let n=(await o(c(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}function nt(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function rt(e){await o(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),ye()}async function it(){let e=(await o(c(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function at(e){let t=(await o(c(`/api/agents/${encodeURIComponent(e)}/files`))).payload;if(!t?.files||!t.bootstrapDir)throw Error(`Invalid files list response`);return t}async function ot(e,t){let n=(await o(c(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function st(e,t,n){await o(c(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}var L=`main`,ct=/^[a-z0-9][a-z0-9_-]{0,63}$/i,lt=/[^a-z0-9_-]+/g,ut=/^-+/,dt=/-+$/,ft=/^[a-z0-9][a-z0-9_-]{0,63}$/,pt=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 mt(e){let t=e.trim();if(!t)return L;let n=t.toLowerCase();return ct.test(t)?n:n.replace(lt,`-`).replace(ut,``).replace(dt,``).slice(0,64)||L}function ht(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return ft.test(e)?e===L?{ok:!1,error:`"${L}" is reserved`}:pt.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=mt(t.trim());return r===L?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:pt.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.`}:ft.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 gt(e){let t=e.trim();return t?`~/.xopc/workspace-${mt(t)}`:``}var R=n(),z=[{id:`overview`,labelKey:`navIdentity`,icon:E},{id:`tools`,labelKey:`navTools`,icon:y},{id:`skills`,labelKey:`navSkills`,icon:de},{id:`files`,labelKey:`navCoreFiles`,icon:A}],_t=[{id:`channels`,labelKey:`tabChannels`,icon:ee},{id:`cron`,labelKey:`tabCron`,icon:_e}];function vt(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:h(`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,R.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,R.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:z.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,R.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:_t.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function yt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:c,footerSaveDisabled:l,busy:u,children:d}=e;return(0,R.jsx)(ke,{open:t,onOpenChange:n,children:(0,R.jsxs)(Ee,{children:[(0,R.jsx)(De,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,R.jsxs)(Oe,{className:h(`xopc-dialog-content fixed z-[60] flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,`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,R.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,R.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,R.jsx)(je,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,R.jsx)(Ae,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,R.jsx)(Me,{asChild:!0,children:(0,R.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,R.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,R.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,R.jsx)(vt,{a:r,panel:o,onPanelChange:s})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:d}),(0,R.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:[l?(0,R.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,R.jsx)(N,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:u||l,onClick:()=>void c(),children:r.save})]})]})]})]})]})})}function bt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>{let t=(e.name??``).toLowerCase(),r=e.id.toLowerCase(),i=e.workspace.toLowerCase(),a=(e.description??``).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)||a.includes(n)}):e}function xt(e){let{a:t,busy:n,onNewAgent:r}=e;return(0,R.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(),className:h(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,R.jsx)(we,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),(0,R.jsx)(`span`,{children:t.listNewAgentCard})]})}function St(e){let{a:t,agents:n,searchQuery:r,onOpenAgent:i,onChatWithAgent:a,onNewAgent:o,busy:s}=e,c=bt(n,r),l=n.length>0&&c.length===0&&r.trim().length>0;return n.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listNoAgentsYet}),(0,R.jsx)(`div`,{className:`max-w-sm`,children:(0,R.jsx)(xt,{a:t,busy:s,onNewAgent:o})})]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listEmpty}):null,(0,R.jsxs)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,children:[(0,R.jsx)(`li`,{className:`h-full min-h-0`,children:(0,R.jsx)(xt,{a:t,busy:s,onNewAgent:o})}),c.map(e=>{let n=e.name?.trim()?e.name.trim():e.id,r=e.id,o=e.description?.trim()??``;return(0,R.jsx)(`li`,{className:`h-full min-h-0`,children:(0,R.jsxs)(`div`,{className:h(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,R.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:h(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(`span`,{className:`flex size-11 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,R.jsx)(_,{className:`size-6`,strokeWidth:1.75})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:n}),e.isDefault?(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.defaultBadge}):null]}),(0,R.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,R.jsx)(`p`,{className:h(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,o?`text-fg`:`text-fg-muted/25`),title:o||void 0,children:o||`\xA0`})]}),(0,R.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:h(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,R.jsx)(ae,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),t.listChatWithAgent]})]})},e.id)})]})]})}function Ct(e){let{a:t}=e;return(0,R.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:t.title}),(0,R.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.subtitle})]})})}function B(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Re,`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}}function Dt(e){let{open:t,onOpenChange:n,a:r,chat:i,busy:a,modalError:o,createDisplayName:s,setCreateDisplayName:c,createAgentId:l,setCreateAgentId:u,createDescription:d,setCreateDescription:f,createWorkspace:p,setCreateWorkspace:g,createModel:_,setCreateModel:v,onCreate:y,onSuggestWorkspace:b}=e;return(0,R.jsx)(ke,{open:t,onOpenChange:n,children:(0,R.jsxs)(Ee,{children:[(0,R.jsx)(De,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,R.jsxs)(Oe,{className:h(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,R.jsx)(je,{className:`text-base font-semibold text-fg`,children:r.addAgent}),(0,R.jsx)(Ae,{className:`mt-0.5 text-xs text-fg-muted`,children:r.addAgentHint})]}),(0,R.jsx)(Me,{asChild:!0,children:(0,R.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,R.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,R.jsxs)(`form`,{className:`grid gap-3`,onSubmit:y,children:[o?(0,R.jsx)(`div`,{role:`alert`,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:o}):null,(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentLabel}),(0,R.jsx)(`input`,{className:B(),value:s,onChange:e=>c(e.target.value),onBlur:()=>b(),required:!0,autoComplete:`off`})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentIdOptional}),(0,R.jsx)(`input`,{className:h(B(),`font-mono text-xs`),value:l,onChange:e=>u(e.target.value),onBlur:()=>b(),placeholder:r.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:r.newAgentIdRules}),(0,R.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.newAgentIdRules})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.agentDescription}),(0,R.jsx)(`textarea`,{className:h(B(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),value:d,onChange:e=>f(e.target.value),placeholder:r.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newWorkspace}),(0,R.jsx)(`input`,{className:h(B(),`font-mono text-xs`),value:p,onChange:e=>g(e.target.value),required:!0,autoComplete:`off`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newModelOptional}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,R.jsx)(k,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:_,disabled:a,placeholder:i.modelPlaceholder,searchPlaceholder:i.modelSearchPlaceholder,noMatches:i.modelNoMatches,onChange:e=>v(e)}),_.trim()?(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:a,onClick:()=>v(``),children:r.modelClear}):null]})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,R.jsx)(Me,{asChild:!0,children:(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:a,children:r.createModalCancel})}),(0,R.jsxs)(N,{type:`submit`,disabled:a,children:[(0,R.jsx)(x,{className:`mr-1 size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})})}function Ot(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function V({children:e,className:t}){return(0,R.jsx)(`section`,{className:h(Ot(),t),children:e})}function H({icon:e,title:t,subtitle:n,className:r}){return(0,R.jsxs)(`div`,{className:h(`mb-5 flex items-start gap-3`,r),children:[(0,R.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted dark:bg-surface-hover/70`,"aria-hidden":!0,children:(0,R.jsx)(e,{className:`size-4`,strokeWidth:1.75})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]})]})}var U=h(Ie,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function kt(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:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:x}=e,S=!c&&(l||s.length>0);return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:te,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,R.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,R.jsx)(`span`,{className:`font-mono text-xs`,children:Tt(e.match)}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,R.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,R.jsx)(`input`,{className:B(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,R.jsx)(`select`,{className:h(B(),`py-2`),value:u,onChange:e=>{d(e.target.value),g(null),v(``)},children:s.map(e=>(0,R.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),S&&u.trim()?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,R.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||p||!u.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,R.jsx)(j,{className:h(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,R.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,R.jsxs)(`select`,{className:h(B(),`py-2`),value:m==null?``:String(m),disabled:n||!u.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,R.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,R.jsx)(`option`,{value:String(t),children:qe(e,b)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,className:h(B(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,R.jsxs)(`select`,{className:U,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,R.jsx)(`option`,{value:``,children:x}),f.map(e=>(0,R.jsx)(`option`,{value:e.chatId,children:qe(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,R.jsx)(`div`,{children:(0,R.jsx)(N,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function At(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:g,title:t.cronTitle,subtitle:t.cronHint}),i?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,R.jsx)(`div`,{className:`overflow-x-auto`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,R.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,R.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,R.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,R.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:Je(e),children:Je(e)}),(0,R.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,R.jsx)(`td`,{className:`py-2 pr-3`,children:(0,R.jsxs)(`select`,{className:h(B(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,R.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,R.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,bootstrapViewMode:o,setBootstrapViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,bootstrapFileLoading:d,bootstrapEditorNonce:f}=e,p=ze(e=>e.resolved===`dark`);return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,R.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.tabFiles,children:r.files.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:h(`-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,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":t.filesBootstrapEdit,children:[(0,R.jsxs)(`button`,{type:`button`,className:h(`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,R.jsx)(me,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapEdit]}),(0,R.jsxs)(`button`,{type:`button`,className:h(`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,R.jsx)(ve,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapPreview]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,R.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,R.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,R.jsx)(`div`,{className:h(B(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,R.jsx)(ge,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,R.jsx)(`div`,{className:h(B(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,R.jsx)(We,{content:c,className:`text-sm`})})]}):(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}function Mt(e){let{a:t,chat:n,selected:r,busy:i,editName:a,setEditName:o,editDescription:s,setEditDescription:c,editWorkspace:l,setEditWorkspace:u,editModel:d,setEditModel:f,onSetDefault:p,onSaveAgentEdits:m,onDelete:g,hideInlineSave:_}=e;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:ie,title:t.selectAgent,subtitle:t.selectAgentHint}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:!r||r.isDefault||i,onClick:()=>void p(),children:t.setDefault})})]}),r?(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:T,title:t.editAgent,subtitle:t.editAgentHint}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.displayName}),(0,R.jsx)(`input`,{className:B(),value:a,onChange:e=>o(e.target.value)})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm sm:col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.agentDescription}),(0,R.jsx)(`textarea`,{className:h(B(),`min-h-[5.5rem] resize-y font-sans text-sm leading-relaxed`),value:s,onChange:e=>c(e.target.value),placeholder:t.agentDescriptionPlaceholder,maxLength:4e3,rows:4,spellCheck:!0})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm sm:col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.workspacePath}),(0,R.jsx)(`input`,{className:h(B(),`font-mono text-xs`),value:l,onChange:e=>u(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm sm:col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.modelPrimary}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,R.jsx)(k,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:d,disabled:i,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>f(e)}),d.trim()?(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:i,onClick:()=>f(``),children:t.modelClear}):null]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[_?null:(0,R.jsx)(N,{type:`button`,disabled:i,onClick:()=>void m(),children:t.save}),r.id===`main`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(N,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void g(!1),children:[(0,R.jsx)(M,{className:`mr-1 size-4`,"aria-hidden":!0}),t.removeFromConfig]}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`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`,disabled:i,onClick:()=>void g(!0),children:t.purgeDisk})]})]})]}):null]})}function Nt(e){let{a:t,selected:n,busy:r,skillsCatalogLoading:i,catalogForPick:a,skillsInherit:o,setSkillsInherit:s,skillsPick:c,setSkillsPick:l,onSaveSkills:u,hideInlineSave:d}=e;function p(e){let t=n.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)}function m(){let e=n.skills.effectiveAllowlist;return e===void 0?new Set(a.map(e=>e.name||e.directoryId)):new Set(e)}return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:fe,title:t.skillsTitle,subtitle:t.skillsHint}),(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>s(!0),children:t.skillsInherit}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>{s(!1),l(m())},children:t.skillsCustomize})]}),(0,R.jsx)(f,{to:`/skills`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:t.skillsLibraryLink})]}),(0,R.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[t.skillsDefaultsLabel,` `,n.skills.defaults.length?n.skills.defaults.join(`, `):`—`]}),(0,R.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[t.skillsEffectiveLabel,` `,n.skills.effectiveAllowlist?.length?n.skills.effectiveAllowlist.join(`, `):t.skillsAllFromCatalog]}),i?(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsCatalogLoading}):a.length===0?(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsEmptyCatalog}):(0,R.jsx)(`div`,{className:h(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,o&&`opacity-50`),children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,role:`list`,children:a.map(e=>{let n=e.name||e.directoryId,i=o?p(n):c.has(n),a=typeof e.description==`string`?e.description.trim():``,s=a||t.skillsNoDescription;return(0,R.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,R.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:i,disabled:o||r,onChange:()=>{l(e=>{let t=new Set(e);return i?t.delete(n):t.add(n),t})}}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:n,children:n}),(0,R.jsx)(`p`,{className:h(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:s,children:s})]})]})},n)})})}),d?null:(0,R.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,R.jsx)(N,{type:`button`,disabled:r,onClick:()=>void u(),children:t.skillsSave})})]})}function Pt(e){let{a:t,data:n,selected:r,busy:i,toolEntryDisable:a,setToolEntryDisable:o,onSaveTools:s,onClearToolsEntry:c,hideInlineSave:l}=e;return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:y,title:t.toolsTitle,subtitle:t.toolsHint}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5 pr-1`,role:`list`,children:(n.builtinToolIds.length?n.builtinToolIds:[]).map(e=>{let n=r.tools.defaultsDisable.includes(e),s=n?!1:!a.has(e),c=e in t.toolDescriptions?t.toolDescriptions[e]:``;return(0,R.jsx)(`li`,{className:h(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,n&&`opacity-60`),children:(0,R.jsxs)(`label`,{className:h(`flex cursor-pointer gap-3 text-sm`,n&&`cursor-not-allowed`),children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:s,disabled:n||i,onChange:()=>{n||o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:e}),n?(0,R.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,t.toolsLockedByDefaults,`)`]}):null]}),c?(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c}):null]})]})},e)})})}),(0,R.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[l?null:(0,R.jsx)(N,{type:`button`,disabled:i,onClick:()=>void s(),children:t.toolsSave}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void c(),children:t.toolsClearEntry})]})]})}function Ft(){let e=r(s(e=>e.language)),t=e.agentsSettings,n=e.cron,i=e.chat,o=!!a(e=>e.token),[c]=u(),m=d(),{agentId:h}=p(),g=Be(e=>e.setPageHeader),_=Be(e=>e.clearPageHeader),{data:v,error:y,isLoading:b,mutate:x}=l(o?`settings-gateway-agents`:null,Qe,{revalidateOnFocus:!1}),{data:S}=be(o),ee=(0,F.useMemo)(()=>nt(S?.payload?.config??{}),[S]),C=v??null,te=!!(o&&b),[ne,T]=(0,F.useState)(null),ie=y instanceof Error?y.message:y?t.loadError:null,ae=ne??ie,[E,le]=(0,F.useState)(null),[D,ue]=(0,F.useState)(`overview`),[de,fe]=(0,F.useState)(``),[O,pe]=(0,F.useState)(``),[me,he]=(0,F.useState)(``),[ge,k]=(0,F.useState)(``),[_e,ve]=(0,F.useState)(``),[ye,A]=(0,F.useState)(null),[xe,Se]=(0,F.useState)(!1),Ce=(0,F.useRef)(``),[j,M]=(0,F.useState)(!1),[Ee,De]=(0,F.useState)(``),[Oe,ke]=(0,F.useState)(``),[Ae,je]=(0,F.useState)(``),[Me,Ne]=(0,F.useState)(``),[Pe,Fe]=(0,F.useState)(``),[Ie,Le]=(0,F.useState)(null),[Re,ze]=(0,F.useState)(!1),[P,Ve]=(0,F.useState)(null),[He,Ue]=(0,F.useState)(``),[We,Ge]=(0,F.useState)(!1),[qe,Je]=(0,F.useState)(`edit`),[I,L]=(0,F.useState)(!1),[ct,lt]=(0,F.useState)(0),ut=(0,F.useRef)(He);ut.current=He;let dt=(0,F.useRef)(E);dt.current=E;let ft=(0,F.useRef)(P);ft.current=P;let pt=(0,F.useRef)(``),mt=(0,F.useRef)(``),z=w(async()=>{let e=dt.current,n=ft.current;if(!e||!n||`${e}:${n}`!==pt.current)return;let r=ut.current;if(r!==mt.current){Ge(!0),T(null);try{await st(e,n,r),mt.current=r,Le(t=>!t||t.agentId!==e?t:{...t,files:t.files.map(e=>e.name===n?{...e,missing:!1}:e)})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{Ge(!1)}}},800),_t=(0,F.useRef)(z.flush);_t.current=z.flush,(0,F.useEffect)(()=>()=>{_t.current()},[]);let[vt,bt]=(0,F.useState)(()=>new Set),[xt,B]=(0,F.useState)(()=>new Set),[Tt,Ot]=(0,F.useState)(!0),[V,H]=(0,F.useState)([]),[U,Ft]=(0,F.useState)(``),[W,G]=(0,F.useState)([]),[K,It]=(0,F.useState)(!1),[q,Lt]=(0,F.useState)([]),[Rt,J]=(0,F.useState)(!1),[zt,Bt]=(0,F.useState)(null),[Vt,Ht]=(0,F.useState)(``),[Ut,Wt]=(0,F.useState)([]),[Gt,Kt]=(0,F.useState)(!1),[qt,Jt]=(0,F.useState)([]),[Yt,Xt]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(C){if(h&&C.agents.some(e=>e.id===h)){le(h);return}le(e=>e&&C.agents.some(t=>t.id===e)?e:C.defaultId)}},[C,h]),(0,F.useEffect)(()=>{!C||!h||C.agents.some(e=>e.id===h)||m(re,{replace:!0})},[C,h,m]),(0,F.useEffect)(()=>{h&&ue(`overview`)},[h]),(0,F.useEffect)(()=>{c.get(`panel`)===`defaults`&&m(`/settings/agent-defaults`,{replace:!0,state:{[se]:re}})},[c,m]);let Y=(0,F.useMemo)(()=>C?.agents.find(e=>e.id===E)??null,[C,E]),Zt=(0,F.useMemo)(()=>Y?V.filter(e=>e.agentId.toLowerCase()===Y.id.toLowerCase()):[],[V,Y?.id]),Qt=(0,F.useMemo)(()=>!C||!Y?[]:Ut.filter(e=>wt(e,Y.id,C.defaultId)),[Ut,C,Y?.id]),X=(0,F.useMemo)(()=>qt.filter(e=>e.enabled!==!1),[qt]);(0,F.useEffect)(()=>{if(!Y){ke(``),je(``),Ne(``),Fe(``);return}ke(Y.workspace),je(Y.model?.primary??``),Ne(Y.name?.trim()?Y.name.trim():Y.id),Fe(Y.description?.trim()??``)},[Y]),(0,F.useEffect)(()=>{if(D!==`files`||!E||!o)return;let e=!1;return ze(!0),at(E).then(t=>{e||Le(t)}).catch(()=>{e||Le(null)}).finally(()=>{e||ze(!1)}),()=>{e=!0}},[D,E,o,C?.agents.length]),(0,F.useEffect)(()=>{!Y||D!==`tools`||bt(new Set(Y.tools.entryDisable))},[D,Y]),(0,F.useEffect)(()=>{if(!Y||D!==`skills`)return;let e=Y.skills.entry===void 0;if(Ot(e),e){let e=Y.skills.effectiveAllowlist;B(new Set(e??[]))}else B(new Set(Y.skills.entry??[]))},[D,Y]),(0,F.useEffect)(()=>{D!==`channels`||!o||H(ee)},[D,o,ee]),(0,F.useEffect)(()=>{if(D!==`channels`||!o)return;let e=!1;return It(!0),Ye().then(t=>{e||G(t)}).catch(()=>{e||G([])}).finally(()=>{e||It(!1)}),()=>{e=!0}},[D,o]),(0,F.useEffect)(()=>{K||D!==`channels`||W.length===0||Ft(e=>e&&W.some(t=>t.name===e)?e:W[0].name)},[K,D,W]),(0,F.useEffect)(()=>{if(D!==`channels`||!o)return;let e=U.trim();if(!e){Lt([]);return}let t=!1;return Bt(null),J(!0),Xe(e).then(e=>{t||Lt(e)}).catch(()=>{t||Lt([])}).finally(()=>{t||J(!1)}),()=>{t=!0}},[D,o,U]);let Z=(0,F.useCallback)(()=>{let e=U.trim();e&&(J(!0),Xe(e).then(e=>{Lt(e),Bt(t=>t!=null&&t<e.length?t:null)}).catch(()=>{Lt([]),Bt(null)}).finally(()=>{J(!1)}))},[U]),Q=!K&&W.length===0,$t=D===`channels`&&o&&S===void 0;(0,F.useEffect)(()=>{if(D!==`cron`||!o)return;let e=!1;return Kt(!0),Ze().then(t=>{e||Wt(t)}).catch(()=>{e||Wt([])}).finally(()=>{e||Kt(!1)}),()=>{e=!0}},[D,o]),(0,F.useEffect)(()=>{if(D!==`skills`||!o)return;let e=!1;return Xt(!0),it().then(t=>{e||Jt(t)}).catch(()=>{e||Jt([])}).finally(()=>{e||Xt(!1)}),()=>{e=!0}},[D,o]),(0,F.useEffect)(()=>{if(!P||!E||!o)return;let e=!1;return z.flush(),L(!0),ot(E,P).then(t=>{e||(pt.current=`${E}:${P}`,mt.current=t,Ue(t),lt(e=>e+1))}).catch(()=>{e||(pt.current=`${E}:${P}`,mt.current=``,Ue(``),lt(e=>e+1))}).finally(()=>{e||L(!1)}),()=>{e=!0}},[P,E,o,z]),(0,F.useEffect)(()=>{!P||!E||I||z()},[He,P,E,I,z]),(0,F.useEffect)(()=>{if(D===`files`)return()=>{z.flush()}},[D,z]),(0,F.useEffect)(()=>{Je(`edit`)},[P,E]);let en=(0,F.useCallback)(()=>{let e=gt(O.trim()||de);k(t=>t===``||t===Ce.current?(Ce.current=e,e):t)},[O,de]),tn=(0,F.useCallback)(()=>{Ce.current=``,fe(``),pe(``),he(``),k(``),ve(``),A(null),Se(!0)},[]),nn=e.settingsSections[`agent-defaults`],rn=(0,F.useMemo)(()=>(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,R.jsx)(N,{asChild:!0,variant:`secondary`,className:`shrink-0 gap-2`,children:(0,R.jsxs)(f,{to:`/settings/agent-defaults`,title:nn,state:{[se]:re},children:[(0,R.jsx)(ce,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),nn]})}),(0,R.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,R.jsx)(Te,{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,R.jsx)(`input`,{type:`search`,role:`searchbox`,enterKeyHint:`search`,value:Ee,onChange:e=>De(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,R.jsxs)(N,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":t.addAgentAria,disabled:j,onClick:()=>tn(),children:[(0,R.jsx)(we,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t.addAgent]})]}),[t.addAgent,t.addAgentAria,t.listSearchPlaceholder,j,nn,Ee,tn]);(0,F.useLayoutEffect)(()=>o?(g({startExtra:null,main:null,end:rn}),()=>_()):(_(),()=>_()),[rn,_,o,g]);async function an(e){e.preventDefault();let n=de.trim();if(!n)return;let r=ht(O,n);if(r.ok===!1){A(r.error);return}let i=ge.trim()||gt(O.trim()||n);if(i){M(!0),A(null);try{let e=me.trim(),{createdAgentId:t,...r}=await $e({name:n,workspace:i,...O.trim()?{id:O.trim()}:{},..._e.trim()?{model:_e.trim()}:{},...e?{description:e}:{}});x(r,{revalidate:!1}),fe(``),pe(``),he(``),k(``),ve(``),A(null),Se(!1),le(t),m(oe(t))}catch(e){A(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function on(){if(Y){M(!0),T(null);try{let e=Pe.trim();x(await et(Y.id,{name:Me.trim()||void 0,description:e.length>0?e:null,workspace:Oe.trim()||void 0,model:Ae.trim()||null}),{revalidate:!1})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function $(e){M(!0),T(null);try{x(await et(e.id,{setDefault:!0}),{revalidate:!1}),le(e.id)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}async function sn(e,n){if(e.id!==`main`&&window.confirm(n?t.confirmDeletePurge:t.confirmDelete)){M(!0),T(null);try{let t=await tt(e.id,n);x(t,{revalidate:!1}),le(t.defaultId),ue(`overview`),h===e.id&&m(re,{replace:!0})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function cn(){if(Y){M(!0),T(null);try{let e=[...vt].sort((e,t)=>e.localeCompare(t));x(await et(Y.id,{toolsDisable:e}),{revalidate:!1})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function ln(){if(Y){M(!0),T(null);try{x(await et(Y.id,{toolsDisable:null}),{revalidate:!1}),bt(new Set)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function un(){if(Y){M(!0),T(null);try{x(await et(Y.id,{skills:Tt?null:[...xt].sort((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function dn(e){M(!0),T(null);try{let t=V.filter(t=>t!==e);await rt(t),H(t)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}async function fn(e){if(e.preventDefault(),!Y||!U.trim())return;let n=Et(U,Vt,zt,q),r=[...V,{agentId:Y.id,priority:100,enabled:!0,match:n}];M(!0),T(null);try{await rt(r),H(r),Bt(null),Ht(``)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}async function pn(e,n){M(!0),T(null);try{await Ke(e.id,{agentId:n===``?null:n}),Wt(await Ze())}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}let mn=D===`channels`||D===`cron`;function hn(){switch(D){case`overview`:on();break;case`tools`:cn();break;case`skills`:un();break;case`files`:z.flush();break;default:break}}function gn(e){e||m(re)}let _n=Y?Me.trim()||Y.name?.trim()||Y.id:h??``,vn=Y?.id??h??``;if(!o)return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.title}),(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]});let yn=Y?D===`overview`?(0,R.jsx)(Mt,{a:t,chat:i,selected:Y,busy:j,editName:Me,setEditName:Ne,editDescription:Pe,setEditDescription:Fe,editWorkspace:Oe,setEditWorkspace:ke,editModel:Ae,setEditModel:je,onSetDefault:()=>void $(Y),onSaveAgentEdits:()=>void on(),onDelete:e=>void sn(Y,e),hideInlineSave:!0}):D===`files`?(0,R.jsx)(jt,{a:t,filesLoading:Re,files:Ie,activeFile:P,setActiveFile:Ve,bootstrapViewMode:qe,setBootstrapViewMode:Je,fileDraft:He,setFileDraft:Ue,fileSaving:We,bootstrapFileLoading:I,bootstrapEditorNonce:ct}):D===`tools`?(0,R.jsx)(Pt,{a:t,data:C,selected:Y,busy:j,toolEntryDisable:vt,setToolEntryDisable:bt,onSaveTools:()=>void cn(),onClearToolsEntry:()=>void ln(),hideInlineSave:!0}):D===`skills`?(0,R.jsx)(Nt,{a:t,selected:Y,busy:j,skillsCatalogLoading:Yt,catalogForPick:X,skillsInherit:Tt,setSkillsInherit:Ot,skillsPick:xt,setSkillsPick:B,onSaveSkills:()=>void un(),hideInlineSave:!0}):D===`channels`?(0,R.jsx)(kt,{a:t,busy:j,bindingsLoading:$t,agentBindings:Zt,channelStatuses:W,channelsStatusLoading:K,useManualChannel:Q,newBindChannel:U,setNewBindChannel:Ft,bindSessionChats:q,sessionsLoading:Rt,newBindSessionIdx:zt,setNewBindSessionIdx:Bt,newBindCustomPeer:Vt,setNewBindCustomPeer:Ht,onRefreshSessions:Z,lastActiveLabels:n.lastActiveLabels,selectRecipient:n.selectRecipient,onRemoveBinding:e=>void dn(e),onAddBinding:fn}):D===`cron`&&C?(0,R.jsx)(At,{a:t,data:C,selected:Y,busy:j,cronLoading:Gt,agentCronJobs:Qt,onSetCronJobAgent:(e,t)=>void pn(e,t)}):(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint}):(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint});return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,R.jsx)(Ct,{a:t}),ae?(0,R.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:ae}):null,te?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):C?(0,R.jsx)(St,{a:t,agents:C.agents,searchQuery:Ee,onOpenAgent:e=>m(oe(e)),onChatWithAgent:e=>m(`/chat/new`,{state:{agentId:e.trim().toLowerCase()}}),onNewAgent:tn,busy:j}):null,h&&o?(0,R.jsx)(yt,{open:!!h,onOpenChange:gn,a:t,title:_n,subtitle:vn,panel:D,onPanelChange:ue,onFooterSave:hn,footerSaveDisabled:mn,busy:j,children:te||!C?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):yn}):null,(0,R.jsx)(Dt,{open:xe,onOpenChange:e=>{Se(e),e||(Ce.current=``,fe(``),pe(``),he(``),k(``),ve(``),A(null))},a:t,chat:i,busy:j,modalError:ye,createDisplayName:de,setCreateDisplayName:fe,createAgentId:O,setCreateAgentId:pe,createDescription:me,setCreateDescription:he,createWorkspace:ge,setCreateWorkspace:k,createModel:_e,setCreateModel:ve,onCreate:an,onSuggestWorkspace:()=>en()})]})}var W={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},G={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},K={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},It={summaryModel:``},q={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},Lt={model:``,maxLength:void 0};function Rt(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 J(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 zt(e){return e===!0||e===`true`||e===1}function Bt(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!0};let n=t,r=zt(n.enabled),i=n.headless;return{browserEnabled:r,browserHeadless:!(i===!1||i===`false`||i===0)}}function Vt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...W};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:W.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):W.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:W.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):W.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):W.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:W.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):W.retentionWindow}}function Ht(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...G};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:G.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):G.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:G.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:G.tailKeepRatio}}function Ut(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...K};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:K.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:K.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:K.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 Wt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...It};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Gt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...q};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:q.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):q.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):q.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):q.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):q.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):q.maxDurationMs}}function Kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Lt};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function qt(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 Jt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yt(e){if(e==null)return``;if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Xt(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:J(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:J(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:J(r.imageGenerationModel),{browserEnabled:u,browserHeadless:d}=Bt(r),f=typeof r.maxTaskDurationMs==`number`&&Number.isFinite(r.maxTaskDurationMs)?r.maxTaskDurationMs:void 0,p=f===void 0?void 0:Math.round(f/6e4);return{model:Rt(r.model),modelFallbacks:a,imageModel:Rt(r.imageModel),imageModelFallbacks:s,imageGenerationModel:Rt(r.imageGenerationModel),imageGenerationModelFallbacks:l,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:p,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`,browserEnabled:u,browserHeadless:d,thinkingDefault:typeof r.thinkingDefault==`string`?r.thinkingDefault:`medium`,reasoningDefault:typeof r.reasoningDefault==`string`?r.reasoningDefault:`off`,verboseDefault:typeof r.verboseDefault==`string`?r.verboseDefault:`off`,compaction:Vt(r.compaction),pruning:Ht(r.pruning),memory:Ut(r.memory),sessionSearch:Wt(r.sessionSearch),backgroundReview:Gt(r.backgroundReview),webExtract:Kt(r.webExtract),delegate:qt(r.delegate,!1),executeCode:qt(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:Jt(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return Jt(t)})(),paramsJson:Yt(r.params)}}function Y(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 Zt(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 Qt(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),s=a.length>0&&e.imageGenerationModel.trim()?{primary:e.imageGenerationModel.trim(),fallbacks:a}:e.imageGenerationModel||``,l=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),u=e.skillsAllowlist.map(e=>e.trim()).filter(Boolean),d=e.toolsDisable.map(e=>e.trim()).filter(Boolean),f=Zt(e.paramsJson),p=f===null||Object.keys(f).length===0?null:f,m={model:n,imageModel:i,imageGenerationModel:s,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:l,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:{enabled:e.browserEnabled,headless:e.browserHeadless},thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:Y(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:u.length>0?u:null,tools:{disable:d.length>0?d:null},params:p};await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:m}})}),ye()}function X(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Re,`dark:border-edge`)}function Z(){return h(Ie,Pe)}function Q({label:e,description:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function $t(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:ne,title:a.cardLimitsTitle,subtitle:a.cardLimitsSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.maxTaskDurationMs,description:a.maxTaskDurationMsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,max:240,step:1,value:r.maxTaskDurationMinutes??``,placeholder:a.maxTaskDurationPlaceholder,onChange:e=>{let t=e.target.value;if(t===``){i({maxTaskDurationMinutes:void 0});return}let n=Number.parseInt(t,10);Number.isNaN(n)||i({maxTaskDurationMinutes:Math.min(240,Math.max(1,n))})}})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.maxRequestsPerTurn,description:a.maxRequestsPerTurnDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:10,max:200,value:r.maxRequestsPerTurn,onChange:e=>i({maxRequestsPerTurn:Number.parseInt(e.target.value,10)||50})})}),(0,R.jsx)(Q,{label:a.maxToolFailuresPerTurn,description:a.maxToolFailuresPerTurnDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,max:20,value:r.maxToolFailuresPerTurn,onChange:e=>i({maxToolFailuresPerTurn:Number.parseInt(e.target.value,10)||3})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:v,title:a.cardCompactionTitle,subtitle:a.cardCompactionSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.compactionEnabled,description:a.compactionEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.compaction.enabled,onChange:e=>i({compaction:{...r.compaction,enabled:e.target.checked}})}),(0,R.jsx)(`span`,{children:a.compactionEnabledOn})]})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.compactionMode,description:a.compactionModeDesc,children:(0,R.jsxs)(`select`,{className:Z(),value:r.compaction.mode,onChange:e=>i({compaction:{...r.compaction,mode:e.target.value}}),children:[(0,R.jsx)(`option`,{value:`default`,children:a.compactionModeDefault}),(0,R.jsx)(`option`,{value:`safeguard`,children:a.compactionModeSafeguard})]})}),(0,R.jsx)(Q,{label:a.reserveTokens,description:a.reserveTokensDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1e3,value:r.compaction.reserveTokens,onChange:e=>i({compaction:{...r.compaction,reserveTokens:Number.parseInt(e.target.value,10)||0}})})}),(0,R.jsx)(Q,{label:a.triggerThreshold,description:a.triggerThresholdDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:.5,max:.95,step:.05,value:r.compaction.triggerThreshold,onChange:e=>i({compaction:{...r.compaction,triggerThreshold:Number.parseFloat(e.target.value)||.8}})})}),(0,R.jsx)(Q,{label:a.minMessagesBeforeCompact,description:a.minMessagesBeforeCompactDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.compaction.minMessagesBeforeCompact,onChange:e=>i({compaction:{...r.compaction,minMessagesBeforeCompact:Number.parseInt(e.target.value,10)||10}})})}),(0,R.jsx)(Q,{label:a.keepRecentMessages,description:a.keepRecentMessagesDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.compaction.keepRecentMessages,onChange:e=>i({compaction:{...r.compaction,keepRecentMessages:Number.parseInt(e.target.value,10)||5}})})}),(0,R.jsx)(Q,{label:a.evictionWindow,description:a.evictionWindowDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:.1,max:.5,step:.05,value:r.compaction.evictionWindow,onChange:e=>i({compaction:{...r.compaction,evictionWindow:Number.parseFloat(e.target.value)||.2}})})}),(0,R.jsx)(Q,{label:a.retentionWindow,description:a.retentionWindowDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:3,max:20,value:r.compaction.retentionWindow,onChange:e=>i({compaction:{...r.compaction,retentionWindow:Number.parseInt(e.target.value,10)||6}})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:S,title:a.cardPruningTitle,subtitle:a.cardPruningSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.pruningEnabled,description:a.pruningEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.pruning.enabled,onChange:e=>i({pruning:{...r.pruning,enabled:e.target.checked}})}),(0,R.jsx)(`span`,{children:a.pruningEnabledOn})]})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.maxToolResultChars,description:a.maxToolResultCharsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1e3,value:r.pruning.maxToolResultChars,onChange:e=>i({pruning:{...r.pruning,maxToolResultChars:Number.parseInt(e.target.value,10)||1e4}})})}),(0,R.jsx)(Q,{label:a.headKeepRatio,description:a.headKeepRatioDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,max:1,step:.05,value:r.pruning.headKeepRatio,onChange:e=>i({pruning:{...r.pruning,headKeepRatio:Number.parseFloat(e.target.value)||.3}})})}),(0,R.jsx)(Q,{label:a.tailKeepRatio,description:a.tailKeepRatioDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,max:1,step:.05,value:r.pruning.tailKeepRatio,onChange:e=>i({pruning:{...r.pruning,tailKeepRatio:Number.parseFloat(e.target.value)||.3}})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:D,title:a.cardMemoryTitle,subtitle:a.cardMemorySubtitle}),(0,R.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.memoryEnabled,description:a.memoryEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.memoryEnabledOn})]})}),(0,R.jsx)(Q,{label:a.useEnhancedSystem,description:a.useEnhancedSystemDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.useEnhancedSystemOn})]})}),(0,R.jsx)(Q,{label:a.userProfileEnabled,description:a.userProfileEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.userProfileEnabledOn})]})}),(0,R.jsx)(Q,{label:a.memoryProvider,description:a.memoryProviderDesc,children:(0,R.jsxs)(`select`,{className:Z(),value:r.memory.provider,onChange:e=>i({memory:{...r.memory,provider:e.target.value}}),children:[(0,R.jsx)(`option`,{value:``,children:a.memoryProviderUnset}),(0,R.jsx)(`option`,{value:`none`,children:`none`}),(0,R.jsx)(`option`,{value:`stub`,children:`stub`})]})}),(0,R.jsx)(Q,{label:a.injectionFrequency,description:a.injectionFrequencyDesc,children:(0,R.jsxs)(`select`,{className:Z(),value:r.memory.injectionFrequency,onChange:e=>i({memory:{...r.memory,injectionFrequency:e.target.value}}),children:[(0,R.jsx)(`option`,{value:``,children:a.injectionFrequencyUnset}),(0,R.jsx)(`option`,{value:`every-turn`,children:a.injectionEveryTurn}),(0,R.jsx)(`option`,{value:`first-turn`,children:a.injectionFirstTurn})]})}),(0,R.jsx)(Q,{label:a.memoryCharLimit,description:a.memoryCharLimitDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsx)(Q,{label:a.userCharLimit,description:a.userCharLimitDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsx)(Q,{label:a.contextCadence,description:a.contextCadenceDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsx)(Q,{label:a.dialecticCadence,description:a.dialecticCadenceDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:Te,title:a.cardSessionSearchTitle,subtitle:a.cardSessionSearchSubtitle}),(0,R.jsx)(Q,{label:a.sessionSearchSummaryModel,description:a.sessionSearchSummaryModelDesc,children:(0,R.jsx)(k,{value:r.sessionSearch.summaryModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({sessionSearch:{...r.sessionSearch,summaryModel:e}})})})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:O,title:a.cardReviewTitle,subtitle:a.cardReviewSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.reviewEnabled,description:a.reviewEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.reviewEnabledOn})]})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.memoryNudgeInterval,description:a.memoryNudgeIntervalDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.backgroundReview.memoryNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,memoryNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,R.jsx)(Q,{label:a.skillNudgeInterval,description:a.skillNudgeIntervalDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.backgroundReview.skillNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,skillNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,R.jsx)(Q,{label:a.reviewMaxToolRounds,description:a.reviewMaxToolRoundsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,max:32,value:r.backgroundReview.maxToolRounds,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxToolRounds:Number.parseInt(e.target.value,10)||8}})})}),(0,R.jsx)(Q,{label:a.reviewMaxHistoryMessages,description:a.reviewMaxHistoryMessagesDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:10,max:200,value:r.backgroundReview.maxHistoryMessages,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxHistoryMessages:Number.parseInt(e.target.value,10)||80}})})}),(0,R.jsx)(Q,{label:a.reviewMaxDurationMs,description:a.reviewMaxDurationMsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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}})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:A,title:a.cardWebExtractTitle,subtitle:a.cardWebExtractSubtitle}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(`div`,{className:`sm:col-span-2`,children:(0,R.jsx)(Q,{label:a.webExtractModel,description:a.webExtractModelDesc,children:(0,R.jsx)(k,{value:r.webExtract.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({webExtract:{...r.webExtract,model:e}})})})}),(0,R.jsx)(Q,{label:a.webExtractMaxLength,description:a.webExtractMaxLengthDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:b,title:a.cardDelegateTitle,subtitle:a.cardDelegateSubtitle}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.delegateEnabled,description:a.delegateEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.delegateEnabledOn})]})}),(0,R.jsx)(Q,{label:a.executeCodeEnabled,description:a.executeCodeEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.executeCodeEnabledOn})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:C,title:a.cardPromptSkillsTitle,subtitle:a.cardPromptSkillsSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.systemPromptOverride,description:a.systemPromptOverrideDesc,children:(0,R.jsx)(`textarea`,{className:h(X(),`min-h-[100px] resize-y font-mono text-xs`),value:r.systemPromptOverride,placeholder:a.systemPromptPlaceholder,onChange:e=>i({systemPromptOverride:e.target.value})})}),(0,R.jsx)(Q,{label:a.skillsAllowlist,description:a.skillsAllowlistDesc,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.skillsAllowlist.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,className:h(X(),`font-mono text-xs`),value:e,onChange:e=>{let n=[...r.skillsAllowlist];n[t]=e.target.value,i({skillsAllowlist:n})}}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":a.removeListItem,onClick:()=>i({skillsAllowlist:r.skillsAllowlist.filter((e,n)=>n!==t)}),children:`×`})]},t)),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`w-fit`,onClick:()=>i({skillsAllowlist:[...r.skillsAllowlist,``]}),children:a.addSkillName})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:y,title:a.cardToolsDisableTitle,subtitle:a.cardToolsDisableSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.toolsDisableHint}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.toolsDisable.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,className:h(X(),`font-mono text-xs`),value:e,placeholder:`shell`,onChange:e=>{let n=[...r.toolsDisable];n[t]=e.target.value,i({toolsDisable:n})}}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":a.removeListItem,onClick:()=>i({toolsDisable:r.toolsDisable.filter((e,n)=>n!==t)}),children:`×`})]},t)),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`w-fit`,onClick:()=>i({toolsDisable:[...r.toolsDisable,``]}),children:a.addToolName})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:_e,title:a.cardParamsTitle,subtitle:a.cardParamsSubtitle}),(0,R.jsx)(Q,{label:a.paramsJson,description:a.paramsJsonDesc,children:(0,R.jsx)(`textarea`,{className:h(X(),`min-h-[88px] resize-y font-mono text-xs`),value:r.paramsJson,placeholder:`{}`,onChange:e=>i({paramsJson:e.target.value})})})]})]})}async function en(){let e=await i(c(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function tn(e){let t=new Set,n=[];for(let r of e){let e=r.models.length>0?r.models:r.defaultModel?[r.defaultModel]:[];for(let i of e){let e=`${r.id}/${i}`;t.has(e)||(t.add(e),n.push(e))}}return n}function nn(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/[/\s]+/).filter(Boolean);return e.filter(e=>{let t=e.toLowerCase();return r.every(e=>t.includes(e))})}var rn=`image-generation-providers`;function an({value:e,disabled:t,placeholder:n,searchPlaceholder:r,noMatches:i,className:a,onChange:o}){let[s,c]=(0,F.useState)(!1),[u,d]=(0,F.useState)(``),{data:f,isLoading:p,error:m}=l(rn,en,{revalidateOnFocus:!1}),g=(0,F.useMemo)(()=>tn(f??[]),[f]),_=(0,F.useMemo)(()=>nn(g,u),[g,u]),v=e.trim()?e:n,y=e.trim()||n,b=(0,F.useCallback)(e=>{c(e),e||d(``)},[]);return(0,R.jsxs)(P,{open:s,onOpenChange:b,modal:!1,children:[(0,R.jsx)(He,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,disabled:t||p,title:p?`…`:y,className:h(Fe,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,Ge.transition,`hover:border-edge hover:bg-surface-hover/45`,Ne,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,a),"aria-haspopup":`listbox`,"aria-expanded":s,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:p?`…`:v}),(0,R.jsx)(he,{className:`h-4 w-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0})]})}),(0,R.jsx)(Ve,{children:(0,R.jsxs)(Ue,{className:`z-50 w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsx)(`input`,{type:`search`,className:h(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,Le),placeholder:r,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.stopPropagation()}),(0,R.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":r,children:[m?(0,R.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:m instanceof Error?m.message:`Failed to load image providers`}):null,!m&&g.length===0&&!p?(0,R.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:i}):null,!m&&g.length>0&&_.length===0?(0,R.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:i}):null,_.map(t=>(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===e,className:h(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,t===e&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{o(t),c(!1),d(``)},children:[(0,R.jsx)(pe,{className:h(`h-4 w-4 shrink-0`,t!==e&&`invisible`),"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:t})]},t))]})]})})]})}var on=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`adaptive`];function $({label:e,description:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function sn(){let e=r(s(e=>e.language)),t=e.agentSettings,n=e.chat,i=!!a(e=>e.token),[o,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(null),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(!1),_=(0,F.useRef)(!1),{data:v,error:y,isLoading:b,mutate:x}=be(i),S=(0,F.useMemo)(()=>v?.payload?.config===void 0?null:Xt(v.payload.config),[v]);(0,F.useEffect)(()=>{if(!i){c(null),u(null),_.current=!1;return}S!==null&&(_.current||(c(S),u(S)))},[i,S]);let ee=!!(i&&b&&v===void 0&&!y),C=y instanceof Error?y.message:y?String(y):null,te=(0,F.useMemo)(()=>!o||!l?!1:JSON.stringify(o)!==JSON.stringify(l),[o,l]),w=(0,F.useCallback)(e=>{_.current=!0,c(t=>t?{...t,...e}:null)},[]),ne=(0,F.useCallback)(async()=>{if(!(!o||d)){f(!0),m(null),g(!1);try{try{Zt(o.paramsJson)}catch(e){m(e instanceof SyntaxError?t.advanced.paramsInvalidJson:e instanceof Error?e.message:t.advanced.paramsInvalidJson);return}await Qt(o),_.current=!1,g(!0),window.setTimeout(()=>g(!1),2500)}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}}},[o,d,t.saveError,t.advanced]),T=e.settingsSections[`agent-defaults`];return i?ee?(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,R.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,R.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:e.logs.loading})]}):o?(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:T}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.subtitle}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.sectionDesc})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[h?(0,R.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.saved}):null,(0,R.jsx)(N,{type:`button`,variant:`primary`,disabled:!te||d,onClick:()=>void ne(),children:d?t.saving:t.save})]})]}),p?(0,R.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:p}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:ue,title:t.cardModelsTitle,subtitle:t.cardModelsSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.model,description:t.desc.model,children:(0,R.jsx)(k,{value:o.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>w({model:e})})}),(0,R.jsx)($,{label:t.label.modelFallbacks,description:t.desc.modelFallbacks,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.modelFallbacks.map((e,r)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(k,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...o.modelFallbacks];t[r]=e,w({modelFallbacks:t})}})}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>w({modelFallbacks:o.modelFallbacks.filter((e,t)=>t!==r)}),children:(0,R.jsx)(M,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,R.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>w({modelFallbacks:[...o.modelFallbacks,``]}),children:[(0,R.jsx)(we,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})}),(0,R.jsx)($,{label:t.label.imageModel,description:t.desc.imageModel,children:(0,R.jsx)(k,{value:o.imageModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>w({imageModel:e})})}),(0,R.jsx)($,{label:t.label.imageModelFallbacks,description:t.desc.imageModelFallbacks,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.imageModelFallbacks.map((e,r)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(k,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...o.imageModelFallbacks];t[r]=e,w({imageModelFallbacks:t})}})}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>w({imageModelFallbacks:o.imageModelFallbacks.filter((e,t)=>t!==r)}),children:(0,R.jsx)(M,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,R.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>w({imageModelFallbacks:[...o.imageModelFallbacks,``]}),children:[(0,R.jsx)(we,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})}),(0,R.jsx)($,{label:t.label.imageGenerationModel,description:t.desc.imageGenerationModel,children:(0,R.jsx)(an,{value:o.imageGenerationModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>w({imageGenerationModel:e})})}),(0,R.jsx)($,{label:t.label.imageGenerationModelFallbacks,description:t.desc.imageGenerationModelFallbacks,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.imageGenerationModelFallbacks.map((e,r)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(an,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...o.imageGenerationModelFallbacks];t[r]=e,w({imageGenerationModelFallbacks:t})}})}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>w({imageGenerationModelFallbacks:o.imageGenerationModelFallbacks.filter((e,t)=>t!==r)}),children:(0,R.jsx)(M,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,R.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>w({imageGenerationModelFallbacks:[...o.imageGenerationModelFallbacks,``]}),children:[(0,R.jsx)(we,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:xe,title:t.cardWorkspaceTitle,subtitle:t.cardWorkspaceSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.workspace,description:t.desc.workspace,children:(0,R.jsx)(`input`,{type:`text`,className:X(),value:o.workspace,onChange:e=>w({workspace:e.target.value}),autoComplete:`off`})}),(0,R.jsx)($,{label:t.label.mediaMaxMb,description:t.desc.mediaMaxMb,children:(0,R.jsx)(`input`,{type:`number`,min:1,step:1,className:X(),value:o.mediaMaxMb??``,placeholder:`20`,onChange:e=>{let t=e.target.value;w({mediaMaxMb:t===``?void 0:Number(t)})}})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:le,title:t.cardBrowserTitle,subtitle:t.cardBrowserSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.browserEnabled,description:t.desc.browserEnabled,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:o.browserEnabled,onChange:e=>w({browserEnabled:e.target.checked})}),(0,R.jsx)(`span`,{children:t.browserEnabledOn})]})}),(0,R.jsx)($,{label:t.label.browserHeadless,description:t.desc.browserHeadless,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:o.browserHeadless,onChange:e=>w({browserHeadless:e.target.checked})}),(0,R.jsx)(`span`,{children:t.browserHeadlessOn})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:Se,title:t.cardGenerationTitle,subtitle:t.cardGenerationSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)($,{label:t.label.maxTokens,description:t.desc.maxTokens,children:(0,R.jsx)(`input`,{type:`number`,className:X(),value:o.maxTokens,min:1,onChange:e=>w({maxTokens:Number.parseInt(e.target.value,10)||0})})}),(0,R.jsx)($,{label:t.label.temperature,description:t.desc.temperature,children:(0,R.jsx)(`input`,{type:`number`,className:X(),value:o.temperature,min:0,max:2,step:.1,onChange:e=>w({temperature:Number.parseFloat(e.target.value)||0})})})]}),(0,R.jsx)($,{label:t.label.maxToolIterations,description:t.desc.maxToolIterations,children:(0,R.jsx)(`input`,{type:`number`,className:X(),value:o.maxToolIterations,min:1,onChange:e=>w({maxToolIterations:Number.parseInt(e.target.value,10)||0})})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:Ce,title:t.cardBehaviorTitle,subtitle:t.cardBehaviorSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.thinkingDefault,description:t.desc.thinkingDefault,children:(0,R.jsx)(`select`,{className:Z(),value:o.thinkingDefault,onChange:e=>w({thinkingDefault:e.target.value}),children:on.map(e=>(0,R.jsx)(`option`,{value:e,children:n.thinkingLevels[e]},e))})}),(0,R.jsx)($,{label:t.label.reasoningDefault,description:t.desc.reasoningDefault,children:(0,R.jsxs)(`select`,{className:Z(),value:o.reasoningDefault,onChange:e=>w({reasoningDefault:e.target.value}),children:[(0,R.jsx)(`option`,{value:`off`,children:t.reasoning.off}),(0,R.jsx)(`option`,{value:`on`,children:t.reasoning.on}),(0,R.jsx)(`option`,{value:`stream`,children:t.reasoning.stream})]})}),(0,R.jsx)($,{label:t.label.verboseDefault,description:t.desc.verboseDefault,children:(0,R.jsxs)(`select`,{className:Z(),value:o.verboseDefault,onChange:e=>w({verboseDefault:e.target.value}),children:[(0,R.jsx)(`option`,{value:`off`,children:t.verbose.off}),(0,R.jsx)(`option`,{value:`on`,children:t.verbose.on}),(0,R.jsx)(`option`,{value:`full`,children:t.verbose.full})]})})]})]}),(0,R.jsx)($t,{a:t,chat:n,form:o,update:w})]})]}):(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p??C??t.loadError}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>void x(),children:e.logs.refresh})]}):(0,R.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,R.jsx)(ue,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:T}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.needToken})]})]})})}export{Ft as AgentsSettingsPanel,Ot as i,V as n,H as r,sn as t};
|
|
2
|
-
//# sourceMappingURL=agents-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{i as t,t as n}from"./vendor-react-QAsRxa6t.js";import{l as r,n as i,o as a,r as o,s,t as c}from"./url-D7yWllI8.js";import{r as l}from"./vendor-swr-8rdcElid.js";import{d as u,l as d,t as f,u as p}from"./chunk-QFMPRPBF-DOYp8d2p.js";import{n as m,t as h}from"./cn-DPF56z7S.js";import{C as g,S as _,_ as v,a as y,b,c as x,d as S,f as ee,g as C,h as te,i as w,l as ne,m as T,n as re,o as ie,p as ae,r as oe,s as E,t as se,u as ce,v as le,x as D,y as ue}from"./settings-nav-state-BSa0kz44.js";import{n as de,r as fe,t as O}from"./sparkles-BG1XFBU0.js";import{t as pe}from"./check-CDc_K89l.js";import{c as me,d as he,n as ge,t as k,u as _e}from"./model-selector-BLiY_O25.js";import{i as ve,n as ye,r as be}from"./gateway-config-swr-Cph02QZn.js";import{t as A}from"./file-text-CVBsYEv2.js";import{t as xe}from"./folder-BZ5toHcH.js";import{n as Se,t as Ce}from"./zap-C4SJDlFg.js";import{t as we}from"./plus-CBODkzSX.js";import{t as j}from"./refresh-cw-D7hzzeQ5.js";import{t as Te}from"./search-DoMetBR0.js";import{t as M}from"./trash-2-D9v5oysq.js";import{a as Ee,i as De,n as Oe,o as ke,r as Ae,s as je,t as Me}from"./dist-Db1dcLr9.js";import{t as N}from"./button-CRQ9eQGX.js";import{a as Ne,i as Pe,n as Fe,o as Ie,r as Le,s as Re}from"./form-field-width-BlpNwrfn.js";import{i as ze}from"./theme-store-CywXkKml.js";import{t as Be}from"./page-header-store-BFpnFTed.js";import{a as P,i as Ve,o as He,r as Ue}from"./dist-CpMMntuC.js";import{t as We}from"./markdown-view-BpEqr7_J.js";import{n as Ge}from"./interaction-C4gx-xSs.js";import{C as Ke,a as qe,d as Je,p as Ye,v as Xe,y as Ze}from"./cron-utils-Dkj-Ldpf.js";var F=e(t(),1);function I(e){return{...e,skills:e.skills??{defaults:[]},tools:e.tools??{defaultsDisable:[],entryDisable:[],effectiveDisable:[]}}}async function Qe(){let e=(await o(c(`/api/agents`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(I),builtinToolIds:t}}async function $e(e){let t=await o(c(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(I),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function et(e,t){let n=(await o(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function tt(e,t){let n=(await o(c(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}function nt(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function rt(e){await o(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),ye()}async function it(){let e=(await o(c(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function at(e){let t=(await o(c(`/api/agents/${encodeURIComponent(e)}/files`))).payload;if(!t?.files||!t.bootstrapDir)throw Error(`Invalid files list response`);return t}async function ot(e,t){let n=(await o(c(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function st(e,t,n){await o(c(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}var L=`main`,ct=/^[a-z0-9][a-z0-9_-]{0,63}$/i,lt=/[^a-z0-9_-]+/g,ut=/^-+/,dt=/-+$/,ft=/^[a-z0-9][a-z0-9_-]{0,63}$/,pt=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 mt(e){let t=e.trim();if(!t)return L;let n=t.toLowerCase();return ct.test(t)?n:n.replace(lt,`-`).replace(ut,``).replace(dt,``).slice(0,64)||L}function ht(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return ft.test(e)?e===L?{ok:!1,error:`"${L}" is reserved`}:pt.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=mt(t.trim());return r===L?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:pt.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.`}:ft.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 gt(e){let t=e.trim();return t?`~/.xopc/workspace-${mt(t)}`:``}var R=n(),z=[{id:`overview`,labelKey:`navIdentity`,icon:E},{id:`tools`,labelKey:`navTools`,icon:y},{id:`skills`,labelKey:`navSkills`,icon:de},{id:`files`,labelKey:`navCoreFiles`,icon:A}],_t=[{id:`channels`,labelKey:`tabChannels`,icon:ee},{id:`cron`,labelKey:`tabCron`,icon:_e}];function vt(e){let{a:t,panel:n,onPanelChange:r}=e,i=(e,t,i)=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:h(`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,R.jsx)(i,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e);return(0,R.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":t.editorNavAria,children:[(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:z.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))}),(0,R.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.navAdvanced}),(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:_t.map(({id:e,labelKey:n,icon:r})=>i(e,t[n],r))})]})}function yt(e){let{open:t,onOpenChange:n,a:r,title:i,subtitle:a,panel:o,onPanelChange:s,onFooterSave:c,footerSaveDisabled:l,busy:u,children:d}=e;return(0,R.jsx)(ke,{open:t,onOpenChange:n,children:(0,R.jsxs)(Ee,{children:[(0,R.jsx)(De,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,R.jsxs)(Oe,{className:h(`xopc-dialog-content fixed z-[60] flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,`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,R.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,R.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,R.jsx)(je,{className:`text-base font-semibold leading-snug text-fg`,children:i}),(0,R.jsx)(Ae,{className:`mt-1 font-mono text-xs text-fg-muted`,children:a})]}),(0,R.jsx)(Me,{asChild:!0,children:(0,R.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,R.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[(0,R.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,R.jsx)(vt,{a:r,panel:o,onPanelChange:s})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:pl-2 sm:pr-5`,children:d}),(0,R.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:[l?(0,R.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,R.jsx)(N,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:u||l,onClick:()=>void c(),children:r.save})]})]})]})]})]})})}function bt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>{let t=(e.name??``).toLowerCase(),r=e.id.toLowerCase(),i=e.workspace.toLowerCase(),a=(e.description??``).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)||a.includes(n)}):e}function xt(e){let{a:t,busy:n,onNewAgent:r}=e;return(0,R.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>r(),className:h(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,R.jsx)(we,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),(0,R.jsx)(`span`,{children:t.listNewAgentCard})]})}function St(e){let{a:t,agents:n,searchQuery:r,onOpenAgent:i,onChatWithAgent:a,onNewAgent:o,busy:s}=e,c=bt(n,r),l=n.length>0&&c.length===0&&r.trim().length>0;return n.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listNoAgentsYet}),(0,R.jsx)(`div`,{className:`max-w-sm`,children:(0,R.jsx)(xt,{a:t,busy:s,onNewAgent:o})})]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.listEmpty}):null,(0,R.jsxs)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,children:[(0,R.jsx)(`li`,{className:`h-full min-h-0`,children:(0,R.jsx)(xt,{a:t,busy:s,onNewAgent:o})}),c.map(e=>{let n=e.name?.trim()?e.name.trim():e.id,r=e.id,o=e.description?.trim()??``;return(0,R.jsx)(`li`,{className:`h-full min-h-0`,children:(0,R.jsxs)(`div`,{className:h(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,R.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>i(e.id),className:h(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(`span`,{className:`flex size-11 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,R.jsx)(_,{className:`size-6`,strokeWidth:1.75})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:n}),e.isDefault?(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:t.defaultBadge}):null]}),(0,R.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,R.jsx)(`p`,{className:h(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,o?`text-fg`:`text-fg-muted/25`),title:o||void 0,children:o||`\xA0`})]}),(0,R.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>a(e.id),className:h(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,R.jsx)(ae,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),t.listChatWithAgent]})]})},e.id)})]})]})}function Ct(e){let{a:t}=e;return(0,R.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:t.title}),(0,R.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.subtitle})]})})}function B(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Re,`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}}function Dt(e){let{open:t,onOpenChange:n,a:r,chat:i,busy:a,modalError:o,createDisplayName:s,setCreateDisplayName:c,createAgentId:l,setCreateAgentId:u,createDescription:d,setCreateDescription:f,createWorkspace:p,setCreateWorkspace:g,createModel:_,setCreateModel:v,onCreate:y,onSuggestWorkspace:b}=e;return(0,R.jsx)(ke,{open:t,onOpenChange:n,children:(0,R.jsxs)(Ee,{children:[(0,R.jsx)(De,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,R.jsxs)(Oe,{className:h(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,R.jsx)(je,{className:`text-base font-semibold text-fg`,children:r.addAgent}),(0,R.jsx)(Ae,{className:`mt-0.5 text-xs text-fg-muted`,children:r.addAgentHint})]}),(0,R.jsx)(Me,{asChild:!0,children:(0,R.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,R.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,R.jsxs)(`form`,{className:`grid gap-3`,onSubmit:y,children:[o?(0,R.jsx)(`div`,{role:`alert`,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:o}):null,(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentLabel}),(0,R.jsx)(`input`,{className:B(),value:s,onChange:e=>c(e.target.value),onBlur:()=>b(),required:!0,autoComplete:`off`})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newAgentIdOptional}),(0,R.jsx)(`input`,{className:h(B(),`font-mono text-xs`),value:l,onChange:e=>u(e.target.value),onBlur:()=>b(),placeholder:r.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:r.newAgentIdRules}),(0,R.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.newAgentIdRules})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.agentDescription}),(0,R.jsx)(`textarea`,{className:h(B(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),value:d,onChange:e=>f(e.target.value),placeholder:r.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newWorkspace}),(0,R.jsx)(`input`,{className:h(B(),`font-mono text-xs`),value:p,onChange:e=>g(e.target.value),required:!0,autoComplete:`off`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:r.newModelOptional}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,R.jsx)(k,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:_,disabled:a,placeholder:i.modelPlaceholder,searchPlaceholder:i.modelSearchPlaceholder,noMatches:i.modelNoMatches,onChange:e=>v(e)}),_.trim()?(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:a,onClick:()=>v(``),children:r.modelClear}):null]})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,R.jsx)(Me,{asChild:!0,children:(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:a,children:r.createModalCancel})}),(0,R.jsxs)(N,{type:`submit`,disabled:a,children:[(0,R.jsx)(x,{className:`mr-1 size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})})}function Ot(){return`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`}function V({children:e,className:t}){return(0,R.jsx)(`section`,{className:h(Ot(),t),children:e})}function H({icon:e,title:t,subtitle:n,className:r}){return(0,R.jsxs)(`div`,{className:h(`mb-5 flex items-start gap-3`,r),children:[(0,R.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted dark:bg-surface-hover/70`,"aria-hidden":!0,children:(0,R.jsx)(e,{className:`size-4`,strokeWidth:1.75})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n})]})]})}var U=h(Ie,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function kt(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:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:x}=e,S=!c&&(l||s.length>0);return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:te,title:t.channelsTitle,subtitle:t.channelsHint}),r?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoading}):i.length===0?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsNone}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:i.map((e,r)=>(0,R.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,R.jsx)(`span`,{className:`font-mono text-xs`,children:Tt(e.match)}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void a(e),children:t.removeBinding})]},`${e.match.channel}-${r}`))}),(0,R.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:o,children:[c?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.channelsLoadingChannels}):l?(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,R.jsx)(`input`,{className:B(),value:u,onChange:e=>d(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsManualChannelHint})]}):(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelLabel}),(0,R.jsx)(`select`,{className:h(B(),`py-2`),value:u,onChange:e=>{d(e.target.value),g(null),v(``)},children:s.map(e=>(0,R.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:t.channelsDisabledSuffix]},e.name))})]}),S&&u.trim()?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsSessionLabel}),(0,R.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:n||p||!u.trim(),title:t.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,R.jsx)(j,{className:h(`size-3.5`,p&&`animate-spin`),strokeWidth:1.75}),t.channelsRefreshSessions]})]}),p&&f.length===0?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsLoadingSessions}):null,(0,R.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.channelsPeerFromSessions}),(0,R.jsxs)(`select`,{className:h(B(),`py-2`),value:m==null?``:String(m),disabled:n||!u.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,R.jsx)(`option`,{value:``,children:t.channelsPeerAny}),f.map((e,t)=>(0,R.jsx)(`option`,{value:String(t),children:qe(e,b)},`${e.channel}-${e.chatId}-${t}`))]})]}),f.length===0&&u.trim()&&!p?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsNoSessionsHint}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.peerIdLabel}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,className:h(B(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:t.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,R.jsxs)(`select`,{className:U,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,R.jsx)(`option`,{value:``,children:x}),f.map(e=>(0,R.jsx)(`option`,{value:e.chatId,children:qe(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.channelsCustomPeerHint})]})]}):null,(0,R.jsx)(`div`,{children:(0,R.jsx)(N,{type:`submit`,disabled:n||!u.trim()||c,children:t.addBinding})})]})]})}function At(e){let{a:t,data:n,busy:r,cronLoading:i,agentCronJobs:a,onSetCronJobAgent:o}=e;return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:g,title:t.cronTitle,subtitle:t.cronHint}),i?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronLoading}):a.length===0?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.cronNone}):(0,R.jsx)(`div`,{className:`overflow-x-auto`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSchedule}),(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColMessage}),(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColSession}),(0,R.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:t.cronColAgent})]})}),(0,R.jsx)(`tbody`,{children:a.map(e=>{let i=!e.agentId?.trim(),a=i?``:e.agentId.trim().toLowerCase();return(0,R.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,R.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs`,children:e.schedule}),(0,R.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:Je(e),children:Je(e)}),(0,R.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,R.jsx)(`td`,{className:`py-2 pr-3`,children:(0,R.jsxs)(`select`,{className:h(B(),`min-w-[8rem] py-1 text-xs`),value:a,disabled:r||e.sessionTarget!==`isolated`,onChange:t=>void o(e,t.target.value),children:[(0,R.jsx)(`option`,{value:``,children:i?t.cronAgentDefault:t.cronAgentClear}),n.agents.map(e=>(0,R.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,bootstrapViewMode:o,setBootstrapViewMode:s,fileDraft:c,setFileDraft:l,fileSaving:u,bootstrapFileLoading:d,bootstrapEditorNonce:f}=e,p=ze(e=>e.resolved===`dark`);return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesHint}),n?(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesLoading}):r?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,R.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.tabFiles,children:r.files.map(e=>(0,R.jsxs)(`button`,{type:`button`,className:h(`-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,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":t.filesBootstrapEdit,children:[(0,R.jsxs)(`button`,{type:`button`,className:h(`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,R.jsx)(me,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapEdit]}),(0,R.jsxs)(`button`,{type:`button`,className:h(`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,R.jsx)(ve,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t.filesBootstrapPreview]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[u?(0,R.jsx)(`span`,{children:t.filesSavingStatus}):null,(0,R.jsx)(`span`,{children:t.filesAutoSaveHint})]})]}),o===`edit`?(0,R.jsx)(`div`,{className:h(B(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,d&&`pointer-events-none opacity-60`),children:(0,R.jsx)(ge,{initialContent:c,onChange:l,isDark:p,className:`min-h-0 flex-1`},`${i??`file`}-${f}`)}):(0,R.jsx)(`div`,{className:h(B(),`min-h-0 flex-1 overflow-y-auto text-sm`,d&&`pointer-events-none opacity-60`),children:(0,R.jsx)(We,{content:c,className:`text-sm`})})]}):(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.pickFile})})]}):(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.filesEmpty})]})}function Mt(e){let{a:t,chat:n,selected:r,busy:i,editName:a,setEditName:o,editDescription:s,setEditDescription:c,editWorkspace:l,setEditWorkspace:u,editModel:d,setEditModel:f,onSetDefault:p,onSaveAgentEdits:m,onDelete:g,hideInlineSave:_}=e;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:ie,title:t.selectAgent,subtitle:t.selectAgentHint}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:!r||r.isDefault||i,onClick:()=>void p(),children:t.setDefault})})]}),r?(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:T,title:t.editAgent,subtitle:t.editAgentHint}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.displayName}),(0,R.jsx)(`input`,{className:B(),value:a,onChange:e=>o(e.target.value)})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm sm:col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.agentDescription}),(0,R.jsx)(`textarea`,{className:h(B(),`min-h-[5.5rem] resize-y font-sans text-sm leading-relaxed`),value:s,onChange:e=>c(e.target.value),placeholder:t.agentDescriptionPlaceholder,maxLength:4e3,rows:4,spellCheck:!0})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm sm:col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.workspacePath}),(0,R.jsx)(`input`,{className:h(B(),`font-mono text-xs`),value:l,onChange:e=>u(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm sm:col-span-2`,children:[(0,R.jsx)(`span`,{className:`text-fg-muted`,children:t.modelPrimary}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,R.jsx)(k,{className:`min-w-0 flex-1`,popoverContentClassName:`z-[70]`,value:d,disabled:i,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>f(e)}),d.trim()?(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:i,onClick:()=>f(``),children:t.modelClear}):null]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[_?null:(0,R.jsx)(N,{type:`button`,disabled:i,onClick:()=>void m(),children:t.save}),r.id===`main`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(N,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void g(!1),children:[(0,R.jsx)(M,{className:`mr-1 size-4`,"aria-hidden":!0}),t.removeFromConfig]}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`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`,disabled:i,onClick:()=>void g(!0),children:t.purgeDisk})]})]})]}):null]})}function Nt(e){let{a:t,selected:n,busy:r,skillsCatalogLoading:i,catalogForPick:a,skillsInherit:o,setSkillsInherit:s,skillsPick:c,setSkillsPick:l,onSaveSkills:u,hideInlineSave:d}=e;function p(e){let t=n.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)}function m(){let e=n.skills.effectiveAllowlist;return e===void 0?new Set(a.map(e=>e.name||e.directoryId)):new Set(e)}return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:fe,title:t.skillsTitle,subtitle:t.skillsHint}),(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>s(!0),children:t.skillsInherit}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>{s(!1),l(m())},children:t.skillsCustomize})]}),(0,R.jsx)(f,{to:`/skills`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:t.skillsLibraryLink})]}),(0,R.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[t.skillsDefaultsLabel,` `,n.skills.defaults.length?n.skills.defaults.join(`, `):`—`]}),(0,R.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[t.skillsEffectiveLabel,` `,n.skills.effectiveAllowlist?.length?n.skills.effectiveAllowlist.join(`, `):t.skillsAllFromCatalog]}),i?(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsCatalogLoading}):a.length===0?(0,R.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:t.skillsEmptyCatalog}):(0,R.jsx)(`div`,{className:h(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,o&&`opacity-50`),children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,role:`list`,children:a.map(e=>{let n=e.name||e.directoryId,i=o?p(n):c.has(n),a=typeof e.description==`string`?e.description.trim():``,s=a||t.skillsNoDescription;return(0,R.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,R.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:i,disabled:o||r,onChange:()=>{l(e=>{let t=new Set(e);return i?t.delete(n):t.add(n),t})}}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:n,children:n}),(0,R.jsx)(`p`,{className:h(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:s,children:s})]})]})},n)})})}),d?null:(0,R.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,R.jsx)(N,{type:`button`,disabled:r,onClick:()=>void u(),children:t.skillsSave})})]})}function Pt(e){let{a:t,data:n,selected:r,busy:i,toolEntryDisable:a,setToolEntryDisable:o,onSaveTools:s,onClearToolsEntry:c,hideInlineSave:l}=e;return(0,R.jsxs)(V,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(H,{className:`shrink-0`,icon:y,title:t.toolsTitle,subtitle:t.toolsHint}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5 pr-1`,role:`list`,children:(n.builtinToolIds.length?n.builtinToolIds:[]).map(e=>{let n=r.tools.defaultsDisable.includes(e),s=n?!1:!a.has(e),c=e in t.toolDescriptions?t.toolDescriptions[e]:``;return(0,R.jsx)(`li`,{className:h(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,n&&`opacity-60`),children:(0,R.jsxs)(`label`,{className:h(`flex cursor-pointer gap-3 text-sm`,n&&`cursor-not-allowed`),children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:s,disabled:n||i,onChange:()=>{n||o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:e}),n?(0,R.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,t.toolsLockedByDefaults,`)`]}):null]}),c?(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c}):null]})]})},e)})})}),(0,R.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[l?null:(0,R.jsx)(N,{type:`button`,disabled:i,onClick:()=>void s(),children:t.toolsSave}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void c(),children:t.toolsClearEntry})]})]})}function Ft(){let e=r(s(e=>e.language)),t=e.agentsSettings,n=e.cron,i=e.chat,o=!!a(e=>e.token),[c]=u(),m=d(),{agentId:h}=p(),g=Be(e=>e.setPageHeader),_=Be(e=>e.clearPageHeader),{data:v,error:y,isLoading:b,mutate:x}=l(o?`settings-gateway-agents`:null,Qe,{revalidateOnFocus:!1}),{data:S}=be(o),ee=(0,F.useMemo)(()=>nt(S?.payload?.config??{}),[S]),C=v??null,te=!!(o&&b),[ne,T]=(0,F.useState)(null),ie=y instanceof Error?y.message:y?t.loadError:null,ae=ne??ie,[E,le]=(0,F.useState)(null),[D,ue]=(0,F.useState)(`overview`),[de,fe]=(0,F.useState)(``),[O,pe]=(0,F.useState)(``),[me,he]=(0,F.useState)(``),[ge,k]=(0,F.useState)(``),[_e,ve]=(0,F.useState)(``),[ye,A]=(0,F.useState)(null),[xe,Se]=(0,F.useState)(!1),Ce=(0,F.useRef)(``),[j,M]=(0,F.useState)(!1),[Ee,De]=(0,F.useState)(``),[Oe,ke]=(0,F.useState)(``),[Ae,je]=(0,F.useState)(``),[Me,Ne]=(0,F.useState)(``),[Pe,Fe]=(0,F.useState)(``),[Ie,Le]=(0,F.useState)(null),[Re,ze]=(0,F.useState)(!1),[P,Ve]=(0,F.useState)(null),[He,Ue]=(0,F.useState)(``),[We,Ge]=(0,F.useState)(!1),[qe,Je]=(0,F.useState)(`edit`),[I,L]=(0,F.useState)(!1),[ct,lt]=(0,F.useState)(0),ut=(0,F.useRef)(He);ut.current=He;let dt=(0,F.useRef)(E);dt.current=E;let ft=(0,F.useRef)(P);ft.current=P;let pt=(0,F.useRef)(``),mt=(0,F.useRef)(``),z=w(async()=>{let e=dt.current,n=ft.current;if(!e||!n||`${e}:${n}`!==pt.current)return;let r=ut.current;if(r!==mt.current){Ge(!0),T(null);try{await st(e,n,r),mt.current=r,Le(t=>!t||t.agentId!==e?t:{...t,files:t.files.map(e=>e.name===n?{...e,missing:!1}:e)})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{Ge(!1)}}},800),_t=(0,F.useRef)(z.flush);_t.current=z.flush,(0,F.useEffect)(()=>()=>{_t.current()},[]);let[vt,bt]=(0,F.useState)(()=>new Set),[xt,B]=(0,F.useState)(()=>new Set),[Tt,Ot]=(0,F.useState)(!0),[V,H]=(0,F.useState)([]),[U,Ft]=(0,F.useState)(``),[W,G]=(0,F.useState)([]),[K,It]=(0,F.useState)(!1),[q,Lt]=(0,F.useState)([]),[Rt,J]=(0,F.useState)(!1),[zt,Bt]=(0,F.useState)(null),[Vt,Ht]=(0,F.useState)(``),[Ut,Wt]=(0,F.useState)([]),[Gt,Kt]=(0,F.useState)(!1),[qt,Jt]=(0,F.useState)([]),[Yt,Xt]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(C){if(h&&C.agents.some(e=>e.id===h)){le(h);return}le(e=>e&&C.agents.some(t=>t.id===e)?e:C.defaultId)}},[C,h]),(0,F.useEffect)(()=>{!C||!h||C.agents.some(e=>e.id===h)||m(re,{replace:!0})},[C,h,m]),(0,F.useEffect)(()=>{h&&ue(`overview`)},[h]),(0,F.useEffect)(()=>{c.get(`panel`)===`defaults`&&m(`/settings/agent-defaults`,{replace:!0,state:{[se]:re}})},[c,m]);let Y=(0,F.useMemo)(()=>C?.agents.find(e=>e.id===E)??null,[C,E]),Zt=(0,F.useMemo)(()=>Y?V.filter(e=>e.agentId.toLowerCase()===Y.id.toLowerCase()):[],[V,Y?.id]),Qt=(0,F.useMemo)(()=>!C||!Y?[]:Ut.filter(e=>wt(e,Y.id,C.defaultId)),[Ut,C,Y?.id]),X=(0,F.useMemo)(()=>qt.filter(e=>e.enabled!==!1),[qt]);(0,F.useEffect)(()=>{if(!Y){ke(``),je(``),Ne(``),Fe(``);return}ke(Y.workspace),je(Y.model?.primary??``),Ne(Y.name?.trim()?Y.name.trim():Y.id),Fe(Y.description?.trim()??``)},[Y]),(0,F.useEffect)(()=>{if(D!==`files`||!E||!o)return;let e=!1;return ze(!0),at(E).then(t=>{e||Le(t)}).catch(()=>{e||Le(null)}).finally(()=>{e||ze(!1)}),()=>{e=!0}},[D,E,o,C?.agents.length]),(0,F.useEffect)(()=>{!Y||D!==`tools`||bt(new Set(Y.tools.entryDisable))},[D,Y]),(0,F.useEffect)(()=>{if(!Y||D!==`skills`)return;let e=Y.skills.entry===void 0;if(Ot(e),e){let e=Y.skills.effectiveAllowlist;B(new Set(e??[]))}else B(new Set(Y.skills.entry??[]))},[D,Y]),(0,F.useEffect)(()=>{D!==`channels`||!o||H(ee)},[D,o,ee]),(0,F.useEffect)(()=>{if(D!==`channels`||!o)return;let e=!1;return It(!0),Ye().then(t=>{e||G(t)}).catch(()=>{e||G([])}).finally(()=>{e||It(!1)}),()=>{e=!0}},[D,o]),(0,F.useEffect)(()=>{K||D!==`channels`||W.length===0||Ft(e=>e&&W.some(t=>t.name===e)?e:W[0].name)},[K,D,W]),(0,F.useEffect)(()=>{if(D!==`channels`||!o)return;let e=U.trim();if(!e){Lt([]);return}let t=!1;return Bt(null),J(!0),Xe(e).then(e=>{t||Lt(e)}).catch(()=>{t||Lt([])}).finally(()=>{t||J(!1)}),()=>{t=!0}},[D,o,U]);let Z=(0,F.useCallback)(()=>{let e=U.trim();e&&(J(!0),Xe(e).then(e=>{Lt(e),Bt(t=>t!=null&&t<e.length?t:null)}).catch(()=>{Lt([]),Bt(null)}).finally(()=>{J(!1)}))},[U]),Q=!K&&W.length===0,$t=D===`channels`&&o&&S===void 0;(0,F.useEffect)(()=>{if(D!==`cron`||!o)return;let e=!1;return Kt(!0),Ze().then(t=>{e||Wt(t)}).catch(()=>{e||Wt([])}).finally(()=>{e||Kt(!1)}),()=>{e=!0}},[D,o]),(0,F.useEffect)(()=>{if(D!==`skills`||!o)return;let e=!1;return Xt(!0),it().then(t=>{e||Jt(t)}).catch(()=>{e||Jt([])}).finally(()=>{e||Xt(!1)}),()=>{e=!0}},[D,o]),(0,F.useEffect)(()=>{if(!P||!E||!o)return;let e=!1;return z.flush(),L(!0),ot(E,P).then(t=>{e||(pt.current=`${E}:${P}`,mt.current=t,Ue(t),lt(e=>e+1))}).catch(()=>{e||(pt.current=`${E}:${P}`,mt.current=``,Ue(``),lt(e=>e+1))}).finally(()=>{e||L(!1)}),()=>{e=!0}},[P,E,o,z]),(0,F.useEffect)(()=>{!P||!E||I||z()},[He,P,E,I,z]),(0,F.useEffect)(()=>{if(D===`files`)return()=>{z.flush()}},[D,z]),(0,F.useEffect)(()=>{Je(`edit`)},[P,E]);let en=(0,F.useCallback)(()=>{let e=gt(O.trim()||de);k(t=>t===``||t===Ce.current?(Ce.current=e,e):t)},[O,de]),tn=(0,F.useCallback)(()=>{Ce.current=``,fe(``),pe(``),he(``),k(``),ve(``),A(null),Se(!0)},[]),nn=e.settingsSections[`agent-defaults`],rn=(0,F.useMemo)(()=>(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[(0,R.jsx)(N,{asChild:!0,variant:`secondary`,className:`shrink-0 gap-2`,children:(0,R.jsxs)(f,{to:`/settings/agent-defaults`,title:nn,state:{[se]:re},children:[(0,R.jsx)(ce,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),nn]})}),(0,R.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,R.jsx)(Te,{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,R.jsx)(`input`,{type:`search`,role:`searchbox`,enterKeyHint:`search`,value:Ee,onChange:e=>De(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,R.jsxs)(N,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":t.addAgentAria,disabled:j,onClick:()=>tn(),children:[(0,R.jsx)(we,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t.addAgent]})]}),[t.addAgent,t.addAgentAria,t.listSearchPlaceholder,j,nn,Ee,tn]);(0,F.useLayoutEffect)(()=>o?(g({startExtra:null,main:null,end:rn}),()=>_()):(_(),()=>_()),[rn,_,o,g]);async function an(e){e.preventDefault();let n=de.trim();if(!n)return;let r=ht(O,n);if(r.ok===!1){A(r.error);return}let i=ge.trim()||gt(O.trim()||n);if(i){M(!0),A(null);try{let e=me.trim(),{createdAgentId:t,...r}=await $e({name:n,workspace:i,...O.trim()?{id:O.trim()}:{},..._e.trim()?{model:_e.trim()}:{},...e?{description:e}:{}});x(r,{revalidate:!1}),fe(``),pe(``),he(``),k(``),ve(``),A(null),Se(!1),le(t),m(oe(t))}catch(e){A(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function on(){if(Y){M(!0),T(null);try{let e=Pe.trim();x(await et(Y.id,{name:Me.trim()||void 0,description:e.length>0?e:null,workspace:Oe.trim()||void 0,model:Ae.trim()||null}),{revalidate:!1})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function $(e){M(!0),T(null);try{x(await et(e.id,{setDefault:!0}),{revalidate:!1}),le(e.id)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}async function sn(e,n){if(e.id!==`main`&&window.confirm(n?t.confirmDeletePurge:t.confirmDelete)){M(!0),T(null);try{let t=await tt(e.id,n);x(t,{revalidate:!1}),le(t.defaultId),ue(`overview`),h===e.id&&m(re,{replace:!0})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function cn(){if(Y){M(!0),T(null);try{let e=[...vt].sort((e,t)=>e.localeCompare(t));x(await et(Y.id,{toolsDisable:e}),{revalidate:!1})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function ln(){if(Y){M(!0),T(null);try{x(await et(Y.id,{toolsDisable:null}),{revalidate:!1}),bt(new Set)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function un(){if(Y){M(!0),T(null);try{x(await et(Y.id,{skills:Tt?null:[...xt].sort((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}}async function dn(e){M(!0),T(null);try{let t=V.filter(t=>t!==e);await rt(t),H(t)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}async function fn(e){if(e.preventDefault(),!Y||!U.trim())return;let n=Et(U,Vt,zt,q),r=[...V,{agentId:Y.id,priority:100,enabled:!0,match:n}];M(!0),T(null);try{await rt(r),H(r),Bt(null),Ht(``)}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}async function pn(e,n){M(!0),T(null);try{await Ke(e.id,{agentId:n===``?null:n}),Wt(await Ze())}catch(e){T(e instanceof Error?e.message:t.saveError)}finally{M(!1)}}let mn=D===`channels`||D===`cron`;function hn(){switch(D){case`overview`:on();break;case`tools`:cn();break;case`skills`:un();break;case`files`:z.flush();break;default:break}}function gn(e){e||m(re)}let _n=Y?Me.trim()||Y.name?.trim()||Y.id:h??``,vn=Y?.id??h??``;if(!o)return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.title}),(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]});let yn=Y?D===`overview`?(0,R.jsx)(Mt,{a:t,chat:i,selected:Y,busy:j,editName:Me,setEditName:Ne,editDescription:Pe,setEditDescription:Fe,editWorkspace:Oe,setEditWorkspace:ke,editModel:Ae,setEditModel:je,onSetDefault:()=>void $(Y),onSaveAgentEdits:()=>void on(),onDelete:e=>void sn(Y,e),hideInlineSave:!0}):D===`files`?(0,R.jsx)(jt,{a:t,filesLoading:Re,files:Ie,activeFile:P,setActiveFile:Ve,bootstrapViewMode:qe,setBootstrapViewMode:Je,fileDraft:He,setFileDraft:Ue,fileSaving:We,bootstrapFileLoading:I,bootstrapEditorNonce:ct}):D===`tools`?(0,R.jsx)(Pt,{a:t,data:C,selected:Y,busy:j,toolEntryDisable:vt,setToolEntryDisable:bt,onSaveTools:()=>void cn(),onClearToolsEntry:()=>void ln(),hideInlineSave:!0}):D===`skills`?(0,R.jsx)(Nt,{a:t,selected:Y,busy:j,skillsCatalogLoading:Yt,catalogForPick:X,skillsInherit:Tt,setSkillsInherit:Ot,skillsPick:xt,setSkillsPick:B,onSaveSkills:()=>void un(),hideInlineSave:!0}):D===`channels`?(0,R.jsx)(kt,{a:t,busy:j,bindingsLoading:$t,agentBindings:Zt,channelStatuses:W,channelsStatusLoading:K,useManualChannel:Q,newBindChannel:U,setNewBindChannel:Ft,bindSessionChats:q,sessionsLoading:Rt,newBindSessionIdx:zt,setNewBindSessionIdx:Bt,newBindCustomPeer:Vt,setNewBindCustomPeer:Ht,onRefreshSessions:Z,lastActiveLabels:n.lastActiveLabels,selectRecipient:n.selectRecipient,onRemoveBinding:e=>void dn(e),onAddBinding:fn}):D===`cron`&&C?(0,R.jsx)(At,{a:t,data:C,selected:Y,busy:j,cronLoading:Gt,agentCronJobs:Qt,onSetCronJobAgent:(e,t)=>void pn(e,t)}):(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint}):(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.selectAgentHint});return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,R.jsx)(Ct,{a:t}),ae?(0,R.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:ae}):null,te?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):C?(0,R.jsx)(St,{a:t,agents:C.agents,searchQuery:Ee,onOpenAgent:e=>m(oe(e)),onChatWithAgent:e=>m(`/chat/new`,{state:{agentId:e.trim().toLowerCase()}}),onNewAgent:tn,busy:j}):null,h&&o?(0,R.jsx)(yt,{open:!!h,onOpenChange:gn,a:t,title:_n,subtitle:vn,panel:D,onPanelChange:ue,onFooterSave:hn,footerSaveDisabled:mn,busy:j,children:te||!C?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):yn}):null,(0,R.jsx)(Dt,{open:xe,onOpenChange:e=>{Se(e),e||(Ce.current=``,fe(``),pe(``),he(``),k(``),ve(``),A(null))},a:t,chat:i,busy:j,modalError:ye,createDisplayName:de,setCreateDisplayName:fe,createAgentId:O,setCreateAgentId:pe,createDescription:me,setCreateDescription:he,createWorkspace:ge,setCreateWorkspace:k,createModel:_e,setCreateModel:ve,onCreate:an,onSuggestWorkspace:()=>en()})]})}var W={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},G={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},K={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},It={summaryModel:``},q={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},Lt={model:``,maxLength:void 0};function Rt(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 J(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 zt(e){return e===!0||e===`true`||e===1}function Bt(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!0};let n=t,r=zt(n.enabled),i=n.headless;return{browserEnabled:r,browserHeadless:!(i===!1||i===`false`||i===0)}}function Vt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...W};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:W.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):W.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:W.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):W.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):W.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:W.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):W.retentionWindow}}function Ht(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...G};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:G.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):G.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:G.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:G.tailKeepRatio}}function Ut(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...K};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:K.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:K.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:K.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 Wt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...It};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Gt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...q};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:q.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):q.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):q.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):q.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):q.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):q.maxDurationMs}}function Kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Lt};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function qt(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 Jt(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yt(e){if(e==null)return``;if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Xt(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:J(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:J(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:J(r.imageGenerationModel),{browserEnabled:u,browserHeadless:d}=Bt(r),f=typeof r.maxTaskDurationMs==`number`&&Number.isFinite(r.maxTaskDurationMs)?r.maxTaskDurationMs:void 0,p=f===void 0?void 0:Math.round(f/6e4);return{model:Rt(r.model),modelFallbacks:a,imageModel:Rt(r.imageModel),imageModelFallbacks:s,imageGenerationModel:Rt(r.imageGenerationModel),imageGenerationModelFallbacks:l,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:p,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`,browserEnabled:u,browserHeadless:d,thinkingDefault:typeof r.thinkingDefault==`string`?r.thinkingDefault:`medium`,reasoningDefault:typeof r.reasoningDefault==`string`?r.reasoningDefault:`off`,verboseDefault:typeof r.verboseDefault==`string`?r.verboseDefault:`off`,compaction:Vt(r.compaction),pruning:Ht(r.pruning),memory:Ut(r.memory),sessionSearch:Wt(r.sessionSearch),backgroundReview:Gt(r.backgroundReview),webExtract:Kt(r.webExtract),delegate:qt(r.delegate,!1),executeCode:qt(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:Jt(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return Jt(t)})(),paramsJson:Yt(r.params)}}function Y(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 Zt(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 Qt(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),s=a.length>0&&e.imageGenerationModel.trim()?{primary:e.imageGenerationModel.trim(),fallbacks:a}:e.imageGenerationModel||``,l=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),u=e.skillsAllowlist.map(e=>e.trim()).filter(Boolean),d=e.toolsDisable.map(e=>e.trim()).filter(Boolean),f=Zt(e.paramsJson),p=f===null||Object.keys(f).length===0?null:f,m={model:n,imageModel:i,imageGenerationModel:s,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:l,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:{enabled:e.browserEnabled,headless:e.browserHeadless},thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:Y(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:u.length>0?u:null,tools:{disable:d.length>0?d:null},params:p};await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:m}})}),ye()}function X(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Re,`dark:border-edge`)}function Z(){return h(Ie,Pe)}function Q({label:e,description:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function $t(e){let{a:t,chat:n,form:r,update:i}=e,a=t.advanced;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:ne,title:a.cardLimitsTitle,subtitle:a.cardLimitsSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.maxTaskDurationMs,description:a.maxTaskDurationMsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,max:240,step:1,value:r.maxTaskDurationMinutes??``,placeholder:a.maxTaskDurationPlaceholder,onChange:e=>{let t=e.target.value;if(t===``){i({maxTaskDurationMinutes:void 0});return}let n=Number.parseInt(t,10);Number.isNaN(n)||i({maxTaskDurationMinutes:Math.min(240,Math.max(1,n))})}})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.maxRequestsPerTurn,description:a.maxRequestsPerTurnDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:10,max:200,value:r.maxRequestsPerTurn,onChange:e=>i({maxRequestsPerTurn:Number.parseInt(e.target.value,10)||50})})}),(0,R.jsx)(Q,{label:a.maxToolFailuresPerTurn,description:a.maxToolFailuresPerTurnDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,max:20,value:r.maxToolFailuresPerTurn,onChange:e=>i({maxToolFailuresPerTurn:Number.parseInt(e.target.value,10)||3})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:v,title:a.cardCompactionTitle,subtitle:a.cardCompactionSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.compactionEnabled,description:a.compactionEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.compaction.enabled,onChange:e=>i({compaction:{...r.compaction,enabled:e.target.checked}})}),(0,R.jsx)(`span`,{children:a.compactionEnabledOn})]})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.compactionMode,description:a.compactionModeDesc,children:(0,R.jsxs)(`select`,{className:Z(),value:r.compaction.mode,onChange:e=>i({compaction:{...r.compaction,mode:e.target.value}}),children:[(0,R.jsx)(`option`,{value:`default`,children:a.compactionModeDefault}),(0,R.jsx)(`option`,{value:`safeguard`,children:a.compactionModeSafeguard})]})}),(0,R.jsx)(Q,{label:a.reserveTokens,description:a.reserveTokensDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1e3,value:r.compaction.reserveTokens,onChange:e=>i({compaction:{...r.compaction,reserveTokens:Number.parseInt(e.target.value,10)||0}})})}),(0,R.jsx)(Q,{label:a.triggerThreshold,description:a.triggerThresholdDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:.5,max:.95,step:.05,value:r.compaction.triggerThreshold,onChange:e=>i({compaction:{...r.compaction,triggerThreshold:Number.parseFloat(e.target.value)||.8}})})}),(0,R.jsx)(Q,{label:a.minMessagesBeforeCompact,description:a.minMessagesBeforeCompactDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,value:r.compaction.minMessagesBeforeCompact,onChange:e=>i({compaction:{...r.compaction,minMessagesBeforeCompact:Number.parseInt(e.target.value,10)||10}})})}),(0,R.jsx)(Q,{label:a.keepRecentMessages,description:a.keepRecentMessagesDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.compaction.keepRecentMessages,onChange:e=>i({compaction:{...r.compaction,keepRecentMessages:Number.parseInt(e.target.value,10)||5}})})}),(0,R.jsx)(Q,{label:a.evictionWindow,description:a.evictionWindowDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:.1,max:.5,step:.05,value:r.compaction.evictionWindow,onChange:e=>i({compaction:{...r.compaction,evictionWindow:Number.parseFloat(e.target.value)||.2}})})}),(0,R.jsx)(Q,{label:a.retentionWindow,description:a.retentionWindowDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:3,max:20,value:r.compaction.retentionWindow,onChange:e=>i({compaction:{...r.compaction,retentionWindow:Number.parseInt(e.target.value,10)||6}})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:S,title:a.cardPruningTitle,subtitle:a.cardPruningSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.pruningEnabled,description:a.pruningEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.pruning.enabled,onChange:e=>i({pruning:{...r.pruning,enabled:e.target.checked}})}),(0,R.jsx)(`span`,{children:a.pruningEnabledOn})]})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.maxToolResultChars,description:a.maxToolResultCharsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1e3,value:r.pruning.maxToolResultChars,onChange:e=>i({pruning:{...r.pruning,maxToolResultChars:Number.parseInt(e.target.value,10)||1e4}})})}),(0,R.jsx)(Q,{label:a.headKeepRatio,description:a.headKeepRatioDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,max:1,step:.05,value:r.pruning.headKeepRatio,onChange:e=>i({pruning:{...r.pruning,headKeepRatio:Number.parseFloat(e.target.value)||.3}})})}),(0,R.jsx)(Q,{label:a.tailKeepRatio,description:a.tailKeepRatioDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,max:1,step:.05,value:r.pruning.tailKeepRatio,onChange:e=>i({pruning:{...r.pruning,tailKeepRatio:Number.parseFloat(e.target.value)||.3}})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:D,title:a.cardMemoryTitle,subtitle:a.cardMemorySubtitle}),(0,R.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.memoryEnabled,description:a.memoryEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.memoryEnabledOn})]})}),(0,R.jsx)(Q,{label:a.useEnhancedSystem,description:a.useEnhancedSystemDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.useEnhancedSystemOn})]})}),(0,R.jsx)(Q,{label:a.userProfileEnabled,description:a.userProfileEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.userProfileEnabledOn})]})}),(0,R.jsx)(Q,{label:a.memoryProvider,description:a.memoryProviderDesc,children:(0,R.jsxs)(`select`,{className:Z(),value:r.memory.provider,onChange:e=>i({memory:{...r.memory,provider:e.target.value}}),children:[(0,R.jsx)(`option`,{value:``,children:a.memoryProviderUnset}),(0,R.jsx)(`option`,{value:`none`,children:`none`}),(0,R.jsx)(`option`,{value:`stub`,children:`stub`})]})}),(0,R.jsx)(Q,{label:a.injectionFrequency,description:a.injectionFrequencyDesc,children:(0,R.jsxs)(`select`,{className:Z(),value:r.memory.injectionFrequency,onChange:e=>i({memory:{...r.memory,injectionFrequency:e.target.value}}),children:[(0,R.jsx)(`option`,{value:``,children:a.injectionFrequencyUnset}),(0,R.jsx)(`option`,{value:`every-turn`,children:a.injectionEveryTurn}),(0,R.jsx)(`option`,{value:`first-turn`,children:a.injectionFirstTurn})]})}),(0,R.jsx)(Q,{label:a.memoryCharLimit,description:a.memoryCharLimitDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsx)(Q,{label:a.userCharLimit,description:a.userCharLimitDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsx)(Q,{label:a.contextCadence,description:a.contextCadenceDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsx)(Q,{label:a.dialecticCadence,description:a.dialecticCadenceDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:Te,title:a.cardSessionSearchTitle,subtitle:a.cardSessionSearchSubtitle}),(0,R.jsx)(Q,{label:a.sessionSearchSummaryModel,description:a.sessionSearchSummaryModelDesc,children:(0,R.jsx)(k,{value:r.sessionSearch.summaryModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({sessionSearch:{...r.sessionSearch,summaryModel:e}})})})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:O,title:a.cardReviewTitle,subtitle:a.cardReviewSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.reviewEnabled,description:a.reviewEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.reviewEnabledOn})]})}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.memoryNudgeInterval,description:a.memoryNudgeIntervalDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.backgroundReview.memoryNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,memoryNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,R.jsx)(Q,{label:a.skillNudgeInterval,description:a.skillNudgeIntervalDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:0,value:r.backgroundReview.skillNudgeInterval,onChange:e=>i({backgroundReview:{...r.backgroundReview,skillNudgeInterval:Number.parseInt(e.target.value,10)||0}})})}),(0,R.jsx)(Q,{label:a.reviewMaxToolRounds,description:a.reviewMaxToolRoundsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:1,max:32,value:r.backgroundReview.maxToolRounds,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxToolRounds:Number.parseInt(e.target.value,10)||8}})})}),(0,R.jsx)(Q,{label:a.reviewMaxHistoryMessages,description:a.reviewMaxHistoryMessagesDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),min:10,max:200,value:r.backgroundReview.maxHistoryMessages,onChange:e=>i({backgroundReview:{...r.backgroundReview,maxHistoryMessages:Number.parseInt(e.target.value,10)||80}})})}),(0,R.jsx)(Q,{label:a.reviewMaxDurationMs,description:a.reviewMaxDurationMsDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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}})})})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:A,title:a.cardWebExtractTitle,subtitle:a.cardWebExtractSubtitle}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(`div`,{className:`sm:col-span-2`,children:(0,R.jsx)(Q,{label:a.webExtractModel,description:a.webExtractModelDesc,children:(0,R.jsx)(k,{value:r.webExtract.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>i({webExtract:{...r.webExtract,model:e}})})})}),(0,R.jsx)(Q,{label:a.webExtractMaxLength,description:a.webExtractMaxLengthDesc,children:(0,R.jsx)(`input`,{type:`number`,className:X(),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,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:b,title:a.cardDelegateTitle,subtitle:a.cardDelegateSubtitle}),(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)(Q,{label:a.delegateEnabled,description:a.delegateEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.delegateEnabledOn})]})}),(0,R.jsx)(Q,{label:a.executeCodeEnabled,description:a.executeCodeEnabledDesc,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.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,R.jsx)(`span`,{children:a.executeCodeEnabledOn})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:C,title:a.cardPromptSkillsTitle,subtitle:a.cardPromptSkillsSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(Q,{label:a.systemPromptOverride,description:a.systemPromptOverrideDesc,children:(0,R.jsx)(`textarea`,{className:h(X(),`min-h-[100px] resize-y font-mono text-xs`),value:r.systemPromptOverride,placeholder:a.systemPromptPlaceholder,onChange:e=>i({systemPromptOverride:e.target.value})})}),(0,R.jsx)(Q,{label:a.skillsAllowlist,description:a.skillsAllowlistDesc,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.skillsAllowlist.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,className:h(X(),`font-mono text-xs`),value:e,onChange:e=>{let n=[...r.skillsAllowlist];n[t]=e.target.value,i({skillsAllowlist:n})}}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":a.removeListItem,onClick:()=>i({skillsAllowlist:r.skillsAllowlist.filter((e,n)=>n!==t)}),children:`×`})]},t)),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`w-fit`,onClick:()=>i({skillsAllowlist:[...r.skillsAllowlist,``]}),children:a.addSkillName})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:y,title:a.cardToolsDisableTitle,subtitle:a.cardToolsDisableSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.toolsDisableHint}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.toolsDisable.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,className:h(X(),`font-mono text-xs`),value:e,placeholder:`shell`,onChange:e=>{let n=[...r.toolsDisable];n[t]=e.target.value,i({toolsDisable:n})}}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":a.removeListItem,onClick:()=>i({toolsDisable:r.toolsDisable.filter((e,n)=>n!==t)}),children:`×`})]},t)),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`w-fit`,onClick:()=>i({toolsDisable:[...r.toolsDisable,``]}),children:a.addToolName})]})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:_e,title:a.cardParamsTitle,subtitle:a.cardParamsSubtitle}),(0,R.jsx)(Q,{label:a.paramsJson,description:a.paramsJsonDesc,children:(0,R.jsx)(`textarea`,{className:h(X(),`min-h-[88px] resize-y font-mono text-xs`),value:r.paramsJson,placeholder:`{}`,onChange:e=>i({paramsJson:e.target.value})})})]})]})}async function en(){let e=await i(c(`/api/image/providers`));if(!e.ok)throw Error(`Image providers: HTTP ${e.status}`);return(await e.json()).payload?.providers??[]}function tn(e){let t=new Set,n=[];for(let r of e){let e=r.models.length>0?r.models:r.defaultModel?[r.defaultModel]:[];for(let i of e){let e=`${r.id}/${i}`;t.has(e)||(t.add(e),n.push(e))}}return n}function nn(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/[/\s]+/).filter(Boolean);return e.filter(e=>{let t=e.toLowerCase();return r.every(e=>t.includes(e))})}var rn=`image-generation-providers`;function an({value:e,disabled:t,placeholder:n,searchPlaceholder:r,noMatches:i,className:a,onChange:o}){let[s,c]=(0,F.useState)(!1),[u,d]=(0,F.useState)(``),{data:f,isLoading:p,error:m}=l(rn,en,{revalidateOnFocus:!1}),g=(0,F.useMemo)(()=>tn(f??[]),[f]),_=(0,F.useMemo)(()=>nn(g,u),[g,u]),v=e.trim()?e:n,y=e.trim()||n,b=(0,F.useCallback)(e=>{c(e),e||d(``)},[]);return(0,R.jsxs)(P,{open:s,onOpenChange:b,modal:!1,children:[(0,R.jsx)(He,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,disabled:t||p,title:p?`…`:y,className:h(Fe,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,Ge.transition,`hover:border-edge hover:bg-surface-hover/45`,Ne,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,a),"aria-haspopup":`listbox`,"aria-expanded":s,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:p?`…`:v}),(0,R.jsx)(he,{className:`h-4 w-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0})]})}),(0,R.jsx)(Ve,{children:(0,R.jsxs)(Ue,{className:`z-50 w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,side:`bottom`,sideOffset:4,align:`end`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,R.jsx)(`input`,{type:`search`,className:h(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,Le),placeholder:r,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>e.stopPropagation()}),(0,R.jsxs)(`div`,{className:`max-h-60 overflow-auto`,role:`listbox`,"aria-label":r,children:[m?(0,R.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:m instanceof Error?m.message:`Failed to load image providers`}):null,!m&&g.length===0&&!p?(0,R.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:i}):null,!m&&g.length>0&&_.length===0?(0,R.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:i}):null,_.map(t=>(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===e,className:h(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,t===e&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{o(t),c(!1),d(``)},children:[(0,R.jsx)(pe,{className:h(`h-4 w-4 shrink-0`,t!==e&&`invisible`),"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:t})]},t))]})]})})]})}var on=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`adaptive`];function $({label:e,description:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function sn(){let e=r(s(e=>e.language)),t=e.agentSettings,n=e.chat,i=!!a(e=>e.token),[o,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(null),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(!1),_=(0,F.useRef)(!1),{data:v,error:y,isLoading:b,mutate:x}=be(i),S=(0,F.useMemo)(()=>v?.payload?.config===void 0?null:Xt(v.payload.config),[v]);(0,F.useEffect)(()=>{if(!i){c(null),u(null),_.current=!1;return}S!==null&&(_.current||(c(S),u(S)))},[i,S]);let ee=!!(i&&b&&v===void 0&&!y),C=y instanceof Error?y.message:y?String(y):null,te=(0,F.useMemo)(()=>!o||!l?!1:JSON.stringify(o)!==JSON.stringify(l),[o,l]),w=(0,F.useCallback)(e=>{_.current=!0,c(t=>t?{...t,...e}:null)},[]),ne=(0,F.useCallback)(async()=>{if(!(!o||d)){f(!0),m(null),g(!1);try{try{Zt(o.paramsJson)}catch(e){m(e instanceof SyntaxError?t.advanced.paramsInvalidJson:e instanceof Error?e.message:t.advanced.paramsInvalidJson);return}await Qt(o),_.current=!1,g(!0),window.setTimeout(()=>g(!1),2500)}catch(e){m(e instanceof Error?e.message:t.saveError)}finally{f(!1)}}},[o,d,t.saveError,t.advanced]),T=e.settingsSections[`agent-defaults`];return i?ee?(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,R.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,R.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,R.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:e.logs.loading})]}):o?(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:T}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.subtitle}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.sectionDesc})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[h?(0,R.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.saved}):null,(0,R.jsx)(N,{type:`button`,variant:`primary`,disabled:!te||d,onClick:()=>void ne(),children:d?t.saving:t.save})]})]}),p?(0,R.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:p}):null,(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:ue,title:t.cardModelsTitle,subtitle:t.cardModelsSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.model,description:t.desc.model,children:(0,R.jsx)(k,{value:o.model,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>w({model:e})})}),(0,R.jsx)($,{label:t.label.modelFallbacks,description:t.desc.modelFallbacks,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.modelFallbacks.map((e,r)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(k,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...o.modelFallbacks];t[r]=e,w({modelFallbacks:t})}})}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>w({modelFallbacks:o.modelFallbacks.filter((e,t)=>t!==r)}),children:(0,R.jsx)(M,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,R.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>w({modelFallbacks:[...o.modelFallbacks,``]}),children:[(0,R.jsx)(we,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})}),(0,R.jsx)($,{label:t.label.imageModel,description:t.desc.imageModel,children:(0,R.jsx)(k,{value:o.imageModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>w({imageModel:e})})}),(0,R.jsx)($,{label:t.label.imageModelFallbacks,description:t.desc.imageModelFallbacks,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.imageModelFallbacks.map((e,r)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(k,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...o.imageModelFallbacks];t[r]=e,w({imageModelFallbacks:t})}})}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>w({imageModelFallbacks:o.imageModelFallbacks.filter((e,t)=>t!==r)}),children:(0,R.jsx)(M,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,R.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>w({imageModelFallbacks:[...o.imageModelFallbacks,``]}),children:[(0,R.jsx)(we,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})}),(0,R.jsx)($,{label:t.label.imageGenerationModel,description:t.desc.imageGenerationModel,children:(0,R.jsx)(an,{value:o.imageGenerationModel,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>w({imageGenerationModel:e})})}),(0,R.jsx)($,{label:t.label.imageGenerationModelFallbacks,description:t.desc.imageGenerationModelFallbacks,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.imageGenerationModelFallbacks.map((e,r)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(an,{value:e,placeholder:n.modelPlaceholder,searchPlaceholder:n.modelSearchPlaceholder,noMatches:n.modelNoMatches,onChange:e=>{let t=[...o.imageGenerationModelFallbacks];t[r]=e,w({imageGenerationModelFallbacks:t})}})}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":t.removeModelFallback,onClick:()=>w({imageGenerationModelFallbacks:o.imageGenerationModelFallbacks.filter((e,t)=>t!==r)}),children:(0,R.jsx)(M,{className:`size-4`,strokeWidth:1.75})})]},r)),(0,R.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5`,onClick:()=>w({imageGenerationModelFallbacks:[...o.imageGenerationModelFallbacks,``]}),children:[(0,R.jsx)(we,{className:`size-4 shrink-0`,strokeWidth:1.75}),t.addModelFallback]})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:xe,title:t.cardWorkspaceTitle,subtitle:t.cardWorkspaceSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.workspace,description:t.desc.workspace,children:(0,R.jsx)(`input`,{type:`text`,className:X(),value:o.workspace,onChange:e=>w({workspace:e.target.value}),autoComplete:`off`})}),(0,R.jsx)($,{label:t.label.mediaMaxMb,description:t.desc.mediaMaxMb,children:(0,R.jsx)(`input`,{type:`number`,min:1,step:1,className:X(),value:o.mediaMaxMb??``,placeholder:`20`,onChange:e=>{let t=e.target.value;w({mediaMaxMb:t===``?void 0:Number(t)})}})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:le,title:t.cardBrowserTitle,subtitle:t.cardBrowserSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.browserEnabled,description:t.desc.browserEnabled,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:o.browserEnabled,onChange:e=>w({browserEnabled:e.target.checked})}),(0,R.jsx)(`span`,{children:t.browserEnabledOn})]})}),(0,R.jsx)($,{label:t.label.browserHeadless,description:t.desc.browserHeadless,children:(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:o.browserHeadless,onChange:e=>w({browserHeadless:e.target.checked})}),(0,R.jsx)(`span`,{children:t.browserHeadlessOn})]})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:Se,title:t.cardGenerationTitle,subtitle:t.cardGenerationSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,R.jsx)($,{label:t.label.maxTokens,description:t.desc.maxTokens,children:(0,R.jsx)(`input`,{type:`number`,className:X(),value:o.maxTokens,min:1,onChange:e=>w({maxTokens:Number.parseInt(e.target.value,10)||0})})}),(0,R.jsx)($,{label:t.label.temperature,description:t.desc.temperature,children:(0,R.jsx)(`input`,{type:`number`,className:X(),value:o.temperature,min:0,max:2,step:.1,onChange:e=>w({temperature:Number.parseFloat(e.target.value)||0})})})]}),(0,R.jsx)($,{label:t.label.maxToolIterations,description:t.desc.maxToolIterations,children:(0,R.jsx)(`input`,{type:`number`,className:X(),value:o.maxToolIterations,min:1,onChange:e=>w({maxToolIterations:Number.parseInt(e.target.value,10)||0})})})]})]}),(0,R.jsxs)(V,{children:[(0,R.jsx)(H,{icon:Ce,title:t.cardBehaviorTitle,subtitle:t.cardBehaviorSubtitle}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)($,{label:t.label.thinkingDefault,description:t.desc.thinkingDefault,children:(0,R.jsx)(`select`,{className:Z(),value:o.thinkingDefault,onChange:e=>w({thinkingDefault:e.target.value}),children:on.map(e=>(0,R.jsx)(`option`,{value:e,children:n.thinkingLevels[e]},e))})}),(0,R.jsx)($,{label:t.label.reasoningDefault,description:t.desc.reasoningDefault,children:(0,R.jsxs)(`select`,{className:Z(),value:o.reasoningDefault,onChange:e=>w({reasoningDefault:e.target.value}),children:[(0,R.jsx)(`option`,{value:`off`,children:t.reasoning.off}),(0,R.jsx)(`option`,{value:`on`,children:t.reasoning.on}),(0,R.jsx)(`option`,{value:`stream`,children:t.reasoning.stream})]})}),(0,R.jsx)($,{label:t.label.verboseDefault,description:t.desc.verboseDefault,children:(0,R.jsxs)(`select`,{className:Z(),value:o.verboseDefault,onChange:e=>w({verboseDefault:e.target.value}),children:[(0,R.jsx)(`option`,{value:`off`,children:t.verbose.off}),(0,R.jsx)(`option`,{value:`on`,children:t.verbose.on}),(0,R.jsx)(`option`,{value:`full`,children:t.verbose.full})]})})]})]}),(0,R.jsx)($t,{a:t,chat:n,form:o,update:w})]})]}):(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p??C??t.loadError}),(0,R.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>void x(),children:e.logs.refresh})]}):(0,R.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,R.jsx)(ue,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:T}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.needToken})]})]})})}export{Ft as AgentsSettingsPanel,Ot as i,V as n,H as r,sn as t};
|
|
2
|
+
//# sourceMappingURL=agents-BdC4Y-HX.js.map
|