@nextclaw/ui 0.17.2 → 0.18.1

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 (67) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/assets/{api-CuPWhNDM.js → api-BJioGtWS.js} +1 -1
  3. package/dist/assets/{appearance-settings-page-DRjg6UP3.js → appearance-settings-page-CR2LJW8I.js} +1 -1
  4. package/dist/assets/{book-open-B4ovWX14.js → book-open-aDv6R1av.js} +1 -1
  5. package/dist/assets/{channels-list-page-B26GXq63.js → channels-list-page-BXyx_gxw.js} +1 -1
  6. package/dist/assets/{chat-page-QA0dpNyU.js → chat-page-OP5V5mAm.js} +1 -1
  7. package/dist/assets/{config-split-page-Box_-aBK.js → config-split-page-Bs1wArsX.js} +1 -1
  8. package/dist/assets/{confirm-dialog-uqcCxomz.js → confirm-dialog-BFatCZUq.js} +1 -1
  9. package/dist/assets/{desktop-update-config-DkDor159.js → desktop-update-config-eb7REelt.js} +1 -1
  10. package/dist/assets/{dist-CZLIZntJ.js → dist-CV9wIyME.js} +1 -1
  11. package/dist/assets/{dist-Co2G-YjN.js → dist-D1I3blO_.js} +1 -1
  12. package/dist/assets/{doc-browser-CbCBDdap.js → doc-browser-BFfstBoh.js} +1 -1
  13. package/dist/assets/doc-browser-DEdoMb3X.js +1 -0
  14. package/dist/assets/{doc-browser-context-aeZu0FHR.js → doc-browser-context-BcwcVwX_.js} +1 -1
  15. package/dist/assets/{form-actions-C3Pa1HQb.js → form-actions-YSnn7q_U.js} +1 -1
  16. package/dist/assets/index-DotCWGD1.js +109 -0
  17. package/dist/assets/loader-circle-CsNiT6VM.js +1 -0
  18. package/dist/assets/mcp-marketplace-page-DfUCF-L5.js +1 -0
  19. package/dist/assets/{mcp-marketplace-page-BmqbIQQQ.js → mcp-marketplace-page-ZTHpQTvi.js} +1 -1
  20. package/dist/assets/{model-config-page-BXUoZEEZ.js → model-config-page-BOhaenKN.js} +1 -1
  21. package/dist/assets/{navigation-link-DngetDmN.js → navigation-link-7oSjAC9R.js} +1 -1
  22. package/dist/assets/plus-D6UN8XN5.js +1 -0
  23. package/dist/assets/{provider-scoped-model-input-C4a2TuV7.js → provider-scoped-model-input-DlohNUbq.js} +1 -1
  24. package/dist/assets/{providers-config-page-CHSka1kQ.js → providers-config-page-eYaDPENc.js} +1 -1
  25. package/dist/assets/{react-CPH0zySO.js → react-7zG0fz1I.js} +1 -1
  26. package/dist/assets/{refresh-cw-vTYZqC0b.js → refresh-cw-BUg7hI3u.js} +1 -1
  27. package/dist/assets/remote-Cx_8UTi5.js +1 -0
  28. package/dist/assets/rotate-cw-B3qmXtfJ.js +1 -0
  29. package/dist/assets/{runtime-config-page-V75_zqXa.js → runtime-config-page-D5lV05VE.js} +1 -1
  30. package/dist/assets/{save-lWb6TI69.js → save-CTCYuZqu.js} +1 -1
  31. package/dist/assets/{search-BuUX_0KY.js → search-CfFUpaf7.js} +1 -1
  32. package/dist/assets/{search-config-page-rlkRJZCF.js → search-config-page-DAWe6n7E.js} +1 -1
  33. package/dist/assets/{secrets-config-page-BxCEc8r5.js → secrets-config-page-DyFeZDAi.js} +1 -1
  34. package/dist/assets/security-config-DoVoel5I.js +1 -0
  35. package/dist/assets/{select-oalsltZV.js → select-MSvkWmPP.js} +1 -1
  36. package/dist/assets/{settings-2-Bd9xiNAY.js → settings-2-DXUfAWgg.js} +1 -1
  37. package/dist/assets/skeleton-DDFivi9Y.js +1 -0
  38. package/dist/assets/{tag-chip-B324d_Xk.js → tag-chip-u8g0b0Nf.js} +1 -1
  39. package/dist/assets/x-DdOEUmR4.js +1 -0
  40. package/dist/index.html +19 -19
  41. package/package.json +6 -6
  42. package/src/features/chat/features/conversation/components/__tests__/session-conversation-input.streaming.test.tsx +102 -1
  43. package/src/features/chat/features/conversation/components/session-conversation-area.tsx +2 -0
  44. package/src/features/chat/features/conversation/components/session-conversation-input.tsx +19 -17
  45. package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-controller.test.tsx +46 -0
  46. package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-input-state.test.tsx +31 -0
  47. package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-preference-persistence.test.tsx +110 -0
  48. package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-slash-commands.test.tsx +20 -0
  49. package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +138 -54
  50. package/src/features/chat/features/conversation/hooks/use-session-conversation-input-state.ts +3 -2
  51. package/src/features/chat/features/conversation/hooks/use-session-conversation-preference-actions.ts +30 -3
  52. package/src/features/chat/features/conversation/hooks/use-session-conversation-preference-persistence.ts +88 -0
  53. package/src/features/chat/features/conversation/hooks/use-session-conversation-slash-commands.ts +25 -2
  54. package/src/features/chat/features/session/hooks/__tests__/use-chat-session-update.test.tsx +27 -0
  55. package/src/features/chat/features/session/hooks/use-chat-session-update.ts +17 -6
  56. package/src/shared/lib/i18n/locales/en-US/chat.json +4 -0
  57. package/src/shared/lib/i18n/locales/zh-CN/chat.json +4 -0
  58. package/dist/assets/doc-browser-DUqckL2E.js +0 -1
  59. package/dist/assets/index-CCWgeWoR.js +0 -109
  60. package/dist/assets/loader-circle-DfbWUPdI.js +0 -1
  61. package/dist/assets/mcp-marketplace-page-B2D7ciJL.js +0 -1
  62. package/dist/assets/plus-wNpOxBfP.js +0 -1
  63. package/dist/assets/remote-DgfRmokf.js +0 -1
  64. package/dist/assets/rotate-cw-L_seGUwq.js +0 -1
  65. package/dist/assets/security-config-Cqxe13za.js +0 -1
  66. package/dist/assets/skeleton-D72EdBNa.js +0 -1
  67. package/dist/assets/x-Cps-je1K.js +0 -1
@@ -1 +1 @@
1
- import{c as e}from"./dist-CZLIZntJ.js";var t=e(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
1
+ import{c as e}from"./dist-CV9wIyME.js";var t=e(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{Mt as e}from"./index-DotCWGD1.js";export{e as RemoteAccessPage};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-CV9wIyME.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 +1 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-CPH0zySO.js";import{Gt as i,Kt as a,Nt as o,Qt as s,Ut as c,Vt as l,Xt as u,Yt as d,Zt as f,cn as p,nn as m,rn as h}from"./api-CuPWhNDM.js";import{g}from"./mcp-marketplace-page-BmqbIQQQ.js";import{a as _,i as v,n as y,r as b,t as x}from"./select-oalsltZV.js";import{t as S}from"./loader-circle-DfbWUPdI.js";import{t as C}from"./plus-wNpOxBfP.js";import{t as w}from"./rotate-cw-L_seGUwq.js";import{t as T}from"./save-lWb6TI69.js";import{Ft as E,It as ee,P as D,_ as O,c as k,f as A,l as j,zt as te}from"./index-CCWgeWoR.js";import{t as M}from"./form-actions-C3Pa1HQb.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)(te,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(w,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:r,errorMessage:o,pendingRestart:s,visibleLifecycle:c,visibleMessage:d,visibleServiceState:m}=l(),g=H(r??void 0),_=async e=>{let t=V(r,e);if(!t?.available){p.error(a(t?.reasonIfUnavailable)??n(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(n(`runtimeControlStopServiceConfirm`))))try{let t=await i.runRuntimeControlAction(e);p.success(a(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:n(`runtimeControlActionFailed`);p.error(`${n(`runtimeControlActionFailed`)}: ${t}`)}},v=async()=>{if(!r?.canRestartApp.available){p.error(a(r?.canRestartApp.reasonIfUnavailable)??n(`runtimeRestartAppUnavailable`));return}if(window.confirm(n(`runtimeControlRestartAppConfirm`)))try{let e=await i.runRuntimeControlAction(`restart-app`);p.success(a(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:n(`runtimeControlActionFailed`);p.error(`${n(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(f,{title:n(`runtimeControlTitle`),description:n(`runtimeControlDescription`),children:(0,P.jsxs)(u,{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(m)}),(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:d}),(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)(h,{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)(f,{title:n(`runtimePresenceTitle`),description:n(`runtimePresenceDescription`),children:(0,P.jsx)(u,{children:t})})}function ne(){let e=c().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`){k.start();return}k.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)(d,{title:n(`runtimePresenceCloseToBackground`),description:n(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(o,{id:`runtime-presence-close-background`,"aria-label":n(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{k.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(d,{title:n(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?n(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??n(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(o,{id:`runtime-presence-launch-login`,"aria-label":n(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{k.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)(A,{})]})}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 $(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 ae(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 oe(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(n(`agentIdRequiredError`).replace(`{index}`,String(t)));return ae(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)(f,{title:n(`agentList`),description:n(`agentListHelp`),actions:(0,P.jsxs)(h,{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)(u,{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)(m,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:n(`agentIdPlaceholder`)}),(0,P.jsx)(m,{value:e.workspace??``,onChange:e=>a(t,{workspace:e.target.value}),placeholder:n(`workspaceOverridePlaceholder`)}),(0,P.jsx)(m,{value:e.model??``,onChange:e=>a(t,{model:e.target.value}),placeholder:n(`modelOverridePlaceholder`)}),(0,P.jsx)(m,{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)(m,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>a(t,{contextTokens:Q(e.target.value)}),placeholder:n(`contextTokensPlaceholder`)}),(0,P.jsx)(m,{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)(o,{checked:!!e.default,onCheckedChange:e=>i(t,e)}),(0,P.jsx)(`span`,{children:n(`defaultAgent`)})]}),(0,P.jsxs)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(t),children:[(0,P.jsx)(E,{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)(f,{title:n(`bindings`),description:n(`bindingsHelp`),actions:(0,P.jsxs)(h,{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)(u,{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)(m,{value:e.agentId,onChange:n=>i(t,{...e,agentId:n.target.value}),placeholder:n(`targetAgentIdPlaceholder`)}),(0,P.jsx)(m,{value:e.match.channel,onChange:n=>i(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:n(`channelPlaceholder`)}),(0,P.jsx)(m,{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)(m,{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)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(t),children:[(0,P.jsx)(E,{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)(f,{title:n(`runtimeEntries`),description:n(`runtimeEntriesHelp`),actions:(0,P.jsxs)(h,{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)(u,{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)(m,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:n(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(m,{value:e.label??``,onChange:e=>i(t,{label:e.target.value}),placeholder:n(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(m,{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)(o,{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)(h,{type:`button`,variant:`outline`,onClick:()=>r(t),children:[(0,P.jsx)(E,{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:s,onDefaultEngineChange:c,onDmScopeChange:l}){return(0,P.jsx)(f,{title:n(`dmScope`),description:n(`dmScopeHelp`),children:(0,P.jsxs)(u,{children:[(0,P.jsx)(d,{title:n(`runtimeCompanionEnabled`),description:n(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(o,{checked:e,onCheckedChange:a})}),(0,P.jsx)(d,{title:n(`defaultContextTokens`),description:n(`defaultContextTokensHelp`),control:(0,P.jsx)(m,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>s(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(d,{title:n(`defaultEngine`),description:n(`defaultEngineHelp`),control:(0,P.jsx)(m,{value:r,onChange:e=>c(e.target.value),placeholder:n(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(d,{title:n(`dmScope`),control:(0,P.jsxs)(x,{value:i,onValueChange:e=>l(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)(()=>$(e),[e]),[i,a]=(0,N.useState)(r.agents),[o,c]=(0,N.useState)(r.bindings),[l,u]=(0,N.useState)(r.runtimeEntries),[d,f]=(0,N.useState)(r.dmScope),[m,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)(s,{title:n(`runtimePageTitle`),description:n(`runtimePageDescription`),children:[(0,P.jsx)(q,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:d,defaultContextTokens:_,defaultEngine:y,onCompanionEnabledChange:g,onDmScopeChange:f,onDefaultContextTokensChange:v,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:l,onUpdateEntry:(e,t)=>u(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>u(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>u(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)=>{c(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>c(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>c(e=>[...e,X()])}),(0,P.jsx)(M,{children:(0,P.jsxs)(h,{type:`button`,size:`sm`,onClick:()=>{try{let e=oe({companionEnabled:m,agents:i,bindings:o,runtimeEntries:l,dmScope:d,defaultContextTokens:_,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){p.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(T,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?n(`saving`):n(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=O(),r=D();return t||!e?(0,P.jsx)(s,{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
+ import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-7zG0fz1I.js";import{Gt as i,Kt as a,Nt as o,Qt as s,Ut as c,Vt as l,Xt as u,Yt as d,Zt as f,cn as p,nn as m,rn as h}from"./api-BJioGtWS.js";import{g}from"./mcp-marketplace-page-ZTHpQTvi.js";import{a as _,i as v,n as y,r as b,t as x}from"./select-MSvkWmPP.js";import{t as S}from"./loader-circle-CsNiT6VM.js";import{t as C}from"./plus-D6UN8XN5.js";import{t as w}from"./rotate-cw-B3qmXtfJ.js";import{t as T}from"./save-CTCYuZqu.js";import{Ft as E,It as ee,P as D,_ as O,c as k,f as A,l as j,zt as te}from"./index-DotCWGD1.js";import{t as M}from"./form-actions-YSnn7q_U.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)(te,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(w,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:r,errorMessage:o,pendingRestart:s,visibleLifecycle:c,visibleMessage:d,visibleServiceState:m}=l(),g=H(r??void 0),_=async e=>{let t=V(r,e);if(!t?.available){p.error(a(t?.reasonIfUnavailable)??n(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(n(`runtimeControlStopServiceConfirm`))))try{let t=await i.runRuntimeControlAction(e);p.success(a(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:n(`runtimeControlActionFailed`);p.error(`${n(`runtimeControlActionFailed`)}: ${t}`)}},v=async()=>{if(!r?.canRestartApp.available){p.error(a(r?.canRestartApp.reasonIfUnavailable)??n(`runtimeRestartAppUnavailable`));return}if(window.confirm(n(`runtimeControlRestartAppConfirm`)))try{let e=await i.runRuntimeControlAction(`restart-app`);p.success(a(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:n(`runtimeControlActionFailed`);p.error(`${n(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(f,{title:n(`runtimeControlTitle`),description:n(`runtimeControlDescription`),children:(0,P.jsxs)(u,{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(m)}),(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:d}),(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)(h,{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)(f,{title:n(`runtimePresenceTitle`),description:n(`runtimePresenceDescription`),children:(0,P.jsx)(u,{children:t})})}function ne(){let e=c().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`){k.start();return}k.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)(d,{title:n(`runtimePresenceCloseToBackground`),description:n(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(o,{id:`runtime-presence-close-background`,"aria-label":n(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{k.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(d,{title:n(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?n(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??n(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(o,{id:`runtime-presence-launch-login`,"aria-label":n(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{k.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)(A,{})]})}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 $(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 ae(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 oe(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(n(`agentIdRequiredError`).replace(`{index}`,String(t)));return ae(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)(f,{title:n(`agentList`),description:n(`agentListHelp`),actions:(0,P.jsxs)(h,{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)(u,{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)(m,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:n(`agentIdPlaceholder`)}),(0,P.jsx)(m,{value:e.workspace??``,onChange:e=>a(t,{workspace:e.target.value}),placeholder:n(`workspaceOverridePlaceholder`)}),(0,P.jsx)(m,{value:e.model??``,onChange:e=>a(t,{model:e.target.value}),placeholder:n(`modelOverridePlaceholder`)}),(0,P.jsx)(m,{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)(m,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>a(t,{contextTokens:Q(e.target.value)}),placeholder:n(`contextTokensPlaceholder`)}),(0,P.jsx)(m,{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)(o,{checked:!!e.default,onCheckedChange:e=>i(t,e)}),(0,P.jsx)(`span`,{children:n(`defaultAgent`)})]}),(0,P.jsxs)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(t),children:[(0,P.jsx)(E,{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)(f,{title:n(`bindings`),description:n(`bindingsHelp`),actions:(0,P.jsxs)(h,{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)(u,{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)(m,{value:e.agentId,onChange:n=>i(t,{...e,agentId:n.target.value}),placeholder:n(`targetAgentIdPlaceholder`)}),(0,P.jsx)(m,{value:e.match.channel,onChange:n=>i(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:n(`channelPlaceholder`)}),(0,P.jsx)(m,{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)(m,{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)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(t),children:[(0,P.jsx)(E,{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)(f,{title:n(`runtimeEntries`),description:n(`runtimeEntriesHelp`),actions:(0,P.jsxs)(h,{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)(u,{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)(m,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:n(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(m,{value:e.label??``,onChange:e=>i(t,{label:e.target.value}),placeholder:n(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(m,{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)(o,{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)(h,{type:`button`,variant:`outline`,onClick:()=>r(t),children:[(0,P.jsx)(E,{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:s,onDefaultEngineChange:c,onDmScopeChange:l}){return(0,P.jsx)(f,{title:n(`dmScope`),description:n(`dmScopeHelp`),children:(0,P.jsxs)(u,{children:[(0,P.jsx)(d,{title:n(`runtimeCompanionEnabled`),description:n(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(o,{checked:e,onCheckedChange:a})}),(0,P.jsx)(d,{title:n(`defaultContextTokens`),description:n(`defaultContextTokensHelp`),control:(0,P.jsx)(m,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>s(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(d,{title:n(`defaultEngine`),description:n(`defaultEngineHelp`),control:(0,P.jsx)(m,{value:r,onChange:e=>c(e.target.value),placeholder:n(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(d,{title:n(`dmScope`),control:(0,P.jsxs)(x,{value:i,onValueChange:e=>l(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)(()=>$(e),[e]),[i,a]=(0,N.useState)(r.agents),[o,c]=(0,N.useState)(r.bindings),[l,u]=(0,N.useState)(r.runtimeEntries),[d,f]=(0,N.useState)(r.dmScope),[m,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)(s,{title:n(`runtimePageTitle`),description:n(`runtimePageDescription`),children:[(0,P.jsx)(q,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:d,defaultContextTokens:_,defaultEngine:y,onCompanionEnabledChange:g,onDmScopeChange:f,onDefaultContextTokensChange:v,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:l,onUpdateEntry:(e,t)=>u(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>u(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>u(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)=>{c(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>c(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>c(e=>[...e,X()])}),(0,P.jsx)(M,{children:(0,P.jsxs)(h,{type:`button`,size:`sm`,onClick:()=>{try{let e=oe({companionEnabled:m,agents:i,bindings:o,runtimeEntries:l,dmScope:d,defaultContextTokens:_,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){p.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(T,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?n(`saving`):n(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=O(),r=D();return t||!e?(0,P.jsx)(s,{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 +1 @@
1
- import{c as e}from"./dist-CZLIZntJ.js";var t=e(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
1
+ import{c as e}from"./dist-CV9wIyME.js";var t=e(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
@@ -1 +1 @@
1
- import{c as e}from"./dist-CZLIZntJ.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t as n,n as t};
1
+ import{c as e}from"./dist-CV9wIyME.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t as n,n as t};
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-CPH0zySO.js";import{t as i}from"./navigation-link-DngetDmN.js";import{Qt as a,nn as o,rn as s,tn as c}from"./api-CuPWhNDM.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-oalsltZV.js";import{t as m}from"./search-BuUX_0KY.js";import{F as h,Ut as g,_,g as v,v as y}from"./index-CCWgeWoR.js";import{t as b}from"./form-actions-C3Pa1HQb.js";import{a as x,c as S,l as C,n as w,o as T,r as E,s as D,t as O}from"./config-split-page-Box_-aBK.js";var k=e(t(),1),A=r(),j=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],M=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],N=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],P={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`,exa:`searchProviderExaDescription`};function F(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:``,baseUrl:e.providers.exa.baseUrl}}}}function I(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:e.providers.exa.apiKey||void 0,baseUrl:e.providers.exa.baseUrl}}}}function L(e){let{label:t,value:n,onChange:r,placeholder:i,type:a=`text`,inputMode:s}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(c,{children:t}),(0,A.jsx)(o,{type:a,value:n,onChange:e=>r(e.target.value),placeholder:i,inputMode:s,className:`rounded-xl`})]})}function R(e){let{label:t,value:r,options:i,onChange:a}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(c,{children:t}),(0,A.jsxs)(p,{value:r,onValueChange:a,children:[(0,A.jsx)(u,{className:`rounded-xl`,children:(0,A.jsx)(l,{})}),(0,A.jsx)(d,{children:i.map(e=>(0,A.jsx)(f,{value:e.value,children:n(e.label)},e.value))})]})]})}function z({docsUrl:e}){return e?(0,A.jsx)(i,{href:e,external:!0,children:n(`searchProviderOpenDocs`)}):null}function B(e){let{draft:t,provider:r,search:i,selectedDocsUrl:a,updateProviderDraft:o}=e;if(r===`bocha`){let{bocha:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:n(`apiKey`),value:e.apiKey,onChange:e=>o(`bocha`,{apiKey:e}),placeholder:i.providers.bocha.apiKeyMasked||n(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:n(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`bocha`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:n(`searchProviderSummary`),value:e.summary?`true`:`false`,options:N,onChange:e=>o(`bocha`,{summary:e===`true`})}),(0,A.jsx)(R,{label:n(`searchProviderFreshness`),value:e.freshness,options:j,onChange:e=>o(`bocha`,{freshness:e})})]}),(0,A.jsx)(z,{docsUrl:a??`https://open.bocha.cn`})]})}if(r===`tavily`){let{tavily:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:n(`apiKey`),value:e.apiKey,onChange:e=>o(`tavily`,{apiKey:e}),placeholder:i.providers.tavily.apiKeyMasked||n(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:n(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`tavily`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:n(`searchProviderSearchDepth`),value:e.searchDepth,options:M,onChange:e=>o(`tavily`,{searchDepth:e})}),(0,A.jsx)(R,{label:n(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:N,onChange:e=>o(`tavily`,{includeAnswer:e===`true`})})]}),(0,A.jsx)(z,{docsUrl:a})]})}let s=t.providers[r],c=i.providers[r];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:n(`apiKey`),value:s.apiKey,onChange:e=>o(r,{apiKey:e}),placeholder:c.apiKeyMasked||n(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:n(`searchProviderBaseUrl`),value:s.baseUrl,onChange:e=>o(r,{baseUrl:e})}),(0,A.jsx)(z,{docsUrl:a})]})}function V(e){let{draft:t,providers:r,search:i,selectedProvider:a,onSelect:o}=e;return(0,A.jsxs)(C,{children:[(0,A.jsx)(S,{className:`px-4 py-4`,children:(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:n(`searchChannels`)})}),(0,A.jsx)(T,{className:`space-y-2 p-3`,children:r.map(e=>{let r=i.providers[e.name],s=t.enabledProviders.includes(e.name);return(0,A.jsx)(O,{onClick:()=>o(e.name),active:a===e.name,className:`p-3`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,A.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-muted-foreground`,children:n(P[e.name])})]}),(0,A.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:r.apiKeySet?n(`searchStatusConfigured`):n(`searchStatusNeedsSetup`)}),s?(0,A.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:n(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function H(e){let{initialDraft:t,providers:r,search:i,onSubmit:a,isPending:o}=e,{isMobile:c}=v(),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(t),p=l&&r.some(e=>e.name===l)?l:c?null:i.provider,h=r.find(e=>e.name===p)??null,_=p?i.providers[p]:null,y=p?d.enabledProviders.includes(p):!1,C=_?.docsUrl??h?.docsUrl;return(0,A.jsxs)(x,{className:`md:min-h-0`,compactView:l?`detail`:`list`,onMobileBack:()=>u(null),mobileListLabel:n(`searchPageTitle`),children:[(0,A.jsx)(V,{draft:d,providers:r,search:i,selectedProvider:p??i.provider,onSelect:u}),h?(0,A.jsx)(w,{children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(d)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(S,{className:`px-5 py-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground`,children:(0,A.jsx)(m,{className:`h-5 w-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:h.displayName}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(P[h.name])})]})]}),(0,A.jsx)(s,{type:`button`,variant:y?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=y?d.enabledProviders.filter(e=>e!==p):p?[...d.enabledProviders,p]:d.enabledProviders,t={...d,enabledProviders:e};f(t),a(t)},children:n(y?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,A.jsxs)(T,{className:`space-y-5 px-5 py-4`,children:[(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:n(`searchActiveProvider`),value:d.activeProvider,options:r.map(e=>({value:e.name,label:e.displayName})),onChange:e=>f({...d,activeProvider:e})}),(0,A.jsx)(L,{label:n(`searchDefaultMaxResults`),value:d.maxResults,onChange:e=>f({...d,maxResults:e}),inputMode:`numeric`})]}),(0,A.jsx)(B,{draft:d,provider:p,search:i,selectedDocsUrl:C,updateProviderDraft:(e,t)=>{f(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,A.jsx)(D,{children:(0,A.jsx)(b,{children:(0,A.jsxs)(s,{type:`submit`,size:`sm`,disabled:o,children:[(0,A.jsx)(g,{className:`mr-1.5 h-3.5 w-3.5`}),n(o?`saving`:`saveChanges`)]})})})]})}):(0,A.jsx)(E,{children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`searchNoProviderSelected`)})})]})}function U(){let{data:e}=_(),{data:t}=y(),r=h(),i=t?.search??[],o=e?.search;return!o||i.length===0?(0,A.jsx)(a,{title:n(`searchPageTitle`),description:n(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:n(`loading`)})}):(0,A.jsx)(a,{title:n(`searchPageTitle`),description:n(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(H,{initialDraft:F(o),providers:i,search:o,onSubmit:e=>r.mutate({data:I(e)}),isPending:r.isPending},JSON.stringify(o))})}export{U as SearchConfigPage};
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-7zG0fz1I.js";import{t as i}from"./navigation-link-7oSjAC9R.js";import{Qt as a,nn as o,rn as s,tn as c}from"./api-BJioGtWS.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-MSvkWmPP.js";import{t as m}from"./search-CfFUpaf7.js";import{F as h,Ut as g,_,g as v,v as y}from"./index-DotCWGD1.js";import{t as b}from"./form-actions-YSnn7q_U.js";import{a as x,c as S,l as C,n as w,o as T,r as E,s as D,t as O}from"./config-split-page-Bs1wArsX.js";var k=e(t(),1),A=r(),j=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],M=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],N=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],P={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`,exa:`searchProviderExaDescription`};function F(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:``,baseUrl:e.providers.exa.baseUrl}}}}function I(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:e.providers.exa.apiKey||void 0,baseUrl:e.providers.exa.baseUrl}}}}function L(e){let{label:t,value:n,onChange:r,placeholder:i,type:a=`text`,inputMode:s}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(c,{children:t}),(0,A.jsx)(o,{type:a,value:n,onChange:e=>r(e.target.value),placeholder:i,inputMode:s,className:`rounded-xl`})]})}function R(e){let{label:t,value:r,options:i,onChange:a}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(c,{children:t}),(0,A.jsxs)(p,{value:r,onValueChange:a,children:[(0,A.jsx)(u,{className:`rounded-xl`,children:(0,A.jsx)(l,{})}),(0,A.jsx)(d,{children:i.map(e=>(0,A.jsx)(f,{value:e.value,children:n(e.label)},e.value))})]})]})}function z({docsUrl:e}){return e?(0,A.jsx)(i,{href:e,external:!0,children:n(`searchProviderOpenDocs`)}):null}function B(e){let{draft:t,provider:r,search:i,selectedDocsUrl:a,updateProviderDraft:o}=e;if(r===`bocha`){let{bocha:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:n(`apiKey`),value:e.apiKey,onChange:e=>o(`bocha`,{apiKey:e}),placeholder:i.providers.bocha.apiKeyMasked||n(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:n(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`bocha`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:n(`searchProviderSummary`),value:e.summary?`true`:`false`,options:N,onChange:e=>o(`bocha`,{summary:e===`true`})}),(0,A.jsx)(R,{label:n(`searchProviderFreshness`),value:e.freshness,options:j,onChange:e=>o(`bocha`,{freshness:e})})]}),(0,A.jsx)(z,{docsUrl:a??`https://open.bocha.cn`})]})}if(r===`tavily`){let{tavily:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:n(`apiKey`),value:e.apiKey,onChange:e=>o(`tavily`,{apiKey:e}),placeholder:i.providers.tavily.apiKeyMasked||n(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:n(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`tavily`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:n(`searchProviderSearchDepth`),value:e.searchDepth,options:M,onChange:e=>o(`tavily`,{searchDepth:e})}),(0,A.jsx)(R,{label:n(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:N,onChange:e=>o(`tavily`,{includeAnswer:e===`true`})})]}),(0,A.jsx)(z,{docsUrl:a})]})}let s=t.providers[r],c=i.providers[r];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:n(`apiKey`),value:s.apiKey,onChange:e=>o(r,{apiKey:e}),placeholder:c.apiKeyMasked||n(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:n(`searchProviderBaseUrl`),value:s.baseUrl,onChange:e=>o(r,{baseUrl:e})}),(0,A.jsx)(z,{docsUrl:a})]})}function V(e){let{draft:t,providers:r,search:i,selectedProvider:a,onSelect:o}=e;return(0,A.jsxs)(C,{children:[(0,A.jsx)(S,{className:`px-4 py-4`,children:(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:n(`searchChannels`)})}),(0,A.jsx)(T,{className:`space-y-2 p-3`,children:r.map(e=>{let r=i.providers[e.name],s=t.enabledProviders.includes(e.name);return(0,A.jsx)(O,{onClick:()=>o(e.name),active:a===e.name,className:`p-3`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,A.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-muted-foreground`,children:n(P[e.name])})]}),(0,A.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:r.apiKeySet?n(`searchStatusConfigured`):n(`searchStatusNeedsSetup`)}),s?(0,A.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:n(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function H(e){let{initialDraft:t,providers:r,search:i,onSubmit:a,isPending:o}=e,{isMobile:c}=v(),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(t),p=l&&r.some(e=>e.name===l)?l:c?null:i.provider,h=r.find(e=>e.name===p)??null,_=p?i.providers[p]:null,y=p?d.enabledProviders.includes(p):!1,C=_?.docsUrl??h?.docsUrl;return(0,A.jsxs)(x,{className:`md:min-h-0`,compactView:l?`detail`:`list`,onMobileBack:()=>u(null),mobileListLabel:n(`searchPageTitle`),children:[(0,A.jsx)(V,{draft:d,providers:r,search:i,selectedProvider:p??i.provider,onSelect:u}),h?(0,A.jsx)(w,{children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(d)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(S,{className:`px-5 py-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground`,children:(0,A.jsx)(m,{className:`h-5 w-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:h.displayName}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(P[h.name])})]})]}),(0,A.jsx)(s,{type:`button`,variant:y?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=y?d.enabledProviders.filter(e=>e!==p):p?[...d.enabledProviders,p]:d.enabledProviders,t={...d,enabledProviders:e};f(t),a(t)},children:n(y?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,A.jsxs)(T,{className:`space-y-5 px-5 py-4`,children:[(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:n(`searchActiveProvider`),value:d.activeProvider,options:r.map(e=>({value:e.name,label:e.displayName})),onChange:e=>f({...d,activeProvider:e})}),(0,A.jsx)(L,{label:n(`searchDefaultMaxResults`),value:d.maxResults,onChange:e=>f({...d,maxResults:e}),inputMode:`numeric`})]}),(0,A.jsx)(B,{draft:d,provider:p,search:i,selectedDocsUrl:C,updateProviderDraft:(e,t)=>{f(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,A.jsx)(D,{children:(0,A.jsx)(b,{children:(0,A.jsxs)(s,{type:`submit`,size:`sm`,disabled:o,children:[(0,A.jsx)(g,{className:`mr-1.5 h-3.5 w-3.5`}),n(o?`saving`:`saveChanges`)]})})})]})}):(0,A.jsx)(E,{children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`searchNoProviderSelected`)})})]})}function U(){let{data:e}=_(),{data:t}=y(),r=h(),i=t?.search??[],o=e?.search;return!o||i.length===0?(0,A.jsx)(a,{title:n(`searchPageTitle`),description:n(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:n(`loading`)})}):(0,A.jsx)(a,{title:n(`searchPageTitle`),description:n(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(H,{initialDraft:F(o),providers:i,search:o,onSubmit:e=>r.mutate({data:I(e)}),isPending:r.isPending},JSON.stringify(o))})}export{U as SearchConfigPage};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-CPH0zySO.js";import{Nt as i,Qt as a,Xt as o,Yt as s,Zt as c,cn as l,nn as u,rn as d}from"./api-CuPWhNDM.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-oalsltZV.js";import{t as _}from"./plus-wNpOxBfP.js";import{t as v}from"./save-lWb6TI69.js";import{Ft as y,I as b,_ as x}from"./index-CCWgeWoR.js";import{t as S}from"./form-actions-C3Pa1HQb.js";var C=e(t(),1),w=[`env`,`file`,`exec`];function T(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function E(){return{path:``,source:`env`,provider:``,id:``}}function D(e,t){return t.source===`env`?{...T(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...T(e),source:`file`,path:t.path}:{...T(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{V as t,i as n,z as r}from"./react-7zG0fz1I.js";import{Nt as i,Qt as a,Xt as o,Yt as s,Zt as c,cn as l,nn as u,rn as d}from"./api-BJioGtWS.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-MSvkWmPP.js";import{t as _}from"./plus-D6UN8XN5.js";import{t as v}from"./save-CTCYuZqu.js";import{Ft as y,I as b,_ as x}from"./index-DotCWGD1.js";import{t as S}from"./form-actions-YSnn7q_U.js";var C=e(t(),1),w=[`env`,`file`,`exec`];function T(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function E(){return{path:``,source:`env`,provider:``,id:``}}function D(e,t){return t.source===`env`?{...T(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...T(e),source:`file`,path:t.path}:{...T(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
2
2
  `),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function O(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function k(e){return e?{enabled:!!e.enabled,defaultEnv:e.defaults.env??``,defaultFile:e.defaults.file??``,defaultExec:e.defaults.exec??``,providers:Object.entries(e.providers).map(([e,t])=>D(e,t)),refs:Object.entries(e.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}:{enabled:!0,defaultEnv:``,defaultFile:``,defaultExec:``,providers:[],refs:[]}}function A(e){let t={};for(let[r,i]of e.providers.entries()){let e=i.alias.trim();if(!e)throw Error(`${n(`providerAlias`)} #${r+1} ${n(`isRequired`)}`);if(t[e])throw Error(`${n(`providerAlias`)}: ${e} (${n(`duplicate`)})`);if(i.source===`file`&&!i.path.trim())throw Error(`${n(`secretFilePath`)} #${r+1} ${n(`isRequired`)}`);if(i.source===`exec`&&!i.command.trim())throw Error(`${n(`secretExecCommand`)} #${r+1} ${n(`isRequired`)}`);t[e]=O(i)}let r={};for(let[i,a]of e.refs.entries()){let e=a.path.trim(),o=a.id.trim();if(!e)throw Error(`${n(`secretConfigPath`)} #${i+1} ${n(`isRequired`)}`);if(!o)throw Error(`${n(`secretId`)} #${i+1} ${n(`isRequired`)}`);let s=a.provider.trim();if(s&&!t[s])throw Error(`${n(`secretProviderAlias`)}: ${s} ${n(`notFound`)}`);r[e]={source:a.source,...s?{provider:s}:{},id:o}}return{enabled:e.enabled,defaultEnv:e.defaultEnv.trim(),defaultFile:e.defaultFile.trim(),defaultExec:e.defaultExec.trim(),providers:Object.entries(t).map(([e,t])=>D(e,t)),refs:Object.entries(r).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}}function j(e){return{enabled:e.enabled,defaults:{env:e.defaultEnv||null,file:e.defaultFile||null,exec:e.defaultExec||null},providers:Object.fromEntries(e.providers.map(e=>[e.alias.trim(),O(e)]).filter(([e])=>e)),refs:Object.fromEntries(e.refs.map(e=>[e.path.trim(),{source:e.source,...e.provider.trim()?{provider:e.provider.trim()}:{},id:e.id.trim()}]).filter(([e,t])=>e&&t.id))}}var M=r();function N(e){let{defaultEnv:t,defaultFile:r,defaultExec:i,providerAliases:a,onChange:o}=e;return(0,M.jsx)(M.Fragment,{children:[{label:n(`defaultEnvProvider`),value:t,key:`defaultEnv`},{label:n(`defaultFileProvider`),value:r,key:`defaultFile`},{label:n(`defaultExecProvider`),value:i,key:`defaultExec`}].map(e=>(0,M.jsx)(s,{title:e.label,control:(0,M.jsxs)(g,{value:e.value||`__none__`,onValueChange:t=>o(e.key,t===`__none__`?``:t),children:[(0,M.jsx)(p,{className:`w-56`,children:(0,M.jsx)(f,{placeholder:n(`noneOption`)})}),(0,M.jsxs)(m,{children:[(0,M.jsx)(h,{value:`__none__`,children:n(`noneOption`)}),a.map(e=>(0,M.jsx)(h,{value:e,children:e},e))]})]})},e.key))})}function P(e){let{providers:t,onUpdate:r,onRemove:i,onAdd:a}=e;return(0,M.jsx)(c,{title:n(`secretProvidersTitle`),description:n(`secretProvidersDescription`),actions:(0,M.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,children:[(0,M.jsx)(_,{className:`mr-2 h-4 w-4`}),n(`addSecretProvider`)]}),children:(0,M.jsx)(o,{children:t.map((e,t)=>(0,M.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-3`,children:[(0,M.jsx)(u,{value:e.alias,onChange:e=>r(t,{alias:e.target.value}),placeholder:n(`providerAlias`)}),(0,M.jsxs)(g,{value:e.source,onValueChange:e=>r(t,{source:e}),children:[(0,M.jsx)(p,{children:(0,M.jsx)(f,{})}),(0,M.jsx)(m,{children:w.map(e=>(0,M.jsx)(h,{value:e,children:e},e))})]}),(0,M.jsxs)(d,{type:`button`,variant:`outline`,onClick:()=>i(t),children:[(0,M.jsx)(y,{className:`mr-2 h-4 w-4`}),n(`removeProvider`)]})]}),e.source===`env`?(0,M.jsx)(u,{value:e.prefix,onChange:e=>r(t,{prefix:e.target.value}),placeholder:n(`envPrefix`)}):null,e.source===`file`?(0,M.jsx)(u,{value:e.path,onChange:e=>r(t,{path:e.target.value}),placeholder:n(`secretFilePath`)}):null,e.source===`exec`?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(u,{value:e.command,onChange:e=>r(t,{command:e.target.value}),placeholder:n(`secretExecCommand`)}),(0,M.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-input bg-background px-3 py-2 font-mono text-xs`,value:e.argsText,onChange:e=>r(t,{argsText:e.target.value}),placeholder:n(`secretExecArgs`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-2`,children:[(0,M.jsx)(u,{value:e.cwd,onChange:e=>r(t,{cwd:e.target.value}),placeholder:n(`secretExecCwd`)}),(0,M.jsx)(u,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>r(t,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:n(`secretExecTimeoutMs`)})]})]}):null]},`provider-${t}`))})})}function F(e){let{refs:t,providerAliases:r,onUpdate:i,onRemove:a,onAdd:s}=e;return(0,M.jsx)(c,{title:n(`secretRefsTitle`),description:n(`secretRefsDescription`),actions:(0,M.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:[(0,M.jsx)(_,{className:`mr-2 h-4 w-4`}),n(`addSecretRef`)]}),children:(0,M.jsx)(o,{children:t.map((e,t)=>(0,M.jsx)(`div`,{className:`space-y-3 p-4`,children:(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,M.jsx)(u,{value:e.path,onChange:e=>i(t,{path:e.target.value}),placeholder:n(`secretConfigPath`)}),(0,M.jsx)(u,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:n(`secretId`)}),(0,M.jsxs)(g,{value:e.source,onValueChange:e=>i(t,{source:e}),children:[(0,M.jsx)(p,{children:(0,M.jsx)(f,{})}),(0,M.jsx)(m,{children:w.map(e=>(0,M.jsx)(h,{value:e,children:e},e))})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,M.jsxs)(g,{value:e.provider||`__none__`,onValueChange:e=>i(t,{provider:e===`__none__`?``:e}),children:[(0,M.jsx)(p,{children:(0,M.jsx)(f,{placeholder:n(`secretProviderAlias`)})}),(0,M.jsxs)(m,{children:[(0,M.jsx)(h,{value:`__none__`,children:n(`noneOption`)}),r.map(e=>(0,M.jsx)(h,{value:e,children:e},e))]})]}),(0,M.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>a(t),children:(0,M.jsx)(y,{className:`h-4 w-4`})})]})]})},`ref-${t}`))})})}function I(e){let{initialState:t,isPending:r,onSubmit:u}=e,[f,p]=(0,C.useState)(t),m=(0,C.useMemo)(()=>{let e=f.providers.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[f.providers]);return(0,M.jsxs)(a,{title:n(`secretsPageTitle`),description:n(`secretsPageDescription`),children:[(0,M.jsx)(c,{title:n(`secrets`),description:n(`secretsEnabledHelp`),children:(0,M.jsxs)(o,{children:[(0,M.jsx)(s,{title:n(`enabled`),description:n(`secretsEnabledHelp`),control:(0,M.jsx)(i,{checked:f.enabled,onCheckedChange:e=>p(t=>({...t,enabled:e}))})}),(0,M.jsx)(N,{defaultEnv:f.defaultEnv,defaultFile:f.defaultFile,defaultExec:f.defaultExec,providerAliases:m,onChange:(e,t)=>p(n=>({...n,[e]:t}))})]})}),(0,M.jsx)(P,{providers:f.providers,onUpdate:(e,t)=>{p(n=>({...n,providers:n.providers.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>p(t=>({...t,providers:t.providers.filter((t,n)=>n!==e)})),onAdd:()=>p(e=>({...e,providers:[...e.providers,T()]}))}),(0,M.jsx)(F,{refs:f.refs,providerAliases:m,onUpdate:(e,t)=>{p(n=>({...n,refs:n.refs.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>p(t=>({...t,refs:t.refs.filter((t,n)=>n!==e)})),onAdd:()=>p(e=>({...e,refs:[...e.refs,E()]}))}),(0,M.jsx)(S,{children:(0,M.jsxs)(d,{type:`button`,size:`sm`,onClick:()=>{try{u(A(f))}catch(e){l.error(e instanceof Error?e.message:String(e))}},disabled:r,children:[(0,M.jsx)(v,{className:`mr-1.5 h-3.5 w-3.5`}),n(r?`saving`:`save`)]})})]})}function L(){let{data:e,isLoading:t}=x(),r=b();return t?(0,M.jsx)(a,{title:n(`secretsPageTitle`),description:n(`secretsPageDescription`),children:(0,M.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:n(`loading`)})}):(0,M.jsx)(I,{initialState:k(e?.secrets),isPending:r.isPending,onSubmit:e=>r.mutate({data:j(e)})},JSON.stringify(e?.secrets??null))}export{L as SecretsConfigPage};
@@ -0,0 +1 @@
1
+ import{kt as e}from"./api-BJioGtWS.js";export{e as SecurityConfig};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{B as t,I as n,V as r,z as i}from"./react-CPH0zySO.js";import{_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,n as h,o as g,p as _,r as v,s as y,u as b,x,y as S}from"./dist-CZLIZntJ.js";var C=e(r(),1),w=i(),T=`focusScope.autoFocusOnMount`,E=`focusScope.autoFocusOnUnmount`,D={bubbles:!1,cancelable:!0},O=`FocusScope`,k=C.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,d]=C.useState(null),f=l(i),p=l(a),m=C.useRef(null),h=s(t,e=>d(e)),g=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let e=function(e){if(g.paused||!c)return;let t=e.target;c.contains(t)?m.current=t:P(m.current,{select:!0})},t=function(e){if(g.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||P(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&P(c)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,g.paused]),C.useEffect(()=>{if(c){F.add(g);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(T,D);c.addEventListener(T,f),c.dispatchEvent(t),t.defaultPrevented||(A(L(ee(c)),{select:!0}),document.activeElement===e&&P(c))}return()=>{c.removeEventListener(T,f),setTimeout(()=>{let t=new CustomEvent(E,D);c.addEventListener(E,p),c.dispatchEvent(t),t.defaultPrevented||P(e??document.body,{select:!0}),c.removeEventListener(E,p),F.remove(g)},0)}}},[c,f,p,g]);let _=C.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=j(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&P(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&P(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,w.jsx)(u.div,{tabIndex:-1,...o,ref:h,onKeyDown:_})});k.displayName=O;function A(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(P(r,{select:t}),document.activeElement!==n)return}function j(e){let t=ee(e);return[te(t,e),te(t.reverse(),e)]}function ee(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function te(e,t){for(let n of e)if(!M(n,{upTo:t}))return n}function M(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function N(e){return e instanceof HTMLInputElement&&`select`in e}function P(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&N(e)&&t&&e.select()}}var F=ne();function ne(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=I(e,t),e.unshift(t)},remove(t){e=I(e,t),e[0]?.resume()}}}function I(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function L(e){return e.filter(e=>e.tagName!==`A`)}var R=0;function re(){C.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??ie()),document.body.insertAdjacentElement(`beforeend`,e[1]??ie()),R++,()=>{R===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),R--}},[])}function ie(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var z=function(){return z=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},z.apply(this,arguments)};function ae(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function oe(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var B=`right-scroll-bar-position`,V=`width-before-scroll-bar`,se=`with-scroll-bars-hidden`,ce=`--removed-body-scroll-bar-size`;function le(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ue(e,t){var n=(0,C.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var de=typeof window<`u`?C.useLayoutEffect:C.useEffect,fe=new WeakMap;function pe(e,t){var n=ue(t||null,function(t){return e.forEach(function(e){return le(e,t)})});return de(function(){var t=fe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||le(e,null)}),i.forEach(function(e){r.has(e)||le(e,a)})}fe.set(n,e)},[e]),n}function me(e){return e}function he(e,t){t===void 0&&(t=me);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ge(e){e===void 0&&(e={});var t=he(null);return t.options=z({async:!0,ssr:!1},e),t}var _e=function(e){var t=e.sideCar,n=ae(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return C.createElement(r,z({},n))};_e.isSideCarExport=!0;function ve(e,t){return e.useMedium(t),_e}var ye=ge(),be=function(){},xe=C.forwardRef(function(e,t){var n=C.useRef(null),r=C.useState({onScrollCapture:be,onWheelCapture:be,onTouchMoveCapture:be}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=ae(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=pe([n,t]),w=z(z({},b),i);return C.createElement(C.Fragment,null,u&&C.createElement(x,{sideCar:ye,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?C.cloneElement(C.Children.only(s),z(z({},w),{ref:S})):C.createElement(v,z({},w,{className:c,ref:S}),s))});xe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},xe.classNames={fullWidth:V,zeroRight:B};var Se,Ce=function(){if(Se)return Se;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function we(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ce();return t&&e.setAttribute(`nonce`,t),e}function Te(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ee(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var De=function(){var e=0,t=null;return{add:function(n){e==0&&(t=we())&&(Te(t,n),Ee(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Oe=function(){var e=De();return function(t,n){C.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ke=function(){var e=Oe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Ae={left:0,top:0,right:0,gap:0},je=function(e){return parseInt(e||``,10)||0},Me=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[je(n),je(r),je(i)]},Ne=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Ae;var t=Me(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Pe=ke(),H=`data-scroll-locked`,Fe=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{B as t,I as n,V as r,z as i}from"./react-7zG0fz1I.js";import{_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,n as h,o as g,p as _,r as v,s as y,u as b,x,y as S}from"./dist-CV9wIyME.js";var C=e(r(),1),w=i(),T=`focusScope.autoFocusOnMount`,E=`focusScope.autoFocusOnUnmount`,D={bubbles:!1,cancelable:!0},O=`FocusScope`,k=C.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,d]=C.useState(null),f=l(i),p=l(a),m=C.useRef(null),h=s(t,e=>d(e)),g=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let e=function(e){if(g.paused||!c)return;let t=e.target;c.contains(t)?m.current=t:P(m.current,{select:!0})},t=function(e){if(g.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||P(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&P(c)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,g.paused]),C.useEffect(()=>{if(c){F.add(g);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(T,D);c.addEventListener(T,f),c.dispatchEvent(t),t.defaultPrevented||(A(L(ee(c)),{select:!0}),document.activeElement===e&&P(c))}return()=>{c.removeEventListener(T,f),setTimeout(()=>{let t=new CustomEvent(E,D);c.addEventListener(E,p),c.dispatchEvent(t),t.defaultPrevented||P(e??document.body,{select:!0}),c.removeEventListener(E,p),F.remove(g)},0)}}},[c,f,p,g]);let _=C.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=j(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&P(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&P(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,w.jsx)(u.div,{tabIndex:-1,...o,ref:h,onKeyDown:_})});k.displayName=O;function A(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(P(r,{select:t}),document.activeElement!==n)return}function j(e){let t=ee(e);return[te(t,e),te(t.reverse(),e)]}function ee(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function te(e,t){for(let n of e)if(!M(n,{upTo:t}))return n}function M(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function N(e){return e instanceof HTMLInputElement&&`select`in e}function P(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&N(e)&&t&&e.select()}}var F=ne();function ne(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=I(e,t),e.unshift(t)},remove(t){e=I(e,t),e[0]?.resume()}}}function I(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function L(e){return e.filter(e=>e.tagName!==`A`)}var R=0;function re(){C.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??ie()),document.body.insertAdjacentElement(`beforeend`,e[1]??ie()),R++,()=>{R===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),R--}},[])}function ie(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var z=function(){return z=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},z.apply(this,arguments)};function ae(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function oe(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var B=`right-scroll-bar-position`,V=`width-before-scroll-bar`,se=`with-scroll-bars-hidden`,ce=`--removed-body-scroll-bar-size`;function le(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ue(e,t){var n=(0,C.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var de=typeof window<`u`?C.useLayoutEffect:C.useEffect,fe=new WeakMap;function pe(e,t){var n=ue(t||null,function(t){return e.forEach(function(e){return le(e,t)})});return de(function(){var t=fe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||le(e,null)}),i.forEach(function(e){r.has(e)||le(e,a)})}fe.set(n,e)},[e]),n}function me(e){return e}function he(e,t){t===void 0&&(t=me);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ge(e){e===void 0&&(e={});var t=he(null);return t.options=z({async:!0,ssr:!1},e),t}var _e=function(e){var t=e.sideCar,n=ae(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return C.createElement(r,z({},n))};_e.isSideCarExport=!0;function ve(e,t){return e.useMedium(t),_e}var ye=ge(),be=function(){},xe=C.forwardRef(function(e,t){var n=C.useRef(null),r=C.useState({onScrollCapture:be,onWheelCapture:be,onTouchMoveCapture:be}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=ae(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=pe([n,t]),w=z(z({},b),i);return C.createElement(C.Fragment,null,u&&C.createElement(x,{sideCar:ye,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?C.cloneElement(C.Children.only(s),z(z({},w),{ref:S})):C.createElement(v,z({},w,{className:c,ref:S}),s))});xe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},xe.classNames={fullWidth:V,zeroRight:B};var Se,Ce=function(){if(Se)return Se;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function we(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ce();return t&&e.setAttribute(`nonce`,t),e}function Te(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ee(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var De=function(){var e=0,t=null;return{add:function(n){e==0&&(t=we())&&(Te(t,n),Ee(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Oe=function(){var e=De();return function(t,n){C.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ke=function(){var e=Oe();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Ae={left:0,top:0,right:0,gap:0},je=function(e){return parseInt(e||``,10)||0},Me=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[je(n),je(r),je(i)]},Ne=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Ae;var t=Me(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Pe=ke(),H=`data-scroll-locked`,Fe=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
2
  .${se} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
@@ -1 +1 @@
1
- import{c as e}from"./dist-CZLIZntJ.js";var t=e(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);export{t};
1
+ import{c as e}from"./dist-CV9wIyME.js";var t=e(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{I as e,z as t}from"./react-7zG0fz1I.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 +1 @@
1
- import{i as e}from"./chunk-DseTPa7n.js";import{I as t,V as n,z as r}from"./react-CPH0zySO.js";import{an as i}from"./api-CuPWhNDM.js";var a=e(n(),1),o=r(),s=i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,{variants:{tone:{subtle:`border-gray-200 bg-gray-50 text-gray-600`,neutral:`border-gray-200 bg-white text-gray-600`,success:`border-emerald-200 bg-emerald-50 text-emerald-700`,warning:`border-amber-200 bg-amber-50 text-amber-800`,danger:`border-rose-200 bg-rose-50 text-rose-600`,info:`border-primary/20 bg-primary/10 text-primary`}},defaultVariants:{tone:`subtle`}}),c=a.forwardRef(({className:e,tone:n,...r},i)=>(0,o.jsx)(`span`,{ref:i,className:t(s({tone:n}),e),...r}));c.displayName=`TagChip`;export{c as t};
1
+ import{i as e}from"./chunk-DseTPa7n.js";import{I as t,V as n,z as r}from"./react-7zG0fz1I.js";import{an as i}from"./api-BJioGtWS.js";var a=e(n(),1),o=r(),s=i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,{variants:{tone:{subtle:`border-gray-200 bg-gray-50 text-gray-600`,neutral:`border-gray-200 bg-white text-gray-600`,success:`border-emerald-200 bg-emerald-50 text-emerald-700`,warning:`border-amber-200 bg-amber-50 text-amber-800`,danger:`border-rose-200 bg-rose-50 text-rose-600`,info:`border-primary/20 bg-primary/10 text-primary`}},defaultVariants:{tone:`subtle`}}),c=a.forwardRef(({className:e,tone:n,...r},i)=>(0,o.jsx)(`span`,{ref:i,className:t(s({tone:n}),e),...r}));c.displayName=`TagChip`;export{c as t};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-CV9wIyME.js";var t=e(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
package/dist/index.html CHANGED
@@ -194,29 +194,29 @@
194
194
  })();
195
195
  </script>
196
196
  <title>NextClaw</title>
197
- <script type="module" crossorigin src="/assets/index-CCWgeWoR.js"></script>
197
+ <script type="module" crossorigin src="/assets/index-DotCWGD1.js"></script>
198
198
  <link rel="modulepreload" crossorigin href="/assets/chunk-DseTPa7n.js">
199
199
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-D4M6sveU.js">
200
- <link rel="modulepreload" crossorigin href="/assets/react-CPH0zySO.js">
201
- <link rel="modulepreload" crossorigin href="/assets/dist-CZLIZntJ.js">
202
- <link rel="modulepreload" crossorigin href="/assets/select-oalsltZV.js">
203
- <link rel="modulepreload" crossorigin href="/assets/dist-Co2G-YjN.js">
204
- <link rel="modulepreload" crossorigin href="/assets/api-CuPWhNDM.js">
205
- <link rel="modulepreload" crossorigin href="/assets/x-Cps-je1K.js">
206
- <link rel="modulepreload" crossorigin href="/assets/confirm-dialog-uqcCxomz.js">
207
- <link rel="modulepreload" crossorigin href="/assets/search-BuUX_0KY.js">
208
- <link rel="modulepreload" crossorigin href="/assets/book-open-B4ovWX14.js">
200
+ <link rel="modulepreload" crossorigin href="/assets/react-7zG0fz1I.js">
201
+ <link rel="modulepreload" crossorigin href="/assets/dist-CV9wIyME.js">
202
+ <link rel="modulepreload" crossorigin href="/assets/select-MSvkWmPP.js">
203
+ <link rel="modulepreload" crossorigin href="/assets/dist-D1I3blO_.js">
204
+ <link rel="modulepreload" crossorigin href="/assets/api-BJioGtWS.js">
205
+ <link rel="modulepreload" crossorigin href="/assets/x-DdOEUmR4.js">
206
+ <link rel="modulepreload" crossorigin href="/assets/confirm-dialog-BFatCZUq.js">
207
+ <link rel="modulepreload" crossorigin href="/assets/search-CfFUpaf7.js">
208
+ <link rel="modulepreload" crossorigin href="/assets/book-open-aDv6R1av.js">
209
209
  <link rel="modulepreload" crossorigin href="/assets/host-capabilities-D9C4CBK5.js">
210
- <link rel="modulepreload" crossorigin href="/assets/navigation-link-DngetDmN.js">
211
- <link rel="modulepreload" crossorigin href="/assets/plus-wNpOxBfP.js">
212
- <link rel="modulepreload" crossorigin href="/assets/refresh-cw-vTYZqC0b.js">
210
+ <link rel="modulepreload" crossorigin href="/assets/navigation-link-7oSjAC9R.js">
211
+ <link rel="modulepreload" crossorigin href="/assets/plus-D6UN8XN5.js">
212
+ <link rel="modulepreload" crossorigin href="/assets/refresh-cw-BUg7hI3u.js">
213
213
  <link rel="modulepreload" crossorigin href="/assets/middleware-B3k-TSmZ.js">
214
- <link rel="modulepreload" crossorigin href="/assets/doc-browser-context-aeZu0FHR.js">
215
- <link rel="modulepreload" crossorigin href="/assets/doc-browser-CbCBDdap.js">
216
- <link rel="modulepreload" crossorigin href="/assets/loader-circle-DfbWUPdI.js">
217
- <link rel="modulepreload" crossorigin href="/assets/tag-chip-B324d_Xk.js">
218
- <link rel="modulepreload" crossorigin href="/assets/skeleton-D72EdBNa.js">
219
- <link rel="modulepreload" crossorigin href="/assets/mcp-marketplace-page-BmqbIQQQ.js">
214
+ <link rel="modulepreload" crossorigin href="/assets/doc-browser-context-BcwcVwX_.js">
215
+ <link rel="modulepreload" crossorigin href="/assets/doc-browser-BFfstBoh.js">
216
+ <link rel="modulepreload" crossorigin href="/assets/loader-circle-CsNiT6VM.js">
217
+ <link rel="modulepreload" crossorigin href="/assets/tag-chip-u8g0b0Nf.js">
218
+ <link rel="modulepreload" crossorigin href="/assets/skeleton-DDFivi9Y.js">
219
+ <link rel="modulepreload" crossorigin href="/assets/mcp-marketplace-page-ZTHpQTvi.js">
220
220
  <link rel="stylesheet" crossorigin href="/assets/index-Bsoscjk7.css">
221
221
  </head>
222
222
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/ui",
3
- "version": "0.17.2",
3
+ "version": "0.18.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,14 +34,14 @@
34
34
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
35
35
  "zod": "^3.23.8",
36
36
  "zustand": "^5.0.2",
37
+ "@nextclaw/agent-chat-ui": "0.6.25",
38
+ "@nextclaw/client-sdk": "0.6.4",
39
+ "@nextclaw/agent-chat": "0.3.14",
37
40
  "@nextclaw/ncp": "0.8.0",
41
+ "@nextclaw/ncp-react": "0.5.22",
38
42
  "@nextclaw/ncp-http-agent-client": "0.4.18",
39
- "@nextclaw/client-sdk": "0.6.2",
40
- "@nextclaw/shared": "0.4.24",
41
43
  "@nextclaw/ncp-toolkit": "0.6.20",
42
- "@nextclaw/agent-chat-ui": "0.6.25",
43
- "@nextclaw/agent-chat": "0.3.14",
44
- "@nextclaw/ncp-react": "0.5.22"
44
+ "@nextclaw/shared": "0.4.24"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@testing-library/react": "^16.3.0",
@@ -29,9 +29,12 @@ import type {
29
29
  } from '@/features/chat/features/conversation/hooks/use-session-conversation-input-state';
30
30
  import { useSessionConversationInputState } from '@/features/chat/features/conversation/hooks/use-session-conversation-input-state';
31
31
  import { useChatMessageLayoutStore } from '@/features/chat/stores/chat-message-layout.store';
32
+ import { useChatComposerDraftStore } from '@/features/chat/stores/chat-composer-draft.store';
32
33
  import { ChatComposerIntentManager } from '@/features/chat/managers/chat-composer-intent.manager';
34
+ import type { ThinkingLevel } from '@/shared/lib/api';
33
35
 
34
36
  const uploadNcpAssetsMock = vi.hoisted(() => vi.fn());
37
+ const updateNcpSessionMock = vi.hoisted(() => vi.fn());
35
38
 
36
39
  function renderInput(input: ReactElement) {
37
40
  const queryClient = new QueryClient({
@@ -59,6 +62,7 @@ Object.defineProperty(Range.prototype, 'getBoundingClientRect', {
59
62
 
60
63
  afterEach(() => {
61
64
  useChatMessageLayoutStore.getState().setLayout('card');
65
+ updateNcpSessionMock.mockReset();
62
66
  });
63
67
 
64
68
  vi.mock('@/app/hooks/use-viewport-layout', () => ({
@@ -111,11 +115,106 @@ vi.mock('@/shared/lib/api', async (importOriginal) => {
111
115
  const actual = await importOriginal();
112
116
  return {
113
117
  ...(actual as object),
114
- updateNcpSession: vi.fn(),
118
+ updateNcpSession: updateNcpSessionMock,
115
119
  uploadNcpAssets: uploadNcpAssetsMock,
116
120
  };
117
121
  });
118
122
 
123
+ function ThinkingPreferenceHarness() {
124
+ const { inputActions, inputSnapshot } = useSessionConversationInputState(
125
+ undefined,
126
+ 'thinking-session',
127
+ );
128
+ const inputQuery = useMemo(() => ({
129
+ addDiscoveredModel: vi.fn(async () => null),
130
+ dismissDiscoveredModels: vi.fn(),
131
+ defaultModel: 'openai/gpt-5.6',
132
+ defaultProjectRoot: null,
133
+ discoveredModelOptions: [],
134
+ fallbackPreferredModel: undefined,
135
+ fallbackPreferredThinking: 'high' as const,
136
+ isProviderStateResolved: true,
137
+ isSkillsLoading: false,
138
+ modelOptions: [{
139
+ value: 'openai/gpt-5.6',
140
+ modelLabel: 'GPT-5.6',
141
+ providerLabel: 'OpenAI',
142
+ thinkingCapability: {
143
+ supported: ['off', 'low', 'medium', 'high'] as ThinkingLevel[],
144
+ default: 'high' as const,
145
+ },
146
+ }],
147
+ providersView: null,
148
+ refreshProviderModelCatalog: vi.fn(),
149
+ selectedSession: null,
150
+ selectedSessionKey: 'thinking-session',
151
+ sessionTypeState: {
152
+ canEditSessionType: true,
153
+ defaultSessionType: 'native',
154
+ selectedSessionType: 'native',
155
+ selectedSessionTypeOption: null,
156
+ sessionTypeOptions: [],
157
+ sessionTypeUnavailable: false,
158
+ sessionTypeUnavailableMessage: null,
159
+ },
160
+ skillRecords: [],
161
+ }), []);
162
+
163
+ return (
164
+ <I18nProvider>
165
+ <ChatPresenterProvider presenter={presenter}>
166
+ <SessionConversationInput
167
+ contextWindow={null}
168
+ controller={{ ...controller, isSending: false, sendDisabled: false }}
169
+ inputActions={inputActions}
170
+ inputQuery={inputQuery}
171
+ inputSnapshot={inputSnapshot}
172
+ />
173
+ </ChatPresenterProvider>
174
+ </I18nProvider>
175
+ );
176
+ }
177
+
178
+ describe('SessionConversationInput thinking preference', () => {
179
+ it('switches from high to explicit off and persists the same value', async () => {
180
+ useChatComposerDraftStore.setState({
181
+ drafts: {
182
+ 'session:thinking-session': {
183
+ attachments: [],
184
+ composerFocusRequestId: 0,
185
+ nodes: [],
186
+ pendingSessionType: 'native',
187
+ selectedModel: 'openai/gpt-5.6',
188
+ selectedSessionType: 'native',
189
+ selectedSkills: [],
190
+ selectedThinkingLevel: 'high',
191
+ sendError: null,
192
+ skillRecords: [],
193
+ text: '',
194
+ },
195
+ },
196
+ });
197
+ updateNcpSessionMock.mockResolvedValue({
198
+ sessionId: 'thinking-session',
199
+ updatedAt: '2026-08-15T00:00:00.000Z',
200
+ status: 'idle',
201
+ metadata: { preferred_thinking: 'off' },
202
+ });
203
+ renderInput(<ThinkingPreferenceHarness />);
204
+
205
+ fireEvent.click(screen.getByRole('combobox', { name: /High/ }));
206
+ fireEvent.click(await screen.findByRole('option', { name: /Off|关闭/ }));
207
+
208
+ await waitFor(() => expect(
209
+ screen.getByRole('combobox', { name: /Off|关闭/ }),
210
+ ).toBeTruthy());
211
+ await waitFor(() => expect(updateNcpSessionMock).toHaveBeenCalledWith(
212
+ 'thinking-session',
213
+ { preferredThinking: 'off' },
214
+ ));
215
+ });
216
+ });
217
+
119
218
  type StreamingInputControl = {
120
219
  bumpStream: () => void;
121
220
  };
@@ -140,6 +239,7 @@ const controller: SessionConversationInputController = {
140
239
  primaryAction: 'send',
141
240
  queuedInputs: [],
142
241
  send: vi.fn(),
242
+ sendPresetMessage: vi.fn(),
143
243
  sendDisabled: true,
144
244
  stop: vi.fn(),
145
245
  stopDisabled: false,
@@ -460,6 +560,7 @@ describe('SessionConversationInput streaming stability', () => {
460
560
 
461
561
  expect(screen.queryByText(providerError)).toBeNull();
462
562
  });
563
+
463
564
  });
464
565
 
465
566
  type AttachmentSubmitAgentSend = (envelope: NcpAgentSendEnvelope) => Promise<NcpRunHandle | null>;
@@ -333,6 +333,8 @@ export function SessionConversationArea(props: SessionConversationAreaProps) {
333
333
  primaryAction: controller.primaryAction,
334
334
  queuedInputs: controller.queuedInputs,
335
335
  send: () => controllerRef.current.send(),
336
+ sendPresetMessage: (message: string) =>
337
+ controllerRef.current.sendPresetMessage(message).catch(() => undefined),
336
338
  sendDisabled: controller.sendDisabled,
337
339
  stop: () => controllerRef.current.stop(),
338
340
  stopDisabled: controller.stopDisabled,
@@ -14,7 +14,7 @@ import { isRuntimeDefaultModelValue } from '@nextclaw/shared';
14
14
 
15
15
  import { useI18n } from '@/app/components/i18n-provider';
16
16
  import { useViewportLayout } from '@/app/hooks/use-viewport-layout';
17
- import { updateNcpSession, type SessionSkillEntryView, type ThinkingLevel } from '@/shared/lib/api';
17
+ import { type SessionSkillEntryView } from '@/shared/lib/api';
18
18
  import { t } from '@/shared/lib/i18n';
19
19
  import { usePresenter } from '@/features/chat/components/providers/chat-presenter.provider';
20
20
  import {
@@ -46,6 +46,7 @@ import {
46
46
  import { useSessionConversationInputAttachments } from '@/features/chat/features/conversation/hooks/use-session-conversation-input-attachments';
47
47
  import { useChatComposerReferenceIntent } from '@/features/chat/features/conversation/hooks/use-chat-composer-reference-intent';
48
48
  import { useSessionConversationComposerNodes } from '@/features/chat/features/conversation/hooks/use-session-conversation-composer-nodes';
49
+ import { useSessionConversationPreferencePersistence } from '@/features/chat/features/conversation/hooks/use-session-conversation-preference-persistence';
49
50
  import { useSessionConversationSlashCommands } from '@/features/chat/features/conversation/hooks/use-session-conversation-slash-commands';
50
51
  import { useSystemObjectReferenceSelect } from '@/features/chat/features/conversation/hooks/use-system-object-reference-select';
51
52
  import { ChatConversationTrack } from '@/features/chat/components/conversation/chat-conversation-track';
@@ -79,6 +80,7 @@ export type SessionConversationInputController = {
79
80
  readonly sendDisabled: boolean;
80
81
  readonly stopDisabled: boolean;
81
82
  readonly send: () => Promise<void> | void;
83
+ readonly sendPresetMessage: (message: string) => Promise<void> | void;
82
84
  readonly stop: () => Promise<void> | void;
83
85
  };
84
86
 
@@ -220,6 +222,7 @@ export const SessionConversationInput = memo(function SessionConversationInput(p
220
222
  const slashCommands = useSessionConversationSlashCommands({
221
223
  language,
222
224
  onContextCompactingChange,
225
+ onSendPresetMessage: controller.sendPresetMessage,
223
226
  selectedSessionKey: inputQuery.selectedSessionKey,
224
227
  });
225
228
  const handleSlashPanelAppSelect = useCallback(
@@ -279,15 +282,7 @@ export const SessionConversationInput = memo(function SessionConversationInput(p
279
282
  inputBarRef,
280
283
  addAttachments: inputActions.addAttachments,
281
284
  });
282
- const syncSessionPreferences = useCallback((patch: {
283
- preferredModel?: string | null;
284
- preferredThinking?: ThinkingLevel | null;
285
- }) => {
286
- if (!inputQuery.selectedSessionKey || !inputQuery.selectedSession) {
287
- return;
288
- }
289
- void updateNcpSession(inputQuery.selectedSessionKey, patch).catch(() => undefined);
290
- }, [inputQuery.selectedSession, inputQuery.selectedSessionKey]);
285
+ const persistSessionPreferences = useSessionConversationPreferencePersistence({ inputActions, selectedSessionKey: inputQuery.selectedSessionKey });
291
286
  const handleNodesChange = useSessionConversationComposerNodes(inputActions);
292
287
 
293
288
  useChatComposerReferenceIntent({
@@ -313,17 +308,22 @@ export const SessionConversationInput = memo(function SessionConversationInput(p
313
308
  if (!isRuntimeDefaultModelValue(value)) {
314
309
  chatRecentModelsManager.remember(value);
315
310
  }
316
- syncSessionPreferences({
317
- preferredModel: isRuntimeDefaultModelValue(value) ? null : value,
318
- preferredThinking: nextThinkingLevel,
319
- });
311
+ persistSessionPreferences(
312
+ {
313
+ preferredModel: isRuntimeDefaultModelValue(value) ? null : value,
314
+ preferredThinking: nextThinkingLevel,
315
+ },
316
+ { selectedModel: value, selectedThinkingLevel: nextThinkingLevel },
317
+ { selectedModel, selectedThinkingLevel },
318
+ );
320
319
  }, [
321
320
  inputActions,
322
321
  discoveredModelRecords,
323
322
  inputQuery.sessionTypeState.selectedSessionType,
324
323
  modelRecords,
325
324
  selectedThinkingLevel,
326
- syncSessionPreferences,
325
+ persistSessionPreferences,
326
+ selectedModel,
327
327
  ]);
328
328
  const handleDiscoveredModelSelect = useCallback(async (value: string) => {
329
329
  const option = await inputQuery.addDiscoveredModel(value);
@@ -337,8 +337,10 @@ export const SessionConversationInput = memo(function SessionConversationInput(p
337
337
  ]);
338
338
  const handleThinkingChange = useCallback((value: ChatThinkingLevel | null) => {
339
339
  inputActions.setSelectedThinkingLevel(value);
340
- syncSessionPreferences({ preferredThinking: value });
341
- }, [inputActions, syncSessionPreferences]);
340
+ persistSessionPreferences(
341
+ { preferredThinking: value }, { selectedThinkingLevel: value }, { selectedThinkingLevel },
342
+ );
343
+ }, [inputActions, persistSessionPreferences, selectedThinkingLevel]);
342
344
  const handleSelectedSkillsChange = useCallback((next: string[]) => {
343
345
  const previousSelection = inputSnapshot.selectedSkills;
344
346
  next