shapewall 0.7.1 → 0.7.2
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/CHANGELOG.md +14 -0
- package/dist/agent/package-lock.json +2 -2
- package/dist/client/assets/{BoardChat-Bv4UDOjO.js → BoardChat-B8ucOOc0.js} +1 -1
- package/dist/client/assets/{ChecksPanel-C6r_Tc9g.js → ChecksPanel-m_9S0BeX.js} +1 -1
- package/dist/client/assets/{History-ajFROfWC.js → History-C3z_y_AC.js} +1 -1
- package/dist/client/assets/{LocalSettings-BSbmmpbN.js → LocalSettings-D_tVfnsp.js} +1 -1
- package/dist/client/assets/{Management-mo8uv2qG.js → Management-zSrx0gXl.js} +1 -1
- package/dist/client/assets/{QuickConnect-DlaijESK.js → QuickConnect-BVLgjq9l.js} +1 -1
- package/dist/client/assets/{app-update-dialog-BHVNR5Cp.js → app-update-dialog-hrSzISKP.js} +1 -1
- package/dist/client/assets/{index-B4AoX3ZW.css → index-C2_XIPRO.css} +1 -1
- package/dist/client/assets/{index-CQeHY7en.js → index-t3fn6ogR.js} +17 -17
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/{LocalAccountsApp-C1sCag6a.js → LocalAccountsApp-BFGZQUvR.js} +1 -1
- package/dist/console/assets/{LocalConsole-LXQmzRFT.js → LocalConsole-BF1NlOmi.js} +1 -1
- package/dist/console/assets/{app-update-dialog-CVniDJKA.js → app-update-dialog-RdHZ7VTX.js} +1 -1
- package/dist/console/assets/app-version-Dt9FxRbR.js +1 -0
- package/dist/console/assets/{console-sMMn_Rwc.css → console-BGRSS8Ru.css} +1 -1
- package/dist/console/assets/{console-CMNNLtFw.js → console-C6pwtJ3X.js} +3 -3
- package/dist/console/assets/{local-agents-DwYJ9cPb.js → local-agents-DUtV5lSR.js} +2 -2
- package/dist/console/assets/{tailnet--wXsG3uh.js → tailnet-D2fRVn68.js} +2 -2
- package/dist/console/assets/{usage-C5CJHejQ.js → usage-CLrlKCWx.js} +1 -1
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +5 -5
- package/package.json +1 -1
- package/dist/console/assets/app-version-CTHwlY6g.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{B as n,Cn as r,Ct as i,Dt as a,Et as o,H as s,Jt as c,Mt as l,Ot as u,Qt as ee,R as d,Sn as f,St as p,Tn as m,Tt as h,_n as g,a as _,bn as v,bt as y,c as b,ct as x,dt as S,ft as C,i as w,kt as T,lt as te,n as E,o as ne,pt as D,s as re,t as ie,tt as ae,ut as O,vn as k,w as A,xn as oe}from"./ui-2lMx-4bc.js";import{G as j,J as se,R as ce,X as le,Z as M,at as N,et as P,ft as F,h as I,k as ue,z as de}from"./index-CQeHY7en.js";import{n as L,t as R}from"./circle-x-D5MkDLJk.js";import{t as fe}from"./refresh-cw-B-npxKae.js";var pe={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};pe.node;var z=f(pe),B={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};B.node;var me=f(B),V={name:`image-up`,size:24,node:[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};V.node;var H=f(V),U={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};U.node;var W=f(U),he={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};he.node;var G=f(he),K=r(),q=`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`;function ge(){return(0,K.jsxs)(K.Fragment,{children:[`On the computer running Shapewall, run `,(0,K.jsx)(`code`,{className:`break-words font-mono`,children:`shapewall settings --config FILE --open`}),` with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),`.`]})}var J=t(m(),1);function Y({label:e,htmlFor:t,hint:n,problem:r,children:i,...a}){return(0,K.jsxs)(`div`,{className:`space-y-1`,...a,children:[t?(0,K.jsx)(`label`,{htmlFor:t,className:`block text-xs font-medium text-fg`,children:e}):(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:e}),i,r?(0,K.jsx)(`p`,{id:t?`${t}-problem`:void 0,className:`text-xs text-bad`,role:`alert`,"data-sw-settings-problem":`true`,children:r}):n?(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:n}):null]})}function _e({text:e,label:t,touch:r}){let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!i)return;let e=window.setTimeout(()=>a(!1),1500);return()=>window.clearTimeout(e)},[i]),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-line bg-sunken pl-2`,"data-sw-settings-export":t,children:[(0,K.jsx)(`code`,{ref:c,className:`min-w-0 flex-1 overflow-x-auto py-1.5 font-mono text-[11.5px] whitespace-nowrap text-fg`,children:e}),(0,K.jsx)(n,{variant:`ghost`,size:r?`icon`:`icon-sm`,onClick:async()=>{try{await navigator.clipboard.writeText(e),s(!1),a(!0)}catch{if(c.current){let e=document.createRange();e.selectNodeContents(c.current);let t=window.getSelection();t.removeAllRanges(),t.addRange(e)}s(!0)}},"aria-label":i?`Copied`:`Copy the ${t} line`,children:i?(0,K.jsx)(v,{size:14,"aria-hidden":`true`}):(0,K.jsx)(z,{size:14,"aria-hidden":`true`})})]}),o?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted`,role:`status`,children:`This browser did not allow copying. The line is selected: press Ctrl+C (or long-press) to copy it.`}):null]})}function X({children:e}){return(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-fg`,"data-sw-settings-override":`true`,children:[(0,K.jsx)(ce,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e})]})}function ve({items:e,keyVar:t,onCancel:r,onConfirm:i,busy:a,touch:o,confirmLabel:s=`Allow and save`,children:c=null,blocked:l=!1}){let u=o?`touch`:`md`;return(0,K.jsxs)(d,{open:!!e,onClose:()=>a?null:r(),title:`Allow this?`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:u,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(n,{size:u,variant:`default`,onClick:i,disabled:a||l,"data-sw-settings-confirm":`true`,children:a?`Saving...`:s})]}),children:[e?c:null,(0,K.jsx)(`div`,{className:`space-y-3 p-5 text-sm`,"data-sw-settings-confirm-list":`true`,children:(e||[]).map(e=>e.kind===`command`?(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-confirm-item":`command`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-fg`,children:[(0,K.jsx)(G,{size:14,"aria-hidden":`true`}),` Run this command on this machine, as you`]}),(0,K.jsx)(`code`,{className:`block rounded-md border border-line bg-sunken p-2 font-mono text-xs break-all text-fg`,children:e.command}),e.projectRoot?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Source folder for every board in this project:`,` `,(0,K.jsx)(`code`,{className:`font-mono break-all`,"data-sw-settings-confirm-root":!0,children:e.projectRoot})]}):null,(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Shapewall starts it for each chat thread, with your login and a small environment. Anyone who can chat on this board drives it. Only allow a command you installed yourself.`})]},`command:${e.command}`):(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-confirm-item":`host`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-fg`,children:[(0,K.jsx)(W,{size:14,"aria-hidden":`true`}),` Send your API key to `,e.host]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Every chat request carries the key in `,(0,K.jsx)(`code`,{className:`font-mono`,children:e.keyVar||t}),` to`,` `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:e.host}),`. Allow it only if you trust that host with the key.`]})]},`host:${e.keyVar}@${e.host}`))})]})}function ye({result:e}){if(!e)return null;if(e.note)return(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md border border-line bg-surface-2/60 p-3 text-xs text-muted`,role:`status`,"data-sw-settings-test-result":`note`,children:[(0,K.jsx)(N,{size:14,className:`mt-px shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e.note})]});let t=e.ok?L:R;return(0,K.jsxs)(`div`,{className:l(`rounded-md border p-3 text-xs`,e.ok?`border-ok/40 bg-ok/10`:`border-bad/40 bg-bad/10`),role:`status`,"data-sw-settings-test-result":e.ok?`ok`:`failed`,children:[(0,K.jsxs)(`p`,{className:l(`flex items-start gap-1.5 font-medium`,e.ok?`text-fg`:`text-bad`),children:[(0,K.jsx)(t,{size:14,className:l(`mt-px shrink-0`,e.ok?`text-ok`:`text-bad`),"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e.message})]}),e.details?.length?(0,K.jsx)(`ul`,{className:`mt-1.5 list-disc space-y-0.5 pl-5 text-muted`,children:e.details.map(e=>(0,K.jsx)(`li`,{children:e},e))}):null]})}function be(e){let t=Array.isArray(e?.profiles)?e.profiles:[],n=Array.isArray(e?.detected)?e.detected:[],r=(Array.isArray(e?.known)&&e.known.length?e.known:n).map(e=>{let r=t.find(t=>t.id===e.id),i={builtIn:e.label,logo:e.logo||null};if(r)return{kind:`connected`,id:e.id,label:r.label||e.label,profile:r,...i};let a=n.find(t=>t.id===e.id);return a?{kind:a.state===`ready`?`found`:a.state===`needs-shell`?`needs-shell`:`needs-adapter`,id:e.id,label:e.label,install:a.install||e.install||null,...i}:{kind:`missing`,id:e.id,label:e.label,...i}});for(let e of t)r.some(t=>t.id===e.id)||r.push({kind:`connected`,id:e.id,label:e.label,profile:e,builtIn:null,logo:e.logo||null});return r}async function xe(e,{maxBytes:t=5242880,maxLabel:n=`5 MB`}={}){if(!e||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type))throw Error(`Choose a PNG, JPEG or WebP image.`);if(e.size>t)throw Error(`Choose an image smaller than ${n}.`);let r;try{if(r=await createImageBitmap(e,{imageOrientation:`from-image`}),!r.width||!r.height)throw Error(`empty image`);let t=document.createElement(`canvas`);t.width=256,t.height=256;let n=t.getContext(`2d`);if(!n)throw Error(`no canvas`);let i=Math.min(r.width,r.height);return n.drawImage(r,(r.width-i)/2,(r.height-i)/2,i,i,0,0,256,256),t.toDataURL(`image/png`).split(`,`)[1]}catch{throw Error(`This image could not be read. Try another PNG, JPEG or WebP image.`)}finally{r?.close()}}var Se=2097152,Z=`upload:pending`,Ce=(e={})=>({name:e.label||``,icon:e.icon||null,tint:e.tint||null,png:null});function we(e,t){let n={};return t.name.trim()!==(e.label||``)&&(n.name=t.name.trim()),t.icon!==Z&&t.icon!==(e.icon||null)&&(n.icon=t.icon),t.tint!==(e.tint||null)&&(n.tint=t.tint),Object.keys(n).length?n:null}async function Q(e,t,n){let r=null,i=we(t,n);return i&&(r=await c.post(`/api/agent/settings/identity`,{id:e,...i})),n.icon===Z&&n.png&&(r=await c.post(`/api/agent/settings/identity/icon`,{id:e,png:n.png})),r}function Te({name:e,checked:t,onChange:n,label:r,children:i,className:a,...o}){return(0,K.jsxs)(`label`,{className:l(`relative inline-flex h-11 w-11 cursor-pointer items-center justify-center rounded-xl border-2 border-transparent`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-1 has-[:focus-visible]:outline-accent`,t?`border-accent bg-accent/10`:`hover:border-line-strong`,a),title:r,...o,children:[(0,K.jsx)(`input`,{type:`radio`,name:e,className:`sr-only`,checked:t,onChange:n,"aria-label":r}),i]})}function Ee({value:e,onChange:t,label:r,logo:i=null,upload:o=!0,disabled:s=!1}){let c=(0,J.useId)(),l=(0,J.useRef)(null),[u,ee]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),p=h(i),m=e.png?`data:image/png;base64,${e.png}`:null,g=e.icon===Z||T(e.icon),_=!g&&(e.icon||!p),v=async n=>{if(n){ee(!0),f(``);try{let r=await xe(n,{maxBytes:Se,maxLabel:`2 MB`});t({...e,icon:Z,png:r})}catch(e){f(e.message||`This image could not be read.`)}finally{ee(!1),l.current&&(l.current.value=``)}}},y=n=>t({...e,icon:n,png:null});return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,id:`${c}-icons`,children:`Icon`}),(0,K.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-icons`,className:`flex flex-wrap gap-1`,"data-sw-agent-icon-options":!0,children:[(0,K.jsx)(Te,{name:`${c}-icon`,checked:!e.icon,onChange:()=>y(null),label:p?`Default: the ${p.name} mark`:`Default: initials`,"data-sw-agent-icon-option":`default`,children:(0,K.jsx)(x,{label:r,logo:i,tint:e.tint,size:`lg`,className:`h-9 w-9`})}),O.map(t=>(0,K.jsx)(Te,{name:`${c}-icon`,checked:e.icon===t,onChange:()=>y(t),label:te[t].name,"data-sw-agent-icon-option":t,children:(0,K.jsx)(x,{label:r,icon:t,tint:e.tint,size:`lg`,className:`h-9 w-9`})},t)),g?(0,K.jsx)(Te,{name:`${c}-icon`,checked:!0,onChange:()=>{},label:`Your picture`,"data-sw-agent-icon-option":`upload`,children:(0,K.jsx)(x,{label:r,icon:e.icon===Z?null:e.icon,src:m,size:`lg`,className:`h-9 w-9`})}):null]}),o?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:[(0,K.jsxs)(n,{size:`touch`,className:`lg:h-8`,disabled:u||s,onClick:()=>l.current?.click(),children:[u?(0,K.jsx)(b,{}):(0,K.jsx)(H,{size:14,"aria-hidden":`true`}),` Upload a picture`]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`PNG, JPEG or WebP, up to 2 MB. Cropped to a square.`}),(0,K.jsx)(`input`,{ref:l,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`hidden`,"aria-label":`Choose a picture for the icon`,onChange:e=>void v(e.target.files?.[0]),"data-sw-agent-icon-upload":!0})]}):null,d?(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-agent-icon-problem":!0,children:d}):null]}),_?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,id:`${c}-tints`,children:`Colour`}),(0,K.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-tints`,className:`flex flex-wrap gap-1`,"data-sw-agent-tint-options":!0,children:[(0,K.jsx)(Te,{name:`${c}-tint`,checked:!e.tint,onChange:()=>t({...e,tint:null}),label:`Default colour`,"data-sw-agent-tint-option":`default`,children:(0,K.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full border border-line bg-surface-2 text-muted`,children:(0,K.jsx)(se,{size:13,"aria-hidden":`true`})})}),a.map(n=>(0,K.jsx)(Te,{name:`${c}-tint`,checked:e.tint===n,onChange:()=>t({...e,tint:n}),label:S[n],"data-sw-agent-tint-option":n,children:(0,K.jsx)(`span`,{className:`h-7 w-7 rounded-full`,style:{background:D(n)}})},n))]})]}):null]})}function De({value:e,onChange:t,builtIn:n=``,touch:r=!1,id:i,problem:a=null,disabled:o=!1,hint:s=null}){return(0,K.jsx)(Y,{label:`Name`,htmlFor:i,problem:a,hint:s||(n?`Shown in chats, on its replies and on Fix buttons. Leave it empty for "${n}".`:`Shown in chats, on its replies and on Fix buttons.`),children:(0,K.jsx)(A,{id:i,size:r?`touch`:`sm`,value:e.name,onChange:n=>t({...e,name:n.target.value}),placeholder:n||`Agent`,maxLength:40,autoComplete:`off`,spellCheck:!1,disabled:o,"aria-invalid":a?`true`:void 0,"aria-describedby":a?`${i}-problem`:void 0,"data-sw-agent-name-input":!0})})}function Oe(e){let{problem:t}=u(e);return t?/control/.test(t)?`One line of plain text, without control characters.`:`At most 40 characters.`:null}function ke({value:e,onChange:t,builtIn:n,logo:r=null,upload:i=!0,touch:a=!1,disabled:o=!1}){let s=(0,J.useId)();return(0,K.jsxs)(`div`,{className:`space-y-3 border-b border-line px-5 pt-5 pb-4`,"data-sw-connect-identity":!0,children:[(0,K.jsx)(De,{id:`${s}-name`,value:e,onChange:t,builtIn:n,touch:a,problem:Oe(e.name),disabled:o}),(0,K.jsxs)(`details`,{className:`group`,"data-sw-connect-icon":!0,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2 text-xs font-medium text-fg lg:min-h-8 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(k,{size:13,className:`text-muted transition-transform group-open:rotate-90`,"aria-hidden":`true`}),(0,K.jsx)(x,{label:e.name||n,icon:e.icon===Z?null:e.icon,tint:e.tint,logo:r,size:`sm`,src:e.png?`data:image/png;base64,${e.png}`:null}),`Icon (optional)`]}),(0,K.jsx)(`div`,{className:`pt-2`,children:(0,K.jsx)(Ee,{value:e,onChange:t,label:e.name||n,logo:r,upload:i,disabled:o})})]})]})}function Ae({agent:e,upload:t=!0,touch:r=!1,waiting:i=!1,onClose:a,onSaved:o}){let s=(0,J.useId)(),[c,l]=(0,J.useState)(Ce()),[u,ee]=(0,J.useState)(!1),[f,p]=(0,J.useState)(``),m=(0,J.useRef)(null);(0,J.useEffect)(()=>{e&&(m.current=e.id,l(Ce(e)),p(``))},[e]);let h=r?`touch`:`md`,g=Oe(c.name),_=e&&!e.builtIn&&!c.name.trim()?`Give it a name.`:null,v=e?!!we(e,c)||!!c.png:!1,y=async()=>{ee(!0),p(``);try{let t=await Q(e.id,e,c);await o?.(t),a()}catch(e){p(e.message||`It could not be saved.`)}finally{ee(!1)}},b=c.png?`data:image/png;base64,${c.png}`:null;return(0,K.jsx)(d,{open:!!e,onClose:()=>u?null:a(),title:`Name and icon`,description:`How this agent shows on the board. It keeps running; nothing is restarted.`,wrapDescription:!0,size:`md`,onCloseAutoFocus:e=>{let t=document.querySelector(`[data-sw-agent-edit="${CSS.escape(m.current||``)}"]`);t&&(e.preventDefault(),t.focus())},footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:h,onClick:a,disabled:u,children:`Cancel`}),(0,K.jsx)(n,{size:h,variant:`default`,onClick:y,disabled:u||!v||!!(g||_),"data-sw-agent-identity-save":!0,children:u?i?`Saving when the connection test finishes...`:`Saving...`:`Save`})]}),children:(0,K.jsxs)(`form`,{className:`space-y-4 p-5`,onSubmit:e=>{e.preventDefault(),!u&&v&&!g&&!_&&y()},"data-sw-agent-identity":e?.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(x,{label:c.name||e?.builtIn||e?.label,icon:c.icon===Z?null:c.icon,tint:c.tint,logo:e?.logo,src:b,size:`xl`,"data-sw-agent-identity-preview":!0}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(De,{id:`${s}-name`,value:c,onChange:l,builtIn:e?.builtIn||``,touch:r,problem:g||_,disabled:u})})]}),(0,K.jsx)(Ee,{value:c,onChange:l,label:c.name||e?.builtIn||e?.label,logo:e?.logo,upload:t,disabled:u}),i&&!f?(0,K.jsx)(`p`,{className:`text-xs text-muted`,role:`status`,"data-sw-agent-identity-waiting":!0,children:`Its connection test is still running. Save waits for it to finish, then saves.`}):null,f?(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-agent-identity-error":!0,children:f}):null,(0,K.jsx)(`button`,{type:`submit`,className:`hidden`,tabIndex:-1,"aria-hidden":`true`})]})})}var je={claude:{text:`Install Claude Code and its adapter, then check again.`,anchor:`claude-code`},codex:{text:`Install Codex and its adapter, then check again.`,anchor:`codex`},goose:{text:`Install goose from its install guide, then check again.`,anchor:`goose`},gemini:{text:`Install Gemini CLI, then check again.`,anchor:`gemini-cli`}},Me=`In the demo nothing runs on a computer. On your install this looks for the agent again.`,Ne={connected:`Connected`,found:`Found, not connected`,"needs-adapter":`Found, but its adapter is missing`,"needs-shell":`Found, but only as a .cmd wrapper`,missing:`Not installed`};function Pe({title:e,description:t,children:n,...r}){return(0,K.jsxs)(`section`,{className:`space-y-2.5`,...r,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e}),t?(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t}):null]}),n]})}function Fe({view:e=null,disabled:t=!1,touch:r=!1,onBusy:a=null,onChanged:o=null,endpointForm:s=null,onOpenEndpoint:u=null,agent:f=null}){let[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),[te,E]=(0,J.useState)({}),[ne,D]=(0,J.useState)(!1),[re,ie]=(0,J.useState)(null),[O,k]=(0,J.useState)(Ce());(0,J.useEffect)(()=>a?.(!!x),[x,a]);let A=(0,J.useCallback)(async()=>{if(f&&!f.settingsEditable)_(f.settingsReadonly?`Change agents on the computer running Shapewall.`:`owner`),y(f);else try{let e=await c.get(`/api/agent/settings`);if(e.editable===!1){_(e.message||`owner`),y(await c.get(`/api/agent/status`).catch(()=>null));return}h(e),_(null)}catch(e){e.status===404&&ee(),_(e.status===404?`owner`:e.message),y(await c.get(`/api/agent/status`).catch(()=>null))}},[f]);(0,J.useEffect)(()=>{e||A()},[e,A]),ue(()=>{x||A()},!e);let j=e||m,se=!!j?.testing;(0,J.useEffect)(()=>{if(!se||e||x)return;let t=window.setInterval(A,1500);return()=>window.clearInterval(t)},[se,e,x,A]);let N=async t=>{t&&!e?h(t):e||await A(),await o?.()},P=(e,t)=>t?.demoNote?(T(null),E(n=>({...n,[e]:{note:t.demoNote}})),!0):!1,L=async(e,t=null)=>{S(e),E(t=>({...t,[e]:null}));try{let n=t?{name:O.name.trim(),...O.icon&&!O.png?{icon:O.icon}:{},...O.tint?{tint:O.tint}:{}}:{},r=await c.post(`/api/agent/settings/profiles/connect`,{agentId:e,confirm:t,...n});if(P(e,r))return;if(r.confirm){k(Ce({label:H.find(t=>t.id===e)?.label||``})),T({agentId:e,items:r.confirm,hash:r.confirmHash});return}if(T(null),r.connected&&t&&O.png){let t=await Q(e,{},{...O,name:``,tint:null}).catch(()=>null);t&&(r={...r,...t})}E(t=>({...t,[e]:r.result})),r.connected&&await N(r)}catch(t){T(null),E(n=>({...n,[e]:{ok:!1,message:t.message,details:[]}}))}finally{S(null)}},R=async e=>{S(e);try{let t=await c.delete(`/api/agent/settings/profiles/${encodeURIComponent(e)}`);if(P(e,t))return;await N(t),E(t=>({...t,[e]:null}))}catch(t){E(n=>({...n,[e]:{ok:!1,message:t.message,details:[]}}))}finally{S(null)}},pe=async(t,n=!1)=>{S(t),E(e=>({...e,[t]:null}));try{let r=await c.post(`/api/agent/settings/test`,n?{}:{profileId:t});if(P(t,r))return;E(e=>({...e,[t]:r})),e||await A()}catch(e){E(n=>({...n,[t]:{ok:!1,message:e.message,details:[]}}))}finally{S(null)}},z=async e=>{S(`default:${e}`);try{let t=await c.post(`/api/agent/settings/profiles/${encodeURIComponent(e)}/default`,{});if(P(`default`,t))return;await N(t)}catch(e){E(t=>({...t,default:{ok:!1,message:e.message,details:[]}}))}finally{S(null)}},B=r?`touch`:`sm`;if(g)return(0,K.jsx)(Ie,{locked:g,status:v});if(!j)return(0,K.jsxs)(`p`,{className:`flex items-center gap-2 p-1 text-sm text-muted`,"data-sw-agents-card":`loading`,children:[(0,K.jsx)(b,{}),` Looking for agents on this machine`]});let V=!!j.env?.acp,H=be(j),U=[...H.filter(e=>e.kind===`connected`).map(e=>({id:e.id,label:e.label,state:e.profile.state,isDefault:e.profile.default,...C(e.profile),logo:e.logo})),...j.endpoint?[{id:`endpoint`,label:j.endpoint.label,state:j.endpoint.state,isDefault:j.endpoint.default,...C(j.endpoint)}]:[]],W=j.testing||null,he=W?H.find(e=>e.id===W.id)?.label||j.effective?.label||`the agent`:null,G=W?`Testing the connection to ${he}. This is available when the test finishes.`:void 0,q=!!x||t||V||!!W,ge=!!x||t,Y=w?H.find(e=>e.id===w.agentId):null,X=V&&j.effective?.configured?{id:`default`,label:j.effective.label,...C(j.effective)}:null;return(0,K.jsxs)(`div`,{className:`space-y-6`,"data-sw-agents-card":j.demo?`demo`:`editable`,"data-sw-native-profiles":!0,children:[j.demo?(0,K.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-line bg-surface-2/60 px-3 py-2.5 text-xs text-muted`,role:`note`,"data-sw-agents-demo-note":!0,children:[(0,K.jsx)(oe,{size:14,className:`mt-px shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:`This is a demo with sample agents on a pretend computer. The two scripted agents answer in this browser, and nothing is sent anywhere. Choosing the default, testing, removing and connecting them works here; Reset puts everything back.`})]}):null,W&&!x?(0,K.jsxs)(`p`,{className:`flex items-center gap-2 rounded-md border border-line bg-surface-2/60 px-3 py-2.5 text-xs text-fg`,role:`status`,"data-sw-agents-testing":W.id,children:[(0,K.jsx)(b,{size:12}),(0,K.jsxs)(`span`,{children:[`Testing the connection to `,he,`. Connect, Test connection, Remove and the default wait for it; a name or an icon can be changed meanwhile.`]})]}):null,V?(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-fg`,"data-sw-agents-override":!0,children:[(0,K.jsx)(ce,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[`The agent command comes from `,j.env.acp===`flag`?`--agent-acp`:`SHAPEWALL_AGENT_ACP`,`, which wins over these settings. Change it there, or restart `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),` without it.`]})]}):null,U.length?(0,K.jsxs)(Pe,{title:`Default agent for new chats and fixes`,description:`Chats that chose another agent keep theirs.`,children:[(0,K.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default agent for new chats and fixes`,className:`grid gap-1.5`,"data-sw-agents-default":!0,children:U.map(e=>(0,K.jsxs)(`label`,{className:l(`flex min-h-11 cursor-pointer items-center gap-2.5 rounded-md border px-3 py-2 text-sm lg:min-h-10`,e.isDefault?`border-accent/50 bg-accent/10`:`border-line bg-surface hover:bg-surface-2`,q&&`cursor-default opacity-70`),title:G,"data-sw-agents-default-option":e.id,children:[(0,K.jsx)(`input`,{type:`radio`,name:`sw-default-agent`,className:`h-4 w-4 shrink-0 accent-[var(--color-accent)]`,checked:!!e.isDefault,disabled:q,onChange:()=>z(e.id)}),e.id===`endpoint`&&!e.icon&&!e.tint?(0,K.jsx)(me,{size:16,className:`shrink-0 text-muted`,"aria-hidden":`true`}):(0,K.jsx)(I,{label:e.label,state:e.state,size:`sm`,icon:e.icon,tint:e.tint,logo:e.logo}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:e.label}),x===`default:${e.id}`?(0,K.jsx)(b,{size:12}):null,e.isDefault?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]},e.id))}),te.default?(0,K.jsx)(ye,{result:te.default}):null]}):null,(0,K.jsx)(Pe,{title:`Agents on this machine`,description:`Shapewall looks for these on this computer's PATH. It never installs or downloads anything.`,children:(0,K.jsxs)(`ul`,{className:`divide-y divide-line rounded-md border border-line`,"aria-label":`Agents on this machine`,children:[X?(0,K.jsx)(`li`,{className:`p-3`,"data-sw-agent-row":`default`,"data-sw-agent-row-state":`fixed`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,K.jsx)(I,{label:X.label,state:j.effective.problem?`unavailable`:`ready`,...C(X)}),(0,K.jsxs)(`div`,{className:`min-w-[10rem] flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[X.label,` `,(0,K.jsx)(ae,{tone:`accent`,children:`Default`})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Started from `,j.env.acp===`flag`?`--agent-acp`:`SHAPEWALL_AGENT_ACP`]})]}),(0,K.jsxs)(n,{size:B,disabled:ge,onClick:()=>ie({...X,builtIn:j.effective.builtInLabel||X.label}),"aria-label":`Edit ${X.label}: name and icon`,"data-sw-agent-edit":`default`,children:[(0,K.jsx)(M,{size:13,"aria-hidden":`true`}),` Edit`]})]})}):null,H.map(e=>(0,K.jsxs)(`li`,{className:`space-y-2 p-3`,"data-sw-agent-row":e.id,"data-sw-agent-row-state":e.kind,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,K.jsx)(I,{label:e.label,state:e.kind===`connected`?e.profile.state:`unavailable`,...C(e.profile),logo:e.logo}),(0,K.jsxs)(`div`,{className:`min-w-[10rem] flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[e.label,e.profile?.default?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]}),(0,K.jsx)(`p`,{className:l(`text-xs`,e.kind===`connected`&&e.profile.state===`login`?`text-fg`:`text-muted`),children:e.kind===`connected`?e.profile.state===`testing`?`Connecting. Testing the connection...`:`Connected. ${i(e.profile)}`:Ne[e.kind]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.kind===`connected`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(n,{size:B,disabled:q,title:G,onClick:()=>pe(e.id,e.profile.legacy),"data-sw-agent-test":e.id,children:[x===e.id?(0,K.jsx)(b,{}):null,` Test connection`]}),(0,K.jsxs)(n,{size:B,disabled:ge,onClick:()=>ie({id:e.id,label:e.label,...C(e.profile),logo:e.logo,builtIn:e.builtIn}),"aria-label":`Edit ${e.label}: name and icon`,"data-sw-agent-edit":e.id,children:[(0,K.jsx)(M,{size:13,"aria-hidden":`true`}),` Edit`]}),(0,K.jsxs)(n,{size:B,variant:`danger`,disabled:q,title:G,onClick:()=>R(e.id),"data-sw-agent-remove":e.id,children:[(0,K.jsx)(de,{size:13,"aria-hidden":`true`}),` Remove`]})]}):e.kind===`found`?(0,K.jsxs)(n,{size:B,variant:`default`,disabled:q,title:G,onClick:()=>L(e.id),"data-sw-profile-connect":e.id,"data-sw-agent-connect-row":e.id,children:[x===e.id?(0,K.jsx)(b,{}):(0,K.jsx)(le,{size:13,"aria-hidden":`true`}),` `,x===e.id?`Connecting...`:`Connect`]}):e.kind===`needs-adapter`||e.kind===`missing`?(0,K.jsxs)(n,{size:B,variant:`ghost`,disabled:!!x,onClick:()=>j.demo?P(e.id,{demoNote:Me}):N(),"data-sw-agent-check":e.id,children:[(0,K.jsx)(fe,{size:13,"aria-hidden":`true`}),` Check again`]}):null})]}),e.kind===`connected`&&e.profile.state===`login`&&e.profile.loginHint?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-agent-sign-in":e.id,children:[p(e.profile.loginHint),`, then test again.`]}):null,e.kind===`needs-adapter`&&e.install?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Install its adapter in a terminal, then check again:`}),(0,K.jsx)(_e,{text:e.install,label:`${e.label} install`,touch:r})]}):null,e.kind===`needs-shell`?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`It needs a shell, which Shapewall never starts. Under Other, set the agent command to`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`node`}),` and the path of its script (see the docs).`]}):null,e.kind===`missing`?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[je[e.id]?.text||`Install it, then check again.`,` `,(0,K.jsxs)(`a`,{className:`inline-flex items-center gap-0.5 text-accent underline-offset-2 hover:underline`,href:`${Xe}#${je[e.id]?.anchor||`connect-an-agent-cli-over-acp`}`,target:`_blank`,rel:`noreferrer`,children:[`How to set it up `,(0,K.jsx)(F,{size:11,"aria-hidden":`true`})]})]}):null,(0,K.jsx)(ye,{result:te[e.id]})]},e.id)),(0,K.jsxs)(`li`,{className:`space-y-2 p-3`,"data-sw-agent-row":`endpoint`,"data-sw-agent-row-state":j.endpoint?`connected`:`none`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[j.endpoint?.icon||j.endpoint?.tint?(0,K.jsx)(I,{label:j.endpoint.label,state:j.endpoint.state||`ready`,...C(j.endpoint)}):(0,K.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-line bg-surface-2 text-muted`,children:(0,K.jsx)(me,{size:14,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`min-w-[10rem] flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[`Other`,j.endpoint?.default?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:j.endpoint?`${j.endpoint.label}${j.endpoint.host?` at ${j.endpoint.host}`:``}`:`An OpenAI-compatible endpoint: OpenAI, DeepSeek, OpenRouter, Ollama, LM Studio.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[j.endpoint?.default?(0,K.jsxs)(n,{size:B,disabled:q,onClick:()=>pe(`endpoint`,!0),"data-sw-agent-test":`endpoint`,children:[x===`endpoint`?(0,K.jsx)(b,{}):null,` Test connection`]}):null,j.endpoint?(0,K.jsxs)(n,{size:B,disabled:ge,onClick:()=>ie({id:`endpoint`,label:j.endpoint.label,...C(j.endpoint),builtIn:j.endpoint.model}),"aria-label":`Name and icon of ${j.endpoint.label}`,"data-sw-agent-edit":`endpoint`,children:[(0,K.jsx)(M,{size:13,"aria-hidden":`true`}),` Name and icon`]}):null,s||u?(0,K.jsx)(n,{size:B,disabled:!!x||t,onClick:()=>u?u():D(!0),"data-sw-agent-endpoint":!0,children:j.endpoint?`Edit`:`Set up`}):null]})]}),(0,K.jsx)(ye,{result:te.endpoint})]})]})}),(0,K.jsx)(ve,{items:w?.items||null,keyVar:``,busy:!!x,touch:r,onCancel:()=>T(null),onConfirm:()=>L(w.agentId,w.hash),confirmLabel:`Allow and connect`,blocked:!!Oe(O.name),children:(0,K.jsx)(ke,{value:O,onChange:k,builtIn:Y?.builtIn||Y?.label||``,logo:Y?.logo,upload:j.iconUpload!==!1,touch:r,disabled:!!x})}),(0,K.jsx)(Ae,{agent:re,waiting:!!(W&&re&&(W.id===re.id||re.id==="default"&&W.id==="default")),upload:j.iconUpload!==!1,touch:r,onClose:()=>ie(null),onSaved:e=>e?N(e):null}),s?(0,K.jsx)(d,{open:ne,onClose:()=>{D(!1),N()},title:`Other agent settings`,size:`md`,children:(0,K.jsx)(`div`,{className:`p-5`,children:ne?s({onSaved:()=>N()}):null})}):null]})}function Ie({locked:e,status:t}){let{options:n}=y({profileId:`default`,profiles:t?.profiles||[]}),r=n.length?n:t?.configured?[{id:`default`,label:t.label||`Agent`,state:t.state||`ready`,isDefault:!0,configured:!0,...C(t)}]:[];return(0,K.jsxs)(`div`,{className:`space-y-3`,"data-sw-agents-card":`readonly`,children:[(0,K.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-line bg-surface-2/60 px-3 py-2.5 text-xs text-muted`,role:`note`,children:[(0,K.jsx)(P,{size:14,className:`mt-px shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e===`owner`?`To change agents, open the owner link that shapewall serve prints in your terminal (or run shapewall serve --open).`:e})]}),r.length?(0,K.jsx)(`ul`,{className:`divide-y divide-line rounded-md border border-line`,"aria-label":`Connected agents`,children:r.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 p-3`,"data-sw-agent-row":e.id,"data-sw-agent-row-state":`connected`,children:[(0,K.jsx)(I,{label:e.label,state:e.state,icon:e.icon,tint:e.tint,logo:e.logo}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[e.label,e.isDefault?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:i(e)})]})]},e.id))}):(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`No agent is connected.`})]})}function $(e){let t=e?.saved||{},n=t.backend===`acp`&&t.acpCommand?(t.profiles||[]).find(e=>e.acpCommand===t.acpCommand):null;return{backend:t.backend||e?.effective?.backend||`openai-compatible`,baseUrl:t.baseUrl||``,model:t.model||``,apiKeyEnv:t.apiKeyEnv||``,label:n?.label||t.label||``,acpCommand:t.acpCommand||``,keyHosts:t.keyHosts||[],vision:typeof t.vision==`boolean`?t.vision:null}}function Le(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Re({view:e,form:t,next:n}){let r=e?!Le(t,$(e)):!1,i=$(n);return r?{view:n,form:t,stale:!Le($(e),i)&&!Le(t,i)}:{view:n,form:i,stale:!1}}var ze=e({SettingsDialog:()=>Ye}),Be=/^(SHAPEWALL_AGENT_[A-Z0-9_]+|[A-Z][A-Z0-9_]*_API_KEY)$/,Ve=new Set([`GITHUB_TOKEN`,`GH_TOKEN`,`SHAPEWALL_GITHUB_TOKEN`,`SHAPEWALL_GITHUB_WEBHOOK_SECRET`,`SHAPEWALL_WEBHOOK_SECRET`,`RESEND_API_KEY`,`SHAPEWALL_AGENT_BASE_URL`,`SHAPEWALL_AGENT_MODEL`,`SHAPEWALL_AGENT_KEY_HOSTS`]),He=[{id:`openai-compatible`,label:`OpenAI-compatible`},{id:`acp`,label:`ACP agent`}],Ue=[{label:`Claude Code`,command:`claude-agent-acp`},{label:`Codex`,command:`codex-acp`},{label:`goose`,command:`goose acp --with-builtin developer`},{label:`Gemini CLI`,command:`gemini --acp`}];function We(e){return e&&(!Be.test(e)||Ve.has(e))?`Use SHAPEWALL_AGENT_API_KEY or a name ending in _API_KEY (never another tool’s token).`:null}function Ge(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.host.toLowerCase():null}catch{return null}}function Ke({onSaved:e,touch:t,buzz:r=!1,onDirtyChange:i,agents:a=`inline`}){let[o,s]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)($(null)),[m,h]=(0,J.useState)(!1),[_,y]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[T,te]=(0,J.useState)(!1),[ne,D]=(0,J.useState)(null),[re,O]=(0,J.useState)(!1),k=m||re,[j,se]=(0,J.useState)(!1),M=(0,J.useRef)(0),N=(0,J.useRef)(0),P=(0,J.useRef)(!1),F=(0,J.useRef)({view:null,form:null}),I=(0,J.useRef)(null),de=(0,J.useCallback)(async()=>{let e=++M.current;N.current+=1;try{let t=await c.get(`/api/agent/settings`);if(e!==M.current)return;s(t),p($(t)),se(!1),d(null),F.current={view:t,form:$(t)}}catch(t){if(e!==M.current)return;t.status===404&&ee(),d(t.status===404?q:t.message)}finally{--N.current,!N.current&&P.current&&(P.current=!1,I.current?.())}},[]);(0,J.useEffect)(()=>{de()},[de]),I.current=async()=>{if(k||!F.current.view||u)return;if(N.current){P.current=!0;return}let e=M.current,t;try{t=await c.get(`/api/agent/settings`)}catch{return}if(e!==M.current||N.current||!F.current.view)return;let n=Re({view:F.current.view,form:F.current.form,next:t});s(n.view),p(n.form),n.stale&&se(!0)},ue(()=>I.current?.());let L=e=>t=>{let n=typeof t==`string`?t:t.target.value;p(t=>({...t,[e]:n})),S(!1)};F.current={view:o,form:f};let R=o?!Le(f,$(o)):!1;(0,J.useEffect)(()=>{R||se(!1)},[R]),(0,J.useEffect)(()=>(i?.(R),()=>i?.(!1)),[R,i]);let pe=()=>{p($(o)),y(null),S(!1)},z=o?.config||{},B=o?.effective||{},me=f.backend===`acp`,V=f.apiKeyEnv.trim()||z.apiKeyEnv||o?.defaultKeyVar||`SHAPEWALL_AGENT_API_KEY`,H=We(f.apiKeyEnv.trim()),U=!!o?.keyVarsSet?.includes(V),he=o?.env?.baseUrl?B.baseUrl:f.baseUrl.trim()||z.baseUrl||``,G=Ge(he),be=f.baseUrl.trim()&&!Ge(f.baseUrl.trim())?`An http(s) URL, such as https://api.deepseek.com`:null,xe=!U&&!f.apiKeyEnv.trim()&&!z.apiKeyEnv&&/^http:/i.test(he),Se=!!o?.env?.acp,Z=(0,J.useMemo)(()=>({backend:f.backend,baseUrl:f.baseUrl.trim()||null,model:f.model.trim()||null,apiKeyEnv:f.apiKeyEnv.trim()||null,label:f.label.trim()||null,acpCommand:f.acpCommand.trim()||null,keyHosts:f.keyHosts,vision:f.vision}),[f]),Ce=async(t=null)=>{h(!0),y(null);try{let n=await c.post(`/api/agent/settings`,{settings:Z,confirm:t});if(n.demoNote){w(null),D({note:n.demoNote});return}if(n.confirm){w({items:n.confirm,hash:n.confirmHash});return}M.current+=1,s(n),p($(n)),w(null),S(!0),D(null),e?.()}catch(e){w(null),y(e.message)}finally{h(!1)}},we=async()=>{te(!0),D(null);try{let e=await c.post(`/api/agent/settings/test`,{});D(e),typeof e.vision==`boolean`&&e.vision!==(f.vision??!0)&&p(t=>({...t,vision:e.vision}))}catch(e){D({ok:!1,message:e.message,details:[]})}finally{te(!1)}};if(u)return(0,K.jsxs)(`div`,{className:`space-y-3 p-5`,"data-sw-settings-error":`load`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:u===`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`?(0,K.jsx)(ge,{}):`Could not load the agent settings: ${u}`}),u===`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`?null:(0,K.jsx)(n,{size:t?`touch`:`sm`,onClick:()=>{d(null),de()},children:`Try again`})]});if(!o)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-5 text-sm text-muted`,children:[(0,K.jsx)(b,{}),` Loading`]});if(o.editable===!1)return(0,K.jsxs)(`div`,{className:`space-y-3 p-5`,"data-sw-settings-readonly":!0,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:o.message}),(0,K.jsx)(`dl`,{className:`space-y-2 text-sm text-fg`,children:[[`Agent`,B.label],[`Backend`,B.backend],[`Command`,B.acpCommand],[`Model`,B.model],[`Endpoint`,B.baseUrl],[`Key variable`,B.keyVar]].filter(([,e])=>e).map(([e,t])=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted`,children:e}),(0,K.jsx)(`dd`,{className:`break-all`,children:t})]},e))})]});let Q=t?`touch`:`sm`,Te=e=>B.sources?.[e]===`config`?`from shapewall.config.json`:null,Ee=(e,t)=>z[e]?`${z[e]} (${Te(e)||`from the config`})`:t;return(0,K.jsxs)(`div`,{className:`space-y-5`,"data-sw-settings":`agent`,children:[a===`inline`?(0,K.jsxs)(`section`,{className:`space-y-3 rounded-md border border-line p-3`,"aria-labelledby":`sw-agents-inline`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{id:`sw-agents-inline`,className:`text-sm font-semibold text-fg`,children:`Agents`}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted`,children:[`Connect several agents, then choose one per chat. Each runs its own session with its own login on this computer.`,r?` Buzz conversations are separate.`:``]})]}),(0,K.jsx)(Fe,{view:o,disabled:R||m||T,touch:t,onBusy:O,onChanged:async()=>{await de(),e?.()}}),R?(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Save or discard your changes below before changing agents.`}):null]}):a===`link`?(0,K.jsx)(Je,{view:o,touch:t}):null,o.project?.root?(0,K.jsxs)(`section`,{className:`space-y-1.5 rounded-md border border-line p-3 text-xs`,"data-sw-agent-project":!0,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-fg`,children:`Source folder on the Shapewall computer`}),(0,K.jsx)(`code`,{className:`block font-mono break-all text-fg`,"data-sw-agent-project-root":!0,children:o.project.root}),(0,K.jsx)(`p`,{className:`text-muted`,children:`Native agents work in this folder for every board in this project. Capturing a website does not give access to its source. To work on another repository, serve a separate project from that checkout on the computer with your agent login.`})]}):null,j?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-line p-2.5 text-xs`,role:`status`,"data-sw-settings-stale":!0,children:[(0,K.jsx)(fe,{size:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:`Agent settings changed elsewhere. Reload to see them.`}),(0,K.jsx)(n,{size:t?`touch`:`xs`,variant:`secondary`,onClick:de,"data-sw-settings-stale-reload":!0,children:`Reload`})]}):null,(0,K.jsxs)(`section`,{className:`flex items-start gap-3 rounded-md border border-line bg-surface-2/60 p-3 text-xs`,"data-sw-settings-status":B.configured?`connected`:`not-connected`,children:[(0,K.jsx)(oe,{size:16,className:`mt-px shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,K.jsx)(`p`,{className:`font-medium text-fg`,children:B.configured?(0,K.jsxs)(K.Fragment,{children:[`Chat uses `,B.label||`the agent`,B.backend===`acp`?` over ACP, on this machine`:B.host?` at ${B.host}`:``]}):`Chat is not connected yet`}),B.problem?(0,K.jsx)(`p`,{className:`text-bad`,children:B.problem}):null]}),(0,K.jsx)(ae,{tone:B.configured?`ok`:`warn`,children:B.configured?B.backend===`acp`?`Command set`:`Connected`:`Not connected`})]}),Se?(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-acp-override":o.env.acp,children:[(0,K.jsxs)(X,{children:[`The agent command comes from`,` `,o.env.acp===`flag`?`the --agent-acp option on the command line`:`SHAPEWALL_AGENT_ACP in the environment`,` and wins over these settings until Shapewall is started without it.`]}),(0,K.jsx)(`label`,{htmlFor:`sw-agent-acp-in-use`,className:`block text-xs font-medium text-fg`,children:`Command in use`}),(0,K.jsx)(A,{id:`sw-agent-acp-in-use`,size:Q,value:B.acpCommand||``,readOnly:!0,className:`font-mono`,"data-sw-settings-acp-in-use":`true`})]}):null,o.fileProblem?(0,K.jsx)(`p`,{className:`text-xs text-bad`,children:o.fileProblem}):null,(0,K.jsx)(Y,{label:`Connect to`,children:(0,K.jsx)(ie,{label:`Connect to`,options:He,value:f.backend,onChange:e=>{L(`backend`)(e),D(null)},large:t,disabled:k,className:`max-w-sm`})}),me?(0,K.jsxs)(`div`,{className:`space-y-4`,"data-sw-settings-backend":`acp`,children:[(0,K.jsxs)(`section`,{className:`space-y-1.5 rounded-md border border-warn/60 bg-warn/10 p-3 text-xs text-fg`,role:`note`,"data-sw-settings-acp-warning":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,K.jsx)(ce,{size:14,className:`shrink-0 text-warn`,"aria-hidden":`true`}),` An ACP agent brings its own tools`]}),(0,K.jsx)(`p`,{children:`It runs with its own tools and extensions (a shell, browser control, MCP servers from its own config), and Shapewall does not sandbox them: Shapewall only asks you before its own file writes and commands. Use a restricted profile:`}),(0,K.jsxs)(`ul`,{className:`list-disc space-y-0.5 pl-5`,children:[(0,K.jsxs)(`li`,{children:[`Claude Code: permission mode `,(0,K.jsx)(`code`,{className:`font-mono`,children:`default`}),` or `,(0,K.jsx)(`code`,{className:`font-mono`,children:`plan`}),` in your Claude settings, never `,(0,K.jsx)(`code`,{className:`font-mono`,children:`bypassPermissions`}),`.`]}),(0,K.jsxs)(`li`,{children:[`Codex: `,(0,K.jsx)(`code`,{className:`font-mono`,children:`sandbox_mode = "workspace-write"`}),` or `,(0,K.jsx)(`code`,{className:`font-mono`,children:`"read-only"`}),`, never `,(0,K.jsx)(`code`,{className:`font-mono`,children:`danger-full-access`}),`.`]}),(0,K.jsxs)(`li`,{children:[`goose: `,(0,K.jsx)(`code`,{className:`font-mono`,children:`goose acp --with-builtin developer`}),` with a profile of its own that has no other extensions (`,(0,K.jsx)(`code`,{className:`font-mono`,children:`GOOSE_PATH_ROOT`}),`).`]})]})]}),(0,K.jsx)(Y,{label:Se?`Saved agent command (used when Shapewall starts without the override)`:`Agent command`,htmlFor:`sw-agent-acp`,hint:`One program and its arguments, no shell. It runs on this machine, as you, with its own login; Shapewall asks you before it writes files or runs commands.`,children:(0,K.jsx)(A,{id:`sw-agent-acp`,size:Q,value:f.acpCommand,onChange:L(`acpCommand`),placeholder:`claude-agent-acp`,disabled:k,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,className:`font-mono`,"data-sw-settings-field":`acpCommand`})}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Common agents`,children:Ue.map(e=>(0,K.jsx)(n,{size:t?`touch`:`xs`,variant:f.acpCommand.trim()===e.command?`default`:`secondary`,disabled:k,onClick:()=>L(`acpCommand`)(e.command),"data-sw-settings-preset":e.command,children:e.label},e.command))}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Install the adapter first (for Claude Code:`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`npm install -g @agentclientprotocol/claude-agent-acp`}),`). See`,` `,(0,K.jsx)(`a`,{className:`text-accent underline-offset-2 hover:underline`,href:`https://shapewall.com/docs/chat`,target:`_blank`,rel:`noreferrer`,children:`the chat docs`}),` `,`for Codex, goose and Gemini CLI.`]})]}):(0,K.jsxs)(`div`,{className:`space-y-4`,"data-sw-settings-backend":`openai-compatible`,children:[(0,K.jsxs)(Y,{label:`Base URL`,htmlFor:`sw-agent-url`,problem:be,hint:`The chat completions endpoint without /chat/completions, such as https://api.deepseek.com or https://api.openai.com/v1.`,children:[(0,K.jsx)(A,{id:`sw-agent-url`,size:Q,value:f.baseUrl,onChange:L(`baseUrl`),placeholder:Ee(`baseUrl`,`https://api.deepseek.com`),inputMode:`url`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,disabled:o.env.baseUrl||k,"aria-invalid":be?!0:void 0,"aria-describedby":be?`sw-agent-url-problem`:void 0,"data-sw-settings-field":`baseUrl`}),o.env.baseUrl?(0,K.jsx)(X,{children:`SHAPEWALL_AGENT_BASE_URL is set in the environment and wins over this field.`}):null]}),(0,K.jsxs)(Y,{label:`Model`,htmlFor:`sw-agent-model`,children:[(0,K.jsx)(A,{id:`sw-agent-model`,size:Q,value:f.model,onChange:L(`model`),placeholder:Ee(`model`,`deepseek-chat`),spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,disabled:o.env.model||k,"data-sw-settings-field":`model`}),o.env.model?(0,K.jsx)(X,{children:`SHAPEWALL_AGENT_MODEL is set in the environment and wins over this field.`}):null]}),(0,K.jsx)(Y,{label:`API key variable`,htmlFor:`sw-agent-keyvar`,problem:H,hint:`The name of the environment variable that holds the key. Not the key itself.`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(A,{id:`sw-agent-keyvar`,size:Q,value:f.apiKeyEnv,onChange:e=>L(`apiKeyEnv`)(e.target.value.toUpperCase()),placeholder:z.apiKeyEnv||o.defaultKeyVar,spellCheck:!1,autoCapitalize:`characters`,autoComplete:`off`,disabled:k,className:`font-mono`,"aria-invalid":H?!0:void 0,"aria-describedby":H?`sw-agent-keyvar-problem`:void 0,"data-sw-settings-field":`apiKeyEnv`}),xe?null:(0,K.jsx)(ae,{tone:U?`ok`:`warn`,"data-sw-settings-key":U?`set`:`missing`,children:U?`Set`:`Not set`})]})}),(0,K.jsxs)(`div`,{className:`space-y-1`,"data-sw-settings-host":G||`none`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[(0,K.jsx)(le,{size:13,"aria-hidden":`true`}),` Where the key goes`]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:G?U?(0,K.jsxs)(K.Fragment,{children:[`Each chat request sends the key in `,(0,K.jsx)(`code`,{className:`font-mono`,children:V}),` to`,` `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,"data-sw-settings-key-host":`true`,children:G}),`, and nowhere else.`]}):xe?(0,K.jsxs)(K.Fragment,{children:[`Requests go to `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:G}),`, without a key.`]}):(0,K.jsxs)(K.Fragment,{children:[`Requests go to `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:G}),`, without a key until`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:V}),` is set.`]}):`Set a base URL to see where requests go.`})]}),xe?(0,K.jsx)(`p`,{className:`text-xs text-muted`,"data-sw-settings-key-notice":`none`,children:`No API key needed for a local server like Ollama. If yours wants one, name its variable above.`}):(0,K.jsxs)(`div`,{className:`space-y-2 rounded-md border border-line p-3`,"data-sw-settings-key-notice":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[(0,K.jsx)(W,{size:13,"aria-hidden":`true`}),` Keys stay in the environment`]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Shapewall never asks for your API key, saves it or shows it. Set it in the terminal that runs`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),`, then restart it:`]}),(0,K.jsx)(_e,{text:`export ${V}="paste-your-key-here"`,label:`shell`,touch:t}),(0,K.jsx)(_e,{text:`$env:${V} = "paste-your-key-here"`,label:`PowerShell`,touch:t})]}),f.keyHosts.length?(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-key-hosts":`true`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:`Hosts you allowed the key to go to`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.keyHosts.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-2 py-0.5 pr-0.5 pl-2 text-xs`,"data-sw-settings-key-host-item":e.host,children:[e.host,` `,(0,K.jsx)(`span`,{className:`font-mono text-faint`,children:e.apiKeyEnv}),(0,K.jsx)(n,{variant:`ghost`,size:t?`icon`:`icon-xs`,disabled:k,onClick:()=>p(t=>({...t,keyHosts:t.keyHosts.filter(t=>t!==e)})),"aria-label":`Stop sending ${e.apiKeyEnv} to ${e.host}`,children:(0,K.jsx)(g,{size:12,"aria-hidden":`true`})})]},`${e.apiKeyEnv}@${e.host}`))})]}):null]}),(0,K.jsxs)(`div`,{className:`space-y-1`,"data-sw-settings-vision":f.vision===null?`auto`:String(f.vision),children:[(0,K.jsxs)(E,{size:Q,pressed:f.vision??(!me||B.vision!==!1),disabled:k,onPressedChange:e=>{p(t=>({...t,vision:e})),S(!1)},"data-sw-settings-field":`vision`,children:[f.vision??(!me||B.vision!==!1)?(0,K.jsx)(v,{size:13,"aria-hidden":`true`}):null,`This model takes images`]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:f.vision===!1?`Images are not sent; the chat says so when one is attached.`:me&&f.vision===null?`The agent says itself whether it takes images. Test connection checks it.`:`Turn off for a text-only model (many local models): images are then left out instead of failing.`})]}),(0,K.jsx)(Y,{label:`Name in the chat panel (optional)`,htmlFor:`sw-agent-label`,children:(0,K.jsx)(A,{id:`sw-agent-label`,size:Q,value:f.label,onChange:L(`label`),placeholder:z.label||(me?`the agent’s name`:`the model name`),maxLength:40,disabled:k,"data-sw-settings-field":`label`})}),(0,K.jsxs)(`p`,{className:`text-xs text-faint`,"data-sw-settings-file":`true`,children:[`Saved for this project in `,(0,K.jsx)(`code`,{className:`font-mono break-all`,children:o.file||`your config folder`}),`, outside the repo, never in shapewall.config.json. The environment and `,(0,K.jsx)(`code`,{className:`font-mono`,children:`--agent-acp`}),` win over these settings; they win over the config.`]}),_?(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-settings-error":`save`,children:_}):null,(0,K.jsx)(ye,{result:ne}),(0,K.jsxs)(`div`,{className:l(`flex flex-wrap items-center gap-2`,t&&`flex-col-reverse items-stretch`),children:[(0,K.jsxs)(n,{size:Q,onClick:we,disabled:T||m||R,"data-sw-settings-test":`true`,children:[T?(0,K.jsx)(b,{}):(0,K.jsx)(le,{size:14,"aria-hidden":`true`}),` `,T?`Testing...`:`Test connection`]}),R?(0,K.jsx)(`span`,{className:`text-xs text-muted`,children:`Save to test these settings.`}):null,x&&!R?(0,K.jsx)(`span`,{className:`text-xs text-muted`,role:`status`,"data-sw-settings-saved":`true`,children:`Saved. Chat uses it now.`}):null,R?(0,K.jsx)(n,{size:Q,variant:`ghost`,className:l(!t&&`ml-auto`),onClick:pe,disabled:m,"data-sw-settings-discard":`true`,children:`Discard changes`}):null,(0,K.jsx)(n,{size:Q,variant:`default`,className:l(!t&&!R&&`ml-auto`),onClick:()=>Ce(null),disabled:m||!R||!!H||!!be,"data-sw-settings-save":`true`,children:m?`Saving...`:`Save`})]}),(0,K.jsx)(ve,{items:C?.items||null,keyVar:V,busy:m,touch:t,onCancel:()=>w(null),onConfirm:()=>Ce(C?.hash||null)})]})}var qe=`/console?section=agents`;function Je({view:e,touch:t}){let r=e.profiles||[],i=r.find(e=>e.default);return(0,K.jsxs)(`section`,{className:`flex flex-wrap items-center gap-3 rounded-md border border-line p-3`,"data-sw-agents-link":!0,children:[(0,K.jsx)(oe,{size:16,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-xs`,children:[(0,K.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:`Agents`}),(0,K.jsxs)(`p`,{className:`text-muted`,children:[r.length?`${r.map(e=>e.label).join(`, `)} connected${i?`. New chats and fixes use ${i.label}`:``}.`:`No agent connected yet.`,` `,`Connect, remove and choose the default on the Agents page of the Workspace Console.`]})]}),(0,K.jsx)(n,{asChild:!0,size:t?`touch`:`sm`,children:(0,K.jsx)(`a`,{href:qe,"data-sw-agents-open":!0,children:`Manage agents`})})]})}function Ye({open:e,onClose:t,onSaved:n,touch:r,buzz:i=!1}){let[a,o]=(0,J.useState)(!1);return(0,K.jsx)(d,{open:e,onClose:t,title:`Settings`,size:`md`,sticky:a,children:(0,K.jsxs)(w,{defaultValue:`agent`,className:`p-5`,children:[(0,K.jsx)(ne,{className:`mb-4 max-w-40`,"aria-label":`Settings`,children:(0,K.jsx)(re,{value:`agent`,large:r,"data-sw-settings-tab":`agent`,children:`Agent`})}),(0,K.jsx)(_,{value:`agent`,children:e?(0,K.jsx)(Ke,{onSaved:n,touch:r,buzz:i,onDirtyChange:o}):null})]})})}var Xe=`https://shapewall.com/docs/chat`,Ze=`${Xe}#restrict-the-agents-own-tools`;function Qe({onOpenSettings:e,docsUrl:t,touch:r,open:i=!1}){return(0,K.jsxs)(`details`,{className:`group rounded-md border border-line text-left`,open:i,"data-sw-chat-other-options":`true`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-1.5 px-3 text-xs font-medium text-fg lg:min-h-9 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(k,{size:13,className:`text-muted transition-transform group-open:rotate-90`,"aria-hidden":`true`}),` Other options`]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-line p-3 text-xs text-muted`,children:[(0,K.jsx)(`p`,{children:`An OpenAI-compatible endpoint (OpenAI, DeepSeek, OpenRouter, Ollama, LM Studio) or another agent command:`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,K.jsxs)(n,{size:r?`touch`:`sm`,onClick:e,"data-sw-settings-open":`connect`,children:[(0,K.jsx)(j,{size:13,"aria-hidden":`true`}),` Open agent settings`]}),(0,K.jsx)(n,{asChild:!0,variant:`ghost`,size:r?`touch`:`sm`,children:(0,K.jsxs)(`a`,{href:t||`https://shapewall.com/docs/chat`,target:`_blank`,rel:`noreferrer`,"data-sw-chat-docs":`true`,children:[(0,K.jsx)(F,{size:13,"aria-hidden":`true`}),` Chat docs`]})})]})]})]})}function $e({agent:e,touch:t,onOpenSettings:r,onConnected:i}){let[a,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(Ce()),x=(0,J.useCallback)(async()=>{try{l(await c.get(`/api/agent/settings`)),d(null)}catch(e){e.status===404&&ee(),d(e.status===404?q:e.message)}},[]);(0,J.useEffect)(()=>{x()},[x]);let S=async(e,t=null)=>{p(e.id),h(null);try{let n=t?{name:v.name.trim(),...v.icon&&!v.png?{icon:v.icon}:{},...v.tint?{tint:v.tint}:{}}:{},r=await c.post(`/api/agent/settings/profiles/connect`,{agentId:e.id,confirm:t,...n});if(r.confirm){y(Ce({label:e.label})),_({item:e,items:r.confirm,hash:r.confirmHash});return}if(_(null),r.connected&&t&&v.png&&await Q(e.id,{},{...v,name:``,tint:null}).catch(()=>null),!r.connected){h({id:e.id,result:r.result}),l(r);return}i?.(r.result)}catch(t){_(null),h({id:e.id,result:{ok:!1,message:t.message,details:[]}})}finally{p(null)}};if(u)return(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-settings-error":`load`,children:u===`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`?(0,K.jsx)(ge,{}):`Could not look for agents: ${u}`});if(!a)return(0,K.jsxs)(`p`,{className:`flex items-center justify-center gap-2 text-xs text-muted`,"data-sw-chat-detect":`loading`,children:[(0,K.jsx)(b,{size:12}),` Looking for agents on this machine`]});let C=a.detected||[],w=C.filter(e=>e.state===`ready`),T=C.filter(e=>e.state===`needs-adapter`),te=C.filter(e=>e.state===`needs-shell`),E=!!a.env?.acp,ne=t?`touch`:`sm`;return(0,K.jsxs)(`div`,{className:`w-full space-y-3 text-left`,"data-sw-chat-connect":`true`,children:[E?(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-fg`,"data-sw-chat-connect-override":`true`,children:[(0,K.jsx)(ce,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[`The agent command comes from `,a.env.acp===`flag`?`--agent-acp`:`SHAPEWALL_AGENT_ACP`,` and wins over the board. Fix it there, or restart `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),` without it.`]})]}):null,w.length?(0,K.jsx)(`ul`,{className:`space-y-2`,"aria-label":`Agents found on this machine`,children:w.map(e=>{let t=m?.id===e.id?m.result:null;return(0,K.jsxs)(`li`,{className:`space-y-2 rounded-md border border-line bg-surface-2/60 p-3`,"data-sw-chat-detected":e.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(L,{size:15,className:`shrink-0 text-ok`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm font-medium text-fg`,children:[e.label,` found on this machine`]}),(0,K.jsx)(s,{content:e.path||null,children:(0,K.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted`,children:e.command})})]}),(0,K.jsxs)(n,{variant:`default`,size:ne,onClick:()=>S(e),disabled:!!f||E||!!a.testing,title:a.testing?`A connection test is running. Connect is available when it finishes.`:void 0,"data-sw-chat-connect-agent":e.id,children:[f===e.id?(0,K.jsx)(b,{}):(0,K.jsx)(le,{size:13,"aria-hidden":`true`}),` `,f===e.id?`Connecting...`:`Connect`]})]}),t?(0,K.jsxs)(`div`,{className:`rounded-md border border-bad/40 bg-bad/10 p-2 text-xs`,role:`alert`,"data-sw-chat-connect-result":`failed`,children:[(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 font-medium text-bad`,children:[(0,K.jsx)(R,{size:13,className:`mt-px shrink-0`,"aria-hidden":`true`}),` `,t.message]}),(0,K.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Nothing was changed. `,e.login?`To log it in: ${e.login}.`:``]})]}):null]},e.id)})}):(0,K.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-chat-detected":`none`,children:[`No agent CLI with ACP found on this machine (Claude Code, Codex, goose, Gemini CLI).`,T.length?null:(0,K.jsx)(K.Fragment,{children:` For Claude Code, install its adapter in a terminal, then check again:`})]}),!w.length&&!T.length?(0,K.jsx)(_e,{text:`npm install -g @agentclientprotocol/claude-agent-acp`,label:`install`,touch:t}):null,T.map(e=>(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs text-muted`,"data-sw-chat-needs-adapter":e.id,children:[(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),` is installed, but not its ACP adapter. Install it in a terminal, then check again:`]}),e.install?(0,K.jsx)(_e,{text:e.install,label:`${e.label} install`,touch:t}):null]},e.id)),te.map(e=>(0,K.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-chat-needs-shell":e.id,children:[(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),` is installed only as a `,(0,K.jsx)(`code`,{className:`font-mono`,children:`.cmd`}),` wrapper, which needs a shell, and Shapewall never starts one. In Other options, set the agent command to`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`node`}),` and the path of its script (see the chat docs).`]},e.id)),w.length?(0,K.jsxs)(`p`,{className:`text-[11px] leading-4 text-muted`,"data-sw-chat-connect-note":`true`,children:[`Connect asks first, then runs that command on this machine, as you, with the agent’s own login. It brings its own tools (a shell, file edits), which Shapewall does not sandbox:`,` `,(0,K.jsx)(`a`,{className:`text-accent underline-offset-2 hover:underline`,href:Ze,target:`_blank`,rel:`noreferrer`,children:`use a restricted profile`}),`.`]}):null,(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)(n,{variant:`ghost`,size:t?`touch`:`xs`,onClick:x,disabled:!!f,"data-sw-chat-detect-again":`true`,children:[(0,K.jsx)(fe,{size:12,"aria-hidden":`true`}),` Check again`]})}),(0,K.jsx)(Qe,{onOpenSettings:r,docsUrl:e?.docsUrl,touch:t,open:!w.length&&!T.length}),(0,K.jsx)(ve,{items:g?.items||null,busy:!!f,touch:t,confirmLabel:`Allow and connect`,onCancel:()=>_(null),onConfirm:()=>S(g.item,g.hash),blocked:!!Oe(v.name),children:(0,K.jsx)(ke,{value:v,onChange:y,builtIn:g?.item.label||``,logo:o(g?.item.id),upload:a.iconUpload!==!1,touch:t,disabled:!!f})})]})}function et({result:e,onDismiss:t,touch:r}){return e?(0,K.jsxs)(`div`,{className:l(`rounded-md border border-ok/40 bg-ok/10 p-3 text-left text-xs`),role:`status`,"data-sw-chat-connected-note":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 font-medium text-fg`,children:[(0,K.jsx)(oe,{size:14,className:`mt-px shrink-0 text-ok`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`flex-1`,children:[`Connected to `,e.label,`. `,e.message]}),(0,K.jsx)(n,{variant:`ghost`,size:r?`icon`:`icon-xs`,onClick:t,"aria-label":`Dismiss`,className:`-mt-1 -mr-1`,children:(0,K.jsx)(g,{size:13,"aria-hidden":`true`})})]}),e.details?.length?(0,K.jsx)(`ul`,{className:`mt-1.5 list-disc space-y-0.5 pl-5 text-muted`,children:e.details.map(e=>(0,K.jsx)(`li`,{children:e},e))}):null]}):null}export{ze as a,G as c,Ke as i,W as l,Xe as n,ge as o,$e as r,q as s,et as t,z as u};
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{B as n,Cn as r,Ct as i,Dt as a,Et as o,H as s,Jt as c,Mt as l,Ot as u,Qt as ee,R as d,Sn as f,St as p,Tn as m,Tt as h,_n as g,a as _,bn as v,bt as y,c as b,ct as x,dt as S,ft as C,i as w,kt as T,lt as te,n as E,o as ne,pt as D,s as re,t as ie,tt as ae,ut as O,vn as k,w as A,xn as oe}from"./ui-2lMx-4bc.js";import{G as j,J as se,R as ce,X as le,Z as M,at as N,et as P,ft as F,h as I,k as ue,z as de}from"./index-t3fn6ogR.js";import{n as L,t as R}from"./circle-x-D5MkDLJk.js";import{t as fe}from"./refresh-cw-B-npxKae.js";var pe={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};pe.node;var z=f(pe),B={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};B.node;var me=f(B),V={name:`image-up`,size:24,node:[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};V.node;var H=f(V),U={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};U.node;var W=f(U),he={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};he.node;var G=f(he),K=r(),q=`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`;function ge(){return(0,K.jsxs)(K.Fragment,{children:[`On the computer running Shapewall, run `,(0,K.jsx)(`code`,{className:`break-words font-mono`,children:`shapewall settings --config FILE --open`}),` with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),`.`]})}var J=t(m(),1);function Y({label:e,htmlFor:t,hint:n,problem:r,children:i,...a}){return(0,K.jsxs)(`div`,{className:`space-y-1`,...a,children:[t?(0,K.jsx)(`label`,{htmlFor:t,className:`block text-xs font-medium text-fg`,children:e}):(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:e}),i,r?(0,K.jsx)(`p`,{id:t?`${t}-problem`:void 0,className:`text-xs text-bad`,role:`alert`,"data-sw-settings-problem":`true`,children:r}):n?(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:n}):null]})}function _e({text:e,label:t,touch:r}){let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!i)return;let e=window.setTimeout(()=>a(!1),1500);return()=>window.clearTimeout(e)},[i]),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-line bg-sunken pl-2`,"data-sw-settings-export":t,children:[(0,K.jsx)(`code`,{ref:c,className:`min-w-0 flex-1 overflow-x-auto py-1.5 font-mono text-[11.5px] whitespace-nowrap text-fg`,children:e}),(0,K.jsx)(n,{variant:`ghost`,size:r?`icon`:`icon-sm`,onClick:async()=>{try{await navigator.clipboard.writeText(e),s(!1),a(!0)}catch{if(c.current){let e=document.createRange();e.selectNodeContents(c.current);let t=window.getSelection();t.removeAllRanges(),t.addRange(e)}s(!0)}},"aria-label":i?`Copied`:`Copy the ${t} line`,children:i?(0,K.jsx)(v,{size:14,"aria-hidden":`true`}):(0,K.jsx)(z,{size:14,"aria-hidden":`true`})})]}),o?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted`,role:`status`,children:`This browser did not allow copying. The line is selected: press Ctrl+C (or long-press) to copy it.`}):null]})}function X({children:e}){return(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-fg`,"data-sw-settings-override":`true`,children:[(0,K.jsx)(ce,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e})]})}function ve({items:e,keyVar:t,onCancel:r,onConfirm:i,busy:a,touch:o,confirmLabel:s=`Allow and save`,children:c=null,blocked:l=!1}){let u=o?`touch`:`md`;return(0,K.jsxs)(d,{open:!!e,onClose:()=>a?null:r(),title:`Allow this?`,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:u,onClick:r,disabled:a,children:`Cancel`}),(0,K.jsx)(n,{size:u,variant:`default`,onClick:i,disabled:a||l,"data-sw-settings-confirm":`true`,children:a?`Saving...`:s})]}),children:[e?c:null,(0,K.jsx)(`div`,{className:`space-y-3 p-5 text-sm`,"data-sw-settings-confirm-list":`true`,children:(e||[]).map(e=>e.kind===`command`?(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-confirm-item":`command`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-fg`,children:[(0,K.jsx)(G,{size:14,"aria-hidden":`true`}),` Run this command on this machine, as you`]}),(0,K.jsx)(`code`,{className:`block rounded-md border border-line bg-sunken p-2 font-mono text-xs break-all text-fg`,children:e.command}),e.projectRoot?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Source folder for every board in this project:`,` `,(0,K.jsx)(`code`,{className:`font-mono break-all`,"data-sw-settings-confirm-root":!0,children:e.projectRoot})]}):null,(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Shapewall starts it for each chat thread, with your login and a small environment. Anyone who can chat on this board drives it. Only allow a command you installed yourself.`})]},`command:${e.command}`):(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-confirm-item":`host`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium text-fg`,children:[(0,K.jsx)(W,{size:14,"aria-hidden":`true`}),` Send your API key to `,e.host]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Every chat request carries the key in `,(0,K.jsx)(`code`,{className:`font-mono`,children:e.keyVar||t}),` to`,` `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:e.host}),`. Allow it only if you trust that host with the key.`]})]},`host:${e.keyVar}@${e.host}`))})]})}function ye({result:e}){if(!e)return null;if(e.note)return(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md border border-line bg-surface-2/60 p-3 text-xs text-muted`,role:`status`,"data-sw-settings-test-result":`note`,children:[(0,K.jsx)(N,{size:14,className:`mt-px shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e.note})]});let t=e.ok?L:R;return(0,K.jsxs)(`div`,{className:l(`rounded-md border p-3 text-xs`,e.ok?`border-ok/40 bg-ok/10`:`border-bad/40 bg-bad/10`),role:`status`,"data-sw-settings-test-result":e.ok?`ok`:`failed`,children:[(0,K.jsxs)(`p`,{className:l(`flex items-start gap-1.5 font-medium`,e.ok?`text-fg`:`text-bad`),children:[(0,K.jsx)(t,{size:14,className:l(`mt-px shrink-0`,e.ok?`text-ok`:`text-bad`),"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e.message})]}),e.details?.length?(0,K.jsx)(`ul`,{className:`mt-1.5 list-disc space-y-0.5 pl-5 text-muted`,children:e.details.map(e=>(0,K.jsx)(`li`,{children:e},e))}):null]})}function be(e){let t=Array.isArray(e?.profiles)?e.profiles:[],n=Array.isArray(e?.detected)?e.detected:[],r=(Array.isArray(e?.known)&&e.known.length?e.known:n).map(e=>{let r=t.find(t=>t.id===e.id),i={builtIn:e.label,logo:e.logo||null};if(r)return{kind:`connected`,id:e.id,label:r.label||e.label,profile:r,...i};let a=n.find(t=>t.id===e.id);return a?{kind:a.state===`ready`?`found`:a.state===`needs-shell`?`needs-shell`:`needs-adapter`,id:e.id,label:e.label,install:a.install||e.install||null,...i}:{kind:`missing`,id:e.id,label:e.label,...i}});for(let e of t)r.some(t=>t.id===e.id)||r.push({kind:`connected`,id:e.id,label:e.label,profile:e,builtIn:null,logo:e.logo||null});return r}async function xe(e,{maxBytes:t=5242880,maxLabel:n=`5 MB`}={}){if(!e||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type))throw Error(`Choose a PNG, JPEG or WebP image.`);if(e.size>t)throw Error(`Choose an image smaller than ${n}.`);let r;try{if(r=await createImageBitmap(e,{imageOrientation:`from-image`}),!r.width||!r.height)throw Error(`empty image`);let t=document.createElement(`canvas`);t.width=256,t.height=256;let n=t.getContext(`2d`);if(!n)throw Error(`no canvas`);let i=Math.min(r.width,r.height);return n.drawImage(r,(r.width-i)/2,(r.height-i)/2,i,i,0,0,256,256),t.toDataURL(`image/png`).split(`,`)[1]}catch{throw Error(`This image could not be read. Try another PNG, JPEG or WebP image.`)}finally{r?.close()}}var Se=2097152,Z=`upload:pending`,Ce=(e={})=>({name:e.label||``,icon:e.icon||null,tint:e.tint||null,png:null});function we(e,t){let n={};return t.name.trim()!==(e.label||``)&&(n.name=t.name.trim()),t.icon!==Z&&t.icon!==(e.icon||null)&&(n.icon=t.icon),t.tint!==(e.tint||null)&&(n.tint=t.tint),Object.keys(n).length?n:null}async function Q(e,t,n){let r=null,i=we(t,n);return i&&(r=await c.post(`/api/agent/settings/identity`,{id:e,...i})),n.icon===Z&&n.png&&(r=await c.post(`/api/agent/settings/identity/icon`,{id:e,png:n.png})),r}function Te({name:e,checked:t,onChange:n,label:r,children:i,className:a,...o}){return(0,K.jsxs)(`label`,{className:l(`relative inline-flex h-11 w-11 cursor-pointer items-center justify-center rounded-xl border-2 border-transparent`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-1 has-[:focus-visible]:outline-accent`,t?`border-accent bg-accent/10`:`hover:border-line-strong`,a),title:r,...o,children:[(0,K.jsx)(`input`,{type:`radio`,name:e,className:`sr-only`,checked:t,onChange:n,"aria-label":r}),i]})}function Ee({value:e,onChange:t,label:r,logo:i=null,upload:o=!0,disabled:s=!1}){let c=(0,J.useId)(),l=(0,J.useRef)(null),[u,ee]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),p=h(i),m=e.png?`data:image/png;base64,${e.png}`:null,g=e.icon===Z||T(e.icon),_=!g&&(e.icon||!p),v=async n=>{if(n){ee(!0),f(``);try{let r=await xe(n,{maxBytes:Se,maxLabel:`2 MB`});t({...e,icon:Z,png:r})}catch(e){f(e.message||`This image could not be read.`)}finally{ee(!1),l.current&&(l.current.value=``)}}},y=n=>t({...e,icon:n,png:null});return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,id:`${c}-icons`,children:`Icon`}),(0,K.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-icons`,className:`flex flex-wrap gap-1`,"data-sw-agent-icon-options":!0,children:[(0,K.jsx)(Te,{name:`${c}-icon`,checked:!e.icon,onChange:()=>y(null),label:p?`Default: the ${p.name} mark`:`Default: initials`,"data-sw-agent-icon-option":`default`,children:(0,K.jsx)(x,{label:r,logo:i,tint:e.tint,size:`lg`,className:`h-9 w-9`})}),O.map(t=>(0,K.jsx)(Te,{name:`${c}-icon`,checked:e.icon===t,onChange:()=>y(t),label:te[t].name,"data-sw-agent-icon-option":t,children:(0,K.jsx)(x,{label:r,icon:t,tint:e.tint,size:`lg`,className:`h-9 w-9`})},t)),g?(0,K.jsx)(Te,{name:`${c}-icon`,checked:!0,onChange:()=>{},label:`Your picture`,"data-sw-agent-icon-option":`upload`,children:(0,K.jsx)(x,{label:r,icon:e.icon===Z?null:e.icon,src:m,size:`lg`,className:`h-9 w-9`})}):null]}),o?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:[(0,K.jsxs)(n,{size:`touch`,className:`lg:h-8`,disabled:u||s,onClick:()=>l.current?.click(),children:[u?(0,K.jsx)(b,{}):(0,K.jsx)(H,{size:14,"aria-hidden":`true`}),` Upload a picture`]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`PNG, JPEG or WebP, up to 2 MB. Cropped to a square.`}),(0,K.jsx)(`input`,{ref:l,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`hidden`,"aria-label":`Choose a picture for the icon`,onChange:e=>void v(e.target.files?.[0]),"data-sw-agent-icon-upload":!0})]}):null,d?(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-agent-icon-problem":!0,children:d}):null]}),_?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,id:`${c}-tints`,children:`Colour`}),(0,K.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-tints`,className:`flex flex-wrap gap-1`,"data-sw-agent-tint-options":!0,children:[(0,K.jsx)(Te,{name:`${c}-tint`,checked:!e.tint,onChange:()=>t({...e,tint:null}),label:`Default colour`,"data-sw-agent-tint-option":`default`,children:(0,K.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full border border-line bg-surface-2 text-muted`,children:(0,K.jsx)(se,{size:13,"aria-hidden":`true`})})}),a.map(n=>(0,K.jsx)(Te,{name:`${c}-tint`,checked:e.tint===n,onChange:()=>t({...e,tint:n}),label:S[n],"data-sw-agent-tint-option":n,children:(0,K.jsx)(`span`,{className:`h-7 w-7 rounded-full`,style:{background:D(n)}})},n))]})]}):null]})}function De({value:e,onChange:t,builtIn:n=``,touch:r=!1,id:i,problem:a=null,disabled:o=!1,hint:s=null}){return(0,K.jsx)(Y,{label:`Name`,htmlFor:i,problem:a,hint:s||(n?`Shown in chats, on its replies and on Fix buttons. Leave it empty for "${n}".`:`Shown in chats, on its replies and on Fix buttons.`),children:(0,K.jsx)(A,{id:i,size:r?`touch`:`sm`,value:e.name,onChange:n=>t({...e,name:n.target.value}),placeholder:n||`Agent`,maxLength:40,autoComplete:`off`,spellCheck:!1,disabled:o,"aria-invalid":a?`true`:void 0,"aria-describedby":a?`${i}-problem`:void 0,"data-sw-agent-name-input":!0})})}function Oe(e){let{problem:t}=u(e);return t?/control/.test(t)?`One line of plain text, without control characters.`:`At most 40 characters.`:null}function ke({value:e,onChange:t,builtIn:n,logo:r=null,upload:i=!0,touch:a=!1,disabled:o=!1}){let s=(0,J.useId)();return(0,K.jsxs)(`div`,{className:`space-y-3 border-b border-line px-5 pt-5 pb-4`,"data-sw-connect-identity":!0,children:[(0,K.jsx)(De,{id:`${s}-name`,value:e,onChange:t,builtIn:n,touch:a,problem:Oe(e.name),disabled:o}),(0,K.jsxs)(`details`,{className:`group`,"data-sw-connect-icon":!0,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2 text-xs font-medium text-fg lg:min-h-8 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(k,{size:13,className:`text-muted transition-transform group-open:rotate-90`,"aria-hidden":`true`}),(0,K.jsx)(x,{label:e.name||n,icon:e.icon===Z?null:e.icon,tint:e.tint,logo:r,size:`sm`,src:e.png?`data:image/png;base64,${e.png}`:null}),`Icon (optional)`]}),(0,K.jsx)(`div`,{className:`pt-2`,children:(0,K.jsx)(Ee,{value:e,onChange:t,label:e.name||n,logo:r,upload:i,disabled:o})})]})]})}function Ae({agent:e,upload:t=!0,touch:r=!1,waiting:i=!1,onClose:a,onSaved:o}){let s=(0,J.useId)(),[c,l]=(0,J.useState)(Ce()),[u,ee]=(0,J.useState)(!1),[f,p]=(0,J.useState)(``),m=(0,J.useRef)(null);(0,J.useEffect)(()=>{e&&(m.current=e.id,l(Ce(e)),p(``))},[e]);let h=r?`touch`:`md`,g=Oe(c.name),_=e&&!e.builtIn&&!c.name.trim()?`Give it a name.`:null,v=e?!!we(e,c)||!!c.png:!1,y=async()=>{ee(!0),p(``);try{let t=await Q(e.id,e,c);await o?.(t),a()}catch(e){p(e.message||`It could not be saved.`)}finally{ee(!1)}},b=c.png?`data:image/png;base64,${c.png}`:null;return(0,K.jsx)(d,{open:!!e,onClose:()=>u?null:a(),title:`Name and icon`,description:`How this agent shows on the board. It keeps running; nothing is restarted.`,wrapDescription:!0,size:`md`,onCloseAutoFocus:e=>{let t=document.querySelector(`[data-sw-agent-edit="${CSS.escape(m.current||``)}"]`);t&&(e.preventDefault(),t.focus())},footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{size:h,onClick:a,disabled:u,children:`Cancel`}),(0,K.jsx)(n,{size:h,variant:`default`,onClick:y,disabled:u||!v||!!(g||_),"data-sw-agent-identity-save":!0,children:u?i?`Saving when the connection test finishes...`:`Saving...`:`Save`})]}),children:(0,K.jsxs)(`form`,{className:`space-y-4 p-5`,onSubmit:e=>{e.preventDefault(),!u&&v&&!g&&!_&&y()},"data-sw-agent-identity":e?.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(x,{label:c.name||e?.builtIn||e?.label,icon:c.icon===Z?null:c.icon,tint:c.tint,logo:e?.logo,src:b,size:`xl`,"data-sw-agent-identity-preview":!0}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(De,{id:`${s}-name`,value:c,onChange:l,builtIn:e?.builtIn||``,touch:r,problem:g||_,disabled:u})})]}),(0,K.jsx)(Ee,{value:c,onChange:l,label:c.name||e?.builtIn||e?.label,logo:e?.logo,upload:t,disabled:u}),i&&!f?(0,K.jsx)(`p`,{className:`text-xs text-muted`,role:`status`,"data-sw-agent-identity-waiting":!0,children:`Its connection test is still running. Save waits for it to finish, then saves.`}):null,f?(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-agent-identity-error":!0,children:f}):null,(0,K.jsx)(`button`,{type:`submit`,className:`hidden`,tabIndex:-1,"aria-hidden":`true`})]})})}var je={claude:{text:`Install Claude Code and its adapter, then check again.`,anchor:`claude-code`},codex:{text:`Install Codex and its adapter, then check again.`,anchor:`codex`},goose:{text:`Install goose from its install guide, then check again.`,anchor:`goose`},gemini:{text:`Install Gemini CLI, then check again.`,anchor:`gemini-cli`}},Me=`In the demo nothing runs on a computer. On your install this looks for the agent again.`,Ne={connected:`Connected`,found:`Found, not connected`,"needs-adapter":`Found, but its adapter is missing`,"needs-shell":`Found, but only as a .cmd wrapper`,missing:`Not installed`};function Pe({title:e,description:t,children:n,...r}){return(0,K.jsxs)(`section`,{className:`space-y-2.5`,...r,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e}),t?(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t}):null]}),n]})}function Fe({view:e=null,disabled:t=!1,touch:r=!1,onBusy:a=null,onChanged:o=null,endpointForm:s=null,onOpenEndpoint:u=null,agent:f=null}){let[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),[te,E]=(0,J.useState)({}),[ne,D]=(0,J.useState)(!1),[re,ie]=(0,J.useState)(null),[O,k]=(0,J.useState)(Ce());(0,J.useEffect)(()=>a?.(!!x),[x,a]);let A=(0,J.useCallback)(async()=>{if(f&&!f.settingsEditable)_(f.settingsReadonly?`Change agents on the computer running Shapewall.`:`owner`),y(f);else try{let e=await c.get(`/api/agent/settings`);if(e.editable===!1){_(e.message||`owner`),y(await c.get(`/api/agent/status`).catch(()=>null));return}h(e),_(null)}catch(e){e.status===404&&ee(),_(e.status===404?`owner`:e.message),y(await c.get(`/api/agent/status`).catch(()=>null))}},[f]);(0,J.useEffect)(()=>{e||A()},[e,A]),ue(()=>{x||A()},!e);let j=e||m,se=!!j?.testing;(0,J.useEffect)(()=>{if(!se||e||x)return;let t=window.setInterval(A,1500);return()=>window.clearInterval(t)},[se,e,x,A]);let N=async t=>{t&&!e?h(t):e||await A(),await o?.()},P=(e,t)=>t?.demoNote?(T(null),E(n=>({...n,[e]:{note:t.demoNote}})),!0):!1,L=async(e,t=null)=>{S(e),E(t=>({...t,[e]:null}));try{let n=t?{name:O.name.trim(),...O.icon&&!O.png?{icon:O.icon}:{},...O.tint?{tint:O.tint}:{}}:{},r=await c.post(`/api/agent/settings/profiles/connect`,{agentId:e,confirm:t,...n});if(P(e,r))return;if(r.confirm){k(Ce({label:H.find(t=>t.id===e)?.label||``})),T({agentId:e,items:r.confirm,hash:r.confirmHash});return}if(T(null),r.connected&&t&&O.png){let t=await Q(e,{},{...O,name:``,tint:null}).catch(()=>null);t&&(r={...r,...t})}E(t=>({...t,[e]:r.result})),r.connected&&await N(r)}catch(t){T(null),E(n=>({...n,[e]:{ok:!1,message:t.message,details:[]}}))}finally{S(null)}},R=async e=>{S(e);try{let t=await c.delete(`/api/agent/settings/profiles/${encodeURIComponent(e)}`);if(P(e,t))return;await N(t),E(t=>({...t,[e]:null}))}catch(t){E(n=>({...n,[e]:{ok:!1,message:t.message,details:[]}}))}finally{S(null)}},pe=async(t,n=!1)=>{S(t),E(e=>({...e,[t]:null}));try{let r=await c.post(`/api/agent/settings/test`,n?{}:{profileId:t});if(P(t,r))return;E(e=>({...e,[t]:r})),e||await A()}catch(e){E(n=>({...n,[t]:{ok:!1,message:e.message,details:[]}}))}finally{S(null)}},z=async e=>{S(`default:${e}`);try{let t=await c.post(`/api/agent/settings/profiles/${encodeURIComponent(e)}/default`,{});if(P(`default`,t))return;await N(t)}catch(e){E(t=>({...t,default:{ok:!1,message:e.message,details:[]}}))}finally{S(null)}},B=r?`touch`:`sm`;if(g)return(0,K.jsx)(Ie,{locked:g,status:v});if(!j)return(0,K.jsxs)(`p`,{className:`flex items-center gap-2 p-1 text-sm text-muted`,"data-sw-agents-card":`loading`,children:[(0,K.jsx)(b,{}),` Looking for agents on this machine`]});let V=!!j.env?.acp,H=be(j),U=[...H.filter(e=>e.kind===`connected`).map(e=>({id:e.id,label:e.label,state:e.profile.state,isDefault:e.profile.default,...C(e.profile),logo:e.logo})),...j.endpoint?[{id:`endpoint`,label:j.endpoint.label,state:j.endpoint.state,isDefault:j.endpoint.default,...C(j.endpoint)}]:[]],W=j.testing||null,he=W?H.find(e=>e.id===W.id)?.label||j.effective?.label||`the agent`:null,G=W?`Testing the connection to ${he}. This is available when the test finishes.`:void 0,q=!!x||t||V||!!W,ge=!!x||t,Y=w?H.find(e=>e.id===w.agentId):null,X=V&&j.effective?.configured?{id:`default`,label:j.effective.label,...C(j.effective)}:null;return(0,K.jsxs)(`div`,{className:`space-y-6`,"data-sw-agents-card":j.demo?`demo`:`editable`,"data-sw-native-profiles":!0,children:[j.demo?(0,K.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-line bg-surface-2/60 px-3 py-2.5 text-xs text-muted`,role:`note`,"data-sw-agents-demo-note":!0,children:[(0,K.jsx)(oe,{size:14,className:`mt-px shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:`This is a demo with sample agents on a pretend computer. The two scripted agents answer in this browser, and nothing is sent anywhere. Choosing the default, testing, removing and connecting them works here; Reset puts everything back.`})]}):null,W&&!x?(0,K.jsxs)(`p`,{className:`flex items-center gap-2 rounded-md border border-line bg-surface-2/60 px-3 py-2.5 text-xs text-fg`,role:`status`,"data-sw-agents-testing":W.id,children:[(0,K.jsx)(b,{size:12}),(0,K.jsxs)(`span`,{children:[`Testing the connection to `,he,`. Connect, Test connection, Remove and the default wait for it; a name or an icon can be changed meanwhile.`]})]}):null,V?(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-fg`,"data-sw-agents-override":!0,children:[(0,K.jsx)(ce,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[`The agent command comes from `,j.env.acp===`flag`?`--agent-acp`:`SHAPEWALL_AGENT_ACP`,`, which wins over these settings. Change it there, or restart `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),` without it.`]})]}):null,U.length?(0,K.jsxs)(Pe,{title:`Default agent for new chats and fixes`,description:`Chats that chose another agent keep theirs.`,children:[(0,K.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default agent for new chats and fixes`,className:`grid gap-1.5`,"data-sw-agents-default":!0,children:U.map(e=>(0,K.jsxs)(`label`,{className:l(`flex min-h-11 cursor-pointer items-center gap-2.5 rounded-md border px-3 py-2 text-sm lg:min-h-10`,e.isDefault?`border-accent/50 bg-accent/10`:`border-line bg-surface hover:bg-surface-2`,q&&`cursor-default opacity-70`),title:G,"data-sw-agents-default-option":e.id,children:[(0,K.jsx)(`input`,{type:`radio`,name:`sw-default-agent`,className:`h-4 w-4 shrink-0 accent-[var(--color-accent)]`,checked:!!e.isDefault,disabled:q,onChange:()=>z(e.id)}),e.id===`endpoint`&&!e.icon&&!e.tint?(0,K.jsx)(me,{size:16,className:`shrink-0 text-muted`,"aria-hidden":`true`}):(0,K.jsx)(I,{label:e.label,state:e.state,size:`sm`,icon:e.icon,tint:e.tint,logo:e.logo}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:e.label}),x===`default:${e.id}`?(0,K.jsx)(b,{size:12}):null,e.isDefault?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]},e.id))}),te.default?(0,K.jsx)(ye,{result:te.default}):null]}):null,(0,K.jsx)(Pe,{title:`Agents on this machine`,description:`Shapewall looks for these on this computer's PATH. It never installs or downloads anything.`,children:(0,K.jsxs)(`ul`,{className:`divide-y divide-line rounded-md border border-line`,"aria-label":`Agents on this machine`,children:[X?(0,K.jsx)(`li`,{className:`p-3`,"data-sw-agent-row":`default`,"data-sw-agent-row-state":`fixed`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,K.jsx)(I,{label:X.label,state:j.effective.problem?`unavailable`:`ready`,...C(X)}),(0,K.jsxs)(`div`,{className:`min-w-[10rem] flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[X.label,` `,(0,K.jsx)(ae,{tone:`accent`,children:`Default`})]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Started from `,j.env.acp===`flag`?`--agent-acp`:`SHAPEWALL_AGENT_ACP`]})]}),(0,K.jsxs)(n,{size:B,disabled:ge,onClick:()=>ie({...X,builtIn:j.effective.builtInLabel||X.label}),"aria-label":`Edit ${X.label}: name and icon`,"data-sw-agent-edit":`default`,children:[(0,K.jsx)(M,{size:13,"aria-hidden":`true`}),` Edit`]})]})}):null,H.map(e=>(0,K.jsxs)(`li`,{className:`space-y-2 p-3`,"data-sw-agent-row":e.id,"data-sw-agent-row-state":e.kind,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,K.jsx)(I,{label:e.label,state:e.kind===`connected`?e.profile.state:`unavailable`,...C(e.profile),logo:e.logo}),(0,K.jsxs)(`div`,{className:`min-w-[10rem] flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[e.label,e.profile?.default?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]}),(0,K.jsx)(`p`,{className:l(`text-xs`,e.kind===`connected`&&e.profile.state===`login`?`text-fg`:`text-muted`),children:e.kind===`connected`?e.profile.state===`testing`?`Connecting. Testing the connection...`:`Connected. ${i(e.profile)}`:Ne[e.kind]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.kind===`connected`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(n,{size:B,disabled:q,title:G,onClick:()=>pe(e.id,e.profile.legacy),"data-sw-agent-test":e.id,children:[x===e.id?(0,K.jsx)(b,{}):null,` Test connection`]}),(0,K.jsxs)(n,{size:B,disabled:ge,onClick:()=>ie({id:e.id,label:e.label,...C(e.profile),logo:e.logo,builtIn:e.builtIn}),"aria-label":`Edit ${e.label}: name and icon`,"data-sw-agent-edit":e.id,children:[(0,K.jsx)(M,{size:13,"aria-hidden":`true`}),` Edit`]}),(0,K.jsxs)(n,{size:B,variant:`danger`,disabled:q,title:G,onClick:()=>R(e.id),"data-sw-agent-remove":e.id,children:[(0,K.jsx)(de,{size:13,"aria-hidden":`true`}),` Remove`]})]}):e.kind===`found`?(0,K.jsxs)(n,{size:B,variant:`default`,disabled:q,title:G,onClick:()=>L(e.id),"data-sw-profile-connect":e.id,"data-sw-agent-connect-row":e.id,children:[x===e.id?(0,K.jsx)(b,{}):(0,K.jsx)(le,{size:13,"aria-hidden":`true`}),` `,x===e.id?`Connecting...`:`Connect`]}):e.kind===`needs-adapter`||e.kind===`missing`?(0,K.jsxs)(n,{size:B,variant:`ghost`,disabled:!!x,onClick:()=>j.demo?P(e.id,{demoNote:Me}):N(),"data-sw-agent-check":e.id,children:[(0,K.jsx)(fe,{size:13,"aria-hidden":`true`}),` Check again`]}):null})]}),e.kind===`connected`&&e.profile.state===`login`&&e.profile.loginHint?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-agent-sign-in":e.id,children:[p(e.profile.loginHint),`, then test again.`]}):null,e.kind===`needs-adapter`&&e.install?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Install its adapter in a terminal, then check again:`}),(0,K.jsx)(_e,{text:e.install,label:`${e.label} install`,touch:r})]}):null,e.kind===`needs-shell`?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`It needs a shell, which Shapewall never starts. Under Other, set the agent command to`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`node`}),` and the path of its script (see the docs).`]}):null,e.kind===`missing`?(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[je[e.id]?.text||`Install it, then check again.`,` `,(0,K.jsxs)(`a`,{className:`inline-flex items-center gap-0.5 text-accent underline-offset-2 hover:underline`,href:`${Xe}#${je[e.id]?.anchor||`connect-an-agent-cli-over-acp`}`,target:`_blank`,rel:`noreferrer`,children:[`How to set it up `,(0,K.jsx)(F,{size:11,"aria-hidden":`true`})]})]}):null,(0,K.jsx)(ye,{result:te[e.id]})]},e.id)),(0,K.jsxs)(`li`,{className:`space-y-2 p-3`,"data-sw-agent-row":`endpoint`,"data-sw-agent-row-state":j.endpoint?`connected`:`none`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[j.endpoint?.icon||j.endpoint?.tint?(0,K.jsx)(I,{label:j.endpoint.label,state:j.endpoint.state||`ready`,...C(j.endpoint)}):(0,K.jsx)(`span`,{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-line bg-surface-2 text-muted`,children:(0,K.jsx)(me,{size:14,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`min-w-[10rem] flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[`Other`,j.endpoint?.default?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:j.endpoint?`${j.endpoint.label}${j.endpoint.host?` at ${j.endpoint.host}`:``}`:`An OpenAI-compatible endpoint: OpenAI, DeepSeek, OpenRouter, Ollama, LM Studio.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[j.endpoint?.default?(0,K.jsxs)(n,{size:B,disabled:q,onClick:()=>pe(`endpoint`,!0),"data-sw-agent-test":`endpoint`,children:[x===`endpoint`?(0,K.jsx)(b,{}):null,` Test connection`]}):null,j.endpoint?(0,K.jsxs)(n,{size:B,disabled:ge,onClick:()=>ie({id:`endpoint`,label:j.endpoint.label,...C(j.endpoint),builtIn:j.endpoint.model}),"aria-label":`Name and icon of ${j.endpoint.label}`,"data-sw-agent-edit":`endpoint`,children:[(0,K.jsx)(M,{size:13,"aria-hidden":`true`}),` Name and icon`]}):null,s||u?(0,K.jsx)(n,{size:B,disabled:!!x||t,onClick:()=>u?u():D(!0),"data-sw-agent-endpoint":!0,children:j.endpoint?`Edit`:`Set up`}):null]})]}),(0,K.jsx)(ye,{result:te.endpoint})]})]})}),(0,K.jsx)(ve,{items:w?.items||null,keyVar:``,busy:!!x,touch:r,onCancel:()=>T(null),onConfirm:()=>L(w.agentId,w.hash),confirmLabel:`Allow and connect`,blocked:!!Oe(O.name),children:(0,K.jsx)(ke,{value:O,onChange:k,builtIn:Y?.builtIn||Y?.label||``,logo:Y?.logo,upload:j.iconUpload!==!1,touch:r,disabled:!!x})}),(0,K.jsx)(Ae,{agent:re,waiting:!!(W&&re&&(W.id===re.id||re.id==="default"&&W.id==="default")),upload:j.iconUpload!==!1,touch:r,onClose:()=>ie(null),onSaved:e=>e?N(e):null}),s?(0,K.jsx)(d,{open:ne,onClose:()=>{D(!1),N()},title:`Other agent settings`,size:`md`,children:(0,K.jsx)(`div`,{className:`p-5`,children:ne?s({onSaved:()=>N()}):null})}):null]})}function Ie({locked:e,status:t}){let{options:n}=y({profileId:`default`,profiles:t?.profiles||[]}),r=n.length?n:t?.configured?[{id:`default`,label:t.label||`Agent`,state:t.state||`ready`,isDefault:!0,configured:!0,...C(t)}]:[];return(0,K.jsxs)(`div`,{className:`space-y-3`,"data-sw-agents-card":`readonly`,children:[(0,K.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-line bg-surface-2/60 px-3 py-2.5 text-xs text-muted`,role:`note`,children:[(0,K.jsx)(P,{size:14,className:`mt-px shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:e===`owner`?`To change agents, open the owner link that shapewall serve prints in your terminal (or run shapewall serve --open).`:e})]}),r.length?(0,K.jsx)(`ul`,{className:`divide-y divide-line rounded-md border border-line`,"aria-label":`Connected agents`,children:r.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 p-3`,"data-sw-agent-row":e.id,"data-sw-agent-row-state":`connected`,children:[(0,K.jsx)(I,{label:e.label,state:e.state,icon:e.icon,tint:e.tint,logo:e.logo}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5 text-sm font-medium text-fg`,children:[e.label,e.isDefault?(0,K.jsx)(ae,{tone:`accent`,children:`Default`}):null]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:i(e)})]})]},e.id))}):(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`No agent is connected.`})]})}function $(e){let t=e?.saved||{},n=t.backend===`acp`&&t.acpCommand?(t.profiles||[]).find(e=>e.acpCommand===t.acpCommand):null;return{backend:t.backend||e?.effective?.backend||`openai-compatible`,baseUrl:t.baseUrl||``,model:t.model||``,apiKeyEnv:t.apiKeyEnv||``,label:n?.label||t.label||``,acpCommand:t.acpCommand||``,keyHosts:t.keyHosts||[],vision:typeof t.vision==`boolean`?t.vision:null}}function Le(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Re({view:e,form:t,next:n}){let r=e?!Le(t,$(e)):!1,i=$(n);return r?{view:n,form:t,stale:!Le($(e),i)&&!Le(t,i)}:{view:n,form:i,stale:!1}}var ze=e({SettingsDialog:()=>Ye}),Be=/^(SHAPEWALL_AGENT_[A-Z0-9_]+|[A-Z][A-Z0-9_]*_API_KEY)$/,Ve=new Set([`GITHUB_TOKEN`,`GH_TOKEN`,`SHAPEWALL_GITHUB_TOKEN`,`SHAPEWALL_GITHUB_WEBHOOK_SECRET`,`SHAPEWALL_WEBHOOK_SECRET`,`RESEND_API_KEY`,`SHAPEWALL_AGENT_BASE_URL`,`SHAPEWALL_AGENT_MODEL`,`SHAPEWALL_AGENT_KEY_HOSTS`]),He=[{id:`openai-compatible`,label:`OpenAI-compatible`},{id:`acp`,label:`ACP agent`}],Ue=[{label:`Claude Code`,command:`claude-agent-acp`},{label:`Codex`,command:`codex-acp`},{label:`goose`,command:`goose acp --with-builtin developer`},{label:`Gemini CLI`,command:`gemini --acp`}];function We(e){return e&&(!Be.test(e)||Ve.has(e))?`Use SHAPEWALL_AGENT_API_KEY or a name ending in _API_KEY (never another tool’s token).`:null}function Ge(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.host.toLowerCase():null}catch{return null}}function Ke({onSaved:e,touch:t,buzz:r=!1,onDirtyChange:i,agents:a=`inline`}){let[o,s]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)($(null)),[m,h]=(0,J.useState)(!1),[_,y]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[T,te]=(0,J.useState)(!1),[ne,D]=(0,J.useState)(null),[re,O]=(0,J.useState)(!1),k=m||re,[j,se]=(0,J.useState)(!1),M=(0,J.useRef)(0),N=(0,J.useRef)(0),P=(0,J.useRef)(!1),F=(0,J.useRef)({view:null,form:null}),I=(0,J.useRef)(null),de=(0,J.useCallback)(async()=>{let e=++M.current;N.current+=1;try{let t=await c.get(`/api/agent/settings`);if(e!==M.current)return;s(t),p($(t)),se(!1),d(null),F.current={view:t,form:$(t)}}catch(t){if(e!==M.current)return;t.status===404&&ee(),d(t.status===404?q:t.message)}finally{--N.current,!N.current&&P.current&&(P.current=!1,I.current?.())}},[]);(0,J.useEffect)(()=>{de()},[de]),I.current=async()=>{if(k||!F.current.view||u)return;if(N.current){P.current=!0;return}let e=M.current,t;try{t=await c.get(`/api/agent/settings`)}catch{return}if(e!==M.current||N.current||!F.current.view)return;let n=Re({view:F.current.view,form:F.current.form,next:t});s(n.view),p(n.form),n.stale&&se(!0)},ue(()=>I.current?.());let L=e=>t=>{let n=typeof t==`string`?t:t.target.value;p(t=>({...t,[e]:n})),S(!1)};F.current={view:o,form:f};let R=o?!Le(f,$(o)):!1;(0,J.useEffect)(()=>{R||se(!1)},[R]),(0,J.useEffect)(()=>(i?.(R),()=>i?.(!1)),[R,i]);let pe=()=>{p($(o)),y(null),S(!1)},z=o?.config||{},B=o?.effective||{},me=f.backend===`acp`,V=f.apiKeyEnv.trim()||z.apiKeyEnv||o?.defaultKeyVar||`SHAPEWALL_AGENT_API_KEY`,H=We(f.apiKeyEnv.trim()),U=!!o?.keyVarsSet?.includes(V),he=o?.env?.baseUrl?B.baseUrl:f.baseUrl.trim()||z.baseUrl||``,G=Ge(he),be=f.baseUrl.trim()&&!Ge(f.baseUrl.trim())?`An http(s) URL, such as https://api.deepseek.com`:null,xe=!U&&!f.apiKeyEnv.trim()&&!z.apiKeyEnv&&/^http:/i.test(he),Se=!!o?.env?.acp,Z=(0,J.useMemo)(()=>({backend:f.backend,baseUrl:f.baseUrl.trim()||null,model:f.model.trim()||null,apiKeyEnv:f.apiKeyEnv.trim()||null,label:f.label.trim()||null,acpCommand:f.acpCommand.trim()||null,keyHosts:f.keyHosts,vision:f.vision}),[f]),Ce=async(t=null)=>{h(!0),y(null);try{let n=await c.post(`/api/agent/settings`,{settings:Z,confirm:t});if(n.demoNote){w(null),D({note:n.demoNote});return}if(n.confirm){w({items:n.confirm,hash:n.confirmHash});return}M.current+=1,s(n),p($(n)),w(null),S(!0),D(null),e?.()}catch(e){w(null),y(e.message)}finally{h(!1)}},we=async()=>{te(!0),D(null);try{let e=await c.post(`/api/agent/settings/test`,{});D(e),typeof e.vision==`boolean`&&e.vision!==(f.vision??!0)&&p(t=>({...t,vision:e.vision}))}catch(e){D({ok:!1,message:e.message,details:[]})}finally{te(!1)}};if(u)return(0,K.jsxs)(`div`,{className:`space-y-3 p-5`,"data-sw-settings-error":`load`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:u===`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`?(0,K.jsx)(ge,{}):`Could not load the agent settings: ${u}`}),u===`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`?null:(0,K.jsx)(n,{size:t?`touch`:`sm`,onClick:()=>{d(null),de()},children:`Try again`})]});if(!o)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-5 text-sm text-muted`,children:[(0,K.jsx)(b,{}),` Loading`]});if(o.editable===!1)return(0,K.jsxs)(`div`,{className:`space-y-3 p-5`,"data-sw-settings-readonly":!0,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted`,children:o.message}),(0,K.jsx)(`dl`,{className:`space-y-2 text-sm text-fg`,children:[[`Agent`,B.label],[`Backend`,B.backend],[`Command`,B.acpCommand],[`Model`,B.model],[`Endpoint`,B.baseUrl],[`Key variable`,B.keyVar]].filter(([,e])=>e).map(([e,t])=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted`,children:e}),(0,K.jsx)(`dd`,{className:`break-all`,children:t})]},e))})]});let Q=t?`touch`:`sm`,Te=e=>B.sources?.[e]===`config`?`from shapewall.config.json`:null,Ee=(e,t)=>z[e]?`${z[e]} (${Te(e)||`from the config`})`:t;return(0,K.jsxs)(`div`,{className:`space-y-5`,"data-sw-settings":`agent`,children:[a===`inline`?(0,K.jsxs)(`section`,{className:`space-y-3 rounded-md border border-line p-3`,"aria-labelledby":`sw-agents-inline`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{id:`sw-agents-inline`,className:`text-sm font-semibold text-fg`,children:`Agents`}),(0,K.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted`,children:[`Connect several agents, then choose one per chat. Each runs its own session with its own login on this computer.`,r?` Buzz conversations are separate.`:``]})]}),(0,K.jsx)(Fe,{view:o,disabled:R||m||T,touch:t,onBusy:O,onChanged:async()=>{await de(),e?.()}}),R?(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:`Save or discard your changes below before changing agents.`}):null]}):a===`link`?(0,K.jsx)(Je,{view:o,touch:t}):null,o.project?.root?(0,K.jsxs)(`section`,{className:`space-y-1.5 rounded-md border border-line p-3 text-xs`,"data-sw-agent-project":!0,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-fg`,children:`Source folder on the Shapewall computer`}),(0,K.jsx)(`code`,{className:`block font-mono break-all text-fg`,"data-sw-agent-project-root":!0,children:o.project.root}),(0,K.jsx)(`p`,{className:`text-muted`,children:`Native agents work in this folder for every board in this project. Capturing a website does not give access to its source. To work on another repository, serve a separate project from that checkout on the computer with your agent login.`})]}):null,j?(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-line p-2.5 text-xs`,role:`status`,"data-sw-settings-stale":!0,children:[(0,K.jsx)(fe,{size:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:`Agent settings changed elsewhere. Reload to see them.`}),(0,K.jsx)(n,{size:t?`touch`:`xs`,variant:`secondary`,onClick:de,"data-sw-settings-stale-reload":!0,children:`Reload`})]}):null,(0,K.jsxs)(`section`,{className:`flex items-start gap-3 rounded-md border border-line bg-surface-2/60 p-3 text-xs`,"data-sw-settings-status":B.configured?`connected`:`not-connected`,children:[(0,K.jsx)(oe,{size:16,className:`mt-px shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,K.jsx)(`p`,{className:`font-medium text-fg`,children:B.configured?(0,K.jsxs)(K.Fragment,{children:[`Chat uses `,B.label||`the agent`,B.backend===`acp`?` over ACP, on this machine`:B.host?` at ${B.host}`:``]}):`Chat is not connected yet`}),B.problem?(0,K.jsx)(`p`,{className:`text-bad`,children:B.problem}):null]}),(0,K.jsx)(ae,{tone:B.configured?`ok`:`warn`,children:B.configured?B.backend===`acp`?`Command set`:`Connected`:`Not connected`})]}),Se?(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-acp-override":o.env.acp,children:[(0,K.jsxs)(X,{children:[`The agent command comes from`,` `,o.env.acp===`flag`?`the --agent-acp option on the command line`:`SHAPEWALL_AGENT_ACP in the environment`,` and wins over these settings until Shapewall is started without it.`]}),(0,K.jsx)(`label`,{htmlFor:`sw-agent-acp-in-use`,className:`block text-xs font-medium text-fg`,children:`Command in use`}),(0,K.jsx)(A,{id:`sw-agent-acp-in-use`,size:Q,value:B.acpCommand||``,readOnly:!0,className:`font-mono`,"data-sw-settings-acp-in-use":`true`})]}):null,o.fileProblem?(0,K.jsx)(`p`,{className:`text-xs text-bad`,children:o.fileProblem}):null,(0,K.jsx)(Y,{label:`Connect to`,children:(0,K.jsx)(ie,{label:`Connect to`,options:He,value:f.backend,onChange:e=>{L(`backend`)(e),D(null)},large:t,disabled:k,className:`max-w-sm`})}),me?(0,K.jsxs)(`div`,{className:`space-y-4`,"data-sw-settings-backend":`acp`,children:[(0,K.jsxs)(`section`,{className:`space-y-1.5 rounded-md border border-warn/60 bg-warn/10 p-3 text-xs text-fg`,role:`note`,"data-sw-settings-acp-warning":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,K.jsx)(ce,{size:14,className:`shrink-0 text-warn`,"aria-hidden":`true`}),` An ACP agent brings its own tools`]}),(0,K.jsx)(`p`,{children:`It runs with its own tools and extensions (a shell, browser control, MCP servers from its own config), and Shapewall does not sandbox them: Shapewall only asks you before its own file writes and commands. Use a restricted profile:`}),(0,K.jsxs)(`ul`,{className:`list-disc space-y-0.5 pl-5`,children:[(0,K.jsxs)(`li`,{children:[`Claude Code: permission mode `,(0,K.jsx)(`code`,{className:`font-mono`,children:`default`}),` or `,(0,K.jsx)(`code`,{className:`font-mono`,children:`plan`}),` in your Claude settings, never `,(0,K.jsx)(`code`,{className:`font-mono`,children:`bypassPermissions`}),`.`]}),(0,K.jsxs)(`li`,{children:[`Codex: `,(0,K.jsx)(`code`,{className:`font-mono`,children:`sandbox_mode = "workspace-write"`}),` or `,(0,K.jsx)(`code`,{className:`font-mono`,children:`"read-only"`}),`, never `,(0,K.jsx)(`code`,{className:`font-mono`,children:`danger-full-access`}),`.`]}),(0,K.jsxs)(`li`,{children:[`goose: `,(0,K.jsx)(`code`,{className:`font-mono`,children:`goose acp --with-builtin developer`}),` with a profile of its own that has no other extensions (`,(0,K.jsx)(`code`,{className:`font-mono`,children:`GOOSE_PATH_ROOT`}),`).`]})]})]}),(0,K.jsx)(Y,{label:Se?`Saved agent command (used when Shapewall starts without the override)`:`Agent command`,htmlFor:`sw-agent-acp`,hint:`One program and its arguments, no shell. It runs on this machine, as you, with its own login; Shapewall asks you before it writes files or runs commands.`,children:(0,K.jsx)(A,{id:`sw-agent-acp`,size:Q,value:f.acpCommand,onChange:L(`acpCommand`),placeholder:`claude-agent-acp`,disabled:k,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,className:`font-mono`,"data-sw-settings-field":`acpCommand`})}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Common agents`,children:Ue.map(e=>(0,K.jsx)(n,{size:t?`touch`:`xs`,variant:f.acpCommand.trim()===e.command?`default`:`secondary`,disabled:k,onClick:()=>L(`acpCommand`)(e.command),"data-sw-settings-preset":e.command,children:e.label},e.command))}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Install the adapter first (for Claude Code:`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`npm install -g @agentclientprotocol/claude-agent-acp`}),`). See`,` `,(0,K.jsx)(`a`,{className:`text-accent underline-offset-2 hover:underline`,href:`https://shapewall.com/docs/chat`,target:`_blank`,rel:`noreferrer`,children:`the chat docs`}),` `,`for Codex, goose and Gemini CLI.`]})]}):(0,K.jsxs)(`div`,{className:`space-y-4`,"data-sw-settings-backend":`openai-compatible`,children:[(0,K.jsxs)(Y,{label:`Base URL`,htmlFor:`sw-agent-url`,problem:be,hint:`The chat completions endpoint without /chat/completions, such as https://api.deepseek.com or https://api.openai.com/v1.`,children:[(0,K.jsx)(A,{id:`sw-agent-url`,size:Q,value:f.baseUrl,onChange:L(`baseUrl`),placeholder:Ee(`baseUrl`,`https://api.deepseek.com`),inputMode:`url`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,disabled:o.env.baseUrl||k,"aria-invalid":be?!0:void 0,"aria-describedby":be?`sw-agent-url-problem`:void 0,"data-sw-settings-field":`baseUrl`}),o.env.baseUrl?(0,K.jsx)(X,{children:`SHAPEWALL_AGENT_BASE_URL is set in the environment and wins over this field.`}):null]}),(0,K.jsxs)(Y,{label:`Model`,htmlFor:`sw-agent-model`,children:[(0,K.jsx)(A,{id:`sw-agent-model`,size:Q,value:f.model,onChange:L(`model`),placeholder:Ee(`model`,`deepseek-chat`),spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,disabled:o.env.model||k,"data-sw-settings-field":`model`}),o.env.model?(0,K.jsx)(X,{children:`SHAPEWALL_AGENT_MODEL is set in the environment and wins over this field.`}):null]}),(0,K.jsx)(Y,{label:`API key variable`,htmlFor:`sw-agent-keyvar`,problem:H,hint:`The name of the environment variable that holds the key. Not the key itself.`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(A,{id:`sw-agent-keyvar`,size:Q,value:f.apiKeyEnv,onChange:e=>L(`apiKeyEnv`)(e.target.value.toUpperCase()),placeholder:z.apiKeyEnv||o.defaultKeyVar,spellCheck:!1,autoCapitalize:`characters`,autoComplete:`off`,disabled:k,className:`font-mono`,"aria-invalid":H?!0:void 0,"aria-describedby":H?`sw-agent-keyvar-problem`:void 0,"data-sw-settings-field":`apiKeyEnv`}),xe?null:(0,K.jsx)(ae,{tone:U?`ok`:`warn`,"data-sw-settings-key":U?`set`:`missing`,children:U?`Set`:`Not set`})]})}),(0,K.jsxs)(`div`,{className:`space-y-1`,"data-sw-settings-host":G||`none`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[(0,K.jsx)(le,{size:13,"aria-hidden":`true`}),` Where the key goes`]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:G?U?(0,K.jsxs)(K.Fragment,{children:[`Each chat request sends the key in `,(0,K.jsx)(`code`,{className:`font-mono`,children:V}),` to`,` `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,"data-sw-settings-key-host":`true`,children:G}),`, and nowhere else.`]}):xe?(0,K.jsxs)(K.Fragment,{children:[`Requests go to `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:G}),`, without a key.`]}):(0,K.jsxs)(K.Fragment,{children:[`Requests go to `,(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:G}),`, without a key until`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:V}),` is set.`]}):`Set a base URL to see where requests go.`})]}),xe?(0,K.jsx)(`p`,{className:`text-xs text-muted`,"data-sw-settings-key-notice":`none`,children:`No API key needed for a local server like Ollama. If yours wants one, name its variable above.`}):(0,K.jsxs)(`div`,{className:`space-y-2 rounded-md border border-line p-3`,"data-sw-settings-key-notice":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[(0,K.jsx)(W,{size:13,"aria-hidden":`true`}),` Keys stay in the environment`]}),(0,K.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Shapewall never asks for your API key, saves it or shows it. Set it in the terminal that runs`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),`, then restart it:`]}),(0,K.jsx)(_e,{text:`export ${V}="paste-your-key-here"`,label:`shell`,touch:t}),(0,K.jsx)(_e,{text:`$env:${V} = "paste-your-key-here"`,label:`PowerShell`,touch:t})]}),f.keyHosts.length?(0,K.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-settings-key-hosts":`true`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:`Hosts you allowed the key to go to`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.keyHosts.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-2 py-0.5 pr-0.5 pl-2 text-xs`,"data-sw-settings-key-host-item":e.host,children:[e.host,` `,(0,K.jsx)(`span`,{className:`font-mono text-faint`,children:e.apiKeyEnv}),(0,K.jsx)(n,{variant:`ghost`,size:t?`icon`:`icon-xs`,disabled:k,onClick:()=>p(t=>({...t,keyHosts:t.keyHosts.filter(t=>t!==e)})),"aria-label":`Stop sending ${e.apiKeyEnv} to ${e.host}`,children:(0,K.jsx)(g,{size:12,"aria-hidden":`true`})})]},`${e.apiKeyEnv}@${e.host}`))})]}):null]}),(0,K.jsxs)(`div`,{className:`space-y-1`,"data-sw-settings-vision":f.vision===null?`auto`:String(f.vision),children:[(0,K.jsxs)(E,{size:Q,pressed:f.vision??(!me||B.vision!==!1),disabled:k,onPressedChange:e=>{p(t=>({...t,vision:e})),S(!1)},"data-sw-settings-field":`vision`,children:[f.vision??(!me||B.vision!==!1)?(0,K.jsx)(v,{size:13,"aria-hidden":`true`}):null,`This model takes images`]}),(0,K.jsx)(`p`,{className:`text-xs text-muted`,children:f.vision===!1?`Images are not sent; the chat says so when one is attached.`:me&&f.vision===null?`The agent says itself whether it takes images. Test connection checks it.`:`Turn off for a text-only model (many local models): images are then left out instead of failing.`})]}),(0,K.jsx)(Y,{label:`Name in the chat panel (optional)`,htmlFor:`sw-agent-label`,children:(0,K.jsx)(A,{id:`sw-agent-label`,size:Q,value:f.label,onChange:L(`label`),placeholder:z.label||(me?`the agent’s name`:`the model name`),maxLength:40,disabled:k,"data-sw-settings-field":`label`})}),(0,K.jsxs)(`p`,{className:`text-xs text-faint`,"data-sw-settings-file":`true`,children:[`Saved for this project in `,(0,K.jsx)(`code`,{className:`font-mono break-all`,children:o.file||`your config folder`}),`, outside the repo, never in shapewall.config.json. The environment and `,(0,K.jsx)(`code`,{className:`font-mono`,children:`--agent-acp`}),` win over these settings; they win over the config.`]}),_?(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-settings-error":`save`,children:_}):null,(0,K.jsx)(ye,{result:ne}),(0,K.jsxs)(`div`,{className:l(`flex flex-wrap items-center gap-2`,t&&`flex-col-reverse items-stretch`),children:[(0,K.jsxs)(n,{size:Q,onClick:we,disabled:T||m||R,"data-sw-settings-test":`true`,children:[T?(0,K.jsx)(b,{}):(0,K.jsx)(le,{size:14,"aria-hidden":`true`}),` `,T?`Testing...`:`Test connection`]}),R?(0,K.jsx)(`span`,{className:`text-xs text-muted`,children:`Save to test these settings.`}):null,x&&!R?(0,K.jsx)(`span`,{className:`text-xs text-muted`,role:`status`,"data-sw-settings-saved":`true`,children:`Saved. Chat uses it now.`}):null,R?(0,K.jsx)(n,{size:Q,variant:`ghost`,className:l(!t&&`ml-auto`),onClick:pe,disabled:m,"data-sw-settings-discard":`true`,children:`Discard changes`}):null,(0,K.jsx)(n,{size:Q,variant:`default`,className:l(!t&&!R&&`ml-auto`),onClick:()=>Ce(null),disabled:m||!R||!!H||!!be,"data-sw-settings-save":`true`,children:m?`Saving...`:`Save`})]}),(0,K.jsx)(ve,{items:C?.items||null,keyVar:V,busy:m,touch:t,onCancel:()=>w(null),onConfirm:()=>Ce(C?.hash||null)})]})}var qe=`/console?section=agents`;function Je({view:e,touch:t}){let r=e.profiles||[],i=r.find(e=>e.default);return(0,K.jsxs)(`section`,{className:`flex flex-wrap items-center gap-3 rounded-md border border-line p-3`,"data-sw-agents-link":!0,children:[(0,K.jsx)(oe,{size:16,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-xs`,children:[(0,K.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:`Agents`}),(0,K.jsxs)(`p`,{className:`text-muted`,children:[r.length?`${r.map(e=>e.label).join(`, `)} connected${i?`. New chats and fixes use ${i.label}`:``}.`:`No agent connected yet.`,` `,`Connect, remove and choose the default on the Agents page of the Workspace Console.`]})]}),(0,K.jsx)(n,{asChild:!0,size:t?`touch`:`sm`,children:(0,K.jsx)(`a`,{href:qe,"data-sw-agents-open":!0,children:`Manage agents`})})]})}function Ye({open:e,onClose:t,onSaved:n,touch:r,buzz:i=!1}){let[a,o]=(0,J.useState)(!1);return(0,K.jsx)(d,{open:e,onClose:t,title:`Settings`,size:`md`,sticky:a,children:(0,K.jsxs)(w,{defaultValue:`agent`,className:`p-5`,children:[(0,K.jsx)(ne,{className:`mb-4 max-w-40`,"aria-label":`Settings`,children:(0,K.jsx)(re,{value:`agent`,large:r,"data-sw-settings-tab":`agent`,children:`Agent`})}),(0,K.jsx)(_,{value:`agent`,children:e?(0,K.jsx)(Ke,{onSaved:n,touch:r,buzz:i,onDirtyChange:o}):null})]})})}var Xe=`https://shapewall.com/docs/chat`,Ze=`${Xe}#restrict-the-agents-own-tools`;function Qe({onOpenSettings:e,docsUrl:t,touch:r,open:i=!1}){return(0,K.jsxs)(`details`,{className:`group rounded-md border border-line text-left`,open:i,"data-sw-chat-other-options":`true`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-1.5 px-3 text-xs font-medium text-fg lg:min-h-9 [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(k,{size:13,className:`text-muted transition-transform group-open:rotate-90`,"aria-hidden":`true`}),` Other options`]}),(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-line p-3 text-xs text-muted`,children:[(0,K.jsx)(`p`,{children:`An OpenAI-compatible endpoint (OpenAI, DeepSeek, OpenRouter, Ollama, LM Studio) or another agent command:`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,K.jsxs)(n,{size:r?`touch`:`sm`,onClick:e,"data-sw-settings-open":`connect`,children:[(0,K.jsx)(j,{size:13,"aria-hidden":`true`}),` Open agent settings`]}),(0,K.jsx)(n,{asChild:!0,variant:`ghost`,size:r?`touch`:`sm`,children:(0,K.jsxs)(`a`,{href:t||`https://shapewall.com/docs/chat`,target:`_blank`,rel:`noreferrer`,"data-sw-chat-docs":`true`,children:[(0,K.jsx)(F,{size:13,"aria-hidden":`true`}),` Chat docs`]})})]})]})]})}function $e({agent:e,touch:t,onOpenSettings:r,onConnected:i}){let[a,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(Ce()),x=(0,J.useCallback)(async()=>{try{l(await c.get(`/api/agent/settings`)),d(null)}catch(e){e.status===404&&ee(),d(e.status===404?q:e.message)}},[]);(0,J.useEffect)(()=>{x()},[x]);let S=async(e,t=null)=>{p(e.id),h(null);try{let n=t?{name:v.name.trim(),...v.icon&&!v.png?{icon:v.icon}:{},...v.tint?{tint:v.tint}:{}}:{},r=await c.post(`/api/agent/settings/profiles/connect`,{agentId:e.id,confirm:t,...n});if(r.confirm){y(Ce({label:e.label})),_({item:e,items:r.confirm,hash:r.confirmHash});return}if(_(null),r.connected&&t&&v.png&&await Q(e.id,{},{...v,name:``,tint:null}).catch(()=>null),!r.connected){h({id:e.id,result:r.result}),l(r);return}i?.(r.result)}catch(t){_(null),h({id:e.id,result:{ok:!1,message:t.message,details:[]}})}finally{p(null)}};if(u)return(0,K.jsx)(`p`,{className:`text-xs text-bad`,role:`alert`,"data-sw-settings-error":`load`,children:u===`On the computer running Shapewall, run shapewall settings --config FILE --open with this project’s config file to open agent settings. For a direct local board, you can also use the owner link printed by shapewall serve.`?(0,K.jsx)(ge,{}):`Could not look for agents: ${u}`});if(!a)return(0,K.jsxs)(`p`,{className:`flex items-center justify-center gap-2 text-xs text-muted`,"data-sw-chat-detect":`loading`,children:[(0,K.jsx)(b,{size:12}),` Looking for agents on this machine`]});let C=a.detected||[],w=C.filter(e=>e.state===`ready`),T=C.filter(e=>e.state===`needs-adapter`),te=C.filter(e=>e.state===`needs-shell`),E=!!a.env?.acp,ne=t?`touch`:`sm`;return(0,K.jsxs)(`div`,{className:`w-full space-y-3 text-left`,"data-sw-chat-connect":`true`,children:[E?(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-fg`,"data-sw-chat-connect-override":`true`,children:[(0,K.jsx)(ce,{size:13,className:`mt-px shrink-0 text-warn`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{children:[`The agent command comes from `,a.env.acp===`flag`?`--agent-acp`:`SHAPEWALL_AGENT_ACP`,` and wins over the board. Fix it there, or restart `,(0,K.jsx)(`code`,{className:`font-mono`,children:`shapewall serve`}),` without it.`]})]}):null,w.length?(0,K.jsx)(`ul`,{className:`space-y-2`,"aria-label":`Agents found on this machine`,children:w.map(e=>{let t=m?.id===e.id?m.result:null;return(0,K.jsxs)(`li`,{className:`space-y-2 rounded-md border border-line bg-surface-2/60 p-3`,"data-sw-chat-detected":e.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(L,{size:15,className:`shrink-0 text-ok`,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm font-medium text-fg`,children:[e.label,` found on this machine`]}),(0,K.jsx)(s,{content:e.path||null,children:(0,K.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted`,children:e.command})})]}),(0,K.jsxs)(n,{variant:`default`,size:ne,onClick:()=>S(e),disabled:!!f||E||!!a.testing,title:a.testing?`A connection test is running. Connect is available when it finishes.`:void 0,"data-sw-chat-connect-agent":e.id,children:[f===e.id?(0,K.jsx)(b,{}):(0,K.jsx)(le,{size:13,"aria-hidden":`true`}),` `,f===e.id?`Connecting...`:`Connect`]})]}),t?(0,K.jsxs)(`div`,{className:`rounded-md border border-bad/40 bg-bad/10 p-2 text-xs`,role:`alert`,"data-sw-chat-connect-result":`failed`,children:[(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 font-medium text-bad`,children:[(0,K.jsx)(R,{size:13,className:`mt-px shrink-0`,"aria-hidden":`true`}),` `,t.message]}),(0,K.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Nothing was changed. `,e.login?`To log it in: ${e.login}.`:``]})]}):null]},e.id)})}):(0,K.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-chat-detected":`none`,children:[`No agent CLI with ACP found on this machine (Claude Code, Codex, goose, Gemini CLI).`,T.length?null:(0,K.jsx)(K.Fragment,{children:` For Claude Code, install its adapter in a terminal, then check again:`})]}),!w.length&&!T.length?(0,K.jsx)(_e,{text:`npm install -g @agentclientprotocol/claude-agent-acp`,label:`install`,touch:t}):null,T.map(e=>(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs text-muted`,"data-sw-chat-needs-adapter":e.id,children:[(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),` is installed, but not its ACP adapter. Install it in a terminal, then check again:`]}),e.install?(0,K.jsx)(_e,{text:e.install,label:`${e.label} install`,touch:t}):null]},e.id)),te.map(e=>(0,K.jsxs)(`p`,{className:`text-xs text-muted`,"data-sw-chat-needs-shell":e.id,children:[(0,K.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),` is installed only as a `,(0,K.jsx)(`code`,{className:`font-mono`,children:`.cmd`}),` wrapper, which needs a shell, and Shapewall never starts one. In Other options, set the agent command to`,` `,(0,K.jsx)(`code`,{className:`font-mono`,children:`node`}),` and the path of its script (see the chat docs).`]},e.id)),w.length?(0,K.jsxs)(`p`,{className:`text-[11px] leading-4 text-muted`,"data-sw-chat-connect-note":`true`,children:[`Connect asks first, then runs that command on this machine, as you, with the agent’s own login. It brings its own tools (a shell, file edits), which Shapewall does not sandbox:`,` `,(0,K.jsx)(`a`,{className:`text-accent underline-offset-2 hover:underline`,href:Ze,target:`_blank`,rel:`noreferrer`,children:`use a restricted profile`}),`.`]}):null,(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)(n,{variant:`ghost`,size:t?`touch`:`xs`,onClick:x,disabled:!!f,"data-sw-chat-detect-again":`true`,children:[(0,K.jsx)(fe,{size:12,"aria-hidden":`true`}),` Check again`]})}),(0,K.jsx)(Qe,{onOpenSettings:r,docsUrl:e?.docsUrl,touch:t,open:!w.length&&!T.length}),(0,K.jsx)(ve,{items:g?.items||null,busy:!!f,touch:t,confirmLabel:`Allow and connect`,onCancel:()=>_(null),onConfirm:()=>S(g.item,g.hash),blocked:!!Oe(v.name),children:(0,K.jsx)(ke,{value:v,onChange:y,builtIn:g?.item.label||``,logo:o(g?.item.id),upload:a.iconUpload!==!1,touch:t,disabled:!!f})})]})}function et({result:e,onDismiss:t,touch:r}){return e?(0,K.jsxs)(`div`,{className:l(`rounded-md border border-ok/40 bg-ok/10 p-3 text-left text-xs`),role:`status`,"data-sw-chat-connected-note":`true`,children:[(0,K.jsxs)(`p`,{className:`flex items-start gap-1.5 font-medium text-fg`,children:[(0,K.jsx)(oe,{size:14,className:`mt-px shrink-0 text-ok`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`flex-1`,children:[`Connected to `,e.label,`. `,e.message]}),(0,K.jsx)(n,{variant:`ghost`,size:r?`icon`:`icon-xs`,onClick:t,"aria-label":`Dismiss`,className:`-mt-1 -mr-1`,children:(0,K.jsx)(g,{size:13,"aria-hidden":`true`})})]}),e.details?.length?(0,K.jsx)(`ul`,{className:`mt-1.5 list-disc space-y-0.5 pl-5 text-muted`,children:e.details.map(e=>(0,K.jsx)(`li`,{children:e},e))}):null]}):null}export{ze as a,G as c,Ke as i,W as l,Xe as n,ge as o,$e as r,q as s,et as t,z as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{B as t,Cn as n,Jt as r,R as i,Sn as a,Tn as o,c as s,qt as c,rn as l}from"./ui-2lMx-4bc.js";import{t as u}from"./refresh-cw-B-npxKae.js";import{o as d,s as f}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{B as t,Cn as n,Jt as r,R as i,Sn as a,Tn as o,c as s,qt as c,rn as l}from"./ui-2lMx-4bc.js";import{t as u}from"./refresh-cw-B-npxKae.js";import{o as d,s as f}from"./index-t3fn6ogR.js";var p={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};p.node;var m=a(p),h=e(o(),1),g=n(),_=`/api/app-update`;function v({open:e,onClose:n,onCloseAutoFocus:a,transport:o=r}){let[p,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(null),[T,E]=(0,h.useState)(!1),[D,O]=(0,h.useState)(!1),k=(0,h.useRef)(!0),A=l||c;(0,h.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let j=(0,h.useCallback)(async()=>{b(!0),w(null);try{let e=await o.get(_);k.current&&v(e)}catch(e){k.current&&w(e.status===404?`This installation needs a manual update before in-app updates are available.`:e.message)}finally{k.current&&b(!1)}},[o]);(0,h.useEffect)(()=>{e&&!A&&j()},[e,A,j]);let M=async e=>{S(e),w(null),O(!1);let t=e===`apply`?p?.latest:null,n=e=>t&&e.job?.state!==`running`&&e.current?.version===t.version&&(!t.revision||e.current?.revision===t.revision),r=Date.now()+(e===`apply`?96e4:9e4);try{if(e===`apply`&&(!t||!t.revision&&t.version===p?.current?.version))throw Error(`This update has no distinct build identity. Ask the installer to prepare a versioned release.`);let i=await o.post(`${_}/${e}`);if(!k.current)return;for(v(i);k.current&&(i.job?.state===`running`||e===`apply`&&i.job?.state!==`failed`&&!n(i));){if(Date.now()>=r)throw Error(`Still waiting for the update service. Reopen this panel to refresh its status.`);if(await new Promise(e=>window.setTimeout(e,1200)),!k.current)return;try{if(i=await o.get(_),!k.current)return;if(E(!1),v(i),e===`apply`&&n(i)){O(!0);return}}catch(t){if(e!==`apply`||t.status&&t.status<500)throw t;E(!0)}}if(!k.current)return;if(i.job?.state===`failed`)throw Error(i.job.error||`The update could not finish. Try again or contact the installer.`);e===`apply`&&n(i)&&O(!0)}catch(e){k.current&&w(e.message||`Could not reach Shapewall. Check your connection and try again.`)}finally{k.current&&(S(null),E(!1))}},N=x||p?.job?.state===`running`,P=D||p?.canUpdate&&p?.supported||C||p?.job?.state===`running`,F=T?`Shapewall is restarting. Reconnecting…`:x===`apply`?`Installing the update. This page may briefly disconnect.`:x===`check`?`Checking for updates…`:D?`Update installed. Reload to use the new version.`:p?.job?.state===`running`?`An update operation is running. Refresh its status in a moment.`:p?.job?.state===`failed`?`The last update operation did not finish. You can try again.`:p?.updateAvailable?`An update is available${p.latest?`: ${f(p.latest)}`:``}.`:p?.checkedAt?`You are up to date.`:`Check when you want the latest version.`;return(0,g.jsx)(i,{open:e,onClose:n,onCloseAutoFocus:a,title:`About & Updates`,description:`Shapewall`,footer:A||!P?null:(0,g.jsxs)(`div`,{className:`flex w-full flex-wrap justify-end gap-2`,children:[D?(0,g.jsxs)(t,{size:`touch`,className:`lg:h-9`,onClick:()=>window.location.reload(),"data-sw-app-reload":!0,children:[(0,g.jsx)(u,{size:15,"aria-hidden":`true`}),` Reload Shapewall`]}):null,!D&&p?.canUpdate&&p?.supported?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(t,{variant:`secondary`,size:`touch`,className:`lg:h-9`,disabled:!!(N||y),onClick:()=>M(`check`),"data-sw-app-check":!0,children:[(0,g.jsx)(u,{size:15,"aria-hidden":`true`}),` Check for updates`]}),p.updateAvailable?(0,g.jsxs)(t,{size:`touch`,className:`lg:h-9`,disabled:!!(N||y),onClick:()=>M(`apply`),"data-sw-app-update":!0,children:[(0,g.jsx)(m,{size:15,"aria-hidden":`true`}),` Update now`]}):null]}):null,!x&&(C||p?.job?.state===`running`)?(0,g.jsx)(t,{variant:`secondary`,size:`touch`,className:`lg:h-9`,disabled:y,onClick:j,children:`Refresh status`}):null]}),children:(0,g.jsxs)(`div`,{className:`space-y-4 p-5 text-sm`,"data-sw-app-updates":!0,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`p`,{className:`font-semibold text-fg`,children:[`Shapewall `,f(d)]}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Created by Dan Baruch`})]}),A?(0,g.jsxs)(`p`,{className:`text-muted`,children:[l?`This is the public demo.`:`This is a static export.`,` It cannot update a Shapewall installation. Ask the installer for a new build.`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{className:`text-muted`,children:`Updates are manual. Shapewall checks and installs only when you ask.`}),p?.current&&f(p.current)!==f(d)?(0,g.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Server: `,f(p.current),`. Reload this page to load its current interface.`]}):null,y?(0,g.jsxs)(`p`,{className:`flex items-center gap-2 text-muted`,role:`status`,children:[(0,g.jsx)(s,{}),` Reading installation details…`]}):p?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`p`,{className:`flex items-start gap-2 text-fg`,role:`status`,"data-sw-app-update-status":!0,children:[x?(0,g.jsx)(s,{}):null,(0,g.jsx)(`span`,{children:F})]}),!p.supported||!p.canUpdate?(0,g.jsx)(`p`,{className:`text-muted`,children:p.reason||`Updates are managed by the person who installed Shapewall.`}):null,p.checkedAt?(0,g.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Last checked: `,new Date(p.checkedAt).toLocaleString()]}):null]}):null,C?(0,g.jsx)(`p`,{className:`text-bad`,role:`alert`,children:C}):null]})]})})}export{v as default};
|