@xopcai/xopc 0.0.239 → 0.0.241
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DLfkwJzZ.js → activity-store-CLnbVm9G.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C1rtpjd7.js → agent-avatar-dicebear-DuBewmbW.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DbdgX6AA.js +1 -0
- package/dist/gateway/static/root/assets/agents-BX3uRVm4.js +1 -0
- package/dist/gateway/static/root/assets/{api-IUm57Zse.js → api-DjBZe303.js} +1 -1
- package/dist/gateway/static/root/assets/app-chrome-BeB4KgOf.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CRDnRN4G.js → app-management-settings-panel-D8evZyFQ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BCYZIKqQ.js → appearance-settings-B-iul0RG.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CoZd_cZu.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Bha1jUhj.js → archive-plugin-BOx0EJZs.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Bgfh7Ag2.js → attachment-load-Cfk1lwBo.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BdH131M0.js → automations-page-BTSGvaeS.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-C8RRKT-a.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BwXg9na-.js → binary-plugins-ChZyZK45.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BngtUSNv.js → block-editor-DCH9b2Ht.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-D1GPwIfx.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CHHw7Ula.js → browser-workflow-inputs-jvfcgFG-.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Ael9sxrp.js → browser-workflows-page-DrHW7XNi.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CrXB1Q-l.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-DWMSYaNZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CwUSKmeY.js → channels-status-swr-CC9MFway.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DI0lYVKk.js → chat-terminal-dock-DeeZrVbV.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-DXTl1fNB.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-CLuvPZ3b.js → cron-expression-CiqQOeQ3.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-D4QS8Zzn.js → date-picker-CGAMGPfU.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-CxWeUTsc.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-C6KqTQas.js → desktop-pet-C3QmYO75.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CAADkWYy.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DpeeYAjX.js → extension-debug-page-FQXjDJ8P.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Cescx_be.js → extension-page-BJE1D5Ji.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-C_ubW61U.js → extension-settings-page-5Ik2tNry.js} +1 -1
- package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-BM79X1jC.js → gateway-config-api-cTj71t2a.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-DfMY-MLf.js → gateway-config-swr-Bxe_R-JH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-GV5KAj-l.js → gateway-settings-KXBUjNcx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-S6aB0hVI.js → gateway-startup-retry-DJG-I0wW.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CZ1KeXXU.js → heartbeat-settings-C8cVzIcs.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-NdWtBda5.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-DOX5uq-R.js → image-generation-api-Dc_ojQuj.js} +1 -1
- package/dist/gateway/static/root/assets/index-7i2P3312.js +70 -0
- package/dist/gateway/static/root/assets/index-DTo3IcbW.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Tn7xSeVT.js → keyboard-shortcuts-settings-pOKl7blR.js} +1 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-C_j_od5f.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-Co5_qKEQ.js → local-apps-page-Bi6wwKgm.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-XDFAPNNu.js → locale-store-C5wr3_pc.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-D6PDZEVP.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DE0o5c7Y.js → management-settings-DGlVizWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CADkGbQi.js → markdown-split-CXP5zBx_.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-v-O3cOpk.js → markdown-view-D6LxlDxr.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-mHodPaFz.js → media-plugins-BsENGLr2.js} +1 -1
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +1 -0
- package/dist/gateway/static/root/assets/messages-_tYhRAHD.js +3 -0
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +1 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-43FyMswX.js → mobile-pairing-wizard-DcEz7qcX.js} +1 -1
- package/dist/gateway/static/root/assets/models-hub-cache-Y7GUjxHx.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-BMUyJStB.js → notes-page-D2EqpDyo.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Bu0a83Oj.js +4 -0
- package/dist/gateway/static/root/assets/{oauth-api-B_pcOUfT.js → oauth-api-C5NVcsKE.js} +1 -1
- package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +1 -0
- package/dist/gateway/static/root/assets/popover-select-DrILF6mR.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-B8cjLdm4.js → product-open-page-DMhf1rdz.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DDHi0Y4Q.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CVMFKpmu.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-DeVvBsl4.js → registry-api-FXdFaoWM.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B74aErBY.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ClCEmwPY.js → runtime-tools-settings-panel-Bv-akndY.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-0vcUqeqa.js → schema-form-BUzdHWx6.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-D2wmGNZE.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CYCCUMEt.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BkdLf_sS.js → settings-form-section-DjWzRk4z.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-QBTaBpBn.js → settings-page-C0OBLqpu.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-bQcSMkVr.js → setup-status-panel-NpLQkFCh.js} +1 -1
- package/dist/gateway/static/root/assets/share-preview-page-BtbPYaYC.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-rf8f1OGq.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BkvclZ_o.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-BNcnmaTg.js → skills-page-CYk8pN97.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-BWWcFShl.js → skills-page.utils-DGjnz-NG.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BsH7b3B4.js → system-settings-panel-DmCRSvtd.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-6a2RdDl2.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-5-XHH7F0.js → theme-store-DUko1ZnE.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-D5-Hggt3.js → tunnel-api-Chfiba_x.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Dp1ycDa8.js → use-autosave-W_P8Kiv4.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-SeOHP6XO.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DhrQXH3c.js → voice-api-key-field-BZD0j1jc.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-Bk_bVeGX.js → voice-config-api-BO6A8V3Z.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B7zKAPrb.js → work-discovery-overlay-BfwEoOGL.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-X7Z5_lRX.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-BklMzkg8.js +5 -0
- package/dist/gateway/static/root/index.html +19 -14
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/app.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/execution-environments.js +22 -0
- package/dist/src/gateway/hono/routes/media.js +5 -14
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +4 -0
- package/dist/src/gateway/hono/routes/shares.js +39 -8
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/media-access.d.ts +6 -0
- package/dist/src/gateway/media-access.js +19 -0
- package/dist/src/gateway/security/csp.d.ts +2 -0
- package/dist/src/gateway/security/csp.js +17 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -2
- package/dist/src/gateway/service.js +3 -3
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/share/hosted-session-share.js +1 -1
- package/dist/src/share/share-store.js +3 -2
- package/dist/src/share/share-types.d.ts +2 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-oW6wFuP9.js +0 -1
- package/dist/gateway/static/root/assets/agents-V-nDPOk2.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-dcvQDCvy.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BtwzQZAR.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-kfNOKQ2x.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DOymgkUM.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-YscUvFub.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BtzCRQGz.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DZn-RhEm.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Bov3XuPO.js +0 -1
- package/dist/gateway/static/root/assets/home-page-YdVal_8I.js +0 -1
- package/dist/gateway/static/root/assets/index-7GLgmvAm.css +0 -2
- package/dist/gateway/static/root/assets/index-DKP23eMn.js +0 -70
- package/dist/gateway/static/root/assets/local-app-workbench-page-DCt7cbvK.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-ChfSQQSV.js +0 -2
- package/dist/gateway/static/root/assets/messages-B1HDp_j8.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-Bngs8o1m.js +0 -1
- package/dist/gateway/static/root/assets/notes-api-BMhFpRmW.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-DjHIQneE.js +0 -4
- package/dist/gateway/static/root/assets/popover-select-DBrVS3tZ.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-CXD2pVgQ.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-cqKqkTwG.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-UEinEd7d.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-Cc6ve-qc.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-_J5FSEYX.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-D_OuXnah.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-DJfcpok3.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Bbqp5HaH.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CcAhyw2Z.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Dd_oMNie.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-Cek9K48F.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-T2q2Mx6H.js +0 -5
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GatewayService } from './service.js';
|
|
2
|
+
/** Resolve media only when the supplied session or task references it. */
|
|
3
|
+
export declare function resolveScopedMediaReference(service: GatewayService, uri: string, scope: {
|
|
4
|
+
sessionKey?: string;
|
|
5
|
+
taskId?: string;
|
|
6
|
+
}): Promise<import("../media/media-reference.js").ResolvedMediaReference>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TaskRepository } from "../tasks/task-repository.js";
|
|
2
|
+
import { FileServiceError } from "../files/file-service.js";
|
|
3
|
+
import { resolveMediaReference } from "../media/media-reference.js";
|
|
4
|
+
import { TaskContextRepository } from "../tasks/task-context-repository.js";
|
|
5
|
+
import { pendingTranscriptReferencesMediaUri } from "../agent/inbound/attachment-pipeline.js";
|
|
6
|
+
import { messagesReferenceMediaUri } from "../media/session-references.js";
|
|
7
|
+
//#region src/gateway/media-access.ts
|
|
8
|
+
/** Resolve media only when the supplied session or task references it. */
|
|
9
|
+
async function resolveScopedMediaReference(service, uri, scope) {
|
|
10
|
+
const { sessionKey, taskId } = scope;
|
|
11
|
+
if (!sessionKey && !taskId) throw new FileServiceError(400, "Missing media scope");
|
|
12
|
+
const media = await resolveMediaReference(uri);
|
|
13
|
+
const sessionReferencesUri = sessionKey ? messagesReferenceMediaUri(await service.sessionIndexInstance.loadMessages(sessionKey), media.uri) || pendingTranscriptReferencesMediaUri(sessionKey, media.uri) : false;
|
|
14
|
+
const taskReferencesUri = taskId && new TaskRepository().get(taskId) ? new TaskContextRepository().list(taskId).some((edge) => edge.targetKind === "file" && edge.targetId === media.uri) : false;
|
|
15
|
+
if (!sessionReferencesUri && !taskReferencesUri) throw new FileServiceError(404, "Not found");
|
|
16
|
+
return media;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveScopedMediaReference };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Shared HTML runs with an opaque origin, without access to console storage. */
|
|
2
|
+
export declare const SHARED_HTML_CSP: string;
|
|
1
3
|
/**
|
|
2
4
|
* Compute SHA-256 CSP hashes for inline `<script>` blocks in an HTML string.
|
|
3
5
|
* Only scripts without a `src` attribute are considered inline.
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
//#region src/gateway/security/csp.ts
|
|
3
|
+
/** Shared HTML runs with an opaque origin, without access to console storage. */
|
|
4
|
+
const SHARED_HTML_CSP = [
|
|
5
|
+
"default-src 'none'",
|
|
6
|
+
"sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals",
|
|
7
|
+
"script-src 'unsafe-inline' https:",
|
|
8
|
+
"style-src 'unsafe-inline' https:",
|
|
9
|
+
"img-src https: data: blob:",
|
|
10
|
+
"media-src https: data: blob:",
|
|
11
|
+
"font-src https: data:",
|
|
12
|
+
"connect-src https:",
|
|
13
|
+
"frame-src 'none'",
|
|
14
|
+
"frame-ancestors 'none'",
|
|
15
|
+
"base-uri 'none'",
|
|
16
|
+
"object-src 'none'",
|
|
17
|
+
"form-action https:"
|
|
18
|
+
].join("; ");
|
|
3
19
|
/**
|
|
4
20
|
* Compute SHA-256 CSP hashes for inline `<script>` blocks in an HTML string.
|
|
5
21
|
* Only scripts without a `src` attribute are considered inline.
|
|
@@ -53,4 +69,4 @@ function buildGatewayConsoleCspHeader(options) {
|
|
|
53
69
|
].join("; ");
|
|
54
70
|
}
|
|
55
71
|
//#endregion
|
|
56
|
-
export { buildGatewayConsoleCspHeader, computeInlineScriptHashes };
|
|
72
|
+
export { SHARED_HTML_CSP, buildGatewayConsoleCspHeader, computeInlineScriptHashes };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
4
3
|
import { getModelRegistry } from "../../providers/model-registry.js";
|
|
4
|
+
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
5
5
|
import { init_providers } from "../../providers/index.js";
|
|
6
6
|
import { disposeAllSessionMcpRuntimes } from "../../agent/mcp/bundle-mcp-runtime.js";
|
|
7
7
|
import { reloadImageGenerationProviders } from "../../agent/image/generation/provider-registry.js";
|
|
8
8
|
import "../../agent/mcp/bundle-mcp-tools.js";
|
|
9
9
|
import { ConfigHotReloader } from "../../config/reload.js";
|
|
10
10
|
import "../../config/index.js";
|
|
11
|
-
import { sanitizeTunnelConfig } from "../../tunnel/tunnel-config.js";
|
|
12
11
|
import { computeBundledExtensionExtensionsPatch } from "../../extensions/bundled-extension-activation.js";
|
|
12
|
+
import { sanitizeTunnelConfig } from "../../tunnel/tunnel-config.js";
|
|
13
13
|
//#region src/gateway/service/config-coordinator.ts
|
|
14
14
|
init_providers();
|
|
15
15
|
init_logger();
|
|
@@ -9,14 +9,14 @@ import { closeXopcDatabase, openXopcDatabase } from "../storage/sqlite/connectio
|
|
|
9
9
|
import "../storage/sqlite/index.js";
|
|
10
10
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
11
11
|
import { init_agent_scope, listAgentEntries, normalizeAgentId, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
12
|
-
import { buildSessionKey, init_session_key, sanitizeSegment } from "../routing/session-key.js";
|
|
13
|
-
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
14
12
|
import { init_paths, resolveAgentDir, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
13
|
+
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
15
14
|
import { areExtensionsGloballyDisabled } from "../extensions/discover-extensions.js";
|
|
16
15
|
import { buildExtensionMetadataSnapshot } from "../extensions/extension-metadata-snapshot.js";
|
|
17
16
|
import { buildChannelCatalogForConfig, buildChannelCatalogFromSnapshot, init_channel_catalog_service } from "../channels/catalog/channel-catalog-service.js";
|
|
18
17
|
import { loadConfig, saveConfig } from "../config/loader.js";
|
|
19
|
-
import {
|
|
18
|
+
import { buildSessionKey, init_session_key, sanitizeSegment } from "../routing/session-key.js";
|
|
19
|
+
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
20
20
|
import { init_providers, providers_exports } from "../providers/index.js";
|
|
21
21
|
import { TaskRepository } from "../tasks/task-repository.js";
|
|
22
22
|
import { TaskConversationRepository } from "../tasks/task-conversation-repository.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, shouldSilence, stripHeartbeatToken } from "./tokens.js";
|
|
2
|
-
import { appendCronEventLines } from "./event-prompt.js";
|
|
3
2
|
import { isWithinActiveHours } from "./active-hours.js";
|
|
4
3
|
import { isHeartbeatContentEmpty } from "./content-check.js";
|
|
4
|
+
import { appendCronEventLines } from "./event-prompt.js";
|
|
5
5
|
import { createHeartbeatWake } from "./wake.js";
|
|
6
6
|
export { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, appendCronEventLines, createHeartbeatWake, isHeartbeatContentEmpty, isWithinActiveHours, shouldSilence, stripHeartbeatToken };
|
|
@@ -2,8 +2,8 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { init_paths, resolveConfigPath } from "../config/paths.js";
|
|
4
4
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
|
-
import { resolveGatewayService } from "../daemon/service.js";
|
|
6
5
|
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
6
|
+
import { resolveGatewayService } from "../daemon/service.js";
|
|
7
7
|
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
8
8
|
import { findVerifiedGatewayListenerPidsOnPortSync, signalVerifiedGatewayPidSync } from "./gateway-processes.js";
|
|
9
9
|
import { refreshGatewayServiceAfterUpdate } from "./update-service-refresh.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { runPostUpdateExtensionSync } from "../extensions/update.js";
|
|
1
2
|
import "./update-channels.js";
|
|
2
3
|
import { compareSemver, resolveNpmChannelTag } from "./update-check.js";
|
|
3
|
-
import { runPostUpdateExtensionSync } from "../extensions/update.js";
|
|
4
4
|
import { readPackageName, readPackageVersion } from "./package-json.js";
|
|
5
5
|
import { createDefaultCommandRunner, runCommandWithTimeout } from "./run-command.js";
|
|
6
6
|
import { XOPC_PACKAGE_NAME, cleanupGlobalRenameDirs, createGlobalInstallEnv, detectGlobalInstallManagerForRoot, resolveGlobalInstallSpec, resolveGlobalInstallTarget } from "./update-global.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
2
1
|
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
2
|
+
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
3
3
|
import { getDefaultAuthProfileStore } from "./auth-profile-store.js";
|
|
4
4
|
//#region src/providers/auth-runtime/resolve-auth.ts
|
|
5
5
|
init_env_keys();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __esmMin, __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
|
-
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
4
|
-
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
5
3
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
6
4
|
import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
7
5
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
6
|
+
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
8
7
|
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
8
|
+
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
10
|
import { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
|
-
import { resolveModelsJsonPath } from "../config/paths.js";
|
|
5
4
|
import { init_resolve_config_value, resolveConfigValue, resolveHeaders } from "../config/resolve-config-value.js";
|
|
5
|
+
import { resolveModelsJsonPath } from "../config/paths.js";
|
|
6
6
|
import { getDefaultModelValues, init_models_json, validateModelsConfig } from "../config/models-json.js";
|
|
7
7
|
import { getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
8
8
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
3
2
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
3
|
+
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
4
4
|
import { XOPC_CLOUD_PROVIDER_ID, init_xopc_cloud_config, resolveXopcModelRouterUrl } from "./xopc-cloud-config.js";
|
|
5
5
|
//#region src/providers/register-runtime-providers.ts
|
|
6
6
|
function registerRuntimeProvider(modelRuntime, source) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths-state.js";
|
|
2
|
-
import { init_paths } from "../config/paths.js";
|
|
3
2
|
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
3
|
+
import { init_paths } from "../config/paths.js";
|
|
4
4
|
import { CredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
5
5
|
import { resolveMediaReference } from "../media/media-reference.js";
|
|
6
6
|
import { projectSessionShare } from "./session-share-projector.js";
|
|
@@ -96,8 +96,9 @@ var ShareStore = class {
|
|
|
96
96
|
if ((await lstat(absolutePath)).isSymbolicLink()) {
|
|
97
97
|
if (!isPathUnderWorkspace(workspaceRoot, await realpath(absolutePath))) throw new Error("Symlink target is outside workspace");
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
const
|
|
99
|
+
const sourceName = relPath.split("/").pop() || relPath;
|
|
100
|
+
const fileName = params.fileName || sourceName;
|
|
101
|
+
const mimeType = resolveMimeType(sourceName);
|
|
101
102
|
const record = this.buildRecord({
|
|
102
103
|
kind: "file",
|
|
103
104
|
absolutePath,
|
|
@@ -99,6 +99,8 @@ export interface SessionShareRecord extends ShareRecordBase {
|
|
|
99
99
|
export type WorkspaceShareRecord = FileShareRecord | DirectoryShareRecord;
|
|
100
100
|
export type ShareRecord = WorkspaceShareRecord | NoteShareRecord | SessionShareRecord;
|
|
101
101
|
export interface CreateShareParams {
|
|
102
|
+
/** Display filename for a stored media attachment. */
|
|
103
|
+
fileName?: string;
|
|
102
104
|
/** Workspace-relative file path. */
|
|
103
105
|
path: string;
|
|
104
106
|
/** Time-to-live in milliseconds (default: 24h). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths-state.js";
|
|
2
|
-
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
3
2
|
import { init_paths, resolveAgentProfileDir, resolveBundledSkillsDir } from "../config/paths.js";
|
|
3
|
+
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
4
4
|
import { resolveBootstrapFilesSync } from "../agent/bootstrap/bootstrap-files.js";
|
|
5
5
|
import { createSkillConfigManager, isSkillEnabled } from "../agent/skills/config.js";
|
|
6
6
|
import { loadSkills } from "../agent/skills/index.js";
|
package/dist/src/tui/tui.js
CHANGED
|
@@ -2,10 +2,10 @@ import { version } from "../../package.js";
|
|
|
2
2
|
import { resolveStateDir, resolveXopcDatabasePath } from "../config/paths-state.js";
|
|
3
3
|
import { parseAgentSessionKey } from "../routing/session-key-utils.js";
|
|
4
4
|
import { init_agent_session_key, normalizeAgentId } from "../routing/agent-session-key.js";
|
|
5
|
-
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
6
5
|
import { init_paths } from "../config/paths.js";
|
|
7
6
|
import { loadConfig } from "../config/loader.js";
|
|
8
7
|
import { getAllModels, getAllProviders, getApiKey, init_providers, isProviderConfiguredSync } from "../providers/index.js";
|
|
8
|
+
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
9
9
|
import { ProjectTrustStore, hasTrustRequiringProjectResources } from "../project-trust/trust-store.js";
|
|
10
10
|
import { renderWorkflowFinalSummary, renderWorkflowPanel } from "../agent/workflow/snapshot.js";
|
|
11
11
|
import { ensureStarterAgentsInitialized } from "../agent/starter-agents.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
|
|
2
|
-
import { extractProfileAgentId, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
3
2
|
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
3
|
+
import { extractProfileAgentId, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
4
4
|
import { TaskRepository } from "../../tasks/task-repository.js";
|
|
5
5
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
6
6
|
import { TaskRunRepository } from "../../tasks/task-run-repository.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.241",
|
|
4
4
|
"description": "Local-first personal AI assistant with reviewable user understanding, durable tasks, workflows, automations, and local or cloud models.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as a}from"./popover-select-DBrVS3tZ.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./search-DA7gz22f.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{t as u}from"./button-CSEbl4zT.js";import{n as d,s as f}from"./locale-store-XDFAPNNu.js";import{t as p}from"./skeleton-BwbyijEw.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{r as h}from"./gateway-config-swr-DfMY-MLf.js";import{n as g,t as _}from"./registry-api-DeVvBsl4.js";import{Hn as v,Qs as y,Rs as b,Un as x,Xn as S,_l as C,as as w,bc as T,es as E,gl as D,ns as O,ot as ee,ps as k,v as te,vs as A}from"./index-DKP23eMn.js";import{n as j,r as M}from"./settings-page-layout-BRQNel6r.js";import{l as ne}from"./voice-config-api-Bk_bVeGX.js";import{r as re}from"./image-generation-api-DOX5uq-R.js";var N=e(t(),1),ie=n(),P=r(),F={"xopc-cloud":`XOPC Cloud`,"xopc-local":`XOPC Local`,alibaba:`Alibaba Cloud`,edge:`Microsoft Edge`,groq:`Groq`,minimax:`MiniMax`,openai:`OpenAI`,"tts-local-cli":`Local TTS`};function I(e,t,n){let r=e?.[t]?.[n];return typeof r==`string`&&r.trim()?r.trim():void 0}function L(e){return F[e]??e}function R(e){let t=(0,ie.c)(17),{icon:n,label:r,enabled:i,details:a,zh:o}=e,s;t[0]===n?s=t[1]:(s=(0,P.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,P.jsx)(n,{className:`size-4`,"aria-hidden":!0})}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=c);let l=i?o?`已启用`:`On`:o?`已关闭`:`Off`,u;t[4]===l?u=t[5]:(u=(0,P.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-fg-muted`,children:l}),t[4]=l,t[5]=u);let d;t[6]!==c||t[7]!==u?(d=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f=i?a:o?`不处理语音`:`Voice processing is disabled`,p;t[9]===f?p=t[10]:(p=(0,P.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,P.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==s||t[15]!==m?(h=(0,P.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-panel p-4`,children:[s,m]}),t[14]=s,t[15]=m,t[16]=h):h=t[16],h}function ae(e){let t=(0,ie.c)(27),{zh:n}=e,{data:r,error:a,isLoading:o}=h(!0),s=r?.payload?.config,c,l,d;if(t[0]!==s){d=s===void 0?void 0:ne(s);let e=d?I(d.stt.providers,d.stt.provider,`model`):void 0,n=d?I(d.tts.providers,d.tts.provider,`model`):void 0,r=d?I(d.tts.providers,d.tts.provider,`voice`):void 0;c=d?[L(d.stt.provider),e].filter(Boolean).join(` · `):void 0,l=d?[L(d.tts.provider),n,r].filter(Boolean).join(` · `):void 0,t[0]=s,t[1]=c,t[2]=l,t[3]=d}else c=t[1],l=t[2],d=t[3];let f=l,m=n?`语音能力`:`Voice capabilities`,g;t[4]===m?g=t[5]:(g=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:m}),t[4]=m,t[5]=g);let _=n?`STT 和 TTS 由所有 Agent 共用,在全局语音设置中统一管理。`:`STT and TTS are shared by every agent and managed in global voice settings.`,v;t[6]===_?v=t[7]:(v=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_}),t[6]=_,t[7]=v);let y;t[8]!==g||t[9]!==v?(y=(0,P.jsxs)(`div`,{children:[g,v]}),t[8]=g,t[9]=v,t[10]=y):y=t[10];let x=n?`管理语音设置`:`Manage voice settings`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,P.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[11]=S):S=t[11];let w;t[12]===x?w=t[13]:(w=(0,P.jsx)(u,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,P.jsxs)(i,{to:`/settings/capabilities/voice`,children:[x,S]})}),t[12]=x,t[13]=w);let T;t[14]!==y||t[15]!==w?(T=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[y,w]}),t[14]=y,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==o||t[19]!==c||t[20]!==f||t[21]!==d||t[22]!==n?(E=o||!d?a?(0,P.jsx)(`p`,{className:`mt-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:n?`暂时无法读取语音配置。`:`Voice settings could not be loaded.`}):(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(p,{className:`h-20 rounded-xl`}),(0,P.jsx)(p,{className:`h-20 rounded-xl`})]}):(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(R,{icon:b,label:n?`语音转文字(STT)`:`Speech to text (STT)`,enabled:d.stt.enabled,details:c,zh:n}),(0,P.jsx)(R,{icon:D,label:n?`文字转语音(TTS)`:`Text to speech (TTS)`,enabled:d.tts.enabled,details:f,zh:n})]}),t[17]=a,t[18]=o,t[19]=c,t[20]=f,t[21]=d,t[22]=n,t[23]=E):E=t[23];let O;return t[24]!==T||t[25]!==E?(O=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=O):O=t[26],O}var z=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],oe=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,B={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function se(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function V(e){let t=(0,ie.c)(35),{primary:n,value:r,models:i,loading:a,error:o,zh:s,onChange:l}=e,u;if(t[0]!==i||t[1]!==n||t[2]!==r){let e;t[4]!==n||t[5]!==r?(e=e=>e.id!==n&&!r.includes(e.id),t[4]=n,t[5]=r,t[6]=e):e=t[6],u=i.filter(e),t[0]=i,t[1]=n,t[2]=r,t[3]=u}else u=t[3];let d=u,f=s?`回退顺序`:`Fallback order`,p;t[7]===f?p=t[8]:(p=(0,P.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),t[7]=f,t[8]=p);let m=s?`主模型不可用时,按从左到右的顺序尝试。`:`Tried from left to right when the primary model is unavailable.`,h;t[9]===m?h=t[10]:(h=(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]!==p||t[12]!==h?(g=(0,P.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,P.jsxs)(`div`,{children:[p,h]})}),t[11]=p,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==i||t[15]!==l||t[16]!==r||t[17]!==s?(_=r.length>0?(0,P.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r.map((e,t)=>(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-edge bg-surface-panel py-1 pl-2.5 pr-1 text-xs text-fg`,children:[(0,P.jsx)(`span`,{className:`text-fg-subtle`,children:t+1}),(0,P.jsx)(`span`,{children:i.find(t=>t.id===e)?.name??e}),(0,P.jsx)(`button`,{type:`button`,"aria-label":s?`移除 ${e}`:`Remove ${e}`,className:`rounded-full p-1 text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>l(r.filter(t=>t!==e)),children:(0,P.jsx)(c,{className:`size-3`})})]},e))}):(0,P.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:s?`未设置回退模型。`:`No fallback models configured.`}),t[14]=i,t[15]=l,t[16]=r,t[17]=s,t[18]=_):_=t[18];let v=s?`添加回退模型`:`Add fallback model`,y=s?`搜索模型或服务商`:`Search models or providers`,b=s?`没有可添加的模型`:`No models available to add`,x=s?`添加回退模型`:`Add fallback model`,S;t[19]!==l||t[20]!==r?(S=e=>{e&&l([...r,e])},t[19]=l,t[20]=r,t[21]=S):S=t[21];let C;t[22]!==d||t[23]!==o||t[24]!==a||t[25]!==b||t[26]!==x||t[27]!==S||t[28]!==v||t[29]!==y?(C=(0,P.jsx)(ee,{value:``,models:d,modelsLoading:a,modelsError:o,placeholder:v,searchPlaceholder:y,noMatches:b,showProviderInTrigger:!1,contentAlign:`start`,className:`mt-3 w-full max-w-md`,ariaLabel:x,onChange:S}),t[22]=d,t[23]=o,t[24]=a,t[25]=b,t[26]=x,t[27]=S,t[28]=v,t[29]=y,t[30]=C):C=t[30];let w;return t[31]!==C||t[32]!==g||t[33]!==_?(w=(0,P.jsxs)(`div`,{children:[g,_,C]}),t[31]=C,t[32]=g,t[33]=_,t[34]=w):w=t[34],w}function ce(e){let t=(0,ie.c)(121),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let o=m(_,g,a),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[1]=s):s=t[1];let c=m(`agent-defaults-image-models`,re,s),l;t[2]===o.data?l=t[3]:(l=o.data??[],t[2]=o.data,t[3]=l);let d=l,f;t[4]===c.data?f=t[5]:(f=c.data??[],t[4]=c.data,t[5]=f);let p;t[6]===f?p=t[7]:(p=f.flatMap(H),t[6]=f,t[7]=p);let h=p,v=i?B.zh:B.en,y;t[8]!==n||t[9]!==r?(y=(e,t)=>{let i={...n.models.intents};t?i[e]=se(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[8]=n,t[9]=r,t[10]=y):y=t[10];let b=y,x=i?`默认对话模型`:`Default conversation model`,S;t[11]===x?S=t[12]:(S=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),t[11]=x,t[12]=S);let C=i?`大多数对话和没有专用路由的任务都会使用它。`:`Used for most conversations and every task without a dedicated route.`,w;t[13]===C?w=t[14]:(w=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[13]=C,t[14]=w);let T;t[15]!==w||t[16]!==S?(T=(0,P.jsxs)(`div`,{children:[S,w]}),t[15]=w,t[16]=S,t[17]=T):T=t[17];let E=i?`主模型`:`Primary model`,D;t[18]===E?D=t[19]:(D=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:E}),t[18]=E,t[19]=D);let O=i?`选择模型`:`Select a model`,k=i?`搜索模型或服务商`:`Search models or providers`,te=i?`没有匹配的模型`:`No matching models`,A=i?`默认对话模型`:`Default conversation model`,j;t[20]!==n||t[21]!==r?(j=e=>r({...n,models:{...n.models,chat:{...n.models.chat,primary:e}}}),t[20]=n,t[21]=r,t[22]=j):j=t[22];let M;t[23]!==n.models.chat.primary||t[24]!==O||t[25]!==k||t[26]!==te||t[27]!==A||t[28]!==j?(M=(0,P.jsx)(ee,{value:n.models.chat.primary,placeholder:O,searchPlaceholder:k,noMatches:te,showProviderSettingsFooter:!0,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:A,onChange:j}),t[23]=n.models.chat.primary,t[24]=O,t[25]=k,t[26]=te,t[27]=A,t[28]=j,t[29]=M):M=t[29];let ne;t[30]!==D||t[31]!==M?(ne=(0,P.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[D,M]}),t[30]=D,t[31]=M,t[32]=ne):ne=t[32];let N;t[33]!==n||t[34]!==r?(N=e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}}),t[33]=n,t[34]=r,t[35]=N):N=t[35];let F;t[36]!==n.models.chat.fallbacks||t[37]!==n.models.chat.primary||t[38]!==d||t[39]!==o.error||t[40]!==o.isLoading||t[41]!==N||t[42]!==i?(F=(0,P.jsx)(`div`,{className:`mt-6 border-t border-edge pt-5`,children:(0,P.jsx)(V,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:d,loading:o.isLoading,error:o.error,zh:i,onChange:N})}),t[36]=n.models.chat.fallbacks,t[37]=n.models.chat.primary,t[38]=d,t[39]=o.error,t[40]=o.isLoading,t[41]=N,t[42]=i,t[43]=F):F=t[43];let I;t[44]!==T||t[45]!==ne||t[46]!==F?(I=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[T,ne,F]}),t[44]=T,t[45]=ne,t[46]=F,t[47]=I):I=t[47];let L=i?`图片能力`:`Image capabilities`,R;t[48]===L?R=t[49]:(R=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:L}),t[48]=L,t[49]=R);let ce=i?`没有图片任务时可以保持关闭。`:`Leave these off when the agents do not work with images.`,U;t[50]===ce?U=t[51]:(U=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ce}),t[50]=ce,t[51]=U);let W=i?`图片理解模型`:`Image understanding model`,G;t[52]===W?G=t[53]:(G=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:W}),t[52]=W,t[53]=G);let K=n.models.imageUnderstanding?.primary??``,q=i?`关闭图片理解`:`Image understanding off`,J=i?`搜索视觉模型`:`Search vision models`,le=i?`没有可用的视觉模型`:`No vision models available`,ue=i?`关闭图片理解`:`Image understanding off`,de=i?`图片理解模型`:`Image understanding model`,Y;t[54]!==n||t[55]!==r?(Y=e=>{let t={...n.models};e?t.imageUnderstanding=se(t.imageUnderstanding,e):delete t.imageUnderstanding,r({...n,models:t})},t[54]=n,t[55]=r,t[56]=Y):Y=t[56];let X;t[57]!==K||t[58]!==q||t[59]!==J||t[60]!==le||t[61]!==ue||t[62]!==de||t[63]!==Y?(X=(0,P.jsx)(ee,{value:K,placeholder:q,searchPlaceholder:J,noMatches:le,capabilitiesFilter:`vision`,allowEmpty:!0,emptyLabel:ue,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:de,onChange:Y}),t[57]=K,t[58]=q,t[59]=J,t[60]=le,t[61]=ue,t[62]=de,t[63]=Y,t[64]=X):X=t[64];let fe;t[65]!==G||t[66]!==X?(fe=(0,P.jsxs)(`div`,{children:[G,X]}),t[65]=G,t[66]=X,t[67]=fe):fe=t[67];let pe=i?`图片生成模型`:`Image generation model`,me;t[68]===pe?me=t[69]:(me=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:pe}),t[68]=pe,t[69]=me);let he=n.models.imageGeneration?.primary??``,ge=i?`关闭图片生成`:`Image generation off`,_e=i?`搜索图片模型或服务商`:`Search image models or providers`,ve=i?`没有可用的图片生成模型`:`No image generation models available`,ye=i?`关闭图片生成`:`Image generation off`,be=i?`图片生成模型`:`Image generation model`,Z;t[70]!==n||t[71]!==r?(Z=e=>{let t={...n.models};e?t.imageGeneration={primary:e,fallbacks:t.imageGeneration?.fallbacks??[],timeoutMs:t.imageGeneration?.timeoutMs,autoProviderFallback:t.imageGeneration?.autoProviderFallback??!0}:delete t.imageGeneration,r({...n,models:t})},t[70]=n,t[71]=r,t[72]=Z):Z=t[72];let xe;t[73]!==h||t[74]!==c.error||t[75]!==c.isLoading||t[76]!==he||t[77]!==ge||t[78]!==_e||t[79]!==ve||t[80]!==ye||t[81]!==be||t[82]!==Z?(xe=(0,P.jsx)(ee,{value:he,models:h,modelsLoading:c.isLoading,modelsError:c.error,placeholder:ge,searchPlaceholder:_e,noMatches:ve,allowEmpty:!0,emptyLabel:ye,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:be,onChange:Z}),t[73]=h,t[74]=c.error,t[75]=c.isLoading,t[76]=he,t[77]=ge,t[78]=_e,t[79]=ve,t[80]=ye,t[81]=be,t[82]=Z,t[83]=xe):xe=t[83];let Q;t[84]!==me||t[85]!==xe?(Q=(0,P.jsxs)(`div`,{children:[me,xe]}),t[84]=me,t[85]=xe,t[86]=Q):Q=t[86];let $;t[87]!==fe||t[88]!==Q?($=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-2`,children:[fe,Q]}),t[87]=fe,t[88]=Q,t[89]=$):$=t[89];let Se;t[90]!==n||t[91]!==r||t[92]!==i?(Se=n.models.imageGeneration?(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 border-t border-edge pt-5 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,P.jsx)(`input`,{type:`number`,min:1,className:`${oe} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,P.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[!0,!1].map(e=>(0,P.jsx)(u,{variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]}):null,t[90]=n,t[91]=r,t[92]=i,t[93]=Se):Se=t[93];let Ce;t[94]!==R||t[95]!==U||t[96]!==$||t[97]!==Se?(Ce=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[R,U,$,Se]}),t[94]=R,t[95]=U,t[96]=$,t[97]=Se,t[98]=Ce):Ce=t[98];let we;t[99]===i?we=t[100]:(we=(0,P.jsx)(ae,{zh:i}),t[99]=i,t[100]=we);let Te=i?`按任务选择模型`:`Route by task`,Ee;t[101]===Te?Ee=t[102]:(Ee=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:Te}),t[101]=Te,t[102]=Ee);let De=i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`,Oe;t[103]===De?Oe=t[104]:(Oe=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:De}),t[103]=De,t[104]=Oe);let ke;t[105]!==v||t[106]!==n.models.intents||t[107]!==b||t[108]!==i?(ke=z.map(e=>(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v[e][0]}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v[e][1]})]}),(0,P.jsx)(ee,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${v[e][0]}模型`:`${v[e][0]} model`,onChange:t=>b(e,t)})]},e)),t[105]=v,t[106]=n.models.intents,t[107]=b,t[108]=i,t[109]=ke):ke=t[109];let Ae;t[110]===ke?Ae=t[111]:(Ae=(0,P.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:ke}),t[110]=ke,t[111]=Ae);let je;t[112]!==Ee||t[113]!==Oe||t[114]!==Ae?(je=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[Ee,Oe,Ae]}),t[112]=Ee,t[113]=Oe,t[114]=Ae,t[115]=je):je=t[115];let Me;return t[116]!==I||t[117]!==Ce||t[118]!==we||t[119]!==je?(Me=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[I,Ce,we,je]}),t[116]=I,t[117]=Ce,t[118]=we,t[119]=je,t[120]=Me):Me=t[120],Me}function H(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}var U=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function W(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function G(e){let t=(0,ie.c)(151),{draft:n,setDraft:r,zh:i}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=m(`agent-defaults-workflows`,te,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let d;t[3]===c?d=t[4]:(d=c.map(K),t[3]=c,t[4]=d);let f=d,p=n.workflows.allowed===void 0,h;t[5]!==n||t[6]!==r?(h=(e,t)=>{let i=n.workflows.allowed??[],a=t?[...new Set([...i,e])]:i.filter(t=>t!==e);r({...n,workflows:{...n.workflows,allowed:a}})},t[5]=n,t[6]=r,t[7]=h):h=t[7];let g=h,_=i?`执行限制`:`Execution limits`,v;t[8]===_?v=t[9]:(v=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:_}),t[8]=_,t[9]=v);let y=i?`为所有 Agent 设置安全上限;留空时使用系统默认值。`:`Set safe upper bounds for every agent. Empty fields use system defaults.`,b;t[10]===y?b=t[11]:(b=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let x=i?`每次运行最多轮数`:`Maximum turns per run`,S=n.runtime.maxTurns??``,C=i?`系统默认`:`System default`,w;t[12]!==n||t[13]!==r?(w=e=>r({...n,runtime:{...n.runtime,maxTurns:W(e.target.value)}}),t[12]=n,t[13]=r,t[14]=w):w=t[14];let T;t[15]!==S||t[16]!==C||t[17]!==w?(T=(0,P.jsx)(`input`,{type:`number`,min:1,value:S,placeholder:C,onChange:w,className:`${U} mt-2`}),t[15]=S,t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i?`单轮超时(毫秒)`:`Turn timeout (ms)`,O=n.runtime.timeoutMs??``,ee=i?`系统默认`:`System default`,k;t[22]!==n||t[23]!==r?(k=e=>r({...n,runtime:{...n.runtime,timeoutMs:W(e.target.value)}}),t[22]=n,t[23]=r,t[24]=k):k=t[24];let A;t[25]!==O||t[26]!==ee||t[27]!==k?(A=(0,P.jsx)(`input`,{type:`number`,min:1,value:O,placeholder:ee,onChange:k,className:`${U} mt-2`}),t[25]=O,t[26]=ee,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==D||t[30]!==A?(j=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[D,A]}),t[29]=D,t[30]=A,t[31]=j):j=t[31];let M=i?`每轮最多工具失败次数`:`Maximum tool failures per turn`,ne=n.runtime.maxToolFailuresPerTurn??``,re=i?`系统默认`:`System default`,N;t[32]!==n||t[33]!==r?(N=e=>r({...n,runtime:{...n.runtime,maxToolFailuresPerTurn:W(e.target.value)}}),t[32]=n,t[33]=r,t[34]=N):N=t[34];let F;t[35]!==ne||t[36]!==re||t[37]!==N?(F=(0,P.jsx)(`input`,{type:`number`,min:1,value:ne,placeholder:re,onChange:N,className:`${U} mt-2`}),t[35]=ne,t[36]=re,t[37]=N,t[38]=F):F=t[38];let I;t[39]!==M||t[40]!==F?(I=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[M,F]}),t[39]=M,t[40]=F,t[41]=I):I=t[41];let L;t[42]!==E||t[43]!==j||t[44]!==I?(L=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:[E,j,I]}),t[42]=E,t[43]=j,t[44]=I,t[45]=L):L=t[45];let R;t[46]!==L||t[47]!==v||t[48]!==b?(R=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[v,b,L]}),t[46]=L,t[47]=v,t[48]=b,t[49]=R):R=t[49];let ae=i?`提示词缓存`:`Prompt cache`,z;t[50]===ae?z=t[51]:(z=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ae}),t[50]=ae,t[51]=z);let oe=i?`复用稳定的上下文以降低响应延迟和模型费用。`:`Reuse stable context to reduce latency and model cost.`,B;t[52]===oe?B=t[53]:(B=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:oe}),t[52]=oe,t[53]=B);let se=i?`缓存模式`:`Cache mode`,V;t[54]===se?V=t[55]:(V=(0,P.jsx)(`span`,{children:se}),t[54]=se,t[55]=V);let ce;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ce=[`auto`,`off`],t[56]=ce):ce=t[56];let H;t[57]!==n||t[58]!==r||t[59]!==i?(H=(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:ce.map(e=>(0,P.jsx)(u,{variant:n.runtime.promptCache?.mode===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:e,lifetime:n.runtime.promptCache?.lifetime??`short`}}}),children:e===`auto`?i?`自动`:`Automatic`:i?`关闭`:`Off`},e))}),t[57]=n,t[58]=r,t[59]=i,t[60]=H):H=t[60];let G;t[61]!==V||t[62]!==H?(G=(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[V,H]}),t[61]=V,t[62]=H,t[63]=G):G=t[63];let q;t[64]!==n||t[65]!==r||t[66]!==i?(q=n.runtime.promptCache?.mode===`auto`?(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,P.jsx)(`span`,{children:i?`缓存周期`:`Cache lifetime`}),(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[`short`,`long`].map(e=>(0,P.jsx)(u,{variant:n.runtime.promptCache?.lifetime===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:`auto`,lifetime:e}}}),children:e===`short`?i?`短期`:`Short`:i?`长期`:`Long`},e))})]}):null,t[64]=n,t[65]=r,t[66]=i,t[67]=q):q=t[67];let J;t[68]!==G||t[69]!==q?(J=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[G,q]}),t[68]=G,t[69]=q,t[70]=J):J=t[70];let le;t[71]!==z||t[72]!==B||t[73]!==J?(le=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[z,B,J]}),t[71]=z,t[72]=B,t[73]=J,t[74]=le):le=t[74];let ue=i?`工作流`:`Workflows`,de;t[75]===ue?de=t[76]:(de=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ue}),t[75]=ue,t[76]=de);let Y=i?`设置默认工作流,并决定 Agent 可以调用哪些工作流。`:`Set a default workflow and control which workflows agents may invoke.`,X;t[77]===Y?X=t[78]:(X=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y}),t[77]=Y,t[78]=X);let fe=i?`默认工作流`:`Default workflow`,pe;t[79]===fe?pe=t[80]:(pe=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:fe}),t[79]=fe,t[80]=pe);let me=n.workflows.default??``,he=s.isLoading?i?`正在加载…`:`Loading…`:i?`不设置默认工作流`:`No default workflow`,ge=i?`不设置默认工作流`:`No default workflow`,_e=i?`默认工作流`:`Default workflow`,ve;t[81]!==n||t[82]!==r?(ve=e=>r({...n,workflows:{...n.workflows,default:e||void 0}}),t[81]=n,t[82]=r,t[83]=ve):ve=t[83];let ye;t[84]!==me||t[85]!==he||t[86]!==ge||t[87]!==_e||t[88]!==ve||t[89]!==f||t[90]!==s.isLoading?(ye=(0,P.jsx)(a,{value:me,options:f,placeholder:he,emptyLabel:ge,disabled:s.isLoading,ariaLabel:_e,onChange:ve,triggerClassName:`mt-2`}),t[84]=me,t[85]=he,t[86]=ge,t[87]=_e,t[88]=ve,t[89]=f,t[90]=s.isLoading,t[91]=ye):ye=t[91];let be;t[92]!==pe||t[93]!==ye?(be=(0,P.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[pe,ye]}),t[92]=pe,t[93]=ye,t[94]=be):be=t[94];let Z;t[95]===s.error?Z=t[96]:(Z=s.error?(0,P.jsx)(`p`,{className:`mt-3 text-sm text-red-600`,children:s.error instanceof Error?s.error.message:String(s.error)}):null,t[95]=s.error,t[96]=Z);let xe=i?`允许调用的工作流`:`Allowed workflows`,Q;t[97]===xe?Q=t[98]:(Q=(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:xe}),t[97]=xe,t[98]=Q);let $;t[99]!==n||t[100]!==r?($=()=>r({...n,workflows:{...n.workflows,allowed:void 0}}),t[99]=n,t[100]=r,t[101]=$):$=t[101];let Se=p?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-panel hover:border-edge-strong`,Ce;t[102]===Se?Ce=t[103]:(Ce=l(`rounded-xl border p-4 text-left`,Se),t[102]=Se,t[103]=Ce);let we=i?`允许全部工作流`:`Allow every workflow`,Te;t[104]===we?Te=t[105]:(Te=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:we}),t[104]=we,t[105]=Te);let Ee=i?`新增工作流也会自动可用。`:`New workflows become available automatically.`,De;t[106]===Ee?De=t[107]:(De=(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Ee}),t[106]=Ee,t[107]=De);let Oe;t[108]!==$||t[109]!==Ce||t[110]!==Te||t[111]!==De?(Oe=(0,P.jsxs)(`button`,{type:`button`,onClick:$,className:Ce,children:[Te,De]}),t[108]=$,t[109]=Ce,t[110]=Te,t[111]=De,t[112]=Oe):Oe=t[112];let ke;t[113]!==n||t[114]!==r?(ke=()=>r({...n,workflows:{...n.workflows,allowed:[]}}),t[113]=n,t[114]=r,t[115]=ke):ke=t[115];let Ae=p?`border-edge bg-surface-panel hover:border-edge-strong`:`border-accent bg-accent/5 ring-1 ring-accent/20`,je;t[116]===Ae?je=t[117]:(je=l(`rounded-xl border p-4 text-left`,Ae),t[116]=Ae,t[117]=je);let Me=i?`只允许选中的工作流`:`Allow selected workflows only`,Ne;t[118]===Me?Ne=t[119]:(Ne=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Me}),t[118]=Me,t[119]=Ne);let Pe=i?`未选中的工作流不能被调用。`:`Unselected workflows cannot be invoked.`,Fe;t[120]===Pe?Fe=t[121]:(Fe=(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Pe}),t[120]=Pe,t[121]=Fe);let Ie;t[122]!==ke||t[123]!==je||t[124]!==Ne||t[125]!==Fe?(Ie=(0,P.jsxs)(`button`,{type:`button`,onClick:ke,className:je,children:[Ne,Fe]}),t[122]=ke,t[123]=je,t[124]=Ne,t[125]=Fe,t[126]=Ie):Ie=t[126];let Le;t[127]!==Oe||t[128]!==Ie?(Le=(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Oe,Ie]}),t[127]=Oe,t[128]=Ie,t[129]=Le):Le=t[129];let Re;t[130]!==p||t[131]!==n.workflows.allowed||t[132]!==g||t[133]!==s.data||t[134]!==s.isLoading||t[135]!==i?(Re=p?null:(0,P.jsxs)(`div`,{className:`mt-3 divide-y divide-edge rounded-xl border border-edge bg-surface-panel`,children:[(s.data??[]).map(e=>(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:n.workflows.allowed?.includes(e.id)??!1,onChange:t=>g(e.id,t.target.checked),className:`mt-0.5 size-4 accent-[var(--color-accent)]`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title||e.name}),e.description?(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description}):null]})]},e.id)),(s.data??[]).length===0&&!s.isLoading?(0,P.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`还没有工作流。`:`No workflows yet.`}):null]}),t[130]=p,t[131]=n.workflows.allowed,t[132]=g,t[133]=s.data,t[134]=s.isLoading,t[135]=i,t[136]=Re):Re=t[136];let ze;t[137]!==Q||t[138]!==Le||t[139]!==Re?(ze=(0,P.jsxs)(`div`,{className:`mt-6 border-t border-edge pt-5`,children:[Q,Le,Re]}),t[137]=Q,t[138]=Le,t[139]=Re,t[140]=ze):ze=t[140];let Be;t[141]!==de||t[142]!==X||t[143]!==be||t[144]!==Z||t[145]!==ze?(Be=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[de,X,be,Z,ze]}),t[141]=de,t[142]=X,t[143]=be,t[144]=Z,t[145]=ze,t[146]=Be):Be=t[146];let Ve;return t[147]!==R||t[148]!==le||t[149]!==Be?(Ve=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[R,le,Be]}),t[147]=R,t[148]=le,t[149]=Be,t[150]=Ve):Ve=t[150],Ve}function K(e){return{value:e.id,label:e.title||e.name}}function q(e){return[...new Set(e)].sort()}function J(e){let t=(0,ie.c)(99),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let{data:c,error:u,isLoading:d}=m(`agent-defaults-skills-catalog`,S,a),[f,p]=(0,N.useState)(``),h=n.skills.mode===`selected`?n.skills.include:n.skills.exclude;c?.catalog;let g;if(t[1]!==h||t[2]!==c?.catalog||t[3]!==f){let e=[...c?.catalog??[]],n=new Set(e.map(de));for(let t of h)n.has(t)||e.push({name:t,description:``,enabled:!0});let r=f.trim().toLowerCase();g=e.filter(e=>!r||`${e.name} ${e.description}`.toLowerCase().includes(r)).sort(ue),t[1]=h,t[2]=c?.catalog,t[3]=f,t[4]=g}else g=t[4];let _=g,v;t[5]!==n.skills.exclude||t[6]!==n.skills.include||t[7]!==n.skills.mode?(v=e=>n.skills.mode===`selected`?n.skills.include.includes(e):!n.skills.exclude.includes(e),t[5]=n.skills.exclude,t[6]=n.skills.include,t[7]=n.skills.mode,t[8]=v):v=t[8];let b=v,x;t[9]!==n||t[10]!==r?(x=e=>{if(n.skills.mode===`selected`){let t=n.skills.include.includes(e)?n.skills.include.filter(t=>t!==e):q([...n.skills.include,e]);r({...n,skills:{mode:`selected`,include:t}});return}let t=n.skills.exclude.includes(e)?n.skills.exclude.filter(t=>t!==e):q([...n.skills.exclude,e]);r({...n,skills:{mode:`all-enabled`,exclude:t}})},t[9]=n,t[10]=r,t[11]=x):x=t[11];let C=x,w;t[12]===c?.catalog?w=t[13]:(w=c?.catalog??[],t[12]=c?.catalog,t[13]=w);let T;if(t[14]!==b||t[15]!==w){let e;t[17]===b?e=t[18]:(e=e=>e.enabled&&b(e.name),t[17]=b,t[18]=e),T=w.filter(e),t[14]=b,t[15]=w,t[16]=T}else T=t[16];let E=T.length,D=i?`技能策略`:`Skill policy`,O;t[19]===D?O=t[20]:(O=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:D}),t[19]=D,t[20]=O);let ee=i?`决定所有 Agent 默认可以发现和使用哪些技能。`:`Choose which skills every agent can discover and use by default.`,k;t[21]===ee?k=t[22]:(k=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ee}),t[21]=ee,t[22]=k);let te;t[23]!==n||t[24]!==r?(te=()=>r({...n,skills:{mode:`all-enabled`,exclude:[]}}),t[23]=n,t[24]=r,t[25]=te):te=t[25];let A=n.skills.mode===`all-enabled`?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-panel hover:border-edge-strong`,j;t[26]===A?j=t[27]:(j=l(`flex items-start gap-3 rounded-xl border p-4 text-left`,A),t[26]=A,t[27]=j);let M;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,P.jsx)(o,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[28]=M):M=t[28];let ne=i?`使用所有已启用技能`:`Use every enabled skill`,re;t[29]===ne?re=t[30]:(re=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:ne}),t[29]=ne,t[30]=re);let F=i?`推荐。以后启用的新技能也会自动可用,可单独排除。`:`Recommended. Newly enabled skills become available automatically; exclude exceptions below.`,I;t[31]===F?I=t[32]:(I=(0,P.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:F}),t[31]=F,t[32]=I);let L;t[33]!==re||t[34]!==I?(L=(0,P.jsxs)(`span`,{children:[re,I]}),t[33]=re,t[34]=I,t[35]=L):L=t[35];let R;t[36]!==te||t[37]!==j||t[38]!==L?(R=(0,P.jsxs)(`button`,{type:`button`,onClick:te,className:j,children:[M,L]}),t[36]=te,t[37]=j,t[38]=L,t[39]=R):R=t[39];let ae;t[40]!==n||t[41]!==r?(ae=()=>r({...n,skills:{mode:`selected`,include:[]}}),t[40]=n,t[41]=r,t[42]=ae):ae=t[42];let z=n.skills.mode===`selected`?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-panel hover:border-edge-strong`,oe;t[43]===z?oe=t[44]:(oe=l(`flex items-start gap-3 rounded-xl border p-4 text-left`,z),t[43]=z,t[44]=oe);let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,P.jsx)(y,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[45]=B):B=t[45];let se=i?`只使用选中的技能`:`Use selected skills only`,V;t[46]===se?V=t[47]:(V=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:se}),t[46]=se,t[47]=V);let ce=i?`适合严格受控的环境;新增技能不会自动加入。`:`For tightly controlled environments; new skills are not added automatically.`,H;t[48]===ce?H=t[49]:(H=(0,P.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:ce}),t[48]=ce,t[49]=H);let U;t[50]!==V||t[51]!==H?(U=(0,P.jsxs)(`span`,{children:[V,H]}),t[50]=V,t[51]=H,t[52]=U):U=t[52];let W;t[53]!==ae||t[54]!==oe||t[55]!==U?(W=(0,P.jsxs)(`button`,{type:`button`,onClick:ae,className:oe,children:[B,U]}),t[53]=ae,t[54]=oe,t[55]=U,t[56]=W):W=t[56];let G;t[57]!==R||t[58]!==W?(G=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[R,W]}),t[57]=R,t[58]=W,t[59]=G):G=t[59];let K;t[60]!==k||t[61]!==G||t[62]!==O?(K=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[O,k,G]}),t[60]=k,t[61]=G,t[62]=O,t[63]=K):K=t[63];let J=n.skills.mode===`selected`?i?`选择可用技能`:`Select available skills`:i?`管理例外`:`Manage exceptions`,Y;t[64]===J?Y=t[65]:(Y=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:J}),t[64]=J,t[65]=Y);let X=i?`当前默认可用 ${E} 个技能。`:`${E} skills are available by default.`,fe;t[66]===X?fe=t[67]:(fe=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:X}),t[66]=X,t[67]=fe);let pe;t[68]!==Y||t[69]!==fe?(pe=(0,P.jsxs)(`div`,{children:[Y,fe]}),t[68]=Y,t[69]=fe,t[70]=pe):pe=t[70];let me=i?`搜索技能`:`Search skills`,he;t[71]===me?he=t[72]:(he=(0,P.jsx)(`span`,{className:`sr-only`,children:me}),t[71]=me,t[72]=he);let ge;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,P.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[73]=ge):ge=t[73];let _e;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>p(e.target.value),t[74]=_e):_e=t[74];let ve=i?`搜索技能`:`Search skills`,ye;t[75]!==f||t[76]!==ve?(ye=(0,P.jsx)(`input`,{type:`search`,value:f,onChange:_e,placeholder:ve,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[75]=f,t[76]=ve,t[77]=ye):ye=t[77];let be;t[78]!==he||t[79]!==ye?(be=(0,P.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[he,ge,ye]}),t[78]=he,t[79]=ye,t[80]=be):be=t[80];let Z;t[81]!==pe||t[82]!==be?(Z=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[pe,be]}),t[81]=pe,t[82]=be,t[83]=Z):Z=t[83];let xe;t[84]===u?xe=t[85]:(xe=u?(0,P.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u instanceof Error?u.message:String(u)}):null,t[84]=u,t[85]=xe);let Q;t[86]!==b||t[87]!==d||t[88]!==_||t[89]!==C||t[90]!==i?(Q=d?(0,P.jsx)(`div`,{className:`mt-4 space-y-2`,children:[0,1,2,3].map(le)}):(0,P.jsxs)(`div`,{className:`mt-4 max-h-[32rem] divide-y divide-edge overflow-y-auto rounded-xl border border-edge bg-surface-panel`,children:[_.map(e=>{let t=b(e.name);return(0,P.jsxs)(`label`,{className:l(`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,!e.enabled&&`cursor-not-allowed opacity-55`),children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:t,disabled:!e.enabled,onChange:()=>C(e.name),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),e.enabled?null:(0,P.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] text-fg-muted`,children:i?`全局未启用`:`Disabled globally`})]}),e.description?(0,P.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]})]},e.name)}),_.length===0?(0,P.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`没有匹配的技能。`:`No matching skills.`}):null]}),t[86]=b,t[87]=d,t[88]=_,t[89]=C,t[90]=i,t[91]=Q):Q=t[91];let $;t[92]!==Z||t[93]!==xe||t[94]!==Q?($=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[Z,xe,Q]}),t[92]=Z,t[93]=xe,t[94]=Q,t[95]=$):$=t[95];let Se;return t[96]!==K||t[97]!==$?(Se=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[K,$]}),t[96]=K,t[97]=$,t[98]=Se):Se=t[98],Se}function le(e){return(0,P.jsx)(p,{className:`h-14 rounded-xl`},e)}function ue(e,t){return e.name.localeCompare(t.name)}function de(e){return e.name}function Y(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function X(e){let t=(0,ie.c)(92),{draft:n,setDraft:r,builtinTools:i,zh:a}=e,[o,c]=(0,N.useState)(``),[d,f]=(0,N.useState)(`all`),[p,m]=(0,N.useState)(),h;t[0]===i?h=t[1]:(h=new Map(i.map(pe)),t[0]=i,t[1]=h);let g=h,_;t[2]!==i||t[3]!==n.tools?(_=[...new Set([...i.map(fe),...Object.keys(n.tools)])].sort(),t[2]=i,t[3]=n.tools,t[4]=_):_=t[4];let v=_,y;if(t[5]!==v||t[6]!==n.tools){let e;t[8]===n.tools?e=t[9]:(e=e=>(n.tools[e]?.mode??`allow`)===`allow`,t[8]=n.tools,t[9]=e),y=v.filter(e),t[5]=v,t[6]=n.tools,t[7]=y}else y=t[7];let b=y.length,x;if(t[10]!==v||t[11]!==n.tools){let e;t[13]===n.tools?e=t[14]:(e=e=>n.tools[e]?.mode===`ask`,t[13]=n.tools,t[14]=e),x=v.filter(e),t[10]=v,t[11]=n.tools,t[12]=x}else x=t[12];let S=x.length,C;if(t[15]!==v||t[16]!==n.tools){let e;t[18]===n.tools?e=t[19]:(e=e=>n.tools[e]?.mode===`deny`,t[18]=n.tools,t[19]=e),C=v.filter(e),t[15]=v,t[16]=n.tools,t[17]=C}else C=t[17];let w;t[20]!==y.length||t[21]!==x.length||t[22]!==C.length?(w={allow:b,ask:S,deny:C.length},t[20]=y.length,t[21]=x.length,t[22]=C.length,t[23]=w):w=t[23];let T=w,E;if(t[24]!==v||t[25]!==g||t[26]!==n.tools||t[27]!==d||t[28]!==o){let e=o.trim().toLowerCase();E=v.filter(t=>{let r=n.tools[t]?.mode??`allow`,i=g.get(t),a=`${t} ${i?.en??``} ${i?.zh??``}`.toLowerCase();return(!e||a.includes(e))&&(d===`all`||r===d)}),t[24]=v,t[25]=g,t[26]=n.tools,t[27]=d,t[28]=o,t[29]=E}else E=t[29];let D=E,ee;t[30]!==n||t[31]!==r?(ee=(e,t)=>{let i=n.tools[e]??{mode:`allow`};r({...n,tools:{...n.tools,[e]:{...i,...t}}})},t[30]=n,t[31]=r,t[32]=ee):ee=t[32];let k=ee,te=a?`全部 ${v.length}`:`All ${v.length}`,A;t[33]===te?A=t[34]:(A={id:`all`,label:te},t[33]=te,t[34]=A);let j=a?`允许 ${T.allow}`:`Allow ${T.allow}`,M;t[35]===j?M=t[36]:(M={id:`allow`,label:j},t[35]=j,t[36]=M);let ne=a?`询问 ${T.ask}`:`Ask ${T.ask}`,re;t[37]===ne?re=t[38]:(re={id:`ask`,label:ne},t[37]=ne,t[38]=re);let F=a?`禁用 ${T.deny}`:`Deny ${T.deny}`,I;t[39]===F?I=t[40]:(I={id:`deny`,label:F},t[39]=F,t[40]=I);let L;t[41]!==A||t[42]!==M||t[43]!==re||t[44]!==I?(L=[A,M,re,I],t[41]=A,t[42]=M,t[43]=re,t[44]=I,t[45]=L):L=t[45];let R=L,ae=a?`默认工具权限`:`Default tool permissions`,z;t[46]===ae?z=t[47]:(z=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ae}),t[46]=ae,t[47]=z);let oe=a?`允许:直接执行;询问:执行前确认;禁用:Agent 无法使用。`:`Allow runs directly, Ask requires confirmation, and Deny makes the tool unavailable.`,B;t[48]===oe?B=t[49]:(B=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:oe}),t[48]=oe,t[49]=B);let se;t[50]!==z||t[51]!==B?(se=(0,P.jsxs)(`div`,{children:[z,B]}),t[50]=z,t[51]=B,t[52]=se):se=t[52];let V;t[53]!==d||t[54]!==R?(V=(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-xl bg-surface-panel p-1`,children:R.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:l(`rounded-lg px-3 py-1.5 text-xs font-medium`,d===e.id?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`),children:e.label},e.id))}),t[53]=d,t[54]=R,t[55]=V):V=t[55];let ce=a?`搜索工具`:`Search tools`,H;t[56]===ce?H=t[57]:(H=(0,P.jsx)(`span`,{className:`sr-only`,children:ce}),t[56]=ce,t[57]=H);let U;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,P.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[58]=U):U=t[58];let W;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>c(e.target.value),t[59]=W):W=t[59];let G=a?`搜索工具`:`Search tools`,K;t[60]!==o||t[61]!==G?(K=(0,P.jsx)(`input`,{type:`search`,value:o,onChange:W,placeholder:G,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[60]=o,t[61]=G,t[62]=K):K=t[62];let q;t[63]!==H||t[64]!==K?(q=(0,P.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[H,U,K]}),t[63]=H,t[64]=K,t[65]=q):q=t[65];let J;t[66]!==V||t[67]!==q?(J=(0,P.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center justify-between gap-3`,children:[V,q]}),t[66]=V,t[67]=q,t[68]=J):J=t[68];let le;if(t[69]!==g||t[70]!==n.tools||t[71]!==p||t[72]!==k||t[73]!==D||t[74]!==a){let e;t[76]!==g||t[77]!==n.tools||t[78]!==p||t[79]!==k||t[80]!==a?(e=e=>{let t=n.tools[e]??{mode:`allow`},r=g.get(e),i=p===e;return(0,P.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`code`,{className:`text-xs font-medium text-fg`,children:e}),r?(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:a?r.zh:r.en}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex rounded-lg bg-surface-base p-1`,children:[`allow`,`ask`,`deny`].map(n=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(e,{mode:n}),className:l(`rounded-md px-2.5 py-1 text-xs font-medium capitalize`,t.mode===n?`bg-accent text-white`:`text-fg-muted hover:text-fg`),children:n===`allow`?a?`允许`:`Allow`:n===`ask`?a?`询问`:`Ask`:a?`禁用`:`Deny`},n))}),(0,P.jsx)(u,{variant:`ghost`,className:`px-2 py-1`,"aria-label":a?`${e} 调用限制`:`${e} call limits`,onClick:()=>m(i?void 0:e),children:(0,P.jsx)(O,{className:`size-4`})})]})]}),i?(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 rounded-lg bg-surface-base p-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`每轮最多调用次数`:`Maximum calls per turn`,(0,P.jsx)(`input`,{type:`number`,min:1,value:t.maxCallsPerTurn??``,placeholder:a?`不限制`:`Unlimited`,onChange:t=>k(e,{maxCallsPerTurn:Y(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]}),(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`单次超时(毫秒)`:`Call timeout (ms)`,(0,P.jsx)(`input`,{type:`number`,min:1,value:t.timeoutMs??``,placeholder:a?`使用系统默认值`:`Use system default`,onChange:t=>k(e,{timeoutMs:Y(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]})]}):null]},e)},t[76]=g,t[77]=n.tools,t[78]=p,t[79]=k,t[80]=a,t[81]=e):e=t[81],le=D.map(e),t[69]=g,t[70]=n.tools,t[71]=p,t[72]=k,t[73]=D,t[74]=a,t[75]=le}else le=t[75];let ue;t[82]!==D.length||t[83]!==a?(ue=D.length===0?(0,P.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-fg-muted`,children:a?`没有匹配的工具。`:`No matching tools.`}):null,t[82]=D.length,t[83]=a,t[84]=ue):ue=t[84];let de;t[85]!==le||t[86]!==ue?(de=(0,P.jsxs)(`div`,{className:`mt-4 max-h-[38rem] divide-y divide-edge overflow-y-auto rounded-xl border border-edge bg-surface-panel`,children:[le,ue]}),t[85]=le,t[86]=ue,t[87]=de):de=t[87];let X;return t[88]!==se||t[89]!==J||t[90]!==de?(X=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[se,J,de]}),t[88]=se,t[89]=J,t[90]=de,t[91]=X):X=t[91],X}function fe(e){return e.id}function pe(e){return[e.id,e.description]}function me(){let e=(0,ie.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsxs)(M,{gap:`gap-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(p,{className:`h-7 w-56`}),(0,P.jsx)(p,{className:`h-4 w-96 max-w-full`})]}),(0,P.jsx)(p,{className:`h-9 w-28`})]}),(0,P.jsx)(p,{className:`h-20 rounded-2xl`}),(0,P.jsx)(p,{className:`h-12 rounded-xl`}),(0,P.jsx)(p,{className:`h-72 rounded-2xl`})]}),e[0]=t):t=e[0],t}function he({initial:e,builtinTools:t,zh:n}){let[r,i]=(0,N.useState)(`models`),[a,o]=(0,N.useState)(()=>structuredClone(e)),[s,c]=(0,N.useState)(()=>structuredClone(e)),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(null),h=JSON.stringify(a)!==JSON.stringify(s),g=[{id:`models`,label:n?`模型路由`:`Model routing`,summary:a.models.chat.primary.split(`/`).at(-1)??a.models.chat.primary,icon:E},{id:`skills`,label:n?`技能`:`Skills`,summary:a.skills.mode===`all-enabled`?n?`所有已启用`:`All enabled`:n?`已选 ${a.skills.include.length}`:`${a.skills.include.length} selected`,icon:A},{id:`tools`,label:n?`工具权限`:`Tool access`,summary:n?`${Object.values(a.tools).filter(e=>e.mode===`deny`).length} 个禁用`:`${Object.values(a.tools).filter(e=>e.mode===`deny`).length} denied`,icon:w},{id:`runtime`,label:n?`运行设置`:`Runtime`,summary:a.runtime.maxTurns?n?`最多 ${a.runtime.maxTurns} 轮`:`${a.runtime.maxTurns} turns`:n?`系统限制`:`System limits`,icon:T}],_=async()=>{let e=structuredClone(a);f(!0),m(null);try{let t=await x(e),n=structuredClone(t.defaults);o(t=>JSON.stringify(t)===JSON.stringify(e)?n:t),c(structuredClone(n))}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,P.jsxs)(M,{gap:`gap-5`,children:[(0,P.jsx)(j,{title:n?`Agent 默认配置`:`Agent defaults`,subtitle:n?`为所有 Agent 设置统一的能力基线;单个 Agent 只需配置不同之处。`:`Set one capability baseline for every agent; individual agents only configure what differs.`,actions:(0,P.jsxs)(P.Fragment,{children:[h?(0,P.jsx)(`span`,{className:`hidden text-xs text-amber-700 sm:inline dark:text-amber-300`,children:n?`有未保存的更改`:`Unsaved changes`}):null,h?(0,P.jsxs)(u,{onClick:()=>o(structuredClone(s)),children:[(0,P.jsx)(k,{className:`size-4`}),n?`撤销`:`Reset`]}):null,(0,P.jsx)(u,{variant:`primary`,disabled:d||!h,onClick:()=>void _(),children:d?n?`保存中…`:`Saving…`:n?`保存默认配置`:`Save defaults`})]})}),p?(0,P.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:p}):null,(0,P.jsx)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-accent/20 bg-accent/5 px-4 py-3`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n?`这些设置会影响谁?`:`Who uses these settings?`}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:n?`新 Agent 自动使用;已有 Agent 中未单独修改的项目也会同步更新。`:`New agents use them automatically, and existing agents update every setting they have not customized.`})]})}),(0,P.jsx)(`nav`,{className:`grid grid-cols-2 gap-2 rounded-2xl border border-edge bg-surface-base p-2 lg:grid-cols-4`,"aria-label":n?`默认配置分区`:`Default configuration sections`,children:g.map(({id:e,label:t,summary:n,icon:a})=>(0,P.jsxs)(`button`,{type:`button`,"aria-pressed":r===e,onClick:()=>i(e),className:l(`flex min-w-0 items-center gap-3 rounded-xl px-3 py-2.5 text-left transition-colors`,r===e?`bg-surface-panel text-fg shadow-surface ring-1 ring-edge`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,P.jsx)(a,{className:l(`size-4 shrink-0`,r===e?`text-accent`:`text-fg-subtle`)}),(0,P.jsxs)(`span`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`block text-sm font-medium`,children:t}),(0,P.jsx)(`span`,{className:`block truncate text-[11px] text-fg-subtle`,children:n})]})]},e))}),r===`models`?(0,P.jsx)(ce,{draft:a,setDraft:o,zh:n}):null,r===`skills`?(0,P.jsx)(J,{draft:a,setDraft:o,zh:n}):null,r===`tools`?(0,P.jsx)(X,{draft:a,setDraft:o,builtinTools:t,zh:n}):null,r===`runtime`?(0,P.jsx)(G,{draft:a,setDraft:o,zh:n}):null]})}function ge(){let e=(0,ie.c)(16),t=f(ve),n=d(_e)===`zh`,{data:r,error:i,isLoading:a,mutate:o}=m(t?`settings-agent-defaults`:null,v);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(M,{children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Gateway token required.`})}),e[0]=t):t=e[0],t}if(i&&!r){let t=String(i),r;e[1]===t?r=e[2]:(r=(0,P.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:t}),e[1]=t,e[2]=r);let a;e[3]===o?a=e[4]:(a=()=>void o(),e[3]=o,e[4]=a);let s=n?`重试`:`Retry`,c;e[5]!==a||e[6]!==s?(c=(0,P.jsx)(u,{onClick:a,children:s}),e[5]=a,e[6]=s,e[7]=c):c=e[7];let l;return e[8]!==r||e[9]!==c?(l=(0,P.jsxs)(M,{children:[r,c]}),e[8]=r,e[9]=c,e[10]=l):l=e[10],l}if(a||!r){let t;return e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(me,{}),e[11]=t):t=e[11],t}let s;return e[12]!==r.builtinTools||e[13]!==r.defaults||e[14]!==n?(s=(0,P.jsx)(he,{initial:r.defaults,builtinTools:r.builtinTools,zh:n}),e[12]=r.builtinTools,e[13]=r.defaults,e[14]=n,e[15]=s):s=e[15],s}function _e(e){return e.language}function ve(e){return e.token}export{ge as AgentDefaultsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{n as u,s as d}from"./locale-store-XDFAPNNu.js";import{t as f}from"./skeleton-BwbyijEw.js";import{i as p,o as m}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as h}from"./settings-shell-layer-context-DCp6ykjQ.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BPoKqzeH.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{Bs as w,Gn as T,Jn as E,Kn as D,No as O,bc as k,es as A,ps as j,qn as M,ra as N,tt as P,ul as ee,zo as F}from"./index-DKP23eMn.js";import{n as te,r as I}from"./settings-page-layout-BRQNel6r.js";var L=n(),R=e(t(),1),z=r(),B=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],V=`w-full rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function H(e){return[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))]}function U(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function W(e){let t=(0,L.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[10px] font-medium text-accent`,children:n}),t[0]=n,t[1]=r),r}function G(e){let t=(0,L.c)(10),{title:n,description:r,action:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,z.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,z.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==i||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[s,i]}),t[7]=i,t[8]=s,t[9]=c):c=t[9],c}function K(e){let t=(0,L.c)(10),{label:n,value:r,detail:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,z.jsx)(`p`,{className:`mt-2 truncate text-sm font-semibold text-fg`,title:r,children:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function q(e){let t=(0,L.c)(56),{label:n,inherited:r,value:i,zh:a,allowChatFallback:o,allowDisabled:s,onChange:c}=e,u=o===void 0?!1:o,d=s===void 0?!1:s,f=i!=null,p;t[0]===n?p=t[1]:(p=(0,z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=p);let m;t[2]!==i||t[3]!==a?(m=i===void 0?(0,z.jsx)(W,{children:a?`继承`:`Inherited`}):null,t[2]=i,t[3]=a,t[4]=m):m=t[4];let h;t[5]!==d||t[6]!==i||t[7]!==a?(h=i===null?(0,z.jsx)(W,{children:d?a?`已禁用`:`Disabled`:a?`使用 Chat`:`Uses Chat`}):null,t[5]=d,t[6]=i,t[7]=a,t[8]=h):h=t[8];let g;t[9]!==p||t[10]!==m||t[11]!==h?(g=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m,h]}),t[9]=p,t[10]=m,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==r?.primary||t[14]!==i||t[15]!==a?(_=i===void 0?(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-muted`,children:r?.primary??(a?`全局未配置`:`Not configured globally`)}):null,t[13]=r?.primary,t[14]=i,t[15]=a,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==c||t[21]!==i||t[22]!==a?(y=i===void 0?null:(0,z.jsx)(l,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>c(void 0),children:a?`继承`:`Inherit`}),t[20]=c,t[21]=i,t[22]=a,t[23]=y):y=t[23];let b;t[24]!==u||t[25]!==c||t[26]!==i||t[27]!==a?(b=u&&i!==null?(0,z.jsx)(l,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>c(null),children:a?`使用 Chat`:`Use Chat`}):null,t[24]=u,t[25]=c,t[26]=i,t[27]=a,t[28]=b):b=t[28];let x;t[29]!==d||t[30]!==c||t[31]!==i||t[32]!==a?(x=d&&i!==null?(0,z.jsx)(l,{variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>c(null),children:a?`禁用`:`Disable`}):null,t[29]=d,t[30]=c,t[31]=i,t[32]=a,t[33]=x):x=t[33];let S;t[34]!==f||t[35]!==r?.fallbacks||t[36]!==r?.primary||t[37]!==c||t[38]!==a?(S=f?null:(0,z.jsx)(l,{className:`px-2 py-1 text-xs`,onClick:()=>c({primary:r?.primary??``,fallbacks:[...r?.fallbacks??[]]}),children:a?`自定义`:`Customize`}),t[34]=f,t[35]=r?.fallbacks,t[36]=r?.primary,t[37]=c,t[38]=a,t[39]=S):S=t[39];let C;t[40]!==b||t[41]!==x||t[42]!==S||t[43]!==y?(C=(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[y,b,x,S]}),t[40]=b,t[41]=x,t[42]=S,t[43]=y,t[44]=C):C=t[44];let w;t[45]!==C||t[46]!==v?(w=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[v,C]}),t[45]=C,t[46]=v,t[47]=w):w=t[47];let T;t[48]!==f||t[49]!==c||t[50]!==i||t[51]!==a?(T=f?(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,0.8fr)]`,children:[(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[a?`主模型`:`Primary model`,(0,z.jsx)(`input`,{className:`${V} mt-1.5 font-mono`,value:i.primary,onChange:e=>c({...i,primary:e.target.value})})]}),(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[a?`回退模型`:`Fallbacks`,(0,z.jsx)(`input`,{className:`${V} mt-1.5 font-mono`,value:i.fallbacks.join(`, `),onChange:e=>c({...i,fallbacks:H(e.target.value)}),placeholder:a?`逗号分隔`:`Comma separated`})]})]}):null,t[48]=f,t[49]=c,t[50]=i,t[51]=a,t[52]=T):T=t[52];let E;return t[53]!==w||t[54]!==T?(E=(0,z.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[w,T]}),t[53]=w,t[54]=T,t[55]=E):E=t[55],E}function J(e){return Object.values(e).some(e=>e!==void 0)?e:void 0}function Y({agent:e,toolIds:t,zh:n,externalError:r,onDirtyChange:i,onClose:a,onOpenDefaults:o,onChat:s,onDelete:u}){let[d,f]=(0,R.useState)(`overview`),[p,m]=(0,R.useState)(()=>structuredClone(e.override)),[h,g]=(0,R.useState)(!1),[_,v]=(0,R.useState)(null),y=JSON.stringify(p)!==JSON.stringify(e.override),b=[p.models?.chat,...Object.values(p.models?.intents??{}),p.models?.imageUnderstanding,p.models?.imageGeneration].some(e=>e!=null&&!e.primary.trim());(0,R.useEffect)(()=>i(y),[y,i]);let x=(0,R.useMemo)(()=>[...new Set([...t,...Object.keys(e.effective.tools),...Object.keys(p.tools??{})])].sort(),[e.effective.tools,p.tools,t]),S=[p.models?n?`模型`:`Models`:null,p.skills?n?`技能`:`Skills`:null,p.tools?n?`工具权限`:`Tool access`:null,p.runtime||p.workflows?n?`运行限制`:`Runtime`:null].filter(e=>!!e),C=Object.values(e.effective.tools).filter(e=>e.mode===`deny`).length,T=e.effective.skills.mode===`selected`?n?`${e.effective.skills.include.length} 个已选技能`:`${e.effective.skills.include.length} selected skills`:n?`所有已启用技能`:`All enabled skills`,D=async()=>{g(!0),v(null);try{let t=(await E(e.id,{workspace:p.workspace??null,profile:p.profile,models:p.models??null,skills:p.skills??null,tools:p.tools??null,workflows:p.workflows??null,runtime:p.runtime??null})).agents.find(t=>t.id===e.id);t&&m(structuredClone(t.override))}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}},M=async()=>{g(!0),v(null);try{await E(e.id,{setDefault:!0})}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}},N=(e,t)=>{let n={...p.tools??{}};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},m({...p,tools:Object.keys(n).length>0?n:void 0})},P=(e,t)=>{let n={...p.models??{}},r={...n.intents??{}};t===void 0?delete r[e]:r[e]=t,Object.keys(r).length>0?n.intents=r:delete n.intents,m({...p,models:Object.keys(n).length>0?n:void 0})};return(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row`,children:[(0,z.jsx)(`aside`,{className:`shrink-0 overflow-x-auto border-b border-edge px-3 py-3 sm:w-52 sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-3 sm:py-4`,children:(0,z.jsx)(`nav`,{className:`flex gap-1 sm:flex-col`,children:[{id:`overview`,label:n?`概览`:`Overview`,icon:k},{id:`profile`,label:n?`个性`:`Profile`,icon:O},{id:`models`,label:n?`模型`:`Models`,icon:A},{id:`capabilities`,label:n?`技能与工具`:`Skills & tools`,icon:ee},{id:`runtime`,label:n?`运行限制`:`Runtime`,icon:k},{id:`danger`,label:n?`危险区`:`Danger zone`,icon:F}].map(({id:e,label:t,icon:n})=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>f(e),className:c(`flex shrink-0 items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm font-medium transition-colors`,d===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,z.jsx)(n,{className:`size-4`}),t]},e))})}),(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`main`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:[_||r?(0,z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:_??r}):null,d===`overview`?(0,z.jsxs)(`div`,{className:`space-y-6`,children:[(0,z.jsx)(G,{title:n?`配置概览`:`Configuration overview`,description:n?`查看当前真正生效的配置。Agent 未覆盖的部分会持续跟随全局默认值。`:`Review what actually takes effect. Anything not overridden keeps following global defaults.`,action:(0,z.jsxs)(l,{onClick:s,children:[(0,z.jsx)(w,{className:`size-4`}),n?`开始对话`:`Start chat`]})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 rounded-2xl border border-accent/20 bg-accent/5 p-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:S.length>0?n?`已自定义:${S.join(`、`)}`:`Customized: ${S.join(`, `)}`:n?`能力配置使用全局默认`:`Capabilities use global defaults`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:S.length>0?n?`其他能力会继续跟随全局默认配置。`:`All other capabilities continue to follow global defaults.`:n?`修改全局默认配置后,这个 Agent 会自动同步。`:`This agent updates automatically when global defaults change.`})]}),(0,z.jsx)(l,{onClick:o,children:n?`查看全局默认配置`:`View global defaults`})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(K,{label:n?`对话模型`:`Chat model`,value:e.effective.models.chat.primary,detail:p.models?.chat?n?`Agent 覆盖`:`Agent override`:n?`继承全局`:`Inherited globally`}),(0,z.jsx)(K,{label:n?`技能`:`Skills`,value:T,detail:p.skills?n?`Agent 覆盖`:`Agent override`:n?`继承全局`:`Inherited globally`}),(0,z.jsx)(K,{label:n?`工具权限`:`Tool access`,value:C>0?n?`${C} 个禁用`:`${C} denied`:n?`全部可用`:`All available`,detail:p.tools?n?`${Object.keys(p.tools).length} 个本地覆盖`:`${Object.keys(p.tools).length} local overrides`:n?`继承全局`:`Inherited globally`}),(0,z.jsx)(K,{label:n?`工作区`:`Workspace`,value:e.effective.workspace,detail:p.workspace?n?`Agent 自定义`:`Agent specific`:n?`自动工作区`:`Automatic workspace`})]}),e.isDefault?null:(0,z.jsx)(l,{onClick:()=>void M(),disabled:h,children:n?`设为默认 Agent`:`Make default agent`})]}):null,d===`profile`?(0,z.jsxs)(`div`,{className:`space-y-6`,children:[(0,z.jsx)(G,{title:n?`个性与工作区`:`Profile and workspace`,description:n?`这里只放这个 Agent 独有的身份、表达方式和工作目录。`:`Keep only this agent’s identity, behavior, and workspace here.`}),(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`名称`:`Name`,(0,z.jsx)(`input`,{className:`${V} mt-1.5`,value:p.profile?.name??``,onChange:e=>m({...p,profile:{name:e.target.value,...p.profile?.instructions?{instructions:p.profile.instructions}:{}}})})]}),(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[n?`工作区`:`Workspace`,p.workspace?null:(0,z.jsx)(W,{children:n?`自动`:`Automatic`})]}),(0,z.jsx)(`input`,{className:`${V} mt-1.5 font-mono`,value:p.workspace??``,placeholder:e.effective.workspace,onChange:e=>m({...p,workspace:e.target.value||void 0})})]})]}),(0,z.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n?`个性指令`:`Personality instructions`,(0,z.jsx)(`textarea`,{rows:10,className:`${V} mt-1.5 resize-y leading-6`,value:p.profile?.instructions??``,onChange:t=>m({...p,profile:{name:p.profile?.name||e.name,instructions:t.target.value||void 0}}),placeholder:n?`描述角色、语气、判断偏好和工作方式`:`Describe the role, tone, judgment preferences, and working style`})]})]}):null,d===`models`?(0,z.jsxs)(`div`,{className:`space-y-6`,children:[(0,z.jsx)(G,{title:n?`模型路由`:`Model routing`,description:n?`日常对话使用 Chat;固定意图只在对应任务中生效。默认继承全局。`:`Chat handles normal turns; fixed intents apply only to matching work. Everything inherits by default.`,action:p.models?(0,z.jsxs)(l,{variant:`ghost`,onClick:()=>m({...p,models:void 0}),children:[(0,z.jsx)(j,{className:`size-4`}),n?`全部继承`:`Inherit all`]}):void 0}),(0,z.jsx)(q,{label:`Chat`,inherited:e.effective.models.chat,value:p.models?.chat,zh:n,onChange:e=>{let t={...p.models??{}};e?t.chat=e:delete t.chat,m({...p,models:Object.keys(t).length>0?t:void 0})}}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n?`固定意图`:`Fixed intents`}),(0,z.jsx)(`div`,{className:`space-y-3`,children:B.map(t=>(0,z.jsx)(q,{label:t,inherited:e.effective.models.intents[t]??e.effective.models.chat,value:p.models?.intents?.[t],zh:n,allowChatFallback:!0,onChange:e=>P(t,e)},t))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n?`图片能力`:`Image capabilities`}),(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(q,{label:n?`图片理解`:`Image understanding`,inherited:e.effective.models.imageUnderstanding,value:p.models?.imageUnderstanding,zh:n,allowDisabled:!0,onChange:e=>{let t={...p.models??{}};e===void 0?delete t.imageUnderstanding:t.imageUnderstanding=e,m({...p,models:Object.keys(t).length>0?t:void 0})}}),(0,z.jsx)(q,{label:n?`图片生成`:`Image generation`,inherited:e.effective.models.imageGeneration,value:p.models?.imageGeneration,zh:n,allowDisabled:!0,onChange:t=>{let n={...p.models??{}};t===void 0?delete n.imageGeneration:t===null?n.imageGeneration=null:n.imageGeneration={...t,timeoutMs:p.models?.imageGeneration?.timeoutMs??e.effective.models.imageGeneration?.timeoutMs,autoProviderFallback:p.models?.imageGeneration?.autoProviderFallback??e.effective.models.imageGeneration?.autoProviderFallback??!0},m({...p,models:Object.keys(n).length>0?n:void 0})}}),p.models?.imageGeneration?(0,z.jsxs)(`div`,{className:`grid gap-4 rounded-2xl border border-edge bg-surface-base p-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,z.jsx)(`input`,{type:`number`,min:1,className:`${V} mt-1.5`,value:p.models.imageGeneration.timeoutMs??``,onChange:e=>m({...p,models:{...p.models,imageGeneration:{...p.models.imageGeneration,timeoutMs:U(e.target.value)}}})})]}),(0,z.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,z.jsx)(`span`,{children:n?`提供商自动回退`:`Automatic provider fallback`}),(0,z.jsx)(`div`,{className:`mt-1.5 flex rounded-xl bg-surface-hover p-1`,children:[!0,!1].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>m({...p,models:{...p.models,imageGeneration:{...p.models.imageGeneration,autoProviderFallback:e}}}),className:c(`flex-1 rounded-lg px-3 py-2 text-xs font-medium`,p.models?.imageGeneration?.autoProviderFallback===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted`),children:e?n?`开启`:`On`:n?`关闭`:`Off`},String(e)))})]})]}):null]})]})]}):null,d===`capabilities`?(0,z.jsxs)(`div`,{className:`space-y-7`,children:[(0,z.jsx)(G,{title:n?`技能与工具`:`Skills and tools`,description:n?`保持继承即可获得全局能力;只有确实不同的 Agent 才需要覆盖。`:`Keep inheritance for global capabilities; override only agents that genuinely differ.`}),(0,z.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`技能策略`:`Skill policy`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:p.skills?n?`当前使用 Agent 覆盖`:`Using an agent override`:n?`当前继承全局`:`Currently inherited globally`})]}),p.skills?(0,z.jsxs)(l,{variant:`ghost`,onClick:()=>m({...p,skills:void 0}),children:[(0,z.jsx)(j,{className:`size-4`}),n?`继承`:`Inherit`]}):null]}),(0,z.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,z.jsx)(l,{variant:p.skills?.mode===`merge`?`primary`:`secondary`,onClick:()=>m({...p,skills:{mode:`merge`,add:[],remove:[]}}),children:`Merge`}),(0,z.jsx)(l,{variant:p.skills?.mode===`replace`?`primary`:`secondary`,onClick:()=>m({...p,skills:{mode:`replace`,include:[]}}),children:`Replace`})]}),p.skills?.mode===`merge`?(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`新增技能`:`Add skills`,(0,z.jsx)(`input`,{className:`${V} mt-1.5`,value:p.skills.add.join(`, `),onChange:e=>m({...p,skills:{mode:`merge`,add:H(e.target.value),remove:p.skills?.mode===`merge`?p.skills.remove:[]}})})]}),(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`移除技能`:`Remove skills`,(0,z.jsx)(`input`,{className:`${V} mt-1.5`,value:p.skills.remove.join(`, `),onChange:e=>m({...p,skills:{mode:`merge`,add:p.skills?.mode===`merge`?p.skills.add:[],remove:H(e.target.value)}})})]})]}):null,p.skills?.mode===`replace`?(0,z.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[n?`仅启用这些技能`:`Enable only these skills`,(0,z.jsx)(`input`,{className:`${V} mt-1.5`,value:p.skills.include.join(`, `),onChange:e=>m({...p,skills:{mode:`replace`,include:H(e.target.value)}})})]}):null]}),(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`工具权限`:`Tool permissions`}),p.tools?(0,z.jsxs)(l,{variant:`ghost`,onClick:()=>m({...p,tools:void 0}),children:[(0,z.jsx)(j,{className:`size-4`}),n?`全部继承`:`Inherit all`]}):null]}),(0,z.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-2xl border border-edge bg-surface-base`,children:x.map(t=>{let r=p.tools?.[t]?.mode,i=e.effective.tools[t]?.mode??`allow`;return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`code`,{className:`text-xs text-fg`,children:t}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:r?n?`Agent 覆盖`:`Agent override`:`${n?`继承`:`Inherits`} ${i}`})]}),(0,z.jsx)(`div`,{className:`flex rounded-xl bg-surface-hover p-1`,children:[`inherit`,`allow`,`ask`,`deny`].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>N(t,e),className:c(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,(e===`inherit`?!r:r===e)?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),children:e},e))})]},t)})})]})]}):null,d===`runtime`?(0,z.jsxs)(`div`,{className:`space-y-6`,children:[(0,z.jsx)(G,{title:n?`运行限制`:`Runtime limits`,description:n?`留空即继承全局限制。这里适合为特殊 Agent 收紧或放宽执行边界。`:`Leave blank to inherit global limits. Use overrides only to tighten or relax a specialist agent.`,action:p.runtime||p.workflows?(0,z.jsxs)(l,{variant:`ghost`,onClick:()=>m({...p,runtime:void 0,workflows:void 0}),children:[(0,z.jsx)(j,{className:`size-4`}),n?`全部继承`:`Inherit all`]}):void 0}),(0,z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[[`maxTurns`,n?`单次最大轮数`:`Maximum turns`],[`timeoutMs`,n?`单轮超时(毫秒)`:`Turn timeout (ms)`],[`maxToolFailuresPerTurn`,n?`最大工具失败次数`:`Maximum tool failures`]].map(([t,r])=>(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[r,p.runtime?.[t]===void 0?(0,z.jsx)(W,{children:n?`继承`:`Inherited`}):null]}),(0,z.jsx)(`input`,{type:`number`,min:1,className:`${V} mt-1.5`,value:p.runtime?.[t]??``,placeholder:String(e.effective.runtime[t]??``),onChange:e=>{let n=J({...p.runtime??{},[t]:U(e.target.value)});m({...p,runtime:n})}})]},t))}),(0,z.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`工作流`:`Workflows`}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`默认工作流`:`Default workflow`,(0,z.jsx)(`input`,{className:`${V} mt-1.5`,value:p.workflows?.default??``,placeholder:e.effective.workflows.default,onChange:e=>{let t=J({...p.workflows??{},default:e.target.value||void 0});m({...p,workflows:t})}})]}),(0,z.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[n?`允许的工作流`:`Allowed workflows`,(0,z.jsx)(`input`,{className:`${V} mt-1.5`,value:p.workflows?.allowed?.join(`, `)??``,placeholder:e.effective.workflows.allowed?.join(`, `),onChange:e=>{let t=H(e.target.value),n=J({...p.workflows??{},allowed:t.length>0?t:void 0});m({...p,workflows:n})}})]})]})]}),(0,z.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`提示词缓存`:`Prompt cache`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:p.runtime?.promptCache?n?`使用 Agent 覆盖`:`Using agent override`:n?`继承全局`:`Inherited globally`})]}),p.runtime?.promptCache?(0,z.jsxs)(l,{variant:`ghost`,onClick:()=>{let e=J({...p.runtime??{},promptCache:void 0});m({...p,runtime:e})},children:[(0,z.jsx)(j,{className:`size-4`}),n?`继承`:`Inherit`]}):null]}),p.runtime?.promptCache?(0,z.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,z.jsx)(`span`,{children:n?`模式`:`Mode`}),(0,z.jsx)(`div`,{className:`mt-1.5 flex rounded-xl bg-surface-hover p-1`,children:[`auto`,`off`].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>m({...p,runtime:{...p.runtime,promptCache:{...p.runtime.promptCache,mode:e}}}),className:c(`flex-1 rounded-lg px-3 py-2 text-xs font-medium`,p.runtime?.promptCache?.mode===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted`),children:e},e))})]}),(0,z.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,z.jsx)(`span`,{children:n?`缓存周期`:`Lifetime`}),(0,z.jsx)(`div`,{className:`mt-1.5 flex rounded-xl bg-surface-hover p-1`,children:[`short`,`long`].map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>m({...p,runtime:{...p.runtime,promptCache:{...p.runtime.promptCache,lifetime:e}}}),className:c(`flex-1 rounded-lg px-3 py-2 text-xs font-medium`,p.runtime?.promptCache?.lifetime===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted`),children:e},e))})]})]}):(0,z.jsx)(l,{className:`mt-4`,onClick:()=>m({...p,runtime:{...p.runtime,promptCache:{...e.effective.runtime.promptCache??{mode:`auto`,lifetime:`short`}}}}),children:n?`自定义缓存策略`:`Customize cache policy`})]})]}):null,d===`danger`?(0,z.jsxs)(`div`,{className:`space-y-6`,children:[(0,z.jsx)(G,{title:n?`危险区`:`Danger zone`,description:n?`这些操作会改变默认路由或移除 Agent。`:`These actions change default routing or remove the agent.`}),e.isDefault?null:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:n?`设为默认 Agent`:`Make default agent`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`新会话和未指定路由将使用这个 Agent。`:`New sessions and unspecified routes will use this agent.`})]}),(0,z.jsx)(l,{disabled:h,onClick:()=>void M(),children:n?`设为默认`:`Make default`})]}),e.isDefault?(0,z.jsx)(`p`,{className:`rounded-2xl bg-surface-base p-4 text-sm text-fg-muted`,children:n?`默认 Agent 不能删除,请先将其他 Agent 设为默认。`:`The default agent cannot be deleted. Make another agent the default first.`}):(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-2xl border border-red-500/25 bg-red-500/5 p-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{className:`text-sm font-semibold text-red-600`,children:n?`删除 Agent`:`Delete agent`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`配置条目会被移除,删除前仍会再次确认。`:`The configuration entry will be removed after confirmation.`})]}),(0,z.jsxs)(l,{variant:`ghost`,className:`text-red-600`,onClick:u,children:[(0,z.jsx)(F,{className:`size-4`}),n?`删除`:`Delete`]})]})]}):null]}),(0,z.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge bg-surface-panel px-5 py-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:b?n?`请补全自定义模型`:`Complete the custom model reference`:y?n?`有未保存的更改`:`Unsaved changes`:n?`所有更改已保存`:`All changes saved`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(l,{onClick:a,children:n?`关闭`:`Close`}),(0,z.jsx)(l,{variant:`primary`,disabled:h||!y||b||p.profile!==void 0&&!p.profile.name.trim(),onClick:()=>void D(),children:h?n?`保存中…`:`Saving…`:n?`保存更改`:`Save changes`})]})]})]})]})}function ne(e){let t=(0,L.c)(29),{agent:n,open:r,onOpenChange:i,children:a}=e,[o,l]=(0,R.useState)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(g,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim`,m)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=c(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover`,p,`inset-3 h-[calc(100dvh-1.5rem)] min-h-0 sm:inset-auto sm:left-1/2 sm:top-1/2`,`sm:h-[min(88vh,48rem)] sm:w-[min(94vw,62rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=d):d=t[1];let f;t[2]!==n.avatar||t[3]!==n.id?(f=(0,z.jsx)(P,{agentId:n.id,avatar:n.avatar,size:42,className:`size-11 shrink-0`}),t[2]=n.avatar,t[3]=n.id,t[4]=f):f=t[4];let C;t[5]===n.name?C=t[6]:(C=(0,z.jsx)(x,{className:`truncate text-base font-semibold text-fg`,children:n.name}),t[5]=n.name,t[6]=C);let w;t[7]===n.id?w=t[8]:(w=(0,z.jsx)(_,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,children:n.id}),t[7]=n.id,t[8]=w);let T;t[9]!==C||t[10]!==w?(T=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[9]=C,t[10]=w,t[11]=T):T=t[11];let E;t[12]===n.isDefault?E=t[13]:(E=n.isDefault?(0,z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent`,children:`DEFAULT`}):null,t[12]=n.isDefault,t[13]=E);let D;t[14]!==f||t[15]!==T||t[16]!==E?(D=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[f,T,E]}),t[14]=f,t[15]=T,t[16]=E,t[17]=D):D=t[17];let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,z.jsx)(v,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`Close`,children:(0,z.jsx)(s,{className:`size-4`})})}),t[18]=O):O=t[18];let k;t[19]===D?k=t[20]:(k=(0,z.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-4 border-b border-edge px-5 py-4`,children:[D,O]}),t[19]=D,t[20]=k);let A;t[21]!==a||t[22]!==o||t[23]!==k?(A=(0,z.jsxs)(y,{children:[u,(0,z.jsx)(b,{ref:l,className:d,onOpenAutoFocus:X,children:(0,z.jsxs)(h,{layer:`modal`,portalContainer:o,children:[k,a]})})]}),t[21]=a,t[22]=o,t[23]=k,t[24]=A):A=t[24];let j;return t[25]!==i||t[26]!==r||t[27]!==A?(j=(0,z.jsx)(S,{open:r,onOpenChange:i,children:A}),t[25]=i,t[26]=r,t[27]=A,t[28]=j):j=t[28],j}function X(e){return e.preventDefault()}function Z(e,t){let n=Object.values(e.effective.tools).filter(e=>e.mode===`deny`).length,r=e.effective.skills;return[r.mode===`selected`?t?`${r.include.length} 个技能`:`${r.include.length} skills`:r.exclude.length>0?t?`全部技能,排除 ${r.exclude.length}`:`All skills, ${r.exclude.length} excluded`:t?`全部技能`:`All skills`,n>0?t?`${n} 个工具禁用`:`${n} tools denied`:t?`工具全部可用`:`All tools available`]}function Q(e){let t=(0,L.c)(13),{agents:n,busy:r,zh:i,onOpen:a,onChat:o}=e,s;if(t[0]!==n||t[1]!==r||t[2]!==o||t[3]!==a||t[4]!==i){let e;t[6]!==r||t[7]!==o||t[8]!==a||t[9]!==i?(e=e=>{let t=Z(e,i);return(0,z.jsx)(`li`,{className:`min-h-0`,children:(0,z.jsxs)(`article`,{className:c(`group relative flex min-h-64 flex-col rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,`transition duration-150 hover:-translate-y-0.5 hover:border-accent/30 hover:bg-surface-hover/35`),children:[(0,z.jsx)(`button`,{type:`button`,disabled:r,"aria-label":i?`配置 ${e.name}`:`Configure ${e.name}`,onClick:()=>a(e.id),className:`absolute inset-0 z-0 rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,z.jsxs)(`div`,{className:`pointer-events-none relative z-10 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,z.jsx)(P,{agentId:e.id,avatar:e.avatar,size:48,className:`size-12 shrink-0`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,children:e.id})]})]}),(0,z.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.isDefault?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`),children:e.isDefault?`DEFAULT`:i?`自定义`:`CUSTOM`})]}),(0,z.jsx)(`p`,{className:`pointer-events-none relative z-10 mt-5 line-clamp-2 min-h-10 text-sm leading-5 text-fg-muted`,children:e.description||e.override.profile?.instructions||(i?`继承全局能力,仅保存这个 Agent 的差异。`:`Inherits global capabilities and stores only this agent’s differences.`)}),(0,z.jsxs)(`div`,{className:`pointer-events-none relative z-10 mt-4 rounded-xl bg-surface-base px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:i?`当前模型`:`Current model`}),(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg`,children:e.effective.models.chat.primary})]}),(0,z.jsx)(`div`,{className:`pointer-events-none relative z-10 mt-3 flex flex-wrap gap-1.5`,children:t.map($)}),(0,z.jsx)(`div`,{className:`relative z-10 mt-auto pt-4`,children:(0,z.jsxs)(l,{className:`w-full`,disabled:r,onClick:t=>{t.stopPropagation(),o(e.id)},children:[(0,z.jsx)(w,{className:`size-4`}),i?`与这个 Agent 对话`:`Chat with this agent`]})})]})},e.id)},t[6]=r,t[7]=o,t[8]=a,t[9]=i,t[10]=e):e=t[10],s=n.map(e),t[0]=n,t[1]=r,t[2]=o,t[3]=a,t[4]=i,t[5]=s}else s=t[5];let u;return t[11]===s?u=t[12]:(u=(0,z.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:s}),t[11]=s,t[12]=u),u}function $(e){return(0,z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e)}var re=`w-full rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function ie(e){let t=(0,L.c)(59),{open:n,busy:r,error:i,name:a,instructions:o,zh:u,onNameChange:d,onInstructionsChange:f,onCreate:h,onOpenChange:C}=e,w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,z.jsx)(g,{className:c(`xopc-dialog-overlay fixed inset-0 bg-scrim`,m)}),t[0]=w):w=t[0];let T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=c(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(92vw,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover`,p),t[1]=T):T=t[1];let E=u?`新建 Agent`:`Create agent`,D;t[2]===E?D=t[3]:(D=(0,z.jsx)(x,{className:`text-base font-semibold text-fg`,children:E}),t[2]=E,t[3]=D);let O=u?`只设置身份即可开始,所有能力自动继承全局配置。`:`Set its identity and start. Every capability inherits globally.`,k;t[4]===O?k=t[5]:(k=(0,z.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:O}),t[4]=O,t[5]=k);let A;t[6]!==D||t[7]!==k?(A=(0,z.jsxs)(`div`,{children:[D,k]}),t[6]=D,t[7]=k,t[8]=A):A=t[8];let j;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,z.jsx)(v,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover`,"aria-label":`Close`,children:(0,z.jsx)(s,{className:`size-4`})})}),t[9]=j):j=t[9];let M;t[10]===A?M=t[11]:(M=(0,z.jsxs)(`header`,{className:`flex items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[A,j]}),t[10]=A,t[11]=M);let N;t[12]===i?N=t[13]:(N=i?(0,z.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:i}):null,t[12]=i,t[13]=N);let P=u?`名称`:`Name`,ee=u?`Agent 名称`:`Agent name`,F;t[14]===d?F=t[15]:(F=e=>d(e.target.value),t[14]=d,t[15]=F);let te=u?`例如:数据分析师`:`For example: Data analyst`,I;t[16]!==a||t[17]!==ee||t[18]!==F||t[19]!==te?(I=(0,z.jsx)(`input`,{id:`create-agent-name`,"aria-label":ee,className:`${re} mt-1.5`,value:a,onChange:F,placeholder:te}),t[16]=a,t[17]=ee,t[18]=F,t[19]=te,t[20]=I):I=t[20];let R;t[21]!==P||t[22]!==I?(R=(0,z.jsxs)(`label`,{htmlFor:`create-agent-name`,className:`block text-xs font-medium text-fg-muted`,children:[P,I]}),t[21]=P,t[22]=I,t[23]=R):R=t[23];let B=u?`个性与工作方式(可选)`:`Personality and working style (optional)`,V=u?`个性与工作方式`:`Personality and working style`,H;t[24]===f?H=t[25]:(H=e=>f(e.target.value),t[24]=f,t[25]=H);let U=u?`描述角色、语气和偏好的工作方式`:`Describe its role, tone, and preferred way of working`,W;t[26]!==o||t[27]!==V||t[28]!==H||t[29]!==U?(W=(0,z.jsx)(`textarea`,{id:`create-agent-instructions`,"aria-label":V,rows:4,className:`${re} mt-1.5 resize-none`,value:o,onChange:H,placeholder:U}),t[26]=o,t[27]=V,t[28]=H,t[29]=U,t[30]=W):W=t[30];let G;t[31]!==B||t[32]!==W?(G=(0,z.jsxs)(`label`,{htmlFor:`create-agent-instructions`,className:`block text-xs font-medium text-fg-muted`,children:[B,W]}),t[31]=B,t[32]=W,t[33]=G):G=t[33];let K;t[34]!==N||t[35]!==R||t[36]!==G?(K=(0,z.jsxs)(`div`,{className:`space-y-4 p-5`,children:[N,R,G]}),t[34]=N,t[35]=R,t[36]=G,t[37]=K):K=t[37];let q=u?`取消`:`Cancel`,J;t[38]!==r||t[39]!==q?(J=(0,z.jsx)(v,{asChild:!0,children:(0,z.jsx)(l,{disabled:r,children:q})}),t[38]=r,t[39]=q,t[40]=J):J=t[40];let Y;t[41]!==r||t[42]!==a?(Y=r||!a.trim(),t[41]=r,t[42]=a,t[43]=Y):Y=t[43];let ne=r?u?`创建中…`:`Creating…`:u?`创建 Agent`:`Create agent`,X;t[44]!==h||t[45]!==Y||t[46]!==ne?(X=(0,z.jsx)(l,{variant:`primary`,disabled:Y,onClick:h,children:ne}),t[44]=h,t[45]=Y,t[46]=ne,t[47]=X):X=t[47];let Z;t[48]!==J||t[49]!==X?(Z=(0,z.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[J,X]}),t[48]=J,t[49]=X,t[50]=Z):Z=t[50];let Q;t[51]!==K||t[52]!==Z||t[53]!==M?(Q=(0,z.jsxs)(y,{children:[w,(0,z.jsxs)(b,{className:T,children:[M,K,Z]})]}),t[51]=K,t[52]=Z,t[53]=M,t[54]=Q):Q=t[54];let $;return t[55]!==C||t[56]!==n||t[57]!==Q?($=(0,z.jsx)(S,{open:n,onOpenChange:C,children:Q}),t[55]=C,t[56]=n,t[57]=Q,t[58]=$):$=t[58],$}function ae(){let e=(0,L.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(f,{className:`h-7 w-28`}),(0,z.jsx)(f,{className:`h-4 w-80 max-w-full`})]}),(0,z.jsx)(f,{className:`h-9 w-28`})]}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsxs)(I,{gap:`gap-5`,children:[t,(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(oe)})]}),e[1]=n):n=e[1],n}function oe(e){return(0,z.jsx)(f,{className:`h-64 rounded-2xl`},e)}function se(){let e=d(e=>e.token),t=u(e=>e.language)===`zh`,n=a(),{agentId:r}=i(),{data:s,error:c,isLoading:f,mutate:p}=C(e?`settings-gateway-agents`:null,M),[m,h]=(0,R.useState)({open:!1,name:``,instructions:``}),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),b=(0,R.useRef)(!1),x=s?.agents.find(e=>e.id===r),S=async()=>{_(!0),y(null);try{let e=await T({profile:{name:m.name.trim(),...m.instructions.trim()?{instructions:m.instructions.trim()}:{}}});h({open:!1,name:``,instructions:``}),n(`/agents/${e.createdAgentId}`)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}},w=async e=>{if(window.confirm(t?`删除 ${e.name}?此操作无法撤销。`:`Delete ${e.name}? This cannot be undone.`)){_(!0),y(null);try{await D(e.id),n(`/agents`)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},E=e=>{N(e),n(`/chat/new`)},O=e=>{b.current=!1,window.setTimeout(()=>n(`/agents/${e}`),0)},k=()=>{b.current&&!window.confirm(t?`放弃未保存的更改?`:`Discard unsaved changes?`)||(b.current=!1,n(`/agents`))},A=()=>{b.current&&!window.confirm(t?`放弃未保存的更改?`:`Discard unsaved changes?`)||(b.current=!1,n(`/settings/agent-defaults`))},j=(0,R.useCallback)(e=>{b.current=e},[]);return e?c&&!s?(0,z.jsxs)(I,{children:[(0,z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:String(c)}),(0,z.jsx)(l,{onClick:()=>void p(),children:t?`重试`:`Retry`})]}):f||!s?(0,z.jsx)(ae,{}):(0,z.jsxs)(I,{gap:`gap-5`,children:[(0,z.jsx)(te,{title:`Agents`,subtitle:t?`所有 Agent 默认继承全局能力;这里只配置身份和必要差异。`:`Every agent inherits global capabilities; configure only identity and necessary differences here.`,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(l,{onClick:()=>n(`/settings/agent-defaults`),children:t?`全局默认配置`:`Global defaults`}),(0,z.jsxs)(l,{variant:`primary`,onClick:()=>{y(null),h(e=>({...e,open:!0}))},children:[(0,z.jsx)(o,{className:`size-4`}),t?`新建 Agent`:`New agent`]})]})}),(c||v)&&!x?(0,z.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v??String(c)}):null,(0,z.jsx)(Q,{agents:s.agents,busy:g,zh:t,onOpen:O,onChat:E}),x?(0,z.jsx)(ne,{agent:x,open:!0,onOpenChange:e=>{e||k()},children:(0,z.jsx)(Y,{agent:x,toolIds:s.builtinToolIds,zh:t,externalError:v,onDirtyChange:j,onClose:k,onOpenDefaults:A,onChat:()=>E(x.id),onDelete:()=>void w(x)},x.id)}):null,(0,z.jsx)(ie,{open:m.open,busy:g,error:v,name:m.name,instructions:m.instructions,zh:t,onNameChange:e=>h(t=>({...t,name:e})),onInstructionsChange:e=>h(t=>({...t,instructions:e})),onCreate:()=>void S(),onOpenChange:e=>{g||(h(t=>({...t,open:e})),e||y(null))}})]}):(0,z.jsx)(I,{children:(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Gateway token required.`})})}export{se as AgentsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i,t as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./markdown-view-v-O3cOpk.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./search-DA7gz22f.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./cn-JdwAhgNB.js";import{t as m}from"./button-CSEbl4zT.js";import{t as h}from"./messages-B1HDp_j8.js";import{a as g,i as _,n as v,r as y,s as b}from"./locale-store-XDFAPNNu.js";import{t as x}from"./skeleton-BwbyijEw.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./dist-BPoKqzeH.js";import{a as O,i as k}from"./vendor-swr-BIWyz7Rc.js";import{Aa as A,Bo as j,Ta as M,Zc as N,_a as P,as as ee,ba as F,cs as I,ha as L,js as R,ll as z,sa as B,va as V,ya as H,yl as te,zo as ne}from"./index-DKP23eMn.js";import{t as U}from"./page-tabs-BaEQMYm_.js";var W=e(t(),1),G=n();function K(e){return e===`builtin`||e===`user`?e:`marketplace`}async function q(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function re(e){let t=await _(y(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await _(y(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function Y(e){let t=await _(y(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function X(e){let t=await _(y(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Z=r();function ie(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Q={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function $({className:e}){let t=h(v(e=>e.language)).extensionsPage,n=b(e=>!!e.token),r=P(),{mutate:i}=O(),[a,o]=(0,W.useReducer)(B,Q),{q:s,debounced:c,detailPkg:u,rowBusy:f,actionError:m,restartHint:_}=a,S=n?`marketplace-${c}`:null;(0,W.useEffect)(()=>{let e=window.setTimeout(()=>o({type:`patch`,patch:{debounced:s.trim()}}),300);return()=>window.clearTimeout(e)},[s]);let{data:C,isLoading:w,error:T}=k(S,async()=>g(c.length>0?y(`/api/marketplace?q=${encodeURIComponent(c)}`):y(`/api/marketplace`)),{revalidateOnFocus:!1}),E=(0,W.useCallback)(()=>{i(`gateway-extensions-list`),M()},[i]),D=(0,W.useCallback)(async(e,n)=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await J({name:e,overwrite:n});E(),r.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,E]),A=(0,W.useCallback)(async e=>{o({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await X(e);E(),n.requiresGatewayRestart&&o({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{o({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,E]),ee=C?.extensions??[];return(0,Z.jsxs)(`div`,{className:p(`flex flex-col gap-4`,e),children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:s,onChange:e=>o({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),T?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:T instanceof Error?T.message:t.marketplaceLoadFailed}):null,m?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,_?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_}):null,w&&!C?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,Z.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,Z.jsx)(x,{className:`h-5 w-40`}),(0,Z.jsx)(x,{className:`h-4 w-full max-w-xl`}),(0,Z.jsx)(x,{className:`h-4 w-2/3 max-w-md`})]}),(0,Z.jsx)(x,{className:`h-8 w-20`})]})},e))}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:ee.length===0?(0,Z.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):ee.map(e=>{let n=ie(r,e.id),i=f===e.id;return(0,Z.jsx)(`li`,{className:`list-none`,children:(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o({type:`patch`,patch:{detailPkg:e.id}}))},className:p(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Z.jsx)(N,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Z.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(R,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Z.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&A(e.id).catch(()=>{})},className:p(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(j,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>o({type:`patch`,patch:{detailPkg:e.id}}),className:p(`inline-flex w-full items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:t.marketplaceReview})})]})},e.id)})}),u?(0,Z.jsx)(ae,{packageName:u,copy:t,extensions:r,onClose:()=>o({type:`patch`,patch:{detailPkg:null}}),onInstall:D,onUninstall:A}):null]})}function ae(e){let t=(0,G.c)(102),{packageName:n,copy:r,extensions:i,onClose:o,onInstall:s,onUninstall:u}=e,[d,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),_=b(ue)?`ext-mp-detail-${n}`:null,v;t[0]===n?v=t[1]:(v=async()=>re(n),t[0]=n,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},t[2]=y):y=t[2];let{data:C,error:O,isLoading:A}=k(_,v,y),M;t[3]!==i||t[4]!==n?(M=ie(i,n),t[3]=i,t[4]=n,t[5]=M):M=t[5];let N=M,P=N===`user`,F=C?.manifest?.permissions,I,L,R,z,B,V,H,U,K,q,J;if(t[6]!==r.detailBack||t[7]!==r.detailClose||t[8]!==r.marketplaceAuthor||t[9]!==r.marketplaceCodeRisk||t[10]!==r.marketplaceDependencies||t[11]!==r.marketplaceDetailLoadFailed||t[12]!==r.marketplaceDetailReadmeHeading||t[13]!==r.marketplaceDetailTitle||t[14]!==r.marketplaceDownloads||t[15]!==r.marketplaceIntegrity||t[16]!==r.marketplaceIntegrityVerified||t[17]!==r.marketplaceLifecycleScripts||t[18]!==r.marketplaceLoadFailed||t[19]!==r.marketplaceLoading||t[20]!==r.marketplaceNoReadme||t[21]!==r.marketplacePermissions||t[22]!==r.marketplacePermissionsNone||t[23]!==r.marketplaceRiskConfirm||t[24]!==r.marketplaceRiskTitle||t[25]!==r.marketplaceUnavailableBody||t[26]!==r.marketplaceUnavailableTitle||t[27]!==r.marketplaceVersion||t[28]!==C||t[29]!==O||t[30]!==N||t[31]!==A||t[32]!==o||t[33]!==F||t[34]!==h){let e=F&&typeof F==`object`&&!Array.isArray(F)?Object.entries(F):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==C?(n=C?.readme?.trim()||(C?.description?.trim()?`### ${C.name}\n\n${C.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=C,t[48]=n):n=t[48];let i=n;R=D,z=!0,t[49]===o?B=t[50]:(B=e=>!e&&o(),t[49]=o,t[50]=B),L=w,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=J):J=t[51],I=T,U=`fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,K=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(te,{className:`size-5`}),t[52]=a):a=t[52];let s;t[53]!==r.detailBack||t[54]!==o?(s=(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:a}),t[53]=r.detailBack,t[54]=o,t[55]=s):s=t[55];let l;t[56]===r.marketplaceDetailTitle?l=t[57]:(l=(0,Z.jsx)(E,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=l);let u;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(f,{className:`size-5`}),t[58]=u):u=t[58];let d;t[59]!==r.detailClose||t[60]!==o?(d=(0,Z.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:u}),t[59]=r.detailClose,t[60]=o,t[61]=d):d=t[61],t[62]!==s||t[63]!==l||t[64]!==d?(q=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[s,l,d]}),t[62]=s,t[63]=l,t[64]=d,t[65]=q):q=t[65],V=`min-h-0 flex-1 overflow-y-auto p-5`,H=A&&!C?(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,Z.jsx)(x,{className:`h-6 w-48`}),(0,Z.jsx)(x,{className:`h-4 w-28`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(x,{className:`h-12`}),(0,Z.jsx)(x,{className:`h-12`})]}),(0,Z.jsx)(x,{className:`h-28 w-full`}),(0,Z.jsx)(x,{className:`h-36 w-full`})]}):O?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:O instanceof Error?O.message:r.marketplaceLoadFailed})]}):C?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:C.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:C.id})}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Z.jsx)(`dd`,{children:C.author.username})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Z.jsx)(`dd`,{children:C.latestVersion.version})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Z.jsx)(`dd`,{children:C.downloads})]})]}),N===`bundled`?null:(0,Z.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[C.installability.available?(0,Z.jsx)(ee,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(ne,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:C.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:C.installability.available?r.marketplaceCodeRisk:C.installability.reason??r.marketplaceUnavailableBody})]})]}),C.installability.available?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,Z.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,Z.jsx)(`dd`,{children:C.packageSummary?.dependencyCount??0})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,Z.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(C.packageSummary?.lifecycleScripts.length??0)>0?(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,C.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,Z.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),C.readme?.trim()?(0,Z.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Z.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Z.jsx)(c,{content:i})})]}):null,t[6]=r.detailBack,t[7]=r.detailClose,t[8]=r.marketplaceAuthor,t[9]=r.marketplaceCodeRisk,t[10]=r.marketplaceDependencies,t[11]=r.marketplaceDetailLoadFailed,t[12]=r.marketplaceDetailReadmeHeading,t[13]=r.marketplaceDetailTitle,t[14]=r.marketplaceDownloads,t[15]=r.marketplaceIntegrity,t[16]=r.marketplaceIntegrityVerified,t[17]=r.marketplaceLifecycleScripts,t[18]=r.marketplaceLoadFailed,t[19]=r.marketplaceLoading,t[20]=r.marketplaceNoReadme,t[21]=r.marketplacePermissions,t[22]=r.marketplacePermissionsNone,t[23]=r.marketplaceRiskConfirm,t[24]=r.marketplaceRiskTitle,t[25]=r.marketplaceUnavailableBody,t[26]=r.marketplaceUnavailableTitle,t[27]=r.marketplaceVersion,t[28]=C,t[29]=O,t[30]=N,t[31]=A,t[32]=o,t[33]=F,t[34]=h,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=B,t[40]=V,t[41]=H,t[42]=U,t[43]=K,t[44]=q,t[45]=J}else I=t[35],L=t[36],R=t[37],z=t[38],B=t[39],V=t[40],H=t[41],U=t[42],K=t[43],q=t[44],J=t[45];let Y;t[66]!==V||t[67]!==H?(Y=(0,Z.jsx)(`div`,{className:V,children:H}),t[66]=V,t[67]=H,t[68]=Y):Y=t[68];let X;t[69]!==d||t[70]!==r.marketplaceBuiltinGoBuiltin||t[71]!==r.marketplaceBuiltinManageHint||t[72]!==r.marketplaceInstall||t[73]!==r.marketplaceReinstall||t[74]!==r.marketplaceReinstallConfirm||t[75]!==r.marketplaceUninstall||t[76]!==r.marketplaceUninstallConfirm||t[77]!==C||t[78]!==N||t[79]!==o||t[80]!==s||t[81]!==u||t[82]!==n||t[83]!==h||t[84]!==P?(X=C?(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:N===`bundled`?(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Z.jsx)(a,{to:`/extensions?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:d||!C.installability.available||!h,onClick:()=>{P&&!window.confirm(r.marketplaceReinstallConfirm)||(m(!0),s(n,P).catch(se).finally(()=>m(!1)))},className:p(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[d?(0,Z.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,P?r.marketplaceReinstall:r.marketplaceInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(m(!0),u(n).then(()=>o()).catch(oe).finally(()=>m(!1)))},className:p(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Z.jsx)(j,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=d,t[70]=r.marketplaceBuiltinGoBuiltin,t[71]=r.marketplaceBuiltinManageHint,t[72]=r.marketplaceInstall,t[73]=r.marketplaceReinstall,t[74]=r.marketplaceReinstallConfirm,t[75]=r.marketplaceUninstall,t[76]=r.marketplaceUninstallConfirm,t[77]=C,t[78]=N,t[79]=o,t[80]=s,t[81]=u,t[82]=n,t[83]=h,t[84]=P,t[85]=X):X=t[85];let Q;t[86]!==I||t[87]!==Y||t[88]!==X||t[89]!==U||t[90]!==K||t[91]!==q?(Q=(0,Z.jsxs)(I,{className:U,onOpenAutoFocus:K,children:[q,Y,X]}),t[86]=I,t[87]=Y,t[88]=X,t[89]=U,t[90]=K,t[91]=q,t[92]=Q):Q=t[92];let $;t[93]!==L||t[94]!==Q||t[95]!==J?($=(0,Z.jsxs)(L,{children:[J,Q]}),t[93]=L,t[94]=Q,t[95]=J,t[96]=$):$=t[96];let ae;return t[97]!==R||t[98]!==z||t[99]!==B||t[100]!==$?(ae=(0,Z.jsx)(R,{defaultOpen:z,onOpenChange:B,children:$}),t[97]=R,t[98]=z,t[99]=B,t[100]=$,t[101]=ae):ae=t[101],ae}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,Z.jsxs)(`li`,{className:`break-words`,children:[(0,Z.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.token}function de(){let e=v(e=>e.language),t=h(e),n=A(e=>e.setPageHeader),r=A(e=>e.clearPageHeader),o=P(),s=V(),[c,l]=i(),f=K(c.get(`tab`)),p=c.get(`q`)??``,[g,_]=(0,W.useState)(f),[y,b]=(0,W.useState)(p),[x,S]=(0,W.useState)(null),C=c.toString(),w=(0,W.useRef)(C);if(w.current!==C){w.current=C;let e=K(c.get(`tab`)),t=c.get(`q`)??``;_(t=>t===e?t:e),b(e=>e===t?e:t)}(0,W.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=y.trim();return n?t.set(`q`,n):t.delete(`q`),g===`marketplace`?t.delete(`tab`):t.set(`tab`,g),t.toString()===e.toString()?e:t},{replace:!0})},[g,y,l]);let T=(0,W.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),E=(0,W.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),D=g===`builtin`?T:E,O=(0,W.useMemo)(()=>{let t=y.trim().toLowerCase(),n=D;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[D,y,e]);if((0,W.useEffect)(()=>{S(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?fe(e)===fe(t)&&e.active===t.active?e:t:null})},[o]),(0,W.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(m,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,Z.jsx)(z,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,Z.jsx)(m,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps/new`,children:[(0,Z.jsx)(u,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&g!==`marketplace`)return(0,Z.jsx)(ye,{});let k=g!==`marketplace`&&D.length>0;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,Z.jsx)(U,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:T.length},{id:`user`,label:t.extensionsPage.tabUser,count:E.length}],activeTab:g,onChange:_,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),k?(0,Z.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Z.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:y,onChange:e=>b(e.target.value),placeholder:t.extensionsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),g===`marketplace`?(0,Z.jsx)($,{}):g===`builtin`&&T.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):g===`user`&&E.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyUser}):O.length===0?(0,Z.jsx)(`p`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-3 py-8 text-center text-sm text-fg-muted shadow-surface sm:px-5 xl:px-6`,children:t.extensionsPage.noSearchResults}):(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:O.map(e=>(0,Z.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:g===`user`,onOpen:()=>S(e)},e.id))})]}),x?(0,Z.jsx)(_e,{extension:x,copy:t.extensionsPage,onClose:()=>S(null)},x.id):null]})}function fe(e){return e.activationEligible??e.active}function pe(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function me(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function he(e,t){let n=fe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function ge(e){let t=(0,G.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,s;t[0]===n?s=t[1]:(s=fe(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=p(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=d):d=t[2];let f=n.name||n.id,m;t[3]===f?m=t[4]:(m=f.charAt(0).toUpperCase(),t[3]=f,t[4]=m);let h;t[5]===m?h=t[6]:(h=(0,Z.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:m}),t[5]=m,t[6]=h);let g;t[7]===n.name?g=t[8]:(g=(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=g);let _;t[9]===n.version?_=t[10]:(_=n.version?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=_);let v;t[11]!==g||t[12]!==_?(v=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==r.statusEnabled||t[15]!==c?(y=c?(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,Z.jsx)(o,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,Z.jsx)(u,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=y):y=t[16];let b;t[17]!==v||t[18]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[v,y]}),t[17]=v,t[18]=y,t[19]=b):b=t[19];let x;t[20]!==r.cardNoDescription||t[21]!==n.description?(x=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=x):x=t[22];let S;t[23]===x?S=t[24]:(S=(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:x}),t[23]=x,t[24]=S);let C=n.hasUi?r.badgeKindUi:r.badgeKindBackend,w;t[25]!==C||t[26]!==l?(w=(0,Z.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:C}),t[25]=C,t[26]=l,t[27]=w):w=t[27];let T;t[28]!==r||t[29]!==n||t[30]!==i?(T=n.source===`bundled`?(0,Z.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,Z.jsx)(`span`,{title:pe(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:me(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=T):T=t[31];let E;t[32]!==w||t[33]!==T?(E=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[w,T]}),t[32]=w,t[33]=T,t[34]=E):E=t[34];let D;t[35]!==b||t[36]!==S||t[37]!==E?(D=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,S,E]}),t[35]=b,t[36]=S,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==D||t[40]!==h?(O=(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[h,D]}),t[39]=D,t[40]=h,t[41]=O):O=t[41];let k;return t[42]!==a||t[43]!==O?(k=(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:d,children:O}),t[42]=a,t[43]=O,t[44]=k):k=t[44],k}function _e({extension:e,copy:t,onClose:n}){let{mutate:r}=O(),[i,o]=(0,W.useState)(!1),[c,u]=(0,W.useState)(null),[d,h]=(0,W.useState)(!1),g=e.activationEligible===!0,_=(0,W.useCallback)(async()=>{if(e.source===`bundled`){u(null),h(!1),o(!0);try{let{requiresGatewayRestart:t}=await Y({extensionId:e.id,enabled:!g});await r(`gateway-extensions-list`),M(),h(t)}catch(e){u(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[g,t.builtinToggleFailed,e.id,e.source,r]),v=e.ui?.contributions?.pages??[],y=e.ui?.contributions?.settingsPanels??[],b=e.ui?.contributions?.chatWidgets??[],x=e.ui?.contributions?.sidebarPanels??[],k=v.find(e=>e.showInNav)??v[0],A=y[0],j=k?L(e.id,k):null,N=A?`/settings/ext/${e.id}/${A.id}`:e.hasConfigSchema||H(e)?`/settings/ext/${e.id}`:null;return(0,Z.jsx)(D,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Z.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,Z.jsx)(te,{className:`size-5`})}),(0,Z.jsx)(E,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Z.jsxs)(C,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,Z.jsx)(f,{className:`size-5`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Z.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Z.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,Z.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void _(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(l,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):g?t.builtinToggleDisable:t.builtinToggleEnable})]}),c?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:c}):null,d?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Z.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(v.length>0||y.length>0||b.length>0)?(0,Z.jsxs)(`section`,{className:`mt-8`,children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Z.jsx)(ve,{template:t.badgePages,count:v.length,hidden:v.length===0}),(0,Z.jsx)(ve,{template:t.badgeSettings,count:y.length,hidden:y.length===0}),(0,Z.jsx)(ve,{template:t.badgeWidgets,count:b.length,hidden:b.length===0}),(0,Z.jsx)(ve,{template:t.badgeSidebar,count:x.length,hidden:x.length===0})]})]}):null,F(e)&&(j||N)?(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[j?(0,Z.jsxs)(a,{to:j,onClick:n,className:p(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Z.jsx)(s,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,N?(0,Z.jsxs)(a,{to:N,onClick:n,className:p(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Z.jsx)(I,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Z.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,G.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function ye(){let e=(0,G.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Z.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Z.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(be)})]})}),e[4]=a):a=e[4],a}function be(e){return(0,Z.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function xe(e){let t=(0,G.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{de as ExtensionsPage};
|