@geminilight/mindos 0.6.63 → 0.6.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_standalone/.mindos-build-version +1 -1
- package/_standalone/.next/BUILD_ID +1 -1
- package/_standalone/.next/app-path-routes-manifest.json +21 -21
- package/_standalone/.next/build-manifest.json +2 -2
- package/_standalone/.next/cache/.previewinfo +1 -1
- package/_standalone/.next/cache/.rscinfo +1 -1
- package/_standalone/.next/cache/config.json +3 -3
- package/_standalone/.next/prerender-manifest.json +3 -3
- package/_standalone/.next/server/app/.well-known/agent-card.json/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/_global-error.html +2 -2
- package/_standalone/.next/server/app/_global-error.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/_standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/_standalone/.next/server/app/_not-found/page.js +1 -1
- package/_standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/[agentKey]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/agents/page.js +1 -1
- package/_standalone/.next/server/app/agents/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/delegations/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/discover/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/a2a/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/config/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/registry/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/acp/session/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agent-activity/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/copy-skill/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/agents/copy-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/detect/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/agents/custom/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask/route.js +48 -42
- package/_standalone/.next/server/app/api/ask/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/ask/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/ask-sessions/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/auth/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/backlinks/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/backlinks/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/bootstrap/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/bootstrap/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/changes/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/export/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/export/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/extract-pdf/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/import/route.js +1 -1
- package/_standalone/.next/server/app/api/file/import/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/file/import/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/raw/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/file/raw/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/file/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/files/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/git/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/graph/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/graph/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/inbox/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/init/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route.js +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/mcp/agents/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/install-skill/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/mcp/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/monitoring/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/monitoring/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/recent-files/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/recent-files/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/search/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/list-models/route.js +1 -1
- package/_standalone/.next/server/app/api/settings/list-models/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/reset-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/route.js +1 -1
- package/_standalone/.next/server/app/api/settings/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/settings/test-key/route.js +1 -1
- package/_standalone/.next/server/app/api/settings/test-key/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-path/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/check-port/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/generate-token/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/ls/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/setup/route.js +1 -1
- package/_standalone/.next/server/app/api/setup/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/skills/route.js +1 -1
- package/_standalone/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/sync/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/tree-version/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/tree-version/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/uninstall/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-check/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/update-status/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/api/workflows/route.js.nft.json +1 -1
- package/_standalone/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/changes/page.js +1 -1
- package/_standalone/.next/server/app/changes/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/changes/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page.js +2 -2
- package/_standalone/.next/server/app/echo/[segment]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/[segment]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/echo/page.js +1 -1
- package/_standalone/.next/server/app/echo/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/echo/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/explore/page.js +1 -1
- package/_standalone/.next/server/app/explore/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/explore/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/help/page.js +1 -1
- package/_standalone/.next/server/app/help/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js +1 -1
- package/_standalone/.next/server/app/inbox/history/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/inbox/history/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/login/page.js +1 -1
- package/_standalone/.next/server/app/login/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/page.js +1 -1
- package/_standalone/.next/server/app/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/setup/page.js +2 -2
- package/_standalone/.next/server/app/setup/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/trash/page.js +3 -3
- package/_standalone/.next/server/app/trash/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/trash/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/view/[...path]/page.js +2 -2
- package/_standalone/.next/server/app/view/[...path]/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/view/[...path]/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app/wiki/page.js +1 -1
- package/_standalone/.next/server/app/wiki/page.js.nft.json +1 -1
- package/_standalone/.next/server/app/wiki/page_client-reference-manifest.js +1 -1
- package/_standalone/.next/server/app-paths-manifest.json +21 -21
- package/_standalone/.next/server/chunks/122.js +222 -0
- package/_standalone/.next/server/chunks/3113.js +52 -0
- package/_standalone/.next/server/chunks/6539.js +1 -1
- package/_standalone/.next/server/chunks/8388.js +2 -2
- package/_standalone/.next/server/chunks/953.js +3 -3
- package/_standalone/.next/server/chunks/9787.js +2 -0
- package/_standalone/.next/server/pages/500.html +2 -2
- package/_standalone/.next/server/server-reference-manifest.js +1 -1
- package/_standalone/.next/server/server-reference-manifest.json +1 -1
- package/_standalone/.next/static/chunks/1001-99da82ec8d8c136f.js +1 -0
- package/_standalone/.next/static/chunks/5149-4d828886dda479fa.js +1 -0
- package/_standalone/.next/static/chunks/{5581-82e5db227f8e9393.js → 5581-c671163a2fe1b312.js} +2 -2
- package/_standalone/.next/static/chunks/6636-53238eff89503f03.js +6 -0
- package/_standalone/.next/static/chunks/6757-1c1a89720fdda8f0.js +1 -0
- package/_standalone/.next/static/chunks/7129-20e9d2463a9da646.js +1 -0
- package/_standalone/.next/static/chunks/{3674-be69a8b858ceacdd.js → 7294-cac25d97869afadc.js} +1 -1
- package/_standalone/.next/static/chunks/8225-21e5cebc3731ddf0.js +1 -0
- package/_standalone/.next/static/chunks/8520-b51810e66293ceb8.js +22 -0
- package/_standalone/.next/static/chunks/9207-dc9c31b351a2ed78.js +1 -0
- package/_standalone/.next/static/chunks/app/agents/[agentKey]/{page-b0dabe793500383d.js → page-2f5cf97e03dc1cc9.js} +1 -1
- package/_standalone/.next/static/chunks/app/agents/{page-1f1ac330c8177cf6.js → page-50eac58d511dcc6e.js} +1 -1
- package/_standalone/.next/static/chunks/app/echo/[segment]/page-2a00f4686adf3885.js +11 -0
- package/_standalone/.next/static/chunks/app/{layout-50a6b1164ee98ab9.js → layout-2cb7a6602d2e5d5f.js} +62 -58
- package/_standalone/.next/static/chunks/app/{page-73802bd31d7f6c9f.js → page-5ab911b2226f6ff7.js} +1 -1
- package/_standalone/.next/static/chunks/app/setup/page-907b7c57fad2292b.js +1 -0
- package/_standalone/.next/static/chunks/app/trash/page-11a511b065ea84c2.js +1 -0
- package/_standalone/.next/static/chunks/app/view/[...path]/{page-808f39963bf04715.js → page-26e47dd4c533a58c.js} +2 -2
- package/_standalone/.next/static/css/67e7918f5ed7d147.css +1 -0
- package/_standalone/.next/trace +65 -65
- package/_standalone/__tests__/api/ask-attachments.test.ts +194 -0
- package/_standalone/__tests__/api/settings.test.ts +16 -12
- package/_standalone/__tests__/api/setup.test.ts +11 -9
- package/_standalone/__tests__/api/test-key.test.ts +0 -10
- package/_standalone/__tests__/components/UpdateToast.test.ts +344 -0
- package/_standalone/__tests__/core/context.test.ts +48 -426
- package/_standalone/__tests__/lib/pi-skills.test.ts +4 -4
- package/_standalone/__tests__/lib/settings-ai-client.test.ts +32 -12
- package/_standalone/__tests__/setup.ts +5 -5
- package/_standalone/components/ask/AskContent.tsx +70 -40
- package/_standalone/components/ask/AskHeader.tsx +8 -1
- package/_standalone/components/ask/MessageList.tsx +37 -3
- package/_standalone/components/ask/ProviderModelCapsule.tsx +51 -129
- package/_standalone/components/settings/AiTab.tsx +270 -347
- package/_standalone/components/settings/CustomProviderFields.tsx +121 -0
- package/_standalone/components/settings/CustomProvidersCard.tsx +2 -2
- package/_standalone/components/settings/KnowledgeTab.tsx +6 -20
- package/_standalone/components/settings/McpAgentInstall.tsx +7 -2
- package/_standalone/components/settings/Primitives.tsx +48 -104
- package/_standalone/components/settings/ProviderModal.tsx +38 -221
- package/_standalone/components/settings/SettingsContent.tsx +5 -12
- package/_standalone/components/settings/TestButton.tsx +64 -0
- package/_standalone/components/settings/types.ts +3 -12
- package/_standalone/components/settings/useCustomProviderForm.ts +132 -0
- package/_standalone/components/setup/StepAI.tsx +3 -3
- package/_standalone/components/shared/ModelInput.tsx +18 -4
- package/_standalone/components/shared/ProviderSelect.tsx +126 -134
- package/_standalone/hooks/useAskChat.ts +97 -13
- package/_standalone/hooks/useAskPanel.ts +17 -1
- package/_standalone/lib/settings-ai-client.ts +17 -8
- package/_standalone/tsconfig.tsbuildinfo +1 -1
- package/app/app/api/ask/route.ts +124 -44
- package/app/app/api/mcp/agents/route.ts +3 -3
- package/app/app/api/settings/list-models/route.ts +15 -26
- package/app/app/api/settings/route.ts +14 -59
- package/app/app/api/settings/test-key/route.ts +47 -12
- package/app/app/api/setup/route.ts +36 -18
- package/app/app/api/skills/route.ts +1 -1
- package/app/app/layout.tsx +5 -3
- package/app/components/HomeContent.tsx +11 -0
- package/app/components/UpdateToast.tsx +255 -0
- package/app/components/ask/AskContent.tsx +70 -40
- package/app/components/ask/AskHeader.tsx +8 -1
- package/app/components/ask/MessageList.tsx +37 -3
- package/app/components/ask/ProviderModelCapsule.tsx +51 -129
- package/app/components/settings/AiTab.tsx +270 -347
- package/app/components/settings/CustomProviderFields.tsx +121 -0
- package/app/components/settings/CustomProvidersCard.tsx +2 -2
- package/app/components/settings/KnowledgeTab.tsx +6 -20
- package/app/components/settings/McpAgentInstall.tsx +7 -2
- package/app/components/settings/Primitives.tsx +48 -104
- package/app/components/settings/ProviderModal.tsx +38 -221
- package/app/components/settings/SettingsContent.tsx +5 -12
- package/app/components/settings/TestButton.tsx +64 -0
- package/app/components/settings/types.ts +3 -12
- package/app/components/settings/useCustomProviderForm.ts +132 -0
- package/app/components/setup/StepAI.tsx +3 -3
- package/app/components/shared/ModelInput.tsx +18 -4
- package/app/components/shared/ProviderSelect.tsx +126 -134
- package/app/hooks/useAskChat.ts +97 -13
- package/app/hooks/useAskPanel.ts +17 -1
- package/app/lib/agent/context.ts +65 -0
- package/app/lib/agent/providers.ts +25 -0
- package/app/lib/agent/tools.ts +1 -1
- package/app/lib/custom-endpoints.ts +129 -29
- package/app/lib/i18n/modules/settings.ts +20 -0
- package/app/lib/pi-integration/skills.ts +16 -4
- package/app/lib/settings-ai-client.ts +17 -8
- package/app/lib/settings.ts +64 -90
- package/app/lib/types.ts +4 -0
- package/package.json +1 -1
- package/_standalone/.next/server/chunks/530.js +0 -218
- package/_standalone/.next/server/chunks/9007.js +0 -2
- package/_standalone/.next/server/chunks/9137.js +0 -52
- package/_standalone/.next/static/chunks/1309-373ade1b40aea186.js +0 -1
- package/_standalone/.next/static/chunks/3165-9189a38fd9ebf6f2.js +0 -1
- package/_standalone/.next/static/chunks/4587-5d06728133fff222.js +0 -1
- package/_standalone/.next/static/chunks/6261-5ce86db54b19ae46.js +0 -1
- package/_standalone/.next/static/chunks/6636-9bbc90fb3b8731fe.js +0 -6
- package/_standalone/.next/static/chunks/7637-904b0a381dc3ec02.js +0 -1
- package/_standalone/.next/static/chunks/8520-84e607f33c409f91.js +0 -22
- package/_standalone/.next/static/chunks/9207-9a4a1a1ede4f8e6e.js +0 -1
- package/_standalone/.next/static/chunks/app/echo/[segment]/page-bc5e104eb7ae6327.js +0 -11
- package/_standalone/.next/static/chunks/app/setup/page-79acb0baf38184c6.js +0 -1
- package/_standalone/.next/static/chunks/app/trash/page-d040db56863da504.js +0 -1
- package/_standalone/.next/static/css/1287672978833d07.css +0 -1
- package/_standalone/lib/agent/context.ts +0 -403
- /package/_standalone/.next/static/{X86rF8dKEO0InosOw4a2_ → eIlwbGas1iRGonlPyEwj7}/_buildManifest.js +0 -0
- /package/_standalone/.next/static/{X86rF8dKEO0InosOw4a2_ → eIlwbGas1iRGonlPyEwj7}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8520],{2431:(e,t,r)=>{"use strict";r.d(t,{z:()=>a});var n=r(12115);let s="mindos:acp-detection";function a(){let e=(0,n.useRef)(function(){try{let e=sessionStorage.getItem(s);if(!e)return null;let t=JSON.parse(e);if("number"!=typeof t.ts||Date.now()-t.ts>18e5)return null;return t}catch{return null}}()),[t,r]=(0,n.useState)(e.current?.installed??[]),[a,o]=(0,n.useState)(e.current?.notInstalled??[]),[l,i]=(0,n.useState)(!e.current),[u,c]=(0,n.useState)(null),[d,m]=(0,n.useState)(0),p=(0,n.useRef)(!1),f=(0,n.useRef)(!1),g=(0,n.useCallback)(()=>{try{sessionStorage.removeItem(s)}catch{}e.current=null,f.current=!0,m(e=>e+1)},[]);return(0,n.useEffect)(()=>{let e=()=>g();return window.addEventListener("mindos:settings-changed",e),()=>window.removeEventListener("mindos:settings-changed",e)},[g]),(0,n.useEffect)(()=>{let n=f.current;if(f.current=!1,e.current&&Date.now()-e.current.ts<18e5&&0===d||p.current)return;p.current=!0;let l=t.length>0||a.length>0;l||i(!0),c(null);let u=!1;return fetch(`/api/acp/detect${n?"?force=1":""}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(u)return;let n=t.installed??[],a=t.notInstalled??[];try{sessionStorage.setItem(s,JSON.stringify({installed:n,notInstalled:a,ts:Date.now()}))}catch{}e.current={installed:n,notInstalled:a,ts:Date.now()},r(n),o(a)}).catch(e=>{!u&&(l||c(e.message))}).finally(()=>{p.current=!1,u||i(!1)}),()=>{u=!0}},[d]),{installedAgents:t,notInstalledAgents:a,loading:l,error:u,refresh:g}}},27318:(e,t,r)=>{"use strict";r.d(t,{KT:()=>c,NH:()=>u});var n=r(12115);let s={open:!1,initialMessage:"",source:"user",acpAgent:null},a=new Set;function o(){a.forEach(e=>e())}function l(e){return a.add(e),()=>{a.delete(e)}}function i(){return s}function u(e="",t="user",r=null){s={open:!0,initialMessage:e,source:t,acpAgent:r},o()}function c(){let e=(0,n.useSyncExternalStore)(l,i,i);return{open:e.open,initialMessage:e.initialMessage,source:e.source,acpAgent:e.acpAgent,openWith:(0,n.useCallback)((e,t="user",r=null)=>u(e,t,r),[]),close:(0,n.useCallback)(()=>void(s={open:!1,initialMessage:"",source:"user",acpAgent:null},o()),[])}}},47376:(e,t,r)=>{"use strict";r.d(t,{Ot:()=>d,T_:()=>s,Ux:()=>c,bf:()=>l,jt:()=>a,rl:()=>o});var n=r(20699);r(87358);let s={anthropic:{id:"anthropic",name:"Anthropic",nameZh:"Anthropic",shortLabel:"Anthropic",defaultModel:"claude-sonnet-4-6",supportsBaseUrl:!0,supportsThinking:!0,supportsListModels:!0,signupUrl:"https://console.anthropic.com/settings/keys",category:"primary"},openai:{id:"openai",name:"OpenAI",nameZh:"OpenAI",shortLabel:"OpenAI",defaultModel:"gpt-5.4",supportsBaseUrl:!0,supportsThinking:!0,supportsListModels:!0,signupUrl:"https://platform.openai.com/api-keys",category:"primary"},google:{id:"google",name:"Google Gemini",nameZh:"Google Gemini",shortLabel:"Gemini",defaultModel:"gemini-2.5-flash",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,signupUrl:"https://aistudio.google.com/apikey",category:"primary"},groq:{id:"groq",name:"Groq",nameZh:"Groq",shortLabel:"Groq",defaultModel:"llama-3.3-70b-versatile",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,signupUrl:"https://console.groq.com/keys",category:"more"},xai:{id:"xai",name:"xAI (Grok)",nameZh:"xAI (Grok)",shortLabel:"xAI",defaultModel:"grok-3",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},openrouter:{id:"openrouter",name:"OpenRouter",nameZh:"OpenRouter",shortLabel:"OpenRouter",defaultModel:"anthropic/claude-sonnet-4",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},mistral:{id:"mistral",name:"Mistral",nameZh:"Mistral",shortLabel:"Mistral",defaultModel:"mistral-large-latest",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},deepseek:{id:"deepseek",name:"DeepSeek",nameZh:"DeepSeek",shortLabel:"DeepSeek",defaultModel:"deepseek-chat",piProviderOverride:"openai",fixedBaseUrl:"https://api.deepseek.com/v1",supportsBaseUrl:!0,supportsThinking:!0,supportsListModels:!0,signupUrl:"https://platform.deepseek.com/api_keys",category:"more"},zai:{id:"zai",name:"ZhipuAI (GLM)",nameZh:"智谱 AI (GLM 国际版)",shortLabel:"智谱GLM",defaultModel:"glm-4-plus",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},"zai-cn":{id:"zai-cn",name:"ZhipuAI (GLM China)",nameZh:"智谱 AI (GLM 国内版)",shortLabel:"智谱GLM-CN",description:"China region version",descriptionZh:"中国区版本",defaultModel:"glm-4-plus",piProviderOverride:"zai",fixedBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,signupUrl:"https://open.bigmodel.cn/",category:"more"},"kimi-coding":{id:"kimi-coding",name:"Kimi Coding",nameZh:"Kimi Coding (月之暗面)",shortLabel:"Kimi Coding",defaultModel:"kimi-k2-thinking",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},cerebras:{id:"cerebras",name:"Cerebras",nameZh:"Cerebras",shortLabel:"Cerebras",defaultModel:"llama-4-scout-17b-16e",supportsBaseUrl:!1,supportsThinking:!1,supportsListModels:!0,category:"more"},minimax:{id:"minimax",name:"MiniMax",nameZh:"MiniMax (国际版)",shortLabel:"MiniMax",defaultModel:"MiniMax-M2.5",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},"minimax-cn":{id:"minimax-cn",name:"MiniMax (China)",nameZh:"MiniMax (国内版)",shortLabel:"MiniMax-CN",description:"China region version",descriptionZh:"中国区版本",defaultModel:"MiniMax-M2.5",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},huggingface:{id:"huggingface",name:"Hugging Face",nameZh:"Hugging Face",shortLabel:"HuggingFace",defaultModel:"Qwen/Qwen3-235B-A22B-Thinking-2507",supportsBaseUrl:!1,supportsThinking:!0,supportsListModels:!1,category:"more"},ollama:{id:"ollama",name:"Ollama",nameZh:"Ollama (本地)",shortLabel:"Ollama",description:"Local server (requires setup)",descriptionZh:"本地服务器 (需要本地部署)",defaultModel:"llama3.2",piProviderOverride:"openai",fixedBaseUrl:"http://localhost:11434/v1",apiKeyFallback:"ollama",supportsBaseUrl:!0,supportsThinking:!1,supportsListModels:!0,signupUrl:"https://ollama.com/download",category:"more"}},a=Object.keys(s);function o(e){return e in s}function l(){let e=[],t=[];for(let r of a)"primary"===s[r].category?e.push(r):t.push(r);return t.sort((e,t)=>s[e].name.localeCompare(s[t].name)),{primary:e,more:t}}function i(e){return s[e].piProviderOverride??e}let u={deepseek:"DEEPSEEK_API_KEY"};function c(e){return u[e]?u[e]:m[i(e)]}function d(e){let t=s[e];if(t.fixedBaseUrl)return t.fixedBaseUrl;try{let t=(0,n.zr)(i(e));return t[0]?.baseUrl??""}catch{return""}}let m={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",google:"GEMINI_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",openrouter:"OPENROUTER_API_KEY",zai:"ZAI_API_KEY","zai-cn":"ZAI_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_API_KEY",huggingface:"HF_TOKEN","kimi-coding":"KIMI_API_KEY"}},48391:(e,t,r)=>{"use strict";r.d(t,{Oo:()=>s,dB:()=>c});var n=r(12115);function s(e){let t=e.replace(/<(thinking|reasoning|scratchpad)>[\s\S]*?<\/\1>/gi,"");return(t=t.replace(/<(?:thinking|reasoning|scratchpad)>[\s\S]*$/gi,"")).trim()}let a=new Set(["create_file","write_file","batch_create_files","append_to_file","insert_after_heading","update_section","edit_lines","delete_file","rename_file","move_file","append_csv"]),o=new Set(["read_file","read_lines","search","list_files"]);function l(e,t){return t&&"object"==typeof t?"string"==typeof t.path?t.path:"string"==typeof t.from_path?t.from_path:"batch_create_files"===e&&Array.isArray(t.files)?t.files.map(e=>e.path??"").filter(Boolean).join(", "):"":""}async function i(e){try{let t=await fetch(`/api/file?path=${encodeURIComponent(e)}&op=read_file`);if(!t.ok)return"";return(await t.json()).content??""}catch{return""}}async function u(e,t,r,n){let u=e.getReader(),c=new TextDecoder,d="",m=[],p=new Map,f="",g=0,h=new Set;try{for(;!n?.aborted;){let{done:e,value:n}=await u.read();if(e)break;let y=(d+=c.decode(n,{stream:!0})).split("\n");for(let e of(d=y.pop()??"",y)){let n,u=e.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(!c)continue;try{n=JSON.parse(c)}catch{continue}let d=n.type;switch(d){case"tool_start":{var x,b,v;let e=n.toolName,s=n.toolCallId,u=n.args;g++;let c=(x=d,b=e,v=u,"text_delta"===x?{stage:"analyzing"}:"tool_start"===x&&b?a.has(b)?{stage:"writing",detail:l(b,v)||void 0}:o.has(b)?{stage:"reading",detail:v&&"object"==typeof v&&"path"in v&&"string"==typeof v.path?v.path:void 0}:{stage:"analyzing"}:null);if(c&&t({stageHint:c}),a.has(e)){let n=l(e,u),a="update";"create_file"===e||"batch_create_files"===e?a="create":("delete_file"===e||"rename_file"===e||"move_file"===e)&&(a="unknown"),"update"===a&&n&&!h.has(n)&&(h.add(n),i(n).then(e=>{e&&r(n,e)})),p.set(s,{name:e,path:n,action:a}),t({currentTool:{name:e,path:n}})}break}case"tool_end":{let e=n.toolCallId,r=!!n.isError,s=p.get(e);if(s){if("batch_create_files"===s.name)for(let t of s.path.split(", ").filter(Boolean))m.push({action:s.action,path:t,toolCallId:e,ok:!r});else m.push({action:s.action,path:s.path,toolCallId:e,ok:!r});p.delete(e),t({changes:[...m],currentTool:null})}break}case"text_delta":f+=n.delta??"",t({stageHint:{stage:"analyzing"},summary:s(f)});break;case"error":throw Error(n.message||"AI organize failed")}}}}finally{u.releaseLock()}return{changes:m,summary:s(f),toolCallCount:g}}function c(){let[e,t]=(0,n.useState)("idle"),[r,s]=(0,n.useState)([]),[a,o]=(0,n.useState)(null),[l,i]=(0,n.useState)(null),[c,d]=(0,n.useState)(""),[m,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(0),h=(0,n.useRef)(null),x=(0,n.useRef)(0),b=(0,n.useRef)(new Map),[v,y]=(0,n.useState)([]),[k,w]=(0,n.useState)("upload"),j=(0,n.useRef)(0),[N,C]=(0,n.useState)(0),A=(0,n.useCallback)(async(e,r,n="upload")=>{t("organizing"),s([]),o(null),i({stage:"connecting"}),d(""),p(null),g(0),y(e.map(e=>e.name)),w(n),j.current=Date.now(),C(0),b.current=new Map,x.current=Date.now();let a=new AbortController;h.current=a;let l=e.map(e=>({name:e.name,content:e.content.length>2e4?e.content.slice(0,2e4)+"\n\n[...truncated to first ~20000 chars]":e.content}));try{let e=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:r}],uploadedFiles:l,maxSteps:15,mode:"organize"}),signal:a.signal});if(!e.ok){let t=`Request failed (${e.status})`;try{let r=await e.json();"string"==typeof r?.error?t=r.error:"object"==typeof r?.error&&r.error?.message?t=r.error.message:r?.message&&(t=r.message)}catch{}throw Error(t)}if(!e.body)throw Error("No response body");let n=await u(e.body,e=>{x.current=Date.now(),e.changes&&s(e.changes),void 0!==e.currentTool&&o(e.currentTool),e.stageHint&&i(e.stageHint),void 0!==e.summary&&d(e.summary)},(e,t)=>{b.current.set(e,t)},a.signal);s(n.changes),d(n.summary),g(n.toolCallCount),o(null),C(Date.now()-j.current),t("done")}catch(e){"AbortError"===e.name?t("idle"):(p(e.message),t("error"))}finally{h.current=null}},[]),S=(0,n.useCallback)(()=>{h.current?.abort()},[]),E=(0,n.useCallback)(async e=>{let t=r.find(t=>t.path===e&&t.ok&&!t.undone);if(!t)return!1;try{if("create"===t.action){if(!(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"delete_file",path:t.path})})).ok)return!1}else{if("update"!==t.action)return!1;let r=b.current.get(e);if(!r||!(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"write_file",path:t.path,content:r})})).ok)return!1}return s(t=>t.map(t=>t.path===e&&t.ok&&!t.undone?{...t,undone:!0}:t)),!0}catch{return!1}},[r]),M=(0,n.useCallback)(async()=>{let e=r.filter(e=>e.ok&&!e.undone&&("create"===e.action||"update"===e.action&&b.current.has(e.path))),t=0;for(let r of e)try{if("create"===r.action)(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"delete_file",path:r.path})})).ok&&t++;else if("update"===r.action){let e=b.current.get(r.path);e&&(await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({op:"write_file",path:r.path,content:e})})).ok&&t++}}catch{}return t>0&&s(e=>e.map(e=>!e.ok||e.undone?e:"create"===e.action||"update"===e.action&&b.current.has(e.path)?{...e,undone:!0}:e)),t},[r]),_=(0,n.useCallback)(e=>{let t=r.find(t=>t.path===e&&t.ok&&!t.undone);return!!t&&("create"===t.action||"update"===t.action&&b.current.has(e))},[r]),R=r.some(e=>e.ok&&!e.undone&&("create"===e.action||"update"===e.action&&b.current.has(e.path))),L=(0,n.useCallback)(()=>{t("idle"),s([]),o(null),i(null),d(""),p(null),g(0),y([]),w("upload"),C(0),j.current=0,b.current=new Map,x.current=0},[]);return{phase:e,changes:r,currentTool:a,stageHint:l,summary:c,error:m,toolCallCount:f,sourceFileNames:v,source:k,durationMs:N,snapshots:b,start:A,abort:S,undoOne:E,undoAll:M,canUndo:_,hasAnyUndoable:R,reset:L}}},51541:(e,t,r)=>{"use strict";r.d(t,{A:()=>eX});var n=r(95155),s=r(12115),a=r(51914),o=r(48368),l=r(17243),i=r(33210),u=r(46757),c=r(56204),d=r(35581),m=r(47650),p=r(96035),f=r(86901),g=r(94514),h=r(66088);let x="mindos-ask-mode",b=["agent","chat"];function v({mode:e,onChange:t,disabled:r}){let{t:a}=(0,d.Y)(),[o,l]=(0,s.useState)(!1),[i,u]=(0,s.useState)(null),c=(0,s.useRef)(null),v=(0,s.useRef)(null),y=(0,s.useCallback)(()=>{if(!c.current)return;let e=c.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>120?"up":"down";u({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})},[]);(0,s.useEffect)(()=>{o&&y()},[o,y]),(0,s.useEffect)(()=>{if(!o)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&v.current&&!v.current.contains(t)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),(0,s.useEffect)(()=>{if(!o)return;let e=e=>{"Escape"===e.key&&l(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]),(0,s.useEffect)(()=>{if(o)return window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[o,y]);let k=(0,s.useCallback)(e=>{t(e);try{localStorage.setItem(x,e)}catch{}l(!1)},[t]),w="chat"===e,j=(e,t)=>"chat"===e?(0,n.jsx)(p.A,{size:t,className:"shrink-0"}):(0,n.jsx)(f.A,{size:t,className:"shrink-0"}),N=e=>"chat"===e?a.ask.modeChat:a.ask.modeAgent,C=e=>"chat"===e?a.ask.modeChatHint:a.ask.modeAgentHint,A=o&&i?(0,n.jsx)("div",{ref:v,role:"listbox","aria-label":"Select mode",className:"fixed z-50 min-w-[200px] max-w-[260px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:i.left,..."up"===i.direction?{bottom:window.innerHeight-i.top}:{top:i.top}},children:b.map(t=>{let r=e===t;return(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":r,onClick:()=>k(t),className:"flex w-full items-center gap-2.5 px-3 py-2 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:j(t,13)}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"font-medium",children:N(t)}),(0,n.jsx)("div",{className:"text-2xs text-muted-foreground mt-0.5",children:C(t)})]}),r&&(0,n.jsx)(g.A,{size:12,className:"shrink-0 text-[var(--amber)]"})]},t)})}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{ref:c,type:"button",onClick:()=>{r||l(e=>!e)},disabled:r,className:`
|
|
2
|
+
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
3
|
+
text-2xs font-medium transition-colors select-none
|
|
4
|
+
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
5
|
+
disabled:opacity-40 disabled:cursor-not-allowed
|
|
6
|
+
${w?"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:text-foreground":"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-foreground hover:bg-[var(--amber)]/15"}
|
|
7
|
+
`,title:C(e),"aria-expanded":o,"aria-haspopup":"listbox",children:[j(e,11),(0,n.jsx)("span",{className:"truncate max-w-[80px]",children:N(e)}),(0,n.jsx)(h.A,{size:10,className:"shrink-0 text-muted-foreground"})]}),"u">typeof document&&A&&(0,m.createPortal)(A,document.body)]})}function y(e){let t=Date.now();return{id:`${t}-${Math.random().toString(36).slice(2,8)}`,currentFile:e,createdAt:t,updatedAt:t,messages:[]}}function k(e){if(e.title)return e.title;let t=e.messages.find(e=>"user"===e.role);if(!t)return"(empty session)";let r=t.content.replace(/\s+/g," ").trim();return!r&&t.images&&t.images.length>0?`[${t.images.length} image${t.images.length>1?"s":""}]`:r.length>42?`${r.slice(0,42)}...`:r||"(empty session)"}async function w(){try{let e=await fetch("/api/ask-sessions",{cache:"no-store"});if(!e.ok)return[];let t=await e.json();if(!Array.isArray(t))return[];return t.slice(0,30)}catch{return[]}}async function j(e){try{let t={...e,messages:e.messages.map(e=>e.images&&0!==e.images.length?{...e,images:e.images.map(e=>({...e,data:""}))}:e)};await fetch("/api/ask-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:t})})}catch{}}async function N(e){try{await fetch("/api/ask-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e})})}catch{}}async function C(e){try{await fetch("/api/ask-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:e})})}catch{}}let A=new Set([".txt",".md",".markdown",".csv",".json",".yaml",".yml",".xml",".html",".htm",".pdf"]);function S(e){let t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}async function E(e){let t=e.name;try{let r=await e.arrayBuffer(),n=function(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}(new Uint8Array(r)),s=await fetch("/api/extract-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,dataBase64:n})}),a={};try{a=await s.json()}catch{throw Error("Failed to parse extraction response")}if(!s.ok)throw Error(a.error||`PDF extraction failed (${s.status})`);let o=a.extracted&&a.text||"";if(!o)return{name:t,content:`[PDF: ${t}] Could not extract readable text (possibly scanned/image PDF).`,status:"error",error:"Scanned or image-only PDF — no extractable text"};let l={name:t,content:`[PDF TEXT EXTRACTED: ${t}]
|
|
8
|
+
|
|
9
|
+
${o}`,status:"success"};return a.truncated&&a.totalChars&&(l.truncatedInfo={totalChars:a.totalChars,includedChars:o.length,totalPages:a.pagesParsed??0}),l}catch(e){return{name:t,content:`[PDF: ${t}] Failed to extract text from this PDF.`,status:"error",error:e instanceof Error?e.message:"Unknown error"}}}let M=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function _(e){let t=e.type;if(e.size<=5242880){let r=new Uint8Array(await e.arrayBuffer()),n="";for(let e=0;e<r.length;e+=32768)n+=String.fromCharCode(...r.subarray(e,e+32768));return{data:btoa(n),mimeType:t}}return new Promise((t,r)=>{let n=new Image;n.onload=()=>{let{width:e,height:s}=n;if(e>1920||s>1920){let t=Math.min(1920/e,1920/s);e=Math.round(e*t),s=Math.round(s*t)}let a=document.createElement("canvas");a.width=e,a.height=s;let o=a.getContext("2d");o?(o.drawImage(n,0,0,e,s),t({data:a.toDataURL("image/jpeg",.85).split(",")[1],mimeType:"image/jpeg"}),URL.revokeObjectURL(n.src)):r(Error("Canvas not supported"))},n.onerror=()=>{r(Error("Failed to load image")),URL.revokeObjectURL(n.src)},n.src=URL.createObjectURL(e)})}function R(e){let t=[];for(let r of Array.from(e))if("file"===r.kind&&M.has(r.type)){let e=r.getAsFile();e&&t.push(e)}return t}var L=r(67635),T=r(53961),z=r(56558),I=r(6296),P=r(32967),D=r(59511),$=r(61878),O=r(37618),F=r(31885),U=r(13545),B=r(84755),H=r(56842),K=r(66804),Z=r(32957),W=r(48391),Y=r(7834),q=r(42129),G=r(97810),J=r(49387),Q=r(93631),V=r(45049),X=r(68459),ee=r(48334),et=r(97233),er=r(50538),en=r(84980),es=r(33078),ea=r(21362),eo=r(41585),el=r(12651),ei=r(62791);let eu=new Set(["delete_file","move_file","rename_file","write_file"]),ec=new Set(["write_file","create_file","update_section","insert_after_heading","edit_lines","append_to_file"]),ed={search:$.A,list_files:q.A,read_file:G.A,write_file:J.A,create_file:Q.A,append_to_file:o.A,insert_after_heading:V.A,update_section:J.A,delete_file:X.A,rename_file:o.A,move_file:ee.A,get_backlinks:et.A,get_history:er.A,get_file_at_version:er.A,get_recent:en.A,append_csv:es.A},em="--- changes ---";function ep({part:e}){let t=ec.has(e.toolName),r="done"===e.state,[a,o]=(0,s.useState)(null),l=a??(t&&r),i=ed[e.toolName]??P.A,u=eu.has(e.toolName),c=(0,s.useMemo)(()=>(function(e){if(!e)return{header:"",stats:"",diffLines:[]};let t=e.indexOf(em);if(-1===t)return{header:e,stats:"",diffLines:[]};let r=e.slice(0,t).trim(),n=e.slice(t+em.length).trim(),s=r.match(/\((\+\d+\s*−\d+)\)/);return{header:r,stats:s?s[1]:"",diffLines:n.split("\n").map(e=>e.startsWith("+ ")?{prefix:"+",text:e.slice(2)}:e.startsWith("- ")?{prefix:"-",text:e.slice(2)}:e.startsWith(" ")?{prefix:" ",text:e.slice(2)}:{prefix:" ",text:e})}})(e.output),[e.output]),d=(0,s.useMemo)(()=>e.input&&"object"==typeof e.input?e.input.path??"":"",[e.input]),m=d?`${d.split("/").pop()??d}${c.stats?` (${c.stats})`:""}`:function(e){if(!e||"object"!=typeof e)return String(e??"");let t=[];for(let r of Object.values(e))"string"==typeof r?t.push(r.length>60?`${r.slice(0,60)}…`:r):Array.isArray(r)?t.push(`[${r.length} items]`):null!=r&&t.push(String(r));return t.join(", ")}(e.input);return(0,n.jsxs)("div",{className:`my-1.5 rounded-lg border text-xs font-mono ${u?"border-[var(--amber)]/30 bg-background/60":"border-border/40 bg-background/50"}`,children:[(0,n.jsxs)("button",{type:"button",onClick:()=>o(e=>null===e?!l:!e),"aria-expanded":l,className:"w-full flex items-center gap-1.5 px-2.5 py-2 text-left hover:bg-muted/30 transition-colors rounded-lg",children:[l?(0,n.jsx)(h.A,{size:12,className:"shrink-0 text-muted-foreground"}):(0,n.jsx)(ea.A,{size:12,className:"shrink-0 text-muted-foreground"}),u&&(0,n.jsx)(eo.A,{size:11,className:"shrink-0 text-[var(--amber)]"}),(0,n.jsx)(i,{size:12,className:`shrink-0 ${u?"text-[var(--amber)]":"text-muted-foreground"}`}),(0,n.jsx)("span",{className:`font-medium ${u?"text-[var(--amber)]":"text-foreground"}`,children:e.toolName}),(0,n.jsx)("span",{className:"text-muted-foreground truncate flex-1",children:m}),(0,n.jsx)("span",{className:"shrink-0 ml-auto",children:"pending"===e.state||"running"===e.state?(0,n.jsx)(I.A,{size:12,className:"animate-spin text-[var(--amber)]"}):"done"===e.state?(0,n.jsx)(el.A,{size:12,className:"text-success"}):(0,n.jsx)(ei.A,{size:12,className:"text-error"})})]}),l&&(0,n.jsx)("div",{className:"border-t border-border/30",children:t&&r&&c.diffLines.length>0?(0,n.jsx)("div",{className:"max-h-64 overflow-y-auto",children:c.diffLines.map((e,t)=>(0,n.jsxs)("div",{className:`px-2 py-px flex items-start gap-1.5 ${"+"===e.prefix?"bg-success/8":"-"===e.prefix?"bg-error/8":""}`,children:[(0,n.jsx)("span",{className:`select-none w-3 shrink-0 text-right ${"+"===e.prefix?"text-success":"-"===e.prefix?"text-error":"text-muted-foreground/50"}`,children:e.prefix}),(0,n.jsx)("span",{className:`whitespace-pre-wrap break-all flex-1 ${"+"===e.prefix?"text-success":"-"===e.prefix?"text-error":"text-muted-foreground"}`,children:e.text||"\xa0"})]},t))}):(0,n.jsxs)("div",{className:"px-2.5 pb-2.5 pt-1.5 space-y-1.5",children:["running"===e.state&&(0,n.jsxs)("div",{className:"text-muted-foreground/60 text-2xs flex items-center gap-1.5",children:[(0,n.jsx)(I.A,{size:10,className:"animate-spin"})," Running..."]}),(0,n.jsxs)("div",{className:"text-muted-foreground leading-relaxed",children:[(0,n.jsx)("span",{className:"font-semibold text-foreground/70",children:"Input: "}),(0,n.jsx)("span",{className:"break-all whitespace-pre-wrap",children:JSON.stringify(e.input,null,2)})]}),void 0!==e.output&&""!==e.output&&(0,n.jsxs)("div",{className:"text-muted-foreground leading-relaxed",children:[(0,n.jsx)("span",{className:"font-semibold text-foreground/70",children:"Output: "}),(0,n.jsx)("span",{className:"break-all whitespace-pre-wrap",children:e.output.length>500?e.output.slice(0,500)+"…":e.output})]})]})})]})}var ef=r(90718);function eg({text:e,isStreaming:t}){let[r,a]=(0,s.useState)(!1),{t:o}=(0,d.Y)();return e||t?(0,n.jsxs)("div",{className:"my-1.5 rounded-lg border border-border/30 bg-muted/15 text-xs",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),"aria-expanded":r,className:"w-full flex items-center gap-1.5 px-2.5 py-2 text-left hover:bg-muted/30 transition-colors rounded-lg",children:[r?(0,n.jsx)(h.A,{size:12,className:"shrink-0 text-muted-foreground"}):(0,n.jsx)(ea.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,n.jsx)(ef.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,n.jsxs)("span",{className:"text-muted-foreground font-medium",children:[o.ask.thinkingLabel,t&&!r&&(0,n.jsx)("span",{className:"ml-1 animate-pulse",children:"..."})]}),!r&&e&&(0,n.jsxs)("span",{className:"text-muted-foreground/50 truncate flex-1 ml-1",children:[e.slice(0,80),e.length>80?"...":""]})]}),r&&(0,n.jsx)("div",{className:"px-2.5 pb-2.5 pt-1 border-t border-border/20",children:(0,n.jsxs)("div",{className:"text-muted-foreground whitespace-pre-wrap leading-relaxed",children:[e,t&&(0,n.jsx)("span",{className:"inline-block w-1 h-3 bg-muted-foreground/40 ml-0.5 align-middle animate-pulse rounded-full"})]})})]}):null}let eh=/^Use the skill ([^:]+):\s*/;function ex({text:e,label:t}){let[r,a]=(0,s.useState)(!1),o=(0,s.useCallback)(()=>{(0,Y.l)(e).then(e=>{e&&(a(!0),setTimeout(()=>a(!1),2e3))})},[e]);return(0,n.jsx)("button",{type:"button",onClick:o,className:"absolute -bottom-1 right-1 p-1 rounded-md bg-card border border-border/60 shadow-sm text-muted-foreground hover:text-foreground opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",title:t??"Copy",children:r?(0,n.jsx)(g.A,{size:11,className:"text-success"}):(0,n.jsx)(L.A,{size:11})})}function eb({content:e,skillName:t,images:r,attachedFiles:s,uploadedFileNames:a}){let l=t??e.match(eh)?.[1],i=e.match(eh),u=i?e.slice(i[0].length):e,c=new Set(a??[]),d=s?.filter(e=>!c.has(e.split("/").pop()??e)),m=d&&d.length>0||a&&a.length>0;return(0,n.jsxs)(n.Fragment,{children:[r&&r.length>0&&(0,n.jsx)("div",{className:`flex flex-wrap gap-1.5${e?" mb-2":""}`,children:r.map((e,t)=>e.data?(0,n.jsx)("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:`Image ${t+1}`,className:"max-h-48 max-w-full rounded-md object-contain"},t):(0,n.jsx)("div",{className:"h-12 px-3 rounded-md bg-muted flex items-center gap-1.5 text-xs text-muted-foreground",children:(0,n.jsxs)("span",{children:["[Image ",t+1,"]"]})},t))}),l&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium bg-white/20 text-white/90 mr-1 align-middle",children:[(0,n.jsx)(T.A,{size:10,className:"shrink-0"}),l]}),l?u:e,m&&(0,n.jsxs)("div",{className:"mt-2 pt-1.5 border-t border-white/15 flex flex-wrap gap-1 whitespace-normal",role:"list","aria-label":"Attached files",children:[d?.map(e=>(0,n.jsxs)("span",{role:"listitem",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-white/10 text-white/80 min-w-0",title:e,children:[(0,n.jsx)(o.A,{size:9,className:"shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:e.split("/").pop()})]},e)),a?.map(e=>(0,n.jsxs)("span",{role:"listitem",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-white/10 text-white/80 min-w-0",title:e,children:[(0,n.jsx)(z.A,{size:9,className:"shrink-0 opacity-70"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:e})]},e))]})]})}function ev({content:e,isStreaming:t}){let r=(0,W.Oo)(e);return r||t?(0,n.jsxs)("div",{className:"prose prose-sm prose-panel dark:prose-invert max-w-none text-foreground prose-p:my-2 prose-p:leading-relaxed prose-headings:font-semibold prose-headings:my-3 prose-h1:text-base prose-h2:text-[15px] prose-h3:text-sm prose-ul:my-1.5 prose-li:my-0.5 prose-ol:my-1.5 prose-code:text-[0.8em] prose-code:bg-muted/80 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:before:content-none prose-code:after:content-none prose-code:font-mono prose-pre:bg-muted/60 prose-pre:text-foreground prose-pre:text-xs prose-pre:rounded-lg prose-blockquote:border-l-[var(--amber)] prose-blockquote:text-muted-foreground prose-blockquote:not-italic prose-a:text-[var(--amber)] prose-a:no-underline hover:prose-a:underline prose-strong:text-foreground prose-strong:font-semibold prose-table:text-xs prose-th:py-1.5 prose-td:py-1 ",children:[(0,n.jsx)(K.oz,{remarkPlugins:[Z.A],children:r}),t&&(0,n.jsx)("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--amber)] ml-0.5 align-middle animate-pulse rounded-full"})]}):null}function ey({message:e,isStreaming:t}){let r=e.parts;if(!r||0===r.length)return e.content?(0,n.jsx)(ev,{content:e.content,isStreaming:t}):null;let s=r[r.length-1],a=t&&"tool-call"===s.type&&("running"===s.state||"pending"===s.state);return(0,n.jsxs)("div",{children:[r.map((e,s)=>{if("reasoning"===e.type){let a=t&&s===r.length-1;return(0,n.jsx)(eg,{text:e.text,isStreaming:a},`reasoning-${s}`)}if("text"===e.type){let a=t&&s===r.length-1;return e.text?(0,n.jsx)(ev,{content:e.text,isStreaming:a},s):null}return"tool-call"===e.type?(0,n.jsx)(ep,{part:e},e.toolCallId):null}),a&&(0,n.jsxs)("div",{className:"flex items-center gap-2 py-1.5 mt-1.5",children:[(0,n.jsx)(I.A,{size:12,className:"animate-spin text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Executing tool…"})]})]})}function ek({parts:e}){if(!e)return null;let t=e.filter(e=>"tool-call"===e.type);if(0===t.length)return null;let r=t[t.length-1],s="tool-call"===r.type?r.toolName:"";return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mt-2 pt-1.5 border-t border-border/15 text-xs text-muted-foreground/60",children:[(0,n.jsx)(P.A,{size:10}),(0,n.jsxs)("span",{className:"font-medium",children:["Step ",t.length,s?` — ${s}`:""]})]})}let ew=(0,s.memo)(function({messages:e,isLoading:t,loadingPhase:r,emptyPrompt:a,emptyHint:o,suggestions:l,onSuggestionClick:i,labels:u}){let c=(0,s.useRef)(null),d=(0,s.useRef)(null),[m,p]=(0,s.useState)(!1),g=(0,s.useCallback)(()=>{let e=d.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]);return(0,s.useEffect)(()=>{g()},[e,g]),(0,s.useEffect)(()=>{let e=d.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:r,clientHeight:n}=e;p(r-t-n>100)};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,n.jsxs)("div",{ref:d,role:"log","aria-live":"polite",className:"relative flex-1 overflow-y-auto overflow-x-hidden px-4 py-5 space-y-5 min-h-0",children:[0===e.length&&(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 min-h-[260px] px-6 pt-10 pb-4",children:[(0,n.jsxs)("div",{className:"relative w-12 h-12 rounded-2xl bg-[var(--amber)]/10 flex items-center justify-center mb-6",children:[(0,n.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-[var(--amber)]/5 scale-[1.4]"}),(0,n.jsx)(f.A,{size:22,className:"text-[var(--amber)] relative z-10"})]}),(0,n.jsx)("p",{className:"text-center text-[15px] font-semibold text-foreground tracking-tight mb-2",children:a}),o&&(0,n.jsx)("p",{className:"text-center text-xs text-muted-foreground/80 mb-10 tracking-wide",children:o}),(0,n.jsx)("div",{className:"flex flex-col gap-2.5 max-w-[280px] w-full",children:l.map((e,t)=>{let r=[D.A,$.A,O.A,F.A],s=r[t%r.length];return(0,n.jsxs)("button",{type:"button",onClick:()=>i(e.prompt),className:"group/sug flex items-center gap-3 text-left text-[13px] px-3.5 py-3 rounded-xl border border-border/40 bg-transparent text-muted-foreground hover:text-foreground hover:border-[var(--amber)]/30 hover:bg-[var(--amber)]/5 transition-all leading-snug","aria-label":e.prompt,children:[(0,n.jsx)("span",{className:"shrink-0 w-8 h-8 rounded-lg bg-muted/60 flex items-center justify-center group-hover/sug:bg-[var(--amber)]/10 transition-colors",children:(0,n.jsx)(s,{size:15,className:"text-muted-foreground/70 group-hover/sug:text-[var(--amber)] transition-colors"})}),(0,n.jsx)("span",{className:"flex-1",children:e.label})]},t)})})]}),e.map((s,a)=>(0,n.jsxs)("div",{className:`flex gap-3 animate-[fadeSlideUp_0.22s_ease_both] ${"user"===s.role?"justify-end":"justify-start"}`,children:["assistant"===s.role&&(0,n.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 mt-0.5 bg-[var(--amber)]/8",children:(0,n.jsx)(f.A,{size:13,className:"text-[var(--amber)]"})}),"user"===s.role?(0,n.jsx)("div",{className:"max-w-[85%] px-3.5 py-2.5 rounded-2xl rounded-br-lg text-sm leading-relaxed whitespace-pre-wrap bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm shadow-[var(--amber)]/10",children:(0,n.jsx)(eb,{content:s.content,skillName:s.skillName,images:s.images,attachedFiles:s.attachedFiles,uploadedFileNames:s.uploadedFileNames})}):s.content.startsWith("__error__")?(0,n.jsx)("div",{className:"max-w-[85%] px-3.5 py-3 rounded-2xl rounded-bl-md border border-error/30 bg-error/10 text-sm shadow-sm",children:(0,n.jsxs)("div",{className:"flex items-start gap-2.5 text-error",children:[(0,n.jsx)(U.A,{size:15,className:"shrink-0 mt-0.5"}),(0,n.jsx)("span",{className:"leading-relaxed font-medium",children:s.content.slice(9)})]})}):(0,n.jsx)("div",{className:"group relative max-w-[85%] px-3.5 py-2.5 rounded-2xl rounded-bl-lg bg-card border border-border/30 shadow-sm text-foreground text-sm",children:s.parts&&s.parts.length>0||(0,W.Oo)(s.content)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ey,{message:s,isStreaming:t&&a===e.length-1}),t&&a===e.length-1&&(0,n.jsx)(ek,{parts:s.parts}),!(t&&a===e.length-1)&&(0,W.Oo)(s.content)&&(0,n.jsx)(ex,{text:(0,W.Oo)(s.content),label:u.copyMessage})]}):t&&a===e.length-1?(0,n.jsxs)("div",{className:"flex items-center gap-2.5 py-1",children:["reconnecting"===r?(0,n.jsx)(B.A,{size:14,className:"text-[var(--amber)] animate-pulse"}):(0,n.jsx)(I.A,{size:14,className:"animate-spin text-[var(--amber)]"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:["reconnecting"===r?u.reconnecting??"Reconnecting...":"connecting"===r?u.connecting:"thinking"===r?u.thinking:u.generating,(0,n.jsxs)("span",{className:"inline-flex gap-0.5",children:[(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:0ms]"}),(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:150ms]"}),(0,n.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--amber)] animate-bounce [animation-delay:300ms]"})]})]})})]}):null})]},a)),(0,n.jsx)("div",{ref:c}),m&&e.length>0&&(0,n.jsx)("button",{type:"button",onClick:g,className:"sticky bottom-2 left-1/2 -translate-x-1/2 z-10 p-2 rounded-full border border-border/60 bg-card shadow-md text-muted-foreground hover:text-foreground hover:bg-muted transition-all hover:shadow-lg",title:"Scroll to bottom",children:(0,n.jsx)(H.A,{size:14})})]})});function ej({text:e,query:t}){if(!t)return(0,n.jsx)(n.Fragment,{children:e});let r=e.toLowerCase().indexOf(t.toLowerCase());return -1===r?(0,n.jsx)(n.Fragment,{children:e}):(0,n.jsxs)(n.Fragment,{children:[e.slice(0,r),(0,n.jsx)("span",{className:"text-[var(--amber)] font-semibold",children:e.slice(r,r+t.length)}),e.slice(r+t.length)]})}function eN({results:e,selectedIndex:t,query:r,onSelect:a}){let l=(0,s.useRef)(null),i=(0,s.useRef)(null),[u,c]=(0,s.useState)(280);return((0,s.useEffect)(()=>{let e=i.current;e&&c(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,s.useEffect)(()=>{let e=l.current;if(!e)return;let r=e.children[t];r?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,n.jsxs)("div",{ref:i,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,n.jsx)(q.A,{size:11,className:"text-muted-foreground/50"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Files"}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,n.jsx)("div",{ref:l,className:"overflow-y-auto",style:{maxHeight:u},children:e.map((e,s)=>{let l=e.split("/").pop()??e,i=e.split("/").slice(0,-1).join("/"),u=l.endsWith(".csv");return(0,n.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),a(e)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${s===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[u?(0,n.jsx)(es.A,{size:13,className:"text-success shrink-0"}):(0,n.jsx)(o.A,{size:13,className:"text-muted-foreground shrink-0"}),(0,n.jsx)("span",{className:"truncate font-medium flex-1",title:l,children:(0,n.jsx)(ej,{text:l,query:r})}),i&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 truncate max-w-[140px] shrink-0",title:i,children:(0,n.jsx)(ej,{text:i,query:r})})]},e)})}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,n.jsx)("span",{children:"↑↓ navigate"}),(0,n.jsx)("span",{children:"↵ select"}),(0,n.jsx)("span",{children:"ESC dismiss"})]})]})}function eC({results:e,selectedIndex:t,query:r,onSelect:a}){let o=(0,s.useRef)(null),l=(0,s.useRef)(null),[i,u]=(0,s.useState)(280);return((0,s.useEffect)(()=>{let e=l.current;e&&u(Math.max(120,Math.min(320,Math.min(e.getBoundingClientRect().top-8,.5*window.innerHeight)-80)))},[e.length]),(0,s.useEffect)(()=>{let e=o.current;if(!e)return;let r=e.children[t];r?.scrollIntoView({block:"nearest"})},[t]),0===e.length)?null:(0,n.jsxs)("div",{ref:l,className:"border border-border rounded-lg bg-card shadow-lg overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-1.5",children:[(0,n.jsx)(T.A,{size:11,className:"text-[var(--amber)]/50"}),(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground/70 uppercase tracking-wider",children:"Skills"}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/40 ml-auto",children:e.length})]}),(0,n.jsx)("div",{ref:o,className:"overflow-y-auto",style:{maxHeight:i},children:e.map((e,s)=>(0,n.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),a(e)},className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors ${s===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-muted"}`,children:[(0,n.jsx)(T.A,{size:13,className:"text-[var(--amber)] shrink-0"}),(0,n.jsxs)("span",{className:"text-sm font-medium shrink-0",children:["/",(0,n.jsx)(ej,{text:e.name,query:r})]}),e.description&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground/50 truncate min-w-0 flex-1",title:e.description,children:e.description})]},e.name))}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex gap-3 text-2xs text-muted-foreground/40 shrink-0",children:[(0,n.jsx)("span",{children:"↑↓ navigate"}),(0,n.jsx)("span",{children:"↵ / Tab select"}),(0,n.jsx)("span",{children:"ESC dismiss"})]})]})}var eA=r(36261);function eS({sessions:e,activeSessionId:t,onLoad:r,onDelete:a,onRename:o,onTogglePin:l,onClearAll:i,labels:u}){let[c,d]=(0,s.useState)(!1),m=(0,s.useRef)(void 0),[p,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(""),x=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,s.useEffect)(()=>{p&&x.current&&(x.current.focus(),x.current.select())},[p]);let b=(0,s.useCallback)(e=>{f(e.id),h(k(e))},[]),v=(0,s.useCallback)(()=>{p&&(o(p,g),f(null))},[p,g,o]),y=(0,s.useCallback)(()=>{f(null)},[]);return(0,n.jsxs)("div",{className:"border-b border-border/40 px-4 py-3 max-h-[220px] overflow-y-auto",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:u.title}),e.length>1&&(0,n.jsx)("button",{type:"button",onClick:()=>{if(!c){d(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>d(!1),3e3);return}m.current&&clearTimeout(m.current),i(),d(!1)},className:`text-2xs px-2 py-0.5 rounded-md transition-colors ${c?"bg-error/10 text-error font-medium":"text-muted-foreground/60 hover:text-error hover:bg-muted"}`,children:c?u.confirmClear:u.clearAll})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[0===e.length&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground/50 py-2 text-center",children:u.noSessions}),e.map(e=>{let s=t===e.id;return(0,n.jsxs)("div",{className:"group flex items-center gap-0.5",children:[e.pinned&&(0,n.jsx)(V.A,{size:10,className:"shrink-0 text-[var(--amber)]/50 -rotate-45 ml-1"}),(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.id),onDoubleClick:()=>b(e),className:`flex-1 text-left px-2.5 py-2 rounded-lg text-xs transition-colors min-w-0 ${s?"bg-[var(--amber)]/8 text-foreground border border-[var(--amber)]/15":"text-muted-foreground hover:bg-muted hover:text-foreground border border-transparent"}`,children:[p===e.id?(0,n.jsx)("input",{ref:x,type:"text",value:g,onChange:e=>h(e.target.value),onBlur:v,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v()),"Escape"===e.key&&(e.preventDefault(),y())},onClick:e=>e.stopPropagation(),className:"w-full bg-transparent border-b border-[var(--amber)] outline-none text-xs text-foreground"}):(0,n.jsx)("div",{className:"truncate font-medium",children:k(e)}),p!==e.id&&(0,n.jsx)("div",{className:"text-2xs text-muted-foreground/50 mt-0.5",children:function(e){let t=Math.floor((Date.now()-e.getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);if(r<24)return`${r}h ago`;let n=Math.floor(r/24);return n<7?`${n}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}(new Date(e.updatedAt))})]}),(0,n.jsx)("button",{type:"button",onClick:()=>l(e.id),className:`p-1.5 rounded-lg transition-opacity opacity-0 group-hover:opacity-100 ${e.pinned?"text-[var(--amber)] hover:text-muted-foreground":"text-muted-foreground hover:text-[var(--amber)]"}`,title:e.pinned?"Unpin":"Pin",children:e.pinned?(0,n.jsx)(eA.A,{size:11}):(0,n.jsx)(V.A,{size:11})}),(0,n.jsx)("button",{type:"button",onClick:()=>b(e),className:"p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:u.rename,children:(0,n.jsx)(J.A,{size:11})}),(0,n.jsx)("button",{type:"button",onClick:()=>a(e.id),className:"p-1.5 rounded-lg text-muted-foreground hover:text-error hover:bg-error/5 opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete session",children:(0,n.jsx)(X.A,{size:11})})]},e.id)})]})]})}var eE=r(89823),eM=r(60241),e_=r(24371),eR=r(52335),eL=r(94852);let eT=(0,s.memo)(function({isPanel:e,showHistory:t,onToggleHistory:r,onReset:a,isLoading:o,maximized:l,onMaximize:u,askMode:c,onModeSwitch:p,onClose:x,onDockToPanel:b,hideTitle:v,sessions:y,activeSessionId:w,onLoadSession:j,onDeleteSession:N,onRenameSession:C,onTogglePinSession:A}){let{t:S}=(0,d.Y)(),E=y&&y.length>=1,M=y?.find(e=>e.id===w),_=M?k(M):null,[R,L]=(0,s.useState)(!1),T=(0,s.useRef)(null),z=(0,s.useRef)(null),[I,P]=(0,s.useState)(null),[D,$]=(0,s.useState)(""),O=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!R)return;let e=e=>{let t=e.target;T.current&&!T.current.contains(t)&&z.current&&!z.current.contains(t)&&(L(!1),P(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[R]),(0,s.useEffect)(()=>{if(!R)return;let e=e=>{"Escape"===e.key&&(I?P(null):L(!1))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[R,I]),(0,s.useEffect)(()=>{I&&setTimeout(()=>O.current?.focus(),0)},[I]);let F=(0,s.useCallback)(e=>{j?.(e),L(!1)},[j]),U=(0,s.useCallback)((e,t)=>{P(e),$("(empty session)"===t?"":t)},[]),B=(0,s.useCallback)(()=>{I&&C&&D.trim()&&C(I,D.trim()),P(null)},[I,D,C]),[H,K]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!R||!T.current)return;let e=T.current.getBoundingClientRect();K({top:e.bottom+4,left:e.left,width:Math.max(e.width,240)})},[R]);let Z=R&&H&&y?(0,m.createPortal)((0,n.jsx)("div",{ref:z,className:"fixed z-50 rounded-xl border border-border/50 bg-card shadow-lg py-1 animate-in fade-in-0 slide-in-from-top-1 duration-100",style:{top:H.top,left:H.left,minWidth:H.width,maxWidth:320},role:"listbox",children:y.map(e=>{let t=e.id===w,r=k(e),s="(empty session)"===r?S.hints?.newChat??"New chat":r;return I===e.id?(0,n.jsx)("div",{className:"flex items-center gap-1 px-2 py-1.5",children:(0,n.jsx)("input",{ref:O,type:"text",value:D,onChange:e=>$(e.target.value),onKeyDown:e=>{"Enter"===e.key&&B(),"Escape"===e.key&&P(null)},onBlur:B,className:"flex-1 min-w-0 px-2 py-1 text-xs rounded-md border border-border bg-background text-foreground outline-none focus:border-[var(--amber)]/50",placeholder:"Session name..."})},e.id):(0,n.jsxs)("div",{className:"group/item flex items-center",children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>F(e.id),className:`flex-1 min-w-0 flex items-center gap-2 px-3 py-2 text-xs text-left transition-colors ${t?"text-foreground font-medium":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.pinned&&(0,n.jsx)(V.A,{size:10,className:"shrink-0 text-[var(--amber)]/60 -rotate-45"}),t&&!e.pinned&&(0,n.jsx)(g.A,{size:11,className:"shrink-0 text-[var(--amber)]"}),(0,n.jsx)("span",{className:"truncate",children:s})]}),(0,n.jsxs)("div",{className:"shrink-0 flex items-center gap-0.5 mr-1 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[A&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),A(e.id)},className:`p-1.5 rounded-md transition-colors ${e.pinned?"text-[var(--amber)] hover:text-muted-foreground hover:bg-muted/60":"text-muted-foreground/40 hover:text-[var(--amber)] hover:bg-[var(--amber)]/5"}`,"aria-label":e.pinned?"Unpin":"Pin",children:e.pinned?(0,n.jsx)(eA.A,{size:10}):(0,n.jsx)(V.A,{size:10})}),C&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),U(e.id,r)},className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-foreground hover:bg-muted/60","aria-label":`Rename: ${s}`,children:(0,n.jsx)(J.A,{size:10})}),y.length>1&&N&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),N(e.id)},className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-error hover:bg-error/5","aria-label":`Delete: ${s}`,children:(0,n.jsx)(X.A,{size:10})})]})]},e.id)})}),document.body):null;return(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 shrink-0",children:[!e&&(0,n.jsx)("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-8 h-1 rounded-full bg-muted-foreground/20 md:hidden"}),!v&&(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)("div",{className:"w-6 h-6 rounded-lg bg-[var(--amber)]/10 flex items-center justify-center shrink-0",children:(0,n.jsx)(f.A,{size:13,className:"text-[var(--amber)]"})}),E&&_?(0,n.jsxs)("button",{ref:T,type:"button",onClick:()=>{y&&y.length>=2?L(e=>!e):r()},className:"flex items-center gap-1 min-w-0 text-sm font-medium text-[var(--amber)] hover:text-[var(--amber)]/80 transition-colors","aria-expanded":R,"aria-haspopup":"listbox",children:[(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:"(empty session)"===_?S.hints?.newChat??"New chat":_}),(0,n.jsx)(h.A,{size:12,className:`shrink-0 text-muted-foreground transition-transform duration-150 ${R?"rotate-180":""}`})]}):_?(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground/60 truncate max-w-[180px]",children:"(empty session)"===_?S.hints?.newChat??"New chat":_}):(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground/40",children:S.hints?.newChat??"New chat"})]}),v&&(0,n.jsx)("div",{}),(0,n.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),r()},"aria-pressed":t,className:`p-2 rounded-lg transition-colors ${t?"bg-[var(--amber)]/10 text-[var(--amber)]":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:S.hints.sessionHistory,children:(0,n.jsx)(er.A,{size:14})}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),a()},disabled:o,className:"p-2 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40",title:S.hints.newSession,children:(0,n.jsx)(eE.A,{size:14})}),u&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),u()},className:"p-2 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:l?S.hints.restorePanel:S.hints.maximizePanel,children:l?(0,n.jsx)(eM.A,{size:14}):(0,n.jsx)(e_.A,{size:14})}),b&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),b()},className:"p-2 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:S.hints.dockToSide??"Dock to side panel",children:(0,n.jsx)(eR.A,{size:14})}),p&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),p()},className:"p-2 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"popup"===c?S.hints.dockToSide:S.hints.openAsPopup,children:"popup"===c?(0,n.jsx)(eR.A,{size:14}):(0,n.jsx)(eL.A,{size:14})}),x&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),x()},className:"p-2 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:S.hints.closePanel,"aria-label":"Close",children:(0,n.jsx)(i.A,{size:14})})]}),"u">typeof document&&Z]})});var ez=r(49619),eI=r(38798);let eP={kb:{icon:o.A,cls:"text-muted-foreground"},upload:{icon:z.A,cls:"text-muted-foreground"},image:{icon:l.A,cls:"text-muted-foreground"},skill:{icon:T.A,cls:"text-[var(--amber)]"},agent:{icon:ez.A,cls:"text-muted-foreground"}},eD={kb:"border-border bg-muted text-foreground",upload:"border-border bg-muted text-foreground",image:"border-border bg-muted text-foreground",skill:"border-[var(--amber)]/25 bg-[var(--amber)]/10 text-foreground",agent:"border-[var(--amber)]/25 bg-[var(--amber)]/10 text-foreground"};function e$({path:e,onRemove:t,variant:r="kb",imageData:a,imageMime:o,status:l,error:u,truncatedInfo:c}){let[d,p]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[h,x]=(0,s.useState)(!1),b=(0,s.useRef)(null),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(null);(0,s.useEffect)(()=>x(!0),[]);let j="kb"===r&&e.endsWith("/"),N=j?e.slice(0,-1):e,C=N.split("/").pop()??N,A="kb"===r&&!j&&C.endsWith(".csv"),{icon:S,cls:E}=j?{icon:eI.A,cls:"text-yellow-400"}:A?{icon:es.A,cls:"text-success"}:eP[r],M=!!c,_=null,R="";"loading"===l?(_=I.A,R="text-muted-foreground animate-spin"):"error"===l?(_=U.A,R="text-destructive"):M?(_=eo.A,R="text-amber-500"):"success"===l&&(_=el.A,R="text-emerald-500");let L="error"===l?"border-destructive/30 bg-destructive/5 text-foreground":M?"border-amber-500/30 bg-amber-500/5 text-foreground":eD[r],T=null;if("error"===l&&u)T=u;else if(M){let e=c.totalChars>0?Math.round(c.includedChars/c.totalChars*100):0;T=`Document truncated — only ${e}% included (${Math.round(c.includedChars/1e3)}K / ${Math.round(c.totalChars/1e3)}K chars, ${c.totalPages} pages total)`}(0,s.useEffect)(()=>{if(!d||!b.current)return void y(null);let e=b.current.getBoundingClientRect();y({top:e.top-8,left:e.left})},[d]),(0,s.useEffect)(()=>{if(!f||!b.current)return void w(null);let e=b.current.getBoundingClientRect();w({top:e.top-8,left:e.left})},[f]);let z=d&&v&&a&&o?(0,n.jsx)("div",{className:"fixed z-50 p-1 rounded-lg border border-border bg-card shadow-lg pointer-events-none",style:{left:v.left,bottom:window.innerHeight-v.top},children:(0,n.jsx)("img",{src:`data:${o};base64,${a}`,alt:C,className:"max-h-48 max-w-64 rounded object-contain"})}):null,P=f&&k&&T?(0,n.jsx)("div",{className:`fixed z-50 px-2.5 py-1.5 rounded-lg border bg-card text-xs shadow-lg pointer-events-none max-w-[280px] ${"error"===l?"border-destructive/20 text-destructive":"border-amber-500/20 text-amber-600 dark:text-amber-400"}`,style:{left:k.left,bottom:window.innerHeight-k.top},children:T}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{ref:b,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border max-w-[220px] ${L}`,onMouseEnter:()=>{a&&p(!0),T&&g(!0)},onMouseLeave:()=>{p(!1),g(!1)},children:[(0,n.jsx)(S,{size:11,className:`${E} shrink-0`}),(0,n.jsx)("span",{className:"truncate",title:j?N:e,children:C}),_&&(0,n.jsx)(_,{size:10,className:`${R} shrink-0`}),(0,n.jsx)("button",{type:"button",onClick:t,"aria-label":`Remove ${C}`,className:"p-0.5 -mr-1 rounded hover:text-foreground transition-colors shrink-0 text-muted-foreground",children:(0,n.jsx)(i.A,{size:10})})]}),h&&z&&(0,m.createPortal)(z,document.body),h&&P&&(0,m.createPortal)(P,document.body)]})}function eO({selectedAgent:e,onSelect:t,installedAgents:r,loading:a=!1}){let{t:o}=(0,d.Y)(),l=o.panels.agents,[u,c]=(0,s.useState)(!1),[p,f]=(0,s.useState)(null),x=(0,s.useRef)(null),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!u||!x.current)return;let e=x.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>200?"up":"down";f({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})},[u]),(0,s.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.target;x.current&&!x.current.contains(t)&&b.current&&!b.current.contains(t)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]),(0,s.useEffect)(()=>{if(!u)return;let e=e=>{"Escape"===e.key&&c(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u]),(0,s.useEffect)(()=>{if(!u||!x.current)return;let e=()=>{if(!x.current)return;let e=x.current.getBoundingClientRect(),t=e.top,r=t>window.innerHeight-e.bottom&&t>200?"up":"down";f({left:e.left,top:"up"===r?e.top-6:e.bottom+6,direction:r})};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[u]);let v=(0,s.useCallback)(()=>{t(null),c(!1)},[t]),y=(0,s.useCallback)(e=>{t({id:e.id,name:e.name}),c(!1)},[t]),k=(0,s.useCallback)(e=>{e.stopPropagation(),t(null)},[t]),w=!e,j=e?.name??l.acpDefaultAgent;if(!a&&0===r.length&&!e)return null;let N=u&&p?(0,n.jsxs)("div",{ref:b,role:"listbox","aria-label":l.acpSelectAgent,className:"fixed z-50 min-w-[180px] max-w-[240px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{left:p.left,..."up"===p.direction?{bottom:window.innerHeight-p.top}:{top:p.top}},children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":w,onClick:v,className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)(ez.A,{size:12,className:"shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"flex-1 truncate font-medium",children:l.acpDefaultAgent}),w&&(0,n.jsx)(g.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]}),r.length>0&&(0,n.jsx)("div",{className:"mx-2 my-1 border-t border-border/60"}),r.map(t=>{let r=e?.id===t.id;return(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":r,onClick:()=>y(t),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors hover:bg-muted",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-[var(--success)] shrink-0"}),(0,n.jsx)("span",{className:"flex-1 truncate",children:t.name}),r&&(0,n.jsx)(g.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]},t.id)})]}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{ref:x,type:"button",onClick:()=>c(e=>!e),className:`
|
|
10
|
+
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
11
|
+
text-2xs font-medium transition-colors
|
|
12
|
+
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
13
|
+
${w?"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:text-foreground":"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-foreground hover:bg-[var(--amber)]/15"}
|
|
14
|
+
`,title:l.acpChangeAgent,"aria-expanded":u,"aria-haspopup":"listbox",children:[w?(0,n.jsx)(ez.A,{size:11,className:"shrink-0 text-muted-foreground"}):(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--success)] shrink-0"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:j}),e?(0,n.jsx)("span",{role:"button",tabIndex:0,onClick:k,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),k(e))},className:"p-0.5 -mr-1 rounded-full text-muted-foreground hover:text-foreground transition-colors","aria-label":`Remove ${e.name}`,children:(0,n.jsx)(i.A,{size:9})}):(0,n.jsx)(h.A,{size:10,className:"shrink-0 text-muted-foreground"})]}),"u">typeof document&&N&&(0,m.createPortal)(N,document.body)]})}var eF=r(91958),eU=r(65576),eB=r(47376),eH=r(60112);let eK="mindos-provider-model";function eZ(e,t){try{e||t?localStorage.setItem(eK,JSON.stringify({provider:e,model:t})):localStorage.removeItem(eK),localStorage.removeItem("mindos-provider-override")}catch{}}function eW({providerValue:e,onProviderChange:t,modelValue:r,onModelChange:a,disabled:o=!1}){let{t:l,locale:i}=(0,d.Y)(),[u,c]=(0,s.useState)(!1),p=(0,s.useRef)(null),f=(0,s.useRef)(null),x=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(null),[y,k]=(0,s.useState)(null),w=(0,s.useRef)(null),j=(0,s.useRef)(null),[N,C]=(0,s.useState)(null),[A,S]=(0,s.useState)({}),[E,M]=(0,s.useState)(null),[_,R]=(0,s.useState)(!1),[L,T]=(0,s.useState)(""),[z,P]=(0,s.useState)(""),[D,O]=(0,s.useState)(-1),F=(0,s.useRef)(0),U=(0,s.useRef)({}),B=(0,s.useRef)(void 0),H=(0,s.useRef)(void 0),K=(0,s.useCallback)(()=>{B.current&&(clearTimeout(B.current),B.current=void 0)},[]),Z=(0,s.useCallback)(()=>{K(),B.current=setTimeout(()=>{C(null),P("")},300)},[K]);(0,s.useEffect)(()=>()=>{B.current&&clearTimeout(B.current),H.current&&clearTimeout(H.current),er.current&&clearTimeout(er.current)},[]),(0,s.useEffect)(()=>{let e=!1,t=()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.json()).then(t=>{e||k(t)}).catch(()=>{})};t();let r=()=>{"visible"===document.visibilityState&&t()},n=()=>t();return document.addEventListener("visibilitychange",r),window.addEventListener("mindos:settings-changed",n),()=>{e=!0,document.removeEventListener("visibilitychange",r),window.removeEventListener("mindos:settings-changed",n)}},[]);let W=y?.ai?.activeProvider||"",Y=(0,s.useMemo)(()=>y?(y.ai?.providers??[]).map(e=>e.id):[],[y]);(0,s.useEffect)(()=>{y&&e&&(Y.includes(e)||(t(null),a(null),eZ(null,null)))},[y,e,Y,t,a]);let q=e??W,G=(0,eH.lh)(y?.ai?.providers??[],String(q)),J=G?eB.T_[G.protocol]:null,Q=G?.model||J?.defaultModel||"",V=r||Q,X=G?.name||(J?"zh"===i?J.nameZh:J.name:String(q)),[ee,et]=(0,s.useState)({}),er=(0,s.useRef)(void 0),en=(0,s.useCallback)(()=>{if(!p.current)return;let e=p.current.getBoundingClientRect(),t=e.top>window.innerHeight-e.bottom&&e.top>280;et({position:"fixed",left:Math.min(e.left,window.innerWidth-230),...t?{bottom:window.innerHeight-e.top+6}:{top:e.bottom+6},zIndex:50})},[]),es=(0,s.useCallback)(()=>{er.current&&clearTimeout(er.current),er.current=setTimeout(()=>{en()},0)},[en]);(0,s.useEffect)(()=>{u&&en()},[u,en]),(0,s.useEffect)(()=>{if(u)return window.addEventListener("scroll",es,!0),window.addEventListener("resize",es),()=>{window.removeEventListener("scroll",es,!0),window.removeEventListener("resize",es),er.current&&clearTimeout(er.current)}},[u,es]),(0,s.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.target;p.current?.contains(t)||f.current?.contains(t)||x.current?.contains(t)||(c(!1),C(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]),(0,s.useEffect)(()=>{if(!u)return;let e=e=>{"Escape"===e.key&&(N?(C(null),P("")):c(!1))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u,N]);let eo=(0,s.useCallback)(async(e,t=!1)=>{if(!t&&U.current[e]){M(U.current[e]),R(!1);return}t&&delete U.current[e],R(!0),T(""),M(null);let r=++F.current;try{let t=await fetch("/api/settings/list-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e})});if(r!==F.current)return;let n=await t.json();if(r!==F.current)return;n.ok&&Array.isArray(n.models)?(U.current[e]=n.models,M(n.models)):T(n.error||"Failed")}catch{r===F.current&&T("Network error")}finally{r===F.current&&R(!1)}},[]),el=(0,s.useCallback)(e=>{let t=(0,eH.lh)(y?.ai?.providers??[],e);if(!t)return!1;let r=eB.T_[t.protocol];return r?.supportsListModels??!1},[y]),ei=(0,s.useCallback)(()=>{let e=w.current,t=j.current;if(!e||!t)return;let r=e.getBoundingClientRect(),n=t.getBoundingClientRect(),s=r.right+4,a=n.top;window.innerHeight-a<320&&(a=Math.max(8,n.bottom-320)),S({position:"fixed",left:s+220>window.innerWidth-8?r.left-220-4:s,top:a,zIndex:51})},[]),eu=(0,s.useCallback)(e=>{K(),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{if(!el(e)){C(null),P("");return}C(e),P(""),O(-1),T(""),M(U.current[e]??null),U.current[e]||eo(e),requestAnimationFrame(()=>{ei(),setTimeout(()=>b.current?.focus(),50)})},80)},[K,eo,ei,el]),ec=(0,s.useCallback)(()=>{K(),H.current&&(clearTimeout(H.current),H.current=void 0),C(null),P("")},[K]),ed=(0,s.useCallback)(e=>{t(e),a(null),eZ(e,null),c(!1),C(null),P("")},[t,a]),em=(0,s.useCallback)((e,r)=>{t(e),a(r),eZ(e,r),c(!1),C(null),P("")},[t,a]),ep=(0,s.useMemo)(()=>{if(!E)return[];if(!z.trim())return E;let e=z.toLowerCase();return E.filter(t=>t.toLowerCase().includes(e))},[E,z]);(0,s.useEffect)(()=>{O(-1)},[ep]);let ef=(0,s.useCallback)(e=>{ep.length&&("ArrowDown"===e.key?(e.preventDefault(),O(e=>(e+1)%ep.length)):"ArrowUp"===e.key?(e.preventDefault(),O(e=>(e-1+ep.length)%ep.length)):"Enter"===e.key&&D>=0&&D<ep.length&&N?(e.preventDefault(),em(N,ep[D])):"Escape"===e.key&&(e.preventDefault(),C(null),P("")))},[ep,D,N,em]);if((0,s.useEffect)(()=>{if(D<0||!v.current)return;let e=v.current.querySelectorAll("[data-model-item]");e[D]?.scrollIntoView({block:"nearest"})},[D]),!y||0===Y.length)return null;let eg=(V||"").length>20?(V||"").slice(0,18)+"…":V,eh=(X||"").length>12?(X||"").slice(0,10)+"…":J?.shortLabel||X,ex=`${X} \xb7 ${V}`,eb=!!(r&&r!==Q),ev=u?(0,n.jsx)("div",{ref:f,style:ee,children:(0,n.jsx)("div",{ref:w,role:"listbox","aria-label":l.ask?.providerCapsule??"Provider",className:"w-[220px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",style:{maxHeight:"70vh",overflowY:"auto"},children:Y.map(t=>{let s=(0,eH.lh)(y?.ai?.providers??[],t);if(!s)return null;let a=eB.T_[s.protocol],o=s.name||("zh"===i?a?.nameZh:a?.name)||t,u=r&&e===t?r:s.model||a?.defaultModel||"",c=e===t||!e&&W===t,d=N===t,m=el(t);return(0,n.jsx)("div",{ref:d?j:void 0,onMouseEnter:()=>m?eu(t):ec(),onMouseLeave:Z,children:(0,n.jsxs)("div",{className:`flex w-full items-center text-xs transition-colors ${d?"bg-accent/60":"hover:bg-muted/60"}`,children:[(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":c,onClick:()=>ed(t),className:"flex flex-1 items-center gap-2 px-3 py-1.5 min-w-0",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0 truncate",children:[(0,n.jsx)("span",{className:`text-xs ${c?"font-medium text-foreground":"text-foreground/80"}`,children:o}),(0,n.jsx)("span",{className:"text-2xs text-muted-foreground ml-1.5",children:u})]}),c&&(0,n.jsx)(g.A,{size:11,className:"shrink-0 text-[var(--amber)]"})]}),m&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),N===t?ec():eu(t)},className:`shrink-0 px-1.5 py-1.5 mr-1 rounded transition-colors ${d?"text-foreground":"text-muted-foreground/40 hover:text-muted-foreground"}`,title:l.ask?.selectModel??"Select model",children:(0,n.jsx)(ea.A,{size:11})})]})},t)})})}):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{ref:p,type:"button",onClick:()=>{!o&&(c(e=>!e),u&&(C(null),P("")))},disabled:o,className:`
|
|
15
|
+
inline-flex items-center gap-1 rounded-full px-2.5 py-0.5
|
|
16
|
+
text-2xs font-medium transition-colors select-none max-w-[260px]
|
|
17
|
+
border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
18
|
+
disabled:opacity-40 disabled:cursor-not-allowed
|
|
19
|
+
${e||eb?"bg-[var(--amber)]/10 border-[var(--amber)]/25 text-foreground hover:bg-[var(--amber)]/15":"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:text-foreground"}
|
|
20
|
+
`,title:ex,"aria-expanded":u,"aria-haspopup":"listbox",children:[(0,n.jsx)(eU.A,{size:11,className:"shrink-0"}),(0,n.jsxs)("span",{className:"truncate",children:[eh,(0,n.jsx)("span",{className:"text-muted-foreground",children:" \xb7 "}),(0,n.jsx)("span",{className:eb?"text-[var(--amber)]":"text-muted-foreground",children:eg})]}),(0,n.jsx)(h.A,{size:10,className:"shrink-0 text-muted-foreground"})]}),"u">typeof document&&ev&&(0,m.createPortal)(ev,document.body),"u">typeof document&&u&&(()=>{if(!N)return null;let t=(0,eH.lh)(y?.ai?.providers??[],N),s=t?eB.T_[t.protocol]:null,a=t?.name||(s?"zh"===i?s.nameZh:s.name:String(N));return(0,m.createPortal)((0,n.jsxs)("div",{ref:x,style:A,className:"w-[220px] rounded-lg border border-border bg-card shadow-lg py-1 animate-in fade-in-0 zoom-in-95 duration-100",onMouseEnter:K,onMouseLeave:Z,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[(0,n.jsx)("span",{className:"text-2xs font-medium text-muted-foreground",children:a}),(0,n.jsx)("button",{type:"button",onClick:()=>eo(N,!0),disabled:_,className:"p-1 text-muted-foreground/50 hover:text-foreground transition-colors disabled:opacity-30",title:"Refresh",children:(0,n.jsx)(eF.A,{size:10,className:_?"animate-spin":""})})]}),(0,n.jsx)("div",{className:"px-2 pt-1.5 pb-1",children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)($.A,{size:10,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/40"}),(0,n.jsx)("input",{ref:b,type:"text",value:z,onChange:e=>P(e.target.value),onKeyDown:ef,placeholder:l.ask?.searchModels??"Search...",className:"w-full text-2xs pl-6 pr-2 py-1 rounded border border-border/50 bg-transparent text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:border-[var(--amber)]/50",autoComplete:"off"})]})}),(0,n.jsxs)("div",{ref:v,className:"max-h-[240px] overflow-y-auto px-1 pb-1",children:[_&&!E&&(0,n.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-3 text-2xs text-muted-foreground justify-center",children:[(0,n.jsx)(I.A,{size:10,className:"animate-spin"}),l.ask?.loadingModels??"Loading..."]}),L&&!_&&(0,n.jsx)("div",{className:"px-2 py-3 text-2xs text-destructive text-center",children:L}),!_&&!L&&0===ep.length&&null!==E&&(0,n.jsx)("div",{className:"px-2 py-3 text-2xs text-muted-foreground text-center",children:z?"No matches":"No models"}),ep.map((a,o)=>{let l=e===N&&r===a,i=t?.model||s?.defaultModel;return(0,n.jsxs)("button",{type:"button","data-model-item":!0,onClick:()=>em(N,a),className:`w-full text-left px-2 py-1 text-2xs rounded transition-colors flex items-center gap-1 ${l?"bg-[var(--amber)]/12 text-foreground font-medium":o===D?"bg-accent":"hover:bg-accent/60"}`,children:[l?(0,n.jsx)(g.A,{size:9,className:"shrink-0 text-[var(--amber)]"}):(0,n.jsx)("span",{className:"w-[9px] shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:a}),a===i&&!l&&(0,n.jsx)("span",{className:"ml-auto text-[9px] text-muted-foreground/30 shrink-0",children:"default"})]},a)})]})]}),document.body)})()]})}var eY=r(68589);let eq=new Set([401,403,429]),eG=[/api.?key/i,/model.*not.?found/i,/authentication/i,/unauthorized/i,/forbidden/i];var eJ=r(91337),eQ=r(2431);let eV=new WeakMap;function eX({visible:e,currentFile:t,initialMessage:r,initialAcpAgent:m,onFirstMessage:p,variant:f,onClose:g,maximized:h,onMaximize:b,askMode:k,onModeSwitch:L,onDockToPanel:T}){let z="panel"===f,I="home"===f,P=(0,s.useRef)(null),D=(0,s.useRef)(null),{t:$}=(0,d.Y)(),[O,F]=(0,s.useState)(!1);(0,s.useEffect)(()=>F(!0),[]);let[U,B]=(0,s.useState)(""),H=(0,s.useRef)("");H.current=U;let[K,Z]=(0,s.useState)([]),W=(0,s.useRef)(K);W.current=K;let[Y,q]=(0,s.useState)(!1),[G,J]=(0,s.useState)(!1),[Q,V]=(0,s.useState)(!1),[X,ee]=(0,s.useState)(null),et=(0,s.useRef)(X);et.current=X;let[er,en]=(0,s.useState)(null),es=(0,s.useRef)(er);es.current=er;let[ea,eo]=(0,s.useState)("agent"),[el,ei]=(0,s.useState)(null),[eu,ec]=(0,s.useState)(null);(0,s.useEffect)(()=>{eo(function(){try{let e=localStorage.getItem(x);if("chat"===e||"agent"===e)return e}catch{}return"agent"}());let e=function(){try{let e=localStorage.getItem(eK);if(!e){let e=localStorage.getItem("mindos-provider-override");if(e&&((0,eB.rl)(e)||(0,eH.Ny)(e)))return{provider:e,model:null};return{provider:null,model:null}}let t=JSON.parse(e),r=t?.provider&&((0,eB.rl)(t.provider)||(0,eH.Ny)(t.provider))?t.provider:null,n="string"==typeof t?.model?t.model:null;return{provider:r,model:n}}catch{return{provider:null,model:null}}}();ei(e.provider),ec(e.model)},[]);let ed=function(e){let[t,r]=(0,s.useState)([]),[n,a]=(0,s.useState)([]),[o,l]=(0,s.useState)(null),i=(0,s.useRef)(null),u=(0,s.useCallback)(async()=>{let t=(await w()).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,30),n=t.filter(e=>0===e.messages.length).map(e=>e.id),s=n.length>0?t.filter(e=>!n.includes(e.id)):t;n.length>0&&C(n);let o=y(e),i=e?s.find(t=>t.currentFile===e):s[0];i?(l(i.id),r(i.messages),a([...s])):(l(o.id),r([]),a([o,...s].slice(0,30)))},[e]),c=(0,s.useCallback)((t,r)=>{if(!r||0===t.length)return;let n=null;a(s=>{let a=Date.now(),o=s.find(e=>e.id===r);n=o?{...o,currentFile:e,updatedAt:a,messages:t}:{id:r,currentFile:e,createdAt:a,updatedAt:a,messages:t};let l=s.filter(e=>e.id!==r);return[n,...l].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,30)}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{n&&j(n)},600)},[e]),d=(0,s.useCallback)(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),m=(0,s.useCallback)(()=>{a(t=>{let n=t.find(e=>e.id===o);if(n&&0===n.messages.length)return t;let s=y(e);return l(s.id),r([]),[s,...t].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,30)})},[e,o]),p=(0,s.useCallback)(e=>{let t=n.find(t=>t.id===e);if(!t)return;let s=o?n.find(e=>e.id===o):null;s&&0===s.messages.length&&s.id!==e&&a(e=>e.filter(e=>e.id!==s.id)),l(t.id),r(t.messages)},[n,o]),f=(0,s.useCallback)(t=>{let s=n.find(e=>e.id===t);s&&s.messages.length>0&&N(t);let i=n.filter(e=>e.id!==t);if(a(i),o===t){let t=y(e);l(t.id),r([]),a([t,...i].slice(0,30))}},[o,e,n]),g=(0,s.useCallback)((e,t)=>{let r=t.trim();a(t=>{let n=t.findIndex(t=>t.id===e);if(n<0)return t;let s={...t[n],title:r||void 0},a=[...t];return a[n]=s,j(s),a})},[]),h=(0,s.useCallback)(e=>{a(t=>{let r=t.findIndex(t=>t.id===e);if(r<0)return t;let n={...t[r],pinned:!t[r].pinned},s=[...t];return s[r]=n,n.messages.length>0&&j(n),s})},[]),x=(0,s.useCallback)(()=>{let t=n.filter(e=>e.messages.length>0).map(e=>e.id);t.length>0&&C(t);let s=y(e);l(s.id),r([]),a([s])},[e,n]);return{messages:t,setMessages:r,sessions:[...n].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:t.updatedAt-e.updatedAt),activeSessionId:o,initSessions:u,persistSession:c,clearPersistTimer:d,resetSession:m,loadSession:p,deleteSession:f,renameSession:g,togglePinSession:h,clearAllSessions:x}}(t),em=(0,s.useRef)(ed);em.current=ed;let ep=function(){let[e,t]=(0,s.useState)([]),[r,n]=(0,s.useState)(""),a=(0,s.useRef)(null),o=(0,s.useCallback)(async e=>{if(!e||0===e.length)return;let r=Array.from(e).slice(0,8),s=[],a=[];for(let e of r){let t=S(e.name);A.has(t)?s.push(e):a.push(e.name)}a.length>0?n(`Unsupported file type: ${a.join(", ")}`):n("");let o=[],l=[];for(let e of s)".pdf"===S(e.name)?(l.push({name:e.name,content:"",status:"loading"}),o.push(e)):l.push({name:e.name,content:await e.text(),status:"success"});if(t(e=>{let t=[...e];for(let e of l)t.some(t=>t.name===e.name)||t.push(e);return t}),o.length>0){let e=await Promise.all(o.map(E));t(t=>t.map(t=>"loading"!==t.status?t:e.find(e=>e.name===t.name)??t))}},[]),l=(0,s.useCallback)(e=>{t(t=>t.filter((t,r)=>r!==e))},[]);return{localAttachments:e,uploadError:r,uploadInputRef:a,pickFiles:o,removeAttachment:l,clearAttachments:(0,s.useCallback)(()=>{t([]),n("")},[]),injectFiles:(0,s.useCallback)(e=>{t(t=>{let r=[...t];for(let t of e)r.some(e=>e.name===t.name)||r.push(t);return r})},[])}}(),ef=(0,s.useRef)(ep);ef.current=ep;let eg=function(){let[e,t]=(0,s.useState)([]),[r,n]=(0,s.useState)(""),a=(0,s.useCallback)(async e=>{n("");let r=e.slice(0,4),s=[];for(let e of r){var a;if(a=e.type,!M.has(a)){n(`Unsupported image type: ${e.type}`);continue}try{let{data:t,mimeType:r}=await _(e);s.push({type:"image",data:t,mimeType:r,fileName:e.name||void 0})}catch{n(`Failed to process image: ${e.name}`)}}t(e=>{let t=[...e,...s];return t.length>4?(n("Maximum 4 images allowed"),t.slice(0,4)):t})},[]),o=(0,s.useCallback)(async e=>{let t=e.clipboardData?.items;if(!t)return!1;let r=R(t);return 0!==r.length&&(await a(r),!0)},[a]),l=(0,s.useCallback)(async e=>{let t=e.dataTransfer?.items;if(!t)return;let r=R(t);r.length>0&&(e.preventDefault(),await a(r))},[a]),i=(0,s.useCallback)(async e=>{if(!e)return;let t=Array.from(e).filter(e=>{var t;return t=e.type,M.has(t)});await a(t)},[a]);return{images:e,imageError:r,addImages:a,handlePaste:o,handleDrop:l,handleFileSelect:i,removeImage:(0,s.useCallback)(e=>{t(t=>t.filter((t,r)=>r!==e))},[]),clearImages:(0,s.useCallback)(()=>{t([]),n("")},[])}}(),eh=function(){let[e,t]=(0,s.useState)([]),[r,n]=(0,s.useState)(null),[a,o]=(0,s.useState)([]),[l,i]=(0,s.useState)(0),u=(0,s.useCallback)(()=>{fetch("/api/files").then(e=>e.ok?e.json():[]).then(e=>Array.isArray(e)?e:[]).catch(()=>[]).then(t)},[]);(0,s.useEffect)(()=>{u();let e=()=>u();return window.addEventListener("mindos:files-changed",e),()=>window.removeEventListener("mindos:files-changed",e)},[u]);let c=(0,s.useCallback)((t,r)=>{let s=r??t.length,a=t.slice(0,s),l=a.lastIndexOf("@");if(-1===l||l>0&&" "!==a[l-1]&&"\n"!==a[l-1])return void n(null);let u=a.slice(l+1);if(u.includes(" ")||u.includes("\n")){n(null),o([]),i(0);return}let c=u.toLowerCase();if(!c){n(u),o(e.slice(0,30)),i(0);return}let d=e.map(e=>{let t=(e.split("/").pop()??e).toLowerCase(),r=e.toLowerCase(),n=0;return t.startsWith(c)?n=100:t.includes(c)?n=50:r.includes(c)&&(n=10),{path:e,score:n}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,30);if(0===d.length){n(null),o([]),i(0);return}n(u),o(d.map(e=>e.path)),i(0)},[e]),d=(0,s.useCallback)(e=>{0!==a.length&&("down"===e?i(e=>Math.min(e+1,a.length-1)):i(e=>Math.max(e-1,0)))},[a.length]);return{mentionQuery:r,mentionResults:a,mentionIndex:l,updateMentionFromInput:c,navigateMention:d,resetMention:(0,s.useCallback)(()=>{n(null),o([]),i(0)},[])}}(),ex=function(){let[e,t]=(0,s.useState)([]),[r,n]=(0,s.useState)(null),[a,o]=(0,s.useState)([]),[l,i]=(0,s.useState)(0),u=(0,s.useRef)(!1),c=(0,s.useCallback)(async()=>{t((await fetch("/api/skills").then(e=>e.ok?e.json():{skills:[]}).then(e=>Array.isArray(e?.skills)?e.skills:[]).catch(()=>[])).filter(e=>e.enabled)),u.current=!0},[]);(0,s.useEffect)(()=>{c();let e=()=>c();return window.addEventListener("mindos:skills-changed",e),()=>window.removeEventListener("mindos:skills-changed",e)},[c]);let d=(0,s.useCallback)((t,r)=>{let s=t.slice(0,r),a=s.lastIndexOf("/");if(-1===a||a>0&&" "!==s[a-1]&&"\n"!==s[a-1])return void n(null);let l=s.slice(a+1);if(l.includes(" "))return void n(null);if(!u.current){c(),n(null);return}let d=l.toLowerCase(),m=d?e.map(e=>{let t=e.name.toLowerCase(),r=0;return t.startsWith(d)?r=100:t.includes(d)?r=50:e.description.toLowerCase().includes(d)&&(r=10),{s:e,score:r}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,20).map(e=>({type:"skill",name:e.s.name,description:e.s.description})):e.slice(0,20).map(e=>({type:"skill",name:e.name,description:e.description}));if(0===m.length){n(null),o([]),i(0);return}n(l),o(m),i(0)},[e,c]),m=(0,s.useCallback)(e=>{0!==a.length&&("down"===e?i(e=>Math.min(e+1,a.length-1)):i(e=>Math.max(e-1,0)))},[a.length]);return{slashQuery:r,slashResults:a,slashIndex:l,updateSlashFromInput:d,navigateSlash:m,resetSlash:(0,s.useCallback)(()=>{n(null),o([]),i(0)},[])}}(),eb=(0,eQ.z)(),ev=(0,s.useRef)(eg);ev.current=eg;let ey=(0,s.useRef)(eh);ey.current=eh;let ek=(0,s.useRef)(ex);ek.current=ex;let ej=(0,s.useCallback)(()=>{B(""),ee(null),en(null),Z(t?[t]:[]),ep.clearAttachments()},[t,ep]),eA=(0,s.useCallback)(e=>{B(e.content),e.images&&e.images.length>0&&eg.clearImages(),e.attachedFiles&&Z(e.attachedFiles),e.skillName&&ex.resetSlash(),setTimeout(()=>P.current?.focus(),50)},[eg,ex]),eE=(0,s.useRef)({inputValueRef:H,mentionRef:ey,slashRef:ek,imageUploadRef:ev,sessionRef:em,uploadRef:ef,selectedSkillRef:et,selectedAcpAgentRef:es,attachedFilesRef:W}),eM=function({currentFile:e,chatMode:t,providerOverride:r,modelOverride:n,onFirstMessage:a,refs:o,errorLabels:l,resetInputState:i,onRestoreInput:u}){let[c,d]=(0,s.useState)(!1),[m,p]=(0,s.useState)("connecting"),[f,g]=(0,s.useState)(0),h=(0,s.useRef)(3),x=(0,s.useRef)(null),b=(0,s.useRef)(!1),v=(0,s.useRef)(!1),y=(0,s.useRef)(null),k=(0,s.useRef)(!1),w=(0,s.useCallback)(()=>{let e=y.current;x.current?.abort(),e&&(k.current=!0,o.sessionRef.current?.setMessages(t=>{let r=[...t],n=e.userMessageIndex;return n+1<r.length&&r[n+1]?.role==="assistant"&&r.splice(n+1,1),n<r.length&&r[n]?.role==="user"&&r.splice(n,1),r}),u?.(e.userMessage),y.current=null,v.current=!0,setTimeout(()=>{v.current=!1},300))},[o,u]),j=(0,s.useCallback)(async s=>{if(s.preventDefault(),v.current)return;let u=o.mentionRef.current,c=o.slashRef.current,m=o.imageUploadRef.current,f=o.sessionRef.current,w=o.uploadRef.current;if(!u||!c||!m||!f||!w||null!==u.mentionQuery||null!==c.slashQuery)return;let j=o.inputValueRef.current?.trim()??"";if(!j&&0===m.images.length||N.current)return;let C=o.selectedSkillRef.current,A=o.selectedAcpAgentRef.current,S=m.images.length>0?[...m.images]:void 0,E=o.attachedFilesRef.current.filter(t=>t!==e),M=E.length>0?E:void 0,_=w.localAttachments.filter(e=>"loading"!==e.status).map(e=>e.name),R={role:"user",content:j,timestamp:Date.now(),...C&&{skillName:C.name},...S&&{images:S},...M&&{attachedFiles:M},..._.length>0&&{uploadedFileNames:_}};m.clearImages();let L=[...f.messages,R];y.current={userMessageIndex:L.length-1,userMessage:R},k.current=!1,f.setMessages([...L,{role:"assistant",content:"",timestamp:Date.now()}]),i(),a&&!b.current&&(b.current=!0,a()),d(!0),p("connecting"),g(0);let T=new AbortController;x.current=T;let z=3;try{let e=localStorage.getItem("mindos-reconnect-retries");if(null!==e){let t=parseInt(e,10);Number.isFinite(t)&&(z=Math.max(0,Math.min(10,t)))}}catch{}h.current=z;let I=JSON.stringify({messages:L,currentFile:e,attachedFiles:o.attachedFilesRef.current,uploadedFiles:w.localAttachments.filter(e=>"loading"!==e.status).map(e=>({name:e.name,content:e.content.length>8e4?e.content.slice(0,8e4)+"\n\n[...truncated to first ~80000 chars]":e.content})),selectedAcpAgent:A,mode:t,providerOverride:r??void 0,modelOverride:n??void 0}),P=async()=>{let e=await fetch("/api/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:I,signal:T.signal});if(!e.ok){let t=`Request failed (${e.status})`;try{let r=await e.json();"string"==typeof r?.error&&r.error.trim()?t=r.error:"object"==typeof r?.error&&"string"==typeof r.error?.message&&r.error.message.trim()?t=r.error.message:"string"==typeof r?.message&&r.message.trim()&&(t=r.message)}catch(e){console.warn("[useAskChat] error body parse failed:",e)}let r=Error(t);throw r.httpStatus=e.status,r}if(!e.body)throw Error("No response body");return p("thinking"),{finalMessage:await (0,eY.m)(e.body,e=>{p("streaming"),o.sessionRef.current?.setMessages(t=>{let r=[...t];return r[r.length-1]=e,r})},T.signal)}};try{let e=null;for(let t=0;t<=z&&!T.signal.aborted;t++){if(t>0){var D;g(t),p("reconnecting"),o.sessionRef.current?.setMessages(e=>{let t=[...e];return t[t.length-1]={role:"assistant",content:"",timestamp:Date.now()},t}),await function(e,t){return new Promise((r,n)=>{let s=()=>t?.reason??new DOMException("The operation was aborted.","AbortError");if(t?.aborted)return void n(s());let a=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(a),n(s())},{once:!0})})}((D=t-1,Math.min(1e3*2**D,1e4)),T.signal),p("connecting")}try{let{finalMessage:e}=await P();e.content.trim()||e.parts&&0!==e.parts.length||o.sessionRef.current?.setMessages(e=>{let t=[...e];return t[t.length-1]={role:"assistant",content:`__error__${l.noResponse}`},t}),y.current=null;return}catch(n){e=n instanceof Error?n:Error(String(n));let r=n.httpStatus;if(!function(e,t){if(e instanceof DOMException&&"AbortError"===e.name||t&&eq.has(t))return!1;if(e instanceof Error){let t=e.message;if(eG.some(e=>e.test(t)))return!1}return!0}(n,r)||t>=z)break}}if(e)throw e}catch(e){if("AbortError"===e.name)k.current||o.sessionRef.current?.setMessages(e=>{let t=[...e],r=t.length-1;if(r>=0&&"assistant"===t[r].role){let e=t[r];e.content.trim()||e.parts&&e.parts.length>0||(t[r]={role:"assistant",content:`__error__${l.stopped}`})}return t});else{let t=e instanceof Error?e.message:"Something went wrong";o.sessionRef.current?.setMessages(e=>{let r=[...e],n=r.length-1;if(n>=0&&"assistant"===r[n].role){let e=r[n];if(!(e.content.trim()||e.parts&&e.parts.length>0))return r[n]={role:"assistant",content:`__error__${t}`},r}return[...r,{role:"assistant",content:`__error__${t}`}]})}}finally{d(!1),g(0),x.current=null,y.current=null}},[e,t,r,l.noResponse,l.stopped,a,o,i]),N=(0,s.useRef)(c);return N.current=c,{isLoading:c,isLoadingRef:N,loadingPhase:m,reconnectAttempt:f,reconnectMaxRef:h,abortRef:x,firstMessageFired:b,submit:j,stop:w}}({currentFile:t,chatMode:ea,providerOverride:el,modelOverride:eu,onFirstMessage:p,refs:eE.current,errorLabels:{noResponse:$.ask.errorNoResponse,stopped:$.ask.stopped},resetInputState:ej,onRestoreInput:eA}),{isLoading:e_,loadingPhase:eR,reconnectAttempt:eL,reconnectMaxRef:ez}=eM,eI=eM.submit,eP=eM.stop;(0,s.useEffect)(()=>{let e=e=>{let t=e.detail?.files;Array.isArray(t)&&t.length>0&&ef.current.injectFiles(t)};return window.addEventListener("mindos:inject-ask-files",e),()=>window.removeEventListener("mindos:inject-ask-files",e)},[]),(0,s.useEffect)(()=>{if(!I)return;let e=e=>{let t=e.detail?.text;"string"==typeof t&&(B(t),setTimeout(()=>P.current?.focus(),50))};return window.addEventListener("mindos:home-suggestion",e),()=>window.removeEventListener("mindos:home-suggestion",e)},[I]);let eD=(0,s.useRef)(!1),eF=(0,s.useRef)(t);(0,s.useEffect)(()=>{let n="panel"===f||"home"===f?e&&!eD.current:e,s=e&&eD.current&&t!==eF.current;n?(setTimeout(()=>P.current?.focus(),50),ed.initSessions(),B(r||""),eM.firstMessageFired.current=!1,Z(t?[t]:[]),ep.clearAttachments(),eg.clearImages(),eh.resetMention(),ex.resetSlash(),ee(null),en(m??null),q(!1)):s?Z(t?[t]:[]):e||"modal"!==f||eM.abortRef.current?.abort(),"home"===f&&e&&!eD.current&&setTimeout(()=>P.current?.focus(),150),eD.current=e,eF.current=t},[e,t]),(0,s.useEffect)(()=>{if(!e||!ed.activeSessionId)return;let t=ed.messages;if(eM.isLoading&&t.length>0){let e=t[t.length-1];if("assistant"===e.role&&!e.content.trim()&&(!e.parts||0===e.parts.length))return}return ed.persistSession(t,ed.activeSessionId),()=>ed.clearPersistTimer()},[e,ed.messages,ed.activeSessionId,eM.isLoading]),(0,s.useEffect)(()=>{if(!e||"home"===f)return;let t="modal"===f,r="panel"===f&&h;if(!t&&!r)return;let n=e=>{if("Escape"===e.key){if(null!==ey.current.mentionQuery)return void ey.current.resetMention();if(null!==ek.current.slashQuery)return void ek.current.resetSlash();if(r&&b)return void b();t&&g&&g()}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[f,e,g,h,b]),(0,s.useEffect)(()=>{if(!Q)return;let e=()=>V(!1),t=setTimeout(()=>document.addEventListener("click",e),0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[Q]);let eU=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{if(!e)return;let t=P.current;t&&t instanceof HTMLTextAreaElement&&function(e,t){let r=eV.get(e);if(!r){let t=getComputedStyle(e),n=parseFloat(t.lineHeight),s=parseFloat(t.fontSize),a=Number.isFinite(s)?s:14,o=8*(Number.isFinite(n)?n:1.375*a)+((Number.isFinite(parseFloat(t.paddingTop))?parseFloat(t.paddingTop):0)+(Number.isFinite(parseFloat(t.paddingBottom))?parseFloat(t.paddingBottom):0));if(!Number.isFinite(o)||o<=0)return;r={maxH:o},eV.set(e,r)}let{maxH:n}=r;e.style.height="auto";let s=e.scrollHeight,a=Math.min(s,n);e.style.height=`${a}px`,e.style.overflowY=s>n?"auto":"hidden"}(t,0)},[U,e_,e]),(0,s.useEffect)(()=>{let e=P.current;if(!e)return;let t=()=>eV.delete(e);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);let eZ=(0,s.useRef)(null),eX=(0,s.useRef)(null),e0=(0,s.useCallback)((e,t)=>{B(e);let r=t??e.length;eZ.current&&clearTimeout(eZ.current),eX.current&&clearTimeout(eX.current),eZ.current=setTimeout(()=>ey.current.updateMentionFromInput(e,r),80),eX.current=setTimeout(()=>ek.current.updateSlashFromInput(e,r),80)},[]);(0,s.useEffect)(()=>()=>{eZ.current&&clearTimeout(eZ.current),eX.current&&clearTimeout(eX.current)},[]);let e1=(0,s.useCallback)(e=>{let t=P.current,r=H.current,n=t?.selectionStart??r.length,s=r.slice(0,n).lastIndexOf("@");B(r.slice(0,s)+r.slice(n)),ey.current.resetMention(),W.current.includes(e)||Z(t=>[...t,e]),setTimeout(()=>{P.current?.focus(),P.current?.setSelectionRange(s,s)},0)},[]),e2=(0,s.useCallback)(e=>{let t=P.current,r=H.current,n=t?.selectionStart??r.length,s=r.slice(0,n).lastIndexOf("/");B(r.slice(0,s)+r.slice(n)),ee(e),ek.current.resetSlash(),setTimeout(()=>{P.current?.focus(),P.current?.setSelectionRange(s,s)},0)},[]),e5=(0,s.useRef)(e1);e5.current=e1;let e3=(0,s.useRef)(e2);e3.current=e2;let e4=(0,s.useCallback)(e=>{let t=ey.current,r=ek.current;if(null!==t.mentionQuery){if("Escape"===e.key){e.preventDefault(),t.resetMention();return}if("ArrowDown"===e.key)e.preventDefault(),t.navigateMention("down");else if("ArrowUp"===e.key)e.preventDefault(),t.navigateMention("up");else if("Enter"===e.key||"Tab"===e.key){if("Enter"===e.key&&(e.shiftKey||e.nativeEvent.isComposing))return;t.mentionResults.length>0&&(e.preventDefault(),e5.current(t.mentionResults[t.mentionIndex]))}return}if(null!==r.slashQuery){if("Escape"===e.key){e.preventDefault(),r.resetSlash();return}if("ArrowDown"===e.key)e.preventDefault(),r.navigateSlash("down");else if("ArrowUp"===e.key)e.preventDefault(),r.navigateSlash("up");else if("Enter"===e.key||"Tab"===e.key){if("Enter"===e.key&&(e.shiftKey||e.nativeEvent.isComposing))return;r.slashResults.length>0&&(e.preventDefault(),e3.current(r.slashResults[r.slashIndex]))}return}"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&!eM.isLoadingRef.current&&(H.current.trim()||ev.current.images.length>0)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},[]),e8=(0,s.useCallback)(()=>{eM.isLoadingRef.current||(em.current.resetSession(),B(""),Z(t?[t]:[]),ef.current.clearAttachments(),ev.current.clearImages(),ey.current.resetMention(),ek.current.resetSlash(),ee(null),en(null),q(!1),eM.firstMessageFired.current=!1,setTimeout(()=>P.current?.focus(),0))},[t]),e6=(0,s.useCallback)(e=>{(e.dataTransfer.types.includes("text/mindos-path")||e.dataTransfer.types.includes("Files"))&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",J(!0))},[]),e9=(0,s.useCallback)(()=>J(!1),[]),e7=(0,s.useCallback)(async e=>{e.preventDefault(),e.stopPropagation(),J(!1);let t=e.dataTransfer.getData("text/mindos-path");if(t){let r="directory"===e.dataTransfer.getData("text/mindos-type")?t.replace(/\/?$/,"/"):t;W.current.includes(r)||Z(e=>[...e,r]);return}let r=e.dataTransfer.files;if(r.length>0){Array.from(r).some(e=>e.type.startsWith("image/"))&&await ev.current.handleDrop(e);let t=Array.from(r).filter(e=>!e.type.startsWith("image/"));if(t.length>0){let e=new DataTransfer;t.forEach(t=>e.items.add(t)),await ef.current.pickFiles(e.files)}}},[]),te=(0,s.useCallback)(e=>{let t=e.clipboardData?.items;!t||Array.from(t).some(e=>"file"===e.kind&&e.type.startsWith("image/"))&&(e.preventDefault(),ev.current.handlePaste(e))},[]),tt=(0,s.useCallback)(e=>{em.current.loadSession(e),q(!1),B(""),Z(t?[t]:[]),ef.current.clearAttachments(),ev.current.clearImages(),ey.current.resetMention(),ek.current.resetSlash(),ee(null),en(null),setTimeout(()=>P.current?.focus(),0)},[t]),tr=(0,s.useCallback)(()=>q(e=>!e),[]),tn=(0,s.useMemo)(()=>({connecting:$.ask.connecting,thinking:$.ask.thinking,generating:$.ask.generating,reconnecting:eL>0?$.ask.reconnecting(eL,ez.current):void 0,copyMessage:$.ask.copyMessage}),[$,eL]);return(0,n.jsxs)("div",{className:"flex min-h-0 w-full flex-col h-full",children:[(0,n.jsx)(eT,{isPanel:z||I,showHistory:Y,onToggleHistory:tr,onReset:e8,isLoading:e_,maximized:h,onMaximize:b,askMode:I?void 0:k,onModeSwitch:I?void 0:L,onClose:I?void 0:g,onDockToPanel:h?T:void 0,sessions:ed.sessions,activeSessionId:ed.activeSessionId,onLoadSession:tt,onDeleteSession:ed.deleteSession,onRenameSession:ed.renameSession,onTogglePinSession:ed.togglePinSession}),Y&&(0,n.jsx)(eS,{sessions:ed.sessions,activeSessionId:ed.activeSessionId,onLoad:tt,onDelete:ed.deleteSession,onRename:ed.renameSession,onTogglePin:ed.togglePinSession,onClearAll:ed.clearAllSessions,labels:{title:$.ask.sessionHistory??"Session History",clearAll:$.ask.clearAll??"Clear all",confirmClear:$.ask.confirmClear??"Confirm clear?",noSessions:$.ask.noSessions??"No saved sessions.",rename:$.ask.renameSession??"Rename"}}),(0,n.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[!I&&(0,n.jsx)(ew,{messages:ed.messages,isLoading:e_,loadingPhase:eR,emptyPrompt:$.ask.emptyPrompt,emptyHint:$.ask.emptyHint,suggestions:$.ask.suggestions,onSuggestionClick:B,labels:tn}),I&&ed.messages.length>0&&(0,n.jsx)(ew,{messages:ed.messages,isLoading:e_,loadingPhase:eR,emptyPrompt:$.ask.emptyPrompt,emptyHint:$.ask.emptyHint,suggestions:[],onSuggestionClick:B,labels:tn})]}),null!==eh.mentionQuery&&eh.mentionResults.length>0&&(0,n.jsx)("div",{className:"shrink-0 px-3 pb-1",children:(0,n.jsx)(eN,{results:eh.mentionResults,selectedIndex:eh.mentionIndex,query:eh.mentionQuery??void 0,onSelect:e1})}),null!==ex.slashQuery&&ex.slashResults.length>0&&(0,n.jsx)("div",{className:"shrink-0 px-3 pb-1",children:(0,n.jsx)(eC,{results:ex.slashResults,selectedIndex:ex.slashIndex,query:ex.slashQuery??void 0,onSelect:e2})}),(0,n.jsx)("div",{className:(0,eJ.cn)("shrink-0",I?"px-2 pb-2 pt-0.5":"px-3 pb-2.5 pt-1"),children:(0,n.jsxs)("div",{className:(0,eJ.cn)("rounded-xl bg-muted/40 transition-all focus-within:bg-muted/60",G&&"ring-2 ring-[var(--amber)] bg-[var(--amber-dim)]"),onDragOver:e6,onDragLeave:e9,onDrop:e7,children:[(K.length>0||ep.localAttachments.length>0||eg.images.length>0||X||er||ep.uploadError||eg.imageError)&&(0,n.jsxs)("div",{className:(0,eJ.cn)("px-3 pt-2.5 pb-1",z?"max-h-24 overflow-y-auto":"max-h-28 overflow-y-auto"),children:[(0,n.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[K.map(e=>(0,n.jsx)(e$,{path:e,variant:"kb",onRemove:()=>Z(t=>t.filter(t=>t!==e))},e)),ep.localAttachments.map((e,t)=>(0,n.jsx)(e$,{path:e.name,variant:"upload",status:e.status,error:e.error,truncatedInfo:e.truncatedInfo,onRemove:()=>ep.removeAttachment(t)},`up-${e.name}-${t}`)),eg.images.map((e,t)=>(0,n.jsx)(e$,{path:e.fileName||`Image ${t+1}`,variant:"image",imageData:e.data,imageMime:e.mimeType,onRemove:()=>eg.removeImage(t)},`img-${t}`)),X&&(0,n.jsx)(e$,{path:X.name,variant:"skill",onRemove:()=>{ee(null),P.current?.focus()}})]}),(ep.uploadError||eg.imageError)&&(0,n.jsx)("div",{className:"mt-1 text-xs text-error",children:ep.uploadError||eg.imageError})]}),(0,n.jsxs)("form",{ref:eU,onSubmit:eI,className:(0,eJ.cn)("flex items-end gap-1.5",I?"px-2 py-1.5":"px-3 py-2"),children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:()=>V(e=>!e),className:"p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors",title:$.hints.attachFile,children:(0,n.jsx)(a.A,{size:15})}),Q&&(0,n.jsxs)("div",{className:"absolute bottom-full left-0 mb-1.5 py-1 rounded-xl border border-border/60 bg-card shadow-lg z-50 min-w-[150px] animate-in fade-in-0 slide-in-from-bottom-2 duration-150",children:[(0,n.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-xs hover:bg-muted transition-colors text-left rounded-lg",onClick:()=>{V(!1),ep.uploadInputRef.current?.click()},children:[(0,n.jsx)(o.A,{size:12,className:"shrink-0 text-muted-foreground"}),$.ask.attachFileLabel]}),(0,n.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-xs hover:bg-muted transition-colors text-left rounded-lg",onClick:()=>{V(!1),D.current?.click()},children:[(0,n.jsx)(l.A,{size:12,className:"shrink-0 text-muted-foreground"}),$.ask.attachImageLabel]})]})]}),(0,n.jsx)("input",{ref:ep.uploadInputRef,type:"file",className:"hidden",multiple:!0,accept:".txt,.md,.markdown,.csv,.json,.yaml,.yml,.xml,.html,.htm,.pdf,text/plain,text/markdown,text/csv,application/json,application/pdf",onChange:async e=>{let t=e.currentTarget;await ep.pickFiles(t.files),t.value=""}}),(0,n.jsx)("input",{ref:D,type:"file",className:"hidden",multiple:!0,accept:"image/png,image/jpeg,image/gif,image/webp",onChange:async e=>{let t=e.currentTarget;await eg.handleFileSelect(t.files),t.value=""}}),(0,n.jsx)("textarea",{ref:e=>{P.current=e},value:U,onChange:e=>e0(e.target.value,e.target.selectionStart??void 0),onKeyDown:e4,onPaste:te,placeholder:$.ask.placeholder,rows:1,className:(0,eJ.cn)("min-w-0 flex-1 resize-none overflow-y-hidden bg-transparent py-2 leading-relaxed text-foreground placeholder:text-muted-foreground/50 outline-none focus-visible:ring-0",I?"text-xs":"text-sm")}),e_?(0,n.jsx)("button",{type:"button",onClick:eP,className:"p-2 rounded-xl transition-colors shrink-0 text-foreground bg-muted hover:bg-muted/80",title:"reconnecting"===eR?$.ask.cancelReconnect:$.ask.stopTitle,children:"reconnecting"===eR?(0,n.jsx)(i.A,{size:15}):(0,n.jsx)(u.A,{size:15})}):(0,n.jsx)("button",{type:"submit",disabled:!U.trim()&&0===eg.images.length,className:"p-2 rounded-xl disabled:opacity-20 disabled:scale-95 disabled:cursor-not-allowed transition-all duration-150 shrink-0 bg-[var(--amber)] text-[var(--amber-foreground)] shadow-sm shadow-[var(--amber)]/15 hover:shadow-md hover:shadow-[var(--amber)]/20 active:scale-95",children:(0,n.jsx)(c.A,{size:14})})]}),(0,n.jsxs)("div",{className:(0,eJ.cn)("flex items-center justify-between border-t border-border/10",z?"px-2 pb-1.5 pt-1 gap-1":"px-3 pb-2 pt-1.5"),children:[(0,n.jsxs)("div",{className:(0,eJ.cn)("flex items-center flex-wrap",z?"gap-1":"gap-2"),children:[(0,n.jsx)(v,{mode:ea,onChange:eo,disabled:e_}),O&&eb.installedAgents.length>0&&(0,n.jsx)(eO,{selectedAgent:er,onSelect:en,installedAgents:eb.installedAgents,loading:eb.loading}),O&&(0,n.jsx)(eW,{providerValue:el,onProviderChange:e=>{ei(e),ec(null)},modelValue:eu,onModelChange:ec,disabled:e_})]}),!z&&!I&&(0,n.jsxs)("span",{className:"hidden md:inline text-2xs text-muted-foreground/40 select-none shrink-0",children:[(0,n.jsx)("kbd",{className:"font-mono",children:"Enter"})," ",$.ask.send," \xb7 ",(0,n.jsx)("kbd",{className:"font-mono",children:"Shift+Enter"})," ",$.ask.newlineHint]})]})]})})]})}},59960:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});var n=r(95155);function s({id:e,className:t="w-8 h-4"}){return(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 40",fill:"none",className:`${t} text-[var(--amber)]`,"aria-hidden":"true",children:[(0,n.jsxs)("defs",{children:[(0,n.jsxs)("linearGradient",{id:`grad-human-${e}`,x1:"35",y1:"20",x2:"5",y2:"20",gradientUnits:"userSpaceOnUse",children:[(0,n.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.8"}),(0,n.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0.3"})]}),(0,n.jsxs)("linearGradient",{id:`grad-agent-${e}`,x1:"35",y1:"20",x2:"75",y2:"20",gradientUnits:"userSpaceOnUse",children:[(0,n.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.8"}),(0,n.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"1"})]})]}),(0,n.jsx)("path",{d:"M35,20 C25,35 8,35 8,20 C8,5 25,5 35,20",stroke:`url(#grad-human-${e})`,strokeWidth:"3",strokeDasharray:"2 4",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M35,20 C45,2 75,2 75,20 C75,38 45,38 35,20",stroke:`url(#grad-agent-${e})`,strokeWidth:"4.5",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M35,17.5 Q35,20 37.5,20 Q35,20 35,22.5 Q35,20 32.5,20 Q35,20 35,17.5 Z",fill:"#FEF3C7"})]})}},60112:(e,t,r)=>{"use strict";function n(){return"p_"+Math.random().toString(36).slice(2,10)}function s(e){return"string"==typeof e&&e.startsWith("p_")}function a(e,t){return e.find(e=>e.id===t)}r.d(t,{Ny:()=>s,lh:()=>a,mV:()=>n}),r(47376)},60392:e=>{function t(e){return Promise.resolve().then(()=>{var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t})}t.keys=()=>[],t.resolve=t,t.id=60392,e.exports=t},68589:(e,t,r)=>{"use strict";r.d(t,{m:()=>s});let n=new Set(["write_file","create_file","batch_create_files","update_section","insert_after_heading","delete_file","rename_file","create_space"]);async function s(e,t,r){let s=e.getReader(),a=new TextDecoder,o="",l=[],i=new Map,u=null,c=null,d=Date.now();function m(){let e=l.map(e=>"text"===e.type?{type:"text",text:e.text}:"reasoning"===e.type?{type:"reasoning",text:e.text}:{...e});return{role:"assistant",content:e.filter(e=>"text"===e.type).map(e=>e.text).join(""),parts:e,timestamp:d}}try{for(;!r?.aborted;){let{done:e,value:r}=await s.read();if(e)break;let d=(o+=a.decode(r,{stream:!0})).split("\n");o=d.pop()??"";let p=!1;for(let e of d){let t,r=e.trim(),s=null;if(r.startsWith("data:")&&(s=r.slice(5).trim()),s){try{t=JSON.parse(s)}catch{continue}switch(t.type){case"text_delta":{let e=function(e){if(u===e){let e=l[l.length-1];if(e&&"text"===e.type)return e}let t={type:"text",text:""};return l.push(t),u=e,t}("text");e.text+=t.delta??"",p=!0;break}case"thinking_delta":c||(c={type:"reasoning",text:""},l.push(c),u=null),c.text+=t.delta??"",p=!0;break;case"tool_start":{let e=t.toolCallId,r=t.toolName,n=function(e,t){let r=i.get(e);return r||(r={type:"tool-call",toolCallId:e,toolName:t??"unknown",input:void 0,state:"pending"},i.set(e,r),l.push(r),u=null),r}(e,r);n.input=t.args,n.state="running",p=!0;break}case"tool_end":{let e=t.toolCallId,r=i.get(e);r&&(r.output=t.output??"",r.state=t.isError?"error":"done",p=!0,!t.isError&&n.has(r.toolName)&&window.dispatchEvent(new Event("mindos:files-changed")));break}case"error":{let e=t.message;l.push({type:"text",text:`
|
|
21
|
+
|
|
22
|
+
**Stream Error:** ${e}`}),u=null,p=!0}}}}p&&t(m())}}finally{s.releaseLock()}let p=!1;for(let e of i.values())("running"===e.state||"pending"===e.state)&&(e.state="error",e.output=e.output??"Stream ended before tool completed",p=!0);return p&&t(m()),m()}},76449:(e,t,r)=>{"use strict";r.d(t,{g:()=>n});let n=[{anchor:"files-panel",position:"right"},{anchor:"ask-button",position:"bottom"},{anchor:"agents-panel",position:"right"}]},84825:e=>{function t(e){return Promise.resolve().then(()=>{var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t})}t.keys=()=>[],t.resolve=t,t.id=84825,e.exports=t}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9207],{51842:(e,r,t)=>{t.d(r,{A:()=>c});var s=t(95155),o=t(12115),a=t(12651),l=t(51914),n=t(66088),d=t(30125),i=t(47376),u=t(35581);function c({value:e,onChange:r,showSkip:t=!1,compact:c=!1,configuredProviders:m,customProviders:x,onAdd:f}){let{locale:h}=(0,u.Y)(),[p,b]=(0,o.useState)(!1),g=(0,i.bf)(),v=m&&m.size>0,y=x&&x.length>0,j=c&&(v||y)&&!t,k=v?i.jt.filter(e=>m.has(e)):[],{primary:N,more:w}=g,C=t=>{let o=i.T_[t],l="zh"===h?o.nameZh:o.name,n=e===t,d=m?.has(t);return(0,s.jsxs)("button",{type:"button",onClick:()=>r(t),className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm ${n?"border-[var(--amber)] bg-[var(--amber-subtle)] shadow-sm":"border-border/50 hover:border-border hover:bg-muted/30"}`,children:[(0,s.jsx)("span",{className:`font-medium ${n?"text-foreground":"text-muted-foreground"}`,children:l}),d&&!n&&(0,s.jsx)(a.A,{size:12,className:"text-success ml-auto shrink-0"}),n&&(0,s.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]},t)},z=t=>{let o=i.T_[t],l="zh"===h?o.nameZh:o.name,n="zh"===h?o.descriptionZh:o.description,d=e===t,u=m?.has(t);return(0,s.jsxs)("button",{type:"button",onClick:()=>r(t),className:"flex items-start gap-3 p-4 rounded-xl border text-left transition-all duration-150",style:{background:d?"var(--amber-dim)":"var(--card)",borderColor:d?"var(--amber)":"var(--border)"},children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--foreground)"},children:l}),n&&(0,s.jsx)("p",{className:"text-xs mt-0.5",style:{color:"var(--muted-foreground)"},children:n}),(0,s.jsx)("p",{className:`text-xs ${n?"mt-1":"mt-0.5"}`,style:{color:"var(--muted-foreground)"},children:o.defaultModel})]}),u&&!d&&(0,s.jsx)(a.A,{size:14,className:"text-success shrink-0 mt-0.5"}),d&&(0,s.jsx)(a.A,{size:16,className:"shrink-0 mt-0.5",style:{color:"var(--amber)"}})]},t)};return j?(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[k.map(e=>C(e)),x?.map(t=>{let o=e===t.id;return(0,s.jsxs)("button",{type:"button",onClick:()=>r(t.id),className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm ${o?"border-[var(--amber)] bg-[var(--amber-subtle)] shadow-sm":"border-border/50 hover:border-border hover:bg-muted/30"}`,children:[(0,s.jsx)("span",{className:`font-medium ${o?"text-foreground":"text-muted-foreground"}`,children:t.name}),o&&(0,s.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]},t.id)}),f&&(0,s.jsxs)("button",{type:"button",onClick:f,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg border border-dashed border-border/50 text-sm text-muted-foreground hover:border-border hover:text-foreground transition-all",children:[(0,s.jsx)(l.A,{size:14}),(0,s.jsx)("span",{children:"zh"===h?"添加":"Add"})]})]})}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:c?"flex flex-wrap gap-2":"grid grid-cols-1 gap-2",children:N.map(e=>c?C(e):z(e))}),w.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>b(!p),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",children:[(0,s.jsx)(n.A,{size:12,className:`transition-transform ${p?"rotate-180":""}`}),p?"zh"===h?"收起":"Show less":"zh"===h?`更多 (${w.length})`:`More (${w.length})`]}),p&&(0,s.jsx)("div",{className:c?"flex flex-wrap gap-2":"grid grid-cols-1 gap-2",children:w.map(e=>c?C(e):z(e))})]}),t&&(0,s.jsxs)("button",{type:"button",onClick:()=>r("skip"),className:"flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-all text-sm w-full mt-1",style:{background:"skip"===e?"var(--amber-dim)":"var(--card)",borderColor:"skip"===e?"var(--amber)":"var(--border)"},children:[(0,s.jsx)(d.A,{size:14,className:"shrink-0",style:{color:"skip"===e?"var(--amber)":"var(--muted-foreground)"}}),(0,s.jsx)("span",{className:`font-medium ${"skip"===e?"text-foreground":"text-muted-foreground"}`,children:"zh"===h?"暂时跳过":"Skip for now"}),"skip"===e&&(0,s.jsx)(a.A,{size:14,className:"ml-auto shrink-0",style:{color:"var(--amber)"}})]})]})}},79704:(e,r,t)=>{t.d(r,{A:()=>i});var s=t(95155),o=t(12115),a=t(6296),l=t(66088),n=t(20171),d=t(47376);function i({value:e,onChange:r,placeholder:t,provider:i,apiKey:u,envKey:c,baseUrl:m,supportsListModels:x,allowNoKey:f,browseLabel:h="Browse",noModelsLabel:p="No models found"}){let[b,g]=(0,o.useState)(null),[v,y]=(0,o.useState)(!1),[j,k]=(0,o.useState)(!1),[N,w]=(0,o.useState)(""),[C,z]=(0,o.useState)(!1),[A,S]=(0,o.useState)(-1),E=(0,o.useRef)(null),$=(0,o.useRef)(null),L=(0,o.useRef)(null),[R,_]=(0,o.useState)({}),D=(0,o.useRef)(!1),T=(0,o.useRef)(0),F=(0,o.useRef)(!1),K=f||!!u||!!c||!!d.T_[i]?.apiKeyFallback;(0,o.useEffect)(()=>{D.current=!1,T.current++,g(null)},[i,u,m]);let M=(0,o.useCallback)(async(e=!1)=>{if(F.current)return;F.current=!0,y(!0),e||w("");let r=T.current;try{let t={provider:i};u&&(t.apiKey=u),m&&(t.baseUrl=m);let s=await fetch("/api/settings/list-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r!==T.current)return;let o=await s.json();if(r!==T.current)return;o.ok&&Array.isArray(o.models)?(g(o.models),D.current=!0,e||k(!0)):e||w(o.error||"Failed to fetch models")}catch{if(r!==T.current)return;e||w("Network error")}finally{F.current=!1,y(!1)}},[i,u,m]),Z=(0,o.useCallback)(()=>{z(!0),!D.current&&x&&K&&!F.current&&M(!0)},[x,K,M]),B=(0,o.useMemo)(()=>{if(!b)return[];if(!e.trim())return b;let r=e.toLowerCase();return[...b].sort((e,t)=>{let s=e.toLowerCase(),o=t.toLowerCase(),a=s.includes(r),l=o.includes(r);if(a!==l)return a?-1:1;if(a&&l){let e=s.startsWith(r);if(e!==o.startsWith(r))return e?-1:1;let t=s===r;if(t!==(o===r))return t?-1:1}return e.localeCompare(t)})},[b,e]),O=j||C&&null!==b&&e.trim().length>0&&B.length>0;(0,o.useEffect)(()=>{if(!O||!$.current)return;let e=$.current.getBoundingClientRect();_({position:"fixed",top:e.bottom+4,left:e.left,width:e.width})},[O]),(0,o.useEffect)(()=>{S(-1)},[B]),(0,o.useEffect)(()=>{if(A<0||!L.current)return;let e=L.current.querySelectorAll("[data-model-item]");e[A]?.scrollIntoView({block:"nearest"})},[A]);let U=(0,o.useCallback)(e=>{let t=O?B:[];t.length&&("ArrowDown"===e.key?(e.preventDefault(),S(e=>(e+1)%t.length)):"ArrowUp"===e.key?(e.preventDefault(),S(e=>(e-1+t.length)%t.length)):"Enter"===e.key&&A>=0&&A<t.length?(e.preventDefault(),r(t[A]),k(!1),z(!1)):"Escape"===e.key&&(k(!1),z(!1)))},[O,B,A,r]);return(0,o.useEffect)(()=>{if(O)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){E.current&&!E.current.contains(e.target)&&(k(!1),z(!1))}},[O]),(0,s.jsxs)("div",{ref:E,className:"relative",children:[(0,s.jsxs)("div",{ref:$,className:"flex gap-1.5",children:[(0,s.jsx)(n.pd,{value:e,onChange:e=>{r(e.target.value),j||z(!0)},onFocus:Z,onKeyDown:U,placeholder:t,className:"flex-1",autoComplete:"off"}),x&&(0,s.jsxs)("button",{type:"button",disabled:!K||v,onClick:()=>M(!1),title:h,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-border text-muted-foreground hover:text-foreground hover:border-foreground/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[v?(0,s.jsx)(a.A,{size:12,className:"animate-spin"}):(0,s.jsx)(l.A,{size:12}),h]})]}),N&&(0,s.jsx)("p",{className:"text-xs text-error mt-1",children:N}),O&&B.length>0&&(0,s.jsx)("div",{ref:L,style:R,className:"fixed z-[9999] max-h-48 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg",children:B.map((t,o)=>{let a=!e.trim()||t.toLowerCase().includes(e.toLowerCase());return(0,s.jsx)("button",{type:"button","data-model-item":!0,className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${t===e?"bg-accent/60 font-medium":o===A?"bg-accent":"hover:bg-accent"} ${!a?"opacity-50":""}`,onClick:()=>{r(t),k(!1),z(!1)},children:t},t)})}),j&&0===B.length&&(0,s.jsx)("div",{style:R,className:"fixed z-[9999] rounded-lg border border-border bg-popover shadow-lg px-3 py-2 text-xs text-muted-foreground",children:p})]})}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2114],{74009:(e,t,s)=>{Promise.resolve().then(s.bind(s,96485))},96485:(e,t,s)=>{"use strict";s.d(t,{default:()=>J});var r=s(95155),a=s(98500),n=s.n(a),l=s(12115),i=s(80723),o=s(49387),d=s(68459),c=s(15573),u=s(53961),m=s(61878),x=s(41585),p=s(67635),g=s(92451),b=s(73035),f=s(84755),h=s(93219),v=s(6296),j=s(52905),N=s(44478),y=s(439),k=s(84980),w=s(3926),S=s(93631),A=s(10762),C=s(97810),M=s(12651),z=s(13545),R=s(66088),T=s(35581),F=s(4235),E=s(91337),P=s(70617),$=s(2857),O=s(22356),D=s(7834),L=s(13845),I=s(3590),U=s(39498),_=s(85641),H=s(90777);function J({agentKey:e}){let{t}=(0,T.Y)(),s=t.agentsContent,a=t.panels.agents,h=(0,P.kr)(),v=(0,$.V)(),j=(0,l.useMemo)(()=>h.agents.find(t=>t.key===e),[h.agents,e]),[N,y]=(0,l.useState)(""),[k,w]=(0,l.useState)("all"),[S,A]=(0,l.useState)(null),[C,M]=(0,l.useState)(null),[z,R]=(0,l.useState)(""),[E,J]=(0,l.useState)(null),[q,B]=(0,l.useState)(!1),[X,Z]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(null),[es,er]=(0,l.useState)(null),[ea,en]=(0,l.useState)(null),[el,ei]=(0,l.useState)(null),[eo,ed]=(0,l.useState)(null),[ec,eu]=(0,l.useState)(null),[em,ex]=(0,l.useState)(!1),[ep,eg]=(0,l.useState)(!1),eb=(0,l.useCallback)(async()=>{if(j?.isCustom)try{let e=await fetch("/api/agents/custom",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:j.key})});if(e.ok)F.oR.success(s.overview.customAgentRemoved(j.name)),h.refresh(),window.location.href="/agents";else{let t=await e.json();F.oR.error(t.error||s.overview.customAgentFailedRemove)}}catch{F.oR.error(s.overview.customAgentNetworkError)}finally{eg(!1)}},[j,s.overview,h]),ef=(0,l.useMemo)(()=>(0,I.qC)(h.skills,{query:N,source:k}),[h.skills,N,k]),eh=(0,l.useMemo)(()=>({total:h.skills.length,enabled:h.skills.filter(e=>e.enabled).length,builtin:h.skills.filter(e=>"builtin"===e.source).length,user:h.skills.filter(e=>"user"===e.source).length}),[h.skills]),ev=(0,l.useMemo)(()=>{let e=(0,I.HL)(h.agents),t=new Map;for(let s of e)t.set(s.serverName,s.agents);return t},[h.agents]),ej=(0,l.useMemo)(()=>{let e=(0,I.x3)(h.agents),t=new Map;for(let s of e)t.set(s.skillName,s.agents);return t},[h.agents]),eN="mindos"===e,ey=j?(0,I.yv)(j):"notFound",ek=j?.scope==="project"?"project":"global",ew=j?.transport==="http"?"http":"stdio",eS=(0,l.useMemo)(()=>j?(0,L.$k)(j,h.status,ew):{snippet:"",path:""},[j,h.status,ew]),eA=(0,l.useMemo)(()=>new Set(h.skills.map(e=>e.name)),[h.skills]),eC=(0,l.useMemo)(()=>(j?.installedSkillNames??[]).filter(e=>!eA.has(e)),[j?.installedSkillNames,eA]),eM=j?.configuredMcpServers??[],ez=(0,l.useCallback)(async(e,t)=>{A(e),J(null);try{await h.toggleSkill(e,t),await h.refresh()}finally{A(null)}},[h]),eR=(0,l.useCallback)(async e=>{J(null),A(e);try{let t=await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",name:e})});M(e),R(t.content)}catch(e){J(e instanceof Error?e.message:s.detail.skillReadFailed)}finally{A(null)}},[s.detail.skillReadFailed]),eT=(0,l.useCallback)(async()=>{if(C){B(!0),J(null);try{await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update",name:C,content:z})}),M(null),R(""),window.dispatchEvent(new Event("mindos:skills-changed")),await h.refresh()}catch(e){J(e instanceof Error?e.message:s.detail.skillSaveFailed)}finally{B(!1)}}},[C,z,s.detail.skillSaveFailed,h]),eF=(0,l.useCallback)(async e=>{er(null),A(e);try{await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",name:e})}),en(s.detail.skillDeleteSuccess),window.dispatchEvent(new Event("mindos:skills-changed")),await h.refresh()}catch{en(s.detail.skillDeleteFailed)}finally{A(null),setTimeout(()=>en(null),3e3)}},[s.detail.skillDeleteSuccess,s.detail.skillDeleteFailed,h]),eE=(0,l.useCallback)(async e=>{if(j?.skillWorkspacePath){A(e),J(null);try{(await (0,O.n)("/api/agents/copy-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillName:e,targetPath:j.skillWorkspacePath})})).success&&(F.oR.success(`Skill "${e}" copied to ${j.name}`),await h.refresh())}catch(t){let e=t instanceof Error?t.message:"Failed to copy skill";J(e),F.oR.error(e)}finally{A(null)}}},[j,h]),eP=(0,l.useCallback)(async()=>{await (0,D.l)(eS.snippet)&&F.oR.copy()},[eS.snippet]),e$=(0,l.useCallback)(async(e,t)=>{if(j){Z(!0),et(s.detail.mcpApplying);try{let r=await h.installAgent(j.key,{scope:e,transport:t});await h.refresh(),et(r?s.detail.mcpApplySuccess:s.detail.mcpApplyFailed)}finally{Z(!1)}}},[s.detail.mcpApplying,s.detail.mcpApplySuccess,s.detail.mcpApplyFailed,h,j]),eO=(0,l.useCallback)(async e=>{await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",name:e})}),window.dispatchEvent(new Event("mindos:skills-changed")),await h.refresh()},[h]),eD=(0,l.useCallback)(()=>{ei(null),ed(s.detail.mcpServerHint),setTimeout(()=>ed(null),4e3)},[s.detail.mcpServerHint]);if(!j){let t=h.agents.filter(t=>t.key!==e&&"connected"===(0,I.yv)(t)).slice(0,3);return(0,r.jsxs)("div",{className:"content-width px-4 md:px-6 py-8 md:py-10",children:[(0,r.jsxs)(n(),{href:"/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground mb-4",children:[(0,r.jsx)(i.A,{size:14}),s.backToOverview]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6 space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground font-medium",children:s.detailNotFound}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:s.detailNotFoundHint}),t.length>0&&(0,r.jsxs)("div",{className:"pt-2 border-t border-border",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:s.detailNotFoundSuggestion}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:t.map(e=>(0,r.jsx)(n(),{href:`/agents/${encodeURIComponent(e.key)}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-muted text-foreground hover:bg-muted/80 transition-colors",children:e.name},e.key))})]})]})]})}return(0,r.jsxs)("div",{className:"content-width px-4 md:px-6 py-8 md:py-10 space-y-4",children:[(0,r.jsxs)(n(),{href:"/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,r.jsx)(i.A,{size:14}),s.backToOverview]}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3.5 px-5 py-4",children:[(0,r.jsx)(U.lx,{name:j.name,status:ey,size:"md"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-foreground truncate",children:j.name}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 mt-0.5 text-2xs text-muted-foreground/60",children:[(0,r.jsx)("span",{className:`font-medium px-1.5 py-px rounded-full ${"connected"===ey?"bg-muted text-muted-foreground":"detected"===ey?"bg-[var(--amber-subtle)] text-[var(--amber-text)]":"bg-error/10 text-error"}`,children:ey}),(0,r.jsx)("span",{className:"font-mono",children:j.transport??j.preferredTransport}),(0,r.jsx)("span",{className:"text-muted-foreground/25","aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("span",{children:j.skillMode??s.na})]})]}),j.isCustom&&(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>ex(!0),className:"w-8 h-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted transition-colors duration-150 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s.overview.customAgentEdit,title:s.overview.customAgentEdit,children:(0,r.jsx)(o.A,{size:14})}),(0,r.jsx)("button",{type:"button",onClick:()=>eg(!0),className:"w-8 h-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors duration-150 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s.overview.customAgentRemove,title:s.overview.customAgentRemove,children:(0,r.jsx)(d.A,{size:14})})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-2xs text-muted-foreground/50 px-5 py-2 border-t border-border/40",children:[(0,r.jsxs)("span",{children:[j.format," ",(0,r.jsx)("span",{className:"text-muted-foreground/30",children:"\xb7"})," ",W(j.runtimeLastActivityAt)]}),(0,r.jsxs)("span",{className:"tabular-nums",children:[eM.length," MCP ",(0,r.jsx)("span",{className:"text-muted-foreground/30",children:"\xb7"})," ",eC.length," skills"]})]})]}),(0,r.jsx)(G,{}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(c.A,{size:13,className:"text-[var(--amber)]"})}),s.detail.mcpManagement]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[!eN&&(0,r.jsx)(U.rA,{onClick:()=>void eP(),disabled:!1,busy:!1,label:s.detail.mcpCopySnippet}),(0,r.jsx)(U.rA,{onClick:()=>void h.refresh(),disabled:!1,busy:!1,label:s.detail.mcpRefresh}),!eN&&(0,r.jsx)(U.rA,{onClick:()=>void e$(ek,ew),disabled:X,busy:X,label:s.detail.mcpReconnect})]})]}),ee&&(0,r.jsx)("p",{className:"text-2xs text-muted-foreground animate-in fade-in duration-200",children:ee}),(0,r.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:eN?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V,{label:"Status",value:h.status?.running?"Running":"Stopped"}),(0,r.jsx)(V,{label:"Endpoint",value:h.status?.endpoint??s.na}),(0,r.jsx)(V,{label:"Tools",value:h.status?.toolCount!=null?String(h.status.toolCount):s.na})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V,{label:s.detail.mcpInstalled,value:j.installed?s.detail.yes:s.detail.no}),(0,r.jsx)(V,{label:s.detail.mcpScope,value:j.scope??s.na}),(0,r.jsx)(V,{label:s.detail.mcpConfigPath,value:j.configPath??s.na})]})}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground/60 uppercase tracking-wider",children:s.detail.configuredMcpServers}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40 tabular-nums",children:eM.length})]}),eo&&(0,r.jsx)("div",{role:"status","aria-live":"polite",className:"rounded-md border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground animate-in fade-in duration-200",children:eo}),0===eM.length?(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:s.detail.configuredMcpServersEmpty}):(0,r.jsx)("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:eM.map(e=>{let t=(ev.get(e)??[]).filter(e=>e!==j.name);return(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 group/mcp hover:bg-muted/30 transition-colors duration-100",children:[(0,r.jsx)(c.A,{size:11,className:"text-muted-foreground/40 shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-foreground flex-1 min-w-0 truncate",children:e}),t.length>0&&(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[t.slice(0,3).map(e=>(0,r.jsx)(U.lx,{name:e,size:"sm"},e)),t.length>3&&(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:["+",t.length-3]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>ei(e),className:"text-muted-foreground/40 hover:text-destructive cursor-pointer opacity-0 group-hover/mcp:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded p-0.5 transition-all duration-150","aria-label":`${s.detail.mcpServerRemove} ${e}`,children:(0,r.jsx)(d.A,{size:11})})]},e)})})]})]}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(u.A,{size:13,className:"text-[var(--amber)]"})}),s.detail.skillAssignments]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-2xs text-muted-foreground/50 tabular-nums",children:[(0,r.jsxs)("span",{children:[eh.enabled,"/",eh.total," enabled"]}),(0,r.jsx)("span",{className:"text-muted-foreground/25",children:"\xb7"}),(0,r.jsxs)("span",{children:[eC.length," native"]})]})]}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-2",children:[(0,r.jsxs)("label",{className:"relative flex-1",children:[(0,r.jsx)(m.A,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),(0,r.jsx)("input",{value:N,onChange:e=>y(e.target.value),placeholder:s.detail.skillsSearchPlaceholder,className:"w-full h-9 rounded-md border border-border bg-background pl-8 pr-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors duration-150"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5 bg-background",children:[(0,r.jsx)(U.KF,{active:"all"===k,label:s.detail.skillsFilterAll,onClick:()=>w("all")}),(0,r.jsx)(U.KF,{active:"builtin"===k,label:s.detail.skillsFilterBuiltin,onClick:()=>w("builtin")}),(0,r.jsx)(U.KF,{active:"user"===k,label:s.detail.skillsFilterUser,onClick:()=>w("user")})]})]}),ea&&(0,r.jsx)("div",{role:"status","aria-live":"polite",className:"rounded-md border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground animate-in fade-in duration-200",children:ea}),j?.skillMode==="unsupported"&&(0,r.jsxs)("div",{className:"rounded-lg border border-[var(--amber)]/20 bg-[var(--amber-dim)] p-3 mb-2",children:[(0,r.jsxs)("p",{className:"text-sm font-medium text-foreground mb-2 flex items-center gap-1.5",children:[(0,r.jsx)(x.A,{size:14,className:"text-[var(--amber)] shrink-0","aria-hidden":"true"}),"Manual Skill Installation"]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground mb-3",children:["This agent doesn't support ",(0,r.jsx)("code",{className:"bg-background px-1 py-0.5 rounded text-xs font-mono",children:"npx skills"}),". Copy skills manually:"]}),(0,r.jsxs)("div",{className:"bg-background rounded-md px-3 py-2 font-mono text-xs overflow-x-auto border border-border/50 select-all",children:["cp -r ~/.mindos/skills/<skill-name> ",j.skillWorkspacePath||"~/.agent/skills/"]})]}),ef.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5",children:["MindOS Skills ",(0,r.jsxs)("span",{className:"tabular-nums",children:["(",ef.filter(e=>e.enabled).length,"/",ef.length,")"]})]}),(0,r.jsx)("ul",{className:"space-y-0.5",children:ef.map(e=>{let t=C===e.name;return(0,r.jsxs)("li",{className:"rounded-md hover:bg-muted/30 transition-colors duration-100",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-1.5 group/skill",children:[(0,r.jsx)(u.A,{size:13,className:`shrink-0 ${e.enabled?"text-[var(--amber)]":"text-muted-foreground/50"}`,"aria-hidden":"true"}),(0,r.jsx)("button",{type:"button",onClick:()=>eu(e.name),className:"text-xs text-foreground flex-1 min-w-0 truncate hover:text-[var(--amber)] cursor-pointer transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded text-left",children:e.name}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded shrink-0 ${"builtin"===e.source?"bg-muted text-muted-foreground":"bg-[var(--amber-dim)] text-[var(--amber-text)]"}`,children:"builtin"===e.source?s.detail.skillsSourceBuiltin:s.detail.skillsSourceUser}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0 md:opacity-0 md:group-hover/skill:opacity-100 md:focus-within:opacity-100 transition-opacity duration-150",children:[(0,r.jsx)(U.rA,{onClick:()=>void ez(e.name,!e.enabled),disabled:S===e.name,busy:S===e.name,label:e.enabled?s.detail.skillDisable:s.detail.skillEnable}),e.editable&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(U.rA,{onClick:()=>void eR(e.name),disabled:S===e.name||q,busy:!1,label:s.detail.skillEdit}),(0,r.jsx)("button",{type:"button",onClick:()=>er(e.name),disabled:S===e.name,className:"inline-flex items-center justify-center min-h-[28px] px-1.5 rounded-md text-muted-foreground hover:text-destructive cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-150","aria-label":`${s.detail.skillDelete} ${e.name}`,children:(0,r.jsx)(d.A,{size:13})})]}),j?.skillMode==="unsupported"&&(0,r.jsx)("button",{type:"button",onClick:()=>void eE(e.name),disabled:S===e.name,className:"inline-flex items-center justify-center min-h-[28px] px-1.5 rounded-md text-muted-foreground hover:text-[var(--amber)] cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-150",title:`Copy ${e.name} to ${j.name}`,"aria-label":`Copy ${e.name} to ${j.name}`,children:(0,r.jsx)(p.A,{size:13})})]})]}),t&&(0,r.jsxs)("div",{className:"px-3 pb-3 pt-0 space-y-2",children:[(0,r.jsx)("textarea",{value:z,onChange:e=>R(e.target.value),className:"mt-2 w-full h-40 rounded-md border border-border bg-background px-3 py-2 text-xs font-mono text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring resize-y"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(U.rA,{onClick:()=>void eT(),disabled:q,busy:q,label:s.detail.skillSave,variant:"primary"}),(0,r.jsx)(U.rA,{onClick:()=>M(null),disabled:!1,busy:!1,label:s.detail.skillCancel})]})]})]},e.name)})})]}),0===ef.length&&0===eC.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:s.detail.noSkills}),eC.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5",children:[s.detail.nativeInstalledSkills," ",(0,r.jsxs)("span",{className:"tabular-nums",children:["(",eC.length,")"]})]}),(0,r.jsx)("div",{className:"space-y-0.5 max-h-[280px] overflow-y-auto",children:eC.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>eu(e),className:"w-full flex items-center gap-2 py-1.5 px-1.5 rounded-md hover:bg-muted/30 transition-colors duration-100 cursor-pointer text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(u.A,{size:13,className:"shrink-0 text-muted-foreground/50","aria-hidden":"true"}),(0,r.jsx)("span",{className:"text-xs text-foreground flex-1 min-w-0 truncate hover:text-[var(--amber)] transition-colors duration-150",children:e})]},e))})]}),E&&(0,r.jsx)("p",{className:"text-xs text-error",children:E})]}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(g.A,{size:13,className:"text-[var(--amber)]"})}),a.a2aCapabilities]}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded font-medium shrink-0 ${"connected"===ey?"bg-[var(--success)]/15 text-[var(--success)]":"bg-muted text-muted-foreground/60"}`,children:"connected"===ey?a.a2aConnected:a.a2aUnavailable})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:[(0,r.jsx)(V,{label:a.a2aStatus,value:"connected"===ey?a.a2aConnected:a.a2aUnavailable}),(0,r.jsx)(V,{label:s.detail.transport,value:j.transport??j.preferredTransport}),v.agents.length>0&&(0,r.jsx)(V,{label:"Remote agents",value:String(v.agents.length)})]}),v.agents.length>0?(0,r.jsx)("div",{className:"space-y-1",children:v.agents.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-md px-2 py-1.5 hover:bg-muted/30 transition-colors duration-100",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-muted/40 flex items-center justify-center shrink-0",children:(0,r.jsx)(g.A,{size:11,className:"text-muted-foreground/60"})}),(0,r.jsx)("span",{className:"text-xs text-foreground flex-1 min-w-0 truncate",children:e.card.name}),e.reachable?(0,r.jsx)(b.A,{size:11,className:"text-[var(--success)] shrink-0"}):(0,r.jsx)(f.A,{size:11,className:"text-muted-foreground/50 shrink-0"}),(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/50 tabular-nums shrink-0",children:[e.card.skills.length," skills"]})]},e.id))}):(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:a.a2aNoRemoteHint})]}),(0,r.jsx)(K,{agent:j,status:ey,isMindOS:eN,mcpStatus:h.status}),(0,r.jsx)(Y,{agent:j,isMindOS:eN}),(0,r.jsx)(Q,{agent:j}),(0,r.jsx)(U.TM,{open:null!==es,title:s.detail.skillDelete,message:es?s.detail.skillDeleteConfirm(es):"",confirmLabel:s.detail.skillDelete,cancelLabel:s.detail.skillCancel,onConfirm:()=>es&&void eF(es),onCancel:()=>er(null),variant:"destructive"}),(0,r.jsx)(U.TM,{open:null!==el,title:s.detail.mcpServerRemove,message:el?s.detail.mcpServerRemoveConfirm(el):"",confirmLabel:s.detail.mcpServerRemove,cancelLabel:s.detail.skillCancel,onConfirm:eD,onCancel:()=>ei(null),variant:"destructive"}),(0,r.jsx)(_.A,{open:null!==ec,skillName:ec,skill:ec?h.skills.find(e=>e.name===ec)??null:null,agentNames:ec?ej.get(ec)??[]:[],isNative:!!ec&&!h.skills.some(e=>e.name===ec),nativeSourcePath:j?.installedSkillSourcePath,copy:s.skills.skillPopover,onClose:()=>eu(null),onToggle:h.toggleSkill,onDelete:eO,onRefresh:h.refresh}),j?.isCustom&&(0,r.jsx)(H.A,{open:em,onClose:()=>ex(!1),onSuccess:()=>{h.refresh(),ex(!1)},existingAgents:h.agents,editAgent:j}),(0,r.jsx)(U.TM,{open:ep,title:j?s.overview.customAgentRemoveTitle(j.name):"",message:s.overview.customAgentRemoveMessage,confirmLabel:s.overview.customAgentRemoveConfirm,cancelLabel:s.detail.skillCancel,onConfirm:eb,onCancel:()=>eg(!1),variant:"destructive"})]})}function V({label:e,value:t}){return(0,r.jsxs)("div",{className:"flex items-baseline gap-2 px-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider shrink-0 min-w-[60px]",children:e}),(0,r.jsx)("span",{className:"text-xs text-foreground/80 font-mono truncate min-w-0",children:t})]})}function W(e){if(!e)return"—";try{let t=Date.now()-new Date(e).getTime();if(t<0)return"just now";let s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);return`${a}d ago`}catch{return e}}function K({agent:e,status:t,isMindOS:s,mcpStatus:a}){let{t:n}=(0,T.Y)(),i=n.agentsContent.detail,[o,d]=(0,l.useState)("idle"),[c,u]=(0,l.useState)(0),m=(0,l.useCallback)(async()=>{d("pinging");let e=performance.now();try{let t=await fetch("/api/mcp/status",{method:"GET",signal:AbortSignal.timeout(5e3)}),s=Math.round(performance.now()-e);u(s),d(t.ok?"ok":"fail")}catch{d("fail")}},[]);return(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(h.A,{size:13,className:"text-[var(--amber)]"})}),i.runtimeDiagTitle]}),(0,r.jsx)("button",{type:"button",onClick:()=>void m(),disabled:"pinging"===o,className:"inline-flex items-center gap-1 px-2.5 py-1 text-2xs font-medium rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"pinging"===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.A,{size:10,className:"animate-spin"})," ",i.runtimePinging]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.A,{size:10})," ",i.runtimePing]})})]}),"ok"===o&&(0,r.jsx)("div",{role:"status",className:"rounded-md bg-[var(--success)]/10 border border-[var(--success)]/20 px-3 py-1.5 text-2xs text-[var(--success)] font-medium animate-in fade-in duration-200",children:i.runtimePingOk(c)}),"fail"===o&&(0,r.jsx)("div",{role:"status",className:"rounded-md bg-error/10 border border-error/20 px-3 py-1.5 text-2xs text-error font-medium animate-in fade-in duration-200",children:i.runtimePingFail}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:[(0,r.jsx)(V,{label:i.status,value:t}),(0,r.jsx)(V,{label:i.transport,value:e.transport??e.preferredTransport}),s&&a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V,{label:i.runtimeVersion,value:a.endpoint}),(0,r.jsx)(V,{label:i.port,value:String(a.port)})]}),(0,r.jsx)(V,{label:i.lastActivityAt,value:W(e.runtimeLastActivityAt)}),void 0!==e.runtimeConversationSignal&&(0,r.jsx)(V,{label:i.conversationSignal,value:e.runtimeConversationSignal?"Active":"Inactive"}),void 0!==e.runtimeUsageSignal&&(0,r.jsx)(V,{label:i.usageSignal,value:e.runtimeUsageSignal?"Active":"Inactive"})]}),!e.runtimeLastActivityAt&&"idle"===o&&(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:i.runtimeNoData})]})}function Y({agent:e,isMindOS:t}){let{t:s}=(0,T.Y)(),a=s.agentsContent.detail,n=e.scope??(e.hasProjectScope?"project":e.hasGlobalScope?"global":"—");e.hiddenRootPresent;let l=[{label:a.envFileAccess,allowed:!0},{label:a.envNetworkAccess,allowed:"http"===e.transport||t},{label:a.envWriteAccess,allowed:!0},{label:a.envReadOnly,allowed:!1}];return(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(j.A,{size:13,className:"text-[var(--amber)]"})}),a.envPermTitle]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:[(0,r.jsx)(V,{label:a.envScope,value:n}),(0,r.jsx)(V,{label:a.format,value:e.format}),e.hiddenRootPath&&(0,r.jsx)(V,{label:a.hiddenRoot,value:e.hiddenRootPath}),(0,r.jsx)(V,{label:a.skillMode,value:e.skillMode??"—"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground/60 uppercase tracking-wider mb-1.5",children:a.envVars}),e.configuredMcpServers&&e.configuredMcpServers.length>0?(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:a.envVarsCount(e.configuredMcpServers.length)}):(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:a.envVarsEmpty})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground/60 uppercase tracking-wider",children:"Permissions"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:l.map(({label:e,allowed:t})=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-1.5 bg-muted/20",children:[t?(0,r.jsx)(N.A,{size:12,className:"text-[var(--success)] shrink-0"}):(0,r.jsx)(y.A,{size:12,className:"text-muted-foreground/40 shrink-0"}),(0,r.jsx)("span",{className:"text-2xs text-foreground/80",children:e}),(0,r.jsx)("span",{className:`ml-auto text-2xs font-medium ${t?"text-[var(--success)]":"text-muted-foreground/50"}`,children:t?a.envAllowed:a.envRestricted})]},e))})]})]})}function q(e){return/search/.test(e)?"search":/read|list|get/.test(e)?"read":/create|batch_create/.test(e)?"create":/delete/.test(e)?"delete":/write|update|insert|append|edit|rename|move/.test(e)?"write":"other"}let B={read:{icon:k.A,color:"text-blue-400"},write:{icon:w.A,color:"text-[var(--amber)]"},create:{icon:S.A,color:"text-[var(--success)]"},delete:{icon:d.A,color:"text-[var(--error)]"},search:{icon:m.A,color:"text-purple-400"},other:{icon:A.A,color:"text-muted-foreground"}};function G(){let{t:e}=(0,T.Y)(),t=e.agentsContent?.detail,[s,a]=(0,l.useState)([]),[i,o]=(0,l.useState)(!0),[d,c]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=!1,t=()=>{fetch("/api/agent-activity?limit=50").then(e=>e.json()).then(t=>{e||a(t.events??[])}).catch(()=>{}).finally(()=>{e||o(!1)})};t();let s=()=>{"visible"===document.visibilityState&&t()};return document.addEventListener("visibilitychange",s),()=>{e=!0,document.removeEventListener("visibilitychange",s)}},[]);let u=(0,l.useMemo)(()=>{if(0===s.length)return null;let e=s.filter(e=>"read"===q(e.tool)).length,t=s.filter(e=>["write","create","delete"].includes(q(e.tool))).length,r=s.filter(e=>"error"===e.result).length,a=s.filter(e=>"number"==typeof e.durationMs).map(e=>e.durationMs),n=a.length>0?Math.round(a.reduce((e,t)=>e+t,0)/a.length):null,l=new Set;for(let e of s){let t=e.params.path;"string"==typeof t&&l.add(t)}let i=s.length>0?Math.round(r/s.length*100):0;return{total:s.length,reads:e,writes:t,errors:r,errorRate:i,avgMs:n,filesCount:l.size}},[s]),m=(0,l.useMemo)(()=>{let e=s.filter(e=>{let t=q(e.tool);return"write"===t||"create"===t||"delete"===t});return e.length>=3?e:s},[s]),x=d?m:m.slice(0,5),p=m.length-5;return i?(0,r.jsx)("section",{className:"rounded-xl border border-border bg-card p-4",children:(0,r.jsx)("div",{className:"flex justify-center py-6",children:(0,r.jsx)(v.A,{size:16,className:"animate-spin text-muted-foreground"})})}):0===s.length?(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(C.A,{size:13,className:"text-[var(--amber)]"})}),t?.knowledgeInteraction??"Knowledge Interaction"]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-card/30 px-4 py-6 text-center",children:[(0,r.jsx)(C.A,{size:20,className:"text-muted-foreground/30 mx-auto mb-2"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:t?.knowledgeNoData??"No interactions yet. Agents will show activity here once they start working with your knowledge base."})]})]}):(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4 pb-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(C.A,{size:13,className:"text-[var(--amber)]"})}),t?.knowledgeInteraction??"Knowledge Interaction"]}),(0,r.jsxs)(n(),{href:`/view/${(0,E.O0)(".mindos/agent-audit-log.json")}`,className:"text-2xs font-medium text-[var(--amber)] hover:opacity-80 transition-opacity",children:[t?.viewFullLog??"View log"," →"]})]}),u&&(0,r.jsxs)("div",{className:"flex items-center gap-px mx-4 mb-3 rounded-lg overflow-hidden border border-border/40",children:[(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statTotalCalls??"Calls"}),(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground font-mono tabular-nums leading-none",children:u.total})]}),(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20 border-l border-border/30",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statFilesTouched??"Files"}),(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground font-mono tabular-nums leading-none",children:u.filesCount})]}),(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20 border-l border-border/30",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statReadWrite??"R / W"}),(0,r.jsxs)("p",{className:"text-sm font-semibold text-foreground font-mono tabular-nums leading-none",children:[(0,r.jsx)("span",{className:"text-blue-400",children:u.reads}),(0,r.jsx)("span",{className:"text-muted-foreground/30 mx-0.5",children:"/"}),(0,r.jsx)("span",{className:"text-[var(--amber)]",children:u.writes})]})]}),(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20 border-l border-border/30",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statHealth??"Health"}),(0,r.jsx)("p",{className:"text-sm font-semibold font-mono tabular-nums leading-none",children:u.errors>0?(0,r.jsxs)("span",{className:"text-[var(--error)]",children:[u.errorRate,"% err"]}):(0,r.jsx)("span",{className:"text-[var(--success)]",children:"100%"})})]})]}),(0,r.jsxs)("div",{className:"border-t border-border/40",children:[(0,r.jsx)("div",{className:"px-4 py-2 flex items-center justify-between",children:(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/40 uppercase tracking-wider",children:t?.recentOps??"Recent operations"})}),x.map((e,t)=>{let{icon:s,color:a}=B[q(e.tool)],l="string"==typeof e.params.path?e.params.path:null,i=e.tool.replace(/^mindos_/,"");return(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border/20 hover:bg-muted/20 transition-colors",children:[(0,r.jsx)("div",{className:"w-5 h-5 rounded-md bg-muted/40 flex items-center justify-center shrink-0",children:(0,r.jsx)(s,{size:11,className:a})}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground/80 font-mono shrink-0 min-w-[90px]",children:i}),l?(0,r.jsx)(n(),{href:`/view/${(0,E.O0)(l)}`,className:"text-xs text-muted-foreground hover:text-[var(--amber)] truncate min-w-0 flex-1 font-mono transition-colors",title:l,children:l}):(0,r.jsx)("span",{className:"flex-1"}),"ok"===e.result?(0,r.jsx)(M.A,{size:10,className:"shrink-0 text-[var(--success)]/40"}):(0,r.jsx)(z.A,{size:10,className:"shrink-0 text-[var(--error)]/60"}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/30 tabular-nums shrink-0 font-mono w-[28px] text-right",title:e.ts,children:function(e){let t=Date.now()-new Date(e).getTime(),s=Math.floor(t/6e4);if(s<1)return"<1m";if(s<60)return`${s}m`;let r=Math.floor(t/36e5);return r<24?`${r}h`:`${Math.floor(t/864e5)}d`}(e.ts)})]},e.id??t)})]}),p>0&&(0,r.jsx)("div",{className:"px-4 py-2 border-t border-border/20",children:(0,r.jsxs)("button",{onClick:()=>c(e=>!e),className:"flex items-center gap-1.5 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-opacity cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded",children:[(0,r.jsx)(R.A,{size:12,className:`transition-transform duration-200 ${d?"rotate-180":""}`}),(0,r.jsx)("span",{children:d?t?.showLess??"Show less":`${p} more`})]})})]})}function Q({agent:e}){let{t}=(0,T.Y)(),s=t.agentsContent.detail,a=!!e.runtimeLastActivityAt;return(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(h.A,{size:13,className:"text-[var(--amber)]"})}),s.activityTitle]}),a?(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[(0,r.jsx)(X,{label:s.activityLastInvocation,value:W(e.runtimeLastActivityAt)}),(0,r.jsx)(X,{label:s.activityTotal,value:e.runtimeConversationSignal?"Active":"—"}),(0,r.jsx)(X,{label:s.activityLast7d,value:e.runtimeUsageSignal?"Active":"—"})]}):(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-card/30 px-4 py-6 text-center",children:[(0,r.jsx)(h.A,{size:20,className:"text-muted-foreground/30 mx-auto mb-2"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:s.activityNoData})]})]})}function X({label:e,value:t}){return(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-muted/10 px-3 py-2.5",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider mb-0.5",children:e}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground font-mono tabular-nums",children:t})]})}}},e=>{e.O(0,[9186,8409,7637,5581,8252,6636,7249,8441,3794,7358],()=>e(e.s=74009)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2114],{74009:(e,t,s)=>{Promise.resolve().then(s.bind(s,96485))},96485:(e,t,s)=>{"use strict";s.d(t,{default:()=>J});var r=s(95155),a=s(98500),n=s.n(a),l=s(12115),i=s(80723),o=s(49387),d=s(68459),c=s(15573),u=s(53961),m=s(61878),x=s(41585),p=s(67635),g=s(92451),b=s(73035),f=s(84755),h=s(93219),v=s(6296),j=s(52905),N=s(44478),y=s(439),k=s(84980),w=s(3926),S=s(93631),A=s(10762),C=s(97810),M=s(12651),z=s(13545),R=s(66088),T=s(35581),F=s(4235),E=s(91337),P=s(70617),$=s(2857),O=s(22356),D=s(7834),L=s(13845),I=s(3590),U=s(39498),_=s(85641),H=s(90777);function J({agentKey:e}){let{t}=(0,T.Y)(),s=t.agentsContent,a=t.panels.agents,h=(0,P.kr)(),v=(0,$.V)(),j=(0,l.useMemo)(()=>h.agents.find(t=>t.key===e),[h.agents,e]),[N,y]=(0,l.useState)(""),[k,w]=(0,l.useState)("all"),[S,A]=(0,l.useState)(null),[C,M]=(0,l.useState)(null),[z,R]=(0,l.useState)(""),[E,J]=(0,l.useState)(null),[q,B]=(0,l.useState)(!1),[X,Z]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(null),[es,er]=(0,l.useState)(null),[ea,en]=(0,l.useState)(null),[el,ei]=(0,l.useState)(null),[eo,ed]=(0,l.useState)(null),[ec,eu]=(0,l.useState)(null),[em,ex]=(0,l.useState)(!1),[ep,eg]=(0,l.useState)(!1),eb=(0,l.useCallback)(async()=>{if(j?.isCustom)try{let e=await fetch("/api/agents/custom",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:j.key})});if(e.ok)F.oR.success(s.overview.customAgentRemoved(j.name)),h.refresh(),window.location.href="/agents";else{let t=await e.json();F.oR.error(t.error||s.overview.customAgentFailedRemove)}}catch{F.oR.error(s.overview.customAgentNetworkError)}finally{eg(!1)}},[j,s.overview,h]),ef=(0,l.useMemo)(()=>(0,I.qC)(h.skills,{query:N,source:k}),[h.skills,N,k]),eh=(0,l.useMemo)(()=>({total:h.skills.length,enabled:h.skills.filter(e=>e.enabled).length,builtin:h.skills.filter(e=>"builtin"===e.source).length,user:h.skills.filter(e=>"user"===e.source).length}),[h.skills]),ev=(0,l.useMemo)(()=>{let e=(0,I.HL)(h.agents),t=new Map;for(let s of e)t.set(s.serverName,s.agents);return t},[h.agents]),ej=(0,l.useMemo)(()=>{let e=(0,I.x3)(h.agents),t=new Map;for(let s of e)t.set(s.skillName,s.agents);return t},[h.agents]),eN="mindos"===e,ey=j?(0,I.yv)(j):"notFound",ek=j?.scope==="project"?"project":"global",ew=j?.transport==="http"?"http":"stdio",eS=(0,l.useMemo)(()=>j?(0,L.$k)(j,h.status,ew):{snippet:"",path:""},[j,h.status,ew]),eA=(0,l.useMemo)(()=>new Set(h.skills.map(e=>e.name)),[h.skills]),eC=(0,l.useMemo)(()=>(j?.installedSkillNames??[]).filter(e=>!eA.has(e)),[j?.installedSkillNames,eA]),eM=j?.configuredMcpServers??[],ez=(0,l.useCallback)(async(e,t)=>{A(e),J(null);try{await h.toggleSkill(e,t),await h.refresh()}finally{A(null)}},[h]),eR=(0,l.useCallback)(async e=>{J(null),A(e);try{let t=await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",name:e})});M(e),R(t.content)}catch(e){J(e instanceof Error?e.message:s.detail.skillReadFailed)}finally{A(null)}},[s.detail.skillReadFailed]),eT=(0,l.useCallback)(async()=>{if(C){B(!0),J(null);try{await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update",name:C,content:z})}),M(null),R(""),window.dispatchEvent(new Event("mindos:skills-changed")),await h.refresh()}catch(e){J(e instanceof Error?e.message:s.detail.skillSaveFailed)}finally{B(!1)}}},[C,z,s.detail.skillSaveFailed,h]),eF=(0,l.useCallback)(async e=>{er(null),A(e);try{await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",name:e})}),en(s.detail.skillDeleteSuccess),window.dispatchEvent(new Event("mindos:skills-changed")),await h.refresh()}catch{en(s.detail.skillDeleteFailed)}finally{A(null),setTimeout(()=>en(null),3e3)}},[s.detail.skillDeleteSuccess,s.detail.skillDeleteFailed,h]),eE=(0,l.useCallback)(async e=>{if(j?.skillWorkspacePath){A(e),J(null);try{(await (0,O.n)("/api/agents/copy-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillName:e,targetPath:j.skillWorkspacePath})})).success&&(F.oR.success(`Skill "${e}" copied to ${j.name}`),await h.refresh())}catch(t){let e=t instanceof Error?t.message:"Failed to copy skill";J(e),F.oR.error(e)}finally{A(null)}}},[j,h]),eP=(0,l.useCallback)(async()=>{await (0,D.l)(eS.snippet)&&F.oR.copy()},[eS.snippet]),e$=(0,l.useCallback)(async(e,t)=>{if(j){Z(!0),et(s.detail.mcpApplying);try{let r=await h.installAgent(j.key,{scope:e,transport:t});await h.refresh(),et(r?s.detail.mcpApplySuccess:s.detail.mcpApplyFailed)}finally{Z(!1)}}},[s.detail.mcpApplying,s.detail.mcpApplySuccess,s.detail.mcpApplyFailed,h,j]),eO=(0,l.useCallback)(async e=>{await (0,O.n)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",name:e})}),window.dispatchEvent(new Event("mindos:skills-changed")),await h.refresh()},[h]),eD=(0,l.useCallback)(()=>{ei(null),ed(s.detail.mcpServerHint),setTimeout(()=>ed(null),4e3)},[s.detail.mcpServerHint]);if(!j){let t=h.agents.filter(t=>t.key!==e&&"connected"===(0,I.yv)(t)).slice(0,3);return(0,r.jsxs)("div",{className:"content-width px-4 md:px-6 py-8 md:py-10",children:[(0,r.jsxs)(n(),{href:"/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground mb-4",children:[(0,r.jsx)(i.A,{size:14}),s.backToOverview]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6 space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground font-medium",children:s.detailNotFound}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:s.detailNotFoundHint}),t.length>0&&(0,r.jsxs)("div",{className:"pt-2 border-t border-border",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:s.detailNotFoundSuggestion}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:t.map(e=>(0,r.jsx)(n(),{href:`/agents/${encodeURIComponent(e.key)}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-muted text-foreground hover:bg-muted/80 transition-colors",children:e.name},e.key))})]})]})]})}return(0,r.jsxs)("div",{className:"content-width px-4 md:px-6 py-8 md:py-10 space-y-4",children:[(0,r.jsxs)(n(),{href:"/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,r.jsx)(i.A,{size:14}),s.backToOverview]}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3.5 px-5 py-4",children:[(0,r.jsx)(U.lx,{name:j.name,status:ey,size:"md"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-foreground truncate",children:j.name}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 mt-0.5 text-2xs text-muted-foreground/60",children:[(0,r.jsx)("span",{className:`font-medium px-1.5 py-px rounded-full ${"connected"===ey?"bg-muted text-muted-foreground":"detected"===ey?"bg-[var(--amber-subtle)] text-[var(--amber-text)]":"bg-error/10 text-error"}`,children:ey}),(0,r.jsx)("span",{className:"font-mono",children:j.transport??j.preferredTransport}),(0,r.jsx)("span",{className:"text-muted-foreground/25","aria-hidden":"true",children:"\xb7"}),(0,r.jsx)("span",{children:j.skillMode??s.na})]})]}),j.isCustom&&(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>ex(!0),className:"w-8 h-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted transition-colors duration-150 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s.overview.customAgentEdit,title:s.overview.customAgentEdit,children:(0,r.jsx)(o.A,{size:14})}),(0,r.jsx)("button",{type:"button",onClick:()=>eg(!0),className:"w-8 h-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors duration-150 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":s.overview.customAgentRemove,title:s.overview.customAgentRemove,children:(0,r.jsx)(d.A,{size:14})})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-2xs text-muted-foreground/50 px-5 py-2 border-t border-border/40",children:[(0,r.jsxs)("span",{children:[j.format," ",(0,r.jsx)("span",{className:"text-muted-foreground/30",children:"\xb7"})," ",W(j.runtimeLastActivityAt)]}),(0,r.jsxs)("span",{className:"tabular-nums",children:[eM.length," MCP ",(0,r.jsx)("span",{className:"text-muted-foreground/30",children:"\xb7"})," ",eC.length," skills"]})]})]}),(0,r.jsx)(G,{}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(c.A,{size:13,className:"text-[var(--amber)]"})}),s.detail.mcpManagement]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[!eN&&(0,r.jsx)(U.rA,{onClick:()=>void eP(),disabled:!1,busy:!1,label:s.detail.mcpCopySnippet}),(0,r.jsx)(U.rA,{onClick:()=>void h.refresh(),disabled:!1,busy:!1,label:s.detail.mcpRefresh}),!eN&&(0,r.jsx)(U.rA,{onClick:()=>void e$(ek,ew),disabled:X,busy:X,label:s.detail.mcpReconnect})]})]}),ee&&(0,r.jsx)("p",{className:"text-2xs text-muted-foreground animate-in fade-in duration-200",children:ee}),(0,r.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:eN?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V,{label:"Status",value:h.status?.running?"Running":"Stopped"}),(0,r.jsx)(V,{label:"Endpoint",value:h.status?.endpoint??s.na}),(0,r.jsx)(V,{label:"Tools",value:h.status?.toolCount!=null?String(h.status.toolCount):s.na})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V,{label:s.detail.mcpInstalled,value:j.installed?s.detail.yes:s.detail.no}),(0,r.jsx)(V,{label:s.detail.mcpScope,value:j.scope??s.na}),(0,r.jsx)(V,{label:s.detail.mcpConfigPath,value:j.configPath??s.na})]})}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground/60 uppercase tracking-wider",children:s.detail.configuredMcpServers}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/40 tabular-nums",children:eM.length})]}),eo&&(0,r.jsx)("div",{role:"status","aria-live":"polite",className:"rounded-md border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground animate-in fade-in duration-200",children:eo}),0===eM.length?(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:s.detail.configuredMcpServersEmpty}):(0,r.jsx)("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:eM.map(e=>{let t=(ev.get(e)??[]).filter(e=>e!==j.name);return(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 group/mcp hover:bg-muted/30 transition-colors duration-100",children:[(0,r.jsx)(c.A,{size:11,className:"text-muted-foreground/40 shrink-0"}),(0,r.jsx)("span",{className:"text-xs text-foreground flex-1 min-w-0 truncate",children:e}),t.length>0&&(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[t.slice(0,3).map(e=>(0,r.jsx)(U.lx,{name:e,size:"sm"},e)),t.length>3&&(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/50",children:["+",t.length-3]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>ei(e),className:"text-muted-foreground/40 hover:text-destructive cursor-pointer opacity-0 group-hover/mcp:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded p-0.5 transition-all duration-150","aria-label":`${s.detail.mcpServerRemove} ${e}`,children:(0,r.jsx)(d.A,{size:11})})]},e)})})]})]}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(u.A,{size:13,className:"text-[var(--amber)]"})}),s.detail.skillAssignments]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-2xs text-muted-foreground/50 tabular-nums",children:[(0,r.jsxs)("span",{children:[eh.enabled,"/",eh.total," enabled"]}),(0,r.jsx)("span",{className:"text-muted-foreground/25",children:"\xb7"}),(0,r.jsxs)("span",{children:[eC.length," native"]})]})]}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-2",children:[(0,r.jsxs)("label",{className:"relative flex-1",children:[(0,r.jsx)(m.A,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),(0,r.jsx)("input",{value:N,onChange:e=>y(e.target.value),placeholder:s.detail.skillsSearchPlaceholder,className:"w-full h-9 rounded-md border border-border bg-background pl-8 pr-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors duration-150"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5 bg-background",children:[(0,r.jsx)(U.KF,{active:"all"===k,label:s.detail.skillsFilterAll,onClick:()=>w("all")}),(0,r.jsx)(U.KF,{active:"builtin"===k,label:s.detail.skillsFilterBuiltin,onClick:()=>w("builtin")}),(0,r.jsx)(U.KF,{active:"user"===k,label:s.detail.skillsFilterUser,onClick:()=>w("user")})]})]}),ea&&(0,r.jsx)("div",{role:"status","aria-live":"polite",className:"rounded-md border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground animate-in fade-in duration-200",children:ea}),j?.skillMode==="unsupported"&&(0,r.jsxs)("div",{className:"rounded-lg border border-[var(--amber)]/20 bg-[var(--amber-dim)] p-3 mb-2",children:[(0,r.jsxs)("p",{className:"text-sm font-medium text-foreground mb-2 flex items-center gap-1.5",children:[(0,r.jsx)(x.A,{size:14,className:"text-[var(--amber)] shrink-0","aria-hidden":"true"}),"Manual Skill Installation"]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground mb-3",children:["This agent doesn't support ",(0,r.jsx)("code",{className:"bg-background px-1 py-0.5 rounded text-xs font-mono",children:"npx skills"}),". Copy skills manually:"]}),(0,r.jsxs)("div",{className:"bg-background rounded-md px-3 py-2 font-mono text-xs overflow-x-auto border border-border/50 select-all",children:["cp -r ~/.mindos/skills/<skill-name> ",j.skillWorkspacePath||"~/.agent/skills/"]})]}),ef.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5",children:["MindOS Skills ",(0,r.jsxs)("span",{className:"tabular-nums",children:["(",ef.filter(e=>e.enabled).length,"/",ef.length,")"]})]}),(0,r.jsx)("ul",{className:"space-y-0.5",children:ef.map(e=>{let t=C===e.name;return(0,r.jsxs)("li",{className:"rounded-md hover:bg-muted/30 transition-colors duration-100",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-1.5 group/skill",children:[(0,r.jsx)(u.A,{size:13,className:`shrink-0 ${e.enabled?"text-[var(--amber)]":"text-muted-foreground/50"}`,"aria-hidden":"true"}),(0,r.jsx)("button",{type:"button",onClick:()=>eu(e.name),className:"text-xs text-foreground flex-1 min-w-0 truncate hover:text-[var(--amber)] cursor-pointer transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded text-left",children:e.name}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded shrink-0 ${"builtin"===e.source?"bg-muted text-muted-foreground":"bg-[var(--amber-dim)] text-[var(--amber-text)]"}`,children:"builtin"===e.source?s.detail.skillsSourceBuiltin:s.detail.skillsSourceUser}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0 md:opacity-0 md:group-hover/skill:opacity-100 md:focus-within:opacity-100 transition-opacity duration-150",children:[(0,r.jsx)(U.rA,{onClick:()=>void ez(e.name,!e.enabled),disabled:S===e.name,busy:S===e.name,label:e.enabled?s.detail.skillDisable:s.detail.skillEnable}),e.editable&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(U.rA,{onClick:()=>void eR(e.name),disabled:S===e.name||q,busy:!1,label:s.detail.skillEdit}),(0,r.jsx)("button",{type:"button",onClick:()=>er(e.name),disabled:S===e.name,className:"inline-flex items-center justify-center min-h-[28px] px-1.5 rounded-md text-muted-foreground hover:text-destructive cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-150","aria-label":`${s.detail.skillDelete} ${e.name}`,children:(0,r.jsx)(d.A,{size:13})})]}),j?.skillMode==="unsupported"&&(0,r.jsx)("button",{type:"button",onClick:()=>void eE(e.name),disabled:S===e.name,className:"inline-flex items-center justify-center min-h-[28px] px-1.5 rounded-md text-muted-foreground hover:text-[var(--amber)] cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-150",title:`Copy ${e.name} to ${j.name}`,"aria-label":`Copy ${e.name} to ${j.name}`,children:(0,r.jsx)(p.A,{size:13})})]})]}),t&&(0,r.jsxs)("div",{className:"px-3 pb-3 pt-0 space-y-2",children:[(0,r.jsx)("textarea",{value:z,onChange:e=>R(e.target.value),className:"mt-2 w-full h-40 rounded-md border border-border bg-background px-3 py-2 text-xs font-mono text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring resize-y"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(U.rA,{onClick:()=>void eT(),disabled:q,busy:q,label:s.detail.skillSave,variant:"primary"}),(0,r.jsx)(U.rA,{onClick:()=>M(null),disabled:!1,busy:!1,label:s.detail.skillCancel})]})]})]},e.name)})})]}),0===ef.length&&0===eC.length&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:s.detail.noSkills}),eC.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5",children:[s.detail.nativeInstalledSkills," ",(0,r.jsxs)("span",{className:"tabular-nums",children:["(",eC.length,")"]})]}),(0,r.jsx)("div",{className:"space-y-0.5 max-h-[280px] overflow-y-auto",children:eC.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>eu(e),className:"w-full flex items-center gap-2 py-1.5 px-1.5 rounded-md hover:bg-muted/30 transition-colors duration-100 cursor-pointer text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(u.A,{size:13,className:"shrink-0 text-muted-foreground/50","aria-hidden":"true"}),(0,r.jsx)("span",{className:"text-xs text-foreground flex-1 min-w-0 truncate hover:text-[var(--amber)] transition-colors duration-150",children:e})]},e))})]}),E&&(0,r.jsx)("p",{className:"text-xs text-error",children:E})]}),(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(g.A,{size:13,className:"text-[var(--amber)]"})}),a.a2aCapabilities]}),(0,r.jsx)("span",{className:`text-2xs px-1.5 py-0.5 rounded font-medium shrink-0 ${"connected"===ey?"bg-[var(--success)]/15 text-[var(--success)]":"bg-muted text-muted-foreground/60"}`,children:"connected"===ey?a.a2aConnected:a.a2aUnavailable})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:[(0,r.jsx)(V,{label:a.a2aStatus,value:"connected"===ey?a.a2aConnected:a.a2aUnavailable}),(0,r.jsx)(V,{label:s.detail.transport,value:j.transport??j.preferredTransport}),v.agents.length>0&&(0,r.jsx)(V,{label:"Remote agents",value:String(v.agents.length)})]}),v.agents.length>0?(0,r.jsx)("div",{className:"space-y-1",children:v.agents.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2.5 rounded-md px-2 py-1.5 hover:bg-muted/30 transition-colors duration-100",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-muted/40 flex items-center justify-center shrink-0",children:(0,r.jsx)(g.A,{size:11,className:"text-muted-foreground/60"})}),(0,r.jsx)("span",{className:"text-xs text-foreground flex-1 min-w-0 truncate",children:e.card.name}),e.reachable?(0,r.jsx)(b.A,{size:11,className:"text-[var(--success)] shrink-0"}):(0,r.jsx)(f.A,{size:11,className:"text-muted-foreground/50 shrink-0"}),(0,r.jsxs)("span",{className:"text-2xs text-muted-foreground/50 tabular-nums shrink-0",children:[e.card.skills.length," skills"]})]},e.id))}):(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:a.a2aNoRemoteHint})]}),(0,r.jsx)(K,{agent:j,status:ey,isMindOS:eN,mcpStatus:h.status}),(0,r.jsx)(Y,{agent:j,isMindOS:eN}),(0,r.jsx)(Q,{agent:j}),(0,r.jsx)(U.TM,{open:null!==es,title:s.detail.skillDelete,message:es?s.detail.skillDeleteConfirm(es):"",confirmLabel:s.detail.skillDelete,cancelLabel:s.detail.skillCancel,onConfirm:()=>es&&void eF(es),onCancel:()=>er(null),variant:"destructive"}),(0,r.jsx)(U.TM,{open:null!==el,title:s.detail.mcpServerRemove,message:el?s.detail.mcpServerRemoveConfirm(el):"",confirmLabel:s.detail.mcpServerRemove,cancelLabel:s.detail.skillCancel,onConfirm:eD,onCancel:()=>ei(null),variant:"destructive"}),(0,r.jsx)(_.A,{open:null!==ec,skillName:ec,skill:ec?h.skills.find(e=>e.name===ec)??null:null,agentNames:ec?ej.get(ec)??[]:[],isNative:!!ec&&!h.skills.some(e=>e.name===ec),nativeSourcePath:j?.installedSkillSourcePath,copy:s.skills.skillPopover,onClose:()=>eu(null),onToggle:h.toggleSkill,onDelete:eO,onRefresh:h.refresh}),j?.isCustom&&(0,r.jsx)(H.A,{open:em,onClose:()=>ex(!1),onSuccess:()=>{h.refresh(),ex(!1)},existingAgents:h.agents,editAgent:j}),(0,r.jsx)(U.TM,{open:ep,title:j?s.overview.customAgentRemoveTitle(j.name):"",message:s.overview.customAgentRemoveMessage,confirmLabel:s.overview.customAgentRemoveConfirm,cancelLabel:s.detail.skillCancel,onConfirm:eb,onCancel:()=>eg(!1),variant:"destructive"})]})}function V({label:e,value:t}){return(0,r.jsxs)("div",{className:"flex items-baseline gap-2 px-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider shrink-0 min-w-[60px]",children:e}),(0,r.jsx)("span",{className:"text-xs text-foreground/80 font-mono truncate min-w-0",children:t})]})}function W(e){if(!e)return"—";try{let t=Date.now()-new Date(e).getTime();if(t<0)return"just now";let s=Math.floor(t/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;let r=Math.floor(s/60);if(r<24)return`${r}h ago`;let a=Math.floor(r/24);return`${a}d ago`}catch{return e}}function K({agent:e,status:t,isMindOS:s,mcpStatus:a}){let{t:n}=(0,T.Y)(),i=n.agentsContent.detail,[o,d]=(0,l.useState)("idle"),[c,u]=(0,l.useState)(0),m=(0,l.useCallback)(async()=>{d("pinging");let e=performance.now();try{let t=await fetch("/api/mcp/status",{method:"GET",signal:AbortSignal.timeout(5e3)}),s=Math.round(performance.now()-e);u(s),d(t.ok?"ok":"fail")}catch{d("fail")}},[]);return(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(h.A,{size:13,className:"text-[var(--amber)]"})}),i.runtimeDiagTitle]}),(0,r.jsx)("button",{type:"button",onClick:()=>void m(),disabled:"pinging"===o,className:"inline-flex items-center gap-1 px-2.5 py-1 text-2xs font-medium rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"pinging"===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.A,{size:10,className:"animate-spin"})," ",i.runtimePinging]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.A,{size:10})," ",i.runtimePing]})})]}),"ok"===o&&(0,r.jsx)("div",{role:"status",className:"rounded-md bg-[var(--success)]/10 border border-[var(--success)]/20 px-3 py-1.5 text-2xs text-[var(--success)] font-medium animate-in fade-in duration-200",children:i.runtimePingOk(c)}),"fail"===o&&(0,r.jsx)("div",{role:"status",className:"rounded-md bg-error/10 border border-error/20 px-3 py-1.5 text-2xs text-error font-medium animate-in fade-in duration-200",children:i.runtimePingFail}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:[(0,r.jsx)(V,{label:i.status,value:t}),(0,r.jsx)(V,{label:i.transport,value:e.transport??e.preferredTransport}),s&&a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V,{label:i.runtimeVersion,value:a.endpoint}),(0,r.jsx)(V,{label:i.port,value:String(a.port)})]}),(0,r.jsx)(V,{label:i.lastActivityAt,value:W(e.runtimeLastActivityAt)}),void 0!==e.runtimeConversationSignal&&(0,r.jsx)(V,{label:i.conversationSignal,value:e.runtimeConversationSignal?"Active":"Inactive"}),void 0!==e.runtimeUsageSignal&&(0,r.jsx)(V,{label:i.usageSignal,value:e.runtimeUsageSignal?"Active":"Inactive"})]}),!e.runtimeLastActivityAt&&"idle"===o&&(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:i.runtimeNoData})]})}function Y({agent:e,isMindOS:t}){let{t:s}=(0,T.Y)(),a=s.agentsContent.detail,n=e.scope??(e.hasProjectScope?"project":e.hasGlobalScope?"global":"—");e.hiddenRootPresent;let l=[{label:a.envFileAccess,allowed:!0},{label:a.envNetworkAccess,allowed:"http"===e.transport||t},{label:a.envWriteAccess,allowed:!0},{label:a.envReadOnly,allowed:!1}];return(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(j.A,{size:13,className:"text-[var(--amber)]"})}),a.envPermTitle]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 py-2 border-y border-border/30",children:[(0,r.jsx)(V,{label:a.envScope,value:n}),(0,r.jsx)(V,{label:a.format,value:e.format}),e.hiddenRootPath&&(0,r.jsx)(V,{label:a.hiddenRoot,value:e.hiddenRootPath}),(0,r.jsx)(V,{label:a.skillMode,value:e.skillMode??"—"})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground/60 uppercase tracking-wider mb-1.5",children:a.envVars}),e.configuredMcpServers&&e.configuredMcpServers.length>0?(0,r.jsx)("p",{className:"text-2xs text-muted-foreground",children:a.envVarsCount(e.configuredMcpServers.length)}):(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:a.envVarsEmpty})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("p",{className:"text-2xs font-medium text-muted-foreground/60 uppercase tracking-wider",children:"Permissions"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:l.map(({label:e,allowed:t})=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-1.5 bg-muted/20",children:[t?(0,r.jsx)(N.A,{size:12,className:"text-[var(--success)] shrink-0"}):(0,r.jsx)(y.A,{size:12,className:"text-muted-foreground/40 shrink-0"}),(0,r.jsx)("span",{className:"text-2xs text-foreground/80",children:e}),(0,r.jsx)("span",{className:`ml-auto text-2xs font-medium ${t?"text-[var(--success)]":"text-muted-foreground/50"}`,children:t?a.envAllowed:a.envRestricted})]},e))})]})]})}function q(e){return/search/.test(e)?"search":/read|list|get/.test(e)?"read":/create|batch_create/.test(e)?"create":/delete/.test(e)?"delete":/write|update|insert|append|edit|rename|move/.test(e)?"write":"other"}let B={read:{icon:k.A,color:"text-blue-400"},write:{icon:w.A,color:"text-[var(--amber)]"},create:{icon:S.A,color:"text-[var(--success)]"},delete:{icon:d.A,color:"text-[var(--error)]"},search:{icon:m.A,color:"text-purple-400"},other:{icon:A.A,color:"text-muted-foreground"}};function G(){let{t:e}=(0,T.Y)(),t=e.agentsContent?.detail,[s,a]=(0,l.useState)([]),[i,o]=(0,l.useState)(!0),[d,c]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=!1,t=()=>{fetch("/api/agent-activity?limit=50").then(e=>e.json()).then(t=>{e||a(t.events??[])}).catch(()=>{}).finally(()=>{e||o(!1)})};t();let s=()=>{"visible"===document.visibilityState&&t()};return document.addEventListener("visibilitychange",s),()=>{e=!0,document.removeEventListener("visibilitychange",s)}},[]);let u=(0,l.useMemo)(()=>{if(0===s.length)return null;let e=s.filter(e=>"read"===q(e.tool)).length,t=s.filter(e=>["write","create","delete"].includes(q(e.tool))).length,r=s.filter(e=>"error"===e.result).length,a=s.filter(e=>"number"==typeof e.durationMs).map(e=>e.durationMs),n=a.length>0?Math.round(a.reduce((e,t)=>e+t,0)/a.length):null,l=new Set;for(let e of s){let t=e.params.path;"string"==typeof t&&l.add(t)}let i=s.length>0?Math.round(r/s.length*100):0;return{total:s.length,reads:e,writes:t,errors:r,errorRate:i,avgMs:n,filesCount:l.size}},[s]),m=(0,l.useMemo)(()=>{let e=s.filter(e=>{let t=q(e.tool);return"write"===t||"create"===t||"delete"===t});return e.length>=3?e:s},[s]),x=d?m:m.slice(0,5),p=m.length-5;return i?(0,r.jsx)("section",{className:"rounded-xl border border-border bg-card p-4",children:(0,r.jsx)("div",{className:"flex justify-center py-6",children:(0,r.jsx)(v.A,{size:16,className:"animate-spin text-muted-foreground"})})}):0===s.length?(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(C.A,{size:13,className:"text-[var(--amber)]"})}),t?.knowledgeInteraction??"Knowledge Interaction"]}),(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-card/30 px-4 py-6 text-center",children:[(0,r.jsx)(C.A,{size:20,className:"text-muted-foreground/30 mx-auto mb-2"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:t?.knowledgeNoData??"No interactions yet. Agents will show activity here once they start working with your knowledge base."})]})]}):(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4 pb-2",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(C.A,{size:13,className:"text-[var(--amber)]"})}),t?.knowledgeInteraction??"Knowledge Interaction"]}),(0,r.jsxs)(n(),{href:`/view/${(0,E.O0)(".mindos/agent-audit-log.json")}`,className:"text-2xs font-medium text-[var(--amber)] hover:opacity-80 transition-opacity",children:[t?.viewFullLog??"View log"," →"]})]}),u&&(0,r.jsxs)("div",{className:"flex items-center gap-px mx-4 mb-3 rounded-lg overflow-hidden border border-border/40",children:[(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statTotalCalls??"Calls"}),(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground font-mono tabular-nums leading-none",children:u.total})]}),(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20 border-l border-border/30",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statFilesTouched??"Files"}),(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground font-mono tabular-nums leading-none",children:u.filesCount})]}),(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20 border-l border-border/30",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statReadWrite??"R / W"}),(0,r.jsxs)("p",{className:"text-sm font-semibold text-foreground font-mono tabular-nums leading-none",children:[(0,r.jsx)("span",{className:"text-blue-400",children:u.reads}),(0,r.jsx)("span",{className:"text-muted-foreground/30 mx-0.5",children:"/"}),(0,r.jsx)("span",{className:"text-[var(--amber)]",children:u.writes})]})]}),(0,r.jsxs)("div",{className:"flex-1 px-3 py-2 bg-muted/20 border-l border-border/30",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 leading-none mb-1",children:t?.statHealth??"Health"}),(0,r.jsx)("p",{className:"text-sm font-semibold font-mono tabular-nums leading-none",children:u.errors>0?(0,r.jsxs)("span",{className:"text-[var(--error)]",children:[u.errorRate,"% err"]}):(0,r.jsx)("span",{className:"text-[var(--success)]",children:"100%"})})]})]}),(0,r.jsxs)("div",{className:"border-t border-border/40",children:[(0,r.jsx)("div",{className:"px-4 py-2 flex items-center justify-between",children:(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/40 uppercase tracking-wider",children:t?.recentOps??"Recent operations"})}),x.map((e,t)=>{let{icon:s,color:a}=B[q(e.tool)],l="string"==typeof e.params.path?e.params.path:null,i=e.tool.replace(/^mindos_/,"");return(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border/20 hover:bg-muted/20 transition-colors",children:[(0,r.jsx)("div",{className:"w-5 h-5 rounded-md bg-muted/40 flex items-center justify-center shrink-0",children:(0,r.jsx)(s,{size:11,className:a})}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground/80 font-mono shrink-0 min-w-[90px]",children:i}),l?(0,r.jsx)(n(),{href:`/view/${(0,E.O0)(l)}`,className:"text-xs text-muted-foreground hover:text-[var(--amber)] truncate min-w-0 flex-1 font-mono transition-colors",title:l,children:l}):(0,r.jsx)("span",{className:"flex-1"}),"ok"===e.result?(0,r.jsx)(M.A,{size:10,className:"shrink-0 text-[var(--success)]/40"}):(0,r.jsx)(z.A,{size:10,className:"shrink-0 text-[var(--error)]/60"}),(0,r.jsx)("span",{className:"text-2xs text-muted-foreground/30 tabular-nums shrink-0 font-mono w-[28px] text-right",title:e.ts,children:function(e){let t=Date.now()-new Date(e).getTime(),s=Math.floor(t/6e4);if(s<1)return"<1m";if(s<60)return`${s}m`;let r=Math.floor(t/36e5);return r<24?`${r}h`:`${Math.floor(t/864e5)}d`}(e.ts)})]},e.id??t)})]}),p>0&&(0,r.jsx)("div",{className:"px-4 py-2 border-t border-border/20",children:(0,r.jsxs)("button",{onClick:()=>c(e=>!e),className:"flex items-center gap-1.5 text-xs font-medium text-[var(--amber)] hover:opacity-80 transition-opacity cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded",children:[(0,r.jsx)(R.A,{size:12,className:`transition-transform duration-200 ${d?"rotate-180":""}`}),(0,r.jsx)("span",{children:d?t?.showLess??"Show less":`${p} more`})]})})]})}function Q({agent:e}){let{t}=(0,T.Y)(),s=t.agentsContent.detail,a=!!e.runtimeLastActivityAt;return(0,r.jsxs)("section",{className:"rounded-xl border border-border bg-card p-4 space-y-3",children:[(0,r.jsxs)("h2",{className:"text-xs font-semibold text-foreground flex items-center gap-2 shrink-0",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--amber-subtle)] flex items-center justify-center",children:(0,r.jsx)(h.A,{size:13,className:"text-[var(--amber)]"})}),s.activityTitle]}),a?(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[(0,r.jsx)(X,{label:s.activityLastInvocation,value:W(e.runtimeLastActivityAt)}),(0,r.jsx)(X,{label:s.activityTotal,value:e.runtimeConversationSignal?"Active":"—"}),(0,r.jsx)(X,{label:s.activityLast7d,value:e.runtimeUsageSignal?"Active":"—"})]}):(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-card/30 px-4 py-6 text-center",children:[(0,r.jsx)(h.A,{size:20,className:"text-muted-foreground/30 mx-auto mb-2"}),(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50",children:s.activityNoData})]})]})}function X({label:e,value:t}){return(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-muted/10 px-3 py-2.5",children:[(0,r.jsx)("p",{className:"text-2xs text-muted-foreground/50 uppercase tracking-wider mb-0.5",children:e}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground font-mono tabular-nums",children:t})]})}}},e=>{e.O(0,[9186,8409,5149,5581,8252,6636,7249,8441,3794,7358],()=>e(e.s=74009)),_N_E=e.O()}]);
|