@hiperplano/aluy-cli 1.0.0-rc.13 → 1.0.0-rc.15

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,4 +1,4 @@
1
- var gN=Object.defineProperty;var S=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var Bf=(t,e)=>{for(var o in e)gN(t,o,{get:e[o],enumerable:!0})};var aa,gx=S(()=>{"use strict";aa="1.0.0-rc.13"});function Ln(t,e){return t.decide(e)}var jr=S(()=>{"use strict"});var en,Pn,Nn=S(()=>{"use strict";en="remember",Pn="recall"});var Uf,yN,qs,jf=S(()=>{"use strict";Uf=class{id;horizon;label;parentId;children;dependencies;pinned;closed;createdAt;lastAccessedAt;accessCount;context;constructor(e,o,n,r,s){this.id=e,this.horizon=o,this.label=n,this.parentId=r,this.children=new Set,this.dependencies=new Set,this.pinned=!1,this.closed=!1,this.createdAt=s,this.lastAccessedAt=s,this.accessCount=0,this.context=[]}touch(e){this.lastAccessedAt=e,this.accessCount+=1}snapshot(){return{id:this.id,horizon:this.horizon,label:this.label,parentId:this.parentId,children:[...this.children],dependencies:[...this.dependencies],pinned:this.pinned,closed:this.closed,createdAt:this.createdAt,lastAccessedAt:this.lastAccessedAt,accessCount:this.accessCount,contextSize:this.context.length}}},yN=200,qs=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??yN,this.now=e?.clock??Date.now}static boxId(e,o){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)}-${o.toString(36)}`}openBox(e,o,n,r){let s=this.nodes.get(e);if(s)return s.touch(this.now()),{box:s.snapshot(),created:!1};if(this.nodes.size>=this.maxBoxes&&(this.evictOne(),this.nodes.size>=this.maxBoxes))return null;let i=this.now(),a=new Uf(e,o,n,r??null,i);if(r){let c=this.nodes.get(r);c&&c.children.add(e)}return this.nodes.set(e,a),{box:a.snapshot(),created:!0}}closeBox(e){let o=this.nodes.get(e);return o?(o.closed=!0,o.touch(this.now()),o.snapshot()):null}isClosed(e){let o=this.nodes.get(e);return o?o.closed:!1}reopenBox(e){let o=this.nodes.get(e);return o?(o.closed=!1,o.touch(this.now()),o.snapshot()):null}setHorizon(e,o){let n=this.nodes.get(e);return n?(n.horizon=o,n.touch(this.now()),n.snapshot()):null}setParent(e,o){let n=this.nodes.get(e);return n?n.parentId===o?n.snapshot():o!==null&&this.wouldCreateCycle(e,o)?null:(n.parentId&&this.nodes.get(n.parentId)?.children.delete(e),n.parentId=o,o&&this.nodes.get(o)?.children.add(e),n.touch(this.now()),n.snapshot()):null}wouldCreateCycle(e,o){let n=new Set,r=o;for(;r!==null;){if(r===e||n.has(r))return!0;n.add(r),r=this.nodes.get(r)?.parentId??null}return!1}getBox(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),o.snapshot()):null}listBoxes(e="lastAccessedAt"){let o=[...this.nodes.values()].map(n=>n.snapshot());switch(e){case"createdAt":return o.sort((n,r)=>n.createdAt-r.createdAt);case"accessCount":return o.sort((n,r)=>r.accessCount-n.accessCount);default:return o.sort((n,r)=>r.lastAccessedAt-n.lastAccessedAt)}}get size(){return this.nodes.size}addContext(e,o){let n=this.nodes.get(e);return n?(n.context.push({ts:this.now(),text:o}),n.touch(this.now()),n.snapshot()):null}getContext(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),[...o.context]):[]}getContextChain(e){let o=[],n=new Set,r=e;for(;r&&!n.has(r);){n.add(r);let s=this.nodes.get(r);if(!s)break;s.touch(this.now()),o.push({boxId:s.id,entries:[...s.context]}),r=s.parentId}return o}addDependency(e,o){let n=this.nodes.get(e);return!n||!this.nodes.has(o)||n.id===o?!1:(n.dependencies.add(o),n.touch(this.now()),!0)}getDependencies(e){let o=this.nodes.get(e);return o?[...o.dependencies]:[]}pinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!0,o.touch(this.now()),o.snapshot()):null}unpinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!1,o.touch(this.now()),o.snapshot()):null}evictOne(){let e=[];for(let n of this.nodes.values())n.horizon==="longo"||n.pinned||e.push(n);if(e.length===0)return null;e.sort((n,r)=>{let s=n.horizon==="curto"?0:1,i=r.horizon==="curto"?0:1;if(s!==i)return s-i;let a=n.closed?0:1,c=r.closed?0:1;return a!==c?a-c:n.lastAccessedAt!==r.lastAccessedAt?n.lastAccessedAt-r.lastAccessedAt:n.accessCount-r.accessCount});let o=e[0];return this.removeNode(o)}forceEvict(e){let o=this.nodes.get(e);return!o||o.horizon==="longo"||o.pinned?null:this.removeNode(o)}removeBox(e){let o=this.nodes.get(e);return o?this.removeNode(o):null}removeNode(e){if(e.parentId){let o=this.nodes.get(e.parentId);o&&o.children.delete(e.id)}return this.nodes.delete(e.id),e.snapshot()}}});function rd(t){let e=[];for(let o of t){e.push({step:o,depth:0});for(let n of o.substeps??[])e.push({step:n,depth:1})}return e}function vx(t,e){let o,n="pending",r;if(typeof t=="string")o=t;else if(t!==null&&typeof t=="object"){let i=t,a=i.title??i.step??i.text??i.name??i.content;if(typeof a=="string"&&(o=a),typeof i.status=="string"&&bN.has(i.status)&&(n=i.status),e){let c=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(c)&&c.length>0){let l=[];for(let d of c){let f=vx(d,!1);if(typeof f=="string")return f;l.push(f)}r=l}}}if(o===void 0||o.trim()==="")return kN;let s=o.trim().slice(0,vN);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function xN(t){let e=t.steps??t.plan??t.todos??t.items;if(!Array.isArray(e))return{error:'update_plan: passe "steps" como uma LISTA de passos (string ou {title,status}).'};if(e.length===0)return{error:"update_plan: a lista de passos est\xE1 vazia."};let o=[];for(let i of e){let a=vx(i,!0);if(typeof a=="string")return{error:a};o.push(a)}let n=new Set,r=i=>{if(!n.has(i))return n.add(i),i;for(let a=2;;a++){let c=`${i} #${a}`;if(!n.has(c))return n.add(c),c}};for(let i=0;i<o.length;i++){let a=o[i],c=r(a.title),l=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=l!==void 0?{...a,title:c,substeps:l}:{...a,title:c}}let s=rd(o).length;return s>yx?{error:`update_plan: no m\xE1ximo ${yx} passos (recebidos ${s}).`}:{steps:o}}function SN(t){let e=rd(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${kx[r.step.status]} ${r.step.title}`).join(`
1
+ var gN=Object.defineProperty;var S=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var Bf=(t,e)=>{for(var o in e)gN(t,o,{get:e[o],enumerable:!0})};var aa,gx=S(()=>{"use strict";aa="1.0.0-rc.15"});function Ln(t,e){return t.decide(e)}var jr=S(()=>{"use strict"});var en,Pn,Nn=S(()=>{"use strict";en="remember",Pn="recall"});var Uf,yN,qs,jf=S(()=>{"use strict";Uf=class{id;horizon;label;parentId;children;dependencies;pinned;closed;createdAt;lastAccessedAt;accessCount;context;constructor(e,o,n,r,s){this.id=e,this.horizon=o,this.label=n,this.parentId=r,this.children=new Set,this.dependencies=new Set,this.pinned=!1,this.closed=!1,this.createdAt=s,this.lastAccessedAt=s,this.accessCount=0,this.context=[]}touch(e){this.lastAccessedAt=e,this.accessCount+=1}snapshot(){return{id:this.id,horizon:this.horizon,label:this.label,parentId:this.parentId,children:[...this.children],dependencies:[...this.dependencies],pinned:this.pinned,closed:this.closed,createdAt:this.createdAt,lastAccessedAt:this.lastAccessedAt,accessCount:this.accessCount,contextSize:this.context.length}}},yN=200,qs=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??yN,this.now=e?.clock??Date.now}static boxId(e,o){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)}-${o.toString(36)}`}openBox(e,o,n,r){let s=this.nodes.get(e);if(s)return s.touch(this.now()),{box:s.snapshot(),created:!1};if(this.nodes.size>=this.maxBoxes&&(this.evictOne(),this.nodes.size>=this.maxBoxes))return null;let i=this.now(),a=new Uf(e,o,n,r??null,i);if(r){let c=this.nodes.get(r);c&&c.children.add(e)}return this.nodes.set(e,a),{box:a.snapshot(),created:!0}}closeBox(e){let o=this.nodes.get(e);return o?(o.closed=!0,o.touch(this.now()),o.snapshot()):null}isClosed(e){let o=this.nodes.get(e);return o?o.closed:!1}reopenBox(e){let o=this.nodes.get(e);return o?(o.closed=!1,o.touch(this.now()),o.snapshot()):null}setHorizon(e,o){let n=this.nodes.get(e);return n?(n.horizon=o,n.touch(this.now()),n.snapshot()):null}setParent(e,o){let n=this.nodes.get(e);return n?n.parentId===o?n.snapshot():o!==null&&this.wouldCreateCycle(e,o)?null:(n.parentId&&this.nodes.get(n.parentId)?.children.delete(e),n.parentId=o,o&&this.nodes.get(o)?.children.add(e),n.touch(this.now()),n.snapshot()):null}wouldCreateCycle(e,o){let n=new Set,r=o;for(;r!==null;){if(r===e||n.has(r))return!0;n.add(r),r=this.nodes.get(r)?.parentId??null}return!1}getBox(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),o.snapshot()):null}listBoxes(e="lastAccessedAt"){let o=[...this.nodes.values()].map(n=>n.snapshot());switch(e){case"createdAt":return o.sort((n,r)=>n.createdAt-r.createdAt);case"accessCount":return o.sort((n,r)=>r.accessCount-n.accessCount);default:return o.sort((n,r)=>r.lastAccessedAt-n.lastAccessedAt)}}get size(){return this.nodes.size}addContext(e,o){let n=this.nodes.get(e);return n?(n.context.push({ts:this.now(),text:o}),n.touch(this.now()),n.snapshot()):null}getContext(e){let o=this.nodes.get(e);return o?(o.touch(this.now()),[...o.context]):[]}getContextChain(e){let o=[],n=new Set,r=e;for(;r&&!n.has(r);){n.add(r);let s=this.nodes.get(r);if(!s)break;s.touch(this.now()),o.push({boxId:s.id,entries:[...s.context]}),r=s.parentId}return o}addDependency(e,o){let n=this.nodes.get(e);return!n||!this.nodes.has(o)||n.id===o?!1:(n.dependencies.add(o),n.touch(this.now()),!0)}getDependencies(e){let o=this.nodes.get(e);return o?[...o.dependencies]:[]}pinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!0,o.touch(this.now()),o.snapshot()):null}unpinBox(e){let o=this.nodes.get(e);return o?(o.pinned=!1,o.touch(this.now()),o.snapshot()):null}evictOne(){let e=[];for(let n of this.nodes.values())n.horizon==="longo"||n.pinned||e.push(n);if(e.length===0)return null;e.sort((n,r)=>{let s=n.horizon==="curto"?0:1,i=r.horizon==="curto"?0:1;if(s!==i)return s-i;let a=n.closed?0:1,c=r.closed?0:1;return a!==c?a-c:n.lastAccessedAt!==r.lastAccessedAt?n.lastAccessedAt-r.lastAccessedAt:n.accessCount-r.accessCount});let o=e[0];return this.removeNode(o)}forceEvict(e){let o=this.nodes.get(e);return!o||o.horizon==="longo"||o.pinned?null:this.removeNode(o)}removeBox(e){let o=this.nodes.get(e);return o?this.removeNode(o):null}removeNode(e){if(e.parentId){let o=this.nodes.get(e.parentId);o&&o.children.delete(e.id)}return this.nodes.delete(e.id),e.snapshot()}}});function rd(t){let e=[];for(let o of t){e.push({step:o,depth:0});for(let n of o.substeps??[])e.push({step:n,depth:1})}return e}function vx(t,e){let o,n="pending",r;if(typeof t=="string")o=t;else if(t!==null&&typeof t=="object"){let i=t,a=i.title??i.step??i.text??i.name??i.content;if(typeof a=="string"&&(o=a),typeof i.status=="string"&&bN.has(i.status)&&(n=i.status),e){let c=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(c)&&c.length>0){let l=[];for(let d of c){let f=vx(d,!1);if(typeof f=="string")return f;l.push(f)}r=l}}}if(o===void 0||o.trim()==="")return kN;let s=o.trim().slice(0,vN);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function xN(t){let e=t.steps??t.plan??t.todos??t.items;if(!Array.isArray(e))return{error:'update_plan: passe "steps" como uma LISTA de passos (string ou {title,status}).'};if(e.length===0)return{error:"update_plan: a lista de passos est\xE1 vazia."};let o=[];for(let i of e){let a=vx(i,!0);if(typeof a=="string")return{error:a};o.push(a)}let n=new Set,r=i=>{if(!n.has(i))return n.add(i),i;for(let a=2;;a++){let c=`${i} #${a}`;if(!n.has(c))return n.add(c),c}};for(let i=0;i<o.length;i++){let a=o[i],c=r(a.title),l=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=l!==void 0?{...a,title:c,substeps:l}:{...a,title:c}}let s=rd(o).length;return s>yx?{error:`update_plan: no m\xE1ximo ${yx} passos (recebidos ${s}).`}:{steps:o}}function SN(t){let e=rd(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${kx[r.step.status]} ${r.step.title}`).join(`
2
2
  `);return`plano (${o}/${e.length}):
3
3
  ${n}`}function AN(t,e){return e<0?"m\xE9dio":t===e?"curto":t>e?"longo":"m\xE9dio"}function EN(t,e){let o=new Map;for(let i of e.listBoxes())o.set(i.label,i.id);let n=t.findIndex(i=>i.status==="in_progress"||(i.substeps??[]).some(a=>a.status==="in_progress")),r=(i,a,c)=>{let l=i.status==="in_progress"?"curto":c,d=o.get(i.title),f=d??qs.boxId(i.title,0);return d?(i.status!=="completed"&&e.isClosed(d)&&e.reopenBox(d),e.setHorizon(d,l),e.setParent(d,a)):e.openBox(f,l,i.title,a),i.status==="completed"&&!e.isClosed(f)&&e.closeBox(f),o.set(i.title,f),f};t.forEach((i,a)=>{let c=AN(a,n),l=r(i,null,c);for(let d of i.substeps??[])r(d,l,c)});let s=new Set;for(let i of t){s.add(i.title);for(let a of i.substeps??[])s.add(a.title)}for(let i of e.listBoxes())s.has(i.label)||e.removeBox(i.id)}function TN(t,e){if(!e)return SN(t);let o=new Map;for(let l of e.listBoxes())o.set(l.label,l);let n=new Map;for(let l of e.listBoxes())n.set(l.id,l);let r=new Map,s=(l,d=new Set)=>{let f=r.get(l);if(f!==void 0)return f;let u=n.get(l);if(!u||!u.parentId||d.has(l))return r.set(l,0),0;let p=s(u.parentId,new Set(d).add(l))+1;return r.set(l,p),p},i=rd(t),c=[`plano (${i.filter(l=>l.step.status==="completed").length}/${i.length}):`];for(let{step:l,depth:d}of i){let f=o.get(l.title),u=f?wN[f.horizon]:"",p=f?s(f.id):d,h=" ".repeat(p),y=kx[l.status];c.push(`${h}${u} ${y} ${l.title}`)}return c.join(`
4
4
  `)}var ca,bN,yx,vN,kN,kx,wN,bx,_N,xx,sd=S(()=>{"use strict";jf();ca="update_plan";bN=new Set(["pending","in_progress","completed"]),yx=30,vN=120,kN="update_plan: cada passo precisa de um t\xEDtulo (texto) n\xE3o-vazio.";kx={pending:"\u2610",in_progress:"\u25B6",completed:"\u2611"};wN={longo:"[\u{1F4D0}]",m\u00E9dio:"[\u{1F4CB}]",curto:"[\u{1F4CC}]"};bx=Object.freeze({type:"string",enum:["pending","in_progress","completed"],description:"pending (a fazer) \xB7 in_progress (em curso) \xB7 completed (feito)."}),_N=Object.freeze({type:"object",properties:{steps:{type:"array",description:"A lista COMPLETA de passos do plano (re-emita TODOS a cada atualiza\xE7\xE3o \u2014 substitui o anterior).",items:{type:"object",properties:{title:{type:"string",description:"O passo, curto e no imperativo."},status:bx,substeps:{type:"array",description:"OPCIONAL: sub-passos que detalham este passo (1 n\xEDvel). Aparecem indentados sob o passo e seguem o foco dele. Use quando um passo tem a\xE7\xF5es menores distintas.",items:{type:"object",properties:{title:{type:"string",description:"O sub-passo, curto e no imperativo."},status:bx},required:["title"],additionalProperties:!1}}},required:["title"],additionalProperties:!1}}},required:["steps"],additionalProperties:!1}),xx={name:ca,effect:"read",description:"Declara/atualiza um PLANO vis\xEDvel (checklist de passos). Use ao iniciar uma tarefa com V\xC1RIOS passos e a cada progresso: re-emita a lista TODA marcando o status de cada passo (pending/in_progress/completed). Mantenha 1 passo in_progress por vez. N\xE3o tem efeito no sistema \u2014 \xE9 s\xF3 o seu plano, para voc\xEA e para o usu\xE1rio acompanharem.",parameters:_N,async run(t,e){let o=xN(t);return"error"in o?{ok:!1,observation:o.error}:(e.graph&&EN(o.steps,e.graph),e.plan&&e.plan.set(rd(o.steps).map(r=>({title:r.step.title,status:r.step.status}))),{ok:!0,observation:TN(o.steps,e.graph)})}}});function Sx(t){let e=t.question??t.prompt??t.text??t.message;if(typeof e!="string"||e.trim()==="")return{error:'perguntar: passe "question" (a pergunta em texto). Para escolha, passe tamb\xE9m "options".'};let o=e.trim().slice(0,2e3),n=t.header??t.title,r=typeof n=="string"&&n.trim()!==""?n.trim().slice(0,200):void 0,s=t.options??t.choices,i=Array.isArray(s)?CN(s):void 0;if(typeof i=="string")return{error:i};let a,c=t.kind??t.type;if(typeof c=="string"&&RN.has(c))a=c;else{if(typeof c=="string"&&c.trim()!=="")return{error:`perguntar: "kind" inv\xE1lido "${c}". Use "single", "multi" ou "text".`};a=i!==void 0&&i.length>0?"single":"text"}if((a==="single"||a==="multi")&&(i===void 0||i.length===0))return{error:`perguntar: kind "${a}" requer "options" (uma lista de ao menos 1 op\xE7\xE3o).`};let l=t.allowOther!==!1;return{spec:{kind:a,question:o,...r!==void 0?{header:r}:{},...a!=="text"&&i!==void 0?{options:i}:{},...a!=="text"?{allowOther:l}:{}}}}function CN(t){if(t.length===0)return'perguntar: a lista de "options" est\xE1 vazia.';if(t.length>12)return`perguntar: no m\xE1ximo 12 op\xE7\xF5es (recebidas ${t.length}).`;let e=[];for(let o of t){let n,r;if(typeof o=="string")n=o;else if(o!==null&&typeof o=="object"){let s=o,i=s.label??s.text??s.value??s.name??s.title;typeof i=="string"&&(n=i),typeof s.description=="string"&&s.description.trim()!==""&&(r=s.description.trim().slice(0,300))}if(n===void 0||n.trim()==="")return'perguntar: cada op\xE7\xE3o precisa de um "label" (texto) n\xE3o-vazio.';e.push({label:n.trim().slice(0,200),...r!==void 0?{description:r}:{}})}return e}function ON(t){switch(t.kind){case"choice":return t.label;case"choices":return t.labels.length===0?"(nenhuma)":t.labels.join(", ");case"text":{let e=t.text.split(`
@@ -135,7 +135,7 @@ ${t.trim()}`}}function vT(t,e,o=pc){let{older:n,recent:r}=Tu(t,o);if(n.length===
135
135
  \u2026[truncado: ${t.length-Oy} chars omitidos]`}function yB(t){return t.length<=Ly?t:`${t.slice(0,Ly)}\u2026`}function o_(t){let e=t_(t.server,t.descriptor.name),o=yB(t.descriptor.description.trim()),n=`[tool de um SERVER MCP de terceiro "${t.server}" \u2014 efeito n\xE3o-confi\xE1vel, passa pela catraca] ${o||"(sem descri\xE7\xE3o)"}`,r=t.descriptor.inputSchema,s=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;return{name:e,effect:"mcp",description:n,...s?{parameters:s}:{},async run(i,a,c){try{let l=await t.transport.callTool(t.descriptor.name,i,c?.signal),d=Ue(l.content);return l.ok?{ok:!0,observation:e_(d),display:`${e}(${bB(i)})`}:{ok:!1,observation:e_(`MCP "${e}" erro: ${d}`)}}catch(l){return{ok:!1,observation:`MCP "${e}" falhou: ${l instanceof Error?l.message:String(l)}`}}}}}function Py(t,e){let o=[],n=new Set,r=new Map,s=new Map,i=new Set;for(let a of t){let c=o_(a);if(n.has(c.name))continue;n.add(c.name);let l=a.server;s.set(l,(s.get(l)??0)+1);let d=r.get(l)??0;if(d>=My){i.add(l);continue}r.set(l,d+1),o.push(c)}if(e)for(let a of i){let c=s.get(a)??0;e(`server MCP "${a}" exp\xF4s ${c} tools; usando as primeiras ${My} (teto por server, anti-estouro de contexto). As demais foram ignoradas \u2014 revise o server ou reduza as tools que ele exp\xF5e.`)}return o}function bB(t){if(Object.keys(t).length===0)return"";let o=JSON.stringify(t);return o.length<=200?o:`${o.slice(0,200)}\u2026`}var Oy,My,Ly,n_=S(()=>{"use strict";cd();Bn();Oy=2e4;My=128,Ly=1024});function i_(t,e){let o=new URL(s_);return t.trim().length>0&&o.searchParams.set("search",t.trim()),o.searchParams.set("limit",String(kB)),e!==void 0&&e.length>0&&o.searchParams.set("cursor",e),o.toString()}async function Iy(t,e,o){let n=t.trim(),r=[],s;for(let i=0;i<vB;i++){let a=i_(n,s),c;try{c=await e(a,o)}catch(f){return{ok:!1,query:n,reason:Iu(TB(f))}}if(!c.ok)return{ok:!1,query:n,reason:Iu(c.reason)};if(c.status<200||c.status>=300)return{ok:!1,query:n,reason:Iu(`HTTP ${c.status}`)};let l;try{l=JSON.parse(c.body)}catch{return{ok:!1,query:n,reason:Iu("resposta n\xE3o \xE9 JSON v\xE1lido")}}let d=c_(l);for(let f of d.servers)if(a_(f,n)&&r.push(f),r.length>=Ny)break;if(r.length>=Ny||(s=d.nextCursor,s===void 0||s.length===0))break}return{ok:!0,query:n,results:r}}function Iu(t){return`registro MCP indispon\xEDvel (${bi}): ${t}`}function a_(t,e){if(e.length===0)return!0;let o=e.toLowerCase();return[t.name,t.title??"",t.description,t.run.command??"",t.run.args.join(" ")].join(" ").toLowerCase().includes(o)}function c_(t){if(!qn(t))return{servers:[]};let e=Array.isArray(t.servers)?t.servers:[],o=[];for(let s of e){let i=xB(s);i!==void 0&&o.push(i)}let n=qn(t.metadata)?t.metadata:void 0,r=n!==void 0&&typeof n.nextCursor=="string"?n.nextCursor:void 0;return{servers:o,...r!==void 0?{nextCursor:r}:{}}}function xB(t){if(!qn(t))return;let e=qn(t.server)?t.server:t,o=typeof e.name=="string"?e.name.trim():"";if(o.length===0)return;let n=typeof e.description=="string"?e.description.trim():"",r=typeof e.title=="string"&&e.title.trim().length>0?e.title.trim():void 0,s=typeof e.version=="string"?e.version.trim():void 0,i=SB(e);return{name:o,description:n,run:i,...r!==void 0?{title:r}:{},...s!==void 0?{version:s}:{}}}function SB(t){let e=[],o=Array.isArray(t.remotes)?t.remotes:[];for(let r of o)qn(r)&&typeof r.url=="string"&&e.push(r.url);let n=Array.isArray(t.packages)?t.packages:[];for(let r of n){if(!qn(r))continue;let s=wB(r);if(s!==void 0)return{...s,remoteUrls:e}}return{args:[],env:[],remoteUrls:e}}function wB(t){let e=as(t.registryType)??as(t.registry_name),o=as(t.identifier)??as(t.name);if(o===void 0)return;let n=as(t.version),r=as(t.runtimeHint),s=qn(t.transport)?as(t.transport.type):void 0,i=EB(t.environmentVariables),a=r_(t.runtimeArguments),c=r_(t.packageArguments),l=n!==void 0?`${o}@${n}`:o;return e==="npm"||r==="npx"?{command:"npx",args:AB(["-y",...a,l,...c]),env:i,...s!==void 0?{transport:s}:{}}:e==="pypi"||r==="uvx"||r==="uv"?{command:"uvx",args:[...a,o,...c],env:i,...s!==void 0?{transport:s}:{}}:e==="oci"||r==="docker"?{command:"docker",args:["run","-i","--rm",...a,l,...c],env:i,...s!==void 0?{transport:s}:{}}:{args:[l],env:i,...s!==void 0?{transport:s}:{}}}function AB(t){let e=[],o=!1;for(let n of t){if(n==="-y"||n==="--yes"){if(o)continue;o=!0}e.push(n)}return e}function r_(t){if(!Array.isArray(t))return[];let e=[];for(let o of t)qn(o)&&typeof o.value=="string"&&e.push(o.value);return e}function EB(t){if(!Array.isArray(t))return[];let e=[];for(let o of t)qn(o)&&typeof o.name=="string"&&o.name.length>0&&e.push({name:o.name,required:o.isRequired===!0});return e}function as(t){return typeof t=="string"&&t.trim().length>0?t.trim():void 0}function qn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function TB(t){return t instanceof Error?t.message:String(t)}var bi,s_,vB,kB,Ny,l_=S(()=>{"use strict";bi="registry.modelcontextprotocol.io",s_=`https://${bi}/v0/servers`,vB=5,kB=100,Ny=25});function u_(t){let{command:e,args:o}=t.run;if(e===void 0)return;let n=m_(t.name);return["aluy","mcp","add",d_(n),"--",e,...o.map(d_)].join(" ")}function m_(t){let o=(t.split("/").pop()??t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return o.length>0?o:"server"}function d_(t){return/^[A-Za-z0-9_./@:+=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Dy(t){if(!t.ok)return`\u26A0 ${t.reason}
136
136
  Tente de novo em instantes; a busca no registro n\xE3o bloqueia o resto do aluy.`;if(t.results.length===0)return`nenhum server encontrado para "${t.query}" no registro oficial MCP.`;let e=[],o=t.results.length;e.push(`${o} server${o===1?"":"s"} para "${t.query}" (registro oficial MCP):`),e.push("");for(let n of t.results)e.push(_B(n)),e.push("");return e.push('Para instalar, copie a linha "\u2192 aluy mcp add \u2026" do server desejado.'),e.push("A sa\xEDda do registro \xE9 apenas informativa \u2014 nada \xE9 executado pela busca."),e.join(`
137
137
  `)}function _B(t){let o=[`\u2022 ${t.version!==void 0?`${t.name} (v${t.version})`:t.name}`],n=t.title!==void 0&&t.title!==t.name?t.title:void 0;n!==void 0&&o.push(` ${n}`),t.description.length>0&&o.push(` ${RB(t.description,200)}`);let r=u_(t);if(r!==void 0){o.push(` \u2192 ${r}`),t.run.transport!==void 0&&t.run.transport!=="stdio"&&o.push(` (transporte "${t.run.transport}" \u2014 v1 do aluy s\xF3 pluga servers stdio LOCAIS)`);let s=t.run.env.filter(i=>i.required).map(i=>i.name);s.length>0&&o.push(` requer env: ${s.join(", ")} (defina por-server no mcp.json)`)}else t.run.remoteUrls.length>0?o.push(` (server REMOTO: ${t.run.remoteUrls.join(", ")} \u2014 fora do v1 de \`aluy mcp add\`)`):o.push(" (sem pacote local conhecido \u2014 nada a instalar pelo aluy)");return o.join(`
138
- `)}function RB(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"\u2026"}var f_=S(()=>{"use strict"});var p_=S(()=>{"use strict";Nu();YT();VT();XT();JT();ZT();n_();cd();l_();f_()});function $y(t){let e=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(t.trim());if(!e)return null;let o=e[4]?e[4].split(".").map(n=>/^\d+$/.test(n)?Number(n):n):[];return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),pre:o}}function h_(t,e){let o=$y(t),n=$y(e);if(!o||!n)return null;for(let s of["major","minor","patch"])if(o[s]!==n[s])return o[s]<n[s]?-1:1;if(o.pre.length===0&&n.pre.length===0)return 0;if(o.pre.length===0)return 1;if(n.pre.length===0)return-1;let r=Math.max(o.pre.length,n.pre.length);for(let s=0;s<r;s++){let i=o.pre[s],a=n.pre[s];if(i===void 0)return-1;if(a===void 0)return 1;if(i===a)continue;let c=typeof i=="number",l=typeof a=="number";return c&&l?i<a?-1:1:c?-1:l?1:i<a?-1:1}return 0}function Fy(t,e){return h_(t,e)===1}var g_=S(()=>{"use strict"});var By=S(()=>{"use strict"});var y_=S(()=>{"use strict";By()});var b_=S(()=>{"use strict"});var v_=S(()=>{"use strict"});var k_=S(()=>{"use strict"});var j=S(()=>{"use strict";gx();jx();eS();vw();$T();GT();p_();yy();mu();g_();By();y_();b_();v_();k_()});import{posix as XU}from"node:path";function JU(t){return XU.normalize(t)}function Jt(t){let e=JU(t);for(let o of QU)if(o.re.test(e))return o.deny?{kind:"deny",why:o.why}:{kind:"ask",why:o.why};return{kind:"allow"}}function rb(t){return Jt(t).kind==="allow"}var QU,xr=S(()=>{"use strict";QU=[{re:/(?:^|\/|~\/)\.ssh(?:\/|$)/,why:"chaves SSH (~/.ssh)",deny:!0},{re:/(?:^|\/|~\/)\.aws(?:\/|$)/,why:"credenciais AWS (~/.aws)",deny:!0},{re:/(?:^|\/|~\/)\.gnupg(?:\/|$)/,why:"chaves GPG (~/.gnupg)",deny:!0},{re:/(?:~\/|\$\{?HOME\}?\/|\/(?:home|Users)\/[^/]+\/)\.aluy\/rooms(?:\/|$)/,why:"arquivos de sala do Aluy (~/.aluy/rooms)",deny:!0},{re:/~\/\.aluy(?:\/|$)/,why:"estado/credencial do Aluy (~/.aluy)",deny:!0},{re:/(?:^|\/)\.aluy(?:\/(?!agents\/|workflows\/|commands\/)|$)/,why:"estado/credencial do Aluy (.aluy/)",deny:!0},{re:/(?:^|\/|~\/)\.config\/gh\/hosts\.yml$/,why:"token do gh CLI",deny:!0},{re:/(?:^|\/|~\/)\.docker\/config\.json$/,why:"credenciais Docker",deny:!0},{re:/(?:^|\/|~\/)\.kube\/config$/,why:"kubeconfig",deny:!0},{re:/(?:^|\/)id_(?:rsa|ed25519|ecdsa|dsa)\b/,why:"chave privada",deny:!0},{re:/\.pem$|\.p12$|\.pfx$|\.key$/i,why:"material de chave privada",deny:!0},{re:/(?:^|[/\w.-])\.env(?:\.(?!example$|sample$|template$|dist$)[\w.-]+)?$/,why:"arquivo .env (segredos)",deny:!1},{re:/(?:^|\/)[^/]*(?:secret|credential|token|apikey|api_key|password|passwd)[^/]*$/i,why:"arquivo com nome sens\xEDvel (token/secret)",deny:!1}]});var _b={};Bf(_b,{UserWorkflowsLoader:()=>_i,WORKFLOWS_DIRNAME:()=>Tb});import{homedir as IH}from"node:os";import{join as Eb}from"node:path";import{readdirSync as DH,readFileSync as $H,mkdirSync as FH,statSync as BH}from"node:fs";var UH,Tb,jH,HH,_i,om=S(()=>{"use strict";j();UH=448,Tb="workflows",jH=64*1024,HH=256,_i=class{dir;constructor(e={}){let o=e.baseDir??Eb(IH(),".aluy");this.dir=Eb(o,Tb)}get workflowsDir(){return this.dir}ensureDir(){try{FH(this.dir,{mode:UH,recursive:!0})}catch{}}load(){let e;try{e=DH(this.dir,{withFileTypes:!0})}catch{return{workflows:[],errors:[]}}let o=e.filter(i=>i.isFile()&&i.name.toLowerCase().endsWith(".md")).map(i=>i.name).sort((i,a)=>i.localeCompare(a)),n=new Set,r=[],s=[];for(let i of o){if(r.length>=HH)break;let a=this.readOne(i);if(a!==null){if(nc(a)){s.push(a);continue}n.has(a.name)||(n.add(a.name),r.push(a))}}return{workflows:r,errors:s}}readOne(e){let o=Eb(this.dir,e);try{let n=BH(o);if(!n.isFile()||n.size>jH)return null;let r=$H(o,"utf8");return rc(e,r,"global")}catch{return null}}}});var Cb={};Bf(Cb,{PROJECT_WORKFLOWS_DIRNAMES:()=>Rb,ProjectWorkflowsLoader:()=>Ri});import{join as qH}from"node:path";import{readdirSync as WH,readFileSync as GH,statSync as zH}from"node:fs";var Rb,KH,YH,Ri,nm=S(()=>{"use strict";j();xr();Rb=[".claude/workflows",".aluy/workflows"],KH=64*1024,YH=256,Ri=class{workspace;constructor(e){this.workspace=e.workspace}load(){let e=new Set,o=[],n=[];for(let r of Rb){let s;try{s=this.workspace.resolveInside(r)}catch{continue}let i;try{i=WH(s,{withFileTypes:!0})}catch{continue}let a=i.filter(c=>c.isFile()&&c.name.toLowerCase().endsWith(".md")).map(c=>c.name).sort((c,l)=>c.localeCompare(l));for(let c of a){if(o.length>=YH)break;let l=this.readOne(r,s,c);if(l!==null){if(nc(l)){n.push(l);continue}e.has(l.name)||(e.add(l.name),o.push(l))}}}return{workflows:o,errors:n}}readOne(e,o,n){let r=`${e}/${n}`;if(Jt(r).kind!=="allow")return null;let s=qH(o,n);try{this.workspace.resolveInside(r);let i=zH(s);if(!i.isFile()||i.size>KH)return null;let a=GH(s,"utf8");return rc(n,a,"project")}catch{return null}}}});var Mn="1.0.0-rc.13";j();var x_=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
138
+ `)}function RB(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"\u2026"}var f_=S(()=>{"use strict"});var p_=S(()=>{"use strict";Nu();YT();VT();XT();JT();ZT();n_();cd();l_();f_()});function $y(t){let e=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(t.trim());if(!e)return null;let o=e[4]?e[4].split(".").map(n=>/^\d+$/.test(n)?Number(n):n):[];return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),pre:o}}function h_(t,e){let o=$y(t),n=$y(e);if(!o||!n)return null;for(let s of["major","minor","patch"])if(o[s]!==n[s])return o[s]<n[s]?-1:1;if(o.pre.length===0&&n.pre.length===0)return 0;if(o.pre.length===0)return 1;if(n.pre.length===0)return-1;let r=Math.max(o.pre.length,n.pre.length);for(let s=0;s<r;s++){let i=o.pre[s],a=n.pre[s];if(i===void 0)return-1;if(a===void 0)return 1;if(i===a)continue;let c=typeof i=="number",l=typeof a=="number";return c&&l?i<a?-1:1:c?-1:l?1:i<a?-1:1}return 0}function Fy(t,e){return h_(t,e)===1}var g_=S(()=>{"use strict"});var By=S(()=>{"use strict"});var y_=S(()=>{"use strict";By()});var b_=S(()=>{"use strict"});var v_=S(()=>{"use strict"});var k_=S(()=>{"use strict"});var j=S(()=>{"use strict";gx();jx();eS();vw();$T();GT();p_();yy();mu();g_();By();y_();b_();v_();k_()});import{posix as XU}from"node:path";function JU(t){return XU.normalize(t)}function Jt(t){let e=JU(t);for(let o of QU)if(o.re.test(e))return o.deny?{kind:"deny",why:o.why}:{kind:"ask",why:o.why};return{kind:"allow"}}function rb(t){return Jt(t).kind==="allow"}var QU,xr=S(()=>{"use strict";QU=[{re:/(?:^|\/|~\/)\.ssh(?:\/|$)/,why:"chaves SSH (~/.ssh)",deny:!0},{re:/(?:^|\/|~\/)\.aws(?:\/|$)/,why:"credenciais AWS (~/.aws)",deny:!0},{re:/(?:^|\/|~\/)\.gnupg(?:\/|$)/,why:"chaves GPG (~/.gnupg)",deny:!0},{re:/(?:~\/|\$\{?HOME\}?\/|\/(?:home|Users)\/[^/]+\/)\.aluy\/rooms(?:\/|$)/,why:"arquivos de sala do Aluy (~/.aluy/rooms)",deny:!0},{re:/~\/\.aluy(?:\/|$)/,why:"estado/credencial do Aluy (~/.aluy)",deny:!0},{re:/(?:^|\/)\.aluy(?:\/(?!agents\/|workflows\/|commands\/)|$)/,why:"estado/credencial do Aluy (.aluy/)",deny:!0},{re:/(?:^|\/|~\/)\.config\/gh\/hosts\.yml$/,why:"token do gh CLI",deny:!0},{re:/(?:^|\/|~\/)\.docker\/config\.json$/,why:"credenciais Docker",deny:!0},{re:/(?:^|\/|~\/)\.kube\/config$/,why:"kubeconfig",deny:!0},{re:/(?:^|\/)id_(?:rsa|ed25519|ecdsa|dsa)\b/,why:"chave privada",deny:!0},{re:/\.pem$|\.p12$|\.pfx$|\.key$/i,why:"material de chave privada",deny:!0},{re:/(?:^|[/\w.-])\.env(?:\.(?!example$|sample$|template$|dist$)[\w.-]+)?$/,why:"arquivo .env (segredos)",deny:!1},{re:/(?:^|\/)[^/]*(?:secret|credential|token|apikey|api_key|password|passwd)[^/]*$/i,why:"arquivo com nome sens\xEDvel (token/secret)",deny:!1}]});var _b={};Bf(_b,{UserWorkflowsLoader:()=>_i,WORKFLOWS_DIRNAME:()=>Tb});import{homedir as IH}from"node:os";import{join as Eb}from"node:path";import{readdirSync as DH,readFileSync as $H,mkdirSync as FH,statSync as BH}from"node:fs";var UH,Tb,jH,HH,_i,om=S(()=>{"use strict";j();UH=448,Tb="workflows",jH=64*1024,HH=256,_i=class{dir;constructor(e={}){let o=e.baseDir??Eb(IH(),".aluy");this.dir=Eb(o,Tb)}get workflowsDir(){return this.dir}ensureDir(){try{FH(this.dir,{mode:UH,recursive:!0})}catch{}}load(){let e;try{e=DH(this.dir,{withFileTypes:!0})}catch{return{workflows:[],errors:[]}}let o=e.filter(i=>i.isFile()&&i.name.toLowerCase().endsWith(".md")).map(i=>i.name).sort((i,a)=>i.localeCompare(a)),n=new Set,r=[],s=[];for(let i of o){if(r.length>=HH)break;let a=this.readOne(i);if(a!==null){if(nc(a)){s.push(a);continue}n.has(a.name)||(n.add(a.name),r.push(a))}}return{workflows:r,errors:s}}readOne(e){let o=Eb(this.dir,e);try{let n=BH(o);if(!n.isFile()||n.size>jH)return null;let r=$H(o,"utf8");return rc(e,r,"global")}catch{return null}}}});var Cb={};Bf(Cb,{PROJECT_WORKFLOWS_DIRNAMES:()=>Rb,ProjectWorkflowsLoader:()=>Ri});import{join as qH}from"node:path";import{readdirSync as WH,readFileSync as GH,statSync as zH}from"node:fs";var Rb,KH,YH,Ri,nm=S(()=>{"use strict";j();xr();Rb=[".claude/workflows",".aluy/workflows"],KH=64*1024,YH=256,Ri=class{workspace;constructor(e){this.workspace=e.workspace}load(){let e=new Set,o=[],n=[];for(let r of Rb){let s;try{s=this.workspace.resolveInside(r)}catch{continue}let i;try{i=WH(s,{withFileTypes:!0})}catch{continue}let a=i.filter(c=>c.isFile()&&c.name.toLowerCase().endsWith(".md")).map(c=>c.name).sort((c,l)=>c.localeCompare(l));for(let c of a){if(o.length>=YH)break;let l=this.readOne(r,s,c);if(l!==null){if(nc(l)){n.push(l);continue}e.has(l.name)||(e.add(l.name),o.push(l))}}}return{workflows:o,errors:n}}readOne(e,o,n){let r=`${e}/${n}`;if(Jt(r).kind!=="allow")return null;let s=qH(o,n);try{this.workspace.resolveInside(r);let i=zH(s);if(!i.isFile()||i.size>KH)return null;let a=GH(s,"utf8");return rc(n,a,"project")}catch{return null}}}});var Mn="1.0.0-rc.15";j();var x_=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
139
139
 
140
140
  Uso:
141
141
  aluy ["objetivo"] [--plan | --yolo] [--dense] [--tier <tier>] [--lang <pt-BR|en>]
@@ -444,7 +444,7 @@ ${jo(w)}`}}catch(h){let y=d?`o proxy n\xE3o respondeu em ${f}ms (timeout)`:h ins
444
444
  ${r.text}`).join(`
445
445
 
446
446
  `),n=Hd(o);return{...n!==void 0?{instructions:n}:{},sources:e.map(r=>r.filename)}}async function ZU(t){return gR(Sr,t)}import{homedir as sj}from"node:os";import{join as LR}from"node:path";import{randomBytes as ij}from"node:crypto";import{openSync as aj,writeSync as cj,closeSync as PR,readFileSync as lj,mkdirSync as dj,renameSync as uj,unlinkSync as mj,constants as ub}from"node:fs";var Xu={fg:{color:"#F2EEE8"},fgDim:{color:"#8A7F6D",dimColor:!0},accent:{color:"#DDA13F",bold:!0},accentDim:{color:"#A66A14",bold:!0},danger:{color:"#E5897C",bold:!0},success:{color:"#82CF9E"},depth:{color:"#5BA8A2"}},Ju={fg:{color:"#1A1712"},fgDim:{color:"#544B3C"},accent:{color:"#82530F",bold:!0},accentDim:{color:"#82530F",bold:!0},danger:{color:"#B23A2A",bold:!0},success:{color:"#1F6B3A"},depth:{color:"#2E6E69"}},yR={fg:{color:"white"},fgDim:{color:"gray",dimColor:!0},accent:{color:"yellow",bold:!0},accentDim:{color:"yellow",bold:!0},danger:{color:"red",bold:!0},success:{color:"green"},depth:{color:"cyan"}},bR={fg:{color:"black"},fgDim:{color:"gray",dimColor:!0},accent:{color:"yellow",bold:!0},accentDim:{color:"yellow",bold:!0},danger:{color:"red",bold:!0},success:{color:"green"},depth:{color:"cyan"}},vR={fg:{color:"#F2EEE8"},fgDim:{color:"#B0A593",dimColor:!0},accent:{color:"#DDA13F",bold:!0},accentDim:{color:"#A66A14",bold:!0},danger:{color:"#E5897C",bold:!0},success:{color:"#82CF9E"},depth:{color:"#5BA8A2"}},kR={fg:{},fgDim:{dimColor:!0},accent:{bold:!0},accentDim:{bold:!0},danger:{bold:!0,inverse:!0},success:{},depth:{}};var xR={you:"\u258C",aluy:"\u039B",tool:"\u23FA",toolInflight:"\u25CB",wave:"~",waveHead:"\u203A",ask:"\u26A0",ok:"\u2713",err:"\u2717",broker:"\u25CF",clock:"\u25F7",gauge:"\u25D4",window:"\u25A1",branch:"\u2387",diffDel:"\u2039",diffAdd:"\u203A",prompt:"\u203A",cursor:"\u25CF",thinkingCursor:"\u25CF",planMode:"\u25D1",normalMode:"\u25C7",subagents:"+",sessionDot:"\u25CF",barFull:"\u25B0",barEmpty:"\u25B1"},SR={you:"\u258C",aluy:"\u039B",tool:"\u25CF",toolInflight:"\u25CB",wave:"~",waveHead:">",ask:"!",ok:"\u221A",err:"x",broker:"\u25CF",clock:"o",gauge:"\u25D4",window:"\u25A1",branch:"Y",diffDel:"<",diffAdd:">",prompt:">",cursor:"\u25CF",thinkingCursor:"\u25CF",planMode:"\u25D1",normalMode:"\u25C7",subagents:"+",sessionDot:"\u25CF",barFull:"\u2588",barEmpty:"\u2591"},wR={you:">",aluy:"/\\",tool:"o",toolInflight:".",wave:"~",waveHead:">",ask:"!",ok:"[ok]",err:"[x]",broker:"(b)",clock:"t:",gauge:"%:",window:"ctx:",branch:"git:",diffDel:"-",diffAdd:"+",prompt:">",cursor:"*",thinkingCursor:"*",planMode:"[plan]",normalMode:"*",subagents:"(+)",sessionDot:"*",barFull:"#",barEmpty:"."},AR=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],ER=["-","\\","|","/"],TR={topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",teeLeft:"\u251C",teeRight:"\u2524"},_R={topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|",teeLeft:"+",teeRight:"+"};var $c=[{name:"ambar",darkHex:"#DDA13F",lightHex:"#82530F",ansi:"yellow"},{name:"verde",darkHex:"#82CF9E",lightHex:"#1F6B3A",ansi:"green"},{name:"teal",darkHex:"#5BA8A2",lightHex:"#2E6E69",ansi:"cyan"},{name:"azul",darkHex:"#6FA8DC",lightHex:"#1F5C99",ansi:"blue"},{name:"violeta",darkHex:"#B08CD9",lightHex:"#6A3FA6",ansi:"magenta"},{name:"rosa",darkHex:"#E59BC0",lightHex:"#A63D74",ansi:"magenta"},{name:"coral",darkHex:"#E5897C",lightHex:"#B23A2A",ansi:"red"},{name:"ardosia",darkHex:"#9AA7B0",lightHex:"#4A5963",ansi:"gray"}],Ti=$c.map(t=>t.name);function RR(t){return Ti.includes(t.trim().toLowerCase())}function ib(t){let e=2166136261,o=t.trim().toLowerCase();for(let r=0;r<o.length;r++)e^=o.charCodeAt(r),e=Math.imul(e,16777619);let n=(e>>>0)%$c.length;return $c[n].name}function CR(t,e,o){let n=t.trim().toLowerCase(),r=$c.find(s=>s.name===n)??$c.find(s=>s.name===ib(n));return e==="mono"?{bold:!0}:e==="truecolor"?{color:o==="light"?r.lightHex:r.darkHex,bold:!0}:{color:r.ansi,bold:!0}}function Qu(t){return t!==void 0&&t!==""&&t!=="0"&&t.toLowerCase()!=="false"}function ej(t){if(t.NO_COLOR!==void 0)return"mono";let e=(t.COLORTERM??"").toLowerCase();if(e==="truecolor"||e==="24bit")return"truecolor";let o=(t.TERM??"").toLowerCase();return o==="dumb"||o===""?"mono":"ansi16"}function tj(t,e){if(e)return e;let o=t.COLORFGBG;if(o){let n=o.split(";"),r=Number(n[n.length-1]);if(Number.isFinite(r))return r>=8?"light":"dark"}return"dark"}function oj(t){let e=(t.TERM??"").toLowerCase();if(e==="linux"||e==="dumb")return!1;let o=`${t.LC_ALL??""}${t.LC_CTYPE??""}${t.LANG??""}`.toLowerCase();return!(Qu(t.ALUY_ASCII)||o&&!o.includes("utf"))}function nj(t,e){return e!==void 0?e:Qu(t.ALUY_SAFE_GLYPHS)}function rj(t,e,o){return t==="mono"?kR:t==="truecolor"?o??(e==="light"?Ju:Xu):e==="light"?bR:yR}function ln(t={}){let e=t.env??process.env,o=ej(e),n=tj(e,t.theme),r=oj(e),s=r&&nj(e,t.safeGlyphs),i=t.density??(Qu(e.ALUY_DENSITY)&&e.ALUY_DENSITY==="compact"?"compact":"comfortable"),a=t.animate??!Qu(e.ALUY_NO_ANIM),c=rj(o,n,t.truecolorPalette),l=r?s?SR:xR:wR;return{colorMode:o,brightness:n,unicode:r,safeGlyphs:s,density:i,animate:a,role:p=>c[p],sessionColor:p=>CR(p,o,n),glyph:p=>l[p],aluyMark:r?"\u039B":"/\\",spinnerFrames:r&&!s?AR:ER,box:r?TR:_R}}var po=[{name:"aluy-dark",label:"Aluy Dark",brightness:"dark",summary:"escuro neutro (default) \u2014 fundo quase-preto, accent \xE2mbar",bg:"#070707",palette:Xu},{name:"aluy-light",label:"Aluy Light",brightness:"light",summary:"claro creme \u2014 fundo --stone-50, accent \xE2mbar escurecido (AA)",bg:"#F4ECDC",palette:Ju},{name:"aluy-slate",label:"Aluy Slate",brightness:"dark",summary:"terra escura WARM \u2014 fundo --stone-950, accent \xE2mbar",bg:"#0E0C09",palette:vR}],lb="aluy-dark";function wr(t){return po.find(e=>e.name===t)}function Yn(t){let e=t.trim().toLowerCase();if(e==="")return;let o=po.find(r=>r.name===e);if(o)return o;let n=po.find(r=>r.name===`aluy-${e}`);return n||po.find(r=>r.label.toLowerCase()===e)}function ds(t){return t==="light"?"aluy-light":"aluy-dark"}function OR(t,e={}){let o=wr(t)??wr(lb);return ln({...e,theme:o.brightness,truecolorPalette:o.palette})}var dn="pt-BR",wo=[{code:"pt-BR",label:"Portugu\xEAs (Brasil)",summary:"idioma padr\xE3o da TUI"},{code:"en",label:"English",summary:"English interface (opt-in)"}];function us(t){return wo.find(e=>e.code===t)}function Ar(t){let e=t.trim().toLowerCase();if(e==="")return;let o=wo.find(n=>n.code.toLowerCase()===e);if(o)return o;if(e==="pt"||e==="pt_br"||e==="br"||e==="portugu\xEAs"||e==="portugues")return us("pt-BR");if(e==="en"||e==="en_us"||e==="english"||e==="ingl\xEAs"||e==="ingles")return us("en")}function MR(t){let e=(t.LC_ALL??t.LC_MESSAGES??t.LANG??"").trim().toLowerCase();if(e==="")return dn;let o=e.split(".")[0].split("@")[0].replace("_","-");return o==="c"||o==="posix"?dn:o==="en"||o.startsWith("en-")?"en":dn}function db(t,e,o){if(t!==void 0&&t.trim()!==""){let n=Ar(t);if(n)return n.code}return e!==void 0?e:MR(o)}var fj=448,pj=384,Bc="config.json",hj=new Set(["openai-compat","anthropic","gemini"]);function NR(t){let o=(Array.isArray(t)?t:t!==void 0?[t]:[]).filter(n=>typeof n=="string"&&n.trim()!=="");return o.length>0?o:void 0}function gj(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e==="localhost"||e==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}function yj(t){return typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=65535}function mb(t){if(typeof t!="object"||t===null)return;let e=t,o={};return gj(e.host)&&(o.host=e.host.trim()),yj(e.port)&&(o.port=e.port),o.host!==void 0||o.port!==void 0?o:void 0}function bj(t){if(typeof t!="object"||t===null)return;let e=t,o={};if(typeof e.telegram=="object"&&e.telegram!==null){let n=e.telegram;if(Array.isArray(n.allowlist)){let r=[];for(let s of n.allowlist)typeof s=="number"&&Number.isFinite(s)&&Number.isInteger(s)&&!r.includes(s)&&r.push(s);o.telegram={allowlist:r}}else o.telegram={}}return o.telegram!==void 0?o:void 0}function vj(t){if(typeof t!="object"||t===null)return;let e=t,o={},n=mb(e.ollama),r=mb(e.mem0),s=mb(e.headroom);return n&&(o.ollama=n),r&&(o.mem0=r),s&&(o.headroom=s),Object.keys(o).length>0?o:void 0}function kj(t){if(!Array.isArray(t))return;let e=[];for(let o of t){if(typeof o!="object"||o===null)continue;let n=o,r=typeof n.id=="string"?n.id.trim():"",s=typeof n.baseUrl=="string"?n.baseUrl.trim():"",i=typeof n.defaultModel=="string"?n.defaultModel.trim():"",a=typeof n.wireFormat=="string"?n.wireFormat:"";if(r===""||s===""||i===""||!hj.has(a))continue;let c=NR(n.auth),l=NR(n.models),d={id:r,wireFormat:a,baseUrl:s,defaultModel:i,...typeof n.label=="string"&&n.label.trim()?{label:n.label.trim()}:{},...c?{auth:c}:{},...l?{models:l}:{}};e.push(d)}return e.length>0?e:void 0}var xj=128;function Fc(t){if(typeof t!="string")return!1;let e=t.trim();return e===""||e.length>xj?!1:!/[\u0000-\u001F\u007F]/.test(e)}function IR(t){if(typeof t!="object"||t===null)return{};let e=t,o={};if(typeof e.theme=="string"){let i=wr(e.theme);i&&(o.theme=i.name)}if(Fc(e.tier)&&(o.tier=e.tier.trim()),o.tier==="custom"&&Fc(e.model)&&(o.model=e.model.trim()),typeof e.splitView=="boolean"&&(o.splitView=e.splitView),typeof e.lang=="string"){let i=us(e.lang);i&&(o.lang=i.code)}if(typeof e.fullscreen=="boolean"&&(o.fullscreen=e.fullscreen),(e.backend==="broker"||e.backend==="local")&&(o.backend=e.backend),Fc(e.localProvider)&&(o.localProvider=e.localProvider.trim()),Fc(e.localModel)&&(o.localModel=e.localModel.trim()),(e.localAuth==="apikey"||e.localAuth==="oauth")&&(o.localAuth=e.localAuth),Fc(e.localBaseUrl)&&(o.localBaseUrl=e.localBaseUrl.trim()),typeof e.localBudget=="boolean"&&(o.localBudget=e.localBudget),typeof e.rooms=="object"&&e.rooms!==null){let i=e.rooms;if(typeof i.backend=="string"){let a=i.backend.trim().toLowerCase();a.length>0&&a.length<=32&&(o.rooms={backend:a})}}if((e.profile==="turbo"||e.profile==="leve")&&(o.profile=e.profile),typeof e.sidecarToggles=="object"&&e.sidecarToggles!==null){let i=e.sidecarToggles,a={};typeof i.ollama=="boolean"&&(a.ollama=i.ollama),typeof i.mem0=="boolean"&&(a.mem0=i.mem0),typeof i.headroom=="boolean"&&(a.headroom=i.headroom),Object.keys(a).length>0&&(o.sidecarToggles=a)}let n=kj(e.providers);n&&(o.providers=n);let r=vj(e.services);r&&(o.services=r);let s=bj(e.connectors);return s&&(o.connectors=s),o}var Vn=class{base;file;constructor(e={}){this.base=e.baseDir??LR(sj(),".aluy"),this.file=LR(this.base,Bc)}get configPath(){return this.file}load(){let e;try{e=lj(this.file,"utf8")}catch{return{}}let o;try{o=JSON.parse(e)}catch{return{}}return IR(o)}save(e){try{let o=IR({...this.load(),...e});return this.writeAtomic(o),!0}catch{return!1}}saveTheme(e){return this.save({theme:e})}saveLang(e){return this.save({lang:e})}saveTier(e,o){let r=e.trim()==="custom"&&o!==void 0&&o.trim()!==""?o.trim():void 0;return this.save(r!==void 0?{tier:e,model:r}:{tier:e})}saveSplitView(e){return this.save({splitView:e})}saveFullscreen(e){return this.save({fullscreen:e})}saveLocalBudget(e){return this.save({localBudget:e})}writeAtomic(e){dj(this.base,{recursive:!0,mode:fj});let o=`${this.file}.${process.pid}.${ij(6).toString("hex")}.tmp`,n=JSON.stringify(e,null,2)+`
447
- `,r;try{r=aj(o,ub.O_CREAT|ub.O_EXCL|ub.O_WRONLY,pj),cj(r,n),PR(r),r=void 0,uj(o,this.file)}catch(s){if(r!==void 0)try{PR(r)}catch{}try{mj(o)}catch{}throw s}}};function fb(t,e,o){return t!==void 0&&t.trim()!==""?t.trim():e.tier!==void 0&&e.tier.trim()!==""?e.tier.trim():o}function Sj(t){return t.theme}function DR(t){return t.lang}function pb(t,e){return t===!0?!0:e.splitView??!1}function hb(t,e){return t===!0?!0:e.fullscreen??!1}import{homedir as wj}from"node:os";import{join as gb,basename as Aj}from"node:path";import{openSync as Ej,writeSync as Tj,closeSync as $R,mkdirSync as _j,renameSync as Rj,unlinkSync as Cj,constants as yb}from"node:fs";var Oj=448,Mj=384,FR="exports",Lj=(t,e,o)=>Tj(t,e,o,e.length-o);function Pj(t,e){if(t===void 0||t.trim()==="")return e;let o=Aj(t.trim());return o=o.replace(/[-/\\]/g,""),o===""||o==="."||o===".."?e:(/\.md$/i.test(o)||(o+=".md"),o)}function Nj(t){return t.toISOString().replace(/[:.]/g,"-").replace(/-\d{3}Z$/,"Z")}var Uc=class{base;now;writeChunk;constructor(e={}){this.base=gb(e.baseDir??gb(wj(),".aluy"),FR),this.now=e.now??(()=>new Date),this.writeChunk=e.writeChunk??Lj}get dir(){return this.base}write(e,o={}){let n=`${(o.sessionId??"sessao").slice(0,40)}-${Nj(this.now())}.md`,r=Pj(o.fileName,n),s=gb(this.base,r),i=`${s}.${process.pid}.tmp`,a;try{_j(this.base,{recursive:!0,mode:Oj}),a=Ej(i,yb.O_CREAT|yb.O_EXCL|yb.O_WRONLY,Mj);let c=Buffer.from(e,"utf8"),l=0;for(;l<c.length;){let d=this.writeChunk(a,c,l);if(d<=0)throw new Error(`escrita parou em ${l}/${c.length} bytes (writeSync devolveu ${d})`);l+=d}return $R(a),a=void 0,Rj(i,s),{ok:!0,path:s}}catch(c){if(a!==void 0)try{$R(a)}catch{}try{Cj(i)}catch{}return{ok:!1,error:`falha ao exportar: ${String(c)}`}}}};function Ij(t,e,o={}){return t.write(e,o)}import{homedir as qj}from"node:os";import{join as vb}from"node:path";import{randomBytes as Wj}from"node:crypto";import{openSync as Gj,writeSync as zj,closeSync as HR,readFileSync as Kj,readdirSync as qR,mkdirSync as Yj,renameSync as Vj,unlinkSync as WR,statSync as Xj,existsSync as Noe,constants as kb}from"node:fs";var Dj=new Set(["you","aluy","tool","deny","bang","broker-error","note","inject","doctor"]);function ct(t){return typeof t=="string"}function BR(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}function $j(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Fj(t){return t==="ok"||t==="warn"||t==="fail"?t:"warn"}function Bj(t){if(typeof t!="object"||t===null)return null;let e=t;return!ct(e.id)||!ct(e.label)?null:{id:e.id,label:e.label,status:Fj(e.status),...ct(e.detail)?{detail:e.detail}:{},...ct(e.fix)?{fix:e.fix}:{}}}function UR(t){if(typeof t!="object"||t===null)return null;let e=t,o=e.kind;if(typeof o!="string"||!Dj.has(o))return null;switch(o){case"you":return ct(e.text)?{kind:"you",text:e.text}:null;case"aluy":return ct(e.text)?{kind:"aluy",text:e.text,streaming:!1}:null;case"tool":{if(!ct(e.verb)||!ct(e.target)||!ct(e.result))return null;let n=e.status==="ok"||e.status==="err"?e.status:"err";return{kind:"tool",verb:e.verb,target:e.target,result:e.result,status:n,...ct(e.output)?{output:e.output}:{},...ct(e.verbGerund)?{verbGerund:e.verbGerund}:{},...BR(e.added)?{added:e.added}:{},...BR(e.removed)?{removed:e.removed}:{}}}case"deny":return ct(e.verb)&&ct(e.exact)?{kind:"deny",verb:e.verb,exact:e.exact}:null;case"bang":{if(!ct(e.command))return null;let n=e.status==="ok"||e.status==="err"||e.status==="blocked"?e.status:"err";return{kind:"bang",command:e.command,status:n,...ct(e.output)?{output:e.output}:{}}}case"broker-error":return ct(e.message)?{kind:"broker-error",message:e.message,...typeof e.status=="number"?{status:e.status}:{}}:null;case"note":return ct(e.title)&&$j(e.lines)?{kind:"note",title:e.title,lines:e.lines}:null;case"inject":return ct(e.text)?{kind:"inject",text:e.text}:null;case"doctor":{if(!Array.isArray(e.checks))return null;let n=e.checks.map(Bj).filter(r=>r!==null);return n.length===0?null:{kind:"doctor",checks:n,...ct(e.summary)?{summary:e.summary}:{}}}default:return null}}function Zu(t){if(!Array.isArray(t))return[];let e=[];for(let o of t){let n=UR(o);n&&e.push(n)}return e}var bb="sess\xE3o-anterior";function ms(t){let e=[];for(let o of t)switch(o.kind){case"you":e.push({role:"goal",text:o.text});break;case"aluy":o.text.trim()!==""&&e.push({role:"model",text:o.text});break;case"tool":{let n=[`${o.verb} ${o.target} \u2192 ${o.result||o.status}`];o.output&&n.push(o.output),e.push({role:"observation",toolName:bb,text:n.join(`
447
+ `,r;try{r=aj(o,ub.O_CREAT|ub.O_EXCL|ub.O_WRONLY,pj),cj(r,n),PR(r),r=void 0,uj(o,this.file)}catch(s){if(r!==void 0)try{PR(r)}catch{}try{mj(o)}catch{}throw s}}};function fb(t,e,o){return t!==void 0&&t.trim()!==""?t.trim():e.tier!==void 0&&e.tier.trim()!==""?e.tier.trim():o}function Sj(t){return t.theme}function DR(t){return t.lang}function pb(t,e){return t===!0?!0:e.splitView??!1}function hb(t,e){return t===!0?!0:e.fullscreen??!1}import{homedir as wj}from"node:os";import{join as gb,basename as Aj}from"node:path";import{openSync as Ej,writeSync as Tj,closeSync as $R,mkdirSync as _j,renameSync as Rj,unlinkSync as Cj,constants as yb}from"node:fs";var Oj=448,Mj=384,FR="exports",Lj=(t,e,o)=>Tj(t,e,o,e.length-o);function Pj(t,e){if(t===void 0||t.trim()==="")return e;let o=Aj(t.trim());return o=o.replace(/[-/\\]/g,""),o===""||o==="."||o===".."?e:(/\.md$/i.test(o)||(o+=".md"),o)}function Nj(t){return t.toISOString().replace(/[:.]/g,"-").replace(/-\d{3}Z$/,"Z")}var Uc=class{base;now;writeChunk;constructor(e={}){this.base=gb(e.baseDir??gb(wj(),".aluy"),FR),this.now=e.now??(()=>new Date),this.writeChunk=e.writeChunk??Lj}get dir(){return this.base}write(e,o={}){let n=`${(o.sessionId??"sessao").slice(0,40)}-${Nj(this.now())}.md`,r=Pj(o.fileName,n),s=gb(this.base,r),i=`${s}.${process.pid}.tmp`,a;try{_j(this.base,{recursive:!0,mode:Oj}),a=Ej(i,yb.O_CREAT|yb.O_EXCL|yb.O_WRONLY,Mj);let c=Buffer.from(e,"utf8"),l=0;for(;l<c.length;){let d=this.writeChunk(a,c,l);if(d<=0)throw new Error(`escrita parou em ${l}/${c.length} bytes (writeSync devolveu ${d})`);l+=d}return $R(a),a=void 0,Rj(i,s),{ok:!0,path:s}}catch(c){if(a!==void 0)try{$R(a)}catch{}try{Cj(i)}catch{}return{ok:!1,error:`falha ao exportar: ${String(c)}`}}}};function Ij(t,e,o={}){return t.write(e,o)}import{homedir as qj}from"node:os";import{join as vb}from"node:path";import{randomBytes as Wj}from"node:crypto";import{openSync as Gj,writeSync as zj,closeSync as HR,readFileSync as Kj,readdirSync as qR,mkdirSync as Yj,renameSync as Vj,unlinkSync as WR,statSync as Xj,existsSync as Doe,constants as kb}from"node:fs";var Dj=new Set(["you","aluy","tool","deny","bang","broker-error","note","inject","doctor"]);function ct(t){return typeof t=="string"}function BR(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}function $j(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Fj(t){return t==="ok"||t==="warn"||t==="fail"?t:"warn"}function Bj(t){if(typeof t!="object"||t===null)return null;let e=t;return!ct(e.id)||!ct(e.label)?null:{id:e.id,label:e.label,status:Fj(e.status),...ct(e.detail)?{detail:e.detail}:{},...ct(e.fix)?{fix:e.fix}:{}}}function UR(t){if(typeof t!="object"||t===null)return null;let e=t,o=e.kind;if(typeof o!="string"||!Dj.has(o))return null;switch(o){case"you":return ct(e.text)?{kind:"you",text:e.text}:null;case"aluy":return ct(e.text)?{kind:"aluy",text:e.text,streaming:!1}:null;case"tool":{if(!ct(e.verb)||!ct(e.target)||!ct(e.result))return null;let n=e.status==="ok"||e.status==="err"?e.status:"err";return{kind:"tool",verb:e.verb,target:e.target,result:e.result,status:n,...ct(e.output)?{output:e.output}:{},...ct(e.verbGerund)?{verbGerund:e.verbGerund}:{},...BR(e.added)?{added:e.added}:{},...BR(e.removed)?{removed:e.removed}:{}}}case"deny":return ct(e.verb)&&ct(e.exact)?{kind:"deny",verb:e.verb,exact:e.exact}:null;case"bang":{if(!ct(e.command))return null;let n=e.status==="ok"||e.status==="err"||e.status==="blocked"?e.status:"err";return{kind:"bang",command:e.command,status:n,...ct(e.output)?{output:e.output}:{}}}case"broker-error":return ct(e.message)?{kind:"broker-error",message:e.message,...typeof e.status=="number"?{status:e.status}:{}}:null;case"note":return ct(e.title)&&$j(e.lines)?{kind:"note",title:e.title,lines:e.lines}:null;case"inject":return ct(e.text)?{kind:"inject",text:e.text}:null;case"doctor":{if(!Array.isArray(e.checks))return null;let n=e.checks.map(Bj).filter(r=>r!==null);return n.length===0?null:{kind:"doctor",checks:n,...ct(e.summary)?{summary:e.summary}:{}}}default:return null}}function Zu(t){if(!Array.isArray(t))return[];let e=[];for(let o of t){let n=UR(o);n&&e.push(n)}return e}var bb="sess\xE3o-anterior";function ms(t){let e=[];for(let o of t)switch(o.kind){case"you":e.push({role:"goal",text:o.text});break;case"aluy":o.text.trim()!==""&&e.push({role:"model",text:o.text});break;case"tool":{let n=[`${o.verb} ${o.target} \u2192 ${o.result||o.status}`];o.output&&n.push(o.output),e.push({role:"observation",toolName:bb,text:n.join(`
448
448
  `)});break}case"bang":{let n=[`! ${o.command} (${o.status})`];o.output&&n.push(o.output),e.push({role:"observation",toolName:bb,text:n.join(`
449
449
  `)});break}case"broker-error":e.push({role:"observation",toolName:bb,text:`(erro de broker anterior: ${o.message})`});break;case"note":case"deny":case"subagents":case"doctor":case"inject":break}return e}j();var Uj=new Set(["bash","run_command"]),jj=new Set(["read","grep","attach","headroom_retrieve"]);function Hj(t){return t.kind==="tool"&&jj.has(t.verb)}function jR(t){let e=!1,o=t.map(n=>{if(n.kind==="tool"&&Hj(n)){let r=Ue(n.result),s=n.output!==void 0?Ue(n.output):void 0,i=n.liveOutput!==void 0?Ue(n.liveOutput):void 0;return r===n.result&&s===n.output&&i===n.liveOutput?n:(e=!0,{...n,result:r,...s!==void 0?{output:s}:{},...i!==void 0?{liveOutput:i}:{}})}if(n.kind==="bang"){let r=It(n.command);return r===n.command?n:(e=!0,{...n,command:r})}if(n.kind==="tool"&&Uj.has(n.verb)){let r=It(n.target);return r===n.target?n:(e=!0,{...n,target:r})}return n});return e?o:t}var Jj=448,Qj=384,GR="sessions",zR=1,Zj=720*60*60*1e3,eH=50,xb=8*1024*1024,tH=xb*8,oH=Math.floor(xb*.9),em=/^[A-Za-z0-9_-]{1,128}$/,nH=64;function rH(t,e){let o=[...t];return o.length>e?o.slice(0,e).join(""):t}function tm(t){if(typeof t!="string")return;let e="";for(let n of t){let r=n.codePointAt(0)??0;e+=r<32||r===127?" ":n}let o=e.replace(/\s+/g," ").trim();if(o!=="")return rH(o,nH)}function sH(t){for(let e of t)if(e.kind==="you"){let o=e.text.replace(/\s+/g," ").trim();if(o==="")return;let n=[...o];return n.length>60?n.slice(0,57).join("")+"\u2026":o}}var jc=class{base;dir;now;createdAtCache=new Map;constructor(e={}){this.base=e.baseDir??vb(qj(),".aluy"),this.dir=vb(this.base,GR),this.now=e.now??(()=>Date.now())}get sessionsDir(){return this.dir}pathFor(e){return vb(this.dir,`${e}.json`)}save(e){if(!em.test(e.id))return!1;try{let o=this.now(),n=this.resolveCreatedAt(e.id,o),r=e.tier==="custom"&&typeof e.model=="string"&&e.model.trim()!=="",s=r&&typeof e.provider=="string"&&e.provider.trim()!=="",i=tm(e.label),a=i!==void 0?tm(e.labelColor):void 0,c={id:e.id,version:zR,createdAt:n,updatedAt:o,cwd:e.cwd,tier:e.tier,...r?{model:e.model.trim()}:{},...s?{provider:e.provider.trim()}:{},...i!==void 0?{label:i}:{},...a!==void 0?{labelColor:a}:{}},l=this.fitBlocks(c,jR(Zu(e.blocks))),d={...c,blocks:l};return this.writeAtomic(d),!0}catch{return!1}}resolveCreatedAt(e,o){let n=this.createdAtCache.get(e);if(n!==void 0)return n;let r=this.load(e)?.createdAt??o;return this.createdAtCache.set(e,r),r}load(e){if(!em.test(e))return null;let o=this.pathFor(e),n,r=!1;try{let a=Xj(o);if(a.size>tH)return null;r=a.size>xb,n=Kj(o,"utf8")}catch{return null}let s;try{s=JSON.parse(n)}catch{return null}let i=this.sanitizeRecord(s);if(i&&r){let{blocks:a,...c}=i,l=this.fitBlocks(c,a),d=a.length-l.length,f={kind:"note",title:"sess\xE3o grande \u2014 contexto antigo omitido no resume",lines:[`Esta sess\xE3o era grande demais p/ recarregar inteira; ${d} bloco(s) antigo(s) foram omitidos e a parte recente foi preservada.`,"O contexto restante ser\xE1 resumido automaticamente na pr\xF3xima intera\xE7\xE3o."]};i={...i,blocks:d>0?[f,...l]:l}}return i&&this.createdAtCache.set(i.id,i.createdAt),i}list(){let e;try{e=qR(this.dir)}catch{return[]}let o=[];for(let n of e){if(!n.endsWith(".json"))continue;let r=n.slice(0,-5),s=this.load(r);s&&o.push({id:s.id,createdAt:s.createdAt,updatedAt:s.updatedAt,cwd:s.cwd,tier:s.tier,...s.model!==void 0?{model:s.model}:{},...s.provider!==void 0?{provider:s.provider}:{},...s.label!==void 0?{label:s.label}:{},...s.labelColor!==void 0?{labelColor:s.labelColor}:{},blockCount:s.blocks.length,title:sH(s.blocks)})}return o.sort((n,r)=>r.updatedAt-n.updatedAt),o}latestForCwd(e){let o;try{o=qR(this.dir)}catch{return null}let n=null;for(let r of o){if(!r.endsWith(".json"))continue;let s=r.slice(0,-5),i=this.load(s);!i||i.cwd!==e||(n===null||i.updatedAt>n.updatedAt)&&(n=i)}return n}remove(e){if(em.test(e)){this.createdAtCache.delete(e);try{WR(this.pathFor(e))}catch{}}}gc(e={}){let o=e.maxAgeMs??Zj,n=e.maxCount??eH,r=this.list(),s=this.now()-o;r.forEach((i,a)=>{(i.updatedAt<s||a>=n)&&this.remove(i.id)})}sanitizeRecord(e){if(typeof e!="object"||e===null)return null;let o=e;if(typeof o.id!="string"||!em.test(o.id)||!Array.isArray(o.blocks))return null;let n=typeof o.createdAt=="number"&&o.createdAt>=0?o.createdAt:0,r=typeof o.updatedAt=="number"&&o.updatedAt>=0?o.updatedAt:n,s=typeof o.cwd=="string"?o.cwd:"",i=typeof o.tier=="string"&&o.tier.trim()!==""?o.tier:"",a=typeof o.version=="number"?o.version:0,c=i==="custom"&&typeof o.model=="string"&&o.model.trim()!==""?o.model.trim():void 0,l=c!==void 0&&typeof o.provider=="string"&&o.provider.trim()!==""?o.provider.trim():void 0,d=tm(o.label),f=d!==void 0?tm(o.labelColor):void 0;return{id:o.id,version:a,createdAt:n,updatedAt:r,cwd:s,tier:i,...c!==void 0?{model:c}:{},...l!==void 0?{provider:l}:{},...d!==void 0?{label:d}:{},...f!==void 0?{labelColor:f}:{},blocks:Zu(o.blocks)}}fitBlocks(e,o){let n=i=>Buffer.byteLength(JSON.stringify({...e,blocks:i})+`
450
450
  `,"utf8")<=oH;if(n(o))return o;let r=1,s=o.length;for(;r<s;){let i=r+s>>1;n(o.slice(i))?s=i:r=i+1}return o.slice(r)}writeAtomic(e){Yj(this.dir,{recursive:!0,mode:Jj});let o=this.pathFor(e.id),n=`${o}.${process.pid}.${Wj(6).toString("hex")}.tmp`,r=JSON.stringify(e)+`
@@ -510,17 +510,17 @@ Responda APENAS com JSON no formato:
510
510
  `).length,f=t.maxRows!==void 0&&d>t.maxRows,u=f?Math.max(1,t.maxRows-1):0,p=f?wO(t.value,s,u):{text:t.value,cursor:s,hiddenAbove:0,hiddenBelow:0};return mn(bv,{flexDirection:"column",children:[mn(bv,{children:[Xe(EO,{...t.sessionLabel!==void 0?{label:t.sessionLabel}:{},...t.sessionColor!==void 0?{color:t.sessionColor}:{}}),Xe(L,{name:"prompt",role:"accent"}),Xe(ks,{children:" "}),a?mn(pl,{children:[c&&l,Xe(m,{name:"fgDim",children:n})]}):Xe(AO,{text:p.text,pos:p.cursor,showCursor:c,active:t.active,cursorGlyph:r}),!t.active&&t.hint&&mn(pl,{children:[Xe(ks,{children:" "}),Xe(m,{name:"fgDim",children:t.hint})]})]}),f&&(p.hiddenAbove>0||p.hiddenBelow>0)&&mn(m,{name:"fgDim",children:[p.hiddenAbove>0?`\u2191${p.hiddenAbove}`:"",p.hiddenAbove>0&&p.hiddenBelow>0?" \xB7 ":"",p.hiddenBelow>0?`\u2193${p.hiddenBelow}`:"",` ${o("composer.moreLines")}`]})]})}import"react";import{Box as Ii}from"ink";var kv=3,vv=1;function xs(t,e){if(e<=0)return"";if(ye(t)<=e)return t;let o=e-1,n="",r=0;for(let s of t){let i=ye(s);if(r+i>o)break;n+=s,r+=i}return n+"\u2026"}function xv(t,e,o){let n=Math.max(0,e-ye(t));if(n===0)return t;if(o==="right")return" ".repeat(n)+t;if(o==="center"){let r=Math.floor(n/2);return" ".repeat(r)+t+" ".repeat(n-r)}return t+" ".repeat(n)}function TO(t,e,o,n){let r=[];for(let d=0;d<o;d++){let f=ye(t[d]??"");for(let u of e)f=Math.max(f,ye(u[d]??""));r.push(Math.max(vv,f))}if(!n||n<=0)return r;let s=o>0?(o-1)*kv:0,i=Math.max(o*vv,n-s),a=r.reduce((d,f)=>d+f,0);if(a<=i)return r;let c=[...r],l=a*2+10;for(;a>i&&l-- >0;){let d=-1,f=vv;for(let u=0;u<o;u++)c[u]>f&&(f=c[u],d=u);if(d<0)break;c[d]-=1,a-=1}return c}import{jsx as fn,jsxs as RO}from"react/jsx-runtime";var gl=3,h2=48;function _O(t){let e=t.replace(/\s+/g," ").trim();return xs(e,h2)}function Em(t){if(t<=0)return 0;let e=Math.min(t,gl),o=t>gl?1:0;return 1+e+o}function Sv(t){let{items:e}=t;if(e.length===0)return null;let o=e.slice(0,gl),n=e.length-o.length;return RO(Ii,{flexDirection:"column",children:[fn(m,{name:"depth",children:`\u229F ${e.length} na fila \xB7 enviada(s) ao terminar o turno`}),o.map((r,s)=>fn(Ii,{children:fn(m,{name:"fgDim",children:` \u203A ${_O(r)}`})},s)),n>0&&fn(Ii,{children:fn(m,{name:"fgDim",children:` \u2026+${n} na fila`})})]})}function wv(t){let{items:e}=t;if(e.length===0)return null;let o=e.slice(0,gl),n=e.length-o.length;return RO(Ii,{flexDirection:"column",children:[fn(m,{name:"depth",children:`\u21B3 ${e.length} encaixando\u2026 \xB7 incorporada(s) na pr\xF3xima itera\xE7\xE3o`}),o.map((r,s)=>fn(Ii,{children:fn(m,{name:"fgDim",children:` \u203A ${_O(r)}`})},s)),n>0&&fn(Ii,{children:fn(m,{name:"fgDim",children:` \u2026+${n} encaixando`})})]})}j();import"react";import{Box as Hi,Text as tG}from"ink";import"react";import{Box as Bi,Text as _r}from"ink";import"react";import{Box as _m,Text as o0}from"ink";import{createLowlight as C2}from"lowlight";function CO(t){let e=t.regex,o={},n={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[o]}]};Object.assign(o,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},n]});let r={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},s=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),i={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},a={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,o,r]};r.contains.push(a);let c={match:/\\"/},l={className:"string",begin:/'/,end:/'/},d={match:/\\'/},f={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,o]},u=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],p=t.SHEBANG({binary:`(${u.join("|")})`,relevance:10}),h={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},y=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],g=["true","false"],w={match:/(\/[a-z._-]+)+/},C=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],E=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],M=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],U=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:y,literal:g,built_in:[...C,...E,"set","shopt",...M,...U]},contains:[p,t.SHEBANG(),h,f,s,i,w,a,c,l,d,o]}}var g2=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),y2=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],b2=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],v2=[...y2,...b2],k2=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),x2=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),S2=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),w2=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function OO(t){let e=t.regex,o=g2(t),n={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="and or not only",s=/@-?\w[\w]*(-\w+)*/,i="[a-zA-Z-][a-zA-Z0-9_-]*",a=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[o.BLOCK_COMMENT,n,o.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+i,relevance:0},o.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+x2.join("|")+")"},{begin:":(:)?("+S2.join("|")+")"}]},o.CSS_VARIABLE,{className:"attribute",begin:"\\b("+w2.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[o.BLOCK_COMMENT,o.HEXCOLOR,o.IMPORTANT,o.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},o.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:r,attribute:k2.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...a,o.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+v2.join("|")+")\\b"}]}}function MO(t){let e=t.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:e.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:e.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function LO(t){let s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:s,illegal:/["']/}]}]}}var PO="[A-Za-z$_][0-9A-Za-z$_]*",A2=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],E2=["true","false","null","undefined","NaN","Infinity"],NO=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],IO=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],DO=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],T2=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],_2=[].concat(DO,NO,IO);function $O(t){let e=t.regex,o=(Y,{after:re})=>{let ce="</"+Y[0].slice(1);return Y.input.indexOf(ce,re)!==-1},n=PO,r={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Y,re)=>{let ce=Y[0].length+Y.index,pe=Y.input[ce];if(pe==="<"||pe===","){re.ignoreMatch();return}pe===">"&&(o(Y,{after:ce})||re.ignoreMatch());let Q,se=Y.input.substring(ce);if(Q=se.match(/^\s*=/)){re.ignoreMatch();return}if((Q=se.match(/^\s+extends\s+/))&&Q.index===0){re.ignoreMatch();return}}},a={$pattern:PO,keyword:A2,literal:E2,built_in:_2,"variable.language":T2},c="[0-9](_?[0-9])*",l=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},u={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,u],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,u],subLanguage:"css"}},y={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,u],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,u]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},E=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,h,y,g,{match:/\$\d+/},f];u.contains=E.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(E)});let M=[].concat(C,u.contains),U=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(M)}]),H={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:U},W={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,e.concat(n,"(",e.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},G={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...NO,...IO]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},X={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[H],illegal:/%/},ne={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(Y){return e.concat("(?!",Y.join("|"),")")}let I={match:e.concat(/\b/,z([...DO,"super","import"].map(Y=>`${Y}\\s*\\(`)),n,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},K={begin:e.concat(/\./,e.lookahead(e.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Oe={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},H]},q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[H]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:U,CLASS_REFERENCE:G},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,h,y,g,C,{match:/\$\d+/},f,G,{scope:"attr",match:n+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:U}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},X,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[H,t.inherit(t.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},K,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[H]},I,ne,W,Oe,{match:/\$[(.]/}]}}function FO(t){let e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},o={match:/[{}[\],:]/,className:"punctuation",relevance:0},n=["true","false","null"],r={scope:"literal",beginKeywords:n.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:n},contains:[e,o,t.QUOTE_STRING_MODE,r,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function BO(t){let e=t.regex,o={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},n={begin:"^[-\\*]{3,}",end:"$"},r={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},a=/[A-Za-z][A-Za-z0-9+.-]*/,c={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,a,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},l={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},d={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},f=t.inherit(l,{contains:[]}),u=t.inherit(d,{contains:[]});l.contains.push(u),d.contains.push(f);let p=[o,c];return[l,d,f,u].forEach(w=>{w.contains=w.contains.concat(p)}),p=p.concat(l,d),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:p},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:p}]}]},o,s,l,d,{className:"quote",begin:"^>\\s+",contains:p,end:"$"},r,n,c,i,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function UO(t){let e=t.regex,o=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),n=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:n,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},l={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c,d,l]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c,d,l]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,d,l]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,l]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},u="[0-9](_?[0-9])*",p=`(\\b(${u}))?\\.(${u})|\\b(${u})\\.`,h=`\\b|${n.join("|")}`,y={className:"number",relevance:0,variants:[{begin:`(\\b(${u})|(${p}))[eE][+-]?(${u})[jJ]?(?=${h})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${h})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${h})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${h})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${h})`},{begin:`\\b(${u})[jJ](?=${h})`}]},g={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},w={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",c,y,f,t.HASH_COMMENT_MODE]}]};return l.contains=[f,y,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[c,y,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,g,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,o],scope:{1:"keyword",3:"title.function"},contains:[w]},{variants:[{match:[/\bclass/,/\s+/,o,/\s*/,/\(\s*/,o,/\s*\)/]},{match:[/\bclass/,/\s+/,o]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[y,w,f]}]}}function jO(t){let e=t.regex,o=/(r#)?/,n=e.concat(o,t.UNDERSCORE_IDENT_RE),r=e.concat(o,t.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,r,e.lookahead(/\s*\(/))},i="([ui](8|16|32|64|128|size)|f(32|64))?",a=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],c=["true","false","Some","None","Ok","Err"],l=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],d=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:d,keyword:a,literal:c,built_in:l},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+i},{begin:"\\b0o([0-7_]+)"+i},{begin:"\\b0x([A-Fa-f0-9_]+)"+i},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+i}],relevance:0},{begin:[/fn/,/\s+/,n],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,n],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,n,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:l,type:d}},{className:"punctuation",begin:"->"},s]}}function HO(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function qO(t){let e=t.regex,o=t.COMMENT("--","$"),n={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],i=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],l=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],u=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=d,h=[...l,...c].filter(U=>!d.includes(U)),y={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},g={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},w={match:e.concat(/\b/,e.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function C(U){return e.concat(/\b/,e.either(...U.map(H=>H.replace(/\s+/,"\\s+"))),/\b/)}let E={scope:"keyword",match:C(u),relevance:0};function M(U,{exceptions:H,when:W}={}){let G=W;return H=H||[],U.map(P=>P.match(/\|\d+$/)||H.includes(P)?P:G(P)?`${P}|0`:P)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:M(h,{when:U=>U.length<3}),literal:s,type:a,built_in:f},contains:[{scope:"type",match:C(i)},E,w,y,n,r,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,o,g]}}var Tm="[A-Za-z$_][0-9A-Za-z$_]*",WO=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],GO=["true","false","null","undefined","NaN","Infinity"],zO=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],KO=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],YO=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],VO=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],XO=[].concat(YO,zO,KO);function R2(t){let e=t.regex,o=(Y,{after:re})=>{let ce="</"+Y[0].slice(1);return Y.input.indexOf(ce,re)!==-1},n=Tm,r={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Y,re)=>{let ce=Y[0].length+Y.index,pe=Y.input[ce];if(pe==="<"||pe===","){re.ignoreMatch();return}pe===">"&&(o(Y,{after:ce})||re.ignoreMatch());let Q,se=Y.input.substring(ce);if(Q=se.match(/^\s*=/)){re.ignoreMatch();return}if((Q=se.match(/^\s+extends\s+/))&&Q.index===0){re.ignoreMatch();return}}},a={$pattern:Tm,keyword:WO,literal:GO,built_in:XO,"variable.language":VO},c="[0-9](_?[0-9])*",l=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},u={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,u],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,u],subLanguage:"css"}},y={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,u],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,u]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},E=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,h,y,g,{match:/\$\d+/},f];u.contains=E.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(E)});let M=[].concat(C,u.contains),U=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(M)}]),H={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:U},W={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,e.concat(n,"(",e.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},G={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...zO,...KO]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},X={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[H],illegal:/%/},ne={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(Y){return e.concat("(?!",Y.join("|"),")")}let I={match:e.concat(/\b/,z([...YO,"super","import"].map(Y=>`${Y}\\s*\\(`)),n,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},K={begin:e.concat(/\./,e.lookahead(e.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Oe={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},H]},q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[H]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:U,CLASS_REFERENCE:G},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,h,y,g,C,{match:/\$\d+/},f,G,{scope:"attr",match:n+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:U}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:s},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},X,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[H,t.inherit(t.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},K,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[H]},I,ne,W,Oe,{match:/\$[(.]/}]}}function JO(t){let e=t.regex,o=R2(t),n=Tm,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[o.exports.CLASS_REFERENCE]},a={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],l={$pattern:Tm,keyword:WO.concat(c),literal:GO,built_in:XO.concat(r),"variable.language":VO},d={className:"meta",begin:"@"+n},f=(y,g,w)=>{let C=y.contains.findIndex(E=>E.label===g);if(C===-1)throw new Error("can not find mode to replace");y.contains.splice(C,1,w)};Object.assign(o.keywords,l),o.exports.PARAMS_CONTAINS.push(d);let u=o.contains.find(y=>y.scope==="attr"),p=Object.assign({},u,{match:e.concat(n,e.lookahead(/\s*\?:/))});o.exports.PARAMS_CONTAINS.push([o.exports.CLASS_REFERENCE,u,p]),o.contains=o.contains.concat([d,s,i,p]),f(o,"shebang",t.SHEBANG()),f(o,"use_strict",a);let h=o.contains.find(y=>y.label==="func.def");return h.relevance=0,Object.assign(o,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),o}function QO(t){let e=t.regex,o=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),n=/[\p{L}0-9._:-]+/u,r={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=t.inherit(s,{begin:/\(/,end:/\)/}),a=t.inherit(t.APOS_STRING_MODE,{className:"string"}),c=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:n,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,c,a,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,i,c,a]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(o,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:o,relevance:0,starts:l}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(o,/>/))),contains:[{className:"name",begin:o,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function ZO(t){let e="true false yes no null",o="[\\w#;/?:@&=+$,.~*'()[\\]]+",n={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},i={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,r]},a=t.inherit(i,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),u={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},p={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},h={begin:/\{/,end:/\}/,contains:[p],illegal:"\\n",relevance:0},y={begin:"\\[",end:"\\]",contains:[p],illegal:"\\n",relevance:0},g=[n,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+o},{className:"type",begin:"!<"+o+">"},{className:"type",begin:"!"+o},{className:"type",begin:"!!"+o},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},u,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},h,y,s,i],w=[...g];return w.pop(),w.push(a),p.contains=w,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:g}}var e0=C2({bash:CO,css:OO,diff:MO,go:LO,javascript:$O,json:FO,markdown:BO,python:UO,rust:jO,shell:HO,sql:qO,typescript:JO,xml:QO,yaml:ZO}),O2={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",sh:"bash",zsh:"bash",shell:"shell",console:"shell",py:"python",rs:"rust",golang:"go",yml:"yaml",html:"xml",htm:"xml",svg:"xml",md:"markdown",markdown:"markdown",patch:"diff"};function Di(t){if(!t)return null;let e=t.trim().toLowerCase();if(e==="")return null;let o=O2[e]??e;return e0.registered(o)?o:null}function M2(t){if(!t)return"fg";let e=t.replace(/^hljs-/,"");switch(e.split(/[.\s]/)[0]??e){case"keyword":case"built_in":case"literal":case"operator":return"accent";case"string":case"regexp":case"char":case"subst":case"addition":return"success";case"comment":case"quote":case"meta":return"fgDim";case"number":case"symbol":case"bullet":case"link":return"accentDim";case"title":case"function":case"class":case"name":case"tag":case"attr":case"attribute":case"type":case"params":case"property":case"selector":case"section":case"variable":return"depth";case"deletion":return"danger";default:return"fg"}}function L2(t){let e=t.properties?.className;if(Array.isArray(e))return e[e.length-1];if(typeof e=="string")return e}function t0(t,e,o){if(t.type==="text"){let i=t.value;i!==""&&o.push({text:i,role:e});return}let n=t,r=n.type==="element"?M2(L2(n)):e,s=n.type==="element"&&r!=="fg"?r:e;for(let i of n.children??[])t0(i,s,o)}function P2(t){let e=[];for(let o of t){let n=e[e.length-1];n&&n.role===o.role?e[e.length-1]={text:n.text+o.text,role:o.role}:e.push(o)}return e}function yl(t,e){if(t==="")return[];let o=Di(e);if(!o)return[{text:t,role:"fg"}];try{let n=e0.highlight(o,t),r=[];t0(n,"fg",r);let s=P2(r);return s.length>0?s:[{text:t,role:"fg"}]}catch{return[{text:t,role:"fg"}]}}import{jsx as $i,jsxs as Ss}from"react/jsx-runtime";function Av(t){let o=Z().box,n=Di(t.lang),r=(n??t.lang??"code")+(t.open?" \u2026":""),s=t.code.split(`
511
511
  `);return Ss(_m,{flexDirection:"column",paddingY:0,children:[Ss(_m,{children:[Ss(m,{name:"fgDim",children:[o.topLeft,o.horizontal," "]}),$i(m,{name:"depth",children:r}),Ss(m,{name:"fgDim",children:[" ",o.horizontal.repeat(2)]})]}),s.map((i,a)=>Ss(_m,{children:[Ss(m,{name:"fgDim",children:[o.vertical," "]}),$i(N2,{line:i,lang:n??t.lang})]},a)),$i(_m,{children:Ss(m,{name:"fgDim",children:[o.bottomLeft,o.horizontal.repeat(3)]})})]})}function N2(t){if(t.line==="")return $i(o0,{children:" "});let e=yl(t.line,t.lang);return $i(o0,{children:e.map((o,n)=>$i(m,{name:o.role,children:o.text},n))})}import r0 from"react";import{Box as Rm,Text as _v}from"ink";var I2=/(`[^`]+`)|(\[([^\]]+)\]\(([^)\s]+)\))|(\*\*\*[^*]+\*\*\*|(?<![\p{L}\p{N}_])___[^_]+___(?![\p{L}\p{N}_]))|(\*\*[^*]+\*\*|(?<![\p{L}\p{N}_])__[^_]+__(?![\p{L}\p{N}_]))|(\*[^*\n]+\*|(?<![\p{L}\p{N}_])_[^_\n]+_(?![\p{L}\p{N}_]))/u;function Jn(t){let e=[],o=t;for(;o.length>0;){let n=I2.exec(o);if(!n||n.index===void 0){e.push({kind:"plain",text:o});break}n.index>0&&e.push({kind:"plain",text:o.slice(0,n.index)});let r=n[0];n[1]?e.push({kind:"code",text:r.slice(1,-1)}):n[2]?e.push({kind:"link",text:n[3]??"",url:n[4]??""}):n[5]?e.push({kind:"bold",text:r.slice(3,-3)}):n[6]?e.push({kind:"bold",text:r.slice(2,-2)}):n[7]&&e.push({kind:"italic",text:r.slice(1,-1)}),o=o.slice(n.index+r.length)}return e.reduce((n,r)=>{let s=n[n.length-1];return r.kind==="plain"&&s&&s.kind==="plain"?n[n.length-1]={kind:"plain",text:s.text+r.text}:n.push(r),n},[])}var D2=/^(\s*)```(.*)$/,$2=/^(#{1,6})\s+(.*)$/,F2=/^\s*>\s?(.*)$/,B2=/^(\s*)([-*+])\s+(.*)$/,U2=/^(\s*)(\d+)[.)]\s+(.*)$/,j2=/^:?-+:?$/;function Ev(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1)),e.split(/(?<!\\)\|/).map(n=>n.replace(/\\\|/g,"|").trim())}function n0(t){return/(?<!\\)\|/.test(t)}function H2(t){let e=Ev(t);if(e.length===0)return null;let o=[];for(let n of e){if(!j2.test(n))return null;let r=n.startsWith(":"),s=n.endsWith(":");o.push(r&&s?"center":s?"right":"left")}return o}function Tv(t){let e=t.split(`
512
512
  `),o=[],n=null,r=()=>{n&&n.length>0&&o.push({kind:"paragraph",spans:n}),n=null};for(let s=0;s<e.length;s++){let i=e[s]??"",a=D2.exec(i);if(a){r();let p=(a[2]??"").trim()||void 0,h=[],y=!1,g=s+1;for(;g<e.length;g++){let w=e[g]??"";if(/^\s*```\s*$/.test(w)){y=!0;break}h.push(w)}o.push({kind:"code",lang:p,code:h.join(`
513
- `),closed:y}),s=y?g:e.length;continue}if(i.trim()===""){r();continue}if(n0(i)){let p=s+1<e.length?H2(e[s+1]??""):null;if(p){r();let h=Ev(i),y=h.length,g=[];for(let E=0;E<y;E++)g.push(p[E]??"left");let w=[],C=s+2;for(;C<e.length;C++){let E=e[C]??"";if(E.trim()===""||!n0(E))break;let M=Ev(E),U=[];for(let H=0;H<y;H++)U.push(M[H]??"");w.push(U)}o.push({kind:"table",header:h,align:g,rows:w}),s=C-1;continue}}let c=$2.exec(i);if(c){r(),o.push({kind:"heading",level:c[1].length,spans:Jn(c[2]??"")});continue}let l=B2.exec(i);if(l){r(),o.push({kind:"list-item",ordered:!1,marker:"-",indent:Math.floor((l[1]??"").length/2),spans:Jn(l[3]??"")});continue}let d=U2.exec(i);if(d){r(),o.push({kind:"list-item",ordered:!0,marker:`${d[2]}.`,indent:Math.floor((d[1]??"").length/2),spans:Jn(d[3]??"")});continue}let f=F2.exec(i);if(f){r(),o.push({kind:"quote",spans:Jn(f[1]??"")});continue}let u=Jn(i);n=n?[...n,{kind:"plain",text:" "},...u]:u}return r(),o}import{jsx as Qn,jsxs as Rv}from"react/jsx-runtime";function Cm(t){return Jn(t).map(e=>e.text).join("")}function Cv(t){let e=Z(),o=e.box,n=t.base??"fg",r=e.colorMode==="mono",s=t.header.length,i=t.header.map(Cm),a=t.rows.map(p=>{let h=[];for(let y=0;y<s;y++)h.push(Cm(p[y]??""));return h}),c=TO(i,a,s,t.columns??0),l=e.unicode?`${o.horizontal}\u253C${o.horizontal}`:"-+-",d=c.map(p=>o.horizontal.repeat(p)).join(l),f=(p,h,y)=>{let g=Cm(p),w=xs(g,h),C=xv(w,h,y),E=Jn(C);return Qn(Fi,{spans:E,base:n,mono:r})},u=" ".repeat(kv);return Rv(Rm,{flexDirection:"column",paddingY:0,children:[Qn(Rm,{children:t.header.map((p,h)=>Rv(r0.Fragment,{children:[h>0&&Qn(_v,{children:u}),Qn(m,{name:"accent",children:Qn(_v,{bold:!0,children:xv(xs(Cm(p),c[h]??0),c[h]??0,t.align[h]??"left")})})]},h))}),Qn(Rm,{children:Qn(m,{name:"fgDim",children:d})}),t.rows.map((p,h)=>Qn(Rm,{children:p.map((y,g)=>Rv(r0.Fragment,{children:[g>0&&Qn(_v,{children:u}),f(y,c[g]??0,t.align[g]??"left")]},g))},h))]})}import{jsx as je,jsxs as Go}from"react/jsx-runtime";function Ov(t){let e=t.baseRole??"fg",o=Tv(t.text);return je(Bi,{flexDirection:"column",children:o.map((n,r)=>je(q2,{block:n,base:e,...t.columns!==void 0?{columns:t.columns}:{}},r))})}function q2(t){let e=Z(),o=t.block,n=e.colorMode==="mono";switch(o.kind){case"code":return je(Bi,{paddingY:0,children:je(Av,{code:o.code,lang:o.lang,open:!o.closed})});case"table":return je(Cv,{header:o.header,align:o.align,rows:o.rows,base:t.base,...t.columns!==void 0?{columns:t.columns}:{}});case"heading":return Go(Bi,{children:[n&&Go(m,{name:"accent",children:["#".repeat(o.level)," "]}),je(m,{name:"accent",children:je(Fi,{spans:o.spans,base:"accent",mono:n})})]});case"quote":return Go(Bi,{children:[Go(m,{name:"depth",children:[e.glyph("you")," "]}),je(m,{name:"fgDim",children:je(Fi,{spans:o.spans,base:"fgDim",mono:n})})]});case"list-item":return Go(Bi,{paddingLeft:o.indent*2,children:[Go(m,{name:"accent",children:[o.ordered?o.marker:e.unicode?"\u2022":"-"," "]}),je(_r,{children:je(Fi,{spans:o.spans,base:t.base,mono:n})})]});case"paragraph":return je(Bi,{children:je(_r,{children:je(Fi,{spans:o.spans,base:t.base,mono:n})})})}}function Fi(t){return je(_r,{children:t.spans.map((e,o)=>je(W2,{span:e,base:t.base,mono:t.mono},o))})}function W2(t){let{span:e,base:o,mono:n}=t;switch(e.kind){case"plain":return je(m,{name:o,children:e.text});case"bold":return n?je(m,{name:o,children:Go(_r,{bold:!0,children:["*",e.text,"*"]})}):je(m,{name:o,children:je(_r,{bold:!0,children:e.text})});case"italic":return n?je(m,{name:o,children:Go(_r,{italic:!0,children:["_",e.text,"_"]})}):je(m,{name:o,children:je(_r,{italic:!0,children:e.text})});case"code":return n?Go(m,{name:"depth",children:["`",e.text,"`"]}):je(m,{name:"depth",children:e.text});case"link":return Go(_r,{children:[je(m,{name:"accent",children:e.text}),Go(m,{name:"fgDim",children:[" (",e.url,")"]})]})}}import"react";import{Box as G2,Text as bce}from"ink";import{jsx as Mm,jsxs as K2}from"react/jsx-runtime";var Om=8,z2=2;function Lm(t,e){return((t-e)%Om+Om)%Om<Om/2?"accent":"accentDim"}function ws(t){let e=Z(),o=t.frame??0;if(!e.animate)return Mm(m,{name:"accent",children:e.aluyMark});if(!e.unicode){let s=Lm(o,0),i=Lm(o,z2);return K2(G2,{children:[Mm(m,{name:s,children:"/"}),Mm(m,{name:i,children:"\\"})]})}let r=Lm(o,0);return Mm(m,{name:r,children:e.aluyMark})}var Y2=9,vl=8,V2=Y2-vl,Mv=25;function Pm(t){return t>=Mv?V2:0}var X2=1,J2=2;function Nm(t){return t==="unsafe"?J2-X2:0}var Im=2,Dm=4,bl=6,$m=8192,i0=65536;function Ui(t,e){if(e<=0||t.length<=e)return t;let o=Array.from(t);return o.length<=e?t:o.slice(o.length-e).join("").replace(/^\n+/,"")}var Q2=4;function Z2(t,e){if(t.kind==="tool"||t.kind==="bang")return t.status==="running"?1+s0(t.liveOutput,e):0;if(t.kind==="subagents"){let o=0;for(let n of t.children)o+=eG(n,e);return 2+o}return t.kind==="broker-error"?t.retrying===!0?5:0:t.kind==="aluy"?0:1}function s0(t,e){let o=(t??"").replace(/\n+$/,"");if(o.length===0)return 0;let n=e>0?e-Q2:0,r=Mi(o,n);return r<=bl?r:bl+1}function eG(t,e){if(!(e>0))return 1;let o=t.status==="running"?"rodando":t.status==="done"?"pronto":t.status==="cancelled"?"parado":"timeout",n=t.summary!==void 0&&t.status!=="running"?` \xB7 ${t.summary}`:"",r=` [${t.label}] x ${o}${n}`;return Math.max(1,Mi(r,e))}function Fm(t){let{live:e,phase:o,hasBlocks:n}=t,r=t.columns??0,s=0,i=e.find(a=>a.kind==="aluy"&&a.streaming);for(let a of e){if(a===i){s+=3;continue}s+=Z2(a,r)}return(o==="thinking"||o==="compacting")&&(s+=1+(n?1:0)),s}function a0(t){let e=vl+Pm(t.rows)+Nm(t.mode)+Fm({live:t.live,phase:t.phase,hasBlocks:t.hasBlocks,...t.columns!==void 0?{columns:t.columns}:{}})+Dm+(t.stagedLines??0);return Math.max(4,t.rows-e-1-Im)}function c0(t){let e=Fm({live:t.live,phase:t.phase,hasBlocks:t.hasBlocks,...t.columns!==void 0?{columns:t.columns}:{}}),o=t.rows-vl-Pm(t.rows)-Im-e-Nm(t.mode)-(t.queuedLines??0)-(t.overlayLines??0)-1;return Math.max(Dm,o)}import{jsx as pn,jsxs as ji}from"react/jsx-runtime";function Lv(t){let e=t.isCurrent===!1?"fgDim":"fg";return ji(Hi,{flexDirection:"column",children:[ji(Hi,{children:[pn(L,{name:"you",role:"fg"}),pn(m,{name:"fg",children:" voc\xEA"})]}),pn(Hi,{paddingLeft:2,children:pn(m,{name:e,children:t.text})})]})}var oG=2,nG=10,rG=6;function Pv(t){let e=Z(),o=t.streaming?Ui(t.text,i0):t.text,n=mr(o),r=t.isCurrent===!1?"fgDim":"fg",s=t.columns&&t.columns>0?t.columns-oG:0,{text:i,hidden:a}=Li(n,t.streaming?t.maxLines:void 0,s),c=(t.frame??0)%nG,l=!e.animate||c<rG;return ji(Hi,{flexDirection:"column",children:[ji(Hi,{children:[t.streaming?pn(ws,{frame:t.frame??0}):pn(L,{name:"aluy",role:"accent"}),pn(m,{name:"accent",children:" aluy"})]}),ji(Hi,{paddingLeft:2,flexDirection:"column",children:[a>0&&ji(m,{name:"fgDim",children:["\u2026 (",a," linhas acima)"]}),pn(Ov,{text:i,baseRole:r,...s>0?{columns:s}:{}}),t.streaming&&(l?pn(m,{name:"accent",children:e.glyph("thinkingCursor")}):pn(tG,{children:" "}))]})]})}import"react";import{Box as Es,Text as Nv}from"ink";import"react";import{Box as sG,Text as l0}from"ink";import{jsx as qi,jsxs as d0}from"react/jsx-runtime";var iG=3;function As(t){let e=Z(),o=t.width??iG,n=t.frame??0,r=t.glyph??"aluy",s=t.glyphRole??"accent",i=e.animate,a=e.glyph("wave"),c=e.glyph("waveHead"),l=i?n%o:-1;return d0(sG,{children:[r==="aluy"?qi(ws,{frame:n}):qi(L,{name:r,role:s}),qi(l0,{children:" "}),Array.from({length:o},(d,f)=>f===l?qi(m,{name:"accent",children:c},f):qi(m,{name:"accentDim",children:a},f)),qi(l0,{children:" "}),d0(m,{name:"fgDim",children:[t.label,"\u2026"]})]})}import{jsx as Ao,jsxs as zo}from"react/jsx-runtime";var u0=7,aG=4;function cG(t){return t.length>=u0?t:t+" ".repeat(u0-t.length)}function Iv(t){let e=Z();if(t.status==="running"){let n=`${t.verbGerund??"rodando"}${t.target?` ${t.target}`:""}`,s=Ui(t.liveOutput??"",$m).replace(/\n+$/,""),i=t.columns&&t.columns>0?t.columns-aG:0,{text:a,hidden:c}=Li(s,t.maxLines,i);return zo(Es,{flexDirection:"column",paddingLeft:2,children:[Ao(As,{glyph:"toolInflight",glyphRole:"depth",label:n,...t.frame!==void 0?{frame:t.frame}:{}}),a.length>0&&zo(Es,{flexDirection:"column",paddingLeft:2,children:[c>0&&zo(m,{name:"fgDim",children:["\u2026 (",c," linhas acima)"]}),a.split(`
513
+ `),closed:y}),s=y?g:e.length;continue}if(i.trim()===""){r();continue}if(n0(i)){let p=s+1<e.length?H2(e[s+1]??""):null;if(p){r();let h=Ev(i),y=h.length,g=[];for(let E=0;E<y;E++)g.push(p[E]??"left");let w=[],C=s+2;for(;C<e.length;C++){let E=e[C]??"";if(E.trim()===""||!n0(E))break;let M=Ev(E),U=[];for(let H=0;H<y;H++)U.push(M[H]??"");w.push(U)}o.push({kind:"table",header:h,align:g,rows:w}),s=C-1;continue}}let c=$2.exec(i);if(c){r(),o.push({kind:"heading",level:c[1].length,spans:Jn(c[2]??"")});continue}let l=B2.exec(i);if(l){r(),o.push({kind:"list-item",ordered:!1,marker:"-",indent:Math.floor((l[1]??"").length/2),spans:Jn(l[3]??"")});continue}let d=U2.exec(i);if(d){r(),o.push({kind:"list-item",ordered:!0,marker:`${d[2]}.`,indent:Math.floor((d[1]??"").length/2),spans:Jn(d[3]??"")});continue}let f=F2.exec(i);if(f){r(),o.push({kind:"quote",spans:Jn(f[1]??"")});continue}let u=Jn(i);n=n?[...n,{kind:"plain",text:" "},...u]:u}return r(),o}import{jsx as Qn,jsxs as Rv}from"react/jsx-runtime";function Cm(t){return Jn(t).map(e=>e.text).join("")}function Cv(t){let e=Z(),o=e.box,n=t.base??"fg",r=e.colorMode==="mono",s=t.header.length,i=t.header.map(Cm),a=t.rows.map(p=>{let h=[];for(let y=0;y<s;y++)h.push(Cm(p[y]??""));return h}),c=TO(i,a,s,t.columns??0),l=e.unicode?`${o.horizontal}\u253C${o.horizontal}`:"-+-",d=c.map(p=>o.horizontal.repeat(p)).join(l),f=(p,h,y)=>{let g=Cm(p),w=xs(g,h),C=xv(w,h,y),E=Jn(C);return Qn(Fi,{spans:E,base:n,mono:r})},u=" ".repeat(kv);return Rv(Rm,{flexDirection:"column",paddingY:0,children:[Qn(Rm,{children:t.header.map((p,h)=>Rv(r0.Fragment,{children:[h>0&&Qn(_v,{children:u}),Qn(m,{name:"accent",children:Qn(_v,{bold:!0,children:xv(xs(Cm(p),c[h]??0),c[h]??0,t.align[h]??"left")})})]},h))}),Qn(Rm,{children:Qn(m,{name:"fgDim",children:d})}),t.rows.map((p,h)=>Qn(Rm,{children:p.map((y,g)=>Rv(r0.Fragment,{children:[g>0&&Qn(_v,{children:u}),f(y,c[g]??0,t.align[g]??"left")]},g))},h))]})}import{jsx as je,jsxs as Go}from"react/jsx-runtime";function Ov(t){let e=t.baseRole??"fg",o=Tv(t.text);return je(Bi,{flexDirection:"column",children:o.map((n,r)=>je(q2,{block:n,base:e,...t.columns!==void 0?{columns:t.columns}:{}},r))})}function q2(t){let e=Z(),o=t.block,n=e.colorMode==="mono";switch(o.kind){case"code":return je(Bi,{paddingY:0,children:je(Av,{code:o.code,lang:o.lang,open:!o.closed})});case"table":return je(Cv,{header:o.header,align:o.align,rows:o.rows,base:t.base,...t.columns!==void 0?{columns:t.columns}:{}});case"heading":return Go(Bi,{children:[n&&Go(m,{name:"accent",children:["#".repeat(o.level)," "]}),je(m,{name:"accent",children:je(Fi,{spans:o.spans,base:"accent",mono:n})})]});case"quote":return Go(Bi,{children:[Go(m,{name:"depth",children:[e.glyph("you")," "]}),je(m,{name:"fgDim",children:je(Fi,{spans:o.spans,base:"fgDim",mono:n})})]});case"list-item":return Go(Bi,{paddingLeft:o.indent*2,children:[Go(m,{name:"accent",children:[o.ordered?o.marker:e.unicode?"\u2022":"-"," "]}),je(_r,{children:je(Fi,{spans:o.spans,base:t.base,mono:n})})]});case"paragraph":return je(Bi,{children:je(_r,{children:je(Fi,{spans:o.spans,base:t.base,mono:n})})})}}function Fi(t){return je(_r,{children:t.spans.map((e,o)=>je(W2,{span:e,base:t.base,mono:t.mono},o))})}function W2(t){let{span:e,base:o,mono:n}=t;switch(e.kind){case"plain":return je(m,{name:o,children:e.text});case"bold":return n?je(m,{name:o,children:Go(_r,{bold:!0,children:["*",e.text,"*"]})}):je(m,{name:o,children:je(_r,{bold:!0,children:e.text})});case"italic":return n?je(m,{name:o,children:Go(_r,{italic:!0,children:["_",e.text,"_"]})}):je(m,{name:o,children:je(_r,{italic:!0,children:e.text})});case"code":return n?Go(m,{name:"depth",children:["`",e.text,"`"]}):je(m,{name:"depth",children:e.text});case"link":return Go(_r,{children:[je(m,{name:"accent",children:e.text}),Go(m,{name:"fgDim",children:[" (",e.url,")"]})]})}}import"react";import{Box as G2,Text as kce}from"ink";import{jsx as Mm,jsxs as K2}from"react/jsx-runtime";var Om=8,z2=2;function Lm(t,e){return((t-e)%Om+Om)%Om<Om/2?"accent":"accentDim"}function ws(t){let e=Z(),o=t.frame??0;if(!e.animate)return Mm(m,{name:"accent",children:e.aluyMark});if(!e.unicode){let s=Lm(o,0),i=Lm(o,z2);return K2(G2,{children:[Mm(m,{name:s,children:"/"}),Mm(m,{name:i,children:"\\"})]})}let r=Lm(o,0);return Mm(m,{name:r,children:e.aluyMark})}var Y2=9,vl=8,V2=Y2-vl,Mv=25;function Pm(t){return t>=Mv?V2:0}var X2=1,J2=2;function Nm(t){return t==="unsafe"?J2-X2:0}var Im=2,Dm=4,bl=6,$m=8192,i0=65536;function Ui(t,e){if(e<=0||t.length<=e)return t;let o=Array.from(t);return o.length<=e?t:o.slice(o.length-e).join("").replace(/^\n+/,"")}var Q2=4;function Z2(t,e){if(t.kind==="tool"||t.kind==="bang")return t.status==="running"?1+s0(t.liveOutput,e):0;if(t.kind==="subagents"){let o=0;for(let n of t.children)o+=eG(n,e);return 2+o}return t.kind==="broker-error"?t.retrying===!0?5:0:t.kind==="aluy"?0:1}function s0(t,e){let o=(t??"").replace(/\n+$/,"");if(o.length===0)return 0;let n=e>0?e-Q2:0,r=Mi(o,n);return r<=bl?r:bl+1}function eG(t,e){if(!(e>0))return 1;let o=t.status==="running"?"rodando":t.status==="done"?"pronto":t.status==="cancelled"?"parado":"timeout",n=t.summary!==void 0&&t.status!=="running"?` \xB7 ${t.summary}`:"",r=` [${t.label}] x ${o}${n}`;return Math.max(1,Mi(r,e))}function Fm(t){let{live:e,phase:o,hasBlocks:n}=t,r=t.columns??0,s=0,i=e.find(a=>a.kind==="aluy"&&a.streaming);for(let a of e){if(a===i){s+=3;continue}s+=Z2(a,r)}return(o==="thinking"||o==="compacting")&&(s+=1+(n?1:0)),s}function a0(t){let e=vl+Pm(t.rows)+Nm(t.mode)+Fm({live:t.live,phase:t.phase,hasBlocks:t.hasBlocks,...t.columns!==void 0?{columns:t.columns}:{}})+Dm+(t.stagedLines??0);return Math.max(4,t.rows-e-1-Im)}function c0(t){let e=Fm({live:t.live,phase:t.phase,hasBlocks:t.hasBlocks,...t.columns!==void 0?{columns:t.columns}:{}}),o=t.rows-vl-Pm(t.rows)-Im-e-Nm(t.mode)-(t.queuedLines??0)-(t.overlayLines??0)-1;return Math.max(Dm,o)}import{jsx as pn,jsxs as ji}from"react/jsx-runtime";function Lv(t){let e=t.isCurrent===!1?"fgDim":"fg";return ji(Hi,{flexDirection:"column",children:[ji(Hi,{children:[pn(L,{name:"you",role:"fg"}),pn(m,{name:"fg",children:" voc\xEA"})]}),pn(Hi,{paddingLeft:2,children:pn(m,{name:e,children:t.text})})]})}var oG=2,nG=10,rG=6;function Pv(t){let e=Z(),o=t.streaming?Ui(t.text,i0):t.text,n=mr(o),r=t.isCurrent===!1?"fgDim":"fg",s=t.columns&&t.columns>0?t.columns-oG:0,{text:i,hidden:a}=Li(n,t.streaming?t.maxLines:void 0,s),c=(t.frame??0)%nG,l=!e.animate||c<rG;return ji(Hi,{flexDirection:"column",children:[ji(Hi,{children:[t.streaming?pn(ws,{frame:t.frame??0}):pn(L,{name:"aluy",role:"accent"}),pn(m,{name:"accent",children:" aluy"})]}),ji(Hi,{paddingLeft:2,flexDirection:"column",children:[a>0&&ji(m,{name:"fgDim",children:["\u2026 (",a," linhas acima)"]}),pn(Ov,{text:i,baseRole:r,...s>0?{columns:s}:{}}),t.streaming&&(l?pn(m,{name:"accent",children:e.glyph("thinkingCursor")}):pn(tG,{children:" "}))]})]})}import"react";import{Box as Es,Text as Nv}from"ink";import"react";import{Box as sG,Text as l0}from"ink";import{jsx as qi,jsxs as d0}from"react/jsx-runtime";var iG=3;function As(t){let e=Z(),o=t.width??iG,n=t.frame??0,r=t.glyph??"aluy",s=t.glyphRole??"accent",i=e.animate,a=e.glyph("wave"),c=e.glyph("waveHead"),l=i?n%o:-1;return d0(sG,{children:[r==="aluy"?qi(ws,{frame:n}):qi(L,{name:r,role:s}),qi(l0,{children:" "}),Array.from({length:o},(d,f)=>f===l?qi(m,{name:"accent",children:c},f):qi(m,{name:"accentDim",children:a},f)),qi(l0,{children:" "}),d0(m,{name:"fgDim",children:[t.label,"\u2026"]})]})}import{jsx as Ao,jsxs as zo}from"react/jsx-runtime";var u0=7,aG=4;function cG(t){return t.length>=u0?t:t+" ".repeat(u0-t.length)}function Iv(t){let e=Z();if(t.status==="running"){let n=`${t.verbGerund??"rodando"}${t.target?` ${t.target}`:""}`,s=Ui(t.liveOutput??"",$m).replace(/\n+$/,""),i=t.columns&&t.columns>0?t.columns-aG:0,{text:a,hidden:c}=Li(s,t.maxLines,i);return zo(Es,{flexDirection:"column",paddingLeft:2,children:[Ao(As,{glyph:"toolInflight",glyphRole:"depth",label:n,...t.frame!==void 0?{frame:t.frame}:{}}),a.length>0&&zo(Es,{flexDirection:"column",paddingLeft:2,children:[c>0&&zo(m,{name:"fgDim",children:["\u2026 (",c," linhas acima)"]}),a.split(`
514
514
  `).map((l,d)=>Ao(Es,{children:Ao(m,{name:"fgDim",children:l})},d))]})]})}let o=t.status==="err";return zo(Es,{flexDirection:"column",paddingLeft:2,children:[zo(Es,{children:[Ao(L,{name:"tool",role:"depth"}),zo(m,{name:"fg",children:[" ",cG(t.verb)]}),Ao(Nv,{children:" "}),Ao(m,{name:"fg",children:t.target}),Ao(Nv,{children:" "}),Ao(m,{name:"fgDim",children:t.result}),Ao(Nv,{children:" "}),o?Ao(L,{name:"err",role:"danger"}):Ao(L,{name:"ok",role:"success"})]}),o&&t.output&&zo(Es,{flexDirection:"column",paddingLeft:2,children:[zo(m,{name:"fgDim",children:[e.box.topLeft," sa\xEDda ",e.box.horizontal.repeat(8)]}),t.output.split(`
515
515
  `).map((n,r)=>zo(Es,{children:[zo(m,{name:"fgDim",children:[e.box.vertical," "]}),Ao(m,{name:"danger",children:n})]},r)),zo(m,{name:"fgDim",children:[e.box.bottomLeft," ",t.result," ",e.box.horizontal.repeat(4)]})]})]})}import"react";import{Box as xt,Text as Wi}from"ink";import{jsx as be,jsxs as he}from"react/jsx-runtime";function lG(t){if(!t)return;let e=t.split(".").pop();return e&&e!==t?e:void 0}function dG(t){return t.category==="always-ask:destructive"}function uG(t){let e=/^\[sub-agente:\s*([^\]]+)\]/.exec(t.reason??"");return e?e[1].trim():null}function mG(t){let e=t.effect.kind;return e==="diff"||e==="path"?`edit \u2500 ${t.effect.path??t.effect.exact}`:"bash"}function Dv(t){let e=Z(),o=t.request,n=dG(o),r=o.category==="always-ask:network"||t.egressOutsideAllowlist===!0,s=uG(o),i=n?"destrutivo \xB7 ask":"ask";return he(xt,{flexDirection:"column",paddingLeft:2,children:[he(xt,{children:[he(m,{name:"accent",children:[e.box.topLeft," "]}),be(L,{name:"ask",role:"accent"}),he(m,{name:"accent",children:[" ",i," \u2500 ",mG(o)," ",e.box.horizontal.repeat(2),e.box.topRight]})]}),be(m,{name:"accent",children:e.box.vertical}),s!==null&&he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(L,{name:"subagents",role:"accent"}),be(m,{name:"accent",children:" sub-agente: "}),be(m,{name:"fg",children:s})]}),be(hG,{request:o}),r&&he(xt,{flexDirection:"column",children:[he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(L,{name:"ask",role:"accent"}),be(m,{name:"accent",children:" rede \xB7 ask \xB7 destino fora da allowlist"})]}),t.egressTarget&&he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(m,{name:"depth",children:t.egressTarget})]})]}),he(m,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(40),e.box.teeRight]}),n?he(xt,{flexDirection:"column",children:[he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(L,{name:"ask",role:"accent"}),be(m,{name:"accent",children:" esta a\xE7\xE3o n\xE3o pode ser desfeita"})]}),he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(m,{name:"danger",children:"[n] negar"}),be(Wi,{children:" "}),be(m,{name:"accent",children:"[a] aprovar mesmo assim"})]})]}):he(xt,{flexDirection:"column",children:[he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(L,{name:"ask",role:"accent"}),he(m,{name:"accent",children:[" ",pG(o)]})]}),he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(m,{name:"accent",children:"[a] aprovar"}),be(Wi,{children:" "}),o.alwaysAsk===!1&&be(m,{name:"accent",children:"[s] sempre nesta sess\xE3o"})]}),he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(m,{name:"danger",children:"[n] negar"}),be(Wi,{children:" "}),be(m,{name:"fgDim",children:"[e] editar"})]})]}),he(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42),e.box.bottomRight]}),be(m,{name:"fgDim",children:fG(o,n)})]})}function fG(t,e){return e?"n nega (recomendado) \xB7 a aprova mesmo assim \xB7 esc cancela":t.alwaysAsk===!1?"a aprova \xB7 s sempre \xB7 n nega \xB7 e edita \xB7 esc cancela":"a aprova \xB7 n nega \xB7 e edita \xB7 esc cancela"}function pG(t){return t.effect.kind==="diff"||t.effect.kind==="path"?"aplicar esta altera\xE7\xE3o?":"executar este comando?"}function hG(t){let e=Z(),o=t.request.effect;if(o.kind==="diff"){let n=Di(lG(o.path??o.exact));return be(xt,{flexDirection:"column",children:o.exact.split(`
516
516
  `).map((r,s)=>he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(gG,{line:r,lang:n??void 0})]},s))})}return be(xt,{flexDirection:"column",children:o.exact.split(`
517
517
  `).map((n,r)=>he(xt,{children:[he(m,{name:"accent",children:[e.box.vertical," "]}),be(m,{name:"fg",children:n})]},r))})}function gG(t){let e=Z(),o=t.line;return o.startsWith("---")||o.startsWith("+++")||o.startsWith("@@")?be(m,{name:"fgDim",children:o}):o.startsWith("-")?he(Wi,{children:[he(m,{name:"danger",children:[e.glyph("diffDel")," "]}),be(m0,{code:o.slice(1),lang:t.lang,fallback:"danger"})]}):o.startsWith("+")?he(Wi,{children:[he(m,{name:"success",children:[e.glyph("diffAdd")," "]}),be(m0,{code:o.slice(1),lang:t.lang,fallback:"success"})]}):be(m,{name:"fgDim",children:o})}function m0(t){if(t.lang===void 0||t.code==="")return be(m,{name:t.fallback,children:t.code});let e=yl(t.code,t.lang);return be(Wi,{children:e.map((o,n)=>be(m,{name:o.role,children:o.text},n))})}import"react";import{Box as Ko}from"ink";import{jsx as Ft,jsxs as Ne}from"react/jsx-runtime";var hn=-1,$v=42,yG=13;function bG(t){return t.kind!=="text"&&t.allowOther!==!1}function Fv(t){let e=Z(),{spec:o}=t;return Ne(Ko,{flexDirection:"column",paddingLeft:2,children:[Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.topLeft," "]}),Ft(L,{name:"ask",role:"accent"}),Ne(m,{name:"accent",children:[" ","Pergunta ",e.box.horizontal.repeat($v-yG),e.box.topRight]})]}),Ft(m,{name:"accent",children:e.box.vertical}),o.header!==void 0&&Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"depth",children:o.header})]}),o.question.split(`
518
- `).map((n,r)=>Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"fg",children:n})]},`q-${r}`)),Ft(m,{name:"accent",children:e.box.vertical}),o.kind==="text"?Ft(xG,{theme:e,draft:t.draft??""}):Ft(vG,{...t}),Ne(m,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat($v),e.box.teeRight]}),Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"fgDim",children:SG(o,t.editing===!0)})]}),Ne(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat($v),e.box.bottomRight]})]})}function vG(t){let e=Z(),{spec:o}=t,n=o.options??[],r=o.kind==="multi",s=t.selected??new Set;return Ne(Ko,{flexDirection:"column",children:[n.map((i,a)=>{let c=t.cursor===a,l=r?s.has(a)?"[x]":"[ ]":c?"(\u2022)":"( )";return Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ne(m,{name:c?"accent":"fgDim",children:[c?"\u203A":" "," "]}),Ne(m,{name:c?"accent":"fgDim",children:[l," "]}),Ft(m,{name:c?"accent":"fg",children:i.label}),i.description!==void 0&&Ne(m,{name:"fgDim",children:[" \u2014 ",i.description]})]},`opt-${a}`)}),bG(o)&&Ft(kG,{theme:e,onCursor:t.cursor===hn,editing:t.editing===!0&&t.cursor===hn,draft:t.draft??""})]})}function kG(t){let{theme:e,onCursor:o,editing:n,draft:r}=t;return Ne(Ko,{flexDirection:"column",children:[Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ne(m,{name:o?"accent":"fgDim",children:[o?"\u203A":" "," "]}),Ft(m,{name:o?"accent":"fg",children:"Outro (resposta livre)"})]}),n&&Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"fg",children:r}),Ft(m,{name:"accent",children:e.glyph("cursor")})]})]})}function xG(t){let{theme:e,draft:o}=t;return Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ne(m,{name:"depth",children:[e.glyph("prompt")," "]}),Ft(m,{name:"fg",children:o}),Ft(m,{name:"accent",children:e.glyph("cursor")})]})}function SG(t,e){return e?"enter confirma \xB7 esc cancela a digita\xE7\xE3o":t.kind==="text"?"digite a resposta \xB7 enter confirma \xB7 esc cancela":t.kind==="multi"?"\u2191\u2193 navega \xB7 espa\xE7o marca \xB7 enter confirma \xB7 esc cancela":"\u2191\u2193 navega \xB7 enter escolhe \xB7 esc cancela"}import"react";import{Box as kl}from"ink";import{jsx as Bm,jsxs as Eo}from"react/jsx-runtime";function Bv(t){let e=Z(),o=t.backend==="local"?"provider local indispon\xEDvel":"broker indispon\xEDvel",n=t.retrying?"tentando de novo":t.headline??o,r=t.retrying?"esc cancelar":"r tentar agora \xB7 esc cancelar";return Eo(kl,{flexDirection:"column",paddingLeft:4,children:[Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.topLeft," "]}),Bm(L,{name:"broker",role:"depth"}),Eo(m,{name:"danger",children:[" ",n," ",e.box.horizontal.repeat(4)," "]}),Bm(L,{name:"err",role:"danger"})]}),Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.vertical," "]}),Bm(m,{name:"fg",children:t.message})]}),(t.status!==void 0||t.attempt!==void 0||t.retryInSeconds!==void 0)&&Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.vertical," "]}),Eo(m,{name:"fgDim",children:[t.status!==void 0?`${t.status} \xB7 `:"",t.retryInSeconds!==void 0?`tentando de novo em ${t.retryInSeconds}s `:"",t.attempt!==void 0&&t.maxAttempts!==void 0?`(${t.attempt}/${t.maxAttempts})`:""]})]}),Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.vertical," "]}),Bm(m,{name:"fgDim",children:r})]}),Eo(m,{name:"danger",children:[e.box.bottomLeft,e.box.horizontal.repeat(40)]})]})}import"react";import{Box as Rr,Text as wG}from"ink";import{jsx as gn,jsxs as nt}from"react/jsx-runtime";function AG(t){return t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function Uv(t){let e=Z();return nt(Rr,{flexDirection:"column",paddingLeft:2,children:[nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.topLeft," "]}),gn(L,{name:"clock",role:"accent"}),nt(m,{name:"accent",children:[" teto da sess\xE3o ",e.box.horizontal.repeat(6)," pausado"]})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"fg",children:t.reason})]}),t.budgetPct!==void 0&&nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(L,{name:"clock",role:"accent"}),nt(m,{name:"accent",children:[" ",t.budgetPct,"% do teto da sess\xE3o"]}),t.maxTokens!==void 0&&nt(m,{name:"fgDim",children:[" (teto: ",AG(t.maxTokens)," tokens)"]})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"fgDim",children:"o agente pausou para voc\xEA decidir."})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(L,{name:"window",role:"fgDim"}),nt(m,{name:"fgDim",children:[" janela: ",t.windowPct,"% usada"]})]}),t.canCompact&&nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"accent",children:"[k] compactar"}),gn(m,{name:"fgDim",children:" resume a conversa e continua (libera a janela)"})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"accent",children:"[c] continuar (+50 itera\xE7\xF5es)"}),gn(wG,{children:" "}),gn(m,{name:"fgDim",children:"[n] encerrar"})]}),nt(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as Ts,Text as EG}from"ink";import{Fragment as _G,jsx as yn,jsxs as Ct}from"react/jsx-runtime";function TG(t,e,o){switch(t){case"same-tool-call":return`o agente repetiu a tool "${o}" ${e}\xD7 sem avan\xE7ar.`;case"same-tool-error":return`a mesma falha se repetiu ${e}\xD7 seguidas (${o}).`;case"empty-turns":return`o agente respondeu vazio ${e}\xD7 seguidas (sem texto nem a\xE7\xE3o).`;case"no-progress":return`${e} itera\xE7\xF5es sem avan\xE7o real (nenhum arquivo/edi\xE7\xE3o/comando novo).`}}function jv(t){let e=Z(),o=TG(t.kind,t.count,t.sample);return Ct(Ts,{flexDirection:"column",paddingLeft:2,children:[Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.topLeft," "]}),yn(L,{name:"clock",role:"accent"}),Ct(m,{name:"accent",children:[" parece travado ",e.box.horizontal.repeat(6)," pausado"]})]}),Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"fg",children:o})]}),t.redirecting?Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"accent",children:"[r] "}),yn(m,{name:"fgDim",children:"digite a nova instru\xE7\xE3o e tecle Enter (esc cancela)."})]}):Ct(_G,{children:[Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"fgDim",children:"o agente pausou para voc\xEA decidir o rumo."})]}),Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"accent",children:"[r] redirecionar"}),yn(m,{name:"fgDim",children:" (dar uma nova instru\xE7\xE3o)"})]}),Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"accent",children:"[c] continuar mesmo assim"}),yn(EG,{children:" "}),yn(m,{name:"fgDim",children:"[n] encerrar"})]})]}),Ct(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as Mle}from"ink";import{jsx as Nle,jsxs as Ile}from"react/jsx-runtime";import DG from"react";import{Box as zi,Text as $G}from"ink";function Hv(t,e=""){return t.parallelWhileBusy===!0||t.id==="ask"?!0:t.parallelWhileBusyWith?t.parallelWhileBusyWith(e):!1}function RG(t){return t.trim()===""}function CG(t){let e=t.trim().split(/\s+/)[0]?.toLowerCase()??"";return e===""?!0:e==="list"||e==="search"}function jm(t){return t.kind==="command"?t.command.name:`${t.parent.name} ${t.sub.name}`}function qv(t){let e=t.kind==="command"?t.command:t.parent;return e.source==="user"?"usu\xE1rio":e.section??"sess\xE3o"}function Wv(t){return t.kind==="command"?t.command.summary:t.sub.summary}var OG=56;function MG(t,e){let o=jm(t),r=(t.kind==="subcommand"?4:2)+ye(`/${o}`)+Math.max(1,18-o.length)+ye(Wv(t));return Math.max(1,Math.ceil(r/e))}function Um(t,e){let o=e!==void 0&&e>0?Math.max(1,Math.ceil(OG/e)):1,n=null;for(let r of t){let s=qv(r);s!==n&&(o+=1),n=s,o+=e!==void 0&&e>0?MG(r,e):1}return o}function f0(t,e,o,n){if(Um(t,n)<=o)return{slice:t,hiddenAbove:0,hiddenBelow:0};let r=Number.isFinite(e)?Math.max(0,Math.min(e,t.length-1)):0,s=(d,f)=>Um(t.slice(d,f),n)+(d>0?1:0)+(f<t.length?1:0),i=r,a=r+1,c=!0,l=!0;for(;l;)l=!1,c?i>0&&s(i-1,a)<=o?(i--,l=!0):a<t.length&&s(i,a+1)<=o&&(a++,l=!0):a<t.length&&s(i,a+1)<=o?(a++,l=!0):i>0&&s(i-1,a)<=o&&(i--,l=!0),c=!c;for(;i>0&&s(i-1,a)<=o;)i--;for(;a<t.length&&s(i,a+1)<=o;)a++;return{slice:t.slice(i,a),hiddenAbove:i,hiddenBelow:t.length-a}}function Hm(t){return t.kind==="subcommand"?`/${t.parent.name} ${t.sub.name} `:t.command.subcommands&&t.command.subcommands.length>0?`/${t.command.name} `:`/${t.command.name}`}function Gv(t){return t.kind==="subcommand"&&t.sub.terminal===!0}function p0(t){return`/${t.parent.name} ${t.sub.name}`}var To=[{name:"help",summary:"mostra esta lista",summaryKey:"cmd.help",source:"native",id:"help",section:"sess\xE3o",parallelWhileBusy:!0},{name:"login",summary:"entrar na conta",summaryKey:"cmd.login",source:"native",id:"login",section:"conta"},{name:"logout",summary:"sair da conta",summaryKey:"cmd.logout",source:"native",id:"logout",section:"conta"},{name:"whoami",summary:"conta, org e escopos atuais",summaryKey:"cmd.whoami",source:"native",id:"whoami",section:"conta",parallelWhileBusy:!0},{name:"doctor",summary:"diagn\xF3stico da instala\xE7\xE3o \xB7 credencial, broker, MCP, config (read-only)",summaryKey:"cmd.doctor",source:"native",id:"doctor",section:"conta",parallelWhileBusy:!0},{name:"model",summary:"trocar o tier",summaryKey:"cmd.model",source:"native",id:"model",section:"sess\xE3o"},{name:"provider",summary:"seta o provider do modelo Custom",summaryKey:"cmd.provider",source:"native",id:"provider",section:"sess\xE3o"},{name:"effort",summary:"seta o reasoning_effort (low/medium/high/custom) \xB7 passthrough \u226432 chars",summaryKey:"cmd.effort",source:"native",id:"effort",section:"sess\xE3o",parallelWhileBusyWith:RG},{name:"theme",summary:"trocar o tema (dark/light) \xB7 auto-detecta no boot",summaryKey:"cmd.theme",source:"native",id:"theme",section:"sess\xE3o"},{name:"lang",summary:"trocar o idioma (pt-BR/en) \xB7 auto-detecta no boot",summaryKey:"cmd.lang",source:"native",id:"lang",section:"sess\xE3o"},{name:"usage",summary:"tokens e janela desta sess\xE3o",summaryKey:"cmd.usage",source:"native",id:"usage",section:"sess\xE3o",parallelWhileBusy:!0},{name:"rename",summary:"d\xE1 um nome + cor de identifica\xE7\xE3o \xE0 sess\xE3o \xB7 \u25CFnome no composer",summaryKey:"cmd.rename",source:"native",id:"rename",section:"sess\xE3o"},{name:"history",summary:"navega e RETOMA uma sess\xE3o anterior \xB7 sem sair do aluy",summaryKey:"cmd.history",source:"native",id:"history",section:"sess\xE3o"},{name:"ask",summary:"pergunta PARALELA (read-only) sem parar o trabalho em curso",source:"native",id:"ask",section:"sess\xE3o",parallelWhileBusy:!0},{name:"notify",summary:"liga/desliga o sino de aten\xE7\xE3o (on/off)",summaryKey:"cmd.notify",source:"native",id:"notify",section:"sess\xE3o"},{name:"split",summary:"liga/desliga o painel de LOG ao lado do chat (Ctrl+L \xB7 /view)",source:"native",id:"split",section:"sess\xE3o"},{name:"fullscreen",summary:"modo cockpit (tela cheia, alt-screen)",summaryKey:"cmd.fullscreen",source:"native",id:"fullscreen",section:"sess\xE3o"},{name:"undo",summary:"desfaz a \xFAltima edi\xE7\xE3o de arquivo do agente",summaryKey:"cmd.undo",source:"native",id:"undo",section:"workspace"},{name:"redo",summary:"refaz a \xFAltima edi\xE7\xE3o desfeita",summaryKey:"cmd.redo",source:"native",id:"redo",section:"workspace"},{name:"rewind",summary:"volta a um ponto da sess\xE3o (c\xF3digo e/ou conversa) \xB7 Esc Esc",summaryKey:"cmd.rewind",source:"native",id:"rewind",section:"workspace"},{name:"clear",summary:"limpa a sess\xE3o (contexto) \xB7 full tamb\xE9m APAGA a mem\xF3ria do agente",summaryKey:"cmd.clear",source:"native",id:"clear",section:"sess\xE3o",subcommands:[{name:"full",summary:"limpa a sess\xE3o E APAGA a mem\xF3ria (global+projeto) \xB7 confirma",usage:"full",terminal:!0},{name:"memory",summary:"APAGA s\xF3 a mem\xF3ria do agente (global+projeto) \xB7 confirma",usage:"memory",terminal:!0}]},{name:"compact",summary:"compacta o contexto (resume a conversa e continua)",summaryKey:"cmd.compact",source:"native",id:"compact",section:"sess\xE3o"},{name:"cycle",summary:"roda uma tarefa em ciclos \xB7 com tetos duros e parada (anti-runaway)",summaryKey:"cmd.cycle",source:"native",id:"cycle",section:"sess\xE3o",usage:'<intervalo> "<tarefa>"',subcommands:[{name:"pause",summary:"pausa o /cycle em execu\xE7\xE3o (sem matar; Esc ainda para)",usage:"pause",terminal:!0},{name:"resume",summary:"retoma um /cycle pausado",usage:"resume",terminal:!0},{name:"edit",summary:"reconfigura o /cycle ativo \xB7 vale na pr\xF3xima itera\xE7\xE3o",usage:'edit ["<tarefa>"] [<intervalo>] [--max-iter N]'},{name:"status",summary:"mostra o /cycle ativo (config corrente \xB7 pausado?)",usage:"status",terminal:!0},{name:"stop",summary:"para/encerra o /cycle em execu\xE7\xE3o (= Esc)",usage:"stop",terminal:!0}]},{name:"cron",summary:"agendamento PERSISTENTE \xB7 lista/gerencia os jobs (mesmo motor do aluy cron)",source:"native",id:"cron",section:"sess\xE3o",usage:'list \xB7 add <quando> "<tarefa>" \xB7 edit/enable/disable/rm <id>',subcommands:[{name:"list",summary:"lista os jobs (id \xB7 on/off \xB7 schedule \xB7 tarefa)",usage:"list",terminal:!0},{name:"add",summary:"agenda um job novo (cron de 5 campos)",usage:'add <quando> "<tarefa>" [--yolo]'},{name:"edit",summary:"reconfigura um job (preserva id)",usage:'edit <id> [--quando "<cron>"] [--tarefa "<txt>"] [--yolo|--no-yolo]'},{name:"enable",summary:"reativa um job desabilitado",usage:"enable <id>"},{name:"disable",summary:"desabilita SEM excluir (sai do agendador)",usage:"disable <id>"},{name:"rm",summary:"remove um job de vez",usage:"rm <id>"}]},{name:"permissions",summary:"painel \xB7 modo, grants e tools seguras (sempre-ask travado)",summaryKey:"cmd.permissions",source:"native",id:"permissions",section:"workspace"},{name:"tools",summary:"invent\xE1rio unificado das ferramentas \xB7 nativas, MCP, permiss\xE3o (read-only)",summaryKey:"cmd.tools",source:"native",id:"tools",section:"workspace",parallelWhileBusy:!0},{name:"add-dir",summary:"autoriza um diret\xF3rio EXTRA p/ o agente (sess\xE3o) \xB7 sem args lista",summaryKey:"cmd.addDir",source:"native",id:"add-dir",section:"workspace"},{name:"init",summary:"cria um AGENT.md neste projeto",summaryKey:"cmd.init",source:"native",id:"init",section:"workspace"},{name:"memory",summary:"v\xEA/edita/esquece/fixa a mem\xF3ria do agente (global + projeto)",summaryKey:"cmd.memory",source:"native",id:"memory",section:"workspace",subcommands:[{name:"list",summary:"lista a mem\xF3ria (global + projeto)",usage:"list"},{name:"forget",summary:"remove um fato pelo id",usage:"forget <id>"},{name:"edit",summary:"corrige o texto de um fato",usage:"edit <id> <texto>"},{name:"pin",summary:"fixa um fato (reten\xE7\xE3o)",usage:"pin <id>"},{name:"unpin",summary:"desfixa um fato",usage:"unpin <id>"}]},{name:"todo",summary:"v\xEA/gerencia o backlog de tarefas anotadas (done/clear)",summaryKey:"cmd.todo",source:"native",id:"todo",section:"workspace",subcommands:[{name:"list",summary:"lista o backlog (pendentes + feitos)",usage:"list"},{name:"done",summary:"marca um item como conclu\xEDdo",usage:"done <id>"},{name:"clear",summary:"remove os itens j\xE1 feitos",usage:"clear",terminal:!0}]},{name:"mcp",summary:"lista/gerencia servers MCP (add/remove/disable/enable \xB7 search <termo>)",summaryKey:"cmd.mcp",source:"native",id:"mcp",section:"workspace",parallelWhileBusyWith:CG,subcommands:[{name:"search",summary:"busca no registro oficial aberto",usage:"search <termo>"},{name:"add",summary:"adiciona um server local (stdio)",usage:"add <nome> -- <cmd> [args...]"},{name:"list",summary:"lista os servers de todas as fontes",usage:"list"},{name:"remove",summary:"remove um server gerenciado pelo aluy",usage:"remove <nome>"},{name:"disable",summary:"desativa um server sem desinstalar",usage:"disable <nome>"},{name:"enable",summary:"reativa um server desativado",usage:"enable <nome>"},{name:"reconnect",summary:'re-sobe + re-handshake os servers (recupera "Not connected")',usage:"reconnect [all|<nome>]"},{name:"reload",summary:"re-l\xEA o ~/.aluy/mcp.json + reconecta (aplica edi\xE7\xF5es da config)",usage:"reload [all|<nome>]"}]},{name:"agents",summary:"lista os agentes .md mapeados (global + projeto \xB7 v\xE1lidos + rejeitados)",source:"native",id:"agents",section:"workspace",parallelWhileBusy:!0},{name:"skills",summary:"lista as skills SKILL.md mapeadas (global + projeto \xB7 v\xE1lidas + rejeitadas)",source:"native",id:"skills",section:"workspace",parallelWhileBusy:!0},{name:"workflows",summary:"fluxos de atividades que coordenam o agente \u2014 lista, executa e ativa",summaryKey:"cmd.workflows",source:"native",id:"workflows",section:"workspace",subcommands:[{name:"run",summary:"executa as atividades do workflow em sequ\xEAncia",usage:"run <nome>"},{name:"use",summary:"ativa o modo de workflow \u2014 submiss\xF5es seguem o fluxo",usage:"use <nome>"}],parallelWhileBusy:!0},{name:"rooms",summary:"salas entre agentes \u2014 lista, cria, l\xEA e OBSERVA AO VIVO a conversa da frota",source:"native",id:"rooms",section:"workspace",subcommands:[{name:"list",summary:"lista as salas (c\xF3digo \xB7 msgs \xB7 atividade \xB7 quem)",usage:"list"},{name:"new",summary:"cria uma sala e mostra o c\xF3digo",usage:"new"},{name:"read",summary:"snapshot da conversa de uma sala",usage:"read <c\xF3digo>"},{name:"watch",summary:"observa a conversa AO VIVO (poll at\xE9 2min)",usage:"watch <c\xF3digo>"}]},{name:"subagent",summary:"fala 1:1 com um sub-agente (perfil .md) numa sub-sess\xE3o focada e cont\xEDnua",source:"native",id:"subagent",section:"workspace"},{name:"back",summary:"volta ao agente principal (sai do foco de /subagent)",source:"native",id:"back",section:"workspace"},{name:"quit",summary:"sair do aluy",summaryKey:"cmd.quit",source:"native",id:"quit",section:"sess\xE3o"}];function h0(t,e){let o=!1,n=t.map(r=>{if(r.summaryKey===void 0)return r;let s=e(r.summaryKey);return s===r.summary?r:(o=!0,{...r,summary:s})});return o?n:t}var LG=[{id:"action:cycle-mode",label:"trocar modo",description:"cicla o modo da sess\xE3o (plan \u2192 normal \u2192 yolo) \xB7 tamb\xE9m no Tab",action:{kind:"action",actionId:"cycle-mode"}}];function PG(t=[],e=To){return[...[...e,...t].map(n=>({id:`cmd:${n.source}:${n.name}`,label:`/${n.name}`,description:n.summary,action:{kind:"command",command:n}})),...LG]}function g0(t,e=[],o=To){let n=PG(e,o),r=t.trim();if(r==="")return n.map(i=>({...i,score:0,matched:[]}));let s=[];for(let i of n){let a=Vc(r,i.label),c=Vc(r,i.description);if(!a&&!c)continue;let l=a?a.score:-1/0,d=c?c.score-5:-1/0,f=Math.max(l,d);s.push({...i,score:f,matched:a?a.matched:[]})}return s.sort((i,a)=>a.score-i.score||i.label.length-a.label.length||i.label.localeCompare(a.label)),s}function Gi(t,e=[]){let o=t.trim();if(o.startsWith("!")){let d=o.slice(1).trim();return d===""?{kind:"goal",text:""}:{kind:"bang",command:d}}if(!o.startsWith("/"))return{kind:"goal",text:o};let n=o.slice(1),r=n.search(/\s/),s=(r===-1?n:n.slice(0,r)).toLowerCase(),i=s==="view"?"split":s==="cockpit"?"fullscreen":s,a=r===-1?"":n.slice(r+1).trim(),l=[...To,...e].find(d=>d.name===i);return l?{kind:"command",command:l,args:a}:{kind:"unknown-command",name:i}}function zv(t,e=[]){if(!t.startsWith("/"))return!1;let o=t.slice(1);if(!/\s/.test(o))return!0;let n=o.search(/\s/),r=o.slice(0,n).toLowerCase(),s=o.slice(n).replace(/^\s+/,""),a=[...To,...e].find(c=>c.name===r);return!a?.subcommands||a.subcommands.length===0?!1:!/\s/.test(s)}function NG(t=[],e=To){let o=[];for(let n of[...e,...t]){o.push({kind:"command",command:n});for(let r of n.subcommands??[])o.push({kind:"subcommand",parent:n,sub:r})}return o}function y0(t,e=[],o=To){let n=t.trim().replace(/\s+/g," ").toLowerCase(),r=NG(e,o);if(n==="")return r;let s=c=>jm(c).toLowerCase(),i=r.filter(c=>s(c).startsWith(n)),a=r.filter(c=>!s(c).startsWith(n)&&s(c).includes(n));return[...i,...a]}var IG="COMANDOS DA SESS\xC3O (o HUMANO os digita; voc\xEA os RECOMENDA, n\xE3o os invoca como ferramenta):";function b0(t=To){let e=t.filter(o=>o.summary.trim()!=="").map(o=>{let n=` /${o.name} \u2014 ${o.summary}`;return o.usage?`${n}
518
+ `).map((n,r)=>Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"fg",children:n})]},`q-${r}`)),Ft(m,{name:"accent",children:e.box.vertical}),o.kind==="text"?Ft(xG,{theme:e,draft:t.draft??""}):Ft(vG,{...t}),Ne(m,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat($v),e.box.teeRight]}),Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"fgDim",children:SG(o,t.editing===!0)})]}),Ne(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat($v),e.box.bottomRight]})]})}function vG(t){let e=Z(),{spec:o}=t,n=o.options??[],r=o.kind==="multi",s=t.selected??new Set;return Ne(Ko,{flexDirection:"column",children:[n.map((i,a)=>{let c=t.cursor===a,l=r?s.has(a)?"[x]":"[ ]":c?"(\u2022)":"( )";return Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ne(m,{name:c?"accent":"fgDim",children:[c?"\u203A":" "," "]}),Ne(m,{name:c?"accent":"fgDim",children:[l," "]}),Ft(m,{name:c?"accent":"fg",children:i.label}),i.description!==void 0&&Ne(m,{name:"fgDim",children:[" \u2014 ",i.description]})]},`opt-${a}`)}),bG(o)&&Ft(kG,{theme:e,onCursor:t.cursor===hn,editing:t.editing===!0&&t.cursor===hn,draft:t.draft??""})]})}function kG(t){let{theme:e,onCursor:o,editing:n,draft:r}=t;return Ne(Ko,{flexDirection:"column",children:[Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ne(m,{name:o?"accent":"fgDim",children:[o?"\u203A":" "," "]}),Ft(m,{name:o?"accent":"fg",children:"Outro (resposta livre)"})]}),n&&Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ft(m,{name:"fg",children:r}),Ft(m,{name:"accent",children:e.glyph("cursor")})]})]})}function xG(t){let{theme:e,draft:o}=t;return Ne(Ko,{children:[Ne(m,{name:"accent",children:[e.box.vertical," "]}),Ne(m,{name:"depth",children:[e.glyph("prompt")," "]}),Ft(m,{name:"fg",children:o}),Ft(m,{name:"accent",children:e.glyph("cursor")})]})}function SG(t,e){return e?"enter confirma \xB7 esc cancela a digita\xE7\xE3o":t.kind==="text"?"digite a resposta \xB7 enter confirma \xB7 esc cancela":t.kind==="multi"?"\u2191\u2193 navega \xB7 espa\xE7o marca \xB7 enter confirma \xB7 esc cancela":"\u2191\u2193 navega \xB7 enter escolhe \xB7 esc cancela"}import"react";import{Box as kl}from"ink";import{jsx as Bm,jsxs as Eo}from"react/jsx-runtime";function Bv(t){let e=Z(),o=t.backend==="local"?"provider local indispon\xEDvel":"broker indispon\xEDvel",n=t.retrying?"tentando de novo":t.headline??o,r=t.retrying?"esc cancelar":"r tentar agora \xB7 esc cancelar";return Eo(kl,{flexDirection:"column",paddingLeft:4,children:[Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.topLeft," "]}),Bm(L,{name:"broker",role:"depth"}),Eo(m,{name:"danger",children:[" ",n," ",e.box.horizontal.repeat(4)," "]}),Bm(L,{name:"err",role:"danger"})]}),Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.vertical," "]}),Bm(m,{name:"fg",children:t.message})]}),(t.status!==void 0||t.attempt!==void 0||t.retryInSeconds!==void 0)&&Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.vertical," "]}),Eo(m,{name:"fgDim",children:[t.status!==void 0?`${t.status} \xB7 `:"",t.retryInSeconds!==void 0?`tentando de novo em ${t.retryInSeconds}s `:"",t.attempt!==void 0&&t.maxAttempts!==void 0?`(${t.attempt}/${t.maxAttempts})`:""]})]}),Eo(kl,{children:[Eo(m,{name:"danger",children:[e.box.vertical," "]}),Bm(m,{name:"fgDim",children:r})]}),Eo(m,{name:"danger",children:[e.box.bottomLeft,e.box.horizontal.repeat(40)]})]})}import"react";import{Box as Rr,Text as wG}from"ink";import{jsx as gn,jsxs as nt}from"react/jsx-runtime";function AG(t){return t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function Uv(t){let e=Z();return nt(Rr,{flexDirection:"column",paddingLeft:2,children:[nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.topLeft," "]}),gn(L,{name:"clock",role:"accent"}),nt(m,{name:"accent",children:[" teto da sess\xE3o ",e.box.horizontal.repeat(6)," pausado"]})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"fg",children:t.reason})]}),t.budgetPct!==void 0&&nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(L,{name:"clock",role:"accent"}),nt(m,{name:"accent",children:[" ",t.budgetPct,"% do teto da sess\xE3o"]}),t.maxTokens!==void 0&&nt(m,{name:"fgDim",children:[" (teto: ",AG(t.maxTokens)," tokens)"]})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"fgDim",children:"o agente pausou para voc\xEA decidir."})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(L,{name:"window",role:"fgDim"}),nt(m,{name:"fgDim",children:[" janela: ",t.windowPct,"% usada"]})]}),t.canCompact&&nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"accent",children:"[k] compactar"}),gn(m,{name:"fgDim",children:" resume a conversa e continua (libera a janela)"})]}),nt(Rr,{children:[nt(m,{name:"accent",children:[e.box.vertical," "]}),gn(m,{name:"accent",children:"[c] continuar (+50 itera\xE7\xF5es)"}),gn(wG,{children:" "}),gn(m,{name:"fgDim",children:"[n] encerrar"})]}),nt(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as Ts,Text as EG}from"ink";import{Fragment as _G,jsx as yn,jsxs as Ct}from"react/jsx-runtime";function TG(t,e,o){switch(t){case"same-tool-call":return`o agente repetiu a tool "${o}" ${e}\xD7 sem avan\xE7ar.`;case"same-tool-error":return`a mesma falha se repetiu ${e}\xD7 seguidas (${o}).`;case"empty-turns":return`o agente respondeu vazio ${e}\xD7 seguidas (sem texto nem a\xE7\xE3o).`;case"no-progress":return`${e} itera\xE7\xF5es sem avan\xE7o real (nenhum arquivo/edi\xE7\xE3o/comando novo).`}}function jv(t){let e=Z(),o=TG(t.kind,t.count,t.sample);return Ct(Ts,{flexDirection:"column",paddingLeft:2,children:[Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.topLeft," "]}),yn(L,{name:"clock",role:"accent"}),Ct(m,{name:"accent",children:[" parece travado ",e.box.horizontal.repeat(6)," pausado"]})]}),Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"fg",children:o})]}),t.redirecting?Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"accent",children:"[r] "}),yn(m,{name:"fgDim",children:"digite a nova instru\xE7\xE3o e tecle Enter (esc cancela)."})]}):Ct(_G,{children:[Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"fgDim",children:"o agente pausou para voc\xEA decidir o rumo."})]}),Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"accent",children:"[r] redirecionar"}),yn(m,{name:"fgDim",children:" (dar uma nova instru\xE7\xE3o)"})]}),Ct(Ts,{children:[Ct(m,{name:"accent",children:[e.box.vertical," "]}),yn(m,{name:"accent",children:"[c] continuar mesmo assim"}),yn(EG,{children:" "}),yn(m,{name:"fgDim",children:"[n] encerrar"})]})]}),Ct(m,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as Ple}from"ink";import{jsx as Dle,jsxs as $le}from"react/jsx-runtime";import DG from"react";import{Box as zi,Text as $G}from"ink";function Hv(t,e=""){return t.parallelWhileBusy===!0||t.id==="ask"?!0:t.parallelWhileBusyWith?t.parallelWhileBusyWith(e):!1}function RG(t){return t.trim()===""}function CG(t){let e=t.trim().split(/\s+/)[0]?.toLowerCase()??"";return e===""?!0:e==="list"||e==="search"}function jm(t){return t.kind==="command"?t.command.name:`${t.parent.name} ${t.sub.name}`}function qv(t){let e=t.kind==="command"?t.command:t.parent;return e.source==="user"?"usu\xE1rio":e.section??"sess\xE3o"}function Wv(t){return t.kind==="command"?t.command.summary:t.sub.summary}var OG=56;function MG(t,e){let o=jm(t),r=(t.kind==="subcommand"?4:2)+ye(`/${o}`)+Math.max(1,18-o.length)+ye(Wv(t));return Math.max(1,Math.ceil(r/e))}function Um(t,e){let o=e!==void 0&&e>0?Math.max(1,Math.ceil(OG/e)):1,n=null;for(let r of t){let s=qv(r);s!==n&&(o+=1),n=s,o+=e!==void 0&&e>0?MG(r,e):1}return o}function f0(t,e,o,n){if(Um(t,n)<=o)return{slice:t,hiddenAbove:0,hiddenBelow:0};let r=Number.isFinite(e)?Math.max(0,Math.min(e,t.length-1)):0,s=(d,f)=>Um(t.slice(d,f),n)+(d>0?1:0)+(f<t.length?1:0),i=r,a=r+1,c=!0,l=!0;for(;l;)l=!1,c?i>0&&s(i-1,a)<=o?(i--,l=!0):a<t.length&&s(i,a+1)<=o&&(a++,l=!0):a<t.length&&s(i,a+1)<=o?(a++,l=!0):i>0&&s(i-1,a)<=o&&(i--,l=!0),c=!c;for(;i>0&&s(i-1,a)<=o;)i--;for(;a<t.length&&s(i,a+1)<=o;)a++;return{slice:t.slice(i,a),hiddenAbove:i,hiddenBelow:t.length-a}}function Hm(t){return t.kind==="subcommand"?`/${t.parent.name} ${t.sub.name} `:t.command.subcommands&&t.command.subcommands.length>0?`/${t.command.name} `:`/${t.command.name}`}function Gv(t){return t.kind==="subcommand"&&t.sub.terminal===!0}function p0(t){return`/${t.parent.name} ${t.sub.name}`}var To=[{name:"help",summary:"mostra esta lista",summaryKey:"cmd.help",source:"native",id:"help",section:"sess\xE3o",parallelWhileBusy:!0},{name:"login",summary:"entrar na conta",summaryKey:"cmd.login",source:"native",id:"login",section:"conta"},{name:"logout",summary:"sair da conta",summaryKey:"cmd.logout",source:"native",id:"logout",section:"conta"},{name:"whoami",summary:"conta, org e escopos atuais",summaryKey:"cmd.whoami",source:"native",id:"whoami",section:"conta",parallelWhileBusy:!0},{name:"doctor",summary:"diagn\xF3stico da instala\xE7\xE3o \xB7 credencial, broker, MCP, config (read-only)",summaryKey:"cmd.doctor",source:"native",id:"doctor",section:"conta",parallelWhileBusy:!0},{name:"model",summary:"trocar o tier",summaryKey:"cmd.model",source:"native",id:"model",section:"sess\xE3o"},{name:"provider",summary:"seta o provider do modelo Custom",summaryKey:"cmd.provider",source:"native",id:"provider",section:"sess\xE3o"},{name:"effort",summary:"seta o reasoning_effort (low/medium/high/custom) \xB7 passthrough \u226432 chars",summaryKey:"cmd.effort",source:"native",id:"effort",section:"sess\xE3o",parallelWhileBusyWith:RG},{name:"theme",summary:"trocar o tema (dark/light) \xB7 auto-detecta no boot",summaryKey:"cmd.theme",source:"native",id:"theme",section:"sess\xE3o"},{name:"lang",summary:"trocar o idioma (pt-BR/en) \xB7 auto-detecta no boot",summaryKey:"cmd.lang",source:"native",id:"lang",section:"sess\xE3o"},{name:"usage",summary:"tokens e janela desta sess\xE3o",summaryKey:"cmd.usage",source:"native",id:"usage",section:"sess\xE3o",parallelWhileBusy:!0},{name:"rename",summary:"d\xE1 um nome + cor de identifica\xE7\xE3o \xE0 sess\xE3o \xB7 \u25CFnome no composer",summaryKey:"cmd.rename",source:"native",id:"rename",section:"sess\xE3o"},{name:"history",summary:"navega e RETOMA uma sess\xE3o anterior \xB7 sem sair do aluy",summaryKey:"cmd.history",source:"native",id:"history",section:"sess\xE3o"},{name:"ask",summary:"pergunta PARALELA (read-only) sem parar o trabalho em curso",source:"native",id:"ask",section:"sess\xE3o",parallelWhileBusy:!0},{name:"notify",summary:"liga/desliga o sino de aten\xE7\xE3o (on/off)",summaryKey:"cmd.notify",source:"native",id:"notify",section:"sess\xE3o"},{name:"split",summary:"liga/desliga o painel de LOG ao lado do chat (Ctrl+L \xB7 /view)",source:"native",id:"split",section:"sess\xE3o"},{name:"fullscreen",summary:"modo cockpit (tela cheia, alt-screen)",summaryKey:"cmd.fullscreen",source:"native",id:"fullscreen",section:"sess\xE3o"},{name:"undo",summary:"desfaz a \xFAltima edi\xE7\xE3o de arquivo do agente",summaryKey:"cmd.undo",source:"native",id:"undo",section:"workspace"},{name:"redo",summary:"refaz a \xFAltima edi\xE7\xE3o desfeita",summaryKey:"cmd.redo",source:"native",id:"redo",section:"workspace"},{name:"rewind",summary:"volta a um ponto da sess\xE3o (c\xF3digo e/ou conversa) \xB7 Esc Esc",summaryKey:"cmd.rewind",source:"native",id:"rewind",section:"workspace"},{name:"clear",summary:"limpa a sess\xE3o (contexto) \xB7 full tamb\xE9m APAGA a mem\xF3ria do agente",summaryKey:"cmd.clear",source:"native",id:"clear",section:"sess\xE3o",subcommands:[{name:"full",summary:"limpa a sess\xE3o E APAGA a mem\xF3ria (global+projeto) \xB7 confirma",usage:"full",terminal:!0},{name:"memory",summary:"APAGA s\xF3 a mem\xF3ria do agente (global+projeto) \xB7 confirma",usage:"memory",terminal:!0}]},{name:"compact",summary:"compacta o contexto (resume a conversa e continua)",summaryKey:"cmd.compact",source:"native",id:"compact",section:"sess\xE3o"},{name:"cycle",summary:"roda uma tarefa em ciclos \xB7 com tetos duros e parada (anti-runaway)",summaryKey:"cmd.cycle",source:"native",id:"cycle",section:"sess\xE3o",usage:'<intervalo> "<tarefa>"',subcommands:[{name:"pause",summary:"pausa o /cycle em execu\xE7\xE3o (sem matar; Esc ainda para)",usage:"pause",terminal:!0},{name:"resume",summary:"retoma um /cycle pausado",usage:"resume",terminal:!0},{name:"edit",summary:"reconfigura o /cycle ativo \xB7 vale na pr\xF3xima itera\xE7\xE3o",usage:'edit ["<tarefa>"] [<intervalo>] [--max-iter N]'},{name:"status",summary:"mostra o /cycle ativo (config corrente \xB7 pausado?)",usage:"status",terminal:!0},{name:"stop",summary:"para/encerra o /cycle em execu\xE7\xE3o (= Esc)",usage:"stop",terminal:!0}]},{name:"cron",summary:"agendamento PERSISTENTE \xB7 lista/gerencia os jobs (mesmo motor do aluy cron)",source:"native",id:"cron",section:"sess\xE3o",usage:'list \xB7 add <quando> "<tarefa>" \xB7 edit/enable/disable/rm <id>',subcommands:[{name:"list",summary:"lista os jobs (id \xB7 on/off \xB7 schedule \xB7 tarefa)",usage:"list",terminal:!0},{name:"add",summary:"agenda um job novo (cron de 5 campos)",usage:'add <quando> "<tarefa>" [--yolo]'},{name:"edit",summary:"reconfigura um job (preserva id)",usage:'edit <id> [--quando "<cron>"] [--tarefa "<txt>"] [--yolo|--no-yolo]'},{name:"enable",summary:"reativa um job desabilitado",usage:"enable <id>"},{name:"disable",summary:"desabilita SEM excluir (sai do agendador)",usage:"disable <id>"},{name:"rm",summary:"remove um job de vez",usage:"rm <id>"}]},{name:"permissions",summary:"painel \xB7 modo, grants e tools seguras (sempre-ask travado)",summaryKey:"cmd.permissions",source:"native",id:"permissions",section:"workspace"},{name:"tools",summary:"invent\xE1rio unificado das ferramentas \xB7 nativas, MCP, permiss\xE3o (read-only)",summaryKey:"cmd.tools",source:"native",id:"tools",section:"workspace",parallelWhileBusy:!0},{name:"add-dir",summary:"autoriza um diret\xF3rio EXTRA p/ o agente (sess\xE3o) \xB7 sem args lista",summaryKey:"cmd.addDir",source:"native",id:"add-dir",section:"workspace"},{name:"init",summary:"cria um AGENT.md neste projeto",summaryKey:"cmd.init",source:"native",id:"init",section:"workspace"},{name:"memory",summary:"v\xEA/edita/esquece/fixa a mem\xF3ria do agente (global + projeto)",summaryKey:"cmd.memory",source:"native",id:"memory",section:"workspace",subcommands:[{name:"list",summary:"lista a mem\xF3ria (global + projeto)",usage:"list"},{name:"forget",summary:"remove um fato pelo id",usage:"forget <id>"},{name:"edit",summary:"corrige o texto de um fato",usage:"edit <id> <texto>"},{name:"pin",summary:"fixa um fato (reten\xE7\xE3o)",usage:"pin <id>"},{name:"unpin",summary:"desfixa um fato",usage:"unpin <id>"}]},{name:"todo",summary:"v\xEA/gerencia o backlog de tarefas anotadas (done/clear)",summaryKey:"cmd.todo",source:"native",id:"todo",section:"workspace",subcommands:[{name:"list",summary:"lista o backlog (pendentes + feitos)",usage:"list"},{name:"done",summary:"marca um item como conclu\xEDdo",usage:"done <id>"},{name:"clear",summary:"remove os itens j\xE1 feitos",usage:"clear",terminal:!0}]},{name:"mcp",summary:"lista/gerencia servers MCP (add/remove/disable/enable \xB7 search <termo>)",summaryKey:"cmd.mcp",source:"native",id:"mcp",section:"workspace",parallelWhileBusyWith:CG,subcommands:[{name:"search",summary:"busca no registro oficial aberto",usage:"search <termo>"},{name:"add",summary:"adiciona um server local (stdio)",usage:"add <nome> -- <cmd> [args...]"},{name:"list",summary:"lista os servers de todas as fontes",usage:"list"},{name:"remove",summary:"remove um server gerenciado pelo aluy",usage:"remove <nome>"},{name:"disable",summary:"desativa um server sem desinstalar",usage:"disable <nome>"},{name:"enable",summary:"reativa um server desativado",usage:"enable <nome>"},{name:"reconnect",summary:'re-sobe + re-handshake os servers (recupera "Not connected")',usage:"reconnect [all|<nome>]"},{name:"reload",summary:"re-l\xEA o ~/.aluy/mcp.json + reconecta (aplica edi\xE7\xF5es da config)",usage:"reload [all|<nome>]"}]},{name:"agents",summary:"lista os agentes .md mapeados (global + projeto \xB7 v\xE1lidos + rejeitados)",source:"native",id:"agents",section:"workspace",parallelWhileBusy:!0},{name:"skills",summary:"lista as skills SKILL.md mapeadas (global + projeto \xB7 v\xE1lidas + rejeitadas)",source:"native",id:"skills",section:"workspace",parallelWhileBusy:!0},{name:"workflows",summary:"fluxos de atividades que coordenam o agente \u2014 lista, executa e ativa",summaryKey:"cmd.workflows",source:"native",id:"workflows",section:"workspace",subcommands:[{name:"run",summary:"executa as atividades do workflow em sequ\xEAncia",usage:"run <nome>"},{name:"use",summary:"ativa o modo de workflow \u2014 submiss\xF5es seguem o fluxo",usage:"use <nome>"}],parallelWhileBusy:!0},{name:"rooms",summary:"salas entre agentes \u2014 lista, cria, l\xEA e OBSERVA AO VIVO a conversa da frota",source:"native",id:"rooms",section:"workspace",subcommands:[{name:"list",summary:"lista as salas (c\xF3digo \xB7 msgs \xB7 atividade \xB7 quem)",usage:"list"},{name:"new",summary:"cria uma sala e mostra o c\xF3digo",usage:"new"},{name:"read",summary:"snapshot da conversa de uma sala",usage:"read <c\xF3digo>"},{name:"watch",summary:"observa a conversa AO VIVO (poll at\xE9 2min)",usage:"watch <c\xF3digo>"}]},{name:"subagent",summary:"fala 1:1 com um sub-agente (perfil .md) numa sub-sess\xE3o focada e cont\xEDnua",source:"native",id:"subagent",section:"workspace"},{name:"back",summary:"volta ao agente principal (sai do foco de /subagent)",source:"native",id:"back",section:"workspace"},{name:"quit",summary:"sair do aluy",summaryKey:"cmd.quit",source:"native",id:"quit",section:"sess\xE3o"}];function h0(t,e){let o=!1,n=t.map(r=>{if(r.summaryKey===void 0)return r;let s=e(r.summaryKey);return s===r.summary?r:(o=!0,{...r,summary:s})});return o?n:t}var LG=[{id:"action:cycle-mode",label:"trocar modo",description:"cicla o modo da sess\xE3o (plan \u2192 normal \u2192 yolo) \xB7 tamb\xE9m no Tab",action:{kind:"action",actionId:"cycle-mode"}}];function PG(t=[],e=To){return[...[...e,...t].map(n=>({id:`cmd:${n.source}:${n.name}`,label:`/${n.name}`,description:n.summary,action:{kind:"command",command:n}})),...LG]}function g0(t,e=[],o=To){let n=PG(e,o),r=t.trim();if(r==="")return n.map(i=>({...i,score:0,matched:[]}));let s=[];for(let i of n){let a=Vc(r,i.label),c=Vc(r,i.description);if(!a&&!c)continue;let l=a?a.score:-1/0,d=c?c.score-5:-1/0,f=Math.max(l,d);s.push({...i,score:f,matched:a?a.matched:[]})}return s.sort((i,a)=>a.score-i.score||i.label.length-a.label.length||i.label.localeCompare(a.label)),s}function Gi(t,e=[]){let o=t.trim();if(o.startsWith("!")){let d=o.slice(1).trim();return d===""?{kind:"goal",text:""}:{kind:"bang",command:d}}if(!o.startsWith("/"))return{kind:"goal",text:o};let n=o.slice(1),r=n.search(/\s/),s=(r===-1?n:n.slice(0,r)).toLowerCase(),i=s==="view"?"split":s==="cockpit"?"fullscreen":s,a=r===-1?"":n.slice(r+1).trim(),l=[...To,...e].find(d=>d.name===i);return l?{kind:"command",command:l,args:a}:{kind:"unknown-command",name:i}}function zv(t,e=[]){if(!t.startsWith("/"))return!1;let o=t.slice(1);if(!/\s/.test(o))return!0;let n=o.search(/\s/),r=o.slice(0,n).toLowerCase(),s=o.slice(n).replace(/^\s+/,""),a=[...To,...e].find(c=>c.name===r);return!a?.subcommands||a.subcommands.length===0?!1:!/\s/.test(s)}function NG(t=[],e=To){let o=[];for(let n of[...e,...t]){o.push({kind:"command",command:n});for(let r of n.subcommands??[])o.push({kind:"subcommand",parent:n,sub:r})}return o}function y0(t,e=[],o=To){let n=t.trim().replace(/\s+/g," ").toLowerCase(),r=NG(e,o);if(n==="")return r;let s=c=>jm(c).toLowerCase(),i=r.filter(c=>s(c).startsWith(n)),a=r.filter(c=>!s(c).startsWith(n)&&s(c).includes(n));return[...i,...a]}var IG="COMANDOS DA SESS\xC3O (o HUMANO os digita; voc\xEA os RECOMENDA, n\xE3o os invoca como ferramenta):";function b0(t=To){let e=t.filter(o=>o.summary.trim()!=="").map(o=>{let n=` /${o.name} \u2014 ${o.summary}`;return o.usage?`${n}
519
519
  uso: /${o.name} ${o.usage}`:n});if(e.length!==0)return[IG,"Quando o usu\xE1rio pede algo que um destes comandos resolve \u2014 ex.: AGENDAR/REPETIR uma","tarefa em loop recorrente \u21D2 `/cycle`; checar a sa\xFAde da sess\xE3o \u21D2 `/doctor`; liberar",'contexto \u21D2 `/compact` \u2014 RECOMENDE o comando ao usu\xE1rio. N\xC3O diga "n\xE3o tenho como" nem',"sugira ferramentas externas (cron do SO, Windows Task Scheduler) quando existe um","comando nativo que resolve. Voc\xEA N\xC3O digita estes comandos (n\xE3o s\xE3o suas ferramentas);","quem os digita \xE9 o usu\xE1rio.",...e].join(`
520
520
  `)}import{Fragment as BG,jsx as _o,jsxs as Cr}from"react/jsx-runtime";function FG(t){let e=t.sel?"accent":t.sub?"fgDim":"fg",o=t.query.trim().replace(/\s+/g," ").toLowerCase(),n=o?t.path.toLowerCase().indexOf(o):-1;if(n<0||o==="")return Cr(m,{name:e,children:["/",t.path]});let r=t.path.slice(0,n),s=t.path.slice(n,n+o.length),i=t.path.slice(n+o.length);return Cr(BG,{children:[Cr(m,{name:e,children:["/",r]}),_o(m,{name:"accent",children:s}),_o(m,{name:e,children:i})]})}function qm(t){let e=t.query??"",o=t.maxRows!==void 0?f0(t.commands,t.selected,t.maxRows,t.columns):{slice:t.commands,hiddenAbove:0,hiddenBelow:0},n=t.selected-o.hiddenAbove,r=null;return Cr(zi,{flexDirection:"column",children:[_o(zi,{children:_o(m,{name:"fgDim",children:"/ para comandos \xB7 \u2191\u2193 navega \xB7 enter executa \xB7 esc fecha"})}),o.hiddenAbove>0&&_o(zi,{children:Cr(m,{name:"fgDim",children:[" \u2191 ",o.hiddenAbove," acima"]})}),o.slice.map((s,i)=>{let a=i===n,c=qv(s),l=c!==r?c:null;r=c;let d=jm(s),f=s.kind==="subcommand",u=a?"\u203A ":f?" ":" ";return Cr(DG.Fragment,{children:[l&&_o(zi,{children:_o(m,{name:"fgDim",children:l==="usu\xE1rio"?"\u2500\u2500\u2500 seus comandos":l})}),Cr(zi,{children:[_o(m,{name:a?"accent":"fgDim",children:u}),_o(FG,{path:d,query:e,sel:a,sub:f}),_o($G,{children:" ".repeat(Math.max(1,18-d.length))}),_o(m,{name:"fgDim",children:Wv(s)})]})]},`${c}:${d}`)}),o.hiddenBelow>0&&_o(zi,{children:Cr(m,{name:"fgDim",children:[" \u2193 ",o.hiddenBelow," mais (refine a busca)"]})})]})}import"react";import{Box as Ki,Text as UG}from"ink";import{Fragment as qG,jsx as Qt,jsxs as xl}from"react/jsx-runtime";function jG(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Qt(m,{name:e,children:t.label});let n=[],r=0;for(;r<t.label.length;){let s=o.has(r),i=r;for(;i<t.label.length&&o.has(i)===s;)i++;n.push(Qt(m,{name:s?"accent":e,children:t.label.slice(r,i)},r)),r=i}return Qt(qG,{children:n})}function HG(t,e,o){if(t.length<=o)return{start:0,slice:t};let n=e-Math.floor(o/2);return n<0&&(n=0),n+o>t.length&&(n=t.length-o),{start:n,slice:t.slice(n,n+o)}}function Wm(t){let{t:e}=fe(),o=t.maxRows??8,n=t.query??"",{start:r,slice:s}=HG(t.hits,t.selected,o),i=s.reduce((a,c)=>Math.max(a,c.label.length),0);return xl(Ki,{flexDirection:"column",children:[Qt(Ki,{children:Qt(m,{name:"fgDim",children:e("picker.palette.help")})}),xl(Ki,{children:[Qt(m,{name:"accent",children:"> "}),n===""?Qt(m,{name:"fgDim",children:e("picker.palette.search")}):Qt(m,{name:"fg",children:n})]}),t.hits.length===0?Qt(Ki,{children:xl(m,{name:"fgDim",children:[" ",e("picker.palette.empty",{query:n})]})}):s.map((a,c)=>{let d=r+c===t.selected;return xl(Ki,{children:[Qt(m,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),Qt(jG,{label:a.label,matched:a.matched,sel:d}),Qt(UG,{children:" ".repeat(Math.max(1,i-a.label.length+2))}),Qt(m,{name:"fgDim",children:a.description})]},a.id)}),t.hits.length>s.length&&Qt(Ki,{children:xl(m,{name:"fgDim",children:[" ",e("picker.palette.more",{count:t.hits.length-s.length})]})})]})}import"react";import{Box as Sl}from"ink";import{Fragment as zG,jsx as bn,jsxs as Gm}from"react/jsx-runtime";function v0(t,e){if(e<=0||t.length<=e)return t;if(e<=1)return t.slice(0,e);let o="\u2026",n=e-o.length,r=Math.ceil(n/2),s=Math.floor(n/2);return t.slice(0,r)+o+t.slice(t.length-s)}function WG(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return bn(m,{name:e,children:t.path});let n=[],r=0;for(;r<t.path.length;){let s=o.has(r),i=r;for(;i<t.path.length&&o.has(i)===s;)i++;let a=t.path.slice(r,i);n.push(bn(m,{name:s?"accent":e,children:a},r)),r=i}return bn(zG,{children:n})}function GG(t,e,o){if(t.length<=o)return{start:0,slice:t};let n=e-Math.floor(o/2);return n<0&&(n=0),n+o>t.length&&(n=t.length-o),{start:n,slice:t.slice(n,n+o)}}function Kv(t){let{t:e}=fe(),o=t.columns??80,n=t.maxRows??8,r=Math.max(8,o-4),{start:s,slice:i}=GG(t.hits,t.selected,n);return Gm(Sl,{flexDirection:"column",children:[bn(Sl,{children:bn(m,{name:"fgDim",children:e("picker.file.help")})}),t.hits.length===0?bn(Sl,{children:Gm(m,{name:"fgDim",children:[" ",e("picker.file.empty",{query:t.query??""})]})}):i.map((a,c)=>{let d=s+c===t.selected,f=v0(a.path,r),u=f===a.path;return Gm(Sl,{children:[bn(m,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),u?bn(WG,{path:a.path,matched:a.matched,sel:d}):bn(m,{name:d?"accent":"fg",children:f})]},a.path)}),t.hits.length>i.length&&bn(Sl,{children:Gm(m,{name:"fgDim",children:[" ",e("picker.file.more",{count:t.hits.length-i.length})]})})]})}import"react";import{Box as _e,Text as KG}from"ink";import{Fragment as Yv,jsx as ee,jsxs as Ie}from"react/jsx-runtime";var YG={keep:"picker.effort.keep",low:"picker.effort.low",medium:"picker.effort.medium",high:"picker.effort.high",custom:"picker.effort.custom"};function zm(t){let{t:e}=fe();if(t.effortStepOpen)return ee(ZG,{...t});if(t.customInputOpen)return ee(VG,{...t});let o=t.tiers.length;return Ie(_e,{flexDirection:"column",children:[ee(_e,{children:ee(m,{name:"fgDim",children:e("picker.model.help")})}),t.loading?ee(_e,{children:Ie(m,{name:"fgDim",children:[" ",e("picker.model.loading")]})}):Ie(Yv,{children:[t.tiers.map((n,r)=>{let s=r===t.selected,i=n.key===t.currentTier,a=Hb(n),c=jb(n.costSignal);return Ie(_e,{children:[ee(m,{name:s?"accent":"fgDim",children:s?"\u203A ":" "}),ee(m,{name:i?"accent":"fgDim",children:i?"\u25CF ":" "}),ee(m,{name:s?"accent":"fg",children:n.displayName}),a!==""&&Ie(Yv,{children:[ee(m,{name:"fgDim",children:" \xB7 "}),ee(m,{name:"depth",children:a})]}),Ie(m,{name:"fgDim",children:[" \xB7 ",c]})]},n.key)}),Ie(_e,{children:[ee(m,{name:t.selected===o?"accent":"fgDim",children:t.selected===o?"\u203A ":" "}),ee(m,{name:t.currentTier==="custom"?"accent":"fgDim",children:t.currentTier==="custom"?"\u25CF ":" "}),ee(m,{name:t.selected===o?"accent":"fg",children:"Custom"}),Ie(m,{name:"fgDim",children:[" \xB7 ",e("picker.model.customLine")]})]},"__custom__")]}),t.usingFallback===!0&&!t.loading&&ee(_e,{children:Ie(m,{name:"fgDim",children:[" ","\u25CD ",e("picker.model.fallback")]})})]})}function VG(t){return t.customBrowserAvailable===!0?ee(QG,{...t}):ee(tz,{...t})}function XG(t){return t.supportsTools===!0?ee(m,{name:"accent",children:"\u2713 tools"}):t.supportsTools===!1?ee(m,{name:"fgDim",children:"\u2014 tools"}):ee(m,{name:"fgDim",children:"\xB7 tools?"})}function JG(t){let{model:e,highlighted:o}=t.row,n=[e.family,e.context].map(r=>r.trim()).filter(r=>r!=="");return Ie(_e,{children:[ee(m,{name:o?"accent":"fgDim",children:o?"\u203A ":" "}),ee(m,{name:o?"accent":"fg",children:e.id}),n.length>0&&Ie(Yv,{children:[ee(m,{name:"fgDim",children:" "}),ee(m,{name:"depth",children:n.join(" \xB7 ")})]}),ee(KG,{children:" "}),ee(XG,{supportsTools:e.supportsTools})]})}function QG(t){let{t:e}=fe(),o=t.customInput??"",n=t.customRows??[],r=t.customFilteredCount??0,s=t.customTotalCount??0,i=t.customToolsOnly===!0,a=t.customNoToolsWarning??null;return Ie(_e,{flexDirection:"column",children:[ee(_e,{children:ee(m,{name:"fgDim",children:e("picker.model.browseHelp")})}),Ie(_e,{children:[ee(m,{name:"accent",children:"filtro \u203A "}),ee(m,{name:"fg",children:o}),ee(m,{name:"accent",children:"\u258F"}),Ie(m,{name:"fgDim",children:[" ",e("picker.model.browseCount",{filtered:r,total:s}),i?e("picker.model.toolsOnlySuffix"):""]})]}),t.customHasMoreAbove===!0&&ee(_e,{children:Ie(m,{name:"fgDim",children:[" ",e("picker.model.moreAbove")]})}),n.length===0?ee(_e,{children:Ie(m,{name:"fgDim",children:[" ",e("picker.model.noFilterMatch")]})}):ee(_e,{flexDirection:"column",children:n.map(c=>ee(JG,{row:c},c.model.id))}),t.customHasMoreBelow===!0&&ee(_e,{children:Ie(m,{name:"fgDim",children:[" ",e("picker.model.moreBelow")]})}),a!==null&&ee(_e,{children:Ie(m,{name:"accent",children:[" ",e("picker.model.noTools")]})})]})}function ZG(t){let{t:e}=fe();if(t.effortCustomOpen===!0)return ee(ez,{...t});let o=t.effortOptions??[],n=t.effortSelected??0,r=t.currentEffort;return Ie(_e,{flexDirection:"column",children:[ee(_e,{children:ee(m,{name:"fgDim",children:e("picker.effort.help")})}),o.map((s,i)=>{let a=i===n,c=s.kind==="level"&&s.value===r||s.kind==="keep"&&(r===void 0||r==="");return Ie(_e,{children:[ee(m,{name:a?"accent":"fgDim",children:a?"\u203A ":" "}),ee(m,{name:c?"accent":"fgDim",children:c?"\u25CF ":" "}),ee(m,{name:a?"accent":"fg",children:e(YG[s.id]??"picker.effort.keep")})]},s.id)})]})}function ez(t){let{t:e}=fe(),o=t.effortCustomInput??"",n=t.effortCustomWarn??null;return Ie(_e,{flexDirection:"column",children:[ee(_e,{children:ee(m,{name:"fgDim",children:e("picker.effort.customHelp")})}),Ie(_e,{children:[ee(m,{name:"accent",children:"\u203A "}),ee(m,{name:"fg",children:o}),ee(m,{name:"accent",children:"\u258F"})]}),n!==null&&ee(_e,{children:Ie(m,{name:"accent",children:[" ",e(n==="empty"?"picker.effort.warnEmpty":"picker.effort.warnTooLong")]})})]})}function tz(t){let{t:e}=fe(),o=t.customInput??"",n=t.customSuggestions??[],r=t.customWarnOutOfCatalog===!0;return Ie(_e,{flexDirection:"column",children:[ee(_e,{children:ee(m,{name:"fgDim",children:e("picker.model.freeHelp")})}),Ie(_e,{children:[ee(m,{name:"accent",children:"\u203A "}),ee(m,{name:"fg",children:o}),ee(m,{name:"accent",children:"\u258F"})]}),n.length>0&&ee(_e,{flexDirection:"column",children:n.map(s=>Ie(_e,{children:[ee(m,{name:"fgDim",children:" \u25CD "}),ee(m,{name:"depth",children:s})]},s))}),r&&ee(_e,{children:Ie(m,{name:"accent",children:[" ",e("picker.model.outOfCatalog")]})})]})}import"react";import{Box as Al,Text as w0}from"ink";var Vv=15;function Xv(t,e=Vv){let o;try{o=t.list()}catch{return[]}return o.slice(0,Math.max(0,e))}function k0(t){let e=new Date(t),o=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${o(e.getMonth()+1)}-${o(e.getDate())} ${o(e.getHours())}:${o(e.getMinutes())}`}function oz(t){for(let e of t)if(e.kind==="you"){let o=e.text.replace(/\s+/g," ").trim();return o===""?void 0:o.length>60?o.slice(0,57)+"\u2026":o}}function wl(t,e){let o=Qc(t.cwd,e??process.env.HOME??""),n=t.label?.trim();if(n)return`${n} \xB7 ${k0(t.updatedAt)} \xB7 ${o}`;let r=t.title??(t.blocks?oz(t.blocks):void 0)??"(sem objetivo)";return`${k0(t.updatedAt)} \xB7 ${o} \xB7 ${r}`}function nz(t,e){if(t.length===0)return["nenhuma sess\xE3o anterior."];let o=["sess\xF5es anteriores (retome com: /history <id>):",""];for(let n of t){o.push(` ${n.id}`);let r=n.label?.trim()?"\u25CF ":"";o.push(` ${r}${wl(n,e)}`)}return o}function x0(t,e){e.switchSession({id:t.id,cwd:t.cwd,tier:t.tier}),e.resetContinuation?.(),e.clearScreen(),e.restoreBlocks(t.blocks);let o=ms(t.blocks);o.length>0&&e.seedHistory(o),t.cwd.trim()!==""&&e.setSessionCwd?.(t.cwd)}function S0(t,e,o){let n=(t??"").trim();if(n!=="/history"&&!n.startsWith("/history "))return!1;let r=n==="/history"?"":n.slice(9).trim();if(r===""){let i=Xv(o.store,o.limit);for(let a of nz(i,o.home))e.write(`[history] ${a}
521
521
  `);return!0}let s=o.store.load(r);return s?(o.resume(s),e.write(`[history] sess\xE3o retomada: ${r} (${wl(s,o.home)})
522
522
  `),!0):(e.write(`[history] sess\xE3o n\xE3o encontrada: ${r}
523
- `),!0)}function vn(t,e,o,n){if(n===void 0){if(t.length<=o)return{start:0,slice:t};let p=e-Math.floor(o/2);return p<0&&(p=0),p+o>t.length&&(p=t.length-o),{start:p,slice:t.slice(p,p+o)}}let r=t.length;if(r===0)return{start:0,slice:t};let s=p=>Math.max(1,Math.floor(n(t[p]))),i=0;for(let p=0;p<r;p+=1)i+=s(p);if(i<=o)return{start:0,slice:t};let a=Math.max(0,Math.min(e,r-1)),c=a,l=a+1,d=s(a),f=!0,u=!0;for(;u;){u=!1;let p=()=>c>0&&d+s(c-1)<=o?(c-=1,d+=s(c),!0):!1,h=()=>l<r&&d+s(l)<=o?(d+=s(l),l+=1,!0):!1;u=f?p()||h():h()||p(),f=!f}return{start:c,slice:t.slice(c,l)}}import{Fragment as rz,jsx as Or,jsxs as El}from"react/jsx-runtime";function Km(t){let e=Z(),{t:o}=fe(),n=e.glyph("sessionDot"),r=Math.max(1,t.maxRows??10),s=t.columns,i=s!==void 0&&s>0?l=>{let d=2+(l.label?.trim()?2:0)+ye(wl(l,t.home));return Math.max(1,Math.ceil(d/s))}:void 0,{start:a,slice:c}=vn(t.sessions,t.selected,r,i);return El(Al,{flexDirection:"column",children:[Or(Al,{children:Or(m,{name:"fgDim",children:o("picker.history.help")})}),t.sessions.length===0?Or(Al,{children:El(m,{name:"fgDim",children:[" ",o("picker.history.empty")]})}):c.map((l,d)=>{let u=a+d===t.selected,p=l.label?.trim(),h=p?e.sessionColor(l.labelColor??p):void 0,y={};return h?.color!==void 0&&(y.color=h.color),h?.bold!==void 0&&(y.bold=h.bold),El(Al,{children:[Or(m,{name:u?"accent":"fgDim",children:u?"\u203A ":" "}),p&&El(rz,{children:[Or(w0,{...y,children:n}),Or(w0,{children:" "})]}),Or(m,{name:u?"accent":"fg",children:wl(l,t.home)})]},l.id)}),t.sessions.length>c.length&&Or(Al,{children:El(m,{name:"fgDim",children:[" ",o("picker.history.more",{count:t.sessions.length-c.length})]})})]})}import"react";import{Box as Ro}from"ink";var Ym=["both","conversation","code"];function A0(t,e=30){return[...t].reverse().slice(0,e)}function Jv(t){let e=sz(t.ts);return`#${t.ordinal} \xB7 ${e} \xB7 ${t.label}`}function sz(t){let e=new Date(t),o=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${o}:${n}`}import{jsx as Ot,jsxs as _s}from"react/jsx-runtime";function iz(t){switch(t){case"both":return"picker.rewind.action.both";case"conversation":return"picker.rewind.action.conversation";case"code":return"picker.rewind.action.code"}}function Vm(t){let{t:e}=fe();if(t.phase==="list"){let o=Math.max(1,t.maxRows??10),n=t.columns,r=n!==void 0&&n>0?a=>Math.max(1,Math.ceil((2+ye(Jv(a)))/n)):void 0,{start:s,slice:i}=vn(t.checkpoints,t.selected,o,r);return _s(Ro,{flexDirection:"column",children:[Ot(Ro,{children:Ot(m,{name:"fgDim",children:e("picker.rewind.help")})}),t.checkpoints.length===0?Ot(Ro,{children:_s(m,{name:"fgDim",children:[" ",e("picker.rewind.empty")]})}):i.map((a,c)=>{let l=s+c===t.selected;return _s(Ro,{children:[Ot(m,{name:l?"accent":"fgDim",children:l?"\u203A ":" "}),Ot(m,{name:l?"accent":"fg",children:Jv(a)})]},a.id)}),t.checkpoints.length>i.length&&Ot(Ro,{children:_s(m,{name:"fgDim",children:[" ",e("picker.rewind.more",{count:t.checkpoints.length-i.length})]})})]})}return _s(Ro,{flexDirection:"column",children:[Ot(Ro,{children:Ot(m,{name:"fgDim",children:e("picker.rewind.action.help")})}),t.target&&Ot(Ro,{children:Ot(m,{name:"fgDim",children:` \u2192 #${t.target.ordinal} \xB7 ${t.target.label}`})}),t.actions.map((o,n)=>{let r=n===t.selected;return _s(Ro,{children:[Ot(m,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),Ot(m,{name:r?"accent":"fg",children:e(iz(o))})]},o)}),t.barrierWarnings&&t.barrierWarnings.length>0&&_s(Ro,{flexDirection:"column",marginTop:1,children:[Ot(Ro,{children:Ot(m,{name:"accent",children:`\u26A0 ${e("picker.rewind.barrier.warn")}:`})}),t.barrierWarnings.map((o,n)=>Ot(Ro,{children:Ot(m,{name:"fgDim",children:` \xB7 ${o}`})},n))]})]})}import az from"react";import{Box as Bt,Text as cz}from"ink";import{Fragment as mz,jsx as Re,jsxs as ho}from"react/jsx-runtime";var Qv={plan:"PLAN (read-only)",normal:"NORMAL (catraca padrao)",unsafe:"YOLO (aprovacao DESLIGADA)"};function lz(t){switch(t){case"mode":return"modo de sessao \xB7 enter cicla plan \u2192 normal \u2192 yolo";case"safe-tool":return"tools seguras (leitura) \xB7 enter alterna allow \u21C4 ask";case"grant":return"liberados nesta sessao \xB7 enter REVOGA";case"locked":return"TRAVADO por seguranca \xB7 so via --yolo"}}function dz(t){let{row:e,sel:o}=t,n=Re(m,{name:o?"accent":"fgDim",children:o?"\u203A ":" "});switch(e.kind){case"mode":return ho(Bt,{children:[n,Re(m,{name:o?"accent":"fg",children:"modo: "}),Re(m,{name:e.mode==="unsafe"?"danger":o?"accent":"fg",children:Qv[e.mode]})]});case"safe-tool":return ho(Bt,{children:[n,Re(m,{name:o?"accent":"fg",children:e.tool}),Re(m,{name:"fgDim",children:" = "}),Re(m,{name:e.decision==="allow"?"success":"fgDim",children:e.decision})]});case"grant":return ho(Bt,{children:[n,Re(m,{name:"success",children:"\u25CF "}),Re(m,{name:o?"accent":"fg",children:e.grantKey}),Re(m,{name:"fgDim",children:" (enter revoga)"})]});case"locked":{let r=e.category.lock==="deny";return ho(Bt,{flexDirection:"column",children:[ho(Bt,{children:[n,Re(L,{name:"ask",role:"danger"}),Re(m,{name:"danger",children:" [travado] "}),Re(m,{name:o?"accent":"fg",children:e.category.label}),ho(m,{name:"danger",children:[" \xB7 ",r?"deny (nem --yolo)":"sempre pergunta"]})]}),o&&Re(Bt,{paddingLeft:4,children:Re(m,{name:"fgDim",children:e.category.why})})]})}}}function Zv(t){let e=Math.max(1,t.maxRows??14),o=t.columns,n=c=>{switch(c.kind){case"mode":return 8+ye(Qv[c.mode]);case"safe-tool":return 5+ye(c.tool)+ye(c.decision);case"grant":return 19+ye(c.grantKey);case"locked":return 28+ye(c.category.label)}},r=o!==void 0&&o>0?c=>Math.max(1,Math.ceil(n(c)/o)):void 0,{start:s,slice:i}=vn(t.rows,t.selected,e,r),a=null;return ho(Bt,{flexDirection:"column",children:[Re(Bt,{children:Re(m,{name:"fgDim",children:"permissoes \xB7 \u2191\u2193 navega \xB7 enter muda \xB7 esc fecha"})}),ho(Bt,{children:[Re(m,{name:"fgDim",children:"modo atual: "}),Re(m,{name:t.mode==="unsafe"?"danger":"fg",children:Qv[t.mode]})]}),t.rows.length===0?Re(Bt,{children:Re(m,{name:"fgDim",children:" nada a mostrar"})}):ho(mz,{children:[s>0&&Re(Bt,{children:ho(m,{name:"fgDim",children:[" \u2191 ",s," acima"]})}),i.map((c,l)=>{let d=s+l,f=c.kind!==a?lz(c.kind):null;return a=c.kind,ho(az.Fragment,{children:[f&&Re(Bt,{paddingTop:1,children:ho(m,{name:"fgDim",children:["\u2500\u2500\u2500 ",f]})}),Re(dz,{row:c,sel:d===t.selected})]},uz(c,d))}),s+i.length<t.rows.length&&Re(Bt,{children:ho(m,{name:"fgDim",children:[" \u2193 ",t.rows.length-(s+i.length)," abaixo"]})})]}),Re(Bt,{paddingTop:1,children:Re(cz,{children:" "})}),Re(Bt,{children:Re(m,{name:"fgDim",children:"o painel nao relaxa as categorias travadas \u2014 o unico bypass total e --yolo"})})]})}function uz(t,e){switch(t.kind){case"mode":return"mode";case"safe-tool":return`safe:${t.tool}`;case"grant":return`grant:${t.grantKey}`;case"locked":return`locked:${t.category.category}`;default:return`row:${e}`}}import"react";import{Box as ek}from"ink";import{jsx as Tl,jsxs as tk}from"react/jsx-runtime";function Xm(t){let{t:e}=fe();return tk(ek,{flexDirection:"column",children:[Tl(ek,{children:Tl(m,{name:"fgDim",children:e("picker.theme.help")})}),t.themes.map((o,n)=>{let r=n===t.selected,s=o.name===t.currentTheme;return tk(ek,{children:[Tl(m,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),Tl(m,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),Tl(m,{name:r?"accent":"fg",children:o.label}),tk(m,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.name)})]})}import"react";import{Box as ok}from"ink";import{jsx as _l,jsxs as nk}from"react/jsx-runtime";function Jm(t){let{t:e}=fe();return nk(ok,{flexDirection:"column",children:[_l(ok,{children:_l(m,{name:"fgDim",children:e("picker.lang.help")})}),t.langs.map((o,n)=>{let r=n===t.selected,s=o.code===t.currentLang;return nk(ok,{children:[_l(m,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),_l(m,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),_l(m,{name:r?"accent":"fg",children:o.label}),nk(m,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.code)})]})}import"react";import{Box as Rl}from"ink";import{jsx as Mr,jsxs as Cl}from"react/jsx-runtime";function rk(t){let{t:e}=fe(),o=Math.max(1,t.maxRows??10),n=t.columns,r=n!==void 0&&n>0?a=>{let c=4+ye(`${a.label} \xB7 ${a.summary}`)+(a.isDefault?2+ye(e("picker.provider.default")):0);return Math.max(1,Math.ceil(c/n))}:void 0,{start:s,slice:i}=vn(t.providers,t.selected,o,r);return Cl(Rl,{flexDirection:"column",children:[Mr(Rl,{children:Mr(m,{name:"fgDim",children:e("picker.provider.help")})}),t.usingFallback===!0?Mr(Rl,{children:Mr(m,{name:"fgDim",children:e("picker.provider.fallback")})}):null,i.map((a,c)=>{let l=s+c===t.selected,d=a.name===t.currentProvider;return Cl(Rl,{children:[Mr(m,{name:l?"accent":"fgDim",children:l?"\u203A ":" "}),Mr(m,{name:d?"accent":"fgDim",children:d?"\u25CF ":" "}),Mr(m,{name:l?"accent":"fg",children:a.label}),Cl(m,{name:"fgDim",children:[" \xB7 ",a.summary]}),a.isDefault?Cl(m,{name:"fgDim",children:[" \xB7 ",e("picker.provider.default")]}):null]},a.name)}),t.providers.length>i.length&&Mr(Rl,{children:Cl(m,{name:"fgDim",children:[" ",e("picker.provider.more",{count:t.providers.length-i.length})]})})]})}import"react";import{Box as E0,Text as fz}from"ink";import{jsx as sk,jsxs as T0}from"react/jsx-runtime";function ik(t){if(t.chips.length===0)return null;let e=t.active??-1;return sk(E0,{flexWrap:"wrap",children:t.chips.map((o,n)=>{let r=n===e;return T0(E0,{marginRight:1,children:[T0(m,{name:r?"accent":"depth",children:[r?"\u203A ":"","@",o.path,o.truncated?"~":""]}),sk(fz,{children:" "}),sk(m,{name:"fgDim",children:"[\u232B]"})]},o.path)})})}import"react";import{Box as Ol,Text as _0}from"ink";import{jsx as Yo,jsxs as Lr}from"react/jsx-runtime";function ak(t){let e=Z(),{t:o}=fe(),n=t.columns??80,r=t.plan??"assinatura",s=e.glyph("wave").repeat(17);return Lr(Ol,{flexDirection:"column",paddingY:1,children:[Yo(ys,{columns:n}),Yo(Ol,{paddingTop:1,paddingLeft:2,children:Yo(m,{name:"fgDim",children:o("boot.tagline")})}),Lr(Ol,{paddingLeft:2,children:[Yo(m,{name:"accent",children:s}),t.version!==void 0&&Lr(m,{name:"fgDim",children:[" v",t.version]})]}),Lr(Ol,{paddingLeft:2,children:[Yo(L,{name:"window",role:"fgDim"}),Lr(m,{name:"fgDim",children:[" ",r," \xB7 "]}),Yo(m,{name:"fgDim",children:t.tier}),Yo(_0,{children:" "}),Yo(m,{name:"fgDim",children:"\xB7 "}),Yo(L,{name:"broker",role:"depth"}),Lr(m,{name:"depth",children:[" ",o("boot.broker")]})]}),t.status!==void 0&&Lr(Ol,{paddingTop:1,paddingLeft:2,children:[Yo(ws,{frame:t.frame??0}),Yo(_0,{children:" "}),Lr(m,{name:"fgDim",children:[t.status,"\u2026"]})]})]})}import"react";import{Box as R0}from"ink";import{jsx as ck,jsxs as lk}from"react/jsx-runtime";var pz=['"explique a estrutura deste repo"','"rode os testes e resuma as falhas"',"/help para comandos \xB7 /login conta \xB7 /quit"];function dk(t){let e=t.suggestions??pz;return lk(R0,{flexDirection:"column",children:[ck(m,{name:"fg",children:t.name?`bom te ver de novo, ${t.name}.`:"bom te ver por aqui."}),ck(m,{name:"fgDim",children:"eu leio e edito arquivos e rodo comandos aqui \u2014 sempre te mostrando o efeito exato antes."}),lk(R0,{paddingTop:1,flexDirection:"column",children:[ck(m,{name:"fgDim",children:"experimente:"}),e.map((o,n)=>lk(m,{name:"fgDim",children:[" \xB7 ",o]},n))]})]})}import"react";import{jsx as Uue}from"react/jsx-runtime";import"react";import{Box as C0,Text as uk}from"ink";import{jsx as Rs,jsxs as Qm}from"react/jsx-runtime";var O0=12;function M0(t,e){return!Number.isFinite(t)||!Number.isFinite(e)||e<=0?0:Math.max(0,Math.min(1,t/e))}function L0(t,e,o,n,r){let s=Math.max(1,Math.trunc(n)),i=Math.max(0,Math.min(1,t)),a=Math.round(i*s);i>0&&a===0&&(a=1),i<1&&a===s&&(a=s-1);let c=e.repeat(a),l=o.repeat(s-a);return r?{filled:c,rest:l}:{filled:`[${c}`,rest:`${l}]`}}function Yi(t){let e=Z(),o=t.role??"accent";if(t.value!==void 0&&t.max!==void 0){let a=M0(t.value,t.max),c=Math.round(a*100),l=e.glyph("barFull"),d=e.glyph("barEmpty"),f=t.width??O0,{filled:u,rest:p}=L0(a,l,d,f,e.unicode);return Qm(C0,{children:[Rs(m,{name:o,children:u}),Rs(m,{name:"fgDim",children:p}),Rs(uk,{children:" "}),Qm(m,{name:o,children:[c,"%"]}),Rs(uk,{children:" "}),Rs(m,{name:"fgDim",children:t.label})]})}let r=e.spinnerFrames,s=e.animate?r[(t.frame??0)%r.length]:e.glyph("clock"),i=t.elapsedMs!==void 0?Ci(t.elapsedMs):void 0;return Qm(C0,{children:[Rs(m,{name:o,children:s}),Rs(uk,{children:" "}),Qm(m,{name:"fgDim",children:[t.label,"\u2026",i!==void 0?` ${i}`:""]})]})}import"react";import{Box as hz}from"ink";import{jsx as gz,jsxs as P0}from"react/jsx-runtime";function mk(t){let{t:e}=fe(),o=(t.columns??80)<60,n=e(o?"banner.yolo.narrow":"banner.yolo");return P0(hz,{children:[gz(L,{name:"ask",role:"danger"}),P0(m,{name:"danger",children:[" ",n]})]})}import"react";import{Box as yz}from"ink";import{jsx as N0,jsxs as fk}from"react/jsx-runtime";var bz={plan:{glyph:"planMode",role:"depth",word:"PLAN",caption:"mode.plan.caption"},normal:{glyph:"normalMode",role:"fgDim",word:"NORMAL",caption:"mode.normal.caption"},unsafe:{glyph:"ask",role:"danger",word:"YOLO",caption:"mode.unsafe.caption"}};function Zm(t){let{t:e}=fe();if(t.mode==="unsafe")return N0(mk,{...t.columns!==void 0?{columns:t.columns}:{}});let o=bz[t.mode],n=(t.columns??80)<60;return fk(yz,{children:[N0(L,{name:o.glyph,role:o.role}),fk(m,{name:o.role,children:[" ",e("mode.label")," ",o.word]}),!n&&fk(m,{name:"fgDim",children:[" \xB7 ",e(o.caption)]})]})}import"react";import{jsx as I0}from"react/jsx-runtime";var vz={idle:"hints.idle",thinking:"hints.thinking",streaming:"hints.streaming",ask:"hints.ask","ask-destructive":"hints.askDestructive",slash:"hints.slash",palette:"hints.palette",budget:"hints.budget",error:"hints.error","work-subagents":"hints.workSubagents","idle-subagents":"hints.idleSubagents"},kz=new Set(["thinking","streaming","work-subagents"]);function Ml(t){let{t:e}=fe();if(t.armedExit===!0)return I0(m,{name:"accent",children:e("hints.ctrlcAgain")});let o=e(vz[t.state]),n=t.elapsed!==void 0&&t.elapsed!==""&&kz.has(t.state);return I0(m,{name:"fgDim",children:n?`${o} \xB7 ${t.elapsed}`:o})}import"react";import{Box as pk}from"ink";import{jsx as hk,jsxs as gk}from"react/jsx-runtime";function ef(t){return gk(pk,{flexDirection:"column",children:[gk(pk,{children:[hk(L,{name:"clock",role:"depth"}),gk(m,{name:"depth",children:[" ",t.title]})]}),hk(pk,{flexDirection:"column",paddingLeft:2,children:t.lines.map((e,o)=>hk(m,{name:"fgDim",children:e},o))})]})}import"react";import{Box as Cs,Text as xz}from"ink";import{jsx as Vo,jsxs as Co}from"react/jsx-runtime";var Sz=4,wz="shell";function yk(t){let e=Z();if(t.status==="running"){let a=Ui(t.liveOutput??"",$m).replace(/\n+$/,""),c=t.columns&&t.columns>0?t.columns-Sz:0,{text:l,hidden:d}=Li(a,t.maxLines,c);return Co(Cs,{flexDirection:"column",paddingLeft:2,children:[Vo(As,{glyph:"toolInflight",glyphRole:"depth",label:`rodando $ ${t.command}`,...t.frame!==void 0?{frame:t.frame}:{}}),l.length>0&&Co(Cs,{flexDirection:"column",paddingLeft:2,children:[d>0&&Co(m,{name:"fgDim",children:["\u2026 (",d," linhas acima)"]}),l.split(`
523
+ `),!0)}function vn(t,e,o,n){if(n===void 0){if(t.length<=o)return{start:0,slice:t};let p=e-Math.floor(o/2);return p<0&&(p=0),p+o>t.length&&(p=t.length-o),{start:p,slice:t.slice(p,p+o)}}let r=t.length;if(r===0)return{start:0,slice:t};let s=p=>Math.max(1,Math.floor(n(t[p]))),i=0;for(let p=0;p<r;p+=1)i+=s(p);if(i<=o)return{start:0,slice:t};let a=Math.max(0,Math.min(e,r-1)),c=a,l=a+1,d=s(a),f=!0,u=!0;for(;u;){u=!1;let p=()=>c>0&&d+s(c-1)<=o?(c-=1,d+=s(c),!0):!1,h=()=>l<r&&d+s(l)<=o?(d+=s(l),l+=1,!0):!1;u=f?p()||h():h()||p(),f=!f}return{start:c,slice:t.slice(c,l)}}import{Fragment as rz,jsx as Or,jsxs as El}from"react/jsx-runtime";function Km(t){let e=Z(),{t:o}=fe(),n=e.glyph("sessionDot"),r=Math.max(1,t.maxRows??10),s=t.columns,i=s!==void 0&&s>0?l=>{let d=2+(l.label?.trim()?2:0)+ye(wl(l,t.home));return Math.max(1,Math.ceil(d/s))}:void 0,{start:a,slice:c}=vn(t.sessions,t.selected,r,i);return El(Al,{flexDirection:"column",children:[Or(Al,{children:Or(m,{name:"fgDim",children:o("picker.history.help")})}),t.sessions.length===0?Or(Al,{children:El(m,{name:"fgDim",children:[" ",o("picker.history.empty")]})}):c.map((l,d)=>{let u=a+d===t.selected,p=l.label?.trim(),h=p?e.sessionColor(l.labelColor??p):void 0,y={};return h?.color!==void 0&&(y.color=h.color),h?.bold!==void 0&&(y.bold=h.bold),El(Al,{children:[Or(m,{name:u?"accent":"fgDim",children:u?"\u203A ":" "}),p&&El(rz,{children:[Or(w0,{...y,children:n}),Or(w0,{children:" "})]}),Or(m,{name:u?"accent":"fg",children:wl(l,t.home)})]},l.id)}),t.sessions.length>c.length&&Or(Al,{children:El(m,{name:"fgDim",children:[" ",o("picker.history.more",{count:t.sessions.length-c.length})]})})]})}import"react";import{Box as Ro}from"ink";var Ym=["both","conversation","code"];function A0(t,e=30){return[...t].reverse().slice(0,e)}function Jv(t){let e=sz(t.ts);return`#${t.ordinal} \xB7 ${e} \xB7 ${t.label}`}function sz(t){let e=new Date(t),o=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${o}:${n}`}import{jsx as Ot,jsxs as _s}from"react/jsx-runtime";function iz(t){switch(t){case"both":return"picker.rewind.action.both";case"conversation":return"picker.rewind.action.conversation";case"code":return"picker.rewind.action.code"}}function Vm(t){let{t:e}=fe();if(t.phase==="list"){let o=Math.max(1,t.maxRows??10),n=t.columns,r=n!==void 0&&n>0?a=>Math.max(1,Math.ceil((2+ye(Jv(a)))/n)):void 0,{start:s,slice:i}=vn(t.checkpoints,t.selected,o,r);return _s(Ro,{flexDirection:"column",children:[Ot(Ro,{children:Ot(m,{name:"fgDim",children:e("picker.rewind.help")})}),t.checkpoints.length===0?Ot(Ro,{children:_s(m,{name:"fgDim",children:[" ",e("picker.rewind.empty")]})}):i.map((a,c)=>{let l=s+c===t.selected;return _s(Ro,{children:[Ot(m,{name:l?"accent":"fgDim",children:l?"\u203A ":" "}),Ot(m,{name:l?"accent":"fg",children:Jv(a)})]},a.id)}),t.checkpoints.length>i.length&&Ot(Ro,{children:_s(m,{name:"fgDim",children:[" ",e("picker.rewind.more",{count:t.checkpoints.length-i.length})]})})]})}return _s(Ro,{flexDirection:"column",children:[Ot(Ro,{children:Ot(m,{name:"fgDim",children:e("picker.rewind.action.help")})}),t.target&&Ot(Ro,{children:Ot(m,{name:"fgDim",children:` \u2192 #${t.target.ordinal} \xB7 ${t.target.label}`})}),t.actions.map((o,n)=>{let r=n===t.selected;return _s(Ro,{children:[Ot(m,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),Ot(m,{name:r?"accent":"fg",children:e(iz(o))})]},o)}),t.barrierWarnings&&t.barrierWarnings.length>0&&_s(Ro,{flexDirection:"column",marginTop:1,children:[Ot(Ro,{children:Ot(m,{name:"accent",children:`\u26A0 ${e("picker.rewind.barrier.warn")}:`})}),t.barrierWarnings.map((o,n)=>Ot(Ro,{children:Ot(m,{name:"fgDim",children:` \xB7 ${o}`})},n))]})]})}import az from"react";import{Box as Bt,Text as cz}from"ink";import{Fragment as mz,jsx as Re,jsxs as ho}from"react/jsx-runtime";var Qv={plan:"PLAN (read-only)",normal:"NORMAL (catraca padrao)",unsafe:"YOLO (aprovacao DESLIGADA)"};function lz(t){switch(t){case"mode":return"modo de sessao \xB7 enter cicla plan \u2192 normal \u2192 yolo";case"safe-tool":return"tools seguras (leitura) \xB7 enter alterna allow \u21C4 ask";case"grant":return"liberados nesta sessao \xB7 enter REVOGA";case"locked":return"TRAVADO por seguranca \xB7 so via --yolo"}}function dz(t){let{row:e,sel:o}=t,n=Re(m,{name:o?"accent":"fgDim",children:o?"\u203A ":" "});switch(e.kind){case"mode":return ho(Bt,{children:[n,Re(m,{name:o?"accent":"fg",children:"modo: "}),Re(m,{name:e.mode==="unsafe"?"danger":o?"accent":"fg",children:Qv[e.mode]})]});case"safe-tool":return ho(Bt,{children:[n,Re(m,{name:o?"accent":"fg",children:e.tool}),Re(m,{name:"fgDim",children:" = "}),Re(m,{name:e.decision==="allow"?"success":"fgDim",children:e.decision})]});case"grant":return ho(Bt,{children:[n,Re(m,{name:"success",children:"\u25CF "}),Re(m,{name:o?"accent":"fg",children:e.grantKey}),Re(m,{name:"fgDim",children:" (enter revoga)"})]});case"locked":{let r=e.category.lock==="deny";return ho(Bt,{flexDirection:"column",children:[ho(Bt,{children:[n,Re(L,{name:"ask",role:"danger"}),Re(m,{name:"danger",children:" [travado] "}),Re(m,{name:o?"accent":"fg",children:e.category.label}),ho(m,{name:"danger",children:[" \xB7 ",r?"deny (nem --yolo)":"sempre pergunta"]})]}),o&&Re(Bt,{paddingLeft:4,children:Re(m,{name:"fgDim",children:e.category.why})})]})}}}function Zv(t){let e=Math.max(1,t.maxRows??14),o=t.columns,n=c=>{switch(c.kind){case"mode":return 8+ye(Qv[c.mode]);case"safe-tool":return 5+ye(c.tool)+ye(c.decision);case"grant":return 19+ye(c.grantKey);case"locked":return 28+ye(c.category.label)}},r=o!==void 0&&o>0?c=>Math.max(1,Math.ceil(n(c)/o)):void 0,{start:s,slice:i}=vn(t.rows,t.selected,e,r),a=null;return ho(Bt,{flexDirection:"column",children:[Re(Bt,{children:Re(m,{name:"fgDim",children:"permissoes \xB7 \u2191\u2193 navega \xB7 enter muda \xB7 esc fecha"})}),ho(Bt,{children:[Re(m,{name:"fgDim",children:"modo atual: "}),Re(m,{name:t.mode==="unsafe"?"danger":"fg",children:Qv[t.mode]})]}),t.rows.length===0?Re(Bt,{children:Re(m,{name:"fgDim",children:" nada a mostrar"})}):ho(mz,{children:[s>0&&Re(Bt,{children:ho(m,{name:"fgDim",children:[" \u2191 ",s," acima"]})}),i.map((c,l)=>{let d=s+l,f=c.kind!==a?lz(c.kind):null;return a=c.kind,ho(az.Fragment,{children:[f&&Re(Bt,{paddingTop:1,children:ho(m,{name:"fgDim",children:["\u2500\u2500\u2500 ",f]})}),Re(dz,{row:c,sel:d===t.selected})]},uz(c,d))}),s+i.length<t.rows.length&&Re(Bt,{children:ho(m,{name:"fgDim",children:[" \u2193 ",t.rows.length-(s+i.length)," abaixo"]})})]}),Re(Bt,{paddingTop:1,children:Re(cz,{children:" "})}),Re(Bt,{children:Re(m,{name:"fgDim",children:"o painel nao relaxa as categorias travadas \u2014 o unico bypass total e --yolo"})})]})}function uz(t,e){switch(t.kind){case"mode":return"mode";case"safe-tool":return`safe:${t.tool}`;case"grant":return`grant:${t.grantKey}`;case"locked":return`locked:${t.category.category}`;default:return`row:${e}`}}import"react";import{Box as ek}from"ink";import{jsx as Tl,jsxs as tk}from"react/jsx-runtime";function Xm(t){let{t:e}=fe();return tk(ek,{flexDirection:"column",children:[Tl(ek,{children:Tl(m,{name:"fgDim",children:e("picker.theme.help")})}),t.themes.map((o,n)=>{let r=n===t.selected,s=o.name===t.currentTheme;return tk(ek,{children:[Tl(m,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),Tl(m,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),Tl(m,{name:r?"accent":"fg",children:o.label}),tk(m,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.name)})]})}import"react";import{Box as ok}from"ink";import{jsx as _l,jsxs as nk}from"react/jsx-runtime";function Jm(t){let{t:e}=fe();return nk(ok,{flexDirection:"column",children:[_l(ok,{children:_l(m,{name:"fgDim",children:e("picker.lang.help")})}),t.langs.map((o,n)=>{let r=n===t.selected,s=o.code===t.currentLang;return nk(ok,{children:[_l(m,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),_l(m,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),_l(m,{name:r?"accent":"fg",children:o.label}),nk(m,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.code)})]})}import"react";import{Box as Rl}from"ink";import{jsx as Mr,jsxs as Cl}from"react/jsx-runtime";function rk(t){let{t:e}=fe(),o=Math.max(1,t.maxRows??10),n=t.columns,r=n!==void 0&&n>0?a=>{let c=4+ye(`${a.label} \xB7 ${a.summary}`)+(a.isDefault?2+ye(e("picker.provider.default")):0);return Math.max(1,Math.ceil(c/n))}:void 0,{start:s,slice:i}=vn(t.providers,t.selected,o,r);return Cl(Rl,{flexDirection:"column",children:[Mr(Rl,{children:Mr(m,{name:"fgDim",children:e("picker.provider.help")})}),t.usingFallback===!0?Mr(Rl,{children:Mr(m,{name:"fgDim",children:e("picker.provider.fallback")})}):null,i.map((a,c)=>{let l=s+c===t.selected,d=a.name===t.currentProvider;return Cl(Rl,{children:[Mr(m,{name:l?"accent":"fgDim",children:l?"\u203A ":" "}),Mr(m,{name:d?"accent":"fgDim",children:d?"\u25CF ":" "}),Mr(m,{name:l?"accent":"fg",children:a.label}),Cl(m,{name:"fgDim",children:[" \xB7 ",a.summary]}),a.isDefault?Cl(m,{name:"fgDim",children:[" \xB7 ",e("picker.provider.default")]}):null]},a.name)}),t.providers.length>i.length&&Mr(Rl,{children:Cl(m,{name:"fgDim",children:[" ",e("picker.provider.more",{count:t.providers.length-i.length})]})})]})}import"react";import{Box as E0,Text as fz}from"ink";import{jsx as sk,jsxs as T0}from"react/jsx-runtime";function ik(t){if(t.chips.length===0)return null;let e=t.active??-1;return sk(E0,{flexWrap:"wrap",children:t.chips.map((o,n)=>{let r=n===e;return T0(E0,{marginRight:1,children:[T0(m,{name:r?"accent":"depth",children:[r?"\u203A ":"","@",o.path,o.truncated?"~":""]}),sk(fz,{children:" "}),sk(m,{name:"fgDim",children:"[\u232B]"})]},o.path)})})}import"react";import{Box as Ol,Text as _0}from"ink";import{jsx as Yo,jsxs as Lr}from"react/jsx-runtime";function ak(t){let e=Z(),{t:o}=fe(),n=t.columns??80,r=t.plan??"assinatura",s=e.glyph("wave").repeat(17);return Lr(Ol,{flexDirection:"column",paddingY:1,children:[Yo(ys,{columns:n}),Yo(Ol,{paddingTop:1,paddingLeft:2,children:Yo(m,{name:"fgDim",children:o("boot.tagline")})}),Lr(Ol,{paddingLeft:2,children:[Yo(m,{name:"accent",children:s}),t.version!==void 0&&Lr(m,{name:"fgDim",children:[" v",t.version]})]}),Lr(Ol,{paddingLeft:2,children:[Yo(L,{name:"window",role:"fgDim"}),Lr(m,{name:"fgDim",children:[" ",r," \xB7 "]}),Yo(m,{name:"fgDim",children:t.tier}),Yo(_0,{children:" "}),Yo(m,{name:"fgDim",children:"\xB7 "}),Yo(L,{name:"broker",role:"depth"}),Lr(m,{name:"depth",children:[" ",o("boot.broker")]})]}),t.status!==void 0&&Lr(Ol,{paddingTop:1,paddingLeft:2,children:[Yo(ws,{frame:t.frame??0}),Yo(_0,{children:" "}),Lr(m,{name:"fgDim",children:[t.status,"\u2026"]})]})]})}import"react";import{Box as R0}from"ink";import{jsx as ck,jsxs as lk}from"react/jsx-runtime";var pz=['"explique a estrutura deste repo"','"rode os testes e resuma as falhas"',"/help para comandos \xB7 /login conta \xB7 /quit"];function dk(t){let e=t.suggestions??pz;return lk(R0,{flexDirection:"column",children:[ck(m,{name:"fg",children:t.name?`bom te ver de novo, ${t.name}.`:"bom te ver por aqui."}),ck(m,{name:"fgDim",children:"eu leio e edito arquivos e rodo comandos aqui \u2014 sempre te mostrando o efeito exato antes."}),lk(R0,{paddingTop:1,flexDirection:"column",children:[ck(m,{name:"fgDim",children:"experimente:"}),e.map((o,n)=>lk(m,{name:"fgDim",children:[" \xB7 ",o]},n))]})]})}import"react";import{jsx as Hue}from"react/jsx-runtime";import"react";import{Box as C0,Text as uk}from"ink";import{jsx as Rs,jsxs as Qm}from"react/jsx-runtime";var O0=12;function M0(t,e){return!Number.isFinite(t)||!Number.isFinite(e)||e<=0?0:Math.max(0,Math.min(1,t/e))}function L0(t,e,o,n,r){let s=Math.max(1,Math.trunc(n)),i=Math.max(0,Math.min(1,t)),a=Math.round(i*s);i>0&&a===0&&(a=1),i<1&&a===s&&(a=s-1);let c=e.repeat(a),l=o.repeat(s-a);return r?{filled:c,rest:l}:{filled:`[${c}`,rest:`${l}]`}}function Yi(t){let e=Z(),o=t.role??"accent";if(t.value!==void 0&&t.max!==void 0){let a=M0(t.value,t.max),c=Math.round(a*100),l=e.glyph("barFull"),d=e.glyph("barEmpty"),f=t.width??O0,{filled:u,rest:p}=L0(a,l,d,f,e.unicode);return Qm(C0,{children:[Rs(m,{name:o,children:u}),Rs(m,{name:"fgDim",children:p}),Rs(uk,{children:" "}),Qm(m,{name:o,children:[c,"%"]}),Rs(uk,{children:" "}),Rs(m,{name:"fgDim",children:t.label})]})}let r=e.spinnerFrames,s=e.animate?r[(t.frame??0)%r.length]:e.glyph("clock"),i=t.elapsedMs!==void 0?Ci(t.elapsedMs):void 0;return Qm(C0,{children:[Rs(m,{name:o,children:s}),Rs(uk,{children:" "}),Qm(m,{name:"fgDim",children:[t.label,"\u2026",i!==void 0?` ${i}`:""]})]})}import"react";import{Box as hz}from"ink";import{jsx as gz,jsxs as P0}from"react/jsx-runtime";function mk(t){let{t:e}=fe(),o=(t.columns??80)<60,n=e(o?"banner.yolo.narrow":"banner.yolo");return P0(hz,{children:[gz(L,{name:"ask",role:"danger"}),P0(m,{name:"danger",children:[" ",n]})]})}import"react";import{Box as yz}from"ink";import{jsx as N0,jsxs as fk}from"react/jsx-runtime";var bz={plan:{glyph:"planMode",role:"depth",word:"PLAN",caption:"mode.plan.caption"},normal:{glyph:"normalMode",role:"fgDim",word:"NORMAL",caption:"mode.normal.caption"},unsafe:{glyph:"ask",role:"danger",word:"YOLO",caption:"mode.unsafe.caption"}};function Zm(t){let{t:e}=fe();if(t.mode==="unsafe")return N0(mk,{...t.columns!==void 0?{columns:t.columns}:{}});let o=bz[t.mode],n=(t.columns??80)<60;return fk(yz,{children:[N0(L,{name:o.glyph,role:o.role}),fk(m,{name:o.role,children:[" ",e("mode.label")," ",o.word]}),!n&&fk(m,{name:"fgDim",children:[" \xB7 ",e(o.caption)]})]})}import"react";import{jsx as I0}from"react/jsx-runtime";var vz={idle:"hints.idle",thinking:"hints.thinking",streaming:"hints.streaming",ask:"hints.ask","ask-destructive":"hints.askDestructive",slash:"hints.slash",palette:"hints.palette",budget:"hints.budget",error:"hints.error","work-subagents":"hints.workSubagents","idle-subagents":"hints.idleSubagents"},kz=new Set(["thinking","streaming","work-subagents"]);function Ml(t){let{t:e}=fe();if(t.armedExit===!0)return I0(m,{name:"accent",children:e("hints.ctrlcAgain")});let o=e(vz[t.state]),n=t.elapsed!==void 0&&t.elapsed!==""&&kz.has(t.state);return I0(m,{name:"fgDim",children:n?`${o} \xB7 ${t.elapsed}`:o})}import"react";import{Box as pk}from"ink";import{jsx as hk,jsxs as gk}from"react/jsx-runtime";function ef(t){return gk(pk,{flexDirection:"column",children:[gk(pk,{children:[hk(L,{name:"clock",role:"depth"}),gk(m,{name:"depth",children:[" ",t.title]})]}),hk(pk,{flexDirection:"column",paddingLeft:2,children:t.lines.map((e,o)=>hk(m,{name:"fgDim",children:e},o))})]})}import"react";import{Box as Cs,Text as xz}from"ink";import{jsx as Vo,jsxs as Co}from"react/jsx-runtime";var Sz=4,wz="shell";function yk(t){let e=Z();if(t.status==="running"){let a=Ui(t.liveOutput??"",$m).replace(/\n+$/,""),c=t.columns&&t.columns>0?t.columns-Sz:0,{text:l,hidden:d}=Li(a,t.maxLines,c);return Co(Cs,{flexDirection:"column",paddingLeft:2,children:[Vo(As,{glyph:"toolInflight",glyphRole:"depth",label:`rodando $ ${t.command}`,...t.frame!==void 0?{frame:t.frame}:{}}),l.length>0&&Co(Cs,{flexDirection:"column",paddingLeft:2,children:[d>0&&Co(m,{name:"fgDim",children:["\u2026 (",d," linhas acima)"]}),l.split(`
524
524
  `).map((f,u)=>Vo(Cs,{children:Vo(m,{name:"fgDim",children:f})},u))]})]})}let o=t.status==="err",n=t.status==="blocked",r=n?"bloqueado":o?"erro":"ok",s=t.output??"";return Co(Cs,{flexDirection:"column",paddingLeft:2,children:[Co(Cs,{children:[n?Vo(L,{name:"err",role:"danger"}):Vo(L,{name:"tool",role:"depth"}),Co(m,{name:"fg",children:[" ",wz," "]}),Vo(m,{name:"accent",children:"$ "}),Vo(m,{name:"fg",children:t.command}),Vo(xz,{children:" "}),n||o?Vo(L,{name:"err",role:"danger"}):Vo(L,{name:"ok",role:"success"}),Co(m,{name:n||o?"danger":"fgDim",children:[" ",r]})]}),s.trim()!==""&&Co(Cs,{flexDirection:"column",paddingLeft:2,children:[Co(m,{name:"fgDim",children:[e.box.topLeft," sa\xEDda ",e.box.horizontal.repeat(8)]}),s.split(`
525
525
  `).map((i,a)=>Co(Cs,{children:[Co(m,{name:"fgDim",children:[e.box.vertical," "]}),Vo(m,{name:n||o?"danger":"fg",children:i})]},a)),Co(m,{name:"fgDim",children:[e.box.bottomLeft," ",r," ",e.box.horizontal.repeat(4)]})]})]})}import"react";import{Box as bk,Text as D0}from"ink";import{jsx as kn,jsxs as Vi}from"react/jsx-runtime";function Az(t){if(t.status==="running")return"rodando";if(t.status==="done")return"pronto";if(t.status==="cancelled")return"parado";switch(t.stop){case"timeout":return"timeout";case"limit":return"teto";default:return"falhou"}}function Ez(t){let e=t.child,o=Az(e),n=e.status==="running"?kn(L,{name:"clock",role:"depth"}):e.status==="done"?kn(L,{name:"ok",role:"success"}):e.status==="cancelled"?kn(L,{name:"err",role:"fgDim"}):kn(L,{name:"err",role:"danger"}),r=e.status==="done"?"success":e.status==="fail"?"danger":"fgDim";return Vi(bk,{paddingLeft:2,children:[Vi(m,{name:"accent",children:["[",e.label,"]"]}),kn(D0,{children:" "}),n,kn(D0,{children:" "}),kn(m,{name:r,children:o}),e.summary!==void 0&&e.status!=="running"&&Vi(m,{name:"fgDim",children:[" \xB7 ",e.summary]})]})}function vk(t){let e=t.childrenStatus,o=e.length,n=e.filter(s=>s.status==="running").length,r=n>0?` (${n} rodando)`:"";return Vi(bk,{flexDirection:"column",paddingLeft:2,paddingBottom:1,children:[Vi(bk,{children:[kn(L,{name:"subagents",role:"accent"}),Vi(m,{name:"fg",children:[" ",o," sub-agente",o===1?"":"s",":"]}),r!==""&&kn(m,{name:"fgDim",children:r})]}),e.map((s,i)=>kn(Ez,{child:s},`${s.label}:${i}`))]})}import"react";import{Box as Xi,Text as kk}from"ink";import{jsx as Zt,jsxs as Pr}from"react/jsx-runtime";function Tz(t){switch(t){case"pending":return"testando";case"ok":return"ok";case"warn":return"aviso";default:return"falha"}}function _z(t){let e=Z(),o=t.check,n=Tz(o.status),r,s;if(o.status==="pending"){let i=e.spinnerFrames,a=e.animate?i[(t.frame??0)%i.length]:e.glyph("clock");r=Zt(m,{name:"accent",children:a}),s="fgDim"}else o.status==="ok"?(r=Zt(L,{name:"ok",role:"success"}),s="success"):o.status==="warn"?(r=Zt(L,{name:"ask",role:"accent"}),s="accent"):(r=Zt(L,{name:"err",role:"danger"}),s="danger");return Pr(Xi,{flexDirection:"column",children:[Pr(Xi,{children:[Zt(kk,{children:" "}),r,Zt(kk,{children:" "}),Pr(m,{name:"fg",children:[o.label,":"]}),Zt(kk,{children:" "}),o.detail!==void 0&&o.detail!==""?Zt(m,{name:s,children:o.detail}):Pr(m,{name:s,children:[n,"\u2026"]})]}),o.status!=="pending"&&o.status!=="ok"&&o.fix!==void 0&&Zt(Xi,{paddingLeft:4,children:Pr(m,{name:"fgDim",children:["\u2192 ",o.fix]})})]})}function xk(t){let e=t.checks,o=e.filter(s=>s.status==="pending").length,n=o>0?` (${o} testando)`:"",r=t.frame??0;return Pr(Xi,{flexDirection:"column",paddingLeft:2,paddingBottom:1,children:[Pr(Xi,{children:[Zt(L,{name:"clock",role:"accent"}),Zt(m,{name:"fg",children:" doctor \u2014 diagn\xF3stico"}),n!==""&&Zt(m,{name:"fgDim",children:n})]}),e.map(s=>Zt(_z,{check:s,frame:r},s.id)),t.summary!==void 0&&Zt(Xi,{paddingTop:1,children:Pr(m,{name:"fgDim",children:["resumo: ",t.summary]})})]})}import"react";import{Box as Oo,Text as tf}from"ink";import{jsx as Ce,jsxs as Ut}from"react/jsx-runtime";var Sk={thinking:"pensando",tool:"rodando tool",asking:"aguardando confirma\xE7\xE3o",done:"conclu\xEDdo",cancelled:"parado",failed:"falhou"};function $0(t){switch(t){case"done":return"success";case"cancelled":return"fgDim";case"failed":return"danger";default:return"accent"}}function wk(t){let e=[`${kt(t.tokens)} tokens`];return t.toolCalls>0&&e.push(`${t.toolCalls} tools`),e.push(qo(t.durationMs)),e.join(" \xB7 ")}function Rz(t){let e=t.node,o=e.kind==="root"?0:2,n=t.focused?"\u25B8":" ";return Ut(Oo,{paddingLeft:o,children:[Ut(m,{name:t.focused?"accent":"fgDim",children:[n," "]}),Ut(m,{name:"accent",children:["[",e.label,"]"]}),Ce(tf,{children:" "}),Ce(m,{name:$0(e.phase),children:Sk[e.phase]}),Ut(m,{name:"fgDim",children:[" \xB7 ",wk(e.accounting)]})]})}function Cz(t){let e=Math.max(1,t.maxRows??10),o=t.columns,n=o!==void 0&&o>0?i=>{let c=(i.kind==="root"?0:2)+ye(` [${i.label}] ${Sk[i.phase]} \xB7 ${wk(i.accounting)}`);return Math.max(1,Math.ceil(c/o))}:void 0,{start:r,slice:s}=vn(t.overview,t.selected,e,n);return Ut(Oo,{flexDirection:"column",paddingLeft:2,paddingBottom:1,children:[Ut(Oo,{children:[Ce(L,{name:"subagents",role:"accent"}),Ce(m,{name:"fg",children:" \xE1rvore de fluxos \u2014 ver \xB7 parar \xB7 interagir"})]}),s.map((i,a)=>Ce(Rz,{node:i,focused:r+a===t.selected},i.id)),t.overview.length>s.length&&Ce(Oo,{children:Ut(m,{name:"fgDim",children:[" \u2026 ",t.overview.length-s.length," n\xF3s a mais (\u2191\u2193 rola)"]})}),Ce(Oo,{paddingTop:1,children:Ce(m,{name:"fgDim",children:"\u2191\u2193 navega \xB7 enter: ver \xB7 p: parar este \xB7 P: parar todos \xB7 i: interagir \xB7 esc: fecha"})})]})}function Oz(t){let e=t.activity,o=[];return e.durationMs!==void 0&&o.push(qo(e.durationMs)),(e.added!==void 0||e.removed!==void 0)&&o.push(`+${e.added??0}/\u2212${e.removed??0}`),e.tokens!==void 0&&o.push(`${kt(e.tokens)} tok`),Ut(Oo,{flexDirection:"column",paddingLeft:2,children:[Ut(Oo,{children:[e.running?Ce(L,{name:"clock",role:"depth"}):e.ok?Ce(L,{name:"ok",role:"success"}):Ce(L,{name:"err",role:"danger"}),Ce(tf,{children:" "}),Ce(m,{name:"fg",children:e.tool}),e.target!==""&&Ut(m,{name:"fgDim",children:[" ",e.target]}),Ce(tf,{children:" "}),Ce(m,{name:e.running?"fgDim":e.ok?"success":"danger",children:e.summary&&e.summary!==""?e.summary:e.running?"rodando":e.ok?"ok":"erro"}),o.length>0&&Ut(m,{name:"fgDim",children:[" \xB7 ",o.join(" \xB7 ")]})]}),e.running&&e.tail!==void 0&&e.tail!==""&&Ce(Oo,{paddingLeft:4,children:Ce(m,{name:"fgDim",children:e.tail})})]})}function Mz(t){let e=t.node;return Ut(Oo,{flexDirection:"column",paddingLeft:2,paddingBottom:1,children:[Ut(Oo,{children:[Ce(L,{name:"subagents",role:"accent"}),Ce(m,{name:"fg",children:" "}),Ut(m,{name:"accent",children:["[",e.label,"]"]}),Ce(tf,{children:" "}),Ce(m,{name:$0(e.phase),children:Sk[e.phase]}),Ut(m,{name:"fgDim",children:[" \xB7 ",wk(e.accounting)]})]}),e.recent.length===0?Ce(Oo,{paddingLeft:2,children:Ce(m,{name:"fgDim",children:"sem atividade recente."})}):e.recent.map((o,n)=>Ce(Oz,{activity:o},`${o.tool}:${n}`)),Ce(Oo,{paddingTop:1,children:Ce(m,{name:"fgDim",children:"p: parar este \xB7 i: interagir \xB7 esc/enter: volta \xE0 \xE1rvore"})})]})}function Ak(t){return t.drillIn?Ce(Mz,{node:t.drillIn}):Ce(Cz,{...t})}import"react";import{Box as Mo,Text as Ll}from"ink";import{jsx as Ve,jsxs as St}from"react/jsx-runtime";var Lz={thinking:"pensando",tool:"rodando",asking:"confirmando",done:"ok",cancelled:"parado",failed:"falhou"};function Pz(t){switch(t){case"done":return"success";case"cancelled":return"fgDim";case"failed":return"danger";default:return"accent"}}function Nz(t){return t.kind==="spawn"?{glyph:"subagents",role:"depth"}:t.kind==="broker"?{glyph:"broker",role:"depth"}:t.kind==="deny"?{glyph:"err",role:"danger"}:t.kind==="ask"?{glyph:"ask",role:"accent"}:t.status==="running"?{glyph:"toolInflight",role:"fgDim"}:t.status==="err"?{glyph:"err",role:"danger"}:{glyph:"tool",role:"success"}}function Ek(t,e){return e<=1?t:xs(t,e)}function Iz(t){let e=[];return(t.added!==void 0||t.removed!==void 0)&&e.push(`+${t.added??0} \u2212${t.removed??0}`),t.durationMs!==void 0&&e.push(qo(t.durationMs)),t.tokens!==void 0&&e.push(`${kt(t.tokens)} tok`),e.join(" \xB7 ")}function Dz(t){let e=[kt(t.tokens)];return t.toolCalls>0&&e.push(`${t.toolCalls} tools`),e.push(qo(t.durationMs)),e.join(" \xB7 ")}function $z(t){return t==="running"?"fgDim":t==="err"?"danger":"success"}function Fz(t){return t==="running"?"rodando":t==="err"?"erro":"ok"}function F0(t){let e=t.event,o=Nz(e),n=Math.max(4,t.cols-4-ye(e.label)-1),r=Iz(e),s=e.summary!==void 0&&e.summary!==""?e.summary:Fz(e.status);return St(Mo,{flexDirection:"column",paddingLeft:2,children:[Ve(Mo,{children:St(Ll,{wrap:"wrap",children:[Ve(L,{name:o.glyph,role:o.role}),Ve(Ll,{children:" "}),Ve(m,{name:"fg",children:e.label}),e.detail!==""&&St(m,{name:"fgDim",children:[" ",Ek(e.detail,n)]}),Ve(Ll,{children:" \xB7 "}),Ve(m,{name:$z(e.status),children:s}),r!==""&&St(m,{name:"fgDim",children:[" \xB7 ",r]})]})}),e.status==="running"&&e.tail!==void 0&&e.tail!==""&&Ve(Mo,{paddingLeft:4,children:Ve(m,{name:"fgDim",children:Ek(e.tail,Math.max(4,t.cols-4))})})]})}function Bz(t){let e=t.section,o=e.kind==="root"?0:1;return St(Mo,{flexDirection:"column",paddingLeft:o,children:[St(Mo,{children:[St(m,{name:"fgDim",children:[e.collapsed?"\u25B6":"\u25BC"," "]}),St(m,{name:"accent",children:["[",e.label,"]"]}),Ve(Ll,{children:" "}),Ve(m,{name:Pz(e.phase),children:Lz[e.phase]}),St(m,{name:"fgDim",children:[" \xB7 ",Dz(e)]}),e.collapsed&&Ve(m,{name:"fgDim",children:" (colapsado)"})]}),!e.collapsed&&e.events.map((n,r)=>Ve(F0,{event:n,cols:t.cols},`${e.id}:${r}`))]})}function Uz(t){let e=[];for(let o of t)if(e.push({t:"header",section:o}),!o.collapsed)for(let n of o.events)e.push({t:"event",section:o,event:n});return e}function Ji(t){let e=t.columns??40,o=Uz(t.sections);if(o.length===0){let u=(t.bootInfo??[]).filter(p=>p.lines.length>0);return St(Mo,{flexDirection:"column",children:[St(Mo,{children:[Ve(m,{name:t.focused?"accent":"fgDim",children:"LOG"}),Ve(m,{name:"fgDim",children:" \xB7 sem atividade ainda"})]}),u.map(p=>St(Mo,{flexDirection:"column",children:[St(Mo,{children:[Ve(L,{name:"clock",role:"fgDim"}),Ve(Ll,{children:" "}),Ve(m,{name:"accent",children:p.title})]}),p.lines.map((h,y)=>Ve(Mo,{paddingLeft:2,children:Ve(m,{name:"fgDim",children:Ek(h,Math.max(4,e-2))})},`${p.title}:${y}`))]},p.title))]})}let n=Math.max(1,t.visibleRows-1),r=o.length,s=Math.max(0,r-n),i=Math.min(Math.max(0,t.scrollOffset),s),a=r-i,c=Math.max(0,a-n),l=o.slice(c,a),d=c,f=r-a;return St(Mo,{flexDirection:"column",children:[St(Mo,{children:[Ve(m,{name:t.focused?"accent":"fgDim",children:"LOG"}),d>0&&St(m,{name:"fgDim",children:[" \xB7 \u2191",d," acima"]}),f===0?Ve(m,{name:"fgDim",children:" \xB7 \u25BC ao vivo"}):St(m,{name:"fgDim",children:[" \xB7 \u2193",f," abaixo"]})]}),l.map((u,p)=>u.t==="header"?Ve(Bz,{section:{...u.section,events:[]},cols:e},`h:${u.section.id}:${p}`):Ve(F0,{event:u.event,cols:e},`e:${u.section.id}:${p}`))]})}import"react";import{Box as Xo,Text as xn}from"ink";import{jsx as rt,jsxs as Je}from"react/jsx-runtime";var Tk=10;function _k(t){let{score:e,running:o,startedAt:n}=t,s=(t.now??Date.now)()-n,i=Ci(s);if(e.unknownFormat)return Je(Xo,{flexDirection:"column",paddingLeft:2,children:[Je(Xo,{children:[rt(L,{name:"toolInflight",role:"depth"}),rt(xn,{children:" "}),Je(m,{name:"fgDim",children:["rodando testes\u2026 ",i]})]}),rt(Xo,{paddingLeft:2,children:rt(m,{name:"fgDim",children:"formato n\xE3o reconhecido \u2014 placar indispon\xEDvel"})})]});let a=e.total>0,c=e.passed+e.failed,l=e.failed>0?"danger":"success";return Je(Xo,{flexDirection:"column",paddingLeft:2,children:[rt(Xo,{children:a?rt(Yi,{label:`${c}/${e.total} testes`,value:c,max:e.total,role:e.failed>0?"danger":"accent",frame:t.frame??0}):rt(Yi,{label:"testes em andamento",elapsedMs:s,frame:t.frame??0})}),Je(Xo,{paddingLeft:1,children:[Je(m,{name:"success",children:[rt(L,{name:"ok",role:"success"}),Je(xn,{children:[" ",e.passed," passaram"]})]}),rt(xn,{children:" "}),Je(m,{name:l,children:[rt(L,{name:e.failed>0?"err":"ok",role:l}),Je(xn,{children:[" ",e.failed," falharam"]})]}),e.total>0&&rt(m,{name:"fgDim",children:Je(xn,{children:[" (total: ",e.total,")"]})}),rt(m,{name:"fgDim",children:Je(xn,{children:[" ",i]})})]}),e.durationMs!==void 0&&rt(Xo,{paddingLeft:1,children:Je(m,{name:"fgDim",children:["dura\xE7\xE3o: ",(e.durationMs/1e3).toFixed(2),"s"]})}),e.failures.length>0&&Je(Xo,{flexDirection:"column",paddingLeft:1,paddingTop:0,children:[Je(m,{name:"danger",children:["falhas (",Math.min(e.failures.length,e.failed),"):"]}),e.failures.slice(0,Tk).map((d,f)=>Je(Xo,{paddingLeft:2,children:[Je(m,{name:"danger",children:[rt(L,{name:"err",role:"danger"}),Je(xn,{children:[" ",d.name]})]}),d.message!==""&&rt(m,{name:"fgDim",children:Je(xn,{children:[": ",d.message.split(`
526
526
  `)[0]?.slice(0,120)??""]})})]},f)),e.failures.length>Tk&&rt(Xo,{paddingLeft:2,children:Je(m,{name:"fgDim",children:["\u2026 e mais ",e.failures.length-Tk," falhas"]})})]}),!o&&rt(Xo,{paddingLeft:1,children:e.failed===0?Je(m,{name:"success",children:[rt(L,{name:"ok",role:"success"}),rt(xn,{children:" todos passaram"})]}):Je(m,{name:"danger",children:[rt(L,{name:"err",role:"danger"}),Je(xn,{children:[" ",e.failed," falharam"]})]})})]})}import"react";import{Box as jz,Text as Hz}from"ink";import{jsx as of,jsxs as qz}from"react/jsx-runtime";function Rk(t){let e=t.accounting,o=[`${kt(e.tokens)} tokens`];return e.toolCalls>0&&o.push(`${e.toolCalls} tools`),o.push(qo(e.durationMs)),qz(jz,{paddingLeft:2,children:[e.live?of(L,{name:"clock",role:"depth"}):of(L,{name:"ok",role:"success"}),of(Hz,{children:" "}),of(m,{name:"fgDim",children:o.join(" \xB7 ")})]})}j();import B0 from"react";import{Box as Wz,Text as U0}from"ink";import{Fragment as Ok,jsx as Nr,jsxs as Jo}from"react/jsx-runtime";function Ck(t){return t==="crit"?"danger":t==="warn"?"accent":"fgDim"}function Mk(t){let e=wa(t.quota,t.now),o=Jp(t.serverLimits,t.now);if(e===void 0&&o===void 0)return null;let n=e?.creditBalance,r=n===void 0&&o!==void 0;return Jo(Wz,{paddingLeft:2,children:[n!==void 0&&Jo(Ok,{children:[Nr(m,{name:"fgDim",children:"cr\xE9dito: "}),Nr(m,{name:Ck(e?.maxLevel??"ok"),children:n})]}),e!==void 0&&e.segments.map((s,i)=>Jo(B0.Fragment,{children:[(i>0||n!==void 0)&&Nr(m,{name:"fgDim",children:" \xB7 "}),Jo(m,{name:"fgDim",children:[s.label,": "]}),Jo(m,{name:Ck(s.level),children:[s.pct,"%"]})]},`q-${s.label}`)),e?.resetText!==void 0&&Jo(Ok,{children:[Nr(U0,{children:" "}),Jo(m,{name:"fgDim",children:["\xB7 ",e.resetText]})]}),e!==void 0&&r&&Nr(m,{name:"fgDim",children:" \xB7 "}),r&&o.segments.map((s,i)=>Jo(B0.Fragment,{children:[i>0&&Nr(m,{name:"fgDim",children:" \xB7 "}),Jo(m,{name:"fgDim",children:[s.label,": "]}),Nr(m,{name:Ck(s.level),children:s.value})]},`s-${s.label}`)),r&&o.resetText!==void 0&&Jo(Ok,{children:[Nr(U0,{children:" "}),Jo(m,{name:"fgDim",children:["\xB7 ",o.resetText]})]})]})}import"react";import{jsx as zz}from"react/jsx-runtime";var Gz=12;function Os(t){let o=Z().box.horizontal,n=Math.max(1,t.columns??80),r=t.subtle?Math.min(Gz,n):n,s=t.subtle?"fgDim":t.role??"fgDim",i=o.repeat(r);return zz(m,{name:s,children:i})}import{useEffect as Kz,useState as Yz}from"react";var Vz=120;function Pl(t={}){let e=t.enabled??!0,o=t.intervalMs??Vz,[n,r]=Yz(0);return Kz(()=>{if(!e)return;let s=setInterval(()=>r(i=>i+1),o);return()=>clearInterval(s)},[e,o]),e?n:0}import{useCallback as Sn,useMemo as Xz,useRef as Jz,useState as Qi}from"react";function j0(t){let[e,o]=Qi(!1),[n,r]=Qi(""),[s,i]=Qi(0),[a,c]=Qi([]),[l,d]=Qi([]),[f,u]=Qi(null),p=Jz(!1),h=Xz(()=>Lb(n,a),[n,a]),y=Sn(async()=>{if(!p.current){p.current=!0;try{let P=await t.fileIndex.list();c(P.filter(X=>rb(X)))}catch{c([])}}},[t.fileIndex]),g=Sn(()=>{o(!0),r(""),i(0),y()},[y]),w=Sn(()=>{o(!1),r(""),i(0)},[]),C=Sn(P=>{r(P),i(0)},[]),E=Sn(P=>{i(X=>{let ne=Math.max(0,h.length-1);return Math.min(ne,Math.max(0,X+P))})},[h.length]),M=Sn(async(P,X)=>{let ne=await t.attachReader.attach(P,X!==void 0?{confirmSensitive:X}:{});return ne.kind==="rejected"?(u(`@${ne.path||P} \u2014 ${ne.reason}`),null):(u(null),d(z=>z.some(I=>I.path===ne.path)?z:[...z,{path:ne.path,item:ne.item,truncated:ne.truncated}]),ne.path)},[t.attachReader]),U=Sn(async()=>{let P=h[s];return w(),P?M(P.path):null},[h,s,w,M]),H=Sn(()=>{d(P=>P.length===0?P:P.slice(0,-1))},[]),W=Sn(()=>d([]),[]),G=Sn(()=>u(null),[]);return{open:e,query:n,selected:s,hits:h,attachments:l,notice:f,openPicker:g,closePicker:w,setQuery:C,move:E,confirm:U,removeLast:H,clear:W,dismissNotice:G,attachPath:M}}j();import{useCallback as jt,useMemo as Ir,useRef as Qz,useState as eo}from"react";var Nl=10;function H0(t,e){return t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)||t.family.toLowerCase().includes(e)}function q0(t){let[e,o]=eo(!1),[n,r]=eo(0),[s,i]=eo([]),[a,c]=eo(!1),[l,d]=eo(null),[f,u]=eo(!1),[p,h]=eo(""),[y,g]=eo(0),[w,C]=eo(!1),[E,M]=eo(null),[U,H]=eo(0),[W,G]=eo(!1),[P,X]=eo(""),ne=Qz(!1),z=Ir(()=>Ia(),[]),[I,K]=eo([]),Oe=jt(J=>{let D=J.findIndex(v=>v.key===t.currentTier);return D>=0?D:0},[t.currentTier]),q=jt(async()=>{if(ne.current)return;ne.current=!0,c(!0);let J=async()=>{try{let v=await t.catalog.list();v.length===0?(i(Wo),d(!0)):(i(v),d(!1)),r(Oe(v.length===0?Wo:v))}catch{i(Wo),d(!0),r(Oe(Wo))}},D=async()=>{if(!t.customModels){K([]);return}try{K(await t.customModels.list())}catch{K([])}};try{await Promise.all([J(),D()])}finally{c(!1)}},[t.catalog,t.customModels,Oe]),ie=jt(()=>{o(!0),u(!1),h(""),g(0),C(!1),M(null),H(0),G(!1),X(""),q()},[q]),Y=jt(()=>{o(!1),u(!1),h(""),g(0),C(!1),M(null),H(0),G(!1),X("")},[]),re=s.length,ce=e&&n===re,pe=jt(J=>{f||r(D=>{let v=Math.max(0,s.length);return Math.min(v,Math.max(0,D+J))})},[s.length,f]),Q=Ir(()=>{let J=p.trim().toLowerCase();return I.filter(D=>!(w&&D.supportsTools!==!0||J!==""&&!H0(D,J)))},[I,p,w]),se=Q.length===0?-1:Math.min(Math.max(0,y),Q.length-1),Me=Ir(()=>{if(Q.length<=Nl||se<0)return 0;let J=Math.floor(Nl/2),D=Q.length-Nl;return Math.min(Math.max(0,se-J),D)},[Q.length,se]),No=Ir(()=>Q.slice(Me,Me+Nl).map((J,D)=>({model:J,highlighted:Me+D===se})),[Q,Me,se]),lt=Ir(()=>{if(!f||se<0)return null;let J=Q[se];return J&&J.supportsTools===!1?J.id:null},[f,se,Q]),Qe=Ir(()=>{let J=p.trim().toLowerCase();return J===""||I.length===0?[]:I.filter(D=>H0(D,J)).slice(0,8).map(Zz)},[p,I]),Et=Ir(()=>{let J=p.trim();if(J===""||I.length===0)return!1;let D=J.toLowerCase();return!I.some(v=>v.id.toLowerCase()===D)},[p,I]),st=jt(J=>{f&&g(D=>{let v=Q.length;return v===0?0:Math.min(v-1,Math.max(0,D+J))})},[f,Q.length]),dt=jt(()=>{f&&(C(J=>!J),g(0))},[f]),Ze=jt(J=>{M(J),H(0),G(!1),X(""),u(!1)},[]),no=jt(()=>{if(E){if(W){let ao=ah(P);if(ao===null)return null;let Ee=E;return Y(),{model:Ee,effort:ao}}if(z[ei(U)]?.kind==="custom")return G(!0),X(""),null;let v=ih(ei(U));if(v===null)return null;let He=E;return Y(),{model:He,effort:v}}if(f){let D=se>=0?Q[se]:void 0;if(D)return Ze(D.supportsTools===void 0?{kind:"custom",model:D.id}:{kind:"custom",model:D.id,supportsTools:D.supportsTools}),null;let v=p.trim();return v===""||Ze({kind:"custom",model:v}),null}if(n===re)return u(!0),h(""),g(0),C(!1),null;let J=s[n];return J&&Ze({kind:"tier",key:J.key}),null},[E,W,P,z,U,s,n,re,f,p,Q,se,Y,Ze]),ro=jt(J=>{!E||W||H(D=>ei(D+J))},[E,W]),ut=jt(J=>{if(!W)return;let D=J.replace(/[\r\n\t]/g,"");D!==""&&X(v=>v+D)},[W]),go=jt(()=>{W&&X(J=>J.slice(0,-1))},[W]),so=jt(()=>W?(G(!1),X(""),!0):E?(M(null),H(0),!0):!1,[W,E]),En=Ir(()=>{if(!W)return null;let J=Bd(P);return J.ok?null:J.reason},[W,P]),io=jt(J=>{if(!f)return;let D=J.replace(/[\r\n\t]/g,"");D!==""&&(g(0),h(v=>v+D))},[f]),yo=jt(()=>{f&&(g(0),h(J=>J.slice(0,-1)))},[f]);return{open:e,selected:n,tiers:s,loading:a,usingFallback:l,customSelected:ce,customInputOpen:f,customInput:p,customSuggestions:Qe,customWarnOutOfCatalog:Et,customBrowserAvailable:I.length>0,customFilteredCount:Q.length,customTotalCount:I.length,customRows:No,customBrowseIndex:se,customHasMoreAbove:Me>0,customHasMoreBelow:Me+Nl<Q.length,customToolsOnly:w,customNoToolsWarning:lt,openPicker:ie,closePicker:Y,move:pe,confirm:no,appendCustom:io,backspaceCustom:yo,browseMove:st,toggleToolsOnly:dt,effortStepOpen:E!==null,effortOptions:z,effortSelected:ei(U),currentEffort:t.currentEffort,effortCustomOpen:W,effortCustomInput:P,effortCustomWarn:En,effortMove:ro,appendEffortCustom:ut,backspaceEffortCustom:go,backFromEffort:so}}function Zz(t){let e=[t.name,t.family].map(o=>o.trim()).filter(o=>o!=="");return e.length>0?`${t.id} \xB7 ${e.join(" \xB7 ")}`:t.id}j();import{useCallback as nf,useState as Lk}from"react";function W0(t){let e=[];e.push({kind:"mode",mode:t.mode,actionable:!0});for(let o of vd)e.push({kind:"safe-tool",tool:o,decision:t.effectiveSafeDefault(o),actionable:!0});for(let o of t.sessionGrants.list())e.push({kind:"grant",grantKey:o,actionable:!0});for(let o of vp)e.push({kind:"locked",category:o,actionable:!1});return e}function G0(t){let[e,o]=Lk(!1),[n,r]=Lk(0),[s,i]=Lk(0),a=W0(t),c=nf(()=>{o(!0),r(0),i(u=>u+1)},[]),l=nf(()=>{o(!1)},[]),d=nf(u=>{r(p=>{let h=Math.max(0,a.length-1);return Math.min(h,Math.max(0,p+u))})},[a.length]),f=nf(()=>{let u=a[n];if(!(!u||!u.actionable)){switch(u.kind){case"mode":t.setMode(Kb(t.mode));break;case"grant":t.sessionGrants.revoke(u.grantKey);break;case"safe-tool":{let p=u.decision==="allow"?"ask":"allow";t.setSafeToolDefault(u.tool,p);break}}i(p=>p+1),r(p=>Math.min(p,Math.max(0,W0(t).length-1)))}},[a,n,t]);return{open:e,selected:n,rows:a,mode:t.mode,openPanel:c,closePanel:l,move:d,act:f}}import{useCallback as rf,useState as z0}from"react";function K0(t){let e=po.findIndex(o=>o.name===t);return e>=0?e:0}function Y0(t){let[e,o]=z0(!1),[n,r]=z0(()=>K0(t.currentTheme)),s=rf(()=>{r(K0(t.currentTheme)),o(!0)},[t.currentTheme]),i=rf(()=>{o(!1)},[]),a=rf(l=>{r(d=>{let f=Math.max(0,po.length-1);return Math.min(f,Math.max(0,d+l))})},[]),c=rf(()=>{let l=po[n];return o(!1),l?l.name:null},[n]);return{open:e,selected:n,themes:po,openPicker:s,closePicker:i,move:a,confirm:c}}import{useCallback as sf,useState as V0}from"react";function X0(t){let e=wo.findIndex(o=>o.code===t);return e>=0?e:0}function J0(t){let[e,o]=V0(!1),[n,r]=V0(()=>X0(t.currentLang)),s=sf(()=>{r(X0(t.currentLang)),o(!0)},[t.currentLang]),i=sf(()=>{o(!1)},[]),a=sf(l=>{r(d=>{let f=Math.max(0,wo.length-1);return Math.min(f,Math.max(0,d+l))})},[]),c=sf(()=>{let l=wo[n];return o(!1),l?l.code:null},[n]);return{open:e,selected:n,langs:wo,openPicker:s,closePicker:i,move:a,confirm:c}}import{useCallback as Il,useRef as tK,useState as Dl}from"react";var Lo=[{name:"openrouter",label:"OpenRouter",summary:"gateway multi-provider (padr\xE3o do broker)",isDefault:!0},{name:"deepseek",label:"DeepSeek",summary:"API direta da DeepSeek"}];function af(t,e=Lo){let o=t.trim().toLowerCase();if(o!=="")return e.find(n=>n.name.toLowerCase()===o)}function Q0(t,e=Lo){if(t.length===0)return e;let o=new Map(e.map(s=>[s.name.toLowerCase(),s])),n=new Set,r=[];for(let s of t){let i=s.name.trim();if(i==="")continue;let a=i.toLowerCase();if(n.has(a))continue;n.add(a);let c=o.get(a);r.push(c?{...c,name:i}:{name:i,label:eK(i),summary:"cadastrado no broker"})}return r.sort((s,i)=>s.isDefault&&!i.isDefault?-1:i.isDefault&&!s.isDefault?1:s.name.localeCompare(i.name)),r}function eK(t){return t.charAt(0).toUpperCase()+t.slice(1)}function $l(t,e){if(e===void 0)return 0;let o=t.findIndex(n=>n.name.toLowerCase()===e.toLowerCase());return o>=0?o:0}function Z0(t){let[e,o]=Dl(!1),[n,r]=Dl(Lo),[s,i]=Dl(()=>$l(Lo,t.currentProvider)),[a,c]=Dl(!1),[l,d]=Dl(null),f=tK(!1),u=Il(async()=>{if(!f.current){if(f.current=!0,!t.providersClient){r(Lo),d(!0),i($l(Lo,t.currentProvider));return}c(!0);try{let w=await t.providersClient.list(),C=Q0(w),E=w.length===0;r(C),d(E),i($l(C,t.currentProvider))}catch{r(Lo),d(!0),i($l(Lo,t.currentProvider))}finally{c(!1)}}},[t.providersClient,t.currentProvider]),p=Il(()=>{i($l(n,t.currentProvider)),o(!0),u()},[t.currentProvider,n,u]),h=Il(()=>{o(!1)},[]),y=Il(w=>{i(C=>{let E=Math.max(0,n.length-1);return Math.min(E,Math.max(0,C+w))})},[n.length]),g=Il(()=>{let w=n[s];return o(!1),w?w.name:null},[n,s]);return{open:e,selected:s,providers:n,loading:a,usingFallback:l,openPicker:p,closePicker:h,move:y,confirm:g}}import{useCallback as cf,useState as Pk}from"react";function eM(t){let[e,o]=Pk(!1),[n,r]=Pk(0),[s,i]=Pk([]),a=cf(()=>{i(Xv(t.store,t.limit??Vv)),r(0),o(!0)},[t.store,t.limit]),c=cf(()=>{o(!1)},[]),l=cf(f=>{r(u=>{let p=Math.max(0,s.length-1);return Math.min(p,Math.max(0,u+f))})},[s.length]),d=cf(()=>{let f=s[n];return o(!1),f?f.id:null},[s,n]);return{open:e,selected:n,sessions:s,openPicker:a,closePicker:c,move:l,confirm:d}}import{useCallback as Fl,useState as lf}from"react";function tM(t){let[e,o]=lf("closed"),[n,r]=lf(0),[s,i]=lf([]),[a,c]=lf(0),l=Fl(()=>{let h=[];try{h=A0(t.source.list(),t.limit??30)}catch{h=[]}i(h),r(0),c(0),o("list")},[t.source,t.limit]),d=Fl(()=>{o("closed")},[]),f=Fl(h=>{r(y=>{let g=e==="action"?Ym.length:s.length,w=Math.max(0,g-1);return Math.min(w,Math.max(0,y+h))})},[e,s.length]),u=Fl(()=>{if(e==="list")return s.length===0||(c(n),r(0),o("action")),null;if(e==="action"){let h=s[a],y=Ym[n];return o("closed"),!h||!y?null:{checkpointId:h.id,action:y}}return null},[e,s,n,a]),p=Fl(()=>{if(e==="action"){r(a),o("list");return}o("closed")},[e,a]);return{phase:e,open:e!=="closed",selected:n,checkpoints:s,actions:Ym,target:e==="action"?s[a]:void 0,openPicker:l,closePicker:d,move:f,confirm:u,back:p}}import{useCallback as Bl,useMemo as nK,useState as Nk}from"react";function oM(t={}){let[e,o]=Nk(!1),[n,r]=Nk(""),[s,i]=Nk(0),a=t.userCommands??[],c=t.natives,l=nK(()=>g0(n,a,c),[n,a,c]),d=Bl(()=>{r(""),i(0),o(!0)},[]),f=Bl(()=>{o(!1)},[]),u=Bl(y=>{r(y),i(0)},[]),p=Bl(y=>{i(g=>{let w=Math.max(0,l.length-1);return Math.min(w,Math.max(0,g+y))})},[l.length]),h=Bl(()=>{let y=l[s]??null;return o(!1),y},[l,s]);return{open:e,query:n,hits:l,selected:s,openPalette:d,closePalette:f,setQuery:u,move:p,confirm:h}}j();var rK=/^\/ask(?=\s|$)/i,sK=/^\/ask\s*/i;function nM(t){let e=t.trim();if(e==="")return{kind:"stop"};if(rK.test(e)){let o=e.replace(sK,"").trim();return o===""?{kind:"stop"}:{kind:"redirect",inject:o}}return{kind:"redirect",inject:e}}function rM(t,e=!0){return t==="thinking"||t==="boot"||t==="compacting"?!0:t==="streaming"||t==="retrying"?e:!1}function sM(t){return t==="thinking"||t==="streaming"||t==="retrying"||t==="compacting"}import{appendFileSync as iK}from"node:fs";import{homedir as aK}from"node:os";import{join as cK}from"node:path";function lK(t=process.env){let e=t.ALUY_DEBUG_RENDER;return e!==void 0&&e!==""&&e!=="0"&&e!=="false"}var Ik;function df(t){if(lK())try{Ik===void 0&&(Ik=cK(aK(),".aluy","render-debug.log")),iK(Ik,`${new Date().toISOString()} ${t}