@nextclaw/ui 0.15.28 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/assets/{api-a_GaOFc7.js → api-Dket1cmq.js} +1 -1
  3. package/dist/assets/{appearance-settings-page-KEYKkxHu.js → appearance-settings-page-CfwDf9ag.js} +1 -1
  4. package/dist/assets/{channels-list-page-eXLXPgKT.js → channels-list-page-Dyn83ZlS.js} +2 -2
  5. package/dist/assets/chat-page-CL0IMvgF.js +1 -0
  6. package/dist/assets/{config-split-page-ps1Aod3g.js → config-split-page-D4D4HFhq.js} +1 -1
  7. package/dist/assets/{confirm-dialog-DJSUNG33.js → confirm-dialog-Cv6-9Nnj.js} +1 -1
  8. package/dist/assets/{desktop-update-config-C20U71k1.js → desktop-update-config-Bckgulvm.js} +1 -1
  9. package/dist/assets/{dist-BkTYNzm_.js → dist-Bh_tj3FN.js} +1 -1
  10. package/dist/assets/{dist-DkR7_Dpl.js → dist-BrRgjiq1.js} +1 -1
  11. package/dist/assets/{doc-browser-Q67TOGVS.js → doc-browser-BlWjhmnM.js} +1 -1
  12. package/dist/assets/doc-browser-Da9hDsoQ.js +1 -0
  13. package/dist/assets/{doc-browser-context-BQim8SqD.js → doc-browser-context-NGYa66Xg.js} +1 -1
  14. package/dist/assets/{form-actions-B2-bpFie.js → form-actions-CeKgh4SQ.js} +1 -1
  15. package/dist/assets/{index-BP0Hd2jI.js → index-Bz5yNMXA.js} +44 -44
  16. package/dist/assets/loader-circle-DLp2jNIf.js +1 -0
  17. package/dist/assets/mcp-marketplace-page-CIWbjXM8.js +1 -0
  18. package/dist/assets/{mcp-marketplace-page-w8panjZG.js → mcp-marketplace-page-DfNmMqKs.js} +1 -1
  19. package/dist/assets/{model-config-page-CJCnaKOh.js → model-config-page-DHzyDV5v.js} +1 -1
  20. package/dist/assets/{navigation-link-mpHFXwRr.js → navigation-link-CzGgQGi_.js} +1 -1
  21. package/dist/assets/plus-Dfj3tJ_m.js +1 -0
  22. package/dist/assets/{provider-scoped-model-input-Dqu-ZoWG.js → provider-scoped-model-input-CjrHwzFb.js} +1 -1
  23. package/dist/assets/providers-config-page-ZPvJWHFN.js +1 -0
  24. package/dist/assets/{react-BlXwvOLo.js → react-BXRf96P-.js} +1 -1
  25. package/dist/assets/{refresh-cw-JFuyDj_P.js → refresh-cw-ChKuqgPR.js} +1 -1
  26. package/dist/assets/remote-C2enAZbs.js +1 -0
  27. package/dist/assets/rotate-cw-BGkZpcc7.js +1 -0
  28. package/dist/assets/runtime-config-page-CGpPQD8K.js +1 -0
  29. package/dist/assets/{save-BL8P8CLX.js → save-BWGNAKV5.js} +1 -1
  30. package/dist/assets/{search-bZL75Pgc.js → search-DFcT_9wJ.js} +1 -1
  31. package/dist/assets/{search-config-page-DhSFjYj4.js → search-config-page-DBBzVAQZ.js} +1 -1
  32. package/dist/assets/{secrets-config-page-BLGcyb1D.js → secrets-config-page-bnJ8sIB7.js} +2 -2
  33. package/dist/assets/security-config-CfbXSpgX.js +1 -0
  34. package/dist/assets/{select-rUZ8nIZu.js → select-BnNrv8si.js} +1 -1
  35. package/dist/assets/{settings-2-BI4SCkxQ.js → settings-2-CFHrgKTX.js} +1 -1
  36. package/dist/assets/skeleton-tfWhGuJT.js +1 -0
  37. package/dist/assets/{tag-chip-BdI_yIOA.js → tag-chip-L5w4xfS7.js} +1 -1
  38. package/dist/assets/x-BCSE3LCQ.js +1 -0
  39. package/dist/index.html +18 -18
  40. package/package.json +4 -4
  41. package/src/features/apps/components/__tests__/app-packages-panel.test.tsx +36 -0
  42. package/src/features/apps/components/app-marketplace-detail.tsx +19 -2
  43. package/src/features/apps/components/app-package-card.tsx +35 -0
  44. package/src/features/apps/types/app-marketplace.types.ts +3 -2
  45. package/src/features/chat/features/message/hooks/__tests__/use-chat-message-actions.test.tsx +64 -0
  46. package/src/features/chat/features/message/hooks/use-chat-message-actions.tsx +5 -1
  47. package/src/features/chat/features/ncp/hooks/__tests__/use-ncp-session-conversation.test.tsx +1 -1
  48. package/src/features/chat/features/ncp/hooks/use-ncp-session-message-history.ts +1 -1
  49. package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel-content.test.tsx +6 -1
  50. package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +1 -1
  51. package/src/features/chat/managers/__tests__/chat-completion-notification.manager.test.ts +3 -3
  52. package/src/features/chat/managers/chat-completion-notification.manager.ts +10 -4
  53. package/src/features/chat/pages/__tests__/ncp-chat-page.test.tsx +34 -7
  54. package/src/features/chat/pages/ncp-chat-page.tsx +19 -4
  55. package/src/shared/lib/i18n/locales/en-US/doc-browser.json +6 -0
  56. package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +6 -0
  57. package/dist/assets/chat-page-jfImLdsq.js +0 -1
  58. package/dist/assets/doc-browser-DahzJEWj.js +0 -1
  59. package/dist/assets/loader-circle-DyXZU92l.js +0 -1
  60. package/dist/assets/mcp-marketplace-page-B0dBE5CV.js +0 -1
  61. package/dist/assets/plus-Dhb4KuMH.js +0 -1
  62. package/dist/assets/providers-config-page-C6fRN2rJ.js +0 -1
  63. package/dist/assets/remote-Xyv2c_W9.js +0 -1
  64. package/dist/assets/rotate-cw-DjbbiIW_.js +0 -1
  65. package/dist/assets/runtime-config-page-CtypMgLd.js +0 -1
  66. package/dist/assets/security-config-DmJw9QZA.js +0 -1
  67. package/dist/assets/skeleton-CVmEPG43.js +0 -1
  68. package/dist/assets/x-BcEayhV6.js +0 -1
@@ -205,7 +205,7 @@ function createChildTab(): ResolvedChildSessionTab {
205
205
  };
206
206
  }
207
207
 
208
- it('shows compact child session metadata without repeating the tab title', () => {
208
+ it('shows compact child session metadata in a full-height column layout', () => {
209
209
  render(
210
210
  <ChatSessionWorkspacePanelContent
211
211
  activeSelection={{
@@ -226,6 +226,11 @@ it('shows compact child session metadata without repeating the tab title', () =>
226
226
  expect(screen.getByText('minimax/MiniMax-M3')).toBeTruthy();
227
227
  expect(screen.getByText('nextbot')).toBeTruthy();
228
228
  expect(screen.getByTitle('/Users/peiwang/Projects/nextbot')).toBeTruthy();
229
+ const conversationArea = screen.getByTestId('session-conversation-area');
230
+ const selectedContentHost = conversationArea.parentElement?.parentElement;
231
+ expect(Array.from(selectedContentHost?.classList ?? [])).toEqual(
232
+ expect.arrayContaining(['flex', 'min-h-0', 'flex-1', 'flex-col']),
233
+ );
229
234
  });
230
235
 
231
236
  it('shows all session workspace entries in the overview', async () => {
@@ -444,7 +444,7 @@ export function ChatSessionWorkspacePanelContent({
444
444
  ) : null}
445
445
  </div>
446
446
  {projectFilesActive ? null : (
447
- <div className="min-w-0 min-h-0 flex-1">
447
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col">
448
448
  <WorkspaceSelectedContent
449
449
  {...selectedContentProps}
450
450
  activeSelection={activeSelection}
@@ -101,13 +101,13 @@ describe("ChatCompletionNotificationManager", () => {
101
101
  });
102
102
  });
103
103
 
104
- it("suppresses messages completed in the active session, including later replays", () => {
104
+ it("suppresses messages completed in any visible session, including later replays", () => {
105
105
  manager.start();
106
- manager.syncActiveSession("session-background");
106
+ manager.syncVisibleSessions(["session-main", "session-background"]);
107
107
  emit(createCompletedEvent());
108
108
  expect(show).not.toHaveBeenCalled();
109
109
 
110
- manager.syncActiveSession(null);
110
+ manager.syncVisibleSessions(["session-main"]);
111
111
  emit(createCompletedEvent());
112
112
  expect(show).not.toHaveBeenCalled();
113
113
 
@@ -61,7 +61,7 @@ function readAssistantReplyPreview(message: NcpMessage): string {
61
61
  export class ChatCompletionNotificationManager {
62
62
  private readonly cleanups: Array<() => void> = [];
63
63
  private readonly handledMessageIds = new Set<string>();
64
- private activeSessionId: string | null = null;
64
+ private visibleSessionIds = new Set<string>();
65
65
  private started = false;
66
66
 
67
67
  constructor(
@@ -88,8 +88,14 @@ export class ChatCompletionNotificationManager {
88
88
  }
89
89
  };
90
90
 
91
- syncActiveSession = (sessionId: string | null): void => {
92
- this.activeSessionId = sessionId?.trim() || null;
91
+ syncVisibleSessions = (
92
+ sessionIds: readonly (string | null | undefined)[],
93
+ ): void => {
94
+ this.visibleSessionIds = new Set(
95
+ sessionIds
96
+ .map((sessionId) => sessionId?.trim())
97
+ .filter((sessionId): sessionId is string => Boolean(sessionId)),
98
+ );
93
99
  };
94
100
 
95
101
  private readonly handleNcpEvent = (event: NcpEndpointEvent): void => {
@@ -109,7 +115,7 @@ export class ChatCompletionNotificationManager {
109
115
  return;
110
116
  }
111
117
  this.rememberHandledMessage(message.id);
112
- if (sessionId === this.activeSessionId) {
118
+ if (this.visibleSessionIds.has(sessionId)) {
113
119
  return;
114
120
  }
115
121
 
@@ -1,17 +1,18 @@
1
- import { render, screen } from '@testing-library/react';
1
+ import { act, render, screen, waitFor } from '@testing-library/react';
2
2
  import { MemoryRouter, Route, Routes } from 'react-router-dom';
3
3
  import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { AppPresenterProvider } from '@/app/components/app-presenter-provider';
6
6
  import { NcpChatPage } from '@/features/chat/pages/ncp-chat-page';
7
7
  import { buildSessionPath } from '@/features/chat/features/session/utils/chat-session-route.utils';
8
+ import { useChatThreadStore } from '@/features/chat/stores/chat-thread.store';
8
9
 
9
10
  const mocks = vi.hoisted(() => ({
10
11
  confirm: vi.fn(),
11
12
  consumePending: vi.fn(() => null),
12
13
  markConsumed: vi.fn(),
13
14
  subscribe: vi.fn(() => vi.fn()),
14
- syncActiveSession: vi.fn(),
15
+ syncVisibleSessions: vi.fn(),
15
16
  useChatSessionSync: vi.fn(),
16
17
  }));
17
18
 
@@ -24,7 +25,7 @@ vi.mock('@/app/presenters/app.presenter', () => ({
24
25
  subscribe: mocks.subscribe,
25
26
  },
26
27
  chatCompletionNotificationManager: {
27
- syncActiveSession: mocks.syncActiveSession,
28
+ syncVisibleSessions: mocks.syncVisibleSessions,
28
29
  },
29
30
  }),
30
31
  }));
@@ -57,8 +58,13 @@ vi.mock('@/features/chat/features/ncp/hooks/use-ui-show-content-event', () => ({
57
58
 
58
59
  describe('NcpChatPage render boundary', () => {
59
60
  beforeEach(() => {
60
- mocks.syncActiveSession.mockReset();
61
+ mocks.syncVisibleSessions.mockReset();
61
62
  mocks.useChatSessionSync.mockReset();
63
+ useChatThreadStore.getState().setSnapshot({
64
+ workspacePanelParentKey: null,
65
+ activeWorkspacePanelKind: null,
66
+ activeChildSessionKey: null,
67
+ });
62
68
  });
63
69
 
64
70
  it('creates its chat presenter from the global app presenter provider', () => {
@@ -74,8 +80,13 @@ describe('NcpChatPage render boundary', () => {
74
80
  expect(mocks.useChatSessionSync).toHaveBeenCalledOnce();
75
81
  });
76
82
 
77
- it('syncs the active route session and clears it when chat unmounts', () => {
83
+ it('tracks visible route and workspace sessions, then clears them when chat unmounts', async () => {
78
84
  const sessionPath = buildSessionPath('session-background');
85
+ useChatThreadStore.getState().setSnapshot({
86
+ workspacePanelParentKey: 'session-background',
87
+ activeWorkspacePanelKind: 'child-session',
88
+ activeChildSessionKey: 'session-child',
89
+ });
79
90
  const view = render(
80
91
  <MemoryRouter initialEntries={[sessionPath]}>
81
92
  <AppPresenterProvider>
@@ -86,8 +97,24 @@ describe('NcpChatPage render boundary', () => {
86
97
  </MemoryRouter>,
87
98
  );
88
99
 
89
- expect(mocks.syncActiveSession).toHaveBeenCalledWith('session-background');
100
+ expect(mocks.syncVisibleSessions).toHaveBeenCalledWith([
101
+ 'session-background',
102
+ 'session-child',
103
+ ]);
104
+
105
+ act(() => {
106
+ useChatThreadStore.getState().setSnapshot({
107
+ activeWorkspacePanelKind: 'file',
108
+ });
109
+ });
110
+ await waitFor(() => {
111
+ expect(mocks.syncVisibleSessions).toHaveBeenLastCalledWith([
112
+ 'session-background',
113
+ null,
114
+ ]);
115
+ });
116
+
90
117
  view.unmount();
91
- expect(mocks.syncActiveSession).toHaveBeenLastCalledWith(null);
118
+ expect(mocks.syncVisibleSessions).toHaveBeenLastCalledWith([]);
92
119
  });
93
120
  });
@@ -18,6 +18,7 @@ import {
18
18
  import { useConfirmDialog } from "@/shared/hooks/use-confirm-dialog";
19
19
  import { useAppPresenter } from "@/app/components/app-presenter-provider";
20
20
  import { useUiShowContentEvent } from "@/features/chat/features/ncp/hooks/use-ui-show-content-event";
21
+ import { useChatThreadStore } from "@/features/chat/stores/chat-thread.store";
21
22
 
22
23
  function useNcpChatRouteSelection() {
23
24
  const { sessionId: routeSessionIdParam } = useParams<{ sessionId?: string }>();
@@ -64,14 +65,28 @@ function NcpChatPageContent({ view }: ChatPageProps) {
64
65
  const confirmDialog = useNcpChatUiBindings();
65
66
  const routeSelection = useNcpChatRouteSelection();
66
67
  const { routeSessionKey, sessionKey } = routeSelection;
68
+ const visibleWorkspaceSessionKey = useChatThreadStore((state) => {
69
+ const { snapshot } = state;
70
+ if (
71
+ snapshot.workspacePanelParentKey !== (sessionKey ?? null) ||
72
+ snapshot.activeWorkspacePanelKind !== "child-session"
73
+ ) {
74
+ return null;
75
+ }
76
+ return snapshot.activeChildSessionKey?.trim() || null;
77
+ });
67
78
  useEffect(() => {
68
- appPresenter.chatCompletionNotificationManager.syncActiveSession(
69
- sessionKey ?? null,
79
+ appPresenter.chatCompletionNotificationManager.syncVisibleSessions(
80
+ [sessionKey, visibleWorkspaceSessionKey],
70
81
  );
71
82
  return () => {
72
- appPresenter.chatCompletionNotificationManager.syncActiveSession(null);
83
+ appPresenter.chatCompletionNotificationManager.syncVisibleSessions([]);
73
84
  };
74
- }, [appPresenter.chatCompletionNotificationManager, sessionKey]);
85
+ }, [
86
+ appPresenter.chatCompletionNotificationManager,
87
+ sessionKey,
88
+ visibleWorkspaceSessionKey,
89
+ ]);
75
90
  useChatQueryStoreSync({
76
91
  sessionKey: sessionKey ?? null,
77
92
  });
@@ -63,6 +63,11 @@
63
63
  "appPackagesAvailable": "Available",
64
64
  "appPackagesBuiltIn": "Built into NextClaw",
65
65
  "appPackagesLocalService": "Local data service",
66
+ "appPackagesIsolationLabel": "Runtime isolation",
67
+ "appPackagesIsolationPanel": "Isolated interface",
68
+ "appPackagesIsolationMediated": "Host-mediated runtime",
69
+ "appPackagesIsolationFullUser": "Runs with your user permissions",
70
+ "appPackagesDataUsage": "App data",
66
71
  "appPackagesEnable": "Enable",
67
72
  "appPackagesDisable": "Disable",
68
73
  "appPackagesWorking": "Working…",
@@ -92,6 +97,7 @@
92
97
  "appPackagesDocumentAccess": "Needs access to {count} file folder(s) you approve",
93
98
  "appPackagesNetworkAccess": "Needs to connect to {count} network domain(s)",
94
99
  "appPackagesHostBridgeAccess": "Uses local capabilities provided by NextClaw",
100
+ "appPackagesNativeProcessAccess": "Starts a local process with the file and network access available to your user account",
95
101
  "appPackagesLocalStorageAccess": "Stores its own app data on this device",
96
102
  "appPackagesNoExtraAccess": "No additional file or network access declared",
97
103
  "appPackagesPreparing": "Preparing",
@@ -63,6 +63,11 @@
63
63
  "appPackagesAvailable": "可用",
64
64
  "appPackagesBuiltIn": "NextClaw 内置",
65
65
  "appPackagesLocalService": "本地数据服务",
66
+ "appPackagesIsolationLabel": "运行隔离",
67
+ "appPackagesIsolationPanel": "隔离界面",
68
+ "appPackagesIsolationMediated": "受限运行",
69
+ "appPackagesIsolationFullUser": "以当前用户权限运行",
70
+ "appPackagesDataUsage": "应用数据",
66
71
  "appPackagesEnable": "启用",
67
72
  "appPackagesDisable": "停用",
68
73
  "appPackagesWorking": "处理中…",
@@ -92,6 +97,7 @@
92
97
  "appPackagesDocumentAccess": "需要访问 {count} 个由你授权的文件目录",
93
98
  "appPackagesNetworkAccess": "需要连接 {count} 个网络域名",
94
99
  "appPackagesHostBridgeAccess": "需要调用 NextClaw 提供的本机能力",
100
+ "appPackagesNativeProcessAccess": "会启动本机进程;该进程拥有当前用户可访问的文件和网络权限",
95
101
  "appPackagesLocalStorageAccess": "会在本机保存自己的应用数据",
96
102
  "appPackagesNoExtraAccess": "没有声明额外的文件或网络访问",
97
103
  "appPackagesPreparing": "准备中",
@@ -1 +0,0 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{I as t,P as n,V as r,i,z as a}from"./react-BlXwvOLo.js";import{d as o,f as s,u as c}from"./navigation-link-mpHFXwRr.js";import{$t as l,Et as u,Qt as d,nn as f,sn as p,tn as m}from"./api-a_GaOFc7.js";import{g as h,h as g}from"./mcp-marketplace-page-w8panjZG.js";import{c as _}from"./dist-DkR7_Dpl.js";import{C as v,a as ee,i as y,n as b,r as x,t as S}from"./select-rUZ8nIZu.js";import{a as C,c as w,i as T,n as E,o as D,r as te,s as O}from"./confirm-dialog-DJSUNG33.js";import{t as ne}from"./provider-scoped-model-input-Dqu-ZoWG.js";import{t as k}from"./plus-Dhb4KuMH.js";import{t as re}from"./settings-2-BI4SCkxQ.js";import{t as ie}from"./tag-chip-BdI_yIOA.js";import{$ as ae,D as A,Gt as oe,It as se,Jt as ce,Kt as le,O as j,Pt as ue,Q as de,R as fe,Ut as pe,Vt as me,Yt as M,_ as N,_t as P,a as he,at as F,ct as ge,dt as I,et as _e,ft as ve,g as ye,h as be,ht as xe,i as Se,it as Ce,lt as we,m as Te,mt as Ee,o as De,ot as Oe,q as ke,r as L,s as Ae,st as R,t as z,tt as B,u as je,ut as Me,vt as V,zt as H}from"./index-BP0Hd2jI.js";var Ne=_(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),U=e(r(),1),W=a(),G=new Intl.NumberFormat;function Pe({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:r,defaultRuntimeLabel:a,onOpenChange:o,onEdit:s}){if(!e)return null;let c=K(e.model,t?.model),l=Fe({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:r,defaultRuntimeLabel:a}),u=q(e.contextTokens,t?.contextTokens??2e5),d=q(e.reservedContextTokens,t?.reservedContextTokens),p=q(e.maxToolIterations,t?.maxToolIterations??1e3),m=K(e.thinkingDefault,t?.thinkingDefault??`off`),h=Y(e.runtimeConfig??e.engineConfig,t?.engineConfig),g=Y(e.models,t?.models);return(0,W.jsx)(E,{open:e!==null,onOpenChange:o,children:(0,W.jsxs)(te,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-popover p-0 sm:max-h-[720px] sm:max-w-2xl`,children:[(0,W.jsx)(`div`,{className:`shrink-0 px-5 pb-3 pt-5`,children:(0,W.jsx)(D,{className:`text-left`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,W.jsx)(B,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-10 w-10 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(O,{className:`truncate text-base`,children:e.displayName?.trim()||e.id}),(0,W.jsxs)(T,{className:`truncate text-xs`,children:[`@`,e.id]})]})]})})}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-5 py-3`,children:[(0,W.jsxs)(X,{icon:M,title:i(`agentsDetailsIdentitySection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldDisplayName`),value:e.displayName?.trim()||e.id}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldId`),value:e.id,mono:!0}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldDescription`),value:e.description?.trim()||i(`agentsDetailsEmptyValue`),wide:!0}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldWorkspace`),value:e.workspace??i(`agentsDetailsUnsetValue`),mono:!0,wide:!0})]}),(0,W.jsxs)(X,{icon:w,title:i(`agentsDetailsRuntimeSection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldModel`),value:c.value,source:c.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldRuntime`),value:l.value,source:l.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldRuntimeConfig`),value:h.value,source:h.source,mono:!0,prewrap:!0})]}),(0,W.jsxs)(X,{icon:Ne,title:i(`agentsDetailsContextSection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldContextTokens`),value:u.value,source:u.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldReservedContextTokens`),value:d.value,source:d.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldMaxToolIterations`),value:p.value,source:p.source})]}),(0,W.jsxs)(X,{icon:ce,title:i(`agentsDetailsBehaviorSection`),children:[(0,W.jsx)(Z,{label:i(`agentsDetailsFieldThinkingDefault`),value:m.value,source:m.source}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldModelOverrides`),value:g.value,source:g.source,mono:!0,prewrap:!0}),(0,W.jsx)(Z,{label:i(`agentsDetailsFieldAvatar`),value:e.avatar??i(`agentsDetailsUnsetValue`),mono:!0})]})]}),(0,W.jsxs)(C,{className:`shrink-0 px-5 pb-4 pt-2`,children:[(0,W.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:i(`cancel`)}),(0,W.jsxs)(f,{type:`button`,variant:`primary`,className:`px-4`,onClick:()=>s(e),children:[(0,W.jsx)(H,{className:`mr-2 h-4 w-4`}),i(`agentsDetailsEditAction`)]})]})]})})}function K(e,t){let n=e?.trim();return n?{value:n,source:`override`}:{value:t?.trim()||i(`agentsDetailsUnsetValue`),source:`default`}}function q(e,t){return typeof e==`number`?{value:G.format(e),source:`override`}:{value:typeof t==`number`?G.format(t):i(`agentsDetailsUnsetValue`),source:`default`}}function Fe(e){let{agent:t,defaults:n,runtimeOptions:r,defaultRuntime:i,defaultRuntimeLabel:a}=e,o=t.runtime?.trim()||t.engine?.trim();if(o)return{value:J(o,r,a),source:`override`};let s=n?.engine?.trim()||i;return{value:s?J(s,r,a):a,source:`default`}}function J(e,t,n){let r=F(e);return r?t.find(e=>e.value===r)?.label??R(r):n}function Y(e,t){return Ie(e)?{value:JSON.stringify(e,null,2),source:`override`}:{value:Ie(t)?JSON.stringify(t,null,2):i(`agentsDetailsUnsetValue`),source:`default`}}function Ie(e){return!!(e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0)}function X(e){let{icon:t,title:n,children:r}=e;return(0,W.jsxs)(`section`,{className:`space-y-2 border-t border-border/60 pt-3 first:border-t-0 first:pt-0`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold leading-5 text-foreground`,children:[(0,W.jsx)(t,{className:`h-3.5 w-3.5 text-muted-foreground`}),n]}),(0,W.jsx)(`dl`,{className:`grid min-w-0 gap-x-6 gap-y-2.5 pl-5 sm:grid-cols-2`,children:r})]})}function Z(e){let{label:n,value:r,source:i,mono:a=!1,prewrap:o=!1,wide:s=!1}=e,c=o&&r.trim().startsWith(`{`),l=a&&(!o||c);return(0,W.jsxs)(`div`,{className:t(`grid min-w-0 grid-cols-[10rem_minmax(0,1fr)] items-baseline gap-x-2`,(s||c)&&`sm:col-span-2`),children:[(0,W.jsx)(`dt`,{className:`flex min-w-0 items-baseline leading-5`,children:(0,W.jsx)(`span`,{className:`whitespace-nowrap text-xs font-medium text-muted-foreground`,children:n})}),(0,W.jsxs)(`dd`,{className:t(`min-w-0 break-words text-xs leading-5 text-foreground`,c?`max-h-28 overflow-auto whitespace-pre-wrap rounded bg-muted/50 px-2 py-1.5 text-left`:``),children:[(0,W.jsx)(`span`,{className:l?`font-mono`:void 0,children:r}),i?(0,W.jsx)(Le,{source:i}):null]})]})}function Le({source:e}){return(0,W.jsxs)(`span`,{className:t(`ml-1 whitespace-nowrap text-xs font-normal leading-5`,e===`override`?`text-blue-500`:`text-muted-foreground`),children:[`(`,i(e===`override`?`agentsDetailsAgentOverride`:`agentsDetailsInheritedDefault`),`)`]})}function Re({form:e,disabled:t=!1,onChange:n}){return(0,W.jsxs)(`details`,{className:`group rounded-2xl border border-border bg-card`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(re,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`truncate`,children:i(`agentsAdvancedConfigToggle`)})]}),(0,W.jsx)(v,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180`})]}),(0,W.jsxs)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-4`,children:[(0,W.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground`,children:i(`agentsAdvancedConfigDescription`)}),(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:(0,W.jsx)(ze,{label:i(`agentsAdvancedContextTokensLabel`),value:e.contextTokens,min:1e3,step:1e3,disabled:t,onChange:e=>n({contextTokens:e})})})]})]})}function ze(e){let{label:t,value:n,min:r,step:a,disabled:o,onChange:s}=e;return(0,W.jsxs)(`label`,{className:`space-y-2 text-sm font-medium text-foreground`,children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(m,{type:`number`,min:r,step:a,value:n,disabled:o,placeholder:i(`agentsAdvancedInheritPlaceholder`),"aria-label":t,onChange:e=>s(e.target.value)})]})}function Be(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:Ve(e.contextTokens)}}function Ve(e){return typeof e==`number`?String(e):``}var He=U.forwardRef(({className:e,...n},r)=>(0,W.jsx)(`textarea`,{className:t(`flex min-h-28 w-full rounded-xl border border-border/75 bg-card px-3.5 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/55 placeholder:font-normal transition-colors focus:outline-none focus:ring-0 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));He.displayName=`Textarea`;function Ue(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=F(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:R(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function We({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:r,onChange:a}){let o=e.trim()?F(e):``,s=Ue({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?i(`agentsRuntimeUnavailableHelp`):``);return(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(S,{value:o||r,onValueChange:e=>a(e===r?``:e),disabled:t,children:[(0,W.jsx)(y,{"aria-label":i(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,W.jsx)(ee,{placeholder:i(`agentsRuntimeSelectPlaceholder`)})}),(0,W.jsx)(b,{className:`rounded-xl`,children:s.map(e=>(0,W.jsx)(x,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}):null]})}function Ge({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,W.jsx)(E,{open:e!==null,onOpenChange:a,children:e?(0,W.jsx)(Ke,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function Ke(e){let{agent:t,pending:n,providerCatalog:r,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:c}=e,[l,u]=(0,U.useState)(Be(t));return(0,W.jsxs)(te,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-popover p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,W.jsx)(`div`,{className:`shrink-0 border-b border-border px-6 py-6`,children:(0,W.jsxs)(D,{className:`text-left`,children:[(0,W.jsx)(O,{children:i(`agentsEditDialogTitle`)}),(0,W.jsx)(T,{children:i(`agentsEditDialogDescription`)})]})}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(h,{tone:`warning`,title:i(`agentsEditHomeReadonly`),description:i(`agentsEditHomeReadonlyHint`),children:(0,W.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,W.jsx)(m,{value:l.displayName,onChange:e=>u(t=>({...t,displayName:e.target.value})),placeholder:i(`agentsFormNamePlaceholder`)}),(0,W.jsx)(He,{value:l.description,onChange:e=>u(t=>({...t,description:e.target.value})),placeholder:i(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,W.jsx)(m,{value:l.avatar,onChange:e=>u(t=>({...t,avatar:e.target.value})),placeholder:i(`agentsFormAvatarPlaceholder`)}),(0,W.jsx)(ne,{value:l.model,onChange:e=>u(t=>({...t,model:e})),providerCatalog:r,disabled:n,className:`md:col-span-2`}),(0,W.jsx)(We,{value:l.runtime,onChange:e=>u(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:n})]}),(0,W.jsx)(Re,{form:l,disabled:n,onChange:e=>u(t=>({...t,...e}))})]})}),(0,W.jsxs)(C,{className:`shrink-0 border-t border-border px-6 py-5`,children:[(0,W.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:n,children:i(`cancel`)}),(0,W.jsxs)(f,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>c(t.id,l),disabled:n,children:[(0,W.jsx)(H,{className:`mr-2 h-4 w-4`}),i(`agentsEditSaveAction`)]})]})]})}var qe=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function Je(e){let t=e.trim();if(!t)return null;let n=Number(t);if(!Number.isFinite(n))throw Error(i(`agentsAdvancedInvalidNumberError`));return Math.trunc(n)}function Ye(e){return{displayName:e.displayName,description:e.description,avatar:e.avatar,model:e.model,...e.runtime.trim()?{runtime:e.runtime.trim()}:{runtime:``},contextTokens:Je(e.contextTokens)}}function Q(e){let{icon:n,label:r,disabled:i=!1,destructive:a=!1,onClick:o}=e;return(0,W.jsxs)(`button`,{type:`button`,className:t(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-foreground hover:bg-muted`),onClick:o,disabled:i,children:[(0,W.jsx)(n,{className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:r})]})}function Xe(e){let{agent:t,runtimeOptions:n,defaultRuntimeLabel:r,updatePending:a,deletePending:o,onStartChat:s,onView:c,onEdit:l,onDelete:u}=e,d=t.runtime?.trim()||t.engine?.trim()||``,p=d?n.find(e=>e.value===F(d))?.label??R(d):r;return(0,W.jsx)(P,{className:`group overflow-hidden border border-border bg-card shadow-none transition-colors duration-200 hover:border-border/80`,children:(0,W.jsxs)(V,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,W.jsx)(B,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,W.jsxs)(ie,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,W.jsx)(se,{className:`h-3 w-3`}),i(`agentsCardBuiltInTag`)]}):null]}),(0,W.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[`@`,t.id]})]})]}),(0,W.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,W.jsx)(f,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground hover:text-foreground`,"aria-label":i(`agentsCardStartChat`),title:i(`agentsCardStartChat`),onClick:s,children:(0,W.jsx)(me,{className:`h-4 w-4`})}),(0,W.jsxs)(ve,{children:[(0,W.jsx)(xe,{asChild:!0,children:(0,W.jsx)(f,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground hover:text-foreground`,"aria-label":i(`chatSessionMoreActions`),title:i(`chatSessionMoreActions`),children:(0,W.jsx)(le,{className:`h-4 w-4`})})}),(0,W.jsxs)(Ee,{align:`end`,className:`w-44 p-1.5`,children:[(0,W.jsx)(Q,{icon:oe,label:i(`agentsViewDetailsAction`),onClick:c}),(0,W.jsx)(Q,{icon:H,label:i(`agentsEditAction`),onClick:l,disabled:a}),t.builtIn?null:(0,W.jsx)(Q,{icon:ue,label:i(`agentsRemoveAction`),onClick:u,disabled:o,destructive:!0})]})]})]}),(0,W.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-muted-foreground`,children:t.description?.trim()||(t.builtIn?i(`agentsCardBuiltInSummary`):i(`agentsCardCustomSummary`))}),(0,W.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-border/60 pt-2 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(w,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60`}),(0,W.jsx)(`span`,{className:`truncate`,children:p})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function Ze(){let e=I(),t=de(),n=N(),r=j(),a=A(),o=L(),s=_e(),c=ae(),[u,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),_=(0,U.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),v=(0,U.useMemo)(()=>[..._].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[_]),ee=(0,U.useMemo)(()=>fe({config:n.data,providersView:r.data,templatesView:a.data,onlyConfigured:!0}),[n.data,r.data,a.data]),y=(0,U.useMemo)(()=>Ce(o.data?.options??[]),[o.data?.options]),b=(0,U.useMemo)(()=>F(o.data?.defaultType??`native`),[o.data?.defaultType]),x=(0,U.useMemo)(()=>y.find(e=>e.value===b)?.label??R(b),[b,y]),S=n.data?.agents.defaults,C=e=>{m(e)},w=e=>{g(e)},T=async(e,t)=>{let n;try{n=Ye(t)}catch(e){p.error(e instanceof Error?e.message:i(`agentsAdvancedParseFailed`));return}await s.mutateAsync({agentId:e,data:n}),g(null)},E=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,Oe(t,b))},D=()=>{e.chatSessionListManager.startAgentDraftChat(`main`,b,qe)};return(0,W.jsxs)(l,{className:`space-y-6`,children:[(0,W.jsx)(d,{headingLevel:1,title:i(`agentsHeroEyebrow`),description:i(`agentsHeroDescription`),actions:(0,W.jsxs)(f,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:D,children:[(0,W.jsx)(k,{className:`mr-2 h-4 w-4`}),i(`agentsCreateButton`)]})}),(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,W.jsx)(P,{className:`md:col-span-2 xl:col-span-3 border-dashed border-border bg-card/70`,children:(0,W.jsx)(V,{className:`py-14 text-center text-sm text-muted-foreground`,children:i(`agentsLoading`)})}):v.length===0?(0,W.jsx)(P,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-border bg-gradient-subtle`,children:(0,W.jsxs)(V,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,W.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-card/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,W.jsx)(M,{className:`h-8 w-8 text-warning`})}),(0,W.jsx)(`div`,{className:`text-lg font-semibold text-foreground`,children:i(`agentsEmpty`)}),(0,W.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:i(`agentsEmptyDescription`)}),(0,W.jsxs)(f,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:D,children:[(0,W.jsx)(k,{className:`mr-2 h-4 w-4`}),i(`agentsCreateButton`)]})]})}):v.map(e=>(0,W.jsx)(Xe,{agent:e,runtimeOptions:y,defaultRuntimeLabel:x,updatePending:s.isPending,deletePending:c.isPending,onStartChat:()=>E(e),onView:()=>C(e),onEdit:()=>w(e),onDelete:()=>c.mutate({agentId:e.id})},e.id))}),(0,W.jsx)(Pe,{agent:u,defaults:S,runtimeOptions:y,defaultRuntime:b,defaultRuntimeLabel:x,onOpenChange:e=>{e||m(null)},onEdit:e=>{m(null),g(e)}}),(0,W.jsx)(Ge,{agent:h,pending:s.isPending,providerCatalog:ee,runtimeOptions:y,defaultRuntime:b,onOpenChange:e=>{!e&&!s.isPending&&g(null)},onSubmit:T})]})}var $=`max-w-[min(1180px,100%)]`;function Qe(e){let{routeSessionKey:t,syncRouteSessionSelection:n}=e;(0,U.useLayoutEffect)(()=>{n(t)},[t,n])}function $e({view:e,confirmDialog:t}){let{isMobile:n}=ye();return(0,W.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,W.jsx)(De,{}),e===`chat`?n?(0,W.jsx)(Ae,{}):(0,W.jsx)(Te,{}):(0,W.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:e===`inbox`?(0,W.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full flex-col py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(je,{})}):e===`cron`?(0,W.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full px-4 py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(be,{})})}):e===`agents`?(0,W.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full px-4 py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(Ze,{})})}):(0,W.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,W.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full flex-col px-4 py-4 sm:px-6 sm:py-5 ${$}`,children:(0,W.jsx)(ke,{forcedType:`skills`})})})}),t]})}function et(e){let t=I(),n=N(),r=j(),i=A(),a=we({limit:200}),o=L(),s=e.sessionKey?.trim()||`draft-session`,c=ge({sessionId:s});(0,U.useEffect)(()=>{t.chatQueryManager.syncSnapshot({configQuery:n,providersQuery:r,providerTemplatesQuery:i,sessionsQuery:a,sessionTypesQuery:o,sessionSkillsSessionId:s,sessionSkillsQuery:c})},[n,t.chatQueryManager,r,s,c,a,o,i])}function tt(){let e=I();(0,U.useEffect)(()=>u.eventBus.on(n.uiShowContent,t=>{e.chatThreadManager.handleUiShowContentEvent(t)}),[e])}function nt(){let{sessionId:e}=s(),t=(0,U.useMemo)(()=>he(e),[e]);return{routeSessionKey:t,sessionKey:t??void 0}}function rt(){let e=I(),{confirm:t,ConfirmDialog:n}=g(),r=c(),i=o();return(0,U.useEffect)(()=>{e.chatUiManager.syncState({pathname:r.pathname}),e.chatUiManager.bindActions({navigate:i,confirm:t})},[t,r.pathname,i,e]),(0,W.jsx)(n,{})}function it({view:e}){let t=z();return(0,W.jsx)(Me,{presenter:(0,U.useMemo)(()=>new Se(t),[t]),children:(0,W.jsx)(at,{view:e})})}function at({view:e}){let t=z(),n=I(),r=rt(),{routeSessionKey:i,sessionKey:a}=nt();return(0,U.useEffect)(()=>(t.chatCompletionNotificationManager.syncActiveSession(a??null),()=>{t.chatCompletionNotificationManager.syncActiveSession(null)}),[t.chatCompletionNotificationManager,a]),et({sessionKey:a??null}),Qe({routeSessionKey:i,syncRouteSessionSelection:n.chatSessionListManager.syncRouteSessionSelection}),tt(),(0,W.jsx)($e,{view:e,confirmDialog:r})}function ot({view:e}){return(0,W.jsx)(it,{view:e})}export{ot as ChatPage};
@@ -1 +0,0 @@
1
- import{t as e}from"./doc-browser-Q67TOGVS.js";export{e as DocBrowser};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-DkR7_Dpl.js";var t=e(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./mcp-marketplace-page-w8panjZG.js";export{e as McpMarketplacePage};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-DkR7_Dpl.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{I as t,V as n,i as r,o as i,z as a}from"./react-BlXwvOLo.js";import{Mt as o,Zt as s,bn as c,en as l,nn as u,qt as d,sn as f,tn as p}from"./api-a_GaOFc7.js";import{c as m}from"./dist-DkR7_Dpl.js";import{C as h,a as g,i as _,n as v,r as y,t as b}from"./select-rUZ8nIZu.js";import{c as x,l as S,t as C}from"./confirm-dialog-DJSUNG33.js";import{t as w}from"./search-bZL75Pgc.js";import{t as T}from"./loader-circle-DyXZU92l.js";import{t as E}from"./plus-Dhb4KuMH.js";import{t as D}from"./refresh-cw-JFuyDj_P.js";import{t as O}from"./settings-2-BI4SCkxQ.js";import{t as k}from"./x-BcEayhV6.js";import{t as A}from"./host-capabilities-Tk038i04.js";import{A as j,D as M,E as N,Gt as P,H as F,Ht as I,Kt as L,L as R,N as z,Nt as B,O as V,Pt as H,S as U,T as ee,U as W,V as te,W as ne,b as re,ft as G,g as ie,ht as K,k as ae,mt as q,nt as oe,qt as se,w as ce,x as le,y as ue}from"./index-BP0Hd2jI.js";import{t as de}from"./form-actions-B2-bpFie.js";import{t as J}from"./config-hints-nV5HPOvq.js";import{a as fe,c as pe,i as me,l as he,n as ge,o as _e,r as ve,s as ye}from"./config-split-page-ps1Aod3g.js";var be=m(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),xe=m(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Y=e(n(),1),Se={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Ce(e,t){let n=X(e),r=X(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Z(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function we(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=we(n,t))}return n.trim()}function Te(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ee(e,t){return Z(t)}function De(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Oe(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e={},a=W(i.thinking?.supported);if(a.length>0){let t=ne(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function ke(e,t,n){return{...F(e,n),...F(t,n)}}function Ae(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Te([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function je(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Ce(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!Te(e.models,e.currentEditableModels)||!Ae(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Me(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),Ce(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),Te(e.models,e.currentEditableModels)||(t.models=De(e.models,e.providerName??``)),Ae(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Oe(e.modelConfig,e.models)),t}function Ne(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Pe(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Pe(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Fe(e){return r(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ie(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Le(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Re(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function ze(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function Be(e,t,n){return ze(e,t,n).models.slice(e.length)}function Ve(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function He(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):R.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Ue(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function We(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function Ge(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Ie({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:Le({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Ke(e,t){let n=!!e?.supportsWireApi||t,i=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:r(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:Le({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:i.length}),supportsWireApi:n,wireApiSelectOptions:i}}function qe(e){let{providerName:t,providersView:n,templatesView:i,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=i?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??Se,u=a?.uiHints,d=!!s?.isCustom,f=t?J(`providers.${t}.apiKey`,u):void 0,p=t?J(`providers.${t}.apiBase`,u):void 0,m=t?J(`providers.${t}.extraHeaders`,u):void 0,h=t?J(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=d||c?.supportsModelDiscovery===!0,b=Z([c?.modelPrefix||c?.providerType||``,t||``]),x=c?.defaultApiBase||``,S=l.apiBase||x,C=X(l.extraHeaders||null),w=l.wireApi||c?.defaultWireApi||`auto`,T=Ee(Z((c?.defaultModels??[]).map(e=>Q(e,b))),Z((l.models??[]).map(e=>Q(e,b)))),E=Oe(ke(c?.modelConfig,l.modelConfig,b),T),D=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||r(`providerApiBaseHelp`),O=Ge({providerName:t,providerSpec:c,language:o}),k=Ke(c,d);return{apiBaseHelpText:D,apiBaseHint:p,apiKeyHint:f,currentApiBase:S,currentEditableModels:T,currentEnabled:v,currentHeaders:C,currentModelConfig:E,currentWireApi:w,defaultApiBase:x,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...O,providerConfig:s,providerModelAliases:b,resolvedProviderConfig:l,supportsModelDiscovery:y,wireApiHint:h,...k}}function Je(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:i}=e,a=c(),o=ae(),s=ee(),l=ce(),[u,d]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},[]),y=(0,Y.useCallback)((e,n)=>{v(),_.current=window.setTimeout(()=>{(async()=>{if(t)try{let i=await s.mutateAsync({provider:t,data:{sessionId:e}});if(i.status===`pending`){g(r(`providerAuthWaitingBrowser`)),y(e,i.nextPollMs??n);return}if(i.status===`authorized`){m(null),v(),g(r(`providerAuthCompleted`)),f.success(r(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(i.message||`Authorization ${i.status}.`),f.error(i.message||`Authorization ${i.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),f.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[v,s,t,a]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),g(``);let e=await o.mutateAsync({provider:t,data:i?{methodId:i}:{}});if(!e.sessionId||!e.verificationUri)throw Error(r(`providerAuthStartFailed`));m(e.sessionId),g(`${r(`providerAuthOpenPrompt`)}${e.userCode}${r(`providerAuthOpenPromptSuffix`)}`),await A.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),f.error(`${r(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,i,y,o]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),v(),m(null);let e=await l.mutateAsync({provider:t});g(`${r(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),f.success(r(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),f.error(`${r(`providerAuthImportFailed`)}: ${t}`)}},[v,l,n?.kind,t,a]);return(0,Y.useEffect)(()=>{v()},[v,t]),(0,Y.useEffect)(()=>()=>v(),[v]),{authSessionId:u===t?p:null,authStatusMessage:u===t?h:``,importAuthFromCli:x,importPending:l.isPending,startAuth:b,startPending:o.isPending}}function Ye(e){let{providerName:t,apiKey:n,apiKeyRequired:i,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:c,wireApi:l,models:u,providerModelAliases:p}=e,m=j(),h=U(),g=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[_,v]=(0,Y.useState)(null),y=(0,Y.useCallback)(async()=>{if(t)try{let e=await m.mutateAsync({provider:t,data:Ne({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:c,wireApi:l,models:u,providerModelAliases:p})});if(e.success){f.success(`${r(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let i=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&i.push(`model=${e.model}`),f.error(`${r(`providerTestConnectionFailed`)}: ${e.message} | ${i.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);f.error(`${r(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,u,p,t,c,m,l]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(i&&!n.trim()&&!a)return f.error(r(`providerModelsApiKeyRequired`)),null;try{let e=await h.mutateAsync({provider:t,data:Pe({apiKey:n,apiBase:o,extraHeaders:s})});return v({key:g,models:e.models}),f.success(r(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof d&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return f.error(r(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return f.error(`${r(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,i,a,h,g,s,t]),fetchedModels:_?.key===g?_.models:[],isDiscoveringModels:h.isPending,isTestPending:m.isPending,testConnection:y}}var $=a();function Xe({value:e,onChange:n,className:i}){let a=e?Object.entries(e):[],o=(e,t,r)=>{let i=[...a];i[e]=[t,r],n(Object.fromEntries(i))},s=()=>{n({...e,"":``})},c=e=>{let t=a.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,$.jsxs)(`div`,{className:t(`space-y-2`,i),children:[a.map(([e,t],n)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(p,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:r(`headerName`),className:`flex-1`}),(0,$.jsx)(p,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:r(`headerValue`),className:`flex-1`}),(0,$.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>c(n),children:(0,$.jsx)(H,{className:`h-4 w-4 text-red-500`})})]},n)),(0,$.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),r(`add`)]})]})}function Ze(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:e.label},e.value)})})}function Qe(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:u,extraHeadersLabel:d,extraHeaders:f,onExtraHeadersChange:p}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),r(`providerAdvancedSettings`)]}),(0,$.jsx)(h,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)(Ze,{value:o,onChange:e=>s(e),options:u}):(0,$.jsxs)(b,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(_,{className:`rounded-xl`,children:(0,$.jsx)(g,{})}),(0,$.jsx)(v,{children:u.map(e=>(0,$.jsx)(y,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{className:`text-sm font-medium text-foreground`,children:d}),(0,$.jsx)(Xe,{value:f,onChange:p}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerExtraHeadersHelpShort`)})]})]}):null]})}function $e({isSet:e,className:n,value:r,onChange:i,placeholder:a,...o}){let[s,c]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)(!1),f=typeof r==`string`&&r.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!l?(0,$.jsx)(`div`,{onClick:()=>d(!0),className:t(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,n),children:`••••••••••••`}):(0,$.jsx)(p,{type:s?`text`:`password`,className:t(`pr-12`,n),value:r,onChange:i,onBlur:()=>{f||d(!1)},placeholder:a,autoFocus:l,...o}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,$.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>c(!s),children:s?(0,$.jsx)(xe,{className:`h-4 w-4`}):(0,$.jsx)(P,{className:`h-4 w-4`})})})]})}function et(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:i,apiKeyPlaceholder:a,providerAuth:o,providerAuthNote:s,providerAuthMethodOptions:c,providerAuthMethodsCount:d,selectedAuthMethodHint:f,shouldUseAuthMethodPills:p,resolvedAuthMethodId:m,onAuthMethodChange:h,onStartProviderAuth:x,onImportProviderAuthFromCli:S,startPending:C,importPending:w,authSessionId:T,authStatusMessage:E,onApiKeyChange:D}=e,O=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:r(`apiKey`)}),(0,$.jsx)($e,{id:`apiKey`,value:t,isSet:i,onChange:e=>D(e.target.value),placeholder:a,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`leaveBlankToKeepUnchanged`)})]}):null;return o?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[O,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(l,{className:`text-sm font-medium text-foreground`,children:o.displayName||r(`providerAuthSectionTitle`)}),s?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}):null,d>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{className:`text-xs font-medium text-foreground`,children:r(`providerAuthMethodLabel`)}),p?(0,$.jsx)(Ze,{value:m,onChange:h,options:c}):(0,$.jsxs)(b,{value:m,onValueChange:h,children:[(0,$.jsx)(_,{className:`h-8 rounded-lg`,children:(0,$.jsx)(g,{placeholder:r(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(v,{children:c.map(e=>(0,$.jsx)(y,{value:e.value,children:e.label},e.value))})]}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:f}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:x,disabled:C||!!T,children:r(C?`providerAuthStarting`:T?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),o.supportsCliImport?(0,$.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:S,disabled:w,children:r(w?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,T?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[r(`providerAuthSessionLabel`),`: `,T.slice(0,8),`…`]}):null]}),E?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E}):null]})]}):O}function tt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=N({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>Be(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=ze(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function nt(e){let{models:t,modelConfig:n,onModelsChange:i,onRemoveModel:a,onToggleModelThinkingLevel:s,onSetModelThinkingDefault:c,onSetModelVision:u,thinkingLevels:d,formatThinkingLevelLabel:f}=e,[p,m]=(0,Y.useState)(!1),[h,x]=(0,Y.useState)(()=>new Set),S=(0,Y.useMemo)(()=>t.filter(e=>h.has(e)),[t,h]),C=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=()=>{m(!1),x(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:r(`providerModelsSuggestionsSelected`).replace(`{count}`,String(S.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>x(S.length===t.length?new Set:new Set(t)),children:r(S.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:w,children:r(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:S.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{S.length!==0&&(i(t.filter(e=>!h.has(e))),w())},children:[(0,$.jsx)(H,{className:`h-3 w-3`}),r(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>m(!0),children:[(0,$.jsx)(H,{className:`h-3 w-3`}),r(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(p)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:h.has(e),onChange:()=>C(e),"aria-label":r(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=n[e],i=t?.thinking,m=i?.supported??[],x=i?.default??null,S=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`providerModelThinkingTitle`),title:r(`providerModelThinkingTitle`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})}),(0,$.jsxs)(q,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelVisionHint`)})]}),(0,$.jsx)(o,{checked:S,onCheckedChange:t=>u(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${m.includes(t)?`border-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:f(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(l,{className:`text-xs font-medium text-foreground`,children:r(`providerModelThinkingDefault`)}),(0,$.jsxs)(b,{value:x??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:m.length===0,children:[(0,$.jsx)(_,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(g,{})}),(0,$.jsxs)(v,{children:[(0,$.jsx)(y,{value:`__none__`,children:r(`providerModelThinkingDefaultNone`)}),m.map(e=>(0,$.jsx)(y,{value:e,children:f(e)},e))]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`remove`),children:(0,$.jsx)(k,{className:`h-3 w-3`})})]},e)})}),p?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelsRemoveSaveHint`)}):null]})}var rt=20,it=50,at=50;function ot(e){let{expanded:t,fetchedTotal:n,models:i,source:a,onExpandedChange:o,onAddModels:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(()=>new Set),f=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?i.filter(t=>t.toLowerCase().includes(e)):i},[i,c]),m=f.slice(0,at),h=(0,Y.useMemo)(()=>i.filter(e=>u.has(e)),[i,u]),g=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{e.length!==0&&(s(e),l(``),d(new Set))},v=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&i.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:r(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(n))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":t,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground`,onClick:()=>o(!t),children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r(v).replace(`{count}`,String(i.length))}),(0,$.jsx)(se,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${t?`rotate-90`:``}`})]}),i.length<=it?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10`,onClick:()=>_(i),children:r(`providerModelsSuggestionsAddAll`)}):null]}),t?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[i.length>rt?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(p,{value:c,onChange:e=>l(e.target.value),placeholder:r(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto overscroll-contain`,children:[m.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>g(e),"aria-label":r(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),f.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:r(`providerModelsSuggestionsSearchEmpty`)}):null]}),f.length>m.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:r(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(m.length)).replace(`{count}`,String(f.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`providerModelsSuggestionsSelected`).replace(`{count}`,String(h.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:h.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>_(h),children:r(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:r(`providerModelsSuggestionsSaveHint`)})]}):null]})}function st({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(S,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),r(`providerModelsSuggestionsFailed`)]})}function ct(e){let{providerName:t,providerModelAliases:n,models:i,modelConfig:a,modelDraft:o,showModelInput:s,onModelDraftChange:c,onShowModelInputChange:d,onAddModel:f,onModelsChange:m,supportsModelDiscovery:h,onDiscoverModels:g,isDiscoveringModels:_,fetchedModels:v,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w}=e,[O,A]=(0,Y.useState)(!1),j=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=tt({providerName:t,models:i,aliases:n,fetchedModels:v,onModelsChange:m}),L=async()=>{await g()&&(A(!0),window.requestAnimationFrame(()=>{let e=j.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=v.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(l,{className:`text-sm font-medium text-foreground`,children:r(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[h?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:_,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${_?`animate-spin`:``}`}),r(_?`providerModelsFetching`:`providerModelsFetch`)]}):null,s?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),r(`providerAddModel`)]})]})]}),s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(p,{value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),c(``))},placeholder:r(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(u,{type:`button`,size:`sm`,onClick:f,disabled:o.trim().length===0,children:r(`add`)}),(0,$.jsx)(u,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),c(``)},children:(0,$.jsx)(k,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(st,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:h}),h&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),r(`providerModelsSuggestionsChecking`)]}):h&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:j,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ot,{expanded:O,fetchedTotal:v.length,models:F,source:I,onExpandedChange:A,onAddModels:M})}):null,i.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`providerModelsEmptyShort`)}),s?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:r(`providerAddFirstModel`)})]}):(0,$.jsx)(nt,{models:i,modelConfig:a,onModelsChange:m,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w})]})}function lt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:i}){if(!i)return(0,$.jsx)(B,{status:`inactive`,label:r(`disabled`),className:n});let a=!e||t;return(0,$.jsx)(B,{status:a?`ready`:`setup`,label:r(a?`statusReady`:`statusSetup`),className:n})}function ut(e){let{context:t,language:n,providerTitle:i,providerDisplayName:a,apiKey:o,apiBase:s,extraHeaders:c,wireApi:d,models:f,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,connectivity:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:F,onModelsChange:I,onRemoveModel:L,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:B,onSetModelVision:V,onShowAdvancedChange:U,onWireApiChange:ee,onExtraHeadersChange:W,onDeleteProvider:te,onSubmit:ne,onTestConnection:re}=e,G=t.providerAuthMethods.find(e=>e.id===v);return(0,$.jsxs)(ge,{children:[(0,$.jsx)(pe,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:i}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:te,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:r(`providerDelete`),children:(0,$.jsx)(H,{className:`h-4 w-4`})}),(0,$.jsx)(lt,{enabled:t.currentEnabled,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:ne,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(_e,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:r(`providerDisplayName`)}),(0,$.jsx)(p,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||r(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(et,{apiKey:o,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:t.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:t.apiKeyHint?.placeholder??r(`enterApiKey`),providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:G?.hint?.[n]||G?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b,onApiKeyChange:O}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:r(`apiBase`)}),(0,$.jsx)(p,{id:`apiBase`,type:`text`,value:s,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,$.jsx)(ct,{providerName:t.providerConfig?.providerId??``,providerModelAliases:t.providerModelAliases,models:f,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:F,onModelsChange:I,supportsModelDiscovery:t.supportsModelDiscovery,onDiscoverModels:w.discoverModels,isDiscoveringModels:w.isDiscoveringModels,fetchedModels:w.fetchedModels,onRemoveModel:L,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:B,onSetModelVision:V,thinkingLevels:R,formatThinkingLevelLabel:Fe},t.providerConfig?.providerId),(0,$.jsx)(Qe,{showAdvanced:g,onShowAdvancedChange:U,supportsWireApi:t.supportsWireApi,wireApiLabel:r(`wireApi`),wireApi:d,onWireApiChange:ee,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:r(`extraHeaders`),extraHeaders:c,onExtraHeadersChange:W})]}),(0,$.jsx)(ye,{children:(0,$.jsxs)(de,{align:`between`,children:[(0,$.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:re,disabled:w.isTestPending,children:[(0,$.jsx)(be,{className:`mr-1.5 h-3.5 w-3.5`}),w.isTestPending?r(`providerTestingConnection`):r(`providerTestConnection`)]}),(0,$.jsx)(u,{type:`submit`,size:`sm`,disabled:C||!x,children:r(C?`saving`:x?`save`:`unchanged`)})]})})]})]})}function dt({providerName:e,onProviderDeleted:t}){let{data:n}=V(),{data:a}=M(),{data:o}=ue(),s=i(),c=(0,Y.useMemo)(()=>qe({providerName:e,providersView:n,templatesView:a,schema:o,language:s}),[s,e,n,o,a]);if(!e||!c.providerConfig)return(0,$.jsx)(ve,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:r(`providersSelectDescription`)})]})});let l=JSON.stringify({providerConfig:c.providerConfig,currentApiBase:c.currentApiBase,currentEditableModels:c.currentEditableModels,currentModelConfig:c.currentModelConfig,currentWireApi:c.currentWireApi,effectiveDisplayName:c.effectiveDisplayName,preferredAuthMethodId:c.preferredAuthMethodId});return(0,$.jsx)(ft,{providerName:e,onProviderDeleted:t,context:c,language:s},l)}function ft({providerName:e,onProviderDeleted:t,context:n,language:i}){let a=z(),o=le(),{currentApiBase:s,currentEditableModels:c,currentHeaders:l,currentModelConfig:u,currentWireApi:d,defaultApiBase:f,effectiveDisplayName:p,providerAuth:m,providerAuthMethods:h,providerModelAliases:g,resolvedProviderConfig:_,preferredAuthMethodId:v,supportsWireApi:y}=n,[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(s),[w,T]=(0,Y.useState)(_.extraHeaders||null),[E,D]=(0,Y.useState)(d),[O,k]=(0,Y.useState)(c),[A,j]=(0,Y.useState)(u),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(p),[I,L]=(0,Y.useState)(!1),[R,B]=(0,Y.useState)(!1),[V,H]=(0,Y.useState)(v),U=Ye({providerName:e,apiKey:b,apiKeyRequired:_.apiKeyRequired!==!1,apiKeySet:_.apiKeySet,apiBase:S,extraHeaders:w,supportsWireApi:y,wireApi:E,models:O,providerModelAliases:g}),ee=P.trim()||p||e||r(`providersSelectPlaceholder`),W=(0,Y.useMemo)(()=>{if(!h.length)return``;let e=V.trim();return e&&h.some(t=>t.id===e)?e:v||h[0]?.id||``},[V,v,h]),{authSessionId:te,authStatusMessage:ne,importAuthFromCli:re,importPending:G,startAuth:ie,startPending:K}=Je({providerName:e,providerAuth:m,resolvedAuthMethodId:W}),ae=(0,Y.useMemo)(()=>je({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:P,effectiveDisplayName:p}),[e,b,S,s,w,l,y,E,d,O,c,A,u,P,p]),q=e=>{k(e),j(t=>Oe(t,e))};return(0,$.jsx)(ut,{context:n,language:i,providerTitle:ee,providerDisplayName:P,apiKey:b,apiBase:S,extraHeaders:w,wireApi:E,models:O,modelConfig:A,modelDraft:M,showAdvanced:I,showModelInput:R,resolvedAuthMethodId:W,authSessionId:te,authStatusMessage:ne,hasChanges:ae,isDeletePending:o.isPending,isUpdatePending:a.isPending,connectivity:U,startPending:K,importPending:G,onProviderDisplayNameChange:F,onApiKeyChange:x,onApiBaseChange:C,onAuthMethodChange:H,onStartProviderAuth:ie,onImportProviderAuthFromCli:re,onModelDraftChange:N,onShowModelInputChange:B,onAddModel:()=>{let e=Re(O,M,g);q(e.models),N(e.draft)},onModelsChange:q,onRemoveModel:e=>{let t=Ve(O,A,e);k(t.models),j(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{j(n=>He(n,e,t))},onSetModelThinkingDefault:(e,t)=>{j(n=>Ue(n,e,t))},onSetModelVision:(e,t)=>{j(n=>We(n,e,t))},onShowAdvancedChange:L,onWireApiChange:D,onExtraHeadersChange:T,onDeleteProvider:async()=>{if(e&&window.confirm(r(`providerDeleteConfirm`)))try{await o.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&a.mutate({provider:e,data:Me({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,defaultApiBase:f,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:P,effectiveDisplayName:p})})},onTestConnection:U.testConnection})}function pt(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function mt(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function ht(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function gt(){let{isMobile:e}=ie(),{data:n}=V(),{data:i}=M(),a=re(),c=le(),l=z(),[d,f]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)([]),[b,x]=(0,Y.useState)(``),S=(0,Y.useMemo)(()=>mt(Object.values(n?.providers??{}),v),[n?.providers,v]),T=(0,Y.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),D=(0,Y.useMemo)(()=>ht(T),[T]),O=(0,Y.useMemo)(()=>new Map(T.map(e=>[e.providerType,e])),[T]),k=(0,Y.useMemo)(()=>{let e=b.trim().toLowerCase();return S.filter(t=>{if(!e)return!0;let n=t.providerType?O.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[S,b,O]),A=(0,Y.useMemo)(()=>d&&k.some(e=>e.providerId===d)?d:e?null:k[0]?.providerId??null,[k,e,d]);return!n||!i?(0,$.jsx)(s,{title:r(`providersPageTitle`),description:r(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`providersLoading`)})}):(0,$.jsxs)(s,{title:r(`providersPageTitle`),description:r(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(fe,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>f(null),mobileListLabel:r(`providersPageTitle`),children:[(0,$.jsxs)(he,{children:[(0,$.jsx)(pe,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(G,{open:g,onOpenChange:_,children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(u,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),a.isPending?r(`saving`):r(`providerAdd`)]})}),(0,$.jsxs)(q,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:r(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-muted/45`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});x(``),f(e.providerId),y(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(oe,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:r(`providerAddCustom`)})]}),D.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-muted/40`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});x(``),f(t.providerId),y(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(oe,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(p,{value:b,onChange:e=>x(e.target.value),placeholder:r(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(_e,{className:`space-y-2 p-3`,children:[k.map(e=>{let n=e.providerType?O.get(e.providerType):null,i=e.enabled!==!1,a=te(e),s=e.displayName?.trim()||n?.displayName||e.providerId,c=pt(e.apiBase||n?.defaultApiBase||``)||r(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>f(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.providerId))},role:`button`,tabIndex:0,className:t(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,A===e.providerId?`bg-background/95 text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-background/65 hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(oe,{name:e.providerType??e.providerId,src:n?.logo?`/logos/${n.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[c,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(o,{checked:i,disabled:l.isPending,title:r(i?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{l.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),title:r(`more`),children:(0,$.jsx)(L,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-sm text-red-600 hover:bg-red-50`,onClick:()=>h(e.providerId),children:[(0,$.jsx)(H,{className:`h-4 w-4`}),r(`providerDelete`)]})})]})]}),(0,$.jsx)(B,{status:i?a?`ready`:`setup`:`inactive`,label:r(i?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),k.length===0?(0,$.jsx)(me,{icon:I,title:r(`providersNoMatch`)}):null]})]}),(0,$.jsx)(dt,{providerName:A??void 0,onProviderDeleted:e=>{y(t=>t.filter(t=>t!==e)),e===A&&f(null)}})]}),(0,$.jsx)(C,{open:!!m,onOpenChange:e=>{e||h(null)},title:r(`providerDelete`),description:m??void 0,confirmLabel:r(`delete`),variant:`destructive`,onCancel:()=>h(null),onConfirm:()=>{m&&c.mutateAsync({provider:m}).then(()=>{y(e=>e.filter(e=>e!==m)),m===A&&f(null),h(null)})}})]})}export{gt as ProvidersConfigPage};
@@ -1 +0,0 @@
1
- import{jt as e}from"./index-BP0Hd2jI.js";export{e as RemoteAccessPage};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-DkR7_Dpl.js";var t=e(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]);export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-BlXwvOLo.js";import{Bt as i,Gt as a,Ht as o,Jt as s,Mt as c,Wt as l,Xt as u,Yt as d,Zt as f,nn as p,sn as m,tn as h}from"./api-a_GaOFc7.js";import{g}from"./mcp-marketplace-page-w8panjZG.js";import{a as _,i as v,n as y,r as b,t as x}from"./select-rUZ8nIZu.js";import{t as S}from"./loader-circle-DyXZU92l.js";import{t as C}from"./plus-Dhb4KuMH.js";import{t as ee}from"./rotate-cw-DjbbiIW_.js";import{t as w}from"./save-BL8P8CLX.js";import{Ft as T,P as E,Pt as D,Rt as O,_ as k,c as A,f as te,l as j}from"./index-BP0Hd2jI.js";import{t as M}from"./form-actions-B2-bpFie.js";var N=e(t(),1),P=r(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return n(F[e]??`runtimeControlUnavailable`)}function z(e){return n(I[e]??`runtimeControlServiceUnknown`)}function B(e){return n(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:n(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:n(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:n(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:n(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(S,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(T,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:r,errorMessage:o,pendingRestart:s,visibleLifecycle:c,visibleMessage:f,visibleServiceState:h}=i(),g=H(r??void 0),_=async e=>{let t=V(r,e);if(!t?.available){m.error(a(t?.reasonIfUnavailable)??n(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(n(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);m.success(a(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:n(`runtimeControlActionFailed`);m.error(`${n(`runtimeControlActionFailed`)}: ${t}`)}},v=async()=>{if(!r?.canRestartApp.available){m.error(a(r?.canRestartApp.reasonIfUnavailable)??n(`runtimeRestartAppUnavailable`));return}if(window.confirm(n(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);m.success(a(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:n(`runtimeControlActionFailed`);m.error(`${n(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(u,{title:n(`runtimeControlTitle`),description:n(`runtimeControlDescription`),children:(0,P.jsxs)(d,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(h)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r?B(r):n(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(c)}),r?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(r.managementHint)}):null,o&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:o}):null]}),s?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:n(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:n(`runtimeControlPendingRestartDescription`)}),s.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:n(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:g.map(n=>(0,P.jsxs)(p,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){v();return}_(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),g.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(g,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(u,{title:n(`runtimePresenceTitle`),description:n(`runtimePresenceDescription`),children:(0,P.jsx)(d,{children:t})})}function ne(){let e=o().runtimeControlView?.environment,t=j(e=>e.supported),r=j(e=>e.initialized),i=j(e=>e.busyAction),a=j(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){A.start();return}A.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(g,{tone:`neutral`,title:n(`runtimePresenceBehaviorLabel`),description:a?.closeToBackground?n(`runtimePresenceBehaviorBackground`):n(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!r||t&&!a?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:n(`runtimePresenceLoading`)}):null,a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(s,{title:n(`runtimePresenceCloseToBackground`),description:n(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(c,{id:`runtime-presence-close-background`,"aria-label":n(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{A.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(s,{title:n(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?n(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??n(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(c,{id:`runtime-presence-launch-login`,"aria-label":n(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{A.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:n(`runtimePresenceManagedLocalTitle`),description:n(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:n(`runtimePresenceSelfHostedTitle`),description:n(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:n(`runtimePresenceSharedTitle`),description:n(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:n(`runtimePresenceLoading`)})})}function q(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(ne,{}),(0,P.jsx)(te,{})]})}var J={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function Y(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function X(){return{agentId:``,match:{channel:``,accountId:``}}}function Z(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:J,configText:JSON.stringify(J,null,2)}}function re(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ie(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(re),bindings:(e.bindings??[]).map(ie),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(n(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),r=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(r.length>0)throw Error(`${n(`duplicateAgentId`)}: ${r[0]}`);let i=e.bindings.map((t,r)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(n(`bindingAgentIdRequired`).replace(`{index}`,String(r)));if(!e.knownAgentIds.has(i))throw Error(`${n(`bindingAgentIdNotFound`).replace(`{index}`,String(r))}: ${i}`);if(!a)throw Error(n(`bindingChannelRequired`).replace(`{index}`,String(r)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(n(`bindingPeerIdRequired`).replace(`{index}`,String(r)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,r)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(n(`runtimeEntryIdRequired`).replace(`{index}`,String(r)));if(!a)throw Error(n(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${n(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(n(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:r,onSetDefaultAgent:i,onUpdateAgent:a}){return(0,P.jsx)(u,{title:n(`agentList`),description:n(`agentListHelp`),actions:(0,P.jsxs)(p,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),n(`addAgent`)]}),children:(0,P.jsx)(d,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(h,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:n(`agentIdPlaceholder`)}),(0,P.jsx)(h,{value:e.workspace??``,onChange:e=>a(t,{workspace:e.target.value}),placeholder:n(`workspaceOverridePlaceholder`)}),(0,P.jsx)(h,{value:e.model??``,onChange:e=>a(t,{model:e.target.value}),placeholder:n(`modelOverridePlaceholder`)}),(0,P.jsx)(h,{value:e.runtime??e.engine??``,onChange:e=>a(t,{runtime:e.target.value}),placeholder:n(`engineOverridePlaceholder`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,P.jsx)(h,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>a(t,{contextTokens:Q(e.target.value)}),placeholder:n(`contextTokensPlaceholder`)}),(0,P.jsx)(h,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>a(t,{maxToolIterations:Q(e.target.value)}),placeholder:n(`maxToolsPlaceholder`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(c,{checked:!!e.default,onCheckedChange:e=>i(t,e)}),(0,P.jsx)(`span`,{children:n(`defaultAgent`)})]}),(0,P.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(t),children:[(0,P.jsx)(D,{className:`h-4 w-4 mr-1`}),n(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:r,onUpdateBinding:i}){return(0,P.jsx)(u,{title:n(`bindings`),description:n(`bindingsHelp`),actions:(0,P.jsxs)(p,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),n(`addBinding`)]}),children:(0,P.jsx)(d,{children:e.map((e,t)=>{let a=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(h,{value:e.agentId,onChange:n=>i(t,{...e,agentId:n.target.value}),placeholder:n(`targetAgentIdPlaceholder`)}),(0,P.jsx)(h,{value:e.match.channel,onChange:n=>i(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:n(`channelPlaceholder`)}),(0,P.jsx)(h,{value:e.match.accountId??``,onChange:n=>i(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:n(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(x,{value:a||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;i(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(v,{children:(0,P.jsx)(_,{})}),(0,P.jsxs)(y,{children:[(0,P.jsx)(b,{value:`__none__`,children:n(`peerKindOptional`)}),(0,P.jsx)(b,{value:`direct`,children:n(`peerKindDirect`)}),(0,P.jsx)(b,{value:`group`,children:n(`peerKindGroup`)}),(0,P.jsx)(b,{value:`channel`,children:n(`peerKindChannel`)})]})]}),(0,P.jsx)(h,{value:e.match.peer?.id??``,onChange:n=>i(t,{...e,match:{...e.match,peer:a?{kind:a,id:n.target.value}:void 0}}),placeholder:n(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(t),children:[(0,P.jsx)(D,{className:`h-4 w-4 mr-1`}),n(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:r,onUpdateEntry:i}){return(0,P.jsx)(u,{title:n(`runtimeEntries`),description:n(`runtimeEntriesHelp`),actions:(0,P.jsxs)(p,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),n(`addRuntimeEntry`)]}),children:(0,P.jsx)(d,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(h,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:n(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(h,{value:e.label??``,onChange:e=>i(t,{label:e.target.value}),placeholder:n(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(h,{value:e.type,onChange:e=>i(t,{type:e.target.value}),placeholder:n(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:n(`enabled`)}),(0,P.jsx)(c,{checked:e.enabled!==!1,onCheckedChange:e=>i(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:n(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>i(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(p,{type:`button`,variant:`outline`,onClick:()=>r(t),children:[(0,P.jsx)(D,{className:`mr-2 h-4 w-4`}),n(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:r,dmScope:i,onCompanionEnabledChange:a,onDefaultContextTokensChange:o,onDefaultEngineChange:l,onDmScopeChange:f}){return(0,P.jsx)(u,{title:n(`dmScope`),description:n(`dmScopeHelp`),children:(0,P.jsxs)(d,{children:[(0,P.jsx)(s,{title:n(`runtimeCompanionEnabled`),description:n(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(c,{checked:e,onCheckedChange:a})}),(0,P.jsx)(s,{title:n(`defaultContextTokens`),description:n(`defaultContextTokensHelp`),control:(0,P.jsx)(h,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>o(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(s,{title:n(`defaultEngine`),description:n(`defaultEngineHelp`),control:(0,P.jsx)(h,{value:r,onChange:e=>l(e.target.value),placeholder:n(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(s,{title:n(`dmScope`),control:(0,P.jsxs)(x,{value:i,onValueChange:e=>f(e),children:[(0,P.jsx)(v,{className:`w-56`,children:(0,P.jsx)(_,{})}),(0,P.jsx)(y,{children:ue.map(e=>(0,P.jsx)(b,{value:e.value,children:n(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let r=(0,N.useMemo)(()=>ae(e),[e]),[i,a]=(0,N.useState)(r.agents),[o,s]=(0,N.useState)(r.bindings),[c,l]=(0,N.useState)(r.runtimeEntries),[u,d]=(0,N.useState)(r.dmScope),[h,g]=(0,N.useState)(r.companionEnabled),[_,v]=(0,N.useState)(r.defaultContextTokens),[y,b]=(0,N.useState)(r.defaultEngine),x=(0,N.useMemo)(()=>{let e=new Set([`main`]);return i.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[i]);return(0,P.jsxs)(f,{title:n(`runtimePageTitle`),description:n(`runtimePageDescription`),children:[(0,P.jsx)(q,{}),(0,P.jsx)(de,{companionEnabled:h,dmScope:u,defaultContextTokens:_,defaultEngine:y,onCompanionEnabledChange:g,onDmScopeChange:d,onDefaultContextTokensChange:v,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:c,onUpdateEntry:(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>l(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>l(e=>[...e,Z()])}),(0,P.jsx)(se,{agents:i,onUpdateAgent:(e,t)=>{a(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>a(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>a(e=>[...e,Y()]),onSetDefaultAgent:(e,t)=>a(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:o,onUpdateBinding:(e,t)=>{s(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>s(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>s(e=>[...e,X()])}),(0,P.jsx)(M,{children:(0,P.jsxs)(p,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:h,agents:i,bindings:o,runtimeEntries:c,dmScope:u,defaultContextTokens:_,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){m.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?n(`saving`):n(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=k(),r=E();return t||!e?(0,P.jsx)(f,{title:n(`runtimePageTitle`),description:n(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:n(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:r})}export{pe as RuntimeConfig};
@@ -1 +0,0 @@
1
- import{Ot as e}from"./api-a_GaOFc7.js";export{e as SecurityConfig};
@@ -1 +0,0 @@
1
- import{I as e,z as t}from"./react-BlXwvOLo.js";var n=t();function r({className:t,...r}){return(0,n.jsx)(`div`,{className:e(`animate-pulse rounded-md bg-slate-200`,t),...r})}export{r as t};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-DkR7_Dpl.js";var t=e(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};