@qodeca/xezar 0.11.0 → 0.11.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.
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,Rt as i,Vt as a,a as o,i as s,j as ee,k as c,pr as te,qr as ne,t as l}from"./centered-state-B_V_Ai2h.js";import{g as re,h as u,r as d,t as f,v as p}from"./utils-Bb8ohcr3.js";import{h as ie,m as ae,p as oe}from"./new-task-form-BydHBbef.js";import{p as se,r as ce,v as le,y as ue}from"./prompt-templates-B7Fs2b1S.js";import{n as m}from"./textarea--cpYshee.js";import{d as de,f as fe,g as h,h as g,l as _,m as pe,p as v,u as y}from"./alert-dialog-CGskMvgc.js";import{t as me}from"./use-submit-shortcut-JY8M_MPL.js";import{i as he,n as ge,r as _e,t as ve}from"./skills-D4P-Hgey.js";var b=d(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ye=d(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),x=d(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),S=n(),C=e(t(),1);function w(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable?!0:e.closest(`[contenteditable=""], [contenteditable="true"]`)!==null}function T(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function E(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||w(e.target)&&!T(e.target))}function D(e,t){let n=C.useRef(t);C.useLayoutEffect(()=>{n.current=t}),C.useEffect(()=>{let t=t=>{E(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function O(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||w(e.target))}function k(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function A(e,t){let n=C.useRef(t);C.useLayoutEffect(()=>{n.current=t}),C.useEffect(()=>{let t=t=>{O(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function j({...e}){return(0,S.jsx)(_,{"data-slot":`sheet`,...e})}function M({...e}){return(0,S.jsx)(h,{"data-slot":`sheet-trigger`,...e})}function N({...e}){return(0,S.jsx)(y,{"data-slot":`sheet-close`,...e})}function P({...e}){return(0,S.jsx)(pe,{"data-slot":`sheet-portal`,...e})}function F({className:e,...t}){return(0,S.jsx)(v,{"data-slot":`sheet-overlay`,className:f(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function I({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,S.jsxs)(P,{children:[(0,S.jsx)(F,{}),(0,S.jsxs)(de,{"data-slot":`sheet-content`,className:f(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...i,children:[t,r&&(0,S.jsxs)(y,{className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,S.jsx)(m,{className:`size-4`}),(0,S.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function L({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`sheet-header`,className:f(`flex flex-col gap-1.5 p-4`,e),...t})}function R({className:e,...t}){return(0,S.jsx)(g,{"data-slot":`sheet-title`,className:f(`font-semibold text-foreground`,e),...t})}function z({className:e,...t}){return(0,S.jsx)(fe,{"data-slot":`sheet-description`,className:f(`text-sm text-muted-foreground`,e),...t})}function B(e){let[t,n]=C.useState(()=>Date.now());return C.useEffect(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var V={md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,log:`text/plain`,pdf:`application/pdf`};function H(e){return re(e.type)?e.type:V[e.name.split(`.`).pop()?.toLowerCase()??``]??null}async function be(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));let r=btoa(n),i=H(e)??`application/octet-stream`,a=p(i);return{mediaType:i,data:r,...a?{preview:`data:${i};base64,${r}`}:{},name:e.name||(a?`pasted image`:`pasted.${u(i)}`),isImage:a}}function xe(e,t){let n=[],r=[],i=t;for(let t of e){let e=t.name||`attachment`;if(H(t)===null){r.push(`${e} is not a supported attachment (images, PDF and plain-text files such as TXT or MD)`);continue}if(t.size>5242880){r.push(`${e} is too large (max 5 MB)`);continue}if(i>=4){r.push(`${e} skipped — max 4 attachments per message`);continue}n.push(t),i+=1}return{accepted:n,rejected:r}}var U=new Set([`/`,`@`]);function Se(e,t){for(let n=t-1;n>=0;--n){let r=e[n];if(/\s/.test(r))return null;if(U.has(r))return n>0&&!/\s/.test(e[n-1])?null:{trigger:r,start:n,query:e.slice(n+1,t)}}return null}function Ce(e,t,n,r){let i=`${t.trigger}${r} `;return{text:e.slice(0,t.start)+i+e.slice(n),caret:t.start+i.length}}function W(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function we(e,t){let n=e,r=``;for(let e=t.resultIndex;e<t.results.length;e+=1){let i=t.results[e],a=i[0]?.transcript??``;i.isFinal?n+=a:r+=a}return{finalText:n,interim:r}}function Te(e){let[t,n]=C.useState(null),r=C.useRef(null),i=C.useRef(``),[a]=C.useState(()=>W()!==void 0),o=C.useCallback(()=>{let e=r.current;r.current=null,i.current=``,n(null),e&&(e.onresult=null,e.onerror=null,e.onend=null,e.abort())},[]);return C.useEffect(()=>o,[o]),{supported:a,recording:t,start:C.useCallback(()=>{if(r.current)return;let t=W();if(!t)return;let a;try{a=new t,a.lang=navigator.language||`en-US`,a.continuous=!0,a.interimResults=!0;let s=Date.now();a.onresult=e=>{let t=we(i.current,e);i.current=t.finalText,n({transcript:t.finalText+t.interim,startedAt:s})},a.onerror=t=>{e(`Dictation failed${t.error?` — ${t.error}`:``}`),o()},a.start(),r.current=a,n({transcript:``,startedAt:s})}catch{e(`Dictation failed — the microphone could not be started`),o()}},[e,o]),cancel:C.useCallback(()=>o(),[o]),finish:C.useCallback(()=>{let e=r.current,a=(i.current+``).trim()===``?``:i.current,o=t?.transcript??a;return e&&(e.onresult=null,e.onerror=null,e.onend=null,e.stop()),r.current=null,i.current=``,n(null),o.trim()},[t])}}function G(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}var Ee={KeyA:`Yes, approved.`,KeyC:`Continue.`};function K({onSubmit:e,value:t,onValueChange:n,autoFocus:r=!1,footerStart:c,footerEnd:l,sendAriaLabel:re=`Send`,disabled:u=!1,disabledReason:d=`Session closed — Continue to reopen.`,allowEmptySubmit:p=!1,placeholder:de=`Reply — / for skills, @ for files…`,ariaLabel:fe=`Reply to the agent`,autocompleteSkills:h=!0,quickReplies:g=!1,getMentionCandidates:_,ref:pe}){let[v,y]=(0,C.useState)(``),T=t??v,E=(0,C.useRef)(T);E.current=T;let D=(0,C.useRef)(n);D.current=n;let O=(0,C.useCallback)(e=>{let t=typeof e==`function`?e(E.current):e;y(t),D.current?.(t)},[]),[k,A]=(0,C.useState)([]),j=(0,C.useRef)(k);j.current=k;let[M,N]=(0,C.useState)(!1),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(!1),B=(0,C.useRef)(null),V=(0,C.useRef)(null),H=(0,C.useRef)(null),U=i(h&&R),W=a(),we=ne(),G=Te(e=>s(e,{tone:`danger`}));(0,C.useEffect)(()=>{r&&B.current?.focus()},[]),(0,C.useImperativeHandle)(pe,()=>({insertAtCaret:e=>{let t=B.current,n=ce(E.current,t?.selectionStart??E.current.length,e);O(n.text),H.current=n.caret,t?.focus()}}),[O]);let K=(0,C.useCallback)(()=>{let e=B.current;if(!e||u){F(null);return}let t=Se(e.value,e.selectionStart??e.value.length);if(t?.trigger===`/`&&!h||t?.trigger===`@`&&_===void 0)return F(null);t?.trigger===`/`&&z(!0),F(t)},[h,u,_]),q=(0,C.useMemo)(()=>P===null?[]:P.trigger===`/`?ge(U.data??[],P.query,W.data?.skillUsage).map(e=>({value:`${e.name} ${e.path}`,insert:e.name,label:e.name,description:e.description,emphasized:he(e)})):(_?.()??[]).filter(e=>_e(e,P.query)).map(e=>({value:e,insert:e,label:e,emphasized:!1})),[_,U.data,P,W.data?.skillUsage]),J=q.some(e=>e.value===I)?I:q[0]?.value,ke=P!==null,Y=(0,C.useCallback)(()=>F(null),[]),Ae=e=>{let t=B.current;if(!t||P===null)return;let n=t.selectionStart??t.value.length,r=Ce(t.value,P,n,e.insert);P.trigger===`/`&&W.data!==void 0&&te({skillUsage:ve(W.data.skillUsage,e.insert)}).then(()=>we.invalidateQueries({queryKey:ee.uiState})).catch(()=>{}),O(r.text),H.current=r.caret,F(null),t.focus()};(0,C.useLayoutEffect)(()=>{let e=H.current,t=B.current;e!==null&&t&&(t.setSelectionRange(e,e),H.current=null)},[T]),(0,C.useLayoutEffect)(()=>{let e=B.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)},[T]);let X=(0,C.useCallback)(e=>{if(u)return;let t=xe(e,j.current.length);for(let e of t.rejected)s(e,{tone:`danger`});for(let e of t.accepted)be(e).then(e=>A(t=>t.length>=4?t:[...t,e]))},[u]),je=e=>{let t=[...e.clipboardData?.items??[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),X(t))},Me=e=>{let t=[...e.dataTransfer?.files??[]];t.length!==0&&(e.preventDefault(),X(t))},Z=(0,C.useCallback)(async(t,n,r)=>{let i=t.trim();if(!(u||M)&&!(i===``&&n.length===0&&!p)){N(!0);try{await e(i,n.map(({mediaType:e,data:t})=>({mediaType:e,data:t})))}catch(e){s(e instanceof Error?e.message:String(e),{tone:`danger`}),r&&(O(e=>e===``?t:`${t}\n${e}`),A(e=>[...n,...e].slice(0,4)))}finally{N(!1)}}},[p,M,u,e]),Ne=(0,C.useCallback)(()=>{if(T.trim()===``&&k.length===0&&!p)return;let e=T,t=k;O(``),A([]),F(null),Z(e,t,!0)},[p,k,Z,T]),Pe=e=>{if(ke){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),q.length===0)return;let t=q.findIndex(e=>e.value===J),n=e.key===`ArrowDown`?1:-1,r=q[(t+n+q.length)%q.length];L(r.value);return}if(e.key===`Escape`){e.preventDefault(),Y();return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){let t=q.find(e=>e.value===J);if(t){e.preventDefault(),Ae(t);return}Y()}}me({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),Ne())};(0,C.useEffect)(()=>{if(!g||u)return;let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.repeat||w(e.target))return;let t=Ee[e.code];t!==void 0&&(e.preventDefault(),Z(t,[],!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,g,Z]);let Q=e=>{let t=G.finish();if(t===``)return;let n=T.trim()===``?t:`${T.replace(/\s*$/,``)} ${t}`;if(e){O(``),A([]),Z(n,k,!0);return}O(n),H.current=n.length,B.current?.focus()},$=G.recording;return(0,S.jsxs)(oe,{open:ke,onOpenChange:e=>e?void 0:Y(),children:[(0,S.jsx)(ae,{asChild:!0,children:(0,S.jsxs)(`div`,{ref:V,"data-slot":`composer`,"data-disabled":u||void 0,onDrop:Me,onDragOver:e=>e.preventDefault(),className:f(`rounded-xl border border-border bg-card shadow-xs transition-[border-color,box-shadow]`,`focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/15`,u&&`opacity-80`),children:[k.length>0?(0,S.jsx)(`div`,{"data-slot":`composer-thumbs`,className:`flex flex-wrap items-center gap-2 px-4 pt-3`,children:k.map((e,t)=>(0,S.jsxs)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,title:`Click to remove`,className:f(`group relative overflow-hidden rounded-md border border-border`,e.isImage?`size-12`:`flex h-12 max-w-[200px] items-center gap-1.5 bg-muted/40 px-2.5 text-xs text-muted-foreground`),onClick:()=>A(e=>e.filter((e,n)=>n!==t)),children:[e.isImage?(0,S.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,S.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,S.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center bg-background/70 group-hover:flex group-focus-visible:flex`,children:(0,S.jsx)(m,{"aria-hidden":`true`,className:`size-4`})})]},`${e.name}-${t}`))}):null,(0,S.jsx)(`textarea`,{ref:B,rows:1,value:T,disabled:u,"aria-label":fe,placeholder:u?d:de,className:`block max-h-[220px] min-h-11 w-full resize-none bg-transparent px-3 pt-2.5 pb-1 text-base leading-normal outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed md:min-h-[54px] md:px-4 md:pt-3 md:text-sm`,onChange:e=>{O(e.target.value),K()},onKeyDown:Pe,onSelect:K,onPaste:je}),$?(0,S.jsx)(Oe,{transcript:$.transcript,startedAt:$.startedAt,onCancel:G.cancel,onInsert:()=>Q(!1),onInsertAndSend:()=>Q(!0)}):(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 gap-y-1 px-1.5 pt-1 pb-1.5 md:gap-y-1.5 md:px-2 md:pt-1.5 md:pb-2`,children:[(0,S.jsxs)(`div`,{"data-slot":`composer-footer-start`,className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,S.jsx)(De,{disabled:u,onFiles:X}),c]}),(0,S.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[G.supported?(0,S.jsxs)(o,{type:`button`,variant:`ghost`,size:`sm`,disabled:u,"aria-label":`Start dictation`,title:`Dictation`,className:`h-8 gap-1.5 px-2.5 text-xs font-medium text-muted-foreground`,onClick:G.start,children:[(0,S.jsx)(ye,{"aria-hidden":`true`,className:`size-3.5`}),`Dictation`]}):null,l?(0,S.jsx)(`div`,{"data-slot":`composer-footer-end`,className:`flex items-center gap-1.5`,children:l}):null,(0,S.jsx)(o,{type:`button`,size:`icon-sm`,"aria-label":re,disabled:u||M||T.trim()===``&&k.length===0&&!p,className:`size-8`,onClick:Ne,children:(0,S.jsx)(b,{"aria-hidden":`true`})})]})]})]})}),(0,S.jsx)(ie,{side:`top`,align:`start`,sideOffset:8,className:`w-80 max-w-[calc(100vw-2rem)] p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{V.current?.contains(e.target)&&e.preventDefault()},children:(0,S.jsx)(se,{shouldFilter:!1,value:J??``,onValueChange:L,children:(0,S.jsx)(ue,{"data-slot":`composer-menu`,"data-trigger":P?.trigger,className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] p-1`,children:q.length===0?(0,S.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:P?.trigger===`@`?`No files seen in this session yet — full file search arrives with the Files tab.`:U.isPending?`Loading skills…`:`No matching skills.`}):q.map(e=>(0,S.jsxs)(le,{value:e.value,"data-slot":`composer-menu-item`,"data-emphasized":e.emphasized||void 0,onSelect:()=>Ae(e),children:[(0,S.jsx)(`span`,{className:f(`shrink-0 truncate`,e.emphasized&&`font-semibold`,P?.trigger===`@`&&`font-mono text-xs`),children:e.label}),e.description?(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.value))})})})]})}function De({disabled:e,onFiles:t}){let n=(0,C.useRef)(null);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach files`,title:`Attach an image, PDF, TXT or MD file (or paste a screenshot)`,disabled:e,className:`size-8 text-muted-foreground`,onClick:()=>n.current?.click(),children:(0,S.jsx)(x,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,S.jsx)(`input`,{ref:n,type:`file`,accept:`image/*,application/pdf,text/plain,text/markdown,.pdf,.txt,.md,.markdown,.log`,multiple:!0,className:`hidden`,"aria-hidden":`true`,tabIndex:-1,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}function Oe({transcript:e,startedAt:t,onCancel:n,onInsert:i,onInsertAndSend:a}){let s=B(1e3);return(0,S.jsxs)(`div`,{"data-slot":`dictation-overlay`,role:`status`,"aria-label":`Dictation in progress`,className:`flex items-center gap-2.5 rounded-b-xl border-t border-border bg-muted/60 px-3 py-2`,children:[(0,S.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none animate-pulse rounded-full bg-danger motion-reduce:animate-none`}),(0,S.jsx)(`span`,{"data-slot":`dictation-timer`,className:`text-xs font-medium text-muted-foreground tabular-nums`,children:G(t,s)}),(0,S.jsx)(`span`,{"data-slot":`dictation-transcript`,"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e===``?(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Listening…`}):e}),(0,S.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel dictation`,className:`size-8 text-muted-foreground`,onClick:n,children:(0,S.jsx)(m,{"aria-hidden":`true`})}),(0,S.jsx)(o,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":`Insert transcription`,className:`size-8`,onClick:i,children:(0,S.jsx)(r,{"aria-hidden":`true`})}),(0,S.jsx)(o,{type:`button`,size:`icon-sm`,"aria-label":`Insert transcription and send`,className:`size-8`,onClick:a,children:(0,S.jsx)(b,{"aria-hidden":`true`})})]})}function q(){return(0,S.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,S.jsx)(l,{icon:(0,S.jsx)(c,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}export{N as a,L as c,k as d,D as f,b as h,j as i,R as l,x as m,K as n,I as o,A as p,B as r,z as s,q as t,M as u};