@augmentd-labs/canvas-web 2.26.22 → 2.26.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{FiltersApplet-gbu4I1fK.js → FiltersApplet-BAe-Eq0e.js} +1 -1
- package/dist/assets/{HomeFab-CXaEEzXy.js → HomeFab-BXSAtndH.js} +1 -1
- package/dist/assets/{LensApplet-FifF2RUs.js → LensApplet-DuADvEm5.js} +1 -1
- package/dist/assets/{NotesApplet-D94iQKg6.js → NotesApplet-BmLjXx7V.js} +1 -1
- package/dist/assets/{_agentId_-wN8YJoTZ.js → _agentId_-Bquq_bl1.js} +0 -0
- package/dist/assets/{_contextId_-CoJraYnP.js → _contextId_-DndAgEMz.js} +1 -1
- package/dist/assets/{_workspaceName_-CXuIfG46.js → _workspaceName_-C_tzeHUf.js} +1 -1
- package/dist/assets/{about-CT6Ghfkb.js → about-DpILEqyH.js} +1 -1
- package/dist/assets/{add-BzgCpo5S.js → add-BHkmOOkO.js} +1 -1
- package/dist/assets/{agents-DIJpWCkc.js → agents-lo0DGGKV.js} +1 -1
- package/dist/assets/{appearance-D1EpKWaK.js → appearance-5Vx17gl4.js} +1 -1
- package/dist/assets/{apps-DX8oWukQ.js → apps-Ci03cFZm.js} +1 -1
- package/dist/assets/backend-sync-progress-H4Zch25P.js +7 -0
- package/dist/assets/{content-app-view-DS6Nrz6M.js → content-app-view-BFluU_u6.js} +1 -1
- package/dist/assets/{document-list-SsF3jmuq.js → document-list-rh4ittZx.js} +1 -1
- package/dist/assets/embedding-B5JiUA9X.js +1 -0
- package/dist/assets/{embedding-BHnBCyUx.js → embedding-B7cWrpy0.js} +1 -1
- package/dist/assets/{home-3vhobmCu.js → home-Dus2Lg1o.js} +1 -1
- package/dist/assets/{index-CiBgHujl.js → index-Tx_qtD_m.js} +3 -3
- package/dist/assets/inferd-config-editor--MDmN_7w.js +1 -0
- package/dist/assets/{key-bindings-BNeY-GEg.js → key-bindings-C1Zk8f6z.js} +1 -1
- package/dist/assets/{query-debug-BUUG3jpK.js → query-debug-YfWOzM6h.js} +1 -1
- package/dist/assets/{registry-DTWAywyJ.js → registry-J0TPxyW8.js} +2 -2
- package/dist/assets/{settings-jWfP7CP8.js → settings-B8BgCI2q.js} +1 -1
- package/dist/assets/settings-Ba8Od_Uj.js +14 -0
- package/dist/assets/{settings-DjnFAqIe.js → settings-D089lyYg.js} +1 -1
- package/dist/assets/{settings-DNhy58i9.js → settings-DLbaI3my.js} +1 -1
- package/dist/assets/{share-target-CgHlnZLH.js → share-target-CMIiAOIz.js} +1 -1
- package/dist/assets/{shared-BMoiShd9.js → shared-B6YGbqUJ.js} +1 -1
- package/dist/assets/{use-canvas-pins-Bth_Q--t.js → use-canvas-pins-6vnfChWd.js} +1 -1
- package/dist/assets/{useAgentModels-Sa4N8WFd.js → useAgentModels-Cxb5NyCI.js} +1 -1
- package/dist/assets/{workspace-area-menu-UamvRNfd.js → workspace-area-menu-Dg3hXKR3.js} +1 -1
- package/dist/assets/{workspaces-gQY1mczH.js → workspaces-BOYcqiRy.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/backend-sync-progress-BeI9mDEX.js +0 -7
- package/dist/assets/embedding-CEGjemkq.js +0 -1
- package/dist/assets/inferd-config-editor-BHUUFArV.js +0 -1
- package/dist/assets/settings-DH3ZiQLR.js +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Hr as r,I as i,J as a,Nt as o,X as s}from"./ui-Byg1cZDr.js";import{t as c}from"./utils-2pl1SbIp.js";import{t as l}from"./button-SgR3GVvV.js";import{t as u}from"./input-BOtCd4HP.js";import{c as d,t as f}from"./api-CA6WiiYM.js";import{n as p}from"./use-toast-BlLDqSUO.js";var m=e(n(),1),h=[`onnx`,`clip`,`blip`,`openai`],g=[`onnx`,`clip`,`blip`,`ollama`,`vllm`],_=[{id:`openai`,baseUrl:`https://api.openai.com/v1`,label:`OpenAI`},{id:`vllm`,baseUrl:`http://127.0.0.1:8000/v1`,label:`vLLM`},{id:`ollama`,baseUrl:`http://127.0.0.1:11434/v1`,label:`Ollama`}],v=e=>`${d.workspaces}/${encodeURIComponent(e)}/inferd`;function y(e,t){let n={};for(let[r,i]of Object.entries(e.providers||{})){let e={...i};delete e.apiKeySet,delete e.headerNames,t.has(r)&&i.apiKey?e.apiKey=i.apiKey:delete e.apiKey,n[r]=e}return{...e,providers:n}}async function b(e){return await f.get(`${v(e)}/status`)}async function x(e,t={}){let n={};return t.force!==void 0&&(n.force=t.force),t.scope&&(n.scope=t.scope),await f.post(`${v(e)}/summarize/images`,n)}async function ee(e){return await f.post(`${v(e)}/summarize/images/stop`,{})}async function S(e){return await f.get(`${v(e)}/config`)}async function C(e,t){return await f.put(`${v(e)}/config`,t)}async function w(e,t={}){let n={};return t.space&&(n.space=t.space),t.reindex!==void 0&&(n.reindex=t.reindex),t.scope&&(n.scope=t.scope),await f.post(`${v(e)}/reindex`,n)}async function T(e){return await f.get(`${v(e)}/vector-tables`)}async function E(e,t){return await f.delete(`${v(e)}/vector-tables/${encodeURIComponent(t)}`)}async function D(){return await f.get(`${d.inferd}/config`)}async function O(e){return await f.put(`${d.inferd}/config`,e)}async function k(){return await f.get(`${d.inferd}/defaults`)}async function te(e){return await f.put(`${d.inferd}/defaults`,e)}async function ne(e,t){let n={...e};return delete n.apiKeySet,delete n.headerNames,(await f.post(`${d.inferd}/test`,{provider:n,...t?{model:t}:{},probe:!0})).cached??null}async function re(e,t,n=`text`){let r={...e};return delete r.apiKeySet,delete r.headerNames,await f.post(`${d.inferd}/test`,{provider:r,...t?{model:t}:{},modality:n})}var A={text:{label:`Text & documents`,hint:`Notes, emails, documents and text files`},image:{label:`Photos & images`,hint:`Images, matched against what you type: "red bike in the snow" finds the photo`}},j={onnx:`Built-in text model`,clip:`Built-in image model`,blip:`Built-in image describer`,ollama:`Ollama on this server`,vllm:`vLLM on this server`,openai:`OpenAI`},M={onnx:`Built-in, text`,clip:`Built-in, images`,blip:`Built-in, image descriptions`,openai:`OpenAI-compatible server`},N=e=>e.charAt(0).toUpperCase()+e.slice(1);function P(e){return A[e]?.label??N(e)}function ie(e){return A[e]?.hint??null}function F(e){return j[e]??e}function I(e){return M[e]??e}var L=t(),R=`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:ring-2 focus:ring-ring`,z=`font-semibold uppercase tracking-[0.08em]`,B={openai:{url:{key:`baseUrl`,label:`Base URL`,placeholder:`http://gpu.local:8000/v1`,hint:`OpenAI-compatible embeddings endpoint — Ollama, vLLM, TEI, infinity, LM Studio and OpenAI itself all speak this. A trailing /v1 is optional; both http://host:8000 and http://host:8000/v1 work.`},apiKey:"Sent as `Authorization: Bearer …`. Leave empty for servers that do not check it.",note:`Any server that speaks the OpenAI embeddings API: a GPU machine running Ollama, vLLM or TEI, or a hosted service.`,imageInput:!0,timeoutMs:!0,headers:!0,where:e=>e.baseUrl||`no endpoint set`},ollama:{url:{key:`host`,label:`Host (legacy)`,placeholder:`http://127.0.0.1:11434`,hint:`Written by an older version. Switch the type to openai — the host becomes the base URL and the /v1 suffix is added for you.`},apiKey:"Sent as `Authorization: Bearer …`.",where:e=>e.host||`http://127.0.0.1:11434`},onnx:{cacheDir:`Where downloaded models are kept on the server. Empty uses the server default.`,note:`Text model that runs inside Canvas on this server. Nothing to connect; the model downloads on first use.`,where:()=>`runs on this server`},clip:{cacheDir:`Where downloaded models are kept on the server. Empty uses the server default.`,note:`Image model (CLIP) that runs inside Canvas on this server. It also understands text, which is how a typed search finds photos.`,where:()=>`runs on this server`},blip:{cacheDir:`Where downloaded models are kept on the server. Empty uses the server default.`,note:`Vision model that writes image descriptions, inside Canvas on this server. Configured under Image descriptions.`,where:()=>`runs on this server`}},ae=[`baseUrl`,`host`,`apiKey`,`cacheDir`,`imageInput`,`timeoutMs`],oe=[{value:`data-uri`,label:`data-uri (default)`,hint:"Images ride in the ordinary `input` array as data URIs (infinity, TEI-style servers)."},{value:`messages`,label:`messages`,hint:`vLLM's multimodal shape: one request per image, wrapped in a chat message.`}],se=12e4;function V(e){if(typeof e!=`string`||e.trim()===``)return null;let t;try{t=new URL(e.trim())}catch{return`Must be an absolute URL including the scheme, e.g. http://127.0.0.1:11434`}return t.protocol!==`http:`&&t.protocol!==`https:`?`Unsupported scheme '${t.protocol.replace(`:`,``)}'. Use http or https.`:null}function ce({title:e,hint:t}){return(0,L.jsxs)(`div`,{className:`mb-2`,children:[(0,L.jsx)(`h3`,{className:c(`text-[11px] text-muted-foreground`,z),children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t})]})}function H({overridden:e,source:t}){return e?(0,L.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,title:`Set on this layer; it wins over anything inherited`,children:`overridden`}):(0,L.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,title:t?`Inherited: ${t}`:`Inherited from a lower config layer`,children:`inherited`})}function U({label:e,value:t,inheritedValue:n,onChange:r,type:i=`text`,placeholder:a,disabled:o,hint:s,error:l,mono:d}){let f=t!==void 0&&t!==``;return(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`label`,{className:`text-xs font-medium`,children:e}),(0,L.jsx)(H,{overridden:f,source:n===void 0?void 0:String(n)}),f&&!o&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(``),className:`text-[10px] text-muted-foreground underline hover:text-foreground`,title:`Clear the override and fall back to the inherited value`,children:`reset`})]}),(0,L.jsx)(u,{type:i,value:t??``,disabled:o,onChange:e=>r(e.target.value),placeholder:a??(n===void 0?`—`:String(n)),className:c(`h-8 text-sm`,d&&`font-mono`,l&&`border-destructive focus-visible:ring-destructive`)}),l&&(0,L.jsx)(`p`,{className:`text-[11px] font-medium text-destructive`,children:l}),s&&(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s})]})}function W({label:e,checked:t,overridden:n,disabled:r,onChange:i}){return(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,L.jsx)(`input`,{type:`checkbox`,disabled:r,checked:t,onChange:e=>i(e.target.checked)}),e,(0,L.jsx)(H,{overridden:n})]})}function le({storedNames:e,value:t,disabled:n,onChange:r}){let i=t!==void 0,[a,c]=(0,m.useState)([]),d=e=>{c(e),r(Object.fromEntries(e.filter(([e])=>e.trim()!==``)))};return(0,L.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`label`,{className:`text-xs font-medium`,children:`Custom headers`}),i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`rounded bg-warning-subtle px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:`will replace stored`}),!n&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{c([]),r(void 0)},className:`text-[10px] text-muted-foreground underline hover:text-foreground`,children:`cancel`})]}):(0,L.jsx)(H,{overridden:!1,source:e?.join(`, `)})]}),!i&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e?.length?(0,L.jsxs)(L.Fragment,{children:[`Stored: `,(0,L.jsx)(`span`,{className:`font-mono`,children:e.join(`, `)}),` (values are never sent back)`]}):`None set.`}),!n&&(0,L.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c([[``,``]]),r({})},children:e?.length?`Replace headers`:`Add headers`})]}),i&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Saving replaces every stored header, so re-enter the ones you want to keep.`}),a.map(([e,t],r)=>(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(u,{value:e,disabled:n,placeholder:`X-Tenant`,className:`h-8 font-mono text-sm`,onChange:e=>d(a.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,L.jsx)(u,{value:t,disabled:n,placeholder:`value`,className:`h-8 font-mono text-sm`,onChange:e=>d(a.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,L.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,disabled:n,"aria-label":`Remove header ${e||r+1}`,onClick:()=>d(a.filter((e,t)=>t!==r)),children:(0,L.jsx)(s,{className:`h-3.5 w-3.5`})})]},r)),!n&&(0,L.jsxs)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>d([...a,[``,``]]),children:[(0,L.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5`}),`Add header`]})]})]})}function ue({open:e,onClick:t,label:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t,"aria-expanded":e,title:n,"aria-label":n,className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,L.jsx)(r,{className:c(`h-4 w-4 transition-transform motion-reduce:transition-none`,e&&`rotate-180`)})})}var de={configured:`bg-success`,"needs-fill":`bg-warning`,unresolved:`bg-destructive`,unset:`bg-muted-foreground/30`};function G({value:e,effective:t,inherited:n,resolvedSpaces:r,invalid:d,attention:f,onFill:v,saving:b=!1,disabled:x=!1,saveLabel:ee=`Save`,onSave:S}){let{showToast:C}=p(),[w,T]=(0,m.useState)(()=>structuredClone(e)),[E,D]=(0,m.useState)(new Set),[O,k]=(0,m.useState)(null),[te,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(``),[N,z]=(0,m.useState)(``),[G,K]=(0,m.useState)(null),q=(0,m.useMemo)(()=>[...new Set([...Object.keys(t.spaces||{}),...Object.keys(w.spaces||{})])].sort(),[t.spaces,w.spaces]),J=(0,m.useMemo)(()=>[...new Set([...Object.keys(t.providers||{}),...Object.keys(w.providers||{})])].sort(),[t.providers,w.providers]),Y=(e,t,n)=>{T(r=>{let i={...r.spaces||{}},a={...i[e]||{}};if(n===``)delete a[t];else if(t===`dim`||t===`maxLength`||t===`dimensions`){let e=Number(n);if(Number.isNaN(e))return r;a[t]=e}else a[t]=n;return Object.keys(a).length===0?delete i[e]:i[e]=a,{...r,spaces:i}})},fe=(e,t,n)=>{T(r=>{let i={...r.spaces||{}},a={...i[e]||{}};return n===void 0?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,{...r,spaces:i}})},X=(e,t,n)=>{t===`apiKey`&&D(t=>{let r=new Set(t);return n===``?r.delete(e):r.add(e),r}),T(r=>{let i={...r.providers||{}},a={...i[e]||{}};if(n===``)delete a[t];else if(t===`timeoutMs`){let e=Number(n);if(Number.isNaN(e))return r;a[t]=e}else a[t]=n;return Object.keys(a).length===0?delete i[e]:i[e]=a,{...r,providers:i}})},pe=(e,t,n)=>{T(r=>{let i={...r.providers||{}},a={...i[e]||{}};return n===void 0?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,{...r,providers:i}})},me=e=>{T(t=>{let n={...t.providers||{}};return delete n[e],{...t,providers:n}}),D(t=>{let n=new Set(t);return n.delete(e),n})},he=()=>{let e=N.trim();if(e){if(q.includes(e)){C({title:`Already listed`,description:`'${e}' already has a row above.`,variant:`destructive`});return}T(t=>({...t,spaces:{...t.spaces||{},[e]:{}}})),z(``),K(`space:${e}`)}},Z=(e,t)=>{if(e){if(J.includes(e)){C({title:`Already listed`,description:`'${e}' is already set up. Open it below to edit.`,variant:`destructive`});return}T(n=>({...n,providers:{...n.providers||{},[e]:{type:`openai`,...t?{baseUrl:t}:{}}}})),M(``),K(`provider:${e}`)}},ge=e=>({...t.providers?.[e]||{},...w.providers?.[e]||{}}),_e=async e=>{let n=w.spaces?.[e]?.provider??t.spaces?.[e]?.provider,r=w.spaces?.[e]?.model??t.spaces?.[e]?.model;if(!n){C({title:`Nothing to test`,description:`${P(e)} has no model provider set.`,variant:`destructive`});return}let i=ge(n),a=i.type?B[i.type]?.url?.key:void 0,o=a?V(i[a]):null;if(o){C({title:F(n),description:o,variant:`destructive`});return}k(e);try{try{await ne(i,r)===!1&&(A(!0),C({title:`Downloading model`,description:`'${r??`the configured model`}' is not in the server's cache yet; downloading now. A first test can take a few minutes; the model is then cached for good.`}))}catch{}let n=await re(i,r,e),a=w.spaces?.[e]?.dim??t.spaces?.[e]?.dim,o=n.dim>0&&a!==void 0&&n.dim!==a;(o||n.dim>0&&a===void 0)&&Y(e,`dim`,String(n.dim)),C({title:o?`Model answered; vector size corrected`:`Model answered`,description:o?`It returned ${n.dim}-d vectors but ${P(e)} was set to ${a}-d. Updated to ${n.dim}; save to apply. (${n.latencyMs} ms)`:`${n.dim}-d vectors in ${n.latencyMs} ms`})}catch(e){C({title:`Test failed`,description:e instanceof Error?e.message:`Model provider unreachable`,variant:`destructive`})}finally{k(null),A(!1)}},Q=(0,m.useMemo)(()=>{let e=[];for(let[n,r]of Object.entries(w.providers||{})){let i=r.type??t.providers?.[n]?.type,a=i?B[i]?.url?.key:void 0;if(!a)continue;let o=V(r[a]);o&&e.push(`${n}: ${o}`)}return e},[w.providers,t.providers]),$=(0,m.useMemo)(()=>JSON.stringify(w)!==JSON.stringify(e)||E.size>0,[w,e,E]),ve=async()=>{if(Q.length>0){C({title:`Fix the endpoint first`,description:Q.join(` · `),variant:`destructive`});return}await S(y(w,E)),D(new Set)},ye=e=>K(t=>t===e?null:e);return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[d&&(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive-subtle p-3 text-xs`,children:[(0,L.jsx)(a,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`font-medium text-destructive`,children:`Stored config does not resolve; defaults are standing in`}),(0,L.jsx)(`p`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground`,children:d})]})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(ce,{title:`Meaning-search models`,hint:`One model per kind of content. After switching a model, index your existing documents so they show up again. The old index is kept, so switching back costs nothing.`}),q.length===0?(0,L.jsxs)(`div`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:`No models set here`}),(0,L.jsx)(`p`,{className:`mx-auto mt-1 max-w-sm text-xs text-muted-foreground`,children:`Add a content type below and pick where its model runs.`})]}):(0,L.jsx)(`div`,{className:`divide-y overflow-hidden rounded-lg border`,children:q.map(e=>{let a=w.spaces?.[e]||{},o=t.spaces?.[e]||{},s=n.spaces?.[e]||{},u=r?.[e],p=`space:${e}`,m=G===p,h=a.model??o.model,g=a.provider??o.provider,_=a.dim??o.dim,y=a.chunk??o.chunk??!1,b=f?.includes(e)??!1;return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`span`,{className:c(`absolute inset-y-0 left-0 w-[3px]`,de[d?`unresolved`:b?`needs-fill`:h?`configured`:`unset`]),"aria-hidden":!0}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 py-3 pl-4 pr-3 sm:flex-row sm:items-start sm:gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:P(e)}),(0,L.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,title:`Content type id in the config`,children:e})]}),ie(e)&&(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:ie(e)}),(0,L.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,L.jsx)(`span`,{className:`truncate font-mono text-xs`,children:h||`no model set`}),g&&(0,L.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,title:`Provider id: ${g}`,children:F(g)}),_!==void 0&&(0,L.jsxs)(`span`,{className:`text-[11px] tabular-nums text-muted-foreground`,title:`Vector size: how many numbers the model produces per item`,children:[_,`-d`]}),y&&(0,L.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`long documents split`})]}),r&&h&&(0,L.jsxs)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,title:`Where this model's index is stored`,children:[`└─ `,u?.table??(0,L.jsx)(`span`,{className:`not-italic`,children:`not created yet`})]}),b&&(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-warning`,children:`New model, nothing indexed with it yet. Existing documents of this type won't show up in meaning search until you index them. Switching back is still instant.`})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 max-sm:justify-end`,children:[b&&v&&(0,L.jsx)(l,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>v(e),children:`Index existing`}),(0,L.jsxs)(l,{type:`button`,size:`sm`,variant:`ghost`,disabled:x||O!==null,onClick:()=>_e(e),title:`Send a sample to this model and check that it answers (also reports its vector size)`,children:[(0,L.jsx)(i,{className:`mr-1.5 h-3.5 w-3.5`}),O===e?te?`Downloading…`:`Testing…`:`Test`]}),(0,L.jsx)(ue,{open:m,onClick:()=>ye(p),label:`Edit ${P(e)}`})]})]}),m&&(0,L.jsxs)(`div`,{className:`border-t bg-muted/40 py-4 pl-4 pr-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`label`,{className:`text-xs font-medium`,children:`Runs on`}),(0,L.jsx)(H,{overridden:a.provider!==void 0,source:s.provider})]}),(0,L.jsxs)(`select`,{className:R,disabled:x,value:a.provider??``,onChange:t=>Y(e,`provider`,t.target.value),children:[(0,L.jsx)(`option`,{value:``,children:o.provider?`Default: ${F(o.provider)}`:`Default`}),J.map(e=>(0,L.jsxs)(`option`,{value:e,children:[F(e),F(e)===e?``:` (${e})`]},e))]})]}),(0,L.jsx)(U,{label:`Model`,mono:!0,value:a.model,inheritedValue:o.model,onChange:t=>Y(e,`model`,t),disabled:x}),(0,L.jsx)(U,{label:`Vector size`,type:`number`,value:a.dim,inheritedValue:o.dim,onChange:t=>Y(e,`dim`,t),disabled:x,hint:`How many numbers the model produces per item. Test asks the model and fills in the real value.`}),(0,L.jsx)(U,{label:`Max input length`,type:`number`,value:a.maxLength,inheritedValue:o.maxLength,onChange:t=>Y(e,`maxLength`,t),disabled:x,hint:`Longest piece of text, in tokens, the model reads at once.`})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-4`,children:[(0,L.jsx)(W,{label:`Split long documents into parts`,checked:y,overridden:a.chunk!==void 0,disabled:x,onChange:t=>fe(e,`chunk`,t)}),(0,L.jsx)(W,{label:`Fast lookup index (ANN)`,checked:a.annIndex??o.annIndex??!0,overridden:a.annIndex!==void 0,disabled:x,onChange:t=>fe(e,`annIndex`,t)})]})]})]},e)})}),!x&&(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(u,{value:N,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),he())},placeholder:`new content type (e.g. audio)`,className:`h-8 w-full max-w-xs text-sm sm:w-auto`}),(0,L.jsxs)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:he,children:[(0,L.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5`}),`Add content type`]})]})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(ce,{title:`Where models run`,hint:`Built-in models run inside Canvas on this server and need no setup. To use a GPU machine or a hosted API, add an OpenAI-compatible server here, then pick it under the models above.`}),(0,L.jsx)(`div`,{className:`divide-y overflow-hidden rounded-lg border`,children:J.map(e=>{let n=w.providers?.[e]||{},r=t.providers?.[e]||{},i=g.includes(e),a=w.providers?.[e]!==void 0,o=`provider:${e}`,c=G===o,d=n.type??r.type,f=d?B[d]:void 0,p=f?.url?V(n[f.url.key]):null,m={...r,...n},_=ae.filter(e=>!(n[e]===void 0||e===f?.url?.key||e===`apiKey`&&f?.apiKey||e===`cacheDir`&&f?.cacheDir)),v=q.filter(n=>(w.spaces?.[n]?.provider??t.spaces?.[n]?.provider)===e);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 px-4 py-3 sm:flex-row sm:items-start sm:gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold`,children:F(e)}),F(e)!==e&&(0,L.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:d?I(d):`no type`}),i&&(0,L.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`preset`}),m.apiKeySet&&!E.has(e)&&(0,L.jsx)(`span`,{className:`text-[10px] font-medium text-success`,children:`key set`}),p&&(0,L.jsx)(`span`,{className:`text-[10px] font-medium text-destructive`,children:`check endpoint`})]}),(0,L.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:f?f.where(m):`—`}),v.length>0&&(0,L.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[`used for `,v.map(P).join(`, `).toLowerCase()]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 max-sm:justify-end`,children:[a&&!i&&!x&&(0,L.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>me(e),title:`Remove this override`,children:(0,L.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(ue,{open:c,onClick:()=>ye(o),label:`Edit ${F(e)}`})]})]}),c&&(0,L.jsxs)(`div`,{className:`border-t bg-muted/40 px-4 py-4`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`label`,{className:`text-xs font-medium`,children:`Type`}),(0,L.jsx)(H,{overridden:n.type!==void 0,source:r.type})]}),(0,L.jsxs)(`select`,{className:R,disabled:x,value:n.type??``,onChange:t=>X(e,`type`,t.target.value),children:[(0,L.jsx)(`option`,{value:``,children:r.type?`Default: ${I(r.type)}`:`Default`}),h.map(e=>(0,L.jsx)(`option`,{value:e,children:I(e)},e)),d&&!h.includes(d)&&(0,L.jsxs)(`option`,{value:d,children:[d,` (legacy)`]})]}),f?.note&&(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:f.note})]}),f?.url&&(0,L.jsx)(U,{label:f.url.label,mono:!0,value:n[f.url.key],inheritedValue:r[f.url.key],onChange:t=>X(e,f.url.key,t),disabled:x,placeholder:r[f.url.key]??f.url.placeholder,hint:f.url.hint,error:p??void 0}),f?.cacheDir&&(0,L.jsx)(U,{label:`Cache directory`,mono:!0,value:n.cacheDir,inheritedValue:r.cacheDir,onChange:t=>X(e,`cacheDir`,t),disabled:x,placeholder:r.cacheDir??`server default`,hint:f.cacheDir}),f?.imageInput&&(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`label`,{className:`text-xs font-medium`,children:`Image input shape`}),(0,L.jsx)(H,{overridden:n.imageInput!==void 0,source:r.imageInput})]}),(0,L.jsxs)(`select`,{className:R,disabled:x,value:n.imageInput??``,onChange:t=>X(e,`imageInput`,t.target.value),children:[(0,L.jsx)(`option`,{value:``,children:r.imageInput?`inherited: ${r.imageInput}`:`inherited: data-uri`}),oe.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:oe.find(e=>e.value===(n.imageInput??r.imageInput??`data-uri`))?.hint})]}),f?.timeoutMs&&(0,L.jsx)(U,{label:`Request timeout (ms)`,type:`number`,value:n.timeoutMs,inheritedValue:r.timeoutMs??se,onChange:t=>X(e,`timeoutMs`,t),disabled:x,hint:`How long to wait for a batch before giving up. Raise it for a slow or cold GPU host.`}),f?.apiKey&&(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`label`,{className:`text-xs font-medium`,children:`API key`}),E.has(e)&&(0,L.jsx)(`span`,{className:`rounded bg-warning-subtle px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:`will be written`})]}),(0,L.jsx)(u,{type:`password`,autoComplete:`new-password`,disabled:x,value:n.apiKey??``,onChange:t=>X(e,`apiKey`,t.target.value),placeholder:r.apiKeySet?`•••••••• (stored; leave empty to keep)`:`unset`,className:`h-8 text-sm`}),(0,L.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[f.apiKey,` Write-only: the stored key is never sent back, and leaving this empty keeps whatever is stored.`]})]})]}),f?.headers&&(0,L.jsx)(le,{disabled:x,storedNames:r.headerNames,value:n.headers,onChange:t=>pe(e,`headers`,t)}),_.length>0&&!x&&(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 rounded-md border border-dashed p-2 text-[11px] text-muted-foreground`,children:[(0,L.jsxs)(`span`,{children:[`Not used by type `,(0,L.jsx)(`span`,{className:`font-mono`,children:d}),`:`,` `,(0,L.jsx)(`span`,{className:`font-mono`,children:_.join(`, `)})]}),(0,L.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,onClick:()=>_.forEach(t=>X(e,t,``)),children:`clear`})]}),r.headerNames&&r.headerNames.length>0&&(0,L.jsxs)(`p`,{className:`mt-3 text-[11px] text-muted-foreground`,children:[`Stored custom headers: `,(0,L.jsx)(`span`,{className:`font-mono`,children:r.headerNames.join(`, `)}),` (values not shown)`]})]})]},e)})}),!x&&(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(u,{value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Z(j.trim()))},placeholder:`name for a server (e.g. gpu)`,className:`h-8 w-full max-w-xs text-sm sm:w-auto`}),(0,L.jsxs)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>Z(j.trim()),children:[(0,L.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5`}),`Add server`]}),_.filter(e=>!J.includes(e.id)).map(e=>(0,L.jsx)(l,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>Z(e.id,e.baseUrl),title:`Add ${e.label} at ${e.baseUrl}`,children:e.label},e.id))]})]}),!x&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-t pt-4`,children:[(0,L.jsx)(l,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:ve,disabled:b||!$||Q.length>0,children:b?`Saving…`:ee}),(0,L.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,disabled:b||!$,onClick:()=>{T(structuredClone(e)),D(new Set)},children:`Discard changes`}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Q.length>0?(0,L.jsxs)(`span`,{className:`font-medium text-destructive`,children:[Q.length,` endpoint `,Q.length===1?`needs`:`need`,` fixing`]}):$?`Unsaved changes`:`Everything saved`})]})]})}export{D as a,T as c,O as d,C as f,k as i,w as l,ee as m,P as n,S as o,x as p,E as r,b as s,G as t,te as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{ct as r,lt as i,ut as a}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{ct as r,lt as i,ut as a}from"./index-Tx_qtD_m.js";import{n as o}from"./page-header-DkOHw0g-.js";import{t as s}from"./use-settings-back-CQauYjQ4.js";var c=e(n(),1),l=t();function u(){let[e,t]=(0,c.useState)(i),[n,u]=(0,c.useState)(``),d=e=>{if(e.previousTree&&e.previousTree===e.nextTree){u(`Choose a different shortcut: that combination is already assigned.`);return}try{a(e),t(e),u(`Saved on this device.`)}catch{u(`Could not save shortcuts in this browser.`)}};return(0,l.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,l.jsx)(o,{className:`mb-6`,title:`Key bindings`,onBack:s(),description:`Web UI shortcuts, saved on this device and available offline.`}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`font-medium`,children:`Tree navigation`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cycle the open workspace menu’s tabs in their displayed order, including Pins and Layers. Swipe left for next or right for previous over the tab bar. Shortcuts pause while typing or using a dialog.`}),[`previousTree`,`nextTree`].map(t=>(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,l.jsx)(`label`,{htmlFor:t,className:`min-w-32 text-sm`,children:t===`previousTree`?`Previous tree`:`Next tree`}),(0,l.jsxs)(`select`,{id:t,className:`rounded-md border bg-background p-2 text-sm`,value:e[t].split(`+`).slice(0,-1).join(`+`),onChange:n=>d({...e,[t]:n.target.value?`${n.target.value}+${e[t].slice(-1)||r[t].slice(-1)}`:``}),children:[(0,l.jsx)(`option`,{value:``,children:`Disabled`}),[`Alt`,`Alt+Shift`,`Ctrl+Shift`,`Meta+Shift`].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))]}),(0,l.jsx)(`select`,{"aria-label":`${t===`previousTree`?`Previous`:`Next`} tree key`,disabled:!e[t],className:`rounded-md border bg-background p-2 text-sm disabled:opacity-50`,value:e[t].slice(-1)||r[t].slice(-1),onChange:n=>d({...e,[t]:`${e[t].split(`+`).slice(0,-1).join(`+`)}+${n.target.value}`}),children:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``).map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]},t)),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browsers and operating systems may reserve combinations. Choose another if a shortcut does not reach Canvas. Letters refer to physical keyboard positions (Q/W on a US keyboard); Meta is Command on Mac.`}),(0,l.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 text-sm hover:bg-accent`,onClick:()=>d({...r}),children:`Restore defaults`}),(0,l.jsx)(`p`,{role:`status`,className:`text-sm`,children:n})]})]})}export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Gn as r,Ot as i,Tt as a,X as o,hr as s,ir as c}from"./ui-Byg1cZDr.js";import{t as l}from"./button-SgR3GVvV.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./api-CA6WiiYM.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{h as p,o as m,s as h}from"./LinkToCard-nR7Lal_o.js";import{$ as g,I as _,Pn as v,Sn as y,St as b,bt as x,gt as S,in as C}from"./workspace-DvxC7pw1.js";import{a as w,c as T,l as E,n as D,o as O,r as k,u as A}from"./backend-sync-progress-BeI9mDEX.js";import{t as j}from"./workspace-access-C9nZlBBZ.js";var M=e(n(),1),N={membership:`keep`,propagation:`never`,targets:[],acceptPropagatedDeletions:!1},P=e=>`/workspaces/${encodeURIComponent(e)}/trash/operations`,F=(e,t)=>d.get(`${P(e)}?${new URLSearchParams(Object.entries(t).map(([e,t])=>[e,String(t)]))}`),I=(e,t,n,r={})=>d.post(`${P(e)}/${n}`,{ids:t,...r}),L=(e,t,n,r)=>d.patch(`/workspaces/${encodeURIComponent(e)}/backends/imap/${encodeURIComponent(t)}/containers/${encodeURIComponent(n)}`,{removalPolicy:r}),R=t();function z(e){let t=T(`backends`,e.path)?.backend;return(0,R.jsx)(B,{...e},JSON.stringify([e.workspace,t]))}function B({workspace:e,path:t,onNavigate:n}){let l=T(`backends`,t),u=l.backend,d=l.prefix,[f,g]=(0,M.useState)(null),[_,v]=(0,M.useState)(null),y=(0,M.useRef)(!1),[b,S]=(0,M.useState)(null),[C,j]=(0,M.useState)(null),[N,P]=(0,M.useState)(0),[F,I]=(0,M.useState)(new Set),[L,z]=(0,M.useState)(null),B=(0,M.useCallback)(()=>P(e=>e+1),[]),[V,H]=(0,M.useState)(t);V!==t&&(H(t),I(new Set),z(null),j(null),S(null));let U=f?.revision!==N,W=U?[]:f.items,G=U?[]:f.backends,K=f?.days;(0,M.useEffect)(()=>{let t=!1;return(u?w(e,u).then(e=>({...e,backends:[]})):x(e).then(e=>({items:[],days:null,backends:e.filter(e=>e.driver===`file`&&e.enabled!==!1)}))).then(e=>{t||g({...e,revision:N,error:null})}).catch(e=>{t||g({revision:N,items:[],backends:[],days:null,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,u,N]),(0,M.useEffect)(()=>{let t=null,n=n=>{let r=n.detail;r?.workspaceName&&r.workspaceName!==e||r?.treeName&&r.treeName!==`backends`||(t||=setTimeout(()=>{t=null,B()},500))};return window.addEventListener(`workspace:trash:refresh`,n),window.addEventListener(`workspace:tree:refresh`,n),()=>{window.removeEventListener(`workspace:trash:refresh`,n),window.removeEventListener(`workspace:tree:refresh`,n),t&&clearTimeout(t)}},[e,B]);let q=A(W,d),J=async(t,n)=>{if(!(!u||y.current||U||!n.length)&&!(t===`discard`&&!D(u,n))){y.current=!0,v(t),S(null),j(null),z(null);try{let r=await(t===`restore`?O:k)(e,u,[...n].sort((e,t)=>t.deletedAt-e.deletedAt).map(e=>e.id)),i=r.filter(e=>!e.ok);j(`${r.length-i.length} item(s) ${t===`restore`?`restored to their original paths`:`permanently deleted`}.`),i.length&&S(`${i.length} item(s) remain in Trash. ${i.slice(0,3).map(e=>`${e.key||`Item`}: ${e.reason===`precondition-failed`||e.reason===`target-exists`?`original path is occupied`:e.message||e.reason}`).join(`; `)}`),I(new Set)}catch(e){S(e instanceof Error?e.message:String(e))}finally{y.current=!1,v(null),B()}}},Y=(e,t,n)=>z({x:e,y:t,row:n});return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":`Backend Trash`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b px-4 py-3`,children:[(0,R.jsx)(o,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(h,{items:m(t,e).map((e,t)=>t===2&&u?{...e,label:u}:e),onNavigate:n,className:`basis-48`}),(0,R.jsxs)(`div`,{className:`ml-auto flex max-w-full flex-wrap items-center gap-2`,children:[F.size>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`restore`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(a,{className:`h-3.5 w-3.5`}),`Restore selected`]}),(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(o,{className:`h-3.5 w-3.5`}),`Delete selected`]})]}),u&&q.length>0&&(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.flatMap(e=>e.items)),children:[(0,R.jsx)(o,{className:`h-3.5 w-3.5`}),d?`Empty this folder`:`Empty Trash`]}),(0,R.jsx)(`button`,{title:`Refresh Trash`,"aria-label":`Refresh Trash`,className:`rounded p-2 hover:bg-accent`,disabled:!!_||U,onClick:B,children:(0,R.jsx)(i,{className:`h-4 w-4 ${U?`animate-spin`:``}`})})]})]}),(0,R.jsxs)(`div`,{className:`border-b px-4 py-2 text-xs text-muted-foreground`,children:[`Restore files and folders to their original paths. Existing files are kept.`,K?` Deleted items are kept for ${K} days.`:``]}),C&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:C}),(b||f?.error)&&(0,R.jsx)(`p`,{role:`alert`,className:`px-4 py-2 text-sm text-destructive`,children:b||f?.error}),_&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:_===`restore`?`Restoring…`:`Deleting permanently…`}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:U?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Trash…`}):u?q.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`This Trash folder is empty.`}):(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b text-xs text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`w-8 p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all visible items`,checked:q.length>0&&q.every(e=>F.has(e.id)),onChange:e=>I(e.target.checked?new Set(q.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-2`,children:`Name`}),(0,R.jsx)(`th`,{className:`p-2 max-sm:hidden`,children:`Original path`}),(0,R.jsx)(`th`,{className:`p-2 max-md:hidden`,children:`Deleted`}),(0,R.jsx)(`th`,{className:`p-2`,children:(0,R.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,R.jsx)(`tbody`,{children:q.map(e=>(0,R.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-accent/50`,onContextMenu:t=>{t.preventDefault(),Y(t.clientX,t.clientY,e)},onDoubleClick:()=>e.navigable&&n(E(u,e.key)),children:[(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:F.has(e.id),disabled:!!_,onChange:t=>I(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsxs)(`button`,{className:`flex items-center gap-2 text-left`,onClick:()=>e.navigable&&n(E(u,e.key)),children:[e.directory?(0,R.jsx)(r,{className:`h-4 w-4 shrink-0`}):(0,R.jsx)(c,{className:`h-4 w-4 shrink-0`}),(0,R.jsxs)(`span`,{children:[e.name,e.navigable&&(0,R.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.items.length,` items`]})]})]})}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-sm:hidden`,children:e.key}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-md:hidden`,children:new Date(e.items.reduce((e,t)=>Math.max(e,t.deletedAt),0)).toLocaleString()}),(0,R.jsx)(`td`,{className:`p-2 text-right`,children:(0,R.jsx)(`button`,{title:`Actions for ${e.name}`,"aria-label":`Actions for ${e.name}`,disabled:!!_,className:`rounded p-2 hover:bg-accent`,onClick:t=>Y(t.clientX,t.clientY,e),children:(0,R.jsx)(s,{className:`h-4 w-4`})})})]},e.id))})]}):(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:[G.map(e=>(0,R.jsxs)(`button`,{onClick:()=>n(E(e.address)),className:`flex items-center gap-3 rounded-lg border p-4 text-left hover:bg-accent`,children:[(0,R.jsx)(o,{className:`h-6 w-6 text-muted-foreground`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:e.label||e.address}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.address})]})]},e.address)),!G.length&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No file backends are available.`})]})}),L&&(0,R.jsxs)(p,{x:L.x,y:L.y,onClose:()=>z(null),className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[L.row.navigable&&(0,R.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent`,onClick:()=>{n(E(u,L.row.key)),z(null)},children:[(0,R.jsx)(r,{className:`h-4 w-4`}),`Open folder`]}),(0,R.jsxs)(`button`,{disabled:!!_,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent disabled:opacity-50`,onClick:()=>void J(`restore`,L.row.items),children:[(0,R.jsx)(a,{className:`h-4 w-4`}),`Restore `,L.row.directory?`folder`:`file`]}),(0,R.jsxs)(`button`,{disabled:!!_||U,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50`,onClick:()=>void J(`discard`,L.row.items),children:[(0,R.jsx)(o,{className:`h-4 w-4`}),`Delete permanently`]})]})]})}function V({value:e,backends:t,source:n,onSave:r,destination:i=!0}){let[a,o]=(0,M.useState)({...N,...e}),[s,c]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=`rounded border bg-background px-2 py-1.5 text-xs w-full`,p=async()=>{c(!0),d(``);try{await r(a),d(`Removal policy saved.`)}catch(e){d(e instanceof Error?e.message:`Could not save policy`)}finally{c(!1)}};return(0,R.jsxs)(`details`,{className:`border-t pt-3 text-xs`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Source removals and Trash`}),(0,R.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`A completed scan removes missing locations from the backend tree. Items with no remaining locations go to Trash until you purge them.`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`When an item disappears from this source`,(0,R.jsxs)(`select`,{className:f,value:a.membership,disabled:s,onChange:e=>o({...a,membership:e.target.value}),children:[(0,R.jsx)(`option`,{value:`keep`,children:`Keep in managed trees`}),(0,R.jsx)(`option`,{value:`review`,children:`Review removal in Trash`}),(0,R.jsx)(`option`,{value:`trash`,children:`Move to Trash automatically`})]})]}),(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`Remove tracked copies from other backends`,(0,R.jsxs)(`select`,{className:f,value:a.propagation,disabled:s,onChange:e=>o({...a,propagation:e.target.value}),children:[(0,R.jsx)(`option`,{value:`never`,children:`Never`}),(0,R.jsx)(`option`,{value:`review`,children:`Review in Trash`}),(0,R.jsx)(`option`,{value:`automatic`,children:`Automatically, retaining recovery copies`})]})]})]}),a.propagation!==`never`&&(0,R.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,R.jsx)(`legend`,{className:`mb-1 font-medium`,children:`Destinations`}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.targets===`all`,disabled:s,onChange:e=>o({...a,targets:e.target.checked?`all`:[]})}),`All eligible backends`]}),a.targets!==`all`&&t.filter(e=>e.address!==n&&e.kind===`storage`).map(e=>(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s||e.config?.propagatedRemovalSupported!==!0,checked:a.targets.includes(e.address),onChange:t=>o({...a,targets:t.target.checked?[...a.targets,e.address]:a.targets.filter(t=>t!==e.address)})}),String(e.config?.label||e.address),e.config?.propagatedRemovalSupported===!0?!e.config?.removalPolicy?.acceptPropagatedDeletions&&` · protected`:` · recovery removal unavailable`]},e.address)),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Only tracked, Canvas-owned copies are eligible. Protected destinations refuse propagated deletion. Recovery removal currently supports filesystem and workspace blob storage; remote destinations remain protected.`})]}),i&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s,checked:a.acceptPropagatedDeletions,onChange:e=>o({...a,acceptPropagatedDeletions:e.target.checked})}),`Accept propagated deletions on this backend`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:s,onClick:()=>void p(),children:s?`Saving…`:`Save removal policy`}),(0,R.jsx)(`span`,{role:`status`,children:u})]})]})]})}function H({workspaceName:e,canWrite:t}){let{showToast:n}=f(),[r,s]=(0,M.useState)([]),[c,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)([]),[m,h]=(0,M.useState)(!1),g=(0,M.useCallback)(async()=>{u(!0);try{s(await b(e))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to load the trash`,variant:`destructive`})}finally{u(!1)}},[e]);(0,M.useEffect)(()=>{g()},[g]);let y=(0,M.useCallback)(e=>d.includes(e),[d]),x=async(e,t)=>{p(t=>[...t,...e]);try{await t()}finally{p(t=>t.filter(t=>!e.includes(t)))}},S=t=>x([t.id],async()=>{try{let r=await C(e,[t.id]);r.failed?.length?n({title:`Not restored`,description:r.failed[0]?.error||`No restore target recorded`,variant:`destructive`}):(n({title:`Restored`,description:`Document put back where it was.`}),s(e=>e.filter(e=>e.id!==t.id)))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to restore`,variant:`destructive`})}}),w=t=>x([t.id],async()=>{try{let r=await _(e,[t.id]);if(r.failed?.length)throw Error(`The item could not be purged. Refresh and retry.`);n({title:`Cleared from Trash`,description:r.preserved?.length?`Existing backend copies remain indexed.`:`Document permanently deleted.`}),s(e=>e.filter(e=>e.id!==t.id))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to delete`,variant:`destructive`})}}),T=async()=>{if(!m){h(!0);return}h(!1);try{let t=await _(e);n({title:`Trash emptied`,description:`${t.destroyed?.length??0} document(s) purged. ${t.preserved?.length??0} item(s) cleared with backend copies preserved.`}),await g()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to empty the trash`,variant:`destructive`})}},E=(0,M.useMemo)(()=>r.map(e=>{let t=v(e),n=(e.trashed?.placements??[]).flatMap(e=>e.paths.map(t=>`${e.tree}:${t}`));return{document:e,title:t.title,origin:n,trashedAt:e.trashed?.trashedAt||null}}),[r]);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Managed-tree items`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-2xl`,children:`Restore managed-tree placements or permanently purge these items. Pending removals require separate approval. Backend copies are managed below.`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-sm:flex-wrap`,children:[(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>g(),disabled:c,children:[(0,R.jsx)(i,{className:`mr-2 h-3.5 w-3.5 ${c?`animate-spin`:``}`}),`Refresh`]}),(0,R.jsxs)(l,{variant:m?`destructive`:`outline`,size:`sm`,onClick:T,onBlur:()=>h(!1),disabled:!t||r.length===0,children:[(0,R.jsx)(o,{className:`mr-2 h-3.5 w-3.5`}),m?`Click again to delete everything`:`Empty trash`]})]})]}),c&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),!c&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The trash is empty.`}),E.length>0&&(0,R.jsx)(`div`,{className:`border rounded-md divide-y`,children:E.map(({document:e,title:n,origin:r,trashedAt:i})=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm`,children:n}),(0,R.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[r.length>0?`from ${r.join(`, `)}`:`no recorded origin`,i?` · ${new Date(i).toLocaleString()}`:``]})]}),(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>S(e),disabled:!t||y(e.id)||r.length===0,title:r.length===0?`Nothing recorded to restore to`:`Put it back where it was`,children:[(0,R.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),`Restore placements`]}),(0,R.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>w(e),disabled:!t||y(e.id),title:`Delete permanently`,children:(0,R.jsx)(o,{className:`h-3.5 w-3.5`})})]},e.id))})]})}function U({workspaceName:e}){return(0,R.jsx)(W,{workspaceName:e},e)}function W({workspaceName:e}){let[t,n]=(0,M.useState)(`pending`),[r,a]=(0,M.useState)(``),[o,s]=(0,M.useState)(``),[c,d]=(0,M.useState)(0),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(null),[_,v]=(0,M.useState)(``),[b,C]=(0,M.useState)(!1),[w,T]=(0,M.useState)(new Set),[E,D]=(0,M.useState)({}),[O,k]=(0,M.useState)(`/Trash`),[A,P]=(0,M.useState)([]),[B,U]=(0,M.useState)({write:!1,admin:!1});(0,M.useEffect)(()=>{let t=!0;return g(e).then(e=>{let n=e.remote?.permissions||e.access?.permissions||(typeof e.sharedVia==`object`?e.sharedVia?.permissions:[])||[],r=j(e);t&&U({admin:r,write:r||n.includes(`write`)})}).catch(()=>{}),()=>{t=!1}},[e]);let[W,G]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=!0;return x(e).then(e=>{t&&P(e)}).catch(()=>{}),()=>{t=!1}},[e]),(0,M.useEffect)(()=>{let n=!1,i=()=>F(e,{view:t,search:r,...o?{backend:o}:{},offset:c}).then(e=>{n||(h(e),v(``))}).catch(e=>{n||v(e instanceof Error?e.message:`Could not load Trash`)});i();let a=setInterval(()=>{b||i()},5e3);return()=>{n=!0,clearInterval(a)}},[e,t,r,o,c,f,b]);let K=m?.operations||[],q=()=>{T(new Set),p(e=>e+1)},J=()=>{S(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),window.dispatchEvent(new CustomEvent(`workspace:trash:refresh`,{detail:{workspaceName:e}}))},Y=async(t,n=[...w])=>{if(!(!n.length||b)&&!(t===`purge`&&!window.confirm(`Permanently delete retained recovery copies for ${n.length} operation(s)?`))){C(!0),v(``);try{let r=(t===`approve`?(await Promise.all(n.map(n=>I(e,[n],t,E[n])))).flatMap(e=>e.results):(await I(e,n,t)).results).filter(e=>!e.ok||e.operation?.state===`failed`);r.length&&v(r.map(e=>e.error||e.operation?.error||`A destination could not be changed. Expand the item for details.`).join(` `)),J(),q()}catch(e){v(e instanceof Error?e.message:`Trash action failed`)}finally{C(!1)}}},X=e=>{n(e),d(0),h(null),T(new Set),D({})};return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold`,children:`Workspace Trash`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Review source removals, recover items, and see what automatic policies changed.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`tablist`,"aria-label":`Trash views`,children:[[[`pending`,`Pending removal`],[`trashed`,`In Trash`],[`activity`,`Activity`]].map(([e,n])=>(0,R.jsx)(l,{role:`tab`,"aria-selected":t===e,size:`sm`,variant:t===e?`default`:`outline`,onClick:()=>X(e),children:n},e)),(0,R.jsxs)(l,{size:`sm`,variant:`ghost`,className:`ml-auto`,onClick:q,disabled:b,children:[(0,R.jsx)(i,{className:`mr-2 h-3.5 w-3.5`}),`Refresh`]})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{workspaceName:e,canWrite:B.write},f),(0,R.jsxs)(`details`,{className:`rounded border p-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Browse backend recovery copies`}),(0,R.jsx)(`div`,{className:`mt-3 min-h-48`,children:(0,R.jsx)(z,{workspace:e,path:O,onNavigate:k})})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(u,{"aria-label":`Filter Trash items`,placeholder:`Filter by item or path…`,className:`max-w-xs`,value:r,onChange:e=>{a(e.target.value),h(null),d(0),T(new Set)}}),(0,R.jsx)(u,{"aria-label":`Filter by backend`,placeholder:`Backend name…`,className:`max-w-56`,value:o,onChange:e=>{s(e.target.value),h(null),d(0),T(new Set)}}),w.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,R.jsxs)(`span`,{children:[w.size,` selected`]}),t===`pending`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,disabled:b,onClick:()=>void Y(`approve`),children:`Approve selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void Y(`keep`),children:`Keep selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void Y(`retry`),children:`Retry`})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void Y(`restore`),children:`Restore copies`}),(0,R.jsx)(l,{size:`sm`,variant:`destructive`,disabled:b,onClick:()=>void Y(`purge`),children:`Purge copies`})]})]})]}),W&&(0,R.jsxs)(`div`,{className:`rounded border p-3 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Removal policy · `,W.source.account||W.source.backend,W.source.folder?` / ${W.source.folder}`:``]}),(0,R.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>G(null),children:`Close`})]}),(0,R.jsx)(V,{source:W.source.backend,backends:A,destination:!1,value:{...N,...A.find(e=>e.address===W.source.backend)?.config?.removalPolicy,membership:E[W.id]?.membership??W.membership!==`keep`?`review`:`keep`,propagation:W.targets.length?`review`:`never`,targets:[...new Set(W.targets.filter(e=>!E[W.id]||E[W.id].targets.includes(JSON.stringify([e.backend,e.key]))).map(e=>e.backend))]},onSave:async t=>{W.source.driver===`imap`?await L(e,W.source.account,W.source.folder,t):await y(e,W.source.driver,W.source.backend,{removalPolicy:t}),P(await x(e))}},W.id)]}),_&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,R.jsxs)(`div`,{className:`overflow-x-auto rounded border`,children:[(0,R.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,R.jsx)(`thead`,{className:`bg-muted`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`p-3 w-8`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select visible operations`,disabled:!B.write||b||!K.length||t===`activity`,checked:K.length>0&&K.every(e=>w.has(e.id)),onChange:e=>T(e.target.checked?new Set(K.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-3`,children:`Item and affected copies`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Source`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Detected`})]})}),(0,R.jsx)(`tbody`,{children:K.map(e=>{let n=E[e.id]||{targets:e.targets.filter(e=>e.state!==`kept`).map(e=>JSON.stringify([e.backend,e.key])),membership:e.membership!==`keep`};return(0,R.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,R.jsx)(`td`,{className:`p-3`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,disabled:!B.write||b||t===`activity`,checked:w.has(e.id),onChange:t=>T(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-3 min-w-64`,children:(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,R.jsxs)(`div`,{className:`mt-2 space-y-2 text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:e.orphan?`No remaining byte locations. Restore placements only unless recovery bytes are available.`:`${e.remainingLocations.length} remaining location(s) when detected.`}),e.placements.map(e=>(0,R.jsxs)(`p`,{children:[e.tree,`: `,e.paths.join(`, `)]},e.tree)),e.membership!==`keep`&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:n.membership,disabled:b||t!==`pending`||e.membershipApplied,onChange:t=>D({...E,[e.id]:{...n,membership:t.target.checked}})}),e.membershipApplied?`Managed placements moved to Trash`:`Move managed placements to Trash`]}),e.targets.map(r=>{let i=JSON.stringify([r.backend,r.key]);return(0,R.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:b||t!==`pending`||!!r.trashId,checked:n.targets.includes(i),onChange:t=>D({...E,[e.id]:{...n,targets:t.target.checked?[...n.targets,i]:n.targets.filter(e=>e!==i)}})}),(0,R.jsxs)(`span`,{className:`break-all`,children:[r.backend,`:`,r.key,` · `,r.state,r.error&&(0,R.jsx)(`span`,{className:`block text-destructive`,children:r.error})]})]},i)}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!B.admin,onClick:()=>G(e),children:`Use these choices as a source policy`}),e.remainingLocations.map(e=>(0,R.jsx)(`p`,{className:`break-all`,children:e.url},e.url))]})]})}),(0,R.jsxs)(`td`,{className:`p-3 break-all`,children:[e.source.account||e.source.backend,e.source.folder&&(0,R.jsx)(`span`,{className:`block text-muted-foreground`,children:e.source.folder})]}),(0,R.jsxs)(`td`,{className:`p-3`,children:[e.state,e.error&&(0,R.jsx)(`p`,{className:`mt-1 max-w-xs text-destructive`,children:e.error})]}),(0,R.jsx)(`td`,{className:`p-3 whitespace-nowrap text-muted-foreground`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]}),!K.length&&(0,R.jsx)(`p`,{className:`p-5 text-center text-sm text-muted-foreground`,children:m?`No matching operations.`:`Loading…`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[m?.total??0,` operation(s)`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!c||b,onClick:()=>{d(Math.max(0,c-200)),T(new Set)},children:`Previous`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:c+K.length>=(m?.total??0)||b,onClick:()=>{d(c+200),T(new Set)},children:`Next`})]})]})]})}var G=`canvas:query-debug`,K=`canvas:query-debug-changed`;function q(){try{return localStorage.getItem(G)===`1`}catch{return!1}}function J(e){try{e?localStorage.setItem(G,`1`):localStorage.removeItem(G)}catch{}window.dispatchEvent(new CustomEvent(K,{detail:e}))}function Y(){let[e,t]=(0,M.useState)(q);return(0,M.useEffect)(()=>{let e=()=>t(q());return window.addEventListener(K,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(K,e),window.removeEventListener(`storage`,e)}},[]),e}export{V as a,U as i,J as n,z as o,Y as r,L as s,q as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Gn as r,Ot as i,Tt as a,X as o,hr as s,ir as c}from"./ui-Byg1cZDr.js";import{t as l}from"./button-SgR3GVvV.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./api-CA6WiiYM.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{h as p,o as m,s as h}from"./LinkToCard-nR7Lal_o.js";import{$ as g,I as _,Pn as v,Sn as y,St as b,bt as x,gt as S,in as C}from"./workspace-DvxC7pw1.js";import{a as w,c as T,l as E,n as D,o as O,r as k,u as A}from"./backend-sync-progress-H4Zch25P.js";import{t as j}from"./workspace-access-C9nZlBBZ.js";var M=e(n(),1),N={membership:`keep`,propagation:`never`,targets:[],acceptPropagatedDeletions:!1},P=e=>`/workspaces/${encodeURIComponent(e)}/trash/operations`,F=(e,t)=>d.get(`${P(e)}?${new URLSearchParams(Object.entries(t).map(([e,t])=>[e,String(t)]))}`),I=(e,t,n,r={})=>d.post(`${P(e)}/${n}`,{ids:t,...r}),L=(e,t,n,r)=>d.patch(`/workspaces/${encodeURIComponent(e)}/backends/imap/${encodeURIComponent(t)}/containers/${encodeURIComponent(n)}`,{removalPolicy:r}),R=t();function z(e){let t=T(`backends`,e.path)?.backend;return(0,R.jsx)(B,{...e},JSON.stringify([e.workspace,t]))}function B({workspace:e,path:t,onNavigate:n}){let l=T(`backends`,t),u=l.backend,d=l.prefix,[f,g]=(0,M.useState)(null),[_,v]=(0,M.useState)(null),y=(0,M.useRef)(!1),[b,S]=(0,M.useState)(null),[C,j]=(0,M.useState)(null),[N,P]=(0,M.useState)(0),[F,I]=(0,M.useState)(new Set),[L,z]=(0,M.useState)(null),B=(0,M.useCallback)(()=>P(e=>e+1),[]),[V,H]=(0,M.useState)(t);V!==t&&(H(t),I(new Set),z(null),j(null),S(null));let U=f?.revision!==N,W=U?[]:f.items,G=U?[]:f.backends,K=f?.days;(0,M.useEffect)(()=>{let t=!1;return(u?w(e,u).then(e=>({...e,backends:[]})):x(e).then(e=>({items:[],days:null,backends:e.filter(e=>e.driver===`file`&&e.enabled!==!1)}))).then(e=>{t||g({...e,revision:N,error:null})}).catch(e=>{t||g({revision:N,items:[],backends:[],days:null,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,u,N]),(0,M.useEffect)(()=>{let t=null,n=n=>{let r=n.detail;r?.workspaceName&&r.workspaceName!==e||r?.treeName&&r.treeName!==`backends`||(t||=setTimeout(()=>{t=null,B()},500))};return window.addEventListener(`workspace:trash:refresh`,n),window.addEventListener(`workspace:tree:refresh`,n),()=>{window.removeEventListener(`workspace:trash:refresh`,n),window.removeEventListener(`workspace:tree:refresh`,n),t&&clearTimeout(t)}},[e,B]);let q=A(W,d),J=async(t,n)=>{if(!(!u||y.current||U||!n.length)&&!(t===`discard`&&!D(u,n))){y.current=!0,v(t),S(null),j(null),z(null);try{let r=await(t===`restore`?O:k)(e,u,[...n].sort((e,t)=>t.deletedAt-e.deletedAt).map(e=>e.id)),i=r.filter(e=>!e.ok);j(`${r.length-i.length} item(s) ${t===`restore`?`restored to their original paths`:`permanently deleted`}.`),i.length&&S(`${i.length} item(s) remain in Trash. ${i.slice(0,3).map(e=>`${e.key||`Item`}: ${e.reason===`precondition-failed`||e.reason===`target-exists`?`original path is occupied`:e.message||e.reason}`).join(`; `)}`),I(new Set)}catch(e){S(e instanceof Error?e.message:String(e))}finally{y.current=!1,v(null),B()}}},Y=(e,t,n)=>z({x:e,y:t,row:n});return(0,R.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":`Backend Trash`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b px-4 py-3`,children:[(0,R.jsx)(o,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(h,{items:m(t,e).map((e,t)=>t===2&&u?{...e,label:u}:e),onNavigate:n,className:`basis-48`}),(0,R.jsxs)(`div`,{className:`ml-auto flex max-w-full flex-wrap items-center gap-2`,children:[F.size>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`restore`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(a,{className:`h-3.5 w-3.5`}),`Restore selected`]}),(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.filter(e=>F.has(e.id)).flatMap(e=>e.items)),children:[(0,R.jsx)(o,{className:`h-3.5 w-3.5`}),`Delete selected`]})]}),u&&q.length>0&&(0,R.jsxs)(`button`,{className:`flex items-center gap-1 rounded border px-2 py-1 text-sm text-destructive disabled:opacity-50`,disabled:!!_||U,onClick:()=>void J(`discard`,q.flatMap(e=>e.items)),children:[(0,R.jsx)(o,{className:`h-3.5 w-3.5`}),d?`Empty this folder`:`Empty Trash`]}),(0,R.jsx)(`button`,{title:`Refresh Trash`,"aria-label":`Refresh Trash`,className:`rounded p-2 hover:bg-accent`,disabled:!!_||U,onClick:B,children:(0,R.jsx)(i,{className:`h-4 w-4 ${U?`animate-spin`:``}`})})]})]}),(0,R.jsxs)(`div`,{className:`border-b px-4 py-2 text-xs text-muted-foreground`,children:[`Restore files and folders to their original paths. Existing files are kept.`,K?` Deleted items are kept for ${K} days.`:``]}),C&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:C}),(b||f?.error)&&(0,R.jsx)(`p`,{role:`alert`,className:`px-4 py-2 text-sm text-destructive`,children:b||f?.error}),_&&(0,R.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm`,children:_===`restore`?`Restoring…`:`Deleting permanently…`}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:U?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Trash…`}):u?q.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`This Trash folder is empty.`}):(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b text-xs text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`w-8 p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all visible items`,checked:q.length>0&&q.every(e=>F.has(e.id)),onChange:e=>I(e.target.checked?new Set(q.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-2`,children:`Name`}),(0,R.jsx)(`th`,{className:`p-2 max-sm:hidden`,children:`Original path`}),(0,R.jsx)(`th`,{className:`p-2 max-md:hidden`,children:`Deleted`}),(0,R.jsx)(`th`,{className:`p-2`,children:(0,R.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]})}),(0,R.jsx)(`tbody`,{children:q.map(e=>(0,R.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-accent/50`,onContextMenu:t=>{t.preventDefault(),Y(t.clientX,t.clientY,e)},onDoubleClick:()=>e.navigable&&n(E(u,e.key)),children:[(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:F.has(e.id),disabled:!!_,onChange:t=>I(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-2`,children:(0,R.jsxs)(`button`,{className:`flex items-center gap-2 text-left`,onClick:()=>e.navigable&&n(E(u,e.key)),children:[e.directory?(0,R.jsx)(r,{className:`h-4 w-4 shrink-0`}):(0,R.jsx)(c,{className:`h-4 w-4 shrink-0`}),(0,R.jsxs)(`span`,{children:[e.name,e.navigable&&(0,R.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.items.length,` items`]})]})]})}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-sm:hidden`,children:e.key}),(0,R.jsx)(`td`,{className:`p-2 text-xs text-muted-foreground max-md:hidden`,children:new Date(e.items.reduce((e,t)=>Math.max(e,t.deletedAt),0)).toLocaleString()}),(0,R.jsx)(`td`,{className:`p-2 text-right`,children:(0,R.jsx)(`button`,{title:`Actions for ${e.name}`,"aria-label":`Actions for ${e.name}`,disabled:!!_,className:`rounded p-2 hover:bg-accent`,onClick:t=>Y(t.clientX,t.clientY,e),children:(0,R.jsx)(s,{className:`h-4 w-4`})})})]},e.id))})]}):(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:[G.map(e=>(0,R.jsxs)(`button`,{onClick:()=>n(E(e.address)),className:`flex items-center gap-3 rounded-lg border p-4 text-left hover:bg-accent`,children:[(0,R.jsx)(o,{className:`h-6 w-6 text-muted-foreground`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:e.label||e.address}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.address})]})]},e.address)),!G.length&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No file backends are available.`})]})}),L&&(0,R.jsxs)(p,{x:L.x,y:L.y,onClose:()=>z(null),className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[L.row.navigable&&(0,R.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent`,onClick:()=>{n(E(u,L.row.key)),z(null)},children:[(0,R.jsx)(r,{className:`h-4 w-4`}),`Open folder`]}),(0,R.jsxs)(`button`,{disabled:!!_,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm hover:bg-accent disabled:opacity-50`,onClick:()=>void J(`restore`,L.row.items),children:[(0,R.jsx)(a,{className:`h-4 w-4`}),`Restore `,L.row.directory?`folder`:`file`]}),(0,R.jsxs)(`button`,{disabled:!!_||U,className:`flex w-full items-center gap-2 rounded px-3 py-2 text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50`,onClick:()=>void J(`discard`,L.row.items),children:[(0,R.jsx)(o,{className:`h-4 w-4`}),`Delete permanently`]})]})]})}function V({value:e,backends:t,source:n,onSave:r,destination:i=!0}){let[a,o]=(0,M.useState)({...N,...e}),[s,c]=(0,M.useState)(!1),[u,d]=(0,M.useState)(``),f=`rounded border bg-background px-2 py-1.5 text-xs w-full`,p=async()=>{c(!0),d(``);try{await r(a),d(`Removal policy saved.`)}catch(e){d(e instanceof Error?e.message:`Could not save policy`)}finally{c(!1)}};return(0,R.jsxs)(`details`,{className:`border-t pt-3 text-xs`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Source removals and Trash`}),(0,R.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`A completed scan removes missing locations from the backend tree. Items with no remaining locations go to Trash until you purge them.`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`When an item disappears from this source`,(0,R.jsxs)(`select`,{className:f,value:a.membership,disabled:s,onChange:e=>o({...a,membership:e.target.value}),children:[(0,R.jsx)(`option`,{value:`keep`,children:`Keep in managed trees`}),(0,R.jsx)(`option`,{value:`review`,children:`Review removal in Trash`}),(0,R.jsx)(`option`,{value:`trash`,children:`Move to Trash automatically`})]})]}),(0,R.jsxs)(`label`,{className:`space-y-1 block`,children:[`Remove tracked copies from other backends`,(0,R.jsxs)(`select`,{className:f,value:a.propagation,disabled:s,onChange:e=>o({...a,propagation:e.target.value}),children:[(0,R.jsx)(`option`,{value:`never`,children:`Never`}),(0,R.jsx)(`option`,{value:`review`,children:`Review in Trash`}),(0,R.jsx)(`option`,{value:`automatic`,children:`Automatically, retaining recovery copies`})]})]})]}),a.propagation!==`never`&&(0,R.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,R.jsx)(`legend`,{className:`mb-1 font-medium`,children:`Destinations`}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.targets===`all`,disabled:s,onChange:e=>o({...a,targets:e.target.checked?`all`:[]})}),`All eligible backends`]}),a.targets!==`all`&&t.filter(e=>e.address!==n&&e.kind===`storage`).map(e=>(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s||e.config?.propagatedRemovalSupported!==!0,checked:a.targets.includes(e.address),onChange:t=>o({...a,targets:t.target.checked?[...a.targets,e.address]:a.targets.filter(t=>t!==e.address)})}),String(e.config?.label||e.address),e.config?.propagatedRemovalSupported===!0?!e.config?.removalPolicy?.acceptPropagatedDeletions&&` · protected`:` · recovery removal unavailable`]},e.address)),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Only tracked, Canvas-owned copies are eligible. Protected destinations refuse propagated deletion. Recovery removal currently supports filesystem and workspace blob storage; remote destinations remain protected.`})]}),i&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:s,checked:a.acceptPropagatedDeletions,onChange:e=>o({...a,acceptPropagatedDeletions:e.target.checked})}),`Accept propagated deletions on this backend`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:s,onClick:()=>void p(),children:s?`Saving…`:`Save removal policy`}),(0,R.jsx)(`span`,{role:`status`,children:u})]})]})]})}function H({workspaceName:e,canWrite:t}){let{showToast:n}=f(),[r,s]=(0,M.useState)([]),[c,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)([]),[m,h]=(0,M.useState)(!1),g=(0,M.useCallback)(async()=>{u(!0);try{s(await b(e))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to load the trash`,variant:`destructive`})}finally{u(!1)}},[e]);(0,M.useEffect)(()=>{g()},[g]);let y=(0,M.useCallback)(e=>d.includes(e),[d]),x=async(e,t)=>{p(t=>[...t,...e]);try{await t()}finally{p(t=>t.filter(t=>!e.includes(t)))}},S=t=>x([t.id],async()=>{try{let r=await C(e,[t.id]);r.failed?.length?n({title:`Not restored`,description:r.failed[0]?.error||`No restore target recorded`,variant:`destructive`}):(n({title:`Restored`,description:`Document put back where it was.`}),s(e=>e.filter(e=>e.id!==t.id)))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to restore`,variant:`destructive`})}}),w=t=>x([t.id],async()=>{try{let r=await _(e,[t.id]);if(r.failed?.length)throw Error(`The item could not be purged. Refresh and retry.`);n({title:`Cleared from Trash`,description:r.preserved?.length?`Existing backend copies remain indexed.`:`Document permanently deleted.`}),s(e=>e.filter(e=>e.id!==t.id))}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to delete`,variant:`destructive`})}}),T=async()=>{if(!m){h(!0);return}h(!1);try{let t=await _(e);n({title:`Trash emptied`,description:`${t.destroyed?.length??0} document(s) purged. ${t.preserved?.length??0} item(s) cleared with backend copies preserved.`}),await g()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to empty the trash`,variant:`destructive`})}},E=(0,M.useMemo)(()=>r.map(e=>{let t=v(e),n=(e.trashed?.placements??[]).flatMap(e=>e.paths.map(t=>`${e.tree}:${t}`));return{document:e,title:t.title,origin:n,trashedAt:e.trashed?.trashedAt||null}}),[r]);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Managed-tree items`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-2xl`,children:`Restore managed-tree placements or permanently purge these items. Pending removals require separate approval. Backend copies are managed below.`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-sm:flex-wrap`,children:[(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>g(),disabled:c,children:[(0,R.jsx)(i,{className:`mr-2 h-3.5 w-3.5 ${c?`animate-spin`:``}`}),`Refresh`]}),(0,R.jsxs)(l,{variant:m?`destructive`:`outline`,size:`sm`,onClick:T,onBlur:()=>h(!1),disabled:!t||r.length===0,children:[(0,R.jsx)(o,{className:`mr-2 h-3.5 w-3.5`}),m?`Click again to delete everything`:`Empty trash`]})]})]}),c&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),!c&&r.length===0&&(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The trash is empty.`}),E.length>0&&(0,R.jsx)(`div`,{className:`border rounded-md divide-y`,children:E.map(({document:e,title:n,origin:r,trashedAt:i})=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm`,children:n}),(0,R.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[r.length>0?`from ${r.join(`, `)}`:`no recorded origin`,i?` · ${new Date(i).toLocaleString()}`:``]})]}),(0,R.jsxs)(l,{variant:`outline`,size:`sm`,onClick:()=>S(e),disabled:!t||y(e.id)||r.length===0,title:r.length===0?`Nothing recorded to restore to`:`Put it back where it was`,children:[(0,R.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),`Restore placements`]}),(0,R.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>w(e),disabled:!t||y(e.id),title:`Delete permanently`,children:(0,R.jsx)(o,{className:`h-3.5 w-3.5`})})]},e.id))})]})}function U({workspaceName:e}){return(0,R.jsx)(W,{workspaceName:e},e)}function W({workspaceName:e}){let[t,n]=(0,M.useState)(`pending`),[r,a]=(0,M.useState)(``),[o,s]=(0,M.useState)(``),[c,d]=(0,M.useState)(0),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(null),[_,v]=(0,M.useState)(``),[b,C]=(0,M.useState)(!1),[w,T]=(0,M.useState)(new Set),[E,D]=(0,M.useState)({}),[O,k]=(0,M.useState)(`/Trash`),[A,P]=(0,M.useState)([]),[B,U]=(0,M.useState)({write:!1,admin:!1});(0,M.useEffect)(()=>{let t=!0;return g(e).then(e=>{let n=e.remote?.permissions||e.access?.permissions||(typeof e.sharedVia==`object`?e.sharedVia?.permissions:[])||[],r=j(e);t&&U({admin:r,write:r||n.includes(`write`)})}).catch(()=>{}),()=>{t=!1}},[e]);let[W,G]=(0,M.useState)(null);(0,M.useEffect)(()=>{let t=!0;return x(e).then(e=>{t&&P(e)}).catch(()=>{}),()=>{t=!1}},[e]),(0,M.useEffect)(()=>{let n=!1,i=()=>F(e,{view:t,search:r,...o?{backend:o}:{},offset:c}).then(e=>{n||(h(e),v(``))}).catch(e=>{n||v(e instanceof Error?e.message:`Could not load Trash`)});i();let a=setInterval(()=>{b||i()},5e3);return()=>{n=!0,clearInterval(a)}},[e,t,r,o,c,f,b]);let K=m?.operations||[],q=()=>{T(new Set),p(e=>e+1)},J=()=>{S(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),window.dispatchEvent(new CustomEvent(`workspace:trash:refresh`,{detail:{workspaceName:e}}))},Y=async(t,n=[...w])=>{if(!(!n.length||b)&&!(t===`purge`&&!window.confirm(`Permanently delete retained recovery copies for ${n.length} operation(s)?`))){C(!0),v(``);try{let r=(t===`approve`?(await Promise.all(n.map(n=>I(e,[n],t,E[n])))).flatMap(e=>e.results):(await I(e,n,t)).results).filter(e=>!e.ok||e.operation?.state===`failed`);r.length&&v(r.map(e=>e.error||e.operation?.error||`A destination could not be changed. Expand the item for details.`).join(` `)),J(),q()}catch(e){v(e instanceof Error?e.message:`Trash action failed`)}finally{C(!1)}}},X=e=>{n(e),d(0),h(null),T(new Set),D({})};return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold`,children:`Workspace Trash`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Review source removals, recover items, and see what automatic policies changed.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`tablist`,"aria-label":`Trash views`,children:[[[`pending`,`Pending removal`],[`trashed`,`In Trash`],[`activity`,`Activity`]].map(([e,n])=>(0,R.jsx)(l,{role:`tab`,"aria-selected":t===e,size:`sm`,variant:t===e?`default`:`outline`,onClick:()=>X(e),children:n},e)),(0,R.jsxs)(l,{size:`sm`,variant:`ghost`,className:`ml-auto`,onClick:q,disabled:b,children:[(0,R.jsx)(i,{className:`mr-2 h-3.5 w-3.5`}),`Refresh`]})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{workspaceName:e,canWrite:B.write},f),(0,R.jsxs)(`details`,{className:`rounded border p-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`Browse backend recovery copies`}),(0,R.jsx)(`div`,{className:`mt-3 min-h-48`,children:(0,R.jsx)(z,{workspace:e,path:O,onNavigate:k})})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(u,{"aria-label":`Filter Trash items`,placeholder:`Filter by item or path…`,className:`max-w-xs`,value:r,onChange:e=>{a(e.target.value),h(null),d(0),T(new Set)}}),(0,R.jsx)(u,{"aria-label":`Filter by backend`,placeholder:`Backend name…`,className:`max-w-56`,value:o,onChange:e=>{s(e.target.value),h(null),d(0),T(new Set)}}),w.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,R.jsxs)(`span`,{children:[w.size,` selected`]}),t===`pending`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,disabled:b,onClick:()=>void Y(`approve`),children:`Approve selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void Y(`keep`),children:`Keep selected`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void Y(`retry`),children:`Retry`})]}),t===`trashed`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:b,onClick:()=>void Y(`restore`),children:`Restore copies`}),(0,R.jsx)(l,{size:`sm`,variant:`destructive`,disabled:b,onClick:()=>void Y(`purge`),children:`Purge copies`})]})]})]}),W&&(0,R.jsxs)(`div`,{className:`rounded border p-3 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Removal policy · `,W.source.account||W.source.backend,W.source.folder?` / ${W.source.folder}`:``]}),(0,R.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>G(null),children:`Close`})]}),(0,R.jsx)(V,{source:W.source.backend,backends:A,destination:!1,value:{...N,...A.find(e=>e.address===W.source.backend)?.config?.removalPolicy,membership:E[W.id]?.membership??W.membership!==`keep`?`review`:`keep`,propagation:W.targets.length?`review`:`never`,targets:[...new Set(W.targets.filter(e=>!E[W.id]||E[W.id].targets.includes(JSON.stringify([e.backend,e.key]))).map(e=>e.backend))]},onSave:async t=>{W.source.driver===`imap`?await L(e,W.source.account,W.source.folder,t):await y(e,W.source.driver,W.source.backend,{removalPolicy:t}),P(await x(e))}},W.id)]}),_&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,R.jsxs)(`div`,{className:`overflow-x-auto rounded border`,children:[(0,R.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,R.jsx)(`thead`,{className:`bg-muted`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`p-3 w-8`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select visible operations`,disabled:!B.write||b||!K.length||t===`activity`,checked:K.length>0&&K.every(e=>w.has(e.id)),onChange:e=>T(e.target.checked?new Set(K.map(e=>e.id)):new Set)})}),(0,R.jsx)(`th`,{className:`p-3`,children:`Item and affected copies`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Source`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,R.jsx)(`th`,{className:`p-3`,children:`Detected`})]})}),(0,R.jsx)(`tbody`,{children:K.map(e=>{let n=E[e.id]||{targets:e.targets.filter(e=>e.state!==`kept`).map(e=>JSON.stringify([e.backend,e.key])),membership:e.membership!==`keep`};return(0,R.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,R.jsx)(`td`,{className:`p-3`,children:(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,disabled:!B.write||b||t===`activity`,checked:w.has(e.id),onChange:t=>T(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,R.jsx)(`td`,{className:`p-3 min-w-64`,children:(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,R.jsxs)(`div`,{className:`mt-2 space-y-2 text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:e.orphan?`No remaining byte locations. Restore placements only unless recovery bytes are available.`:`${e.remainingLocations.length} remaining location(s) when detected.`}),e.placements.map(e=>(0,R.jsxs)(`p`,{children:[e.tree,`: `,e.paths.join(`, `)]},e.tree)),e.membership!==`keep`&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:n.membership,disabled:b||t!==`pending`||e.membershipApplied,onChange:t=>D({...E,[e.id]:{...n,membership:t.target.checked}})}),e.membershipApplied?`Managed placements moved to Trash`:`Move managed placements to Trash`]}),e.targets.map(r=>{let i=JSON.stringify([r.backend,r.key]);return(0,R.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,disabled:b||t!==`pending`||!!r.trashId,checked:n.targets.includes(i),onChange:t=>D({...E,[e.id]:{...n,targets:t.target.checked?[...n.targets,i]:n.targets.filter(e=>e!==i)}})}),(0,R.jsxs)(`span`,{className:`break-all`,children:[r.backend,`:`,r.key,` · `,r.state,r.error&&(0,R.jsx)(`span`,{className:`block text-destructive`,children:r.error})]})]},i)}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!B.admin,onClick:()=>G(e),children:`Use these choices as a source policy`}),e.remainingLocations.map(e=>(0,R.jsx)(`p`,{className:`break-all`,children:e.url},e.url))]})]})}),(0,R.jsxs)(`td`,{className:`p-3 break-all`,children:[e.source.account||e.source.backend,e.source.folder&&(0,R.jsx)(`span`,{className:`block text-muted-foreground`,children:e.source.folder})]}),(0,R.jsxs)(`td`,{className:`p-3`,children:[e.state,e.error&&(0,R.jsx)(`p`,{className:`mt-1 max-w-xs text-destructive`,children:e.error})]}),(0,R.jsx)(`td`,{className:`p-3 whitespace-nowrap text-muted-foreground`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]}),!K.length&&(0,R.jsx)(`p`,{className:`p-5 text-center text-sm text-muted-foreground`,children:m?`No matching operations.`:`Loading…`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[m?.total??0,` operation(s)`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:!c||b,onClick:()=>{d(Math.max(0,c-200)),T(new Set)},children:`Previous`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,disabled:c+K.length>=(m?.total??0)||b,onClick:()=>{d(c+200),T(new Set)},children:`Next`})]})]})]})}var G=`canvas:query-debug`,K=`canvas:query-debug-changed`;function q(){try{return localStorage.getItem(G)===`1`}catch{return!1}}function J(e){try{e?localStorage.setItem(G,`1`):localStorage.removeItem(G)}catch{}window.dispatchEvent(new CustomEvent(K,{detail:e}))}function Y(){let[e,t]=(0,M.useState)(q);return(0,M.useEffect)(()=>{let e=()=>t(q());return window.addEventListener(K,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(K,e),window.removeEventListener(`storage`,e)}},[]),e}export{V as a,U as i,J as n,z as o,Y as r,L as s,q as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-CkO4uaE3.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-Byg1cZDr.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-cO-FiyPQ.js","assets/workspace-DvxC7pw1.js","assets/button-SgR3GVvV.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-izlVMXfa.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{St as i,Yr as a,ct as o,it as s,mn as c,tt as l}from"./ui-Byg1cZDr.js";var u=e(n(),1),d=t();function f(e){let t=(0,u.lazy)(e);return function(e){return(0,d.jsx)(u.Suspense,{fallback:(0,d.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,d.jsx)(t,{...e})})}}var p=f(()=>r(()=>import(`./TerminalApplet-CkO4uaE3.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),m=f(()=>r(()=>import(`./NotesApplet-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-CkO4uaE3.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-Byg1cZDr.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-cO-FiyPQ.js","assets/workspace-DvxC7pw1.js","assets/button-SgR3GVvV.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-izlVMXfa.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-BmLjXx7V.js","assets/useAddTarget-DUjaZdBQ.js","assets/context-mfIOB8dN.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-zHEWwDfB.js","assets/tags-YamdPoBK.js","assets/index-Tx_qtD_m.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-Dn4gCMcc.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-nR7Lal_o.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-x299QNu_.js","assets/use-canvas-pins-6vnfChWd.js","assets/TodosWidget-BIYqPXUp.js","assets/ObjectPropertiesCard-ChvWbOpZ.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-OPEWPlZs.js","assets/date-time-picker-B6mkWt-g.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-DXxVwHKT.js","assets/text-documents-BvDFBVnC.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-DYLCC63L.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-gbD0Gu_b.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-BSRnneOo.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-8DNmOBS0.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-pbG2cCpW.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-JArcZXXv.css","assets/document-list-rh4ittZx.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-Bo224P4q.js","assets/backend-sync-progress-H4Zch25P.js","assets/PathPickerField-DBe7jykL.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-BW_0sXBs.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-BiJ8N7sS.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-Dg3hXKR3.js","assets/workspace-content-gate-Be4tLYiB.js","assets/UploadProgressList-BXJr87lI.js","assets/sha256-65KIjGvZ.js","assets/FileForm-DhQhVnoi.js","assets/use-theme-DaxpiICf.js","assets/index-D7EoeBID.css","assets/shared-D2uRUNdC.js","assets/use-applet-docs-o5NAUFBk.js","assets/TodosApplet-Bpf1OIH4.js","assets/LensApplet-DuADvEm5.js","assets/FiltersApplet-BAe-Eq0e.js","assets/SketchApplet-ADVOnSLI.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{St as i,Yr as a,ct as o,it as s,mn as c,tt as l}from"./ui-Byg1cZDr.js";var u=e(n(),1),d=t();function f(e){let t=(0,u.lazy)(e);return function(e){return(0,d.jsx)(u.Suspense,{fallback:(0,d.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,d.jsx)(t,{...e})})}}var p=f(()=>r(()=>import(`./TerminalApplet-CkO4uaE3.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),m=f(()=>r(()=>import(`./NotesApplet-BmLjXx7V.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),h=f(()=>r(()=>import(`./TodosApplet-Bpf1OIH4.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),g=f(()=>r(()=>import(`./LensApplet-DuADvEm5.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),_=f(()=>r(()=>import(`./FiltersApplet-BAe-Eq0e.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=f(()=>r(()=>import(`./SketchApplet-ADVOnSLI.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),y=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:s,modes:[`context`],description:`Shell sessions for this context`,Component:p},{id:`filters`,category:`utilities`,label:`Filters`,icon:o,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:_},{id:`notes`,category:`productivity`,label:`Notes`,icon:l,modes:[`context`],description:`All notes in the current context, editable in place`,Component:m},{id:`todo`,category:`productivity`,label:`Todos`,icon:c,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:h},{id:`sketch`,category:`creative`,label:`Sketch`,icon:a,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:v},{id:`lens`,category:`media`,label:`Lens`,icon:i,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:g}];function b(e){return y.filter(t=>t.modes.includes(e))}export{b as n,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-Byg1cZDr.js";import{t as a}from"./button-SgR3GVvV.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Pt as ne}from"./workspace-DvxC7pw1.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-mfIOB8dN.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-BiJ8N7sS.js";import{B as oe,G as se,J as ce,K as le,L as ue,V as de,W as fe,X as pe,Y as me,Z as he,et as ge,ft as _e,ht as ve}from"./index-CiBgHujl.js";import{n as ye}from"./page-header-DkOHw0g-.js";import{n as be,r as xe,t as Se}from"./useAgentModels-Sa4N8WFd.js";var c=e(n(),1),l=t(),Ce={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:we}=ae(),Te=re(),g=ve(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[Ee,De]=(0,c.useState)(!0),[Oe,ke]=(0,c.useState)(null),[Ae,je]=(0,c.useState)(!1),[Me,Ne]=(0,c.useState)(!1),[Pe,Fe]=(0,c.useState)(``),[Ie,Le]=(0,c.useState)(``),[Re,ze]=(0,c.useState)(``),[Be,y]=(0,c.useState)(s()),[b,Ve]=(0,c.useState)(``),[x,He]=(0,c.useState)(``),[S,Ue]=(0,c.useState)(``),[C,We]=(0,c.useState)(``),[w,Ge]=(0,c.useState)(`anthropic`),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(``),[k,A]=(0,c.useState)(``),[Ke,qe]=(0,c.useState)(.7),[Je,j]=(0,c.useState)(4096),[Ye,Xe]=(0,c.useState)(1),Ze=Se(w,T,D,_?.id),Qe=Ze.models.find(e=>e.id===k),[$e,M]=(0,c.useState)([]),[N,P]=(0,c.useState)(``),[et,F]=(0,c.useState)(``),[I,L]=(0,c.useState)(``),[R,z]=(0,c.useState)(``),[tt,nt]=(0,c.useState)(!1),[rt,it]=(0,c.useState)(null),[B,V]=(0,c.useState)(null),[at,ot]=(0,c.useState)(null),[H,U]=(0,c.useState)(!1),[W,G]=(0,c.useState)(null),[K,st]=(0,c.useState)(`context`),[q,ct]=(0,c.useState)(``),[lt,ut]=(0,c.useState)(`/`),[J,dt]=(0,c.useState)(``),[ft,pt]=(0,c.useState)(!0),[Y,mt]=(0,c.useState)(!1),[ht,gt]=(0,c.useState)([]),[_t,vt]=(0,c.useState)([]),[X,yt]=(0,c.useState)(null),[bt,Z]=(0,c.useState)(`{}`),[xt,Q]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(e);St!==e&&(Ct(e),De(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return oe(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Fe(e.name||``),Le(e.label||``),ze(e.description||``),y(e.color||s()),Ve(n.role||``),He(n.identity||``),Ue(n.instructions||``),We(e.config?.prompts?.system||``),Ge(e.llmProvider||`anthropic`),E(e.config?.apiKey||``),O(e.config?.baseUrl||d(e.llmProvider)),A(e.model||Ce[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(qe(r.temperature??.7),j(r.maxTokens??4096),Xe(r.topP??1)),Z(JSON.stringify(e.config?.tools??{},null,2)),Q(null),ke(null);try{M(await le(e.id))}catch{M([])}}).catch(e=>{t||ke(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||De(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([de(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),fe(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(V(n),gt(r),vt(ee),yt(i?i.tools:[]),n&&(st(n.binding.type),ct(n.binding.workspace||``),ut(n.binding.path||`/`),dt(n.binding.context||``),pt(n.permissions.includes(`read`)),mt(n.permissions.includes(`write`))),ot(e))}),()=>{t=!0}},[g,_?.id]);let wt=()=>{let e=xe(b,x,S),t;try{let e=JSON.parse(bt);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Pe.trim(),label:Ie.trim(),description:Re.trim()||void 0,color:Be,llmProvider:w,model:k,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:D||void 0,config:{type:w,model:k,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Ke},maxTokens:Je,topP:Ye}}}}},Tt=async e=>{if(e.preventDefault(),_){je(!0);try{let e=await ge(_.id,wt());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{je(!1)}}},Et=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Ne(!0);try{await ue(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Ne(!1)}}},$=()=>{P(``),F(``),L(``),z(``)},Dt=async()=>{if(!(!_||!R.trim()&&!I.trim())){nt(!0);try{let e=await se(_.id,R.trim()?{source:R.trim()}:{name:N,description:et,content:I});M(e),$(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{nt(!1)}}},Ot=async e=>{if(_){it(e);try{let t=await ce(_.id,e);M(t),(N===e||R===e)&&$(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{it(null)}}},kt=()=>K===`global`?{type:`global`}:K===`context`?J?{type:`context`,context:J}:null:q?K===`path`?{type:`path`,workspace:q,path:lt.trim()||`/`}:{type:`workspace`,workspace:q}:null,At=async()=>{if(!_||H)return;let e=kt(),t=[];if(ft&&t.push(`read`),Y&&t.push(`write`),!e||t.length===0){u({title:`Invalid binding`,description:`Pick a scope target and at least one permission`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Y?`read and write`:`read`} ALL your workspaces. Continue?`))){U(!0);try{let n=await he(_.id,{binding:e,permissions:t});V(n.access),G(n.token),u({title:`Bound`,description:`Access bound — copy the token now, it is not shown again`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{U(!1)}}},jt=async()=>{if(!(!_||H)){U(!0);try{let e=await pe(_.id);V(e.access),G(e.token),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{U(!1)}}},Mt=async()=>{if(!(!_||H)&&window.confirm(`Revoke this agent's canvas access? Its token stops working immediately.`)){U(!0);try{await me(_.id),V(null),G(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{U(!1)}}},Nt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=_t.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(Ee)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||Oe)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:Oe||`Agent not found`});let Pt=_e.find(e=>e.id===g),Ft=encodeURIComponent(_.name||_.id),It=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(ye,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Pt.label} - ${_.label||_.name}`,description:Pt.description,backTo:`/agents/${Ft}`,onBack:Te?we:void 0}),(0,l.jsxs)(`form`,{onSubmit:Tt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Pe,onChange:e=>Fe(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Ie,onChange:e=>Le(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:Re,onChange:e=>ze(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Be,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>Ve(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>He(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>Ue(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>We(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Me,onClick:Et,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Me?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ge(t),E(``),A(Ce[t]||``),O(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:D,onChange:e=>O(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(be,{value:k,onChange:(e,t)=>{A(e),t?.maxTokens&&j(t.maxTokens)},...Ze})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Ke,onChange:e=>qe(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:Qe?.maxTokens,value:Je,onChange:e=>j(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ye,onChange:e=>Xe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),X===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):X.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:X.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B?Nt(B.binding):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:bt,onChange:e=>{Z(e.target.value);try{JSON.parse(e.target.value),Q(null)}catch(e){Q(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),xt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,xt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),$e.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):$e.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{P(e.name),F(e.description||``),L(e.content||``),z(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:rt===(e.source||e.name),onClick:()=>Ot(e.source||e.name),children:rt===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:R,onChange:e=>z(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:N,onChange:e=>P(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!R.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:et,onChange:e=>F(e.target.value),placeholder:`What this skill helps with`,disabled:!!R.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:`# Skill instructions…`,disabled:!!R.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:tt||!R.trim()&&!I.trim(),onClick:Dt,children:tt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:$,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The agent talks to canvas through its own scoped token; the server clamps every request to the binding. Bind, rotate and revoke apply immediately.`})]}),at===_.id?B?(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:Nt(B.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,B.permissions.join(`, `)||`none`,B.boundAt?` · bound ${new Date(B.boundAt).toLocaleString()}`:``,B.rotatedAt?` · token rotated ${new Date(B.rotatedAt).toLocaleString()}`:``]}),(0,l.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:H,onClick:jt,children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:H,onClick:Mt,children:`Revoke Access`})]})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),W&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:W}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(W),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>G(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`In-process agents receive it automatically (canvas.env); external runtimes (agentd) take it as CANVAS_TOKEN.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:B?`Rebind`:`Bind`}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:K,onChange:e=>st(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),K===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:J,onChange:e=>dt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),_t.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(K===`workspace`||K===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:q,onChange:e=>ct(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),ht.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),K===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:lt,onChange:e=>ut(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:ft,onChange:e=>pt(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>mt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:H,onClick:At,children:H?`Working…`:B?`Rebind & Mint Token`:`Bind & Mint Token`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),It&&(0,l.jsx)(a,{type:`submit`,disabled:Ae,children:Ae?`Saving…`:`Save Changes`})]})]})})}export{h as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-Byg1cZDr.js";import{t as a}from"./button-SgR3GVvV.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Pt as ne}from"./workspace-DvxC7pw1.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-mfIOB8dN.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-BiJ8N7sS.js";import{B as oe,G as se,J as ce,K as le,L as ue,V as de,W as fe,X as pe,Y as me,Z as he,et as ge,ft as _e,ht as ve}from"./index-Tx_qtD_m.js";import{n as ye}from"./page-header-DkOHw0g-.js";import{n as be,r as xe,t as Se}from"./useAgentModels-Cxb5NyCI.js";var c=e(n(),1),l=t(),Ce={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:we}=ae(),Te=re(),g=ve(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[Ee,De]=(0,c.useState)(!0),[Oe,ke]=(0,c.useState)(null),[Ae,je]=(0,c.useState)(!1),[Me,Ne]=(0,c.useState)(!1),[Pe,Fe]=(0,c.useState)(``),[Ie,Le]=(0,c.useState)(``),[Re,ze]=(0,c.useState)(``),[Be,y]=(0,c.useState)(s()),[b,Ve]=(0,c.useState)(``),[x,He]=(0,c.useState)(``),[S,Ue]=(0,c.useState)(``),[C,We]=(0,c.useState)(``),[w,Ge]=(0,c.useState)(`anthropic`),[T,E]=(0,c.useState)(``),[D,O]=(0,c.useState)(``),[k,A]=(0,c.useState)(``),[Ke,qe]=(0,c.useState)(.7),[Je,j]=(0,c.useState)(4096),[Ye,Xe]=(0,c.useState)(1),Ze=Se(w,T,D,_?.id),Qe=Ze.models.find(e=>e.id===k),[$e,M]=(0,c.useState)([]),[N,P]=(0,c.useState)(``),[et,F]=(0,c.useState)(``),[I,L]=(0,c.useState)(``),[R,z]=(0,c.useState)(``),[tt,nt]=(0,c.useState)(!1),[rt,it]=(0,c.useState)(null),[B,V]=(0,c.useState)(null),[at,ot]=(0,c.useState)(null),[H,U]=(0,c.useState)(!1),[W,G]=(0,c.useState)(null),[K,st]=(0,c.useState)(`context`),[q,ct]=(0,c.useState)(``),[lt,ut]=(0,c.useState)(`/`),[J,dt]=(0,c.useState)(``),[ft,pt]=(0,c.useState)(!0),[Y,mt]=(0,c.useState)(!1),[ht,gt]=(0,c.useState)([]),[_t,vt]=(0,c.useState)([]),[X,yt]=(0,c.useState)(null),[bt,Z]=(0,c.useState)(`{}`),[xt,Q]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(e);St!==e&&(Ct(e),De(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return oe(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Fe(e.name||``),Le(e.label||``),ze(e.description||``),y(e.color||s()),Ve(n.role||``),He(n.identity||``),Ue(n.instructions||``),We(e.config?.prompts?.system||``),Ge(e.llmProvider||`anthropic`),E(e.config?.apiKey||``),O(e.config?.baseUrl||d(e.llmProvider)),A(e.model||Ce[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(qe(r.temperature??.7),j(r.maxTokens??4096),Xe(r.topP??1)),Z(JSON.stringify(e.config?.tools??{},null,2)),Q(null),ke(null);try{M(await le(e.id))}catch{M([])}}).catch(e=>{t||ke(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||De(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([de(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),fe(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(V(n),gt(r),vt(ee),yt(i?i.tools:[]),n&&(st(n.binding.type),ct(n.binding.workspace||``),ut(n.binding.path||`/`),dt(n.binding.context||``),pt(n.permissions.includes(`read`)),mt(n.permissions.includes(`write`))),ot(e))}),()=>{t=!0}},[g,_?.id]);let wt=()=>{let e=xe(b,x,S),t;try{let e=JSON.parse(bt);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Pe.trim(),label:Ie.trim(),description:Re.trim()||void 0,color:Be,llmProvider:w,model:k,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:D||void 0,config:{type:w,model:k,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Ke},maxTokens:Je,topP:Ye}}}}},Tt=async e=>{if(e.preventDefault(),_){je(!0);try{let e=await ge(_.id,wt());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{je(!1)}}},Et=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Ne(!0);try{await ue(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Ne(!1)}}},$=()=>{P(``),F(``),L(``),z(``)},Dt=async()=>{if(!(!_||!R.trim()&&!I.trim())){nt(!0);try{let e=await se(_.id,R.trim()?{source:R.trim()}:{name:N,description:et,content:I});M(e),$(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{nt(!1)}}},Ot=async e=>{if(_){it(e);try{let t=await ce(_.id,e);M(t),(N===e||R===e)&&$(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{it(null)}}},kt=()=>K===`global`?{type:`global`}:K===`context`?J?{type:`context`,context:J}:null:q?K===`path`?{type:`path`,workspace:q,path:lt.trim()||`/`}:{type:`workspace`,workspace:q}:null,At=async()=>{if(!_||H)return;let e=kt(),t=[];if(ft&&t.push(`read`),Y&&t.push(`write`),!e||t.length===0){u({title:`Invalid binding`,description:`Pick a scope target and at least one permission`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Y?`read and write`:`read`} ALL your workspaces. Continue?`))){U(!0);try{let n=await he(_.id,{binding:e,permissions:t});V(n.access),G(n.token),u({title:`Bound`,description:`Access bound — copy the token now, it is not shown again`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{U(!1)}}},jt=async()=>{if(!(!_||H)){U(!0);try{let e=await pe(_.id);V(e.access),G(e.token),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{U(!1)}}},Mt=async()=>{if(!(!_||H)&&window.confirm(`Revoke this agent's canvas access? Its token stops working immediately.`)){U(!0);try{await me(_.id),V(null),G(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{U(!1)}}},Nt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=_t.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(Ee)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||Oe)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:Oe||`Agent not found`});let Pt=_e.find(e=>e.id===g),Ft=encodeURIComponent(_.name||_.id),It=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(ye,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Pt.label} - ${_.label||_.name}`,description:Pt.description,backTo:`/agents/${Ft}`,onBack:Te?we:void 0}),(0,l.jsxs)(`form`,{onSubmit:Tt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Pe,onChange:e=>Fe(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Ie,onChange:e=>Le(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:Re,onChange:e=>ze(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Be,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>Ve(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>He(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>Ue(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>We(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Me,onClick:Et,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Me?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ge(t),E(``),A(Ce[t]||``),O(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:D,onChange:e=>O(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(be,{value:k,onChange:(e,t)=>{A(e),t?.maxTokens&&j(t.maxTokens)},...Ze})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Ke,onChange:e=>qe(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:Qe?.maxTokens,value:Je,onChange:e=>j(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ye,onChange:e=>Xe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),X===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):X.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:X.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B?Nt(B.binding):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:bt,onChange:e=>{Z(e.target.value);try{JSON.parse(e.target.value),Q(null)}catch(e){Q(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),xt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,xt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),$e.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):$e.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{P(e.name),F(e.description||``),L(e.content||``),z(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:rt===(e.source||e.name),onClick:()=>Ot(e.source||e.name),children:rt===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:R,onChange:e=>z(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:N,onChange:e=>P(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!R.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:et,onChange:e=>F(e.target.value),placeholder:`What this skill helps with`,disabled:!!R.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:`# Skill instructions…`,disabled:!!R.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:tt||!R.trim()&&!I.trim(),onClick:Dt,children:tt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:$,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The agent talks to canvas through its own scoped token; the server clamps every request to the binding. Bind, rotate and revoke apply immediately.`})]}),at===_.id?B?(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:Nt(B.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,B.permissions.join(`, `)||`none`,B.boundAt?` · bound ${new Date(B.boundAt).toLocaleString()}`:``,B.rotatedAt?` · token rotated ${new Date(B.rotatedAt).toLocaleString()}`:``]}),(0,l.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:H,onClick:jt,children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:H,onClick:Mt,children:`Revoke Access`})]})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),W&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:W}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(W),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>G(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`In-process agents receive it automatically (canvas.env); external runtimes (agentd) take it as CANVAS_TOKEN.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:B?`Rebind`:`Bind`}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:K,onChange:e=>st(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),K===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:J,onChange:e=>dt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),_t.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(K===`workspace`||K===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:q,onChange:e=>ct(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),ht.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),K===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:lt,onChange:e=>ut(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:ft,onChange:e=>pt(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>mt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:H,onClick:At,children:H?`Working…`:B?`Rebind & Mint Token`:`Bind & Mint Token`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),It&&(0,l.jsx)(a,{type:`submit`,disabled:Ae,children:Ae?`Saving…`:`Save Changes`})]})]})})}export{h as default};
|