@undefineds.co/xpod 0.4.17 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/config/xpod.base.json +3 -0
  2. package/dist/components/context.jsonld +14 -0
  3. package/dist/identity/ValidatingIdentityProviderHttpHandler.d.ts +32 -1
  4. package/dist/identity/ValidatingIdentityProviderHttpHandler.js +53 -1
  5. package/dist/identity/ValidatingIdentityProviderHttpHandler.jsonld +53 -0
  6. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +39 -10
  7. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsList.js +15 -4
  8. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +1 -1
  9. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +4 -1
  10. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +5 -1
  11. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.js +2 -2
  12. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +5 -1
  13. package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +4 -0
  14. package/node_modules/@undefineds.co/ai-connections/dist/controller.js +3 -1
  15. package/node_modules/@undefineds.co/extension-sdk/dist/layout.d.ts +39 -0
  16. package/node_modules/@undefineds.co/extension-sdk/dist/layout.js +40 -0
  17. package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.d.ts +13 -1
  18. package/node_modules/@undefineds.co/extension-sdk/dist/react/app-layout.js +11 -3
  19. package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.d.ts +13 -4
  20. package/node_modules/@undefineds.co/extension-sdk/dist/react/workspace-layout.js +68 -11
  21. package/node_modules/@undefineds.co/shared-ui/dist/auth-surface.js +6 -6
  22. package/node_modules/@undefineds.co/shared-ui/dist/dialog.js +4 -4
  23. package/node_modules/@undefineds.co/shared-ui/dist/login.js +1 -1
  24. package/node_modules/@undefineds.co/shared-ui/dist/theme.css +128 -79
  25. package/node_modules/@undefineds.co/shared-ui/dist/toast.js +1 -1
  26. package/node_modules/@undefineds.co/shared-ui/dist/tooltip.js +1 -1
  27. package/node_modules/@undefineds.co/solid-sdk/dist/access-route.cjs +87 -9
  28. package/node_modules/@undefineds.co/solid-sdk/dist/access-route.d.ts +31 -3
  29. package/node_modules/@undefineds.co/solid-sdk/dist/access-route.js +156 -14
  30. package/node_modules/@undefineds.co/solid-sdk/dist/index.cjs +86 -8
  31. package/package.json +2 -2
  32. package/static/app/assets/global.css +1 -0
  33. package/static/app/assets/{index-BCZVzMpj.js → index-BeAi28iA.js} +1 -1
  34. package/static/app/assets/inrupt-smoke.js +37 -36
  35. package/static/app/assets/main.js +3 -3
  36. package/static/app/index.html +2 -2
  37. package/static/app/inrupt-smoke.html +2 -1
  38. package/static/dashboard/assets/{AiConfigContext-BedwuLTE.js → AiConfigContext-DelSqO6L.js} +1 -1
  39. package/static/dashboard/assets/{AiConfigPage-hNTayf8G.js → AiConfigPage-dbg0aDvd.js} +1 -1
  40. package/static/dashboard/assets/DocumentProcessingPanel-0-3nlwQf.js +1 -0
  41. package/static/dashboard/assets/IndexLifecyclePanel-DOI3IxOD.js +1 -0
  42. package/static/dashboard/assets/{IndexSubjectPanel-Bv97-ouZ.js → IndexSubjectPanel-ClDgj0SY.js} +1 -1
  43. package/static/dashboard/assets/ModelAssignmentsPanel-BSWH19oT.js +1 -0
  44. package/static/dashboard/assets/ModelsPage-BrzxCkEl.js +11 -0
  45. package/static/{settings/assets/NetworkPage-D50kdbEu.js → dashboard/assets/NetworkPage-CxEKeaPz.js} +2 -2
  46. package/static/dashboard/assets/{PaneListHeader-ByqK_C6i.js → PaneListHeader-xEjcBu9g.js} +1 -1
  47. package/static/dashboard/assets/SearchIndexingPanel-BGlSvEl5.js +1 -0
  48. package/static/dashboard/assets/{StatusSubjectPanel-DPegcFpA.js → StatusSubjectPanel-6s3JXbOd.js} +1 -1
  49. package/static/dashboard/assets/StatusWorkspace-LYMDa4b0.js +1 -0
  50. package/static/dashboard/assets/{SystemSettingsPage-LyXmd6uP.js → SystemSettingsPage-CF_vH-qe.js} +1 -1
  51. package/static/dashboard/assets/SystemSettingsSubjectPanel-hsfHcJRV.js +33 -0
  52. package/static/dashboard/assets/{XpodAiConnectionsPodStore-DXNERI2-.js → XpodAiConnectionsPodStore-CHM-ZwI3.js} +1 -1
  53. package/static/dashboard/assets/{activity-BwRbcTha.js → activity-B7UdTZ1N.js} +1 -1
  54. package/static/dashboard/assets/{badge-BbRb9MsQ.js → badge-B6RuxNt1.js} +1 -1
  55. package/static/dashboard/assets/collection-runtime-CKBQm3Fl.js +1 -0
  56. package/static/dashboard/assets/dashboard-1zrtbMhM.css +1 -0
  57. package/static/dashboard/assets/{dashboard-D2ozrATv.js → dashboard-Dm_h60lA.js} +175 -135
  58. package/static/dashboard/assets/{download-SIHe8Y5t.js → download-BW035kpj.js} +1 -1
  59. package/static/dashboard/assets/{external-link-CiYw5Q4U.js → external-link-BMrNvf3c.js} +1 -1
  60. package/static/dashboard/assets/{index-DC1jRaVA.js → index-2jlFzexm.js} +1 -1
  61. package/static/dashboard/assets/index-CQDQ8WVr.js +4 -0
  62. package/static/dashboard/assets/{key-round-nKtxP6pb.js → key-round-C9vxhn7T.js} +1 -1
  63. package/static/dashboard/assets/{rotate-ccw-CQm5hHMN.js → rotate-ccw-8Vm0-INc.js} +1 -1
  64. package/static/dashboard/assets/{skeleton-TKyLbiPs.js → skeleton-CY_602wn.js} +1 -1
  65. package/static/dashboard/assets/{waypoints-BQS9t0ky.js → waypoints-DdEdgkxD.js} +1 -1
  66. package/static/dashboard/assets/workspace-layout-Wed840qR.js +1 -0
  67. package/static/dashboard/dashboard.html +2 -2
  68. package/static/settings/assets/{AiConfigContext-eLRkXFtH.js → AiConfigContext-CR3YhTA-.js} +1 -1
  69. package/static/settings/assets/AiConfigPage-DnOvX2Kx.js +1 -0
  70. package/static/settings/assets/DocumentProcessingPanel-CccpHBs3.js +1 -0
  71. package/static/settings/assets/IndexLifecyclePanel-BrECzBoM.js +1 -0
  72. package/static/settings/assets/{IndexSubjectPanel-DT0c11VQ.js → IndexSubjectPanel-CP84xXye.js} +1 -1
  73. package/static/settings/assets/ModelAssignmentsPanel-DbFi67Kk.js +1 -0
  74. package/static/settings/assets/ModelsPage-xjHA88qy.js +11 -0
  75. package/static/settings/assets/NetworkPage-Bj4wc0bh.js +2 -0
  76. package/static/settings/assets/{PaneListHeader-Da5jZFvG.js → PaneListHeader-Bz0UAhZr.js} +1 -1
  77. package/static/settings/assets/SearchIndexingPanel-ykhvw1Vl.js +1 -0
  78. package/static/settings/assets/{StatusSubjectPanel-Upqqlvon.js → StatusSubjectPanel-B2Y6ib3d.js} +1 -1
  79. package/static/settings/assets/StatusWorkspace-tx3Xg56J.js +1 -0
  80. package/static/settings/assets/SystemSettingsPage-BbFkv_Wn.js +1 -0
  81. package/static/settings/assets/SystemSettingsSubjectPanel-CcbpQmTc.js +33 -0
  82. package/static/settings/assets/{XpodAiConnectionsPodStore-nFgD_usD.js → XpodAiConnectionsPodStore-B11u0BOi.js} +2 -2
  83. package/static/settings/assets/{activity-CWy1W2W0.js → activity-BE8Hz8WF.js} +1 -1
  84. package/static/settings/assets/auth-callback-5waKJF0n.js +1 -0
  85. package/static/settings/assets/{badge-v30yFaaj.js → badge-xeRbYBMf.js} +1 -1
  86. package/static/settings/assets/collection-runtime-DIBObcT5.js +1 -0
  87. package/static/settings/assets/{download-C3Dzb60R.js → download-xI5yyfk7.js} +1 -1
  88. package/static/settings/assets/{external-link-DnkJGKNc.js → external-link-DmbiCMuc.js} +1 -1
  89. package/static/settings/assets/global-1zrtbMhM.css +1 -0
  90. package/static/settings/assets/{global-B_WO-aYY.js → global-BOl78fr8.js} +160 -120
  91. package/static/settings/assets/index-CFVXiUnV.js +4 -0
  92. package/static/settings/assets/index-DK6qlahe.js +1 -0
  93. package/static/settings/assets/{index-browser-DzhsXZHm.js → index-browser-Bk7jaLCd.js} +1 -1
  94. package/static/settings/assets/{key-round-DoDbsLae.js → key-round-B3VIp8oI.js} +1 -1
  95. package/static/settings/assets/{rotate-ccw-DNR_R3oT.js → rotate-ccw-DRzTN49Z.js} +1 -1
  96. package/static/settings/assets/{settings-BOznrBjy.js → settings-CCM17CMX.js} +1 -1
  97. package/static/settings/assets/{skeleton-BjHhu9qI.js → skeleton-Ckhw5HG7.js} +1 -1
  98. package/static/settings/assets/{waypoints-BXNph9Fd.js → waypoints-BFMI-qS6.js} +1 -1
  99. package/static/settings/assets/workspace-layout-Co0KpMKd.js +1 -0
  100. package/static/settings/auth-callback.html +3 -3
  101. package/static/settings/settings.html +3 -3
  102. package/static/app/assets/main.css +0 -1
  103. package/static/dashboard/assets/DocumentProcessingPanel-BSb_vOj7.js +0 -1
  104. package/static/dashboard/assets/IndexLifecyclePanel-DAHx-PBG.js +0 -1
  105. package/static/dashboard/assets/ModelAssignmentsPanel-CEJZs9At.js +0 -1
  106. package/static/dashboard/assets/ModelsPage-DkBVXmKT.js +0 -11
  107. package/static/dashboard/assets/NetworkPage-BDqKgRZQ.js +0 -2
  108. package/static/dashboard/assets/SearchIndexingPanel-M-WYaQP3.js +0 -1
  109. package/static/dashboard/assets/StatusWorkspace-CPIkjO9S.js +0 -1
  110. package/static/dashboard/assets/SystemSettingsSubjectPanel-CYHqNIn2.js +0 -33
  111. package/static/dashboard/assets/collection-runtime-BRfZD5oS.js +0 -1
  112. package/static/dashboard/assets/dashboard-rk080mvG.css +0 -1
  113. package/static/dashboard/assets/dialog-BbRbILBP.js +0 -1
  114. package/static/dashboard/assets/index-CExLoewO.js +0 -41
  115. package/static/dashboard/assets/index-CTgU8YW1.js +0 -4
  116. package/static/dashboard/assets/workspace-layout-Csbbr3vZ.js +0 -1
  117. package/static/settings/assets/AiConfigPage-BMO-ytdK.js +0 -1
  118. package/static/settings/assets/DocumentProcessingPanel-CH-HBRzQ.js +0 -1
  119. package/static/settings/assets/IndexLifecyclePanel-ChEMn9D8.js +0 -1
  120. package/static/settings/assets/ModelAssignmentsPanel-T59L_wOk.js +0 -1
  121. package/static/settings/assets/ModelsPage-m_SP4PdE.js +0 -11
  122. package/static/settings/assets/SearchIndexingPanel-DQQd3-Jw.js +0 -1
  123. package/static/settings/assets/StatusWorkspace-CPB49bGd.js +0 -1
  124. package/static/settings/assets/SystemSettingsPage-C0wrxcNw.js +0 -1
  125. package/static/settings/assets/SystemSettingsSubjectPanel-BOm7tUH1.js +0 -33
  126. package/static/settings/assets/auth-callback-HhgEuohz.js +0 -1
  127. package/static/settings/assets/collection-runtime-B7oomxic.js +0 -1
  128. package/static/settings/assets/dialog-BAe7moyL.js +0 -1
  129. package/static/settings/assets/global-rk080mvG.css +0 -1
  130. package/static/settings/assets/index-B51ot_m_.js +0 -1
  131. package/static/settings/assets/index-CHBQVfuZ.js +0 -41
  132. package/static/settings/assets/index-DbqRFton.js +0 -4
  133. package/static/settings/assets/workspace-layout-TZ7fteel.js +0 -1
  134. /package/static/app/assets/{_commonjsHelpers-B-UnjaXt.js → global-BGMlqT2c.js} +0 -0
@@ -7,8 +7,8 @@
7
7
  <script src="/app/theme-init.js"></script>
8
8
  <title>ui</title>
9
9
  <script type="module" crossorigin src="/app/assets/main.js"></script>
10
- <link rel="modulepreload" crossorigin href="/app/assets/_commonjsHelpers-B-UnjaXt.js">
11
- <link rel="stylesheet" crossorigin href="/app/assets/main.css">
10
+ <link rel="modulepreload" crossorigin href="/app/assets/global-BGMlqT2c.js">
11
+ <link rel="stylesheet" crossorigin href="/app/assets/global.css">
12
12
  </head>
13
13
  <body class="bg-background text-foreground">
14
14
  <div id="root"></div>
@@ -6,7 +6,8 @@
6
6
  <meta name="theme-color" content="#0f172a" />
7
7
  <title>Inrupt Solid Smoke</title>
8
8
  <script type="module" crossorigin src="/app/assets/inrupt-smoke.js"></script>
9
- <link rel="modulepreload" crossorigin href="/app/assets/_commonjsHelpers-B-UnjaXt.js">
9
+ <link rel="modulepreload" crossorigin href="/app/assets/global-BGMlqT2c.js">
10
+ <link rel="stylesheet" crossorigin href="/app/assets/global.css">
10
11
  </head>
11
12
  <body>
12
13
  <main id="app"></main>
@@ -1 +1 @@
1
- import{o as J,r as a,j as V,p as X}from"./dashboard-D2ozrATv.js";import{a as $}from"./ai-connections-Dr4-rSzX.js";import{d as D}from"./XpodAiConnectionsPodStore-DXNERI2-.js";async function R(t){return k(t(h("/api/ai/config"),{method:"GET",credentials:"include",headers:{accept:"application/json"}}))}async function G(t,e){return k(t(h("/api/ai/config"),{method:"PATCH",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(e)}))}async function H(t,e){const o=await t(h("/api/ai/config/rebuild"),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({target:e})}),s=await o.json().catch(()=>{});if(!o.ok||!s?.job)throw new Error(s?.error??"Index rebuild request failed");return s.job}async function ee(t,e){const o=e.capabilities.some(i=>i.toLowerCase()==="embedding"),s=await t(h(o?"/v1/embeddings":"/v1/chat/completions"),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(o?{model:e.id,input:"xpod readiness probe"}:{model:e.id,messages:[{role:"user",content:"Reply OK."}],max_tokens:1,stream:!1})});if(!s.ok){const i=await s.json().catch(()=>{}),d=typeof i?.error=="string"?i.error:i?.error?.message;throw new Error(d??"Model readiness probe failed")}await s.arrayBuffer()}function h(t){if(typeof window>"u")throw new Error("AI Config API requires the current browser origin");return new URL(t,window.location.origin).toString()}async function k(t){const e=await t,o=await e.json().catch(()=>{});if(!e.ok||!o?.config||!o.capabilities)throw new Error(o?.error??"AI Config request failed");return o}const L=a.createContext(void 0),K=2e3;function te({children:t}){const e=J(),[o,s]=a.useState(),[i,d]=a.useState(),[c,p]=a.useState([]),[y,g]=a.useState(),[O,v]=a.useState(!0),[C,M]=a.useState(!1),[I,P]=a.useState(!1),[S,u]=a.useState(),[N,T]=a.useState(0),q=!!(e.webId&&e.currentPod);a.useEffect(()=>{if(!e.webId||!e.currentPod)return;let r=!1;return queueMicrotask(()=>{if(r||!e.webId||!e.currentPod)return;v(!0),u(void 0);const n=$({webId:e.webId,podUrl:e.currentPod.podUrl,authenticatedFetch:e.fetch}),_=D({database:e.currentPod.database,authenticatedFetch:e.fetch,podUrl:e.currentPod.podUrl,webId:e.currentPod.webId}).listModels?.()?.catch(()=>[])??Promise.resolve([]);Promise.all([R(e.fetch),n.listModels().catch(()=>[]),_]).then(([l,B,F])=>{r||(s(l.config),d(l.capabilities),g(l.lifecycle),p(Q(z(F,B))))}).catch(l=>{r||u(l instanceof Error?l.message:String(l))}).finally(()=>{r||v(!1)})}),()=>{r=!0}},[N,e.currentPod,e.fetch,e.webId]);const A=a.useCallback(()=>{T(r=>r+1)},[]),j=y?.pending??0;a.useEffect(()=>{if(j<=0||!e.webId||!e.currentPod)return;let r=!1;const n=setInterval(()=>{R(e.fetch).then(f=>{r||g(f.lifecycle)}).catch(()=>{})},K);return()=>{r=!0,clearInterval(n)}},[j,e.currentPod,e.fetch,e.webId]);const b=a.useCallback(async r=>{M(!0),u(void 0);try{const n=await G(e.fetch,r);s(n.config),d(n.capabilities),g(n.lifecycle)}catch(n){throw u(n instanceof Error?n.message:String(n)),n}finally{M(!1)}},[e.fetch]),m=a.useCallback(async r=>{P(!0),u(void 0);try{const n=await H(e.fetch,r);g(f=>({configurationVersion:f?.configurationVersion,pending:(f?.pending??0)+1,recent:[n,...f?.recent??[]].slice(0,20)}))}catch(n){throw u(n instanceof Error?n.message:String(n)),n}finally{P(!1)}},[e.fetch]),E=a.useCallback(async(r,n)=>{await b(r),await m(n)},[m,b]),x=q?O:!1,U=a.useMemo(()=>({config:o,capabilities:i,lifecycle:y,models:c,loading:x,saving:C,rebuilding:I,error:S,reload:A,save:b,rebuild:m,saveAndRebuild:E}),[i,o,x,S,y,c,m,I,A,b,E,C]);return V.jsx(L.Provider,{value:U,children:t})}function z(t,e){const o=new Map,s=i=>`${i.provider}\0${w(i.id)}`;for(const i of[...t,...e]){const d=s(i),c=o.get(d);if(!c){o.set(d,{...i,id:w(i.id)});continue}const p=[...new Set([...c.capabilities??[],...i.capabilities??[]])];o.set(d,{...c,...i,id:w(i.id),resourceId:c.resourceId??i.resourceId,displayName:c.displayName??i.displayName,availability:c.availability==="available"?c.availability:i.availability,modelType:c.modelType??i.modelType,...p.length>0?{capabilities:p}:{},...c.inputModalities??i.inputModalities?{inputModalities:c.inputModalities??i.inputModalities}:{}})}return[...o.values()]}function w(t){const e=t.lastIndexOf("#");return e>=0?t.slice(e+1):t}function Q(t){return t.map(e=>({id:e.id,displayName:e.displayName,owner:e.provider,ref:X(e.provider,e.id),capabilities:e.capabilities??[]}))}function ie(t,e){const s={chatModel:["chat"],ocrModel:["ocr"],readerModel:["document-understanding","documentunderstanding"],embeddingModel:["embedding"],indexerModel:["indexing"],rerankerModel:["reranking","reranker"]}[e];return s?t.filter(i=>i.capabilities.some(d=>s.includes(d.toLowerCase()))):t}function ne(){const t=a.useContext(L);if(!t)throw new Error("useAiConfig must be used within AiConfigProvider");return t}export{te as A,ie as m,ee as t,ne as u};
1
+ import{u as J,r as a,j as V,l as X}from"./dashboard-Dm_h60lA.js";import{a as $}from"./ai-connections-Dr4-rSzX.js";import{d as D}from"./XpodAiConnectionsPodStore-CHM-ZwI3.js";async function R(t){return k(t(h("/api/ai/config"),{method:"GET",credentials:"include",headers:{accept:"application/json"}}))}async function G(t,e){return k(t(h("/api/ai/config"),{method:"PATCH",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(e)}))}async function H(t,e){const o=await t(h("/api/ai/config/rebuild"),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({target:e})}),s=await o.json().catch(()=>{});if(!o.ok||!s?.job)throw new Error(s?.error??"Index rebuild request failed");return s.job}async function ee(t,e){const o=e.capabilities.some(i=>i.toLowerCase()==="embedding"),s=await t(h(o?"/v1/embeddings":"/v1/chat/completions"),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(o?{model:e.id,input:"xpod readiness probe"}:{model:e.id,messages:[{role:"user",content:"Reply OK."}],max_tokens:1,stream:!1})});if(!s.ok){const i=await s.json().catch(()=>{}),d=typeof i?.error=="string"?i.error:i?.error?.message;throw new Error(d??"Model readiness probe failed")}await s.arrayBuffer()}function h(t){if(typeof window>"u")throw new Error("AI Config API requires the current browser origin");return new URL(t,window.location.origin).toString()}async function k(t){const e=await t,o=await e.json().catch(()=>{});if(!e.ok||!o?.config||!o.capabilities)throw new Error(o?.error??"AI Config request failed");return o}const L=a.createContext(void 0),K=2e3;function te({children:t}){const e=J(),[o,s]=a.useState(),[i,d]=a.useState(),[c,p]=a.useState([]),[y,g]=a.useState(),[O,v]=a.useState(!0),[C,M]=a.useState(!1),[I,P]=a.useState(!1),[S,u]=a.useState(),[N,T]=a.useState(0),q=!!(e.webId&&e.currentPod);a.useEffect(()=>{if(!e.webId||!e.currentPod)return;let r=!1;return queueMicrotask(()=>{if(r||!e.webId||!e.currentPod)return;v(!0),u(void 0);const n=$({webId:e.webId,podUrl:e.currentPod.podUrl,authenticatedFetch:e.fetch}),_=D({database:e.currentPod.database,authenticatedFetch:e.fetch,podUrl:e.currentPod.podUrl,webId:e.currentPod.webId}).listModels?.()?.catch(()=>[])??Promise.resolve([]);Promise.all([R(e.fetch),n.listModels().catch(()=>[]),_]).then(([l,B,F])=>{r||(s(l.config),d(l.capabilities),g(l.lifecycle),p(Q(z(F,B))))}).catch(l=>{r||u(l instanceof Error?l.message:String(l))}).finally(()=>{r||v(!1)})}),()=>{r=!0}},[N,e.currentPod,e.fetch,e.webId]);const A=a.useCallback(()=>{T(r=>r+1)},[]),j=y?.pending??0;a.useEffect(()=>{if(j<=0||!e.webId||!e.currentPod)return;let r=!1;const n=setInterval(()=>{R(e.fetch).then(f=>{r||g(f.lifecycle)}).catch(()=>{})},K);return()=>{r=!0,clearInterval(n)}},[j,e.currentPod,e.fetch,e.webId]);const b=a.useCallback(async r=>{M(!0),u(void 0);try{const n=await G(e.fetch,r);s(n.config),d(n.capabilities),g(n.lifecycle)}catch(n){throw u(n instanceof Error?n.message:String(n)),n}finally{M(!1)}},[e.fetch]),m=a.useCallback(async r=>{P(!0),u(void 0);try{const n=await H(e.fetch,r);g(f=>({configurationVersion:f?.configurationVersion,pending:(f?.pending??0)+1,recent:[n,...f?.recent??[]].slice(0,20)}))}catch(n){throw u(n instanceof Error?n.message:String(n)),n}finally{P(!1)}},[e.fetch]),E=a.useCallback(async(r,n)=>{await b(r),await m(n)},[m,b]),x=q?O:!1,U=a.useMemo(()=>({config:o,capabilities:i,lifecycle:y,models:c,loading:x,saving:C,rebuilding:I,error:S,reload:A,save:b,rebuild:m,saveAndRebuild:E}),[i,o,x,S,y,c,m,I,A,b,E,C]);return V.jsx(L.Provider,{value:U,children:t})}function z(t,e){const o=new Map,s=i=>`${i.provider}\0${w(i.id)}`;for(const i of[...t,...e]){const d=s(i),c=o.get(d);if(!c){o.set(d,{...i,id:w(i.id)});continue}const p=[...new Set([...c.capabilities??[],...i.capabilities??[]])];o.set(d,{...c,...i,id:w(i.id),resourceId:c.resourceId??i.resourceId,displayName:c.displayName??i.displayName,availability:c.availability==="available"?c.availability:i.availability,modelType:c.modelType??i.modelType,...p.length>0?{capabilities:p}:{},...c.inputModalities??i.inputModalities?{inputModalities:c.inputModalities??i.inputModalities}:{}})}return[...o.values()]}function w(t){const e=t.lastIndexOf("#");return e>=0?t.slice(e+1):t}function Q(t){return t.map(e=>({id:e.id,displayName:e.displayName,owner:e.provider,ref:X(e.provider,e.id),capabilities:e.capabilities??[]}))}function ie(t,e){const s={chatModel:["chat"],ocrModel:["ocr"],readerModel:["document-understanding","documentunderstanding"],embeddingModel:["embedding"],indexerModel:["indexing"],rerankerModel:["reranking","reranker"]}[e];return s?t.filter(i=>i.capabilities.some(d=>s.includes(d.toLowerCase()))):t}function ne(){const t=a.useContext(L);if(!t)throw new Error("useAiConfig must be used within AiConfigProvider");return t}export{te as A,ie as m,ee as t,ne as u};
@@ -1 +1 @@
1
- import{c as d,j as e,q as x,r as p,O as g,N as f,s as y,t as b}from"./dashboard-D2ozrATv.js";import{P as v}from"./PaneListHeader-ByqK_C6i.js";import{A as j,u as k}from"./AiConfigContext-BedwuLTE.js";import{T as N,u as w}from"./workspace-layout-Csbbr3vZ.js";import"./ai-connections-Dr4-rSzX.js";import"./XpodAiConnectionsPodStore-DXNERI2-.js";import"@comunica/query-sparql-solid";const M=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],C=d("file-search",M);const A=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 19H3",key:"wbqt3n"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]],I=d("list-restart",A);const L=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]],H=d("scan-text",L);const q=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],_=d("sliders-horizontal",q);function o(s,a,t,n,i){return{id:s,label:a,path:t,href:`/ai-config/${t}`,end:!0,description:n,icon:i}}const l=[o("model-assignments","Model Assignments","model-assignments","Choose the model used by each Xpod capability.",_),o("document-processing","Document Processing","document-processing","Control OCR and structured document reading.",H),o("search-indexing","Search & Indexing","search-indexing","Enable FTS, vector retrieval, and backend selection.",C),o("index-lifecycle","Index Lifecycle","index-lifecycle","Control automatic indexing and derived-index rebuilds.",I)];function K(){return e.jsx(j,{children:e.jsx(S,{})})}function S(){const s=x(),{config:a,loading:t,saving:n,error:i,reload:m}=k(),[u,c]=p.useState(!1),h=l.find(r=>s.pathname.endsWith(r.path))??l[0];return e.jsx(N,{mode:"auto",listHeader:e.jsx(v,{title:"AI Config"}),list:e.jsx(T,{}),mainHeader:e.jsx("div",{className:"flex h-full min-w-0 items-center px-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"text-sm font-semibold text-foreground",children:["AI Config · ",h.label]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Pod-level AI and derived-index policy"})]})}),main:e.jsxs("section",{className:"min-h-full bg-background",children:[n&&e.jsx("div",{role:"status","aria-live":"polite",className:"border-b border-border px-6 py-2 text-xs text-muted-foreground",children:"Saving AI configuration…"}),i?e.jsx(z,{error:i,showTechnicalDetails:u,onToggleTechnicalDetails:()=>c(r=>!r),onRetry:()=>{c(!1),m()}}):t||!a?e.jsx(P,{}):e.jsx(g,{})]}),className:"min-h-full"})}function z({error:s,showTechnicalDetails:a,onToggleTechnicalDetails:t,onRetry:n}){return e.jsx("div",{className:"mx-auto w-full max-w-4xl p-6",children:e.jsxs("div",{role:"alert","aria-live":"assertive",className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"AI configuration could not be loaded"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Xpod could not read this Pod’s AI settings. Your existing settings were not changed."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Try again"}),e.jsx("button",{type:"button","aria-expanded":a,onClick:t,className:"h-9 rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground hover:bg-accent",children:a?"Hide details":"Show details"})]}),a&&e.jsx("p",{className:"mt-3 break-words font-mono text-xs text-muted-foreground",children:s})]})})}function P(){return e.jsxs("div",{role:"status","aria-live":"polite",className:"mx-auto w-full max-w-4xl p-6",children:[e.jsx("div",{className:"h-7 w-52 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-3 h-4 w-80 max-w-full animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-6 divide-y divide-border overflow-hidden rounded-xl border border-border",children:Array.from({length:4},(s,a)=>e.jsxs("div",{className:"grid gap-4 p-4 lg:grid-cols-[minmax(220px,1fr)_minmax(320px,440px)]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-28 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"h-3 w-52 animate-pulse rounded bg-muted"})]}),e.jsx("div",{className:"h-10 animate-pulse rounded-md bg-muted"})]},a))}),e.jsx("span",{className:"sr-only",children:"Loading AI configuration…"})]})}function T(){const s=w();return e.jsx("aside",{className:"h-full border-r border-border bg-muted/20 py-2",children:e.jsx("nav",{"aria-label":"AI Config sections","data-list-navigation":!0,children:l.map(a=>{const t=a.icon;return e.jsxs(f,{to:a.path,end:a.end,onClick:()=>s.openMain(),onKeyDown:y,className:({isActive:n})=>b(n,{compact:!1}),children:[e.jsx(t,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:a.label}),e.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:a.description})]})]},a.id)})})})}export{K as default};
1
+ import{c as d,j as e,s as x,r as p,O as g,N as f,t as v,v as y}from"./dashboard-Dm_h60lA.js";import{P as b}from"./PaneListHeader-xEjcBu9g.js";import{A as j,u as k}from"./AiConfigContext-DelSqO6L.js";import{T as N,u as w}from"./workspace-layout-Wed840qR.js";import"./ai-connections-Dr4-rSzX.js";import"./XpodAiConnectionsPodStore-CHM-ZwI3.js";import"@comunica/query-sparql-solid";const M=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],C=d("file-search",M);const A=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 19H3",key:"wbqt3n"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]],I=d("list-restart",A);const L=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]],H=d("scan-text",L);const q=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],_=d("sliders-horizontal",q);function o(s,a,t,n,i){return{id:s,label:a,path:t,href:`/ai-config/${t}`,end:!0,description:n,icon:i}}const l=[o("model-assignments","Model Assignments","model-assignments","Choose the model used by each Xpod capability.",_),o("document-processing","Document Processing","document-processing","Control OCR and structured document reading.",H),o("search-indexing","Search & Indexing","search-indexing","Enable FTS, vector retrieval, and backend selection.",C),o("index-lifecycle","Index Lifecycle","index-lifecycle","Control automatic indexing and derived-index rebuilds.",I)];function K(){return e.jsx(j,{children:e.jsx(S,{})})}function S(){const s=x(),{config:a,loading:t,saving:n,error:i,reload:m}=k(),[u,c]=p.useState(!1),h=l.find(r=>s.pathname.endsWith(r.path))??l[0];return e.jsx(N,{mode:"auto",listHeader:e.jsx(b,{title:"AI Config"}),list:e.jsx(T,{}),mainHeader:e.jsx("div",{className:"flex h-full min-w-0 items-center px-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"text-sm font-semibold text-foreground",children:["AI Config · ",h.label]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Pod-level AI and derived-index policy"})]})}),main:e.jsxs("section",{className:"min-h-full bg-background",children:[n&&e.jsx("div",{role:"status","aria-live":"polite",className:"border-b border-border px-6 py-2 text-xs text-muted-foreground",children:"Saving AI configuration…"}),i?e.jsx(z,{error:i,showTechnicalDetails:u,onToggleTechnicalDetails:()=>c(r=>!r),onRetry:()=>{c(!1),m()}}):t||!a?e.jsx(P,{}):e.jsx(g,{})]}),className:"min-h-full"})}function z({error:s,showTechnicalDetails:a,onToggleTechnicalDetails:t,onRetry:n}){return e.jsx("div",{className:"mx-auto w-full max-w-4xl p-6",children:e.jsxs("div",{role:"alert","aria-live":"assertive",className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"AI configuration could not be loaded"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Xpod could not read this Pod’s AI settings. Your existing settings were not changed."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Try again"}),e.jsx("button",{type:"button","aria-expanded":a,onClick:t,className:"h-9 rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground hover:bg-accent",children:a?"Hide details":"Show details"})]}),a&&e.jsx("p",{className:"mt-3 break-words font-mono text-xs text-muted-foreground",children:s})]})})}function P(){return e.jsxs("div",{role:"status","aria-live":"polite",className:"mx-auto w-full max-w-4xl p-6",children:[e.jsx("div",{className:"h-7 w-52 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-3 h-4 w-80 max-w-full animate-pulse rounded bg-muted"}),e.jsx("div",{className:"mt-6 divide-y divide-border overflow-hidden rounded-xl border border-border",children:Array.from({length:4},(s,a)=>e.jsxs("div",{className:"grid gap-4 p-4 lg:grid-cols-[minmax(220px,1fr)_minmax(320px,440px)]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-28 animate-pulse rounded bg-muted"}),e.jsx("div",{className:"h-3 w-52 animate-pulse rounded bg-muted"})]}),e.jsx("div",{className:"h-10 animate-pulse rounded-md bg-muted"})]},a))}),e.jsx("span",{className:"sr-only",children:"Loading AI configuration…"})]})}function T(){const s=w();return e.jsx("aside",{className:"h-full border-r border-border bg-muted/20 py-2",children:e.jsx("nav",{"aria-label":"AI Config sections","data-list-navigation":!0,children:l.map(a=>{const t=a.icon;return e.jsxs(f,{to:a.path,end:a.end,onClick:()=>s.openMain(),onKeyDown:v,className:({isActive:n})=>y(n,{compact:!1}),children:[e.jsx(t,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:a.label}),e.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:a.description})]})]},a.id)})})})}export{K as default};
@@ -0,0 +1 @@
1
+ import{r as u,j as a}from"./dashboard-Dm_h60lA.js";import{i as g,A as x}from"./ModelAssignmentsPanel-BSWH19oT.js";import{u as p}from"./AiConfigContext-DelSqO6L.js";import"./ai-connections-Dr4-rSzX.js";import"./XpodAiConnectionsPodStore-CHM-ZwI3.js";import"@comunica/query-sparql-solid";function R(){const{config:o,save:t,saving:s}=p(),[e,r]=u.useState(o?.documentProcessing);if(u.useEffect(()=>{let n=!1;return queueMicrotask(()=>{n||r(o?.documentProcessing)}),()=>{n=!0}},[o]),!e)return null;const l=g(e,o?.documentProcessing),b=async n=>{n.preventDefault(),await t({documentProcessing:e})};return a.jsx(x,{title:"Document Processing",description:"Control when Xpod invokes OCR and structured document readers.",onSubmit:b,onRestore:()=>t({documentProcessing:{ocrEnabled:!0,automaticOcr:!0,imageRecognition:!0,pdfRecognition:!0,tableRecognition:!1,processingMode:"auto",ocrFallbackOrder:["ocr","reader","plain-text"],readerPolicy:"auto",readerPriority:"structure-first",maxFileSizeMb:64,maxPages:500,failureFallback:"plain-text"}}),saving:s,dirty:l,children:a.jsxs("div",{className:"space-y-4 rounded-xl border border-border p-4",children:[a.jsx(i,{label:"Enable OCR",description:"Read text from images and scanned documents.",checked:e.ocrEnabled,onChange:n=>r({...e,ocrEnabled:n})}),a.jsx(i,{label:"Automatic OCR",description:"Run OCR when indexed content has no usable text layer.",checked:e.automaticOcr,onChange:n=>r({...e,automaticOcr:n})}),a.jsx(i,{label:"Image recognition",description:"Allow OCR and readers to process image resources.",checked:e.imageRecognition,onChange:n=>r({...e,imageRecognition:n})}),a.jsx(i,{label:"PDF recognition",description:"Process native and scanned PDF resources.",checked:e.pdfRecognition,onChange:n=>r({...e,pdfRecognition:n})}),a.jsx(i,{label:"Table recognition",description:"Preserve detected table structure when the reader supports it.",checked:e.tableRecognition,onChange:n=>r({...e,tableRecognition:n})}),a.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Processing mode",a.jsxs("select",{name:"processingMode",value:e.processingMode,onChange:n=>r({...e,processingMode:n.target.value}),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm sm:max-w-xs",children:[a.jsx("option",{value:"auto",children:"Auto"}),a.jsx("option",{value:"on-demand",children:"On demand"})]})]}),a.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["OCR fallback order",a.jsx("input",{value:e.ocrFallbackOrder.join(", "),onChange:n=>r({...e,ocrFallbackOrder:n.target.value.split(",").map(c=>c.trim()).filter(c=>["ocr","reader","plain-text"].includes(c))}),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm"})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsx(d,{label:"Reader policy",value:e.readerPolicy,options:["auto","always","disabled"],onChange:n=>r({...e,readerPolicy:n})}),a.jsx(d,{label:"Reader priority",value:e.readerPriority,options:["structure-first","speed-first"],onChange:n=>r({...e,readerPriority:n})}),a.jsx(m,{label:"Maximum file size (MB)",value:e.maxFileSizeMb,min:1,max:1024,onChange:n=>r({...e,maxFileSizeMb:n})}),a.jsx(m,{label:"Maximum pages",value:e.maxPages,min:1,max:1e4,onChange:n=>r({...e,maxPages:n})}),a.jsx(d,{label:"Failure fallback",value:e.failureFallback,options:["plain-text","skip"],onChange:n=>r({...e,failureFallback:n})})]})]})})}function d({label:o,value:t,options:s,onChange:e}){return a.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[o,a.jsx("select",{value:t,onChange:r=>e(r.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm",children:s.map(r=>a.jsx("option",{value:r,children:r},r))})]})}function m({label:o,value:t,min:s,max:e,onChange:r}){return a.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[o,a.jsx("input",{type:"number",value:t,min:s,max:e,onChange:l=>r(l.target.valueAsNumber),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm"})]})}function i({label:o,description:t,checked:s,onChange:e}){return a.jsxs("label",{className:"flex items-start justify-between gap-4",children:[a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:o}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:t})]}),a.jsx("input",{type:"checkbox",checked:s,onChange:r=>e(r.target.checked),className:"mt-1 h-4 w-4 rounded border-input"})]})}export{R as DocumentProcessingPanel};
@@ -0,0 +1 @@
1
+ import{r as o,j as e}from"./dashboard-Dm_h60lA.js";import{i as y,A as N,B as k}from"./ModelAssignmentsPanel-BSWH19oT.js";import{u as w}from"./AiConfigContext-DelSqO6L.js";import"./ai-connections-Dr4-rSzX.js";import"./XpodAiConnectionsPodStore-CHM-ZwI3.js";import"@comunica/query-sparql-solid";function P(){const{config:t,capabilities:d,lifecycle:i,save:n,rebuild:p,saving:h,rebuilding:b,error:g}=w(),[c,u]=o.useState(),[r,a]=o.useState(t?.lifecycle);if(o.useEffect(()=>{let s=!1;return queueMicrotask(()=>{s||a(t?.lifecycle)}),()=>{s=!0}},[t]),!r)return null;const v=y(r,t?.lifecycle),j=async s=>{s.preventDefault(),await n({lifecycle:r})},m=async s=>{u(void 0);try{await p(s)}catch(l){(l instanceof Error?l.message:String(l)).includes("service_access_missing")&&u(s)}};return e.jsxs(N,{title:"Index Lifecycle",description:"Control automatic maintenance and explicitly schedule rebuilds of derived data.",onSubmit:j,onRestore:()=>n({lifecycle:{automaticIndexing:!0,refreshAfterSourceUpdate:!0,removeAfterSourceDeletion:!0}}),saving:h,dirty:v,children:[e.jsxs("div",{className:"divide-y divide-border rounded-xl border border-border",children:[e.jsxs("label",{className:"flex items-start justify-between gap-4 p-4",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:"Automatically index changes"}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Index new and updated resources, and remove derived entries after deletion."})]}),e.jsx("input",{name:"automaticIndexing",type:"checkbox",checked:r.automaticIndexing,onChange:s=>a({...r,automaticIndexing:s.target.checked}),className:"mt-1 h-4 w-4 rounded border-input"})]}),e.jsx(x,{label:"Refresh after source updates",checked:r.refreshAfterSourceUpdate,onChange:s=>a({...r,refreshAfterSourceUpdate:s})}),e.jsx(x,{label:"Remove derived entries after source deletion",checked:r.removeAfterSourceDeletion,onChange:s=>a({...r,removeAfterSourceDeletion:s})})]}),e.jsxs("section",{className:"rounded-xl border border-border p-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Rebuild derived indexes"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Rebuild actions never modify authority data in the Pod."}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:["fts","vector","all"].map(s=>e.jsxs("button",{type:"button",disabled:!d?.rebuildTargets?.includes(s)||b,onClick:()=>{m(s)},className:"h-9 rounded-md border border-input px-3 text-sm font-medium disabled:opacity-50",children:["Rebuild ",s==="all"?"all":s.toUpperCase()]},s))})]}),e.jsx(k,{...c?{notice:g?.includes("service_access_missing")?`Rebuild ${c.toUpperCase()} needs background Pod access.`:void 0,onGranted:()=>m(c)}:{}}),e.jsxs("section",{className:"rounded-xl border border-border p-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Lifecycle evidence"}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsx(f,{label:"Configuration version",value:i?.configurationVersion??t?.updatedAt??"Default"}),e.jsx(f,{label:"Pending queue",value:String(i?.pending??0)})]}),e.jsx("div",{className:"mt-4 space-y-2",children:i?.recent.length?i.recent.map(s=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border p-3 text-sm",children:[e.jsxs("span",{children:[s.target.toUpperCase()," · ",s.status]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.progress??0,"% · ",new Date(s.createdAt).toLocaleString()]}),s.error?e.jsx("span",{className:"w-full text-xs text-destructive",children:s.error}):null]},s.id)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No rebuild jobs have been scheduled."})})]})]})}function x({label:t,checked:d,onChange:i}){return e.jsxs("label",{className:"flex items-start justify-between gap-4 p-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsx("input",{type:"checkbox",checked:d,onChange:n=>i(n.target.checked),className:"mt-1 h-4 w-4 rounded border-input"})]})}function f({label:t,value:d}){return e.jsxs("div",{className:"rounded-md border border-border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:d})]})}export{P as IndexLifecyclePanel};
@@ -1 +1 @@
1
- import{r as l,j as e,B as g,R as j,C as p,a as y,b,d as S,e as N}from"./dashboard-D2ozrATv.js";import{g as C}from"./admin-C6qCRFiY.js";import{S as m}from"./skeleton-TKyLbiPs.js";function F({kind:r}){const[s,n]=l.useState(null),[d,t]=l.useState(!1),i=l.useCallback(async()=>{t(!0);try{n(await C())}finally{t(!1)}},[]);return l.useEffect(()=>{let c=!0;return Promise.resolve().then(()=>{c&&i()}),()=>{c=!1}},[i]),e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(g,{type:"button",size:"sm",variant:"outline",onClick:i,disabled:d,children:[e.jsx(j,{className:"mr-2 h-4 w-4"}),"Refresh"]})}),e.jsx("div",{role:"status","aria-live":"polite",className:"sr-only",children:d?"Refreshing index evidence…":s?"Index evidence refreshed.":"Waiting for index evidence."}),e.jsxs(p,{children:[e.jsxs(y,{children:[e.jsx(b,{children:w[r]}),e.jsx(S,{children:"Observed derived-index state; policy changes belong in AI Config."})]}),e.jsx(N,{children:d&&!s?e.jsx(B,{}):R(r,s)})]})]})}const w={overview:"Index Overview",fts:"FTS",vector:"Vector","retrieval-points":"Retrieval Points",cache:"Cache","slow-queries":"Slow Queries",benchmark:"Benchmark"};function R(r,s){if(!s)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"Waiting for runtime evidence."});if(r==="benchmark"){const t=s.benchmarkReports;return e.jsx(a,{values:[["Reports",String(t?.reportCount??0)],["Skipped files",String(t?.skippedFiles??0)],["Errors",String(t?.errors.length??0)]]})}if(!s.available)return e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unavailable: ",s.reason]});if(r==="overview"){const t=s.stats.lifecycle;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(a,{values:[["Engine",s.engine],["State",v(t?.status)],["Authority data",o(s.stats.factsBytes)],["Derived storage",o(s.stats.derivedBytes)],["Total storage",o(s.stats.totalBytes)],["Generated",f(s.generatedAt)]]}),e.jsx(x,{children:"Derived indexes are rebuildable runtime evidence; Pod RDF remains the authority data."})]})}if(r==="cache"){const t=s.stats.derivedCache;return t?e.jsx(a,{values:[["Cache bytes",o(t.cacheBytes)],["Limit",o(t.maxCacheBytes)],["Pressure",`${Math.round(t.cachePressure*100)}%`],["Evictions",String(t.evictionCount)]]}):e.jsx(u,{})}if(r==="slow-queries"){const t=s.stats.slowQueries;return t?e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{values:[["Captured",String(t.entryCount)],["Limit",String(t.maxEntries)]]}),t.entries.slice(0,10).map(i=>e.jsxs("div",{className:"rounded-lg border border-border p-3 text-sm",children:[e.jsxs("div",{className:"font-medium",children:[i.runtime.durationMs," ms · ",i.runtime.returnedRows," rows"]}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:i.reasons.join(", ")||i.queryKey})]},`${i.generatedAt}-${i.queryKey}`))]}):e.jsx(u,{})}if(r==="retrieval-points"){const t=s.stats.rdf3x;return t?e.jsx(a,{values:[["State",t.syncedWithFacts?"Synchronized":`${t.refreshLag} versions behind`],["Facts version",String(t.factsDataVersion)],["Retrieval version",String(t.rdf3xFactsDataVersion)],["Pending sources",String(t.pendingSources)]]}):e.jsx(u,{})}const n=s.stats.lifecycle,d=r==="fts"?n?.coldStart?.ownsTextIndex:n?.coldStart?.ownsVectorIndex;if((r==="fts"||r==="vector")&&d){const t=s.stats.pgAcceleration,i=s.stats.rdf3x;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(a,{values:[["State",v(n?.status)],["Ownership","Runtime managed"],["Backend",t?.provider?`${h(t.provider)}${t.version?` ${t.version}`:""}`:n?.driver??"Not reported"],["Freshness",i?i.syncedWithFacts?"Current":`${i.refreshLag} versions behind`:"Not reported"],["Indexes",t?.customIndexes?.map(c=>c.name).join(", ")||"Runtime managed"],["Last ready",f(n?.lastReadyAt)]]}),e.jsxs(x,{children:[r==="fts"?"Text retrieval":"Vector retrieval"," is derived from Pod authority data. Enablement and backend policy are configured in AI Config."]})]})}return e.jsx(u,{})}function a({values:r}){return e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:r.map(([s,n])=>e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.jsx("div",{className:"mt-1 font-medium",children:n})]},s))})}function B(){return e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","aria-hidden":"true",children:Array.from({length:4},(r,s)=>e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx(m,{className:"h-3 w-20"}),e.jsx(m,{className:"mt-2 h-5 w-28"})]},s))})}function u(){return e.jsx("p",{className:"text-sm text-muted-foreground",children:"This runtime does not report evidence for this index subject."})}function x({children:r}){return e.jsx("p",{className:"text-sm text-muted-foreground",children:r})}function o(r){return r<1024?`${r} B`:r<1024*1024?`${Math.round(r/1024)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function f(r){return r?new Date(r).toLocaleString():"Not reported"}function v(r){return r?h(r):"Unknown"}function h(r){return r.charAt(0).toUpperCase()+r.slice(1)}export{F as default};
1
+ import{r as l,j as e,B as g,R as j,C as p,a as y,b,d as S,e as N}from"./dashboard-Dm_h60lA.js";import{g as C}from"./admin-C6qCRFiY.js";import{S as m}from"./skeleton-CY_602wn.js";function F({kind:r}){const[s,n]=l.useState(null),[d,t]=l.useState(!1),i=l.useCallback(async()=>{t(!0);try{n(await C())}finally{t(!1)}},[]);return l.useEffect(()=>{let c=!0;return Promise.resolve().then(()=>{c&&i()}),()=>{c=!1}},[i]),e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(g,{type:"button",size:"sm",variant:"outline",onClick:i,disabled:d,children:[e.jsx(j,{className:"mr-2 h-4 w-4"}),"Refresh"]})}),e.jsx("div",{role:"status","aria-live":"polite",className:"sr-only",children:d?"Refreshing index evidence…":s?"Index evidence refreshed.":"Waiting for index evidence."}),e.jsxs(p,{children:[e.jsxs(y,{children:[e.jsx(b,{children:w[r]}),e.jsx(S,{children:"Observed derived-index state; policy changes belong in AI Config."})]}),e.jsx(N,{children:d&&!s?e.jsx(B,{}):R(r,s)})]})]})}const w={overview:"Index Overview",fts:"FTS",vector:"Vector","retrieval-points":"Retrieval Points",cache:"Cache","slow-queries":"Slow Queries",benchmark:"Benchmark"};function R(r,s){if(!s)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"Waiting for runtime evidence."});if(r==="benchmark"){const t=s.benchmarkReports;return e.jsx(a,{values:[["Reports",String(t?.reportCount??0)],["Skipped files",String(t?.skippedFiles??0)],["Errors",String(t?.errors.length??0)]]})}if(!s.available)return e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unavailable: ",s.reason]});if(r==="overview"){const t=s.stats.lifecycle;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(a,{values:[["Engine",s.engine],["State",v(t?.status)],["Authority data",o(s.stats.factsBytes)],["Derived storage",o(s.stats.derivedBytes)],["Total storage",o(s.stats.totalBytes)],["Generated",f(s.generatedAt)]]}),e.jsx(x,{children:"Derived indexes are rebuildable runtime evidence; Pod RDF remains the authority data."})]})}if(r==="cache"){const t=s.stats.derivedCache;return t?e.jsx(a,{values:[["Cache bytes",o(t.cacheBytes)],["Limit",o(t.maxCacheBytes)],["Pressure",`${Math.round(t.cachePressure*100)}%`],["Evictions",String(t.evictionCount)]]}):e.jsx(u,{})}if(r==="slow-queries"){const t=s.stats.slowQueries;return t?e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{values:[["Captured",String(t.entryCount)],["Limit",String(t.maxEntries)]]}),t.entries.slice(0,10).map(i=>e.jsxs("div",{className:"rounded-lg border border-border p-3 text-sm",children:[e.jsxs("div",{className:"font-medium",children:[i.runtime.durationMs," ms · ",i.runtime.returnedRows," rows"]}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:i.reasons.join(", ")||i.queryKey})]},`${i.generatedAt}-${i.queryKey}`))]}):e.jsx(u,{})}if(r==="retrieval-points"){const t=s.stats.rdf3x;return t?e.jsx(a,{values:[["State",t.syncedWithFacts?"Synchronized":`${t.refreshLag} versions behind`],["Facts version",String(t.factsDataVersion)],["Retrieval version",String(t.rdf3xFactsDataVersion)],["Pending sources",String(t.pendingSources)]]}):e.jsx(u,{})}const n=s.stats.lifecycle,d=r==="fts"?n?.coldStart?.ownsTextIndex:n?.coldStart?.ownsVectorIndex;if((r==="fts"||r==="vector")&&d){const t=s.stats.pgAcceleration,i=s.stats.rdf3x;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(a,{values:[["State",v(n?.status)],["Ownership","Runtime managed"],["Backend",t?.provider?`${h(t.provider)}${t.version?` ${t.version}`:""}`:n?.driver??"Not reported"],["Freshness",i?i.syncedWithFacts?"Current":`${i.refreshLag} versions behind`:"Not reported"],["Indexes",t?.customIndexes?.map(c=>c.name).join(", ")||"Runtime managed"],["Last ready",f(n?.lastReadyAt)]]}),e.jsxs(x,{children:[r==="fts"?"Text retrieval":"Vector retrieval"," is derived from Pod authority data. Enablement and backend policy are configured in AI Config."]})]})}return e.jsx(u,{})}function a({values:r}){return e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:r.map(([s,n])=>e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.jsx("div",{className:"mt-1 font-medium",children:n})]},s))})}function B(){return e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","aria-hidden":"true",children:Array.from({length:4},(r,s)=>e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx(m,{className:"h-3 w-20"}),e.jsx(m,{className:"mt-2 h-5 w-28"})]},s))})}function u(){return e.jsx("p",{className:"text-sm text-muted-foreground",children:"This runtime does not report evidence for this index subject."})}function x({children:r}){return e.jsx("p",{className:"text-sm text-muted-foreground",children:r})}function o(r){return r<1024?`${r} B`:r<1024*1024?`${Math.round(r/1024)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function f(r){return r?new Date(r).toLocaleString():"Not reported"}function v(r){return r?h(r):"Unknown"}function h(r){return r.charAt(0).toUpperCase()+r.slice(1)}export{F as default};
@@ -0,0 +1 @@
1
+ import{u as B,r as c,j as t,B as W,D as Q,m as Y,n as Z,o as ee,p as te,q as re}from"./dashboard-Dm_h60lA.js";import{m as se,u as ne,t as ae}from"./AiConfigContext-DelSqO6L.js";function $(e,s){const r=s??(typeof window>"u"?void 0:window.location.origin);if(!r)throw new Error("task credential request needs a current browser origin");return new URL(e,r).toString()}async function D(e){const s=await e.text().catch(()=>"");if(s)try{const r=JSON.parse(s);return r&&typeof r=="object"&&!Array.isArray(r)?r:void 0}catch{return}}function R(e,s){const r=e?.error;return typeof r=="string"&&r?r:s}async function ie(e){const s=await e.fetch($("/api/ai/task-credentials",e.origin),{method:"GET",credentials:"include",headers:{accept:"application/json"}}),r=await D(s);if(!s.ok)throw new Error(R(r,"Task credential request failed"));const a=r?.data;return Array.isArray(a)?a:[]}async function oe(e){const s=await e.fetch($("/api/ai/task-credentials",e.origin),{method:"POST",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({apiKey:e.apiKey,...e.name?{name:e.name}:{}})}),r=await D(s);if(!s.ok)throw new Error(R(r,"Task credential grant failed"));const a=r?.credential;if(!a||typeof a!="object")throw new Error("Task credential grant returned no grant");return a}async function de(e){const s=await e.fetch($(`/api/ai/task-credentials/${encodeURIComponent(e.credentialRef)}`,e.origin),{method:"DELETE",credentials:"include",headers:{accept:"application/json"}});if(!s.ok)throw new Error(R(await D(s),"Task credential revocation failed"))}function le(e,s){return e.filter(r=>r.status==="active"&&(!s||r.issuer===s)).sort((r,a)=>a.version-r.version)[0]}function ce(){const e=B(),[s,r]=c.useState(),[a,u]=c.useState(!0),[f,o]=c.useState(!1),[d,x]=c.useState(),p=c.useCallback(async()=>{if(!e.webId){r(void 0),u(!1);return}try{const i=await ie({fetch:e.fetch});r(le(i,e.issuer)),x(void 0)}catch(i){x(i instanceof Error?i.message:String(i))}finally{u(!1)}},[e.fetch,e.issuer,e.webId]);c.useEffect(()=>{p()},[p]);const h=c.useCallback(async()=>{o(!0),x(void 0);try{const i=await e.requestPodApiKey?.();if(!i)throw new Error("当前会话无法准备凭据");const b=await oe({fetch:e.fetch,apiKey:i,name:"Xpod 后台任务"});r(b)}catch(i){throw x(i instanceof Error?i.message:String(i)),i}finally{o(!1)}},[e.fetch,e.requestPodApiKey]),j=c.useCallback(async()=>{if(s){o(!0),x(void 0);try{await de({fetch:e.fetch,credentialRef:s.credentialRef}),r(void 0)}catch(i){throw x(i instanceof Error?i.message:String(i)),i}finally{o(!1)}}},[s,e.fetch]);return{...s?{credential:s}:{},loading:a,working:f,...d?{error:d}:{},grant:h,revoke:j,reload:p}}function ue(e){const s=[`已授权 · v${e.version}`];return e.lastUsedAt&&s.push(`最近使用 ${new Date(e.lastUsedAt).toLocaleString()}`),e.expiresAt&&s.push(`${new Date(e.expiresAt).toLocaleDateString()} 到期`),s.join(" · ")}function _({onGranted:e,notice:s}){const r=ce(),a=async()=>{try{await r.grant(),await e?.()}catch{}};return t.jsxs("section",{className:"rounded-xl border border-border p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-sm font-medium",children:"Background Pod access"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Lets index maintenance and embeddings read this Pod while you are not signed in."})]}),r.credential?t.jsx("button",{type:"button",disabled:r.working,onClick:()=>{r.revoke().catch(()=>{})},className:"h-9 rounded-md border border-input px-3 text-sm font-medium disabled:opacity-50",children:r.working?"正在撤销…":"撤销授权"}):t.jsx("button",{type:"button",disabled:r.working||r.loading,onClick:()=>{a()},className:"h-9 rounded-md border border-input px-3 text-sm font-medium disabled:opacity-50",children:r.working?"正在授权…":"授权后台任务访问"})]}),s?t.jsx("p",{className:"mt-3 text-sm text-destructive",children:s}):null,t.jsx("p",{className:"mt-3 text-sm",children:r.credential?ue(r.credential):"未授权:后台任务在你不在时无法读取这个 Pod。"}),r.error?t.jsx("p",{className:"mt-2 text-xs text-destructive",children:r.error}):null]})}function me(e,s){return C(e)!==C(s)}function C(e){return Array.isArray(e)?`[${e.map(C).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,s])=>s!==void 0).sort(([s],[r])=>s.localeCompare(r)).map(([s,r])=>`${JSON.stringify(s)}:${C(r)}`).join(",")}}`:JSON.stringify(e)}const S=[{label:"对话与通用文本",role:"General / Chat",name:"chatModel",description:"用于助手对话与一般文本任务。"},{label:"识别图片文字",role:"OCR",name:"ocrModel",description:"从图片与扫描页里读出文字。"},{label:"理解文档内容",role:"Document Reader",name:"readerModel",description:"提取文档的结构与内容。"},{label:"按意思搜索",role:"Embedding",name:"embeddingModel",description:"为语义搜索生成向量。"},{label:"准备与摘要索引",role:"Indexer / Summarizer",name:"indexerModel",description:"为索引准备并摘要内容。"},{label:"搜索结果重排",role:"Reranker",name:"rerankerModel",description:"按相关性重排搜索结果。"}];function fe(){const{config:e,capabilities:s,lifecycle:r,models:a,save:u,saveAndRebuild:f,saving:o,rebuilding:d}=ne(),x=B(),[p,h]=c.useState({}),[j,i]=c.useState(),[b,w]=c.useState({}),[T,y]=c.useState(),[v,k]=c.useState(),[m,U]=c.useState(!1);c.useEffect(()=>{let n=!1;return queueMicrotask(()=>{n||h(e?.models??{})}),()=>{n=!0}},[e]);const J=me(p,e?.models??{}),A=E(p,e),N=L(r,d),O=()=>Object.fromEntries(S.map(({name:n})=>[n,p[n]||null])),K=async n=>{if(n.preventDefault(),A){if(N)return;y({models:O(),switch:A});return}await u({models:O()})},z=async()=>{const n=Object.fromEntries(S.map(({name:g})=>[g,null])),l=E(n,e);if(!l){await u({models:n});return}N||y({models:n,switch:l})},G=async()=>{const n=T;if(y(void 0),!n)return;const l=q(s);if(!l){await u({models:n.models}),k("模型已保存;此运行时不支持重建索引,请稍后手动重建。");return}await f({models:n.models},l),k(void 0)},X=n=>{const l=p[n];return l?a.find(g=>g.id===l)?.displayName??a.find(g=>g.id===l)?.ref??l:"系统默认"},V=n=>{const l=b[n];return l==="ready"?"已验证可用":l==="failed"?"验证失败":"未验证"},H=t.jsxs("section",{"data-testid":"ai-purpose-summary",className:"overflow-hidden rounded-xl border border-border",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"用途与模型"}),t.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"概要只列用途、当前模型与可用性;点「编辑」才展开兼容选项、恢复默认与有边界的测试。"})]}),t.jsx(W,{type:"button",variant:"outline",size:"sm",onClick:()=>U(!0),children:"编辑"})]}),t.jsxs("div",{className:"divide-y divide-border",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,0.8fr)] gap-2 px-4 py-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:"用途"}),t.jsx("span",{children:"当前模型"}),t.jsx("span",{children:"可用性"})]}),S.map(n=>t.jsxs("div",{"data-testid":"ai-purpose-row","data-purpose":n.name,className:"grid grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,0.8fr)] gap-2 px-4 py-2 text-sm",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate",children:n.label}),t.jsx("span",{"data-testid":"model-assignment-role",className:"mt-0.5 block font-mono text-[11px] text-muted-foreground",children:n.role})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block break-all",children:X(n.name)}),t.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:p[n.name]?"显式指定":"系统默认"})]}),t.jsx("span",{className:"text-muted-foreground",children:V(n.name)})]},n.name))]})]});return m?t.jsxs(t.Fragment,{children:[t.jsxs(I,{title:"用途与模型",description:"按真实用途选择模型;未指定的用途使用系统默认。每行的专业角色名只作说明,不改变运行语义。",onSubmit:K,onRestore:()=>{z()},saving:o||d,dirty:J,children:[t.jsx("div",{className:"divide-y divide-border rounded-xl border border-border",children:S.map(n=>t.jsx(F,{...n,models:a,value:p[n.name],testing:j===n.name,testResult:b[n.name],disabled:n.name==="embeddingModel"&&N,notice:n.name!=="embeddingModel"?void 0:N?"索引重建进行中,完成后才能再次切换向量模型。":A?"切换向量模型会重建索引:保存前需要二次确认,确认后立即排队重建。":void 0,onChange:l=>h(g=>({...g,[n.name]:l})),onTest:async l=>{i(n.name);try{await ae(x.fetch,l),w(g=>({...g,[n.name]:"ready"}))}catch{w(g=>({...g,[n.name]:"failed"}))}finally{i(void 0)}}},n.name))}),t.jsx(M,{lifecycle:r,fallbackNotice:v})]}),t.jsx(_,{}),t.jsx(pe,{request:T?.switch,models:a,saving:o||d||N,onCancel:()=>y(void 0),onConfirm:()=>{G()}})]}):t.jsxs(t.Fragment,{children:[H,t.jsx(M,{lifecycle:r,fallbackNotice:v}),t.jsx(_,{})]})}function E(e,s){const r=e.embeddingModel;if(r===void 0)return;const a=s?.models?.embeddingModel??"";return(r??"")===a?void 0:{from:a||void 0,to:r||void 0}}function L(e,s=!1){if(s)return!0;const r=P(e)?.phase;return r==="queued"||r==="running"}function q(e){const s=e?.rebuildTargets??[];if(s.includes("vector"))return"vector";if(s.includes("all"))return"all"}function P(e){if(!e)return;const s=e.recent[0];if(!s)return e.pending>0?{phase:"queued",pending:e.pending}:void 0;if(!(s.status==="queued"&&e.pending<=0))return{phase:s.status,pending:e.pending,target:s.target,...s.progress!==void 0?{progress:s.progress}:{},...s.error?{error:s.error}:{}}}const xe={queued:"索引重建已排队",running:"索引重建进行中",succeeded:"索引重建完成",failed:"索引重建失败"};function M({lifecycle:e,fallbackNotice:s}){const r=P(e);if(!r)return s?t.jsx("p",{role:"status",className:"text-xs text-warning",children:s}):null;const a=[r.progress!==void 0?`${r.progress}%`:void 0,r.pending>0?`队列 ${r.pending}`:void 0,r.error].filter(Boolean).join(" · ");return t.jsxs("p",{role:"status",className:`text-xs ${r.phase==="failed"?"text-destructive":"text-muted-foreground"}`,children:[xe[r.phase],a?` · ${a}`:""]})}function pe({request:e,models:s,saving:r,onCancel:a,onConfirm:u}){const f=o=>{if(!o)return"系统默认";const d=s.find(x=>x.ref===o);return d?`${d.displayName??d.id} · ${d.owner}`:o};return t.jsx(Q,{open:!!e,onOpenChange:o=>{o||a()},children:t.jsxs(Y,{"data-testid":"embedding-switch-dialog",children:[t.jsxs(Z,{children:[t.jsx(ee,{children:"切换向量模型并重建索引?"}),t.jsx(te,{children:"已建立的向量由原模型生成,切换后需要用新模型重建索引才能参与检索。重建期间检索只会返回文本命中。"})]}),e&&t.jsxs("dl",{className:"grid gap-2 text-sm",children:[t.jsxs("div",{className:"flex justify-between gap-4",children:[t.jsx("dt",{className:"text-muted-foreground",children:"当前"}),t.jsx("dd",{className:"min-w-0 break-all text-right",children:f(e.from)})]}),t.jsxs("div",{className:"flex justify-between gap-4",children:[t.jsx("dt",{className:"text-muted-foreground",children:"切换为"}),t.jsx("dd",{className:"min-w-0 break-all text-right",children:f(e.to)})]})]}),t.jsxs(re,{children:[t.jsx("button",{type:"button",onClick:a,className:"h-9 rounded-md border border-input bg-background px-3 text-sm font-medium hover:bg-accent",children:"取消"}),t.jsx("button",{type:"button",disabled:r,onClick:u,className:"h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground disabled:opacity-50",children:r?"提交中…":"确认切换并重建"})]})]})})}function F({label:e,role:s,name:r,description:a,models:u,value:f,testing:o,testResult:d,notice:x,disabled:p=!1,onChange:h,onTest:j}){const i=u.find(m=>m.ref===f),b=se(u,r),w=i?.capabilities.some(m=>["chat","embedding"].includes(m.toLowerCase()))===!0,v=[i?`Connected · credential ready · ${i.owner}`:f?"Selected model is no longer credential-ready":void 0,d==="ready"?"Probe succeeded":d==="failed"?"Probe failed; review AI Connection health":void 0].filter(Boolean).join(" · "),k=!!(f&&!i)||d==="failed";return t.jsxs("div",{"data-testid":"model-assignment-row",className:"grid gap-3 p-4 lg:grid-cols-[minmax(220px,1fr)_minmax(320px,440px)] lg:items-start",children:[t.jsxs("div",{className:"min-w-0 pt-1",children:[t.jsx("span",{className:"block text-sm font-medium text-foreground",children:e}),s?t.jsx("span",{"data-testid":"model-assignment-role",className:"mt-0.5 block font-mono text-xs text-muted-foreground",children:s}):null,t.jsx("span",{className:"mt-0.5 block text-xs leading-5 text-muted-foreground",children:a})]}),t.jsxs("div",{"data-testid":"model-assignment-controls",className:"grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_4.5rem] sm:items-start",children:[t.jsxs("label",{className:"min-w-0",children:[t.jsxs("span",{className:"sr-only",children:[e," model"]}),t.jsxs("select",{name:r,value:f??"",disabled:p,onChange:m=>h(m.target.value),className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground disabled:opacity-50",children:[t.jsx("option",{value:"",children:"System default"}),b.map(m=>t.jsxs("option",{value:m.ref,children:[m.displayName??m.id," · ",m.owner]},`${m.owner}:${m.id}`))]})]}),t.jsx("button",{type:"button","aria-label":`Test ${e} model`,disabled:p||!w||o,title:i?w?"Send a bounded readiness probe":"This model has no bounded probe endpoint":"Select a connected model first",onClick:()=>i&&void j(i),className:"h-10 w-full self-start rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground hover:bg-accent disabled:opacity-50",children:o?"Testing…":"Test"}),v&&t.jsx("span",{role:"status",className:`text-xs sm:col-span-2 ${k?"text-destructive":"text-muted-foreground"}`,children:v}),x&&t.jsx("span",{"data-testid":"model-assignment-notice",className:"text-xs text-warning sm:col-span-2",children:x})]})]})}function I({title:e,description:s,children:r,onSubmit:a,onRestore:u,footerActions:f,saving:o=!1,dirty:d=!0}){return t.jsxs("form",{onSubmit:a,className:"mx-auto flex w-full max-w-4xl flex-col gap-6 p-6",children:[t.jsxs("header",{children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e}),t.jsx("p",{className:"mt-2 max-w-2xl text-sm text-muted-foreground",children:s})]}),r,t.jsxs("div",{className:"flex justify-end gap-2 border-t border-border pt-4",children:[t.jsx("span",{role:"status",className:"mr-auto self-center text-xs text-muted-foreground",children:d?"Unsaved changes":"Applied"}),f,t.jsx("button",{type:"button",onClick:u,disabled:o||!u,className:"h-9 rounded-md border border-input bg-background px-3 text-sm font-medium hover:bg-accent disabled:opacity-50",children:"Restore defaults"}),t.jsx("button",{type:"submit",disabled:o||!a||!d,className:"h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground disabled:opacity-50",children:o?"Saving…":"Save configuration"})]})]})}const be=Object.freeze(Object.defineProperty({__proto__:null,AiConfigForm:I,ModelAssignmentRow:F,ModelAssignmentsPanel:fe,RebuildStatusLine:M,embeddingModelSwitch:E,rebuildInFlight:L,rebuildStatusFrom:P,rebuildTargetForCapabilities:q},Symbol.toStringTag,{value:"Module"}));export{I as A,_ as B,be as M,me as i};