@hiperplano/aluy-cli 1.0.0-rc.110 → 1.0.0-rc.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ catraca antes de acontecer.
20
20
 
21
21
  Você usa o **seu próprio modelo** (BYO): qualquer provider compatível com a API da
22
22
  OpenAI, com a sua própria credencial — direto, sem intermediário e sem metering.
23
- *(Por enquanto o aluy roda só local, com a sua chave.)*
23
+ _(Por enquanto o aluy roda só local, com a sua chave.)_
24
24
 
25
25
  ## Instalação
26
26
 
@@ -47,14 +47,14 @@ aluy --continue # retoma a sessão mais recente deste diretório
47
47
 
48
48
  Dentro da sessão, **slash-commands** controlam tudo sem sair do fluxo:
49
49
 
50
- | Comando | O que faz |
51
- |---|---|
52
- | `/model` · `/provider` · `/effort` | troca modelo / provider / esforço de raciocínio |
53
- | `/init` | cria o `ALUY.md` + a estrutura `.aluy/` do projeto |
54
- | `/mcp` · `/agents` · `/skills` · `/workflows` | gerencia MCP, sub-agentes, skills e workflows |
55
- | `/rooms` | salas de conversa entre agentes (multi-agente) |
56
- | `/rename` · `/theme` · `/lang` | nome+cor da sessão, tema, idioma |
57
- | `/memory` · `/compact` · `/history` | memória, compactação de contexto, histórico |
50
+ | Comando | O que faz |
51
+ | --------------------------------------------- | -------------------------------------------------- |
52
+ | `/model` · `/provider` · `/effort` | troca modelo / provider / esforço de raciocínio |
53
+ | `/init` | cria o `ALUY.md` + a estrutura `.aluy/` do projeto |
54
+ | `/mcp` · `/agents` · `/skills` · `/workflows` | gerencia MCP, sub-agentes, skills e workflows |
55
+ | `/rooms` | salas de conversa entre agentes (multi-agente) |
56
+ | `/rename` · `/theme` · `/lang` | nome+cor da sessão, tema, idioma |
57
+ | `/memory` · `/compact` · `/history` | memória, compactação de contexto, histórico |
58
58
 
59
59
  ## Como funciona
60
60
 
@@ -75,11 +75,11 @@ Dentro da sessão, **slash-commands** controlam tudo sem sair do fluxo:
75
75
 
76
76
  Tudo vive em `~/.aluy/`:
77
77
 
78
- | Arquivo | Conteúdo |
79
- |---|---|
80
- | `config.json` | preferências (idioma, tema, provider/modelo, perfil, limites…) |
81
- | `providers.json` | seus providers BYO (OpenAI-compatíveis) |
82
- | `mcp.json` | servers MCP globais |
78
+ | Arquivo | Conteúdo |
79
+ | ---------------- | -------------------------------------------------------------- |
80
+ | `config.json` | preferências (idioma, tema, provider/modelo, perfil, limites…) |
81
+ | `providers.json` | seus providers BYO (OpenAI-compatíveis) |
82
+ | `mcp.json` | servers MCP globais |
83
83
 
84
84
  Variáveis `ALUY_*` e flags de CLI sobrescrevem (precedência **flag > env > config > default**).
85
85
  No **projeto**, o `ALUY.md` dá as instruções ao agente e `.aluy/` guarda agents, workflows,
@@ -87,10 +87,10 @@ commands e skills.
87
87
 
88
88
  ## Monorepo
89
89
 
90
- | Pacote | Papel |
91
- |---|---|
90
+ | Pacote | Papel |
91
+ | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
92
92
  | **`@hiperplano/aluy-cli-core`** | Engine **portável** do agente (loop · tools · permissão). Sem Ink, sem I/O de terminal. Hospeda o ponto único de interceptação de tool-calls. |
93
- | **`@hiperplano/aluy-cli`** | TUI (**Ink**) + binário **`aluy`** + wiring. Consome `@hiperplano/aluy-cli-core`. |
93
+ | **`@hiperplano/aluy-cli`** | TUI (**Ink**) + binário **`aluy`** + wiring. Consome `@hiperplano/aluy-cli-core`. |
94
94
 
95
95
  Lema: **core modular, entrega monolítica**. A fronteira `core × TUI` é explícita e
96
96
  testada (o core não importa Ink).
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var tW=Object.create;var Lb=Object.defineProperty;var oW=Object.getOwnPropertyDescriptor;var nW=Object.getOwnPropertyNames;var rW=Object.getPrototypeOf,sW=Object.prototype.hasOwnProperty;var g=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var iW=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}},xt=(t,e)=>{for(var o in e)Lb(t,o,{get:e[o],enumerable:!0})},aW=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nW(e))!sW.call(t,r)&&r!==o&&Lb(t,r,{get:()=>e[r],enumerable:!(n=oW(e,r))||n.enumerable});return t};var lW=(t,e,o)=>(o=t!=null?tW(rW(t)):{},aW(e||!t||!t.__esModule?Lb(o,"default",{value:t,enumerable:!0}):o,t));import{homedir as cW}from"node:os";import{join as dW}from"node:path";function Kc(t=cW()){return dW(t,".aluy")}var Bf=g(()=>{"use strict"});var Yc,yD=g(()=>{"use strict";Yc="1.0.0-rc.110"});function Wn(t,e){return t.decide(e)}var Si=g(()=>{"use strict"});var yr,Wr,Gr=g(()=>{"use strict";yr="remember",Wr="recall"});var Pb,uW,Qa,Ib=g(()=>{"use strict";Pb=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}}},uW=200,Qa=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??uW,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 Pb(e,o,n,r??null,i);if(r){let l=this.nodes.get(r);l&&l.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,l=r.closed?0:1;return a!==l?a-l: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 Uf(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 kD(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"&&mW.has(i.status)&&(n=i.status),e){let l=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(l)&&l.length>0){let c=[];for(let d of l){let m=kD(d,!1);if(typeof m=="string")return m;c.push(m)}r=c}}}if(o===void 0||o.trim()==="")return pW;let s=o.trim().slice(0,fW);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function gW(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=kD(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 l=`${i} #${a}`;if(!n.has(l))return n.add(l),l}};for(let i=0;i<o.length;i++){let a=o[i],l=r(a.title),c=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=c!==void 0?{...a,title:l,substeps:c}:{...a,title:l}}let s=Uf(o).length;return s>bD?{error:`update_plan: no m\xE1ximo ${bD} passos (recebidos ${s}).`}:{steps:o}}function hW(t){let e=Uf(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${xD[r.step.status]} ${r.step.title}`).join(`
2
+ var tW=Object.create;var Lb=Object.defineProperty;var oW=Object.getOwnPropertyDescriptor;var nW=Object.getOwnPropertyNames;var rW=Object.getPrototypeOf,sW=Object.prototype.hasOwnProperty;var g=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var iW=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}},xt=(t,e)=>{for(var o in e)Lb(t,o,{get:e[o],enumerable:!0})},aW=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nW(e))!sW.call(t,r)&&r!==o&&Lb(t,r,{get:()=>e[r],enumerable:!(n=oW(e,r))||n.enumerable});return t};var lW=(t,e,o)=>(o=t!=null?tW(rW(t)):{},aW(e||!t||!t.__esModule?Lb(o,"default",{value:t,enumerable:!0}):o,t));import{homedir as cW}from"node:os";import{join as dW}from"node:path";function Kc(t=cW()){return dW(t,".aluy")}var Bf=g(()=>{"use strict"});var Yc,yD=g(()=>{"use strict";Yc="1.0.0-rc.111"});function Wn(t,e){return t.decide(e)}var Si=g(()=>{"use strict"});var yr,Wr,Gr=g(()=>{"use strict";yr="remember",Wr="recall"});var Pb,uW,Qa,Ib=g(()=>{"use strict";Pb=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}}},uW=200,Qa=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??uW,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 Pb(e,o,n,r??null,i);if(r){let l=this.nodes.get(r);l&&l.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,l=r.closed?0:1;return a!==l?a-l: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 Uf(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 kD(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"&&mW.has(i.status)&&(n=i.status),e){let l=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(l)&&l.length>0){let c=[];for(let d of l){let m=kD(d,!1);if(typeof m=="string")return m;c.push(m)}r=c}}}if(o===void 0||o.trim()==="")return pW;let s=o.trim().slice(0,fW);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function gW(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=kD(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 l=`${i} #${a}`;if(!n.has(l))return n.add(l),l}};for(let i=0;i<o.length;i++){let a=o[i],l=r(a.title),c=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=c!==void 0?{...a,title:l,substeps:c}:{...a,title:l}}let s=Uf(o).length;return s>bD?{error:`update_plan: no m\xE1ximo ${bD} passos (recebidos ${s}).`}:{steps:o}}function hW(t){let e=Uf(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${xD[r.step.status]} ${r.step.title}`).join(`
3
3
  `);return`plano (${o}/${e.length}):
4
4
  ${n}`}function bW(t,e){return e<0?"m\xE9dio":t===e?"curto":t>e?"longo":"m\xE9dio"}function vW(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,l)=>{let c=i.status==="in_progress"?"curto":l,d=o.get(i.title),m=d??Qa.boxId(i.title,0);return d?(i.status!=="completed"&&e.isClosed(d)&&e.reopenBox(d),e.setHorizon(d,c),e.setParent(d,a)):e.openBox(m,c,i.title,a),i.status==="completed"&&!e.isClosed(m)&&e.closeBox(m),o.set(i.title,m),m};t.forEach((i,a)=>{let l=bW(a,n),c=r(i,null,l);for(let d of i.substeps??[])r(d,c,l)});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 kW(t,e){if(!e)return hW(t);let o=new Map;for(let c of e.listBoxes())o.set(c.label,c);let n=new Map;for(let c of e.listBoxes())n.set(c.id,c);let r=new Map,s=(c,d=new Set)=>{let m=r.get(c);if(m!==void 0)return m;let u=n.get(c);if(!u||!u.parentId||d.has(c))return r.set(c,0),0;let p=s(u.parentId,new Set(d).add(c))+1;return r.set(c,p),p},i=Uf(t),l=[`plano (${i.filter(c=>c.step.status==="completed").length}/${i.length}):`];for(let{step:c,depth:d}of i){let m=o.get(c.title),u=m?yW[m.horizon]:"",p=m?s(m.id):d,h=" ".repeat(p),b=xD[c.status];l.push(`${h}${u} ${b} ${c.title}`)}return l.join(`
5
5
  `)}var Vc,mW,bD,fW,pW,xD,yW,vD,xW,SD,jf=g(()=>{"use strict";Ib();Vc="update_plan";mW=new Set(["pending","in_progress","completed"]),bD=30,fW=120,pW="update_plan: cada passo precisa de um t\xEDtulo (texto) n\xE3o-vazio.";xD={pending:"\u2610",in_progress:"\u25B6",completed:"\u2611"};yW={longo:"[\u{1F4D0}]",m\u00E9dio:"[\u{1F4CB}]",curto:"[\u{1F4CC}]"};vD=Object.freeze({type:"string",enum:["pending","in_progress","completed"],description:"pending (a fazer) \xB7 in_progress (em curso) \xB7 completed (feito)."}),xW=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:vD,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:vD},required:["title"],additionalProperties:!1}}},required:["title"],additionalProperties:!1}}},required:["steps"],additionalProperties:!1}),SD={name:Vc,effect:"read",group:"plano",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:xW,async run(t,e){let o=gW(t);return"error"in o?{ok:!1,observation:o.error}:(e.graph&&vW(o.steps,e.graph),e.plan&&e.plan.set(Uf(o.steps).map(r=>({title:r.step.title,status:r.step.status}))),{ok:!0,observation:kW(o.steps,e.graph)})}}});function wD(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)?wW(s):void 0;if(typeof i=="string")return{error:i};let a,l=t.kind??t.type;if(typeof l=="string"&&SW.has(l))a=l;else{if(typeof l=="string"&&l.trim()!=="")return{error:`perguntar: "kind" inv\xE1lido "${l}". 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 c=t.allowOther!==!1;return{spec:{kind:a,question:o,...r!==void 0?{header:r}:{},...a!=="text"&&i!==void 0?{options:i}:{},...a!=="text"?{allowOther:c}:{}}}}function wW(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 EW(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(`
@@ -157,7 +157,7 @@ ${t.trim()}`}}function iL(t,e,o=bu){let{older:n,recent:r}=yg(t,o);if(n.length===
157
157
  `);let i=Ro(process.execPath,[n,"-p",o,"--yolo","--no-self-check"],{stdio:"inherit",timeout:9e5,env:{...process.env,ALUY_OVERWRITE_RENDER:"0",ALUY_SYNC_OUTPUT:"0",ALUY_NO_WEAK_YOLO_WARN:"1",ALUY_PRINT_VERBOSE:"1"}});if(t==="mem0")try{let l=xe(Sn(),es),c=xe(l,Xn);ct(l)&&Vg(Jg(),c)}catch{}t==="ollama"&&(await X4(),J4()),process.stderr.write(`
158
158
  verificando "${t}"\u2026 (alguns segundos; a pr\xF3xima etapa vem em seguida)
159
159
  `);let a=await IP(t,process.platform,!0);for(let l=0;l<K4&&!a;l++)await V4(Y4),a=await IP(t,process.platform,!0);return{target:t,hashOk:a,installed:a,message:a?`complemento "${t}" instalado e verificado.`:`o complemento "${t}" ainda n\xE3o respondeu como esperado. O Aluy CLI funciona sem ele; voc\xEA pode tentar de novo depois com \`aluy bootstrap\`.`}}function V4(t){return new Promise(e=>setTimeout(e,t))}async function X4(){for(let t of[Yn,Qg()])try{await(await fetch(`http://${kn}:${wr}/api/pull`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,stream:!1})})).text()}catch{}}function J4(){if(process.platform!=="win32")try{let t=Ro("sh",["-lc","command -v ollama"],{encoding:"utf8",timeout:1e4});if(t.status===0&&(t.stdout??"").trim()!=="")return;let e=Xg(),n=["/usr/local/bin/ollama","/usr/bin/ollama","/opt/homebrew/bin/ollama",xe(e,".ollama","bin","ollama"),xe(Sn(),$s,"bin","ollama")].find(i=>ct(i));if(n===void 0)return;let r=xe(e,".local","bin");hw(r,{recursive:!0});let s=xe(r,"ollama");try{if(OP(s)===OP(n))return;_4(s)}catch{}try{D4(n,s)}catch{}}catch{}}function Q4(){try{return Ro("python3",["-m","venv","--help"],{timeout:1e4}).status===0}catch{return!1}}function Z4(){try{return Ro("python3",["-m","pip","--version"],{timeout:1e4}).status===0}catch{return!1}}function eK(t){let e=[],o=[];if(t.has("ollama")&&(FP()||(e.push("zstd (extrair o Ollama)"),o.push("zstd")),$P()||(e.push("tar (extrair o Ollama)"),o.push("tar"))),t.has("mem0")||t.has("headroom")){let r=bw();r.ok?(Q4()||(e.push("m\xF3dulo venv do Python (mem0/headroom criam um virtualenv)"),o.push("python3-venv")),Z4()||(e.push("pip do Python (mem0/headroom instalam pacotes)"),o.push("python3-pip"))):(e.push(`python3 >= ${xu} para mem0/headroom (encontrado: ${r.version||"nenhum"})`),o.push("python3","python3-venv","python3-pip"))}if(e.length===0)return[];let n=[...new Set(o)];return["Faltam pr\xE9-requisitos para o modo turbo (o que conseguir, instala; o resto fica de fora):",...e.map(r=>` \u2022 ${r}`),`Instale e rode \`aluy bootstrap\` de novo: sudo apt install -y ${n.join(" ")}`,""]}async function UP(t,e,o){let n=t??"turbo",r=Vn(e??{}),s=o?.useAgent!==!1,i=new gw({...o?.platform?{platform:o.platform}:{},...s?{agentInstaller:z4}:{}});if(!s)for(let a of eK(r))process.stderr.write(a+`
160
- `);return i.provisionAll(n,r)}var NP,Bl,L4,Xn,LP,gw,PP,W4,K4,Y4,vw=g(()=>{"use strict";N();NP=".aluy",Bl=448,L4=384;Xn="aluy-mem0-server.py";LP="application/vnd.ollama.image.model";gw=class{platform;agentInstaller;constructor(e={}){this.platform=e.platform??process.platform,this.agentInstaller=e.agentInstaller}hasPinnedArtifact(){return this.platform==="linux"}async isProvisioned(e){switch(e){case"ollama":{let o=xe(Sn(),$s,"bin","ollama");return ct(o)}case"mem0":{let o=xe(Sn(),es,"bin","python3");return ct(o)&&Fu(o)}case"headroom":{let o=xe(Sn(),Bs,"bin","headroom");return ct(o)}default:return!1}}async provision(e,o){let n=O4().uid;if(OS(n))return{target:e,hashOk:!1,installed:!1,message:"RECUSA ROOT (uid=0): provisionamento de sidecars \xE9 user-space. Execute como usu\xE1rio normal."};if(this.agentInstaller)return this.agentInstaller(e,o);if(!this.hasPinnedArtifact())return{target:e,hashOk:!1,installed:!1,message:`SO '${this.platform}' sem artefato pinado p/ provisionamento direto. Rode \`aluy bootstrap\` (o aluy instala via o pr\xF3prio agente, \u26A0 --yolo) ou instale manualmente.`};switch(e){case"ollama":return $4();case"mem0":return H4();case"headroom":return q4();default:return{target:e,hashOk:!1,installed:!1,message:`Alvo desconhecido: ${String(e)}`}}}async provisionAll(e,o){if(!wu(e))return{profile:e,targets:[],anySuccess:!1,allFailed:!1};let n=[],r=[...o];for(let a=0;a<r.length;a++){let l=r[a],c={index:a+1,total:r.length,plan:r};try{n.push(await this.provision(l,c))}catch(d){let m=d instanceof Error?d.message:String(d);n.push({target:l,hashOk:!1,installed:!1,message:`falha inesperada ao provisionar \u2014 seguindo p/ os pr\xF3ximos (${m}).`})}}let s=n.some(a=>a.installed),i=n.length>0&&n.every(a=>!a.installed);return{profile:e,targets:n,anySuccess:s,allFailed:i}}},PP="na faixa 3.10\u20133.12 (N\xC3O use 3.13+/3.14 \u2014 as depend\xEAncias nativas n\xE3o t\xEAm wheels e o pip falha ao compilar; no Windows prefira `py -3.12` ou `py -3.11`). Se N\xC3O houver um Python 3.10\u20133.12 instalado, INSTALE primeiro (no Windows: `winget install -e --id Python.Python.3.12 --accept-source-agreements --accept-package-agreements`; no Linux/macOS use o gerenciador do sistema). Se j\xE1 existir um venv nesse caminho numa vers\xE3o incompat\xEDvel (ex.: 3.14), APAGUE e recrie com a vers\xE3o certa",W4="IMPORTANTE \u2014 o usu\xE1rio quer ACOMPANHAR: antes de cada passo, diga em 1 linha o que vai fazer; rode os comandos de instala\xE7\xE3o de forma VIS\xCDVEL (N\xC3O silencie pip/apt/curl com -q; mostre a sa\xEDda/progresso). Sem modo silencioso. ";K4=24,Y4=5e3});var wn,jl=g(()=>{"use strict";wn="1.0.0-rc.110"});var GP={};xt(GP,{HELP_TEXT:()=>HP,parseArgs:()=>kw,suggestFlag:()=>sK,versionText:()=>qP});function yt(t,e,o={}){let n=`--${e}=`;for(let r=0;r<t.length;r++){let s=t[r];if(s===`--${e}`){let i=t[r+1];return i===void 0||(o.allowDashValue?i.startsWith("--"):i.startsWith("-"))?void 0:i}if(s!==void 0&&s.startsWith(n))return s.slice(n.length)}}function tK(t,e){let o=`-${e}=`;for(let n=0;n<t.length;n++){let r=t[n];if(r===`-${e}`){let s=t[n+1];return s!==void 0&&!s.startsWith("-")?s:void 0}if(r!==void 0&&r.startsWith(o))return r.slice(o.length)}}function qP(){return`aluy ${wn} (@hiperplano/aluy-cli-core ${Yc})`}function rK(t,e){let o=t.length,n=e.length,r=Array.from({length:n+1},(s,i)=>i);for(let s=1;s<=o;s++){let i=[s];for(let a=1;a<=n;a++){let l=t[s-1]===e[a-1]?0:1;i[a]=Math.min(r[a]+1,i[a-1]+1,r[a-1]+l)}r=i}return r[n]}function sK(t){let e,o=3;for(let n of WP){let r=rK(t,n);r<o&&(o=r,e=n)}return e}function iK(t,e){let o=[];for(let n=0;n<t.length;n++){let r=t[n];if(r==="--")break;if(!r.startsWith("--")||r.length===2||e.has(n))continue;let s=r.slice(2).split("=",1)[0];s===""||WP.has(s)||o.push(`--${s}`)}return o}function kw(t){let e=t[0];if(e==="login"&&!t.includes("-h")&&!t.includes("--help")){let G=t.slice(1),de=yt(G,"token"),Tt=yt(G,"org"),Pt=G.includes("--device"),Eo=yt(G,"provider"),ks=G.includes("--oauth");return{kind:"login",forceDeviceFlow:Pt,...de!==void 0?{token:de}:{},...Tt!==void 0?{org:Tt}:{},...Eo!==void 0?{provider:Eo}:{},...ks?{oauth:!0}:{}}}if(e==="logout"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"logout"};if(e==="whoami"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"whoami"};if(e==="doctor"&&!t.includes("-h")&&!t.includes("--help")){let G=t.includes("--deep")||t.includes("--test"),de=t.includes("--json");return{kind:"doctor",deep:G,json:de}}if(e==="config"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"config",json:t.includes("--json")};if(e==="agents"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"agents"};if(e==="bootstrap"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"bootstrap",agent:!t.includes("--no-agent")};if(e==="uninstall"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"uninstall",agent:t.includes("--agent")};if(e==="onboard"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"onboard"};if(e==="skills"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"skills"};if(e==="workflows"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"workflows"};if((e==="models"||e==="providers")&&!t.includes("-h")&&!t.includes("--help")){let G=t.includes("--json"),de=t.findIndex(Pt=>Pt==="--backend"||Pt.startsWith("--backend=")),Tt="both";if(de!==-1){let Eo=(t[de].includes("=")?t[de].slice(10):t[de+1]??"").trim().toLowerCase();Eo==="local"?Tt="local":Eo==="broker"&&(Tt="broker")}return{kind:"models",scope:Tt,json:G,which:e==="providers"?"providers":"models"}}if(e==="telegram"&&!t.includes("-h")&&!t.includes("--help")){let G=t[1];if(G===void 0||!["login","logout","allow","deny","status"].includes(G))return{kind:"usage-error",message:"uso: aluy telegram <login|logout|allow|deny|status>",exitCode:2};let Tt=t.slice(2);if(G==="login"){let Pt=yt(Tt,"token");return{kind:"telegram",sub:"login",...Pt!==void 0?{token:Pt}:{}}}if(G==="allow"||G==="deny"){let Pt=Tt.find(ks=>!ks.startsWith("-")),Eo=Pt!==void 0&&/^-?\d+$/.test(Pt)?Number(Pt):void 0;return Eo===void 0?{kind:"usage-error",message:`uso: aluy telegram ${G} <chat-id> (um inteiro)`,exitCode:2}:{kind:"telegram",sub:G,chatId:Eo}}return{kind:"telegram",sub:G}}if(e==="mcp"&&t[1]==="search"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"mcp-search",query:t.slice(2).filter(de=>!de.startsWith("-")).join(" ").trim()};if(e==="mcp")return{kind:"mcp",argv:t.slice(1)};if(e==="cron")return{kind:"cron",argv:t.slice(1)};if(t.includes("-v")||t.includes("--version"))return{kind:"version",text:qP()};if(t.includes("-h")||t.includes("--help"))return{kind:"help",text:HP};let o=t.includes("--plan"),n=t.includes("--unsafe"),r=t.includes("--yolo")||n,s=o?"plan":r?"unsafe":"normal",i=t.includes("--dense"),a=t.includes("--ascii"),l=t.includes("--telegram"),c=t.includes("--split")||t.includes("--view")?!0:void 0,d=t.includes("--fullscreen")||t.includes("--cockpit")?!0:void 0,m=t.includes("--no-budget")?!1:t.includes("--budget")?!0:void 0,u=yt(t,"tier"),p=yt(t,"lang"),h=yt(t,"max-tokens"),b=yt(t,"max-iterations"),y=yt(t,"max-output-tokens"),w=!(t.includes("--no-subagents")||t.includes("--no-subagent")),k=t.includes("--no-self-check")?"0":t.includes("--self-check")?"1":void 0,E=t.includes("--no-autocompact")?"off":yt(t,"autocompact-at"),D=t.includes("--quiet")?!0:void 0,F=t.includes("--cycle")?!0:void 0,I=yt(t,"cycles"),W=yt(t,"cycle-for"),$=yt(t,"backend"),U=yt(t,"local-provider"),X=yt(t,"local-model"),te=yt(t,"local-auth"),J=yt(t,"local-base-url"),M=yt(t,"model"),H=yt(t,"provider");if((t.includes("--provider")||t.some(G=>G.startsWith("--provider=")))&&(M===void 0||M.trim()===""))return{kind:"usage-error",message:"aluy: --provider exige --model (ex.: --provider <provider> --model <slug>)",exitCode:2};if((M===void 0||M.trim()==="")&&u!==void 0&&u.trim().toLowerCase()==="custom")return{kind:"usage-error",message:"aluy: --tier custom exige --model <slug> (ex.: --model deepseek-v4-pro). A via Custom precisa do slug do modelo; sem ele use um tier can\xF4nico (aluy-flux, aluy-granito, \u2026).",exitCode:2};let ne=yt(t,"effort"),ue=t.includes("--effort")||t.some(G=>G.startsWith("--effort=")),ie;if(ne!==void 0){if(ne.trim()==="")return{kind:"usage-error",message:"aluy: --effort requer um valor (ex.: --effort low)",exitCode:2};if(ne.length>32)return{kind:"usage-error",message:"aluy: --effort aceita no m\xE1ximo 32 caracteres",exitCode:2};ie=ne}else if(ue)return{kind:"usage-error",message:"aluy: --effort requer um valor (ex.: --effort low)",exitCode:2};let pe=t.includes("-p")||t.includes("--print")||t.includes("--exec")||t.some(G=>G.startsWith("-p=")||G.startsWith("--print=")||G.startsWith("--exec=")),P=pe?yt(t,"print",{allowDashValue:!0})??yt(t,"exec",{allowDashValue:!0})??tK(t,"p")??void 0:void 0,ce=pe?yt(t,"output-format"):void 0;if(ce!==void 0&&!["text","json","stream-json"].includes(ce.trim()))return{kind:"usage-error",message:`aluy: --output-format inv\xE1lido "${ce}" (use text | json | stream-json)`,exitCode:2};let me=t.includes("--new"),ae=t.includes("--continue"),Oe=t.indexOf("--resume"),Ie=t.find(G=>G.startsWith("--resume=")),Qe=Oe>=0||Ie!==void 0,Ze;if(Ie!==void 0)Ze=Ie.slice(9);else if(Oe>=0){let G=t[Oe+1];G!==void 0&&!G.startsWith("-")&&(Ze=G)}let et=u!==void 0?t.indexOf("--tier")+1:-1,So=p!==void 0&&!t.some(G=>G.startsWith("--lang="))?t.indexOf("--lang")+1:-1,De=Ze!==void 0&&Ie===void 0?Oe+1:-1,At=h!==void 0&&!t.some(G=>G.startsWith("--max-tokens="))?t.indexOf("--max-tokens")+1:-1,K=b!==void 0&&!t.some(G=>G.startsWith("--max-iterations="))?t.indexOf("--max-iterations")+1:-1,Ce=I!==void 0&&!t.some(G=>G.startsWith("--cycles="))?t.indexOf("--cycles")+1:-1,_e=W!==void 0&&!t.some(G=>G.startsWith("--cycle-for="))?t.indexOf("--cycle-for")+1:-1,le=y!==void 0&&!t.some(G=>G.startsWith("--max-output-tokens="))?t.indexOf("--max-output-tokens")+1:-1,wo=E!==void 0&&!t.includes("--no-autocompact")&&!t.some(G=>G.startsWith("--autocompact-at="))?t.indexOf("--autocompact-at")+1:-1,Bn=$!==void 0&&!t.some(G=>G.startsWith("--backend="))?t.indexOf("--backend")+1:-1,Ct=(G,de)=>de!==void 0&&!t.some(Tt=>Tt.startsWith(`--${G}=`))?t.indexOf(`--${G}`)+1:-1,zt=Ct("local-provider",U),gn=Ct("local-model",X),Zo=Ct("local-auth",te),re=Ct("local-base-url",J),st=M!==void 0&&!t.some(G=>G.startsWith("--model="))?t.indexOf("--model")+1:-1,dr=H!==void 0&&!t.some(G=>G.startsWith("--provider="))?t.indexOf("--provider")+1:-1,yi=ie!==void 0&&!t.some(G=>G.startsWith("--effort="))?t.indexOf("--effort")+1:-1,bi=ce!==void 0&&!t.some(G=>G.startsWith("--output-format="))?t.indexOf("--output-format")+1:-1,$a=P!==void 0&&!t.some(G=>G.startsWith("-p=")||G.startsWith("--print=")||G.startsWith("--exec="))?Math.max(t.indexOf("-p"),t.indexOf("--print"),t.indexOf("--exec"))+1:-1,Hr=t.find((G,de)=>!G.startsWith("-")&&de!==et&&de!==So&&de!==Bn&&de!==zt&&de!==gn&&de!==Zo&&de!==re&&de!==st&&de!==dr&&de!==yi&&de!==bi&&de!==$a&&de!==De&&de!==At&&de!==K&&de!==le&&de!==wo&&de!==Ce&&de!==_e),x=(P??Hr??"").trim();if(x!==""&&!/\s/.test(x)&&nK.has(x.toLowerCase()))return{kind:"usage-error",message:`aluy: "${x}" \xE9 um comando de SESS\xC3O, n\xE3o um objetivo. Use /${x} DENTRO do aluy (rode \`aluy\` sem argumentos), ou veja \`aluy --help\`. Se voc\xEA quis MESMO um objetivo com essa palavra, d\xEA mais contexto (ex.: \`aluy "${x} o arquivo X"\`).`,exitCode:2};let so=ae?{kind:"continue"}:Qe?{kind:"resume",...Ze!==void 0?{id:Ze}:{}}:void 0,jn=new Set([et,So,Bn,zt,gn,Zo,re,st,dr,yi,bi,$a,De,At,K,le,wo,Ce,_e].filter(G=>G>=0));for(let G of oK){let de=t.indexOf(G);de>=0&&!t[de].includes("=")&&jn.add(de+1)}let it=iK(t,jn);return{kind:"launch",mode:s,unsafe:s==="unsafe",unsafeAliasUsed:n,...it.length>0?{unknownFlags:it}:{},dense:i,fresh:me,subAgents:w,safeGlyphs:a,telegram:l,print:pe,...c!==void 0?{split:c}:{},...d!==void 0?{fullscreen:d}:{},...m!==void 0?{budget:m}:{},...Hr!==void 0?{goal:Hr}:{},...u!==void 0?{tier:u}:{},...$!==void 0?{backend:$}:{},...U!==void 0?{localProvider:U}:{},...X!==void 0?{localModel:X}:{},...te!==void 0?{localAuth:te}:{},...J!==void 0?{localBaseUrl:J}:{},...M!==void 0?{model:M}:{},...H!==void 0?{provider:H}:{},...ie!==void 0?{effort:ie}:{},...P!==void 0?{printArg:P}:{},...ce!==void 0?{outputFormat:ce}:{},...p!==void 0?{lang:p}:{},...so!==void 0?{resume:so}:{},...h!==void 0?{maxTokens:h}:{},...b!==void 0?{maxIterations:b}:{},...y!==void 0?{maxOutputTokens:y}:{},...k!==void 0?{selfCheck:k}:{},...E!==void 0?{autoCompactAt:E}:{},...D!==void 0?{quiet:D}:{},...F!==void 0?{cycle:F}:{},...I!==void 0?{cycles:I}:{},...W!==void 0?{cycleFor:W}:{}}}var HP,WP,oK,nK,xw=g(()=>{"use strict";N();jl();HP=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
160
+ `);return i.provisionAll(n,r)}var NP,Bl,L4,Xn,LP,gw,PP,W4,K4,Y4,vw=g(()=>{"use strict";N();NP=".aluy",Bl=448,L4=384;Xn="aluy-mem0-server.py";LP="application/vnd.ollama.image.model";gw=class{platform;agentInstaller;constructor(e={}){this.platform=e.platform??process.platform,this.agentInstaller=e.agentInstaller}hasPinnedArtifact(){return this.platform==="linux"}async isProvisioned(e){switch(e){case"ollama":{let o=xe(Sn(),$s,"bin","ollama");return ct(o)}case"mem0":{let o=xe(Sn(),es,"bin","python3");return ct(o)&&Fu(o)}case"headroom":{let o=xe(Sn(),Bs,"bin","headroom");return ct(o)}default:return!1}}async provision(e,o){let n=O4().uid;if(OS(n))return{target:e,hashOk:!1,installed:!1,message:"RECUSA ROOT (uid=0): provisionamento de sidecars \xE9 user-space. Execute como usu\xE1rio normal."};if(this.agentInstaller)return this.agentInstaller(e,o);if(!this.hasPinnedArtifact())return{target:e,hashOk:!1,installed:!1,message:`SO '${this.platform}' sem artefato pinado p/ provisionamento direto. Rode \`aluy bootstrap\` (o aluy instala via o pr\xF3prio agente, \u26A0 --yolo) ou instale manualmente.`};switch(e){case"ollama":return $4();case"mem0":return H4();case"headroom":return q4();default:return{target:e,hashOk:!1,installed:!1,message:`Alvo desconhecido: ${String(e)}`}}}async provisionAll(e,o){if(!wu(e))return{profile:e,targets:[],anySuccess:!1,allFailed:!1};let n=[],r=[...o];for(let a=0;a<r.length;a++){let l=r[a],c={index:a+1,total:r.length,plan:r};try{n.push(await this.provision(l,c))}catch(d){let m=d instanceof Error?d.message:String(d);n.push({target:l,hashOk:!1,installed:!1,message:`falha inesperada ao provisionar \u2014 seguindo p/ os pr\xF3ximos (${m}).`})}}let s=n.some(a=>a.installed),i=n.length>0&&n.every(a=>!a.installed);return{profile:e,targets:n,anySuccess:s,allFailed:i}}},PP="na faixa 3.10\u20133.12 (N\xC3O use 3.13+/3.14 \u2014 as depend\xEAncias nativas n\xE3o t\xEAm wheels e o pip falha ao compilar; no Windows prefira `py -3.12` ou `py -3.11`). Se N\xC3O houver um Python 3.10\u20133.12 instalado, INSTALE primeiro (no Windows: `winget install -e --id Python.Python.3.12 --accept-source-agreements --accept-package-agreements`; no Linux/macOS use o gerenciador do sistema). Se j\xE1 existir um venv nesse caminho numa vers\xE3o incompat\xEDvel (ex.: 3.14), APAGUE e recrie com a vers\xE3o certa",W4="IMPORTANTE \u2014 o usu\xE1rio quer ACOMPANHAR: antes de cada passo, diga em 1 linha o que vai fazer; rode os comandos de instala\xE7\xE3o de forma VIS\xCDVEL (N\xC3O silencie pip/apt/curl com -q; mostre a sa\xEDda/progresso). Sem modo silencioso. ";K4=24,Y4=5e3});var wn,jl=g(()=>{"use strict";wn="1.0.0-rc.111"});var GP={};xt(GP,{HELP_TEXT:()=>HP,parseArgs:()=>kw,suggestFlag:()=>sK,versionText:()=>qP});function yt(t,e,o={}){let n=`--${e}=`;for(let r=0;r<t.length;r++){let s=t[r];if(s===`--${e}`){let i=t[r+1];return i===void 0||(o.allowDashValue?i.startsWith("--"):i.startsWith("-"))?void 0:i}if(s!==void 0&&s.startsWith(n))return s.slice(n.length)}}function tK(t,e){let o=`-${e}=`;for(let n=0;n<t.length;n++){let r=t[n];if(r===`-${e}`){let s=t[n+1];return s!==void 0&&!s.startsWith("-")?s:void 0}if(r!==void 0&&r.startsWith(o))return r.slice(o.length)}}function qP(){return`aluy ${wn} (@hiperplano/aluy-cli-core ${Yc})`}function rK(t,e){let o=t.length,n=e.length,r=Array.from({length:n+1},(s,i)=>i);for(let s=1;s<=o;s++){let i=[s];for(let a=1;a<=n;a++){let l=t[s-1]===e[a-1]?0:1;i[a]=Math.min(r[a]+1,i[a-1]+1,r[a-1]+l)}r=i}return r[n]}function sK(t){let e,o=3;for(let n of WP){let r=rK(t,n);r<o&&(o=r,e=n)}return e}function iK(t,e){let o=[];for(let n=0;n<t.length;n++){let r=t[n];if(r==="--")break;if(!r.startsWith("--")||r.length===2||e.has(n))continue;let s=r.slice(2).split("=",1)[0];s===""||WP.has(s)||o.push(`--${s}`)}return o}function kw(t){let e=t[0];if(e==="login"&&!t.includes("-h")&&!t.includes("--help")){let G=t.slice(1),de=yt(G,"token"),Tt=yt(G,"org"),Pt=G.includes("--device"),Eo=yt(G,"provider"),ks=G.includes("--oauth");return{kind:"login",forceDeviceFlow:Pt,...de!==void 0?{token:de}:{},...Tt!==void 0?{org:Tt}:{},...Eo!==void 0?{provider:Eo}:{},...ks?{oauth:!0}:{}}}if(e==="logout"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"logout"};if(e==="whoami"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"whoami"};if(e==="doctor"&&!t.includes("-h")&&!t.includes("--help")){let G=t.includes("--deep")||t.includes("--test"),de=t.includes("--json");return{kind:"doctor",deep:G,json:de}}if(e==="config"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"config",json:t.includes("--json")};if(e==="agents"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"agents"};if(e==="bootstrap"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"bootstrap",agent:!t.includes("--no-agent")};if(e==="uninstall"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"uninstall",agent:t.includes("--agent")};if(e==="onboard"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"onboard"};if(e==="skills"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"skills"};if(e==="workflows"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"workflows"};if((e==="models"||e==="providers")&&!t.includes("-h")&&!t.includes("--help")){let G=t.includes("--json"),de=t.findIndex(Pt=>Pt==="--backend"||Pt.startsWith("--backend=")),Tt="both";if(de!==-1){let Eo=(t[de].includes("=")?t[de].slice(10):t[de+1]??"").trim().toLowerCase();Eo==="local"?Tt="local":Eo==="broker"&&(Tt="broker")}return{kind:"models",scope:Tt,json:G,which:e==="providers"?"providers":"models"}}if(e==="telegram"&&!t.includes("-h")&&!t.includes("--help")){let G=t[1];if(G===void 0||!["login","logout","allow","deny","status"].includes(G))return{kind:"usage-error",message:"uso: aluy telegram <login|logout|allow|deny|status>",exitCode:2};let Tt=t.slice(2);if(G==="login"){let Pt=yt(Tt,"token");return{kind:"telegram",sub:"login",...Pt!==void 0?{token:Pt}:{}}}if(G==="allow"||G==="deny"){let Pt=Tt.find(ks=>!ks.startsWith("-")),Eo=Pt!==void 0&&/^-?\d+$/.test(Pt)?Number(Pt):void 0;return Eo===void 0?{kind:"usage-error",message:`uso: aluy telegram ${G} <chat-id> (um inteiro)`,exitCode:2}:{kind:"telegram",sub:G,chatId:Eo}}return{kind:"telegram",sub:G}}if(e==="mcp"&&t[1]==="search"&&!t.includes("-h")&&!t.includes("--help"))return{kind:"mcp-search",query:t.slice(2).filter(de=>!de.startsWith("-")).join(" ").trim()};if(e==="mcp")return{kind:"mcp",argv:t.slice(1)};if(e==="cron")return{kind:"cron",argv:t.slice(1)};if(t.includes("-v")||t.includes("--version"))return{kind:"version",text:qP()};if(t.includes("-h")||t.includes("--help"))return{kind:"help",text:HP};let o=t.includes("--plan"),n=t.includes("--unsafe"),r=t.includes("--yolo")||n,s=o?"plan":r?"unsafe":"normal",i=t.includes("--dense"),a=t.includes("--ascii"),l=t.includes("--telegram"),c=t.includes("--split")||t.includes("--view")?!0:void 0,d=t.includes("--fullscreen")||t.includes("--cockpit")?!0:void 0,m=t.includes("--no-budget")?!1:t.includes("--budget")?!0:void 0,u=yt(t,"tier"),p=yt(t,"lang"),h=yt(t,"max-tokens"),b=yt(t,"max-iterations"),y=yt(t,"max-output-tokens"),w=!(t.includes("--no-subagents")||t.includes("--no-subagent")),k=t.includes("--no-self-check")?"0":t.includes("--self-check")?"1":void 0,E=t.includes("--no-autocompact")?"off":yt(t,"autocompact-at"),D=t.includes("--quiet")?!0:void 0,F=t.includes("--cycle")?!0:void 0,I=yt(t,"cycles"),W=yt(t,"cycle-for"),$=yt(t,"backend"),U=yt(t,"local-provider"),X=yt(t,"local-model"),te=yt(t,"local-auth"),J=yt(t,"local-base-url"),M=yt(t,"model"),H=yt(t,"provider");if((t.includes("--provider")||t.some(G=>G.startsWith("--provider=")))&&(M===void 0||M.trim()===""))return{kind:"usage-error",message:"aluy: --provider exige --model (ex.: --provider <provider> --model <slug>)",exitCode:2};if((M===void 0||M.trim()==="")&&u!==void 0&&u.trim().toLowerCase()==="custom")return{kind:"usage-error",message:"aluy: --tier custom exige --model <slug> (ex.: --model deepseek-v4-pro). A via Custom precisa do slug do modelo; sem ele use um tier can\xF4nico (aluy-flux, aluy-granito, \u2026).",exitCode:2};let ne=yt(t,"effort"),ue=t.includes("--effort")||t.some(G=>G.startsWith("--effort=")),ie;if(ne!==void 0){if(ne.trim()==="")return{kind:"usage-error",message:"aluy: --effort requer um valor (ex.: --effort low)",exitCode:2};if(ne.length>32)return{kind:"usage-error",message:"aluy: --effort aceita no m\xE1ximo 32 caracteres",exitCode:2};ie=ne}else if(ue)return{kind:"usage-error",message:"aluy: --effort requer um valor (ex.: --effort low)",exitCode:2};let pe=t.includes("-p")||t.includes("--print")||t.includes("--exec")||t.some(G=>G.startsWith("-p=")||G.startsWith("--print=")||G.startsWith("--exec=")),P=pe?yt(t,"print",{allowDashValue:!0})??yt(t,"exec",{allowDashValue:!0})??tK(t,"p")??void 0:void 0,ce=pe?yt(t,"output-format"):void 0;if(ce!==void 0&&!["text","json","stream-json"].includes(ce.trim()))return{kind:"usage-error",message:`aluy: --output-format inv\xE1lido "${ce}" (use text | json | stream-json)`,exitCode:2};let me=t.includes("--new"),ae=t.includes("--continue"),Oe=t.indexOf("--resume"),Ie=t.find(G=>G.startsWith("--resume=")),Qe=Oe>=0||Ie!==void 0,Ze;if(Ie!==void 0)Ze=Ie.slice(9);else if(Oe>=0){let G=t[Oe+1];G!==void 0&&!G.startsWith("-")&&(Ze=G)}let et=u!==void 0?t.indexOf("--tier")+1:-1,So=p!==void 0&&!t.some(G=>G.startsWith("--lang="))?t.indexOf("--lang")+1:-1,De=Ze!==void 0&&Ie===void 0?Oe+1:-1,At=h!==void 0&&!t.some(G=>G.startsWith("--max-tokens="))?t.indexOf("--max-tokens")+1:-1,K=b!==void 0&&!t.some(G=>G.startsWith("--max-iterations="))?t.indexOf("--max-iterations")+1:-1,Ce=I!==void 0&&!t.some(G=>G.startsWith("--cycles="))?t.indexOf("--cycles")+1:-1,_e=W!==void 0&&!t.some(G=>G.startsWith("--cycle-for="))?t.indexOf("--cycle-for")+1:-1,le=y!==void 0&&!t.some(G=>G.startsWith("--max-output-tokens="))?t.indexOf("--max-output-tokens")+1:-1,wo=E!==void 0&&!t.includes("--no-autocompact")&&!t.some(G=>G.startsWith("--autocompact-at="))?t.indexOf("--autocompact-at")+1:-1,Bn=$!==void 0&&!t.some(G=>G.startsWith("--backend="))?t.indexOf("--backend")+1:-1,Ct=(G,de)=>de!==void 0&&!t.some(Tt=>Tt.startsWith(`--${G}=`))?t.indexOf(`--${G}`)+1:-1,zt=Ct("local-provider",U),gn=Ct("local-model",X),Zo=Ct("local-auth",te),re=Ct("local-base-url",J),st=M!==void 0&&!t.some(G=>G.startsWith("--model="))?t.indexOf("--model")+1:-1,dr=H!==void 0&&!t.some(G=>G.startsWith("--provider="))?t.indexOf("--provider")+1:-1,yi=ie!==void 0&&!t.some(G=>G.startsWith("--effort="))?t.indexOf("--effort")+1:-1,bi=ce!==void 0&&!t.some(G=>G.startsWith("--output-format="))?t.indexOf("--output-format")+1:-1,$a=P!==void 0&&!t.some(G=>G.startsWith("-p=")||G.startsWith("--print=")||G.startsWith("--exec="))?Math.max(t.indexOf("-p"),t.indexOf("--print"),t.indexOf("--exec"))+1:-1,Hr=t.find((G,de)=>!G.startsWith("-")&&de!==et&&de!==So&&de!==Bn&&de!==zt&&de!==gn&&de!==Zo&&de!==re&&de!==st&&de!==dr&&de!==yi&&de!==bi&&de!==$a&&de!==De&&de!==At&&de!==K&&de!==le&&de!==wo&&de!==Ce&&de!==_e),x=(P??Hr??"").trim();if(x!==""&&!/\s/.test(x)&&nK.has(x.toLowerCase()))return{kind:"usage-error",message:`aluy: "${x}" \xE9 um comando de SESS\xC3O, n\xE3o um objetivo. Use /${x} DENTRO do aluy (rode \`aluy\` sem argumentos), ou veja \`aluy --help\`. Se voc\xEA quis MESMO um objetivo com essa palavra, d\xEA mais contexto (ex.: \`aluy "${x} o arquivo X"\`).`,exitCode:2};let so=ae?{kind:"continue"}:Qe?{kind:"resume",...Ze!==void 0?{id:Ze}:{}}:void 0,jn=new Set([et,So,Bn,zt,gn,Zo,re,st,dr,yi,bi,$a,De,At,K,le,wo,Ce,_e].filter(G=>G>=0));for(let G of oK){let de=t.indexOf(G);de>=0&&!t[de].includes("=")&&jn.add(de+1)}let it=iK(t,jn);return{kind:"launch",mode:s,unsafe:s==="unsafe",unsafeAliasUsed:n,...it.length>0?{unknownFlags:it}:{},dense:i,fresh:me,subAgents:w,safeGlyphs:a,telegram:l,print:pe,...c!==void 0?{split:c}:{},...d!==void 0?{fullscreen:d}:{},...m!==void 0?{budget:m}:{},...Hr!==void 0?{goal:Hr}:{},...u!==void 0?{tier:u}:{},...$!==void 0?{backend:$}:{},...U!==void 0?{localProvider:U}:{},...X!==void 0?{localModel:X}:{},...te!==void 0?{localAuth:te}:{},...J!==void 0?{localBaseUrl:J}:{},...M!==void 0?{model:M}:{},...H!==void 0?{provider:H}:{},...ie!==void 0?{effort:ie}:{},...P!==void 0?{printArg:P}:{},...ce!==void 0?{outputFormat:ce}:{},...p!==void 0?{lang:p}:{},...so!==void 0?{resume:so}:{},...h!==void 0?{maxTokens:h}:{},...b!==void 0?{maxIterations:b}:{},...y!==void 0?{maxOutputTokens:y}:{},...k!==void 0?{selfCheck:k}:{},...E!==void 0?{autoCompactAt:E}:{},...D!==void 0?{quiet:D}:{},...F!==void 0?{cycle:F}:{},...I!==void 0?{cycles:I}:{},...W!==void 0?{cycleFor:W}:{}}}var HP,WP,oK,nK,xw=g(()=>{"use strict";N();jl();HP=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
161
161
 
162
162
  Uso:
163
163
  aluy ["objetivo"] [--plan | --yolo] [--dense] [--tier <tier>] [--lang <pt-BR|en>]
@@ -590,11 +590,11 @@ ${r.join(`
590
590
  `,{mode:384});return}let s=new Set(r.messages.map(c=>c.msg_id)),i=o.messages.filter(c=>!s.has(c.msg_id)),a=r.revoked!==o.revoked||r.ttlMs!==o.ttlMs,l=!await this.fileEndsWithNewline(this.filePath(e));if(a||l){let c=[...r.messages,...i],d=[wA(o)];for(let u=0;u<c.length;u++)d.push(EA(c[u],u+2));let m=d.join(`
591
591
  `)+`
592
592
  `;if(this.maxBytes>0&&Buffer.byteLength(m,"utf-8")>this.maxBytes)throw new Error(`limite de tamanho da sala excedido (${this.maxBytes} bytes). Evicte salas expiradas ou reduza o volume de mensagens.`);await ze.writeFile(this.filePath(e),m,{mode:384})}else if(i.length>0){let c=r.messages.length+1,d="";for(let m=0;m<i.length;m++){let u=c+m+1;d+=EA(i[m],u)+`
593
- `}if(this.maxBytes>0&&(await ze.stat(this.filePath(e))).size+Buffer.byteLength(d,"utf-8")>this.maxBytes)throw new Error(`limite de tamanho da sala excedido (${this.maxBytes} bytes). Evicte salas expiradas ou reduza o volume de mensagens.`);await ze.appendFile(this.filePath(e),d)}}finally{await this.releaseLock(e,n)}}async remove(e){try{return await ze.unlink(this.filePath(e)),!0}catch(o){if(o.code==="ENOENT")return!1;throw o}}async evictDead(e){let o=e??Date.now(),n;try{n=await ze.readdir(this.baseDir,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")return 0;throw s}let r=0;for(let s of n){if(!s.isFile()||!s.name.endsWith(".jsonl"))continue;let i=s.name.slice(0,-6);if(!/^[a-f0-9]{32}$/.test(i))continue;let a=cc.join(this.baseDir,s.name);try{let l=await py(a,i);(l.revoked||Es(l,o))&&(await ze.unlink(a),r+=1)}catch{try{await ze.unlink(a),r+=1}catch{}}}return r}}});function f1(t){if(t.config.hooks.some(o=>o.event==="pre-tool"&&o.gate===!0))return async(o,n)=>{let r=Hx(t.config,o.name);if(r.length===0)return{blocked:!1};let s=await t.runner.runGate(r,n);return s.blocked?{blocked:!0,observation:`A tool "${o.name}" foi VETADA por um hook de pre-tool (gate) \u2014 isto N\xC3O \xE9 um erro t\xE9cnico nem um bloqueio da catraca: a pol\xEDtica do dono (hook \`${s.command}\`) decidiu barrar esta chamada (o hook terminou com c\xF3digo de sa\xEDda \u2260 0). N\xC3O repita a mesma chamada \u2014 siga por outro caminho. Sa\xEDda do hook (DADO): ${fZ(s.observation)}`}:{blocked:!1}}}function fZ(t){return typeof t.text=="string"?t.text:""}var p1=g(()=>{"use strict";N()});function h1(t={}){let e=t.env??process.env,o=zo(e),n=t.store??new mo,r=new co({baseUrl:o.identityBaseUrl,clientId:_w,store:n,...t.identityFetch?{fetch:t.identityFetch}:{}},{envToken:()=>e.ALUY_TOKEN}),s=En(e),i=t.brokerClient??Cd({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),a=t.catalogClient??Td({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),l=t.customModelClient??Dd({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),c=t.providersClient??_d({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),d=t.quotaClient??ik({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),m=t.mode??(t.unsafe?"unsafe":"normal"),u=m==="unsafe",p=new fo({...t.workspaceRoot!==void 0?{root:t.workspaceRoot}:{},...u?{unconfined:!0}:{}}),h=t.sessionId??gl(),b=new am({sessionId:h,...t.journalBaseDir!==void 0?{baseDir:t.journalBaseDir}:{}});b.gcOrphans();let y=new gu({store:b,workspace:p,restoreWriter:new cm({workspace:p}),currentReader:new dm({workspace:p})}),w=new hu({journal:y}),k=new Zs({workspace:p}),E=new sa(t.egressAllow!==void 0?{allow:t.egressAllow}:{}),D=cS(e.ALUY_WEB_FETCH_MAX_CHARS,t.advanced?.webFetch?.maxObservationChars),F=zw({egress:E,policy:{maxObservationChars:D,...u?{allowInternalHosts:!0}:{}}}),I=new ss({workspace:p,...t.memoryBaseDir!==void 0?{baseDir:t.memoryBaseDir}:{}}),W=new Ki({store:I}),$=new lm({...t.todoBaseDir!==void 0?{baseDir:t.todoBaseDir}:{},sessionId:h}),U=process.env.ALUY_SANDBOX_BASH?Th():void 0,X=new Wh,te=new Qa,J={fs:k,shell:new tm({workspace:p,timeoutMs:pZ,...U?{sandboxLauncher:U}:{},egressAllows:re=>{let Ne=E.inspect(re);return Ne.hasNetwork&&!Ne.outsideAllowlist}}),search:new om({workspace:p}),journal:y.toolPort,web:F,cwd:p,memory:{remember:(re,Ne,st)=>W.remember(re,Ne,st),searchFacts:(re,Ne)=>W.searchFacts(re,Ne)},todo:$,question:X,graph:te},M=new nm({workspace:p}),H=new Sm({workspace:p,fs:k}),Ae=new To({mode:m,diffPreview:(re,Ne,st)=>st!==void 0?Sl(re,st,Ne,!0):Sl(re,"",Ne,!1),maxMemoryWritesPerSession:PD(t.maxMemoryWritesPerSession,e.ALUY_MAX_MEMORY_WRITES_PER_SESSION,t.limits?.maxMemoryWritesPerSession)}),ne=new qh(t.askTimeoutMs!==void 0?{timeoutMs:t.askTimeoutMs}:{}),ue=(t.hooksConfigStore??new km({workspaceRoot:t.workspaceRoot??process.cwd()})).load(),ie=new cu({permission:Ae,ports:J,askResolver:ne}),pe=f1({runner:ie,config:ue}),P=t.tier??On,ce=P==="custom"?t.model:void 0,me=ce!==void 0?t.provider:void 0,ae=t.activeModelSlug??ce,Oe=dh(P,e,void 0,t.context?.window,zl(t.providerWindows,t.activeProviderId,ae)),Ie=t.effort,Ze=(t.effectiveBackend!=="local"?(t.localBudget===!1&&t.onConfigWarn?.("aluy: budget OFF n\xE3o se aplica ao backend broker \u2014 o or\xE7amento de sess\xE3o est\xE1 SEMPRE ativo no broker. Use --backend local para deslig\xE1-lo (BYO)."),!0):t.localBudget!==!1)?{...Ho,maxIterations:Xf(t.maxIterations,e.ALUY_MAX_ITERATIONS,t.limits?.maxIterations),maxTokens:Vf(t.maxTokens,e.ALUY_MAX_TOKENS,t.limits?.maxTokens)}:{maxIterations:1e4,maxToolCalls:1e4*2},et=MD(t.maxOutputTokens,e.ALUY_MAX_OUTPUT_TOKENS,t.limits?.maxOutputTokens,t.onConfigWarn),xo=kk({flag:t.selfCheck,env:e.ALUY_SELF_CHECK,tier:P,everyKEnv:e.ALUY_SELF_CHECK_EVERY,maxVerificationsEnv:e.ALUY_SELF_CHECK_MAX,...t.advanced?.selfCheck?.everyK!==void 0?{everyKConfig:t.advanced.selfCheck.everyK}:{},...t.advanced?.selfCheck?.maxVerifications!==void 0?{maxVerificationsConfig:t.advanced.selfCheck.maxVerifications}:{}}),So={cwd:p.cwd,tier:P,...ce!==void 0?{model:ce}:{},...t.effectiveBackend!==void 0?{backend:t.effectiveBackend}:{},tokens:0,windowPct:0},De=null,vt=new Eu,At=Vn({ollama:e.ALUY_MAESTRO_OLLAMA!=="0",mem0:e.ALUY_MAESTRO_MEM0!=="0"}),j=!1,K=!1,ye=new Gh({client:i,tier:P,...t.headroomUrl!==void 0?{headroomUrl:t.headroomUrl}:{},onHeadroomUsed:re=>vt.record("headroom",re),...ce!==void 0?{model:ce}:{},...me!==void 0?{provider:me}:{},...Ie!==void 0?{effort:Ie}:{},...et!==void 0?{maxTokens:et}:{},sink:{onStart:()=>De?.sink.onStart?.(),onDelta:re=>De?.sink.onDelta(re),onUsage:re=>De?.sink.onUsage?.(re),onQuota:re=>De?.sink.onQuota?.(re),onDone:()=>De?.sink.onDone?.()}}),Ce=new nn({client:i,tier:P,tierSource:ye,maxTokens:gg}),rt=new nn({client:i,tier:P,tierSource:ye,maxTokens:2048}),_e=t.subAgents?.enabled?new nn({client:i,tier:P,tierSource:ye,...et!==void 0?{maxTokens:et}:{}}):void 0,Y=new Map,le,Me=t.subAgents?.enabled?re=>{let Ne=Y.get(re);if(Ne)return Ne;let st=new nn({client:i,tier:re,...et!==void 0?{maxTokens:et}:{}});return le&&st.attachNativeTools(le),Y.set(re,st),st}:void 0,wo=new Map,No="\0__inherit__",Bn=t.subAgents?.enabled?re=>{let Ne=re??No,st=wo.get(Ne);if(st)return st;let Un=re!==void 0?{tier:"custom",model:re,get provider(){return ye.provider}}:{tier:"custom",get model(){return ye.model},get provider(){return ye.provider}},dr=new nn({client:i,tier:"custom",tierSource:Un,...et!==void 0?{maxTokens:et}:{}});return le&&dr.attachNativeTools(le),wo.set(Ne,dr),dr}:void 0,Ct=t.subAgents?.enabled?{availableNames:async()=>(await a.list()).map(re=>re.key)}:void 0,zt=sS(e.ALUY_ROOM_BACKEND,t.roomsBackend);zt.warning&&t.onConfigWarn&&t.onConfigWarn(zt.warning);let gn=(()=>{switch(zt.backend){case"memory":return new Qr;case"file":return new gy;case"loopback":case"broker":throw new Error(`Room backend "${zt.backend}" n\xE3o implementado ainda. Use "memory" ou "file", ou deixe o default.`);default:return new Qr}})(),Zo=new fy({model:ye,compactionModel:Ce,sideQueryModel:rt,permission:Ae,roomStore:gn,ports:J,askResolver:ne,agentMemory:W,commandWorkspace:p,login:r,questionResolver:X,...pe?{preToolGate:pe}:{},...Ut(ue,"user-prompt-submit").length>0?{onUserPromptSubmit:()=>{ie.runAll(Ut(ue,"user-prompt-submit"))}}:{},meta:So,limits:Ze,...xo.enabled?{selfCheck:xo}:{},...t.autoCompactAt!==void 0?{autoCompactAt:t.autoCompactAt}:{},...t.context?{contextConfig:t.context}:{},...t.cycleConfig?{cycleConfig:t.cycleConfig}:{},contextWindow:Oe,...t.providerWindows!==void 0?{providerWindows:t.providerWindows}:{},...t.activeProviderId!==void 0?{activeProviderId:t.activeProviderId}:{},...t.projectInstructions!==void 0?{projectInstructions:t.projectInstructions}:{},...t.availableAgents!==void 0?{availableAgents:t.availableAgents}:{},...t.sessionCommands!==void 0?{sessionCommands:t.sessionCommands}:{},...t.mcpTools!==void 0?{mcpTools:t.mcpTools}:{},...t.pendingMcpServers!==void 0?{pendingMcpServers:t.pendingMcpServers}:{},...t.headroomUrl!==void 0?{headroomRetrieveTool:TN({baseUrl:t.headroomUrl,onUsed:re=>vt.record("headroom",re)})}:{},...t.subAgents?.enabled?{subAgents:{...t.subAgents,env:t.subAgents.env??e,...t.subagentsConfig?{configDefaults:{...t.subagentsConfig.maxPerCall!==void 0?{maxPerCall:t.subagentsConfig.maxPerCall}:{},...t.subagentsConfig.maxConcurrency!==void 0?{maxConcurrency:t.subagentsConfig.maxConcurrency}:{},...t.subagentsConfig.idleTimeoutMs!==void 0?{idleTimeoutMs:t.subagentsConfig.idleTimeoutMs}:{}}}:{},...Ut(ue,"subagent-stop").length>0?{observer:{onChildEnd:()=>{ie.runAll(Ut(ue,"subagent-stop"))}}}:{}}}:{},...t.subAgents?.enabled&&t.agentRegistry?{agentRegistry:t.agentRegistry}:{},...t.skills&&t.skills.length>0?{skills:t.skills}:{},...t.subAgents?.enabled&&t.reloadProjectAgents?{reloadProjectAgents:t.reloadProjectAgents}:{},..._e?{subAgentModel:_e}:{},...Me?{callerForTier:Me}:{},...Bn?{customCallerFor:Bn}:{},...t.callerForLocalModel?{callerForLocalModel:t.callerForLocalModel}:{},...t.localModelCatalog?{localModelCatalog:t.localModelCatalog}:{},...t.verifyAndRegisterLocalModel?{verifyAndRegisterLocalModel:t.verifyAndRegisterLocalModel}:{},...Ct?{modelProbe:Ct}:{},...t.subAgents?.defaultModel!==void 0?{defaultChildModel:t.subAgents.defaultModel}:{},disableNativeTools:e.ALUY_NATIVE_TOOLS_OFF==="1"||e.ALUY_NATIVE_TOOLS_OFF==="true",watchdogEnv:e,quotaFetcher:()=>d.fetchQuota(),...t.memoryMonitor!==void 0?{memory:{heapLimitMb:t.memoryMonitor.heapLimitMb,sampleHeapUsed:t.memoryMonitor.sampleHeapUsed,env:e,...t.memoryMonitor.sampleIntervalMs!==void 0?{sampleIntervalMs:t.memoryMonitor.sampleIntervalMs}:{},...t.advanced?.memPressure?.compactAt!==void 0?{pressureAtConfig:t.advanced.memPressure.compactAt}:{}}}:{},onUserPrompt:(re,Ne)=>{w.markPrompt(re,Ne)},...(()=>{let re=hh({env:e,usage:vt,...t.services?{services:t.services}:{}});if(j=re!==void 0&&At.has("ollama"),!re)return{};let Ne=iN(e);return Ne?{maestro:re,continuationConfig:Ne}:{maestro:re}})(),...(()=>{let re=sN({env:e,usage:vt,...t.services?{services:t.services}:{}});return K=re!==void 0,re?{memoryEngine:re.memory,memoryScope:re.memoryScope,memoryRecallScopes:re.memoryRecallScopes}:{}})(),onToolsReady:re=>{ye.attachNativeTools(re),_e?.attachNativeTools(re),le=re;for(let Ne of Y.values())Ne.attachNativeTools(re);for(let Ne of wo.values())Ne.attachNativeTools(re)}});return De=Zo,Zo.armSidecarUsage({profile:t.profile??"turbo",enabled:{headroom:t.headroomUrl!==void 0,ollama:j,mem0:K}},vt),{controller:Zo,login:r,engine:Ae,egress:E,workspace:p,askResolver:ne,questionResolver:X,journal:y,journalStore:b,checkpoints:w,fileIndex:M,attachReader:H,catalogClient:a,customModelClient:l,providersClient:c,quotaClient:d,ports:J,memory:W,todoStore:$,hookRunner:ie,hooksConfig:ue}}var On,pZ,Rm=g(()=>{"use strict";N();Ks();oa();DN();Tr();aE();ec();wm();BF();UF();qF();SA();ec();m1();p1();N();as();Qw();N();On="aluy-flux",pZ=12e4});var b1={};xt(b1,{runDoctor:()=>gZ});async function gZ(t={}){let e=t.io??jt(),o=t.env??process.env,n=t.json===!0,r=t.probe??hZ(o,t.deep===!0),s=r.tierTester!==void 0;if(!n){e.out("aluy doctor \u2014 diagn\xF3stico"),e.out("");for(let p of vh(s))e.out(`\u25F7 ${p.label}: testando\u2026`);let c={...r,onCheck:(p,h)=>{let b=kh(p,h);if(!b)return;let y=b.status==="ok"?Zu.ok:b.status==="warn"?Zu.warn:Zu.fail;e.out(`${y} ${b.label}: ${b.detail}`),b.status!=="ok"&&b.fix!==void 0&&e.out(` \u2192 ${b.fix}`)}},d=await Xu(c),m=Qu(d),u=AN(m,Zu);return e.out(""),e.out(u[u.length-1]??""),tE(m)?1:0}let i=await Xu(r),a=Qu(i),l=a.checks.map(c=>({id:c.id,status:c.status,label:c.label,detail:c.detail}));return e.out(JSON.stringify(l)),tE(a)?1:0}function hZ(t,e){return{env:t,getAccessToken:()=>yZ(t),memory:vZ(),makeMcpTransport:()=>new is({cwd:process.cwd(),parentEnv:t}),...e?{tierTester:()=>wh({tier:bZ(),login:y1(t),env:t})}:{}}}function y1(t){let e=zo(t),o=new mo;return new co({...e,baseUrl:e.identityBaseUrl,store:o})}function yZ(t){return y1(t).getAccessToken()}function bZ(){try{let t=new Ge({}).load();return Iu(void 0,t,On)}catch{return On}}function vZ(){return{async count(){try{let t=new fo({}),e=new ss({workspace:t});return(await new Ki({store:e}).list()).length}catch{return null}}}}var v1=g(()=>{"use strict";N();Ar();Ks();Tr();Wl();Iw();Gl();eE();Sh();CN();oE();_o();Rm()});function AA(t,e){return e!==void 0&&e.trim()!==""?!0:t.some(o=>o.kind==="you"||o.kind==="aluy")}function k1(t,e){if(!AA(e.blocks,e.label))return!1;try{return t.save(e)}catch{return!1}}function kZ(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 xZ(t){let e=Math.max(0,Math.floor(t/1e3));if(e<60)return"h\xE1 instantes";let o=Math.floor(e/60);if(o<60)return`h\xE1 ${o} min`;let n=Math.floor(o/60);return n<24?`h\xE1 ${n} h`:`h\xE1 ${Math.floor(n/24)} d`}function x1(t,e){return`\u21BB retomar a conversa anterior (${t} ${t===1?"mensagem":"mensagens"}, ${xZ(e)})? [S/n] `}function S1(t){if(t.length===0)return["nenhuma sess\xE3o salva ainda."];let e=["sess\xF5es salvas (retome com: aluy --resume <id>):",""];for(let o of t){let n=o.title??"(sem objetivo)";e.push(` ${o.id}`),e.push(` ${kZ(o.updatedAt)} \xB7 ${o.cwd} \xB7 ${o.blockCount} blocos`),e.push(` ${n}`)}return e}var CA=g(()=>{"use strict"});function Om(t,e=w1){let o=t.tier.trim();if(o!=="custom")return{tier:o};let n=t.model?.trim();if(n!==void 0&&n!==""){let r=t.provider?.trim();return{tier:"custom",model:n,...r!==void 0&&r!==""?{provider:r}:{}}}return{tier:e,warning:`sess\xE3o Custom anterior sem o modelo salvo \u2014 retomada no tier ${e}. Use /model p/ reescolher o modelo Custom.`}}function E1(t,e=w1){return Om({tier:t.tier??"",...t.model!==void 0?{model:t.model}:{},...t.provider!==void 0?{provider:t.provider}:{}},e)}function SZ(t,e,o){if(t===void 0)return{kind:"none"};if(t.kind==="continue"){let r=e.latestForCwd(o);if(r&&C1(r.blocks)>0)return{kind:"resumed",record:r};for(let s of e.list()){if(s.cwd!==o||s.title===void 0)continue;let i=e.load(s.id);if(i)return{kind:"resumed",record:i}}return{kind:"none"}}if(t.id!==void 0&&t.id.trim()!==""){let r=t.id.trim(),s=e.load(r);if(s)return{kind:"resumed",record:s};let i=r.toLowerCase(),a=e.list().filter(l=>(l.label??"").trim().toLowerCase()===i);if(a.length===1){let l=e.load(a[0].id);if(l)return{kind:"resumed",record:l}}return a.length>1?{kind:"pick",choices:a}:{kind:"not-found",requestedId:r}}let n=e.list().filter(r=>r.title!==void 0||r.label!==void 0);return n.length>0?{kind:"pick",choices:n}:{kind:"none"}}function A1(t){return t!==void 0&&Number.isFinite(t)&&t>0?Math.min(wZ,Math.floor(t)):Mm}function EZ(t){let e=0;for(let o of t)(o.kind==="you"||o.kind==="aluy")&&(e+=1);return e}function C1(t){let e=0;for(let o of t)o.kind==="you"&&(e+=1);return e}function AZ(t,e,o,n,r=Date.now(),s=Mm){if(t!==void 0||e)return{kind:"explicit"};let i=o.latestForCwd(n);if(!i)return{kind:"none"};let a=Math.max(0,r-i.updatedAt);if(a>s)return{kind:"none"};let l=EZ(i.blocks);return l===0?{kind:"none"}:C1(i.blocks)===0?{kind:"none"}:{kind:"offer",record:i,ageMs:a,messageCount:l}}async function T1(t){let e=SZ(t.request,t.store,t.cwd);if(e.kind!=="none"||!t.isTty)return e;let o=AZ(t.request,t.fresh,t.store,t.cwd,t.now??Date.now(),t.windowMs??Mm);if(o.kind!=="offer")return{kind:"none"};let n=!1;try{n=await t.promptYesNo(x1(o.messageCount,o.ageMs))}catch{n=!1}return n?{kind:"resumed",record:o.record}:{kind:"none"}}var w1,Mm,wZ,TA=g(()=>{"use strict";CA();w1="aluy-flux";Mm=1440*60*1e3,wZ=10080*60*1e3});function CZ(t){return(t.entries.find(o=>o.wave===1)??t.entries[0])?.id??"anthropic"}function hy(t){return Kr({flag:t.flag,env:t.env.ALUY_BACKEND,config:t.config.backend})}function DA(t,e){return t==null?void 0:Yt(e,t)?.id}function _A(t){if(t==null)return;let e=t.trim().toLowerCase();if(e==="apikey"||e==="oauth"||e==="none")return e}function TZ(t,e){let o=Yt(e,t)?.auth;return o!==void 0&&o.length>0&&o.every(n=>n==="none")?"none":"apikey"}function dc(t){if(t==null)return;let e=t.trim();return e!==""?e:void 0}function uc(t){let e=t.flags??{},o=t.catalog??vr(),n=DA(e.localProvider,o)??DA(t.env.ALUY_LOCAL_PROVIDER,o)??DA(t.config.localProvider,o)??CZ(o),r=Yt(o,n)?.defaultModel??n,s=dc(e.localModel)??dc(t.env.ALUY_LOCAL_MODEL)??dc(t.config.localModel)??r,i=_A(e.localAuth)??_A(t.env.ALUY_LOCAL_AUTH)??_A(t.config.localAuth)??TZ(n,o),a=dc(e.localBaseUrl)??dc(t.env.ALUY_LOCAL_BASE_URL)??dc(t.config.localBaseUrl);return{provider:n,model:s,auth:i,...a!==void 0?{baseUrl:a}:{}}}var yy=g(()=>{"use strict";N()});var _1={};xt(_1,{collectSettings:()=>D1,runConfig:()=>PZ});import{existsSync as RZ}from"node:fs";import{homedir as OZ}from"node:os";import{join as by}from"node:path";function Vo(t,e,o,n,r,s){let i=o?.trim();return i!==void 0&&i!==""?{key:t,value:i,origin:"env",source:e}:n!=null?{key:t,value:String(n),origin:"config.json",source:s??`config.${t}`}:{key:t,value:r,origin:"default",source:"\u2014"}}function Mn(t,e,o){return e!=null?{key:t,value:String(e),origin:"config.json",source:`config.${t}`}:{key:t,value:o,origin:"default",source:"\u2014"}}function D1(t,e){let o=uc({env:{},config:{}}),n=o.baseUrl??"\u2014";return[Vo("backend","ALUY_BACKEND",t.ALUY_BACKEND,e.backend,hy({env:{},config:{}})),Vo("localProvider","ALUY_LOCAL_PROVIDER",t.ALUY_LOCAL_PROVIDER,e.localProvider,o.provider),Vo("localModel","ALUY_LOCAL_MODEL",t.ALUY_LOCAL_MODEL,e.localModel,o.model),Vo("localAuth","ALUY_LOCAL_AUTH",t.ALUY_LOCAL_AUTH,e.localAuth,o.auth),Vo("localBaseUrl","ALUY_LOCAL_BASE_URL",t.ALUY_LOCAL_BASE_URL,e.localBaseUrl,n),Mn("profile",e.profile,"turbo"),Mn("sidecar.ollama",e.sidecarToggles?.ollama,"on (default)"),Mn("sidecar.mem0",e.sidecarToggles?.mem0,"on (default)"),Mn("sidecar.headroom",e.sidecarToggles?.headroom,"on (default)"),Mn("lang",e.lang,"auto"),Mn("theme",e.theme,"default"),Vo("maxTokens","ALUY_MAX_TOKENS",t.ALUY_MAX_TOKENS,e.limits?.maxTokens,String(1e7),"config.limits.maxTokens"),Vo("maxOutputTokens","ALUY_MAX_OUTPUT_TOKENS",t.ALUY_MAX_OUTPUT_TOKENS,e.limits?.maxOutputTokens,"\u2014 (do servidor/tier)","config.limits.maxOutputTokens"),Vo("maxIterations","ALUY_MAX_ITERATIONS",t.ALUY_MAX_ITERATIONS,e.limits?.maxIterations,String(300),"config.limits.maxIterations"),Vo("limits.maxMemoryWritesPerSession","ALUY_MAX_MEMORY_WRITES_PER_SESSION",t.ALUY_MAX_MEMORY_WRITES_PER_SESSION,e.limits?.maxMemoryWritesPerSession,String(Jc),"config.limits.maxMemoryWritesPerSession"),Vo("subagents.maxPerCall","ALUY_SUBAGENT_MAX_PER_CALL",t.ALUY_SUBAGENT_MAX_PER_CALL,e.subagents?.maxPerCall,String(Ms),"config.subagents.maxPerCall"),Vo("subagents.maxConcurrency","ALUY_SUBAGENT_MAX_CONCURRENCY",t.ALUY_SUBAGENT_MAX_CONCURRENCY,e.subagents?.maxConcurrency,String(Zp),"config.subagents.maxConcurrency"),Vo("subagents.idleTimeoutMs","ALUY_SUBAGENT_IDLE_TIMEOUT",t.ALUY_SUBAGENT_IDLE_TIMEOUT,e.subagents?.idleTimeoutMs,String(eg),"config.subagents.idleTimeoutMs"),Mn("cycle.defaultDurationMs",e.cycle?.defaultDurationMs,String(Is)),Mn("cycle.defaultIterations",e.cycle?.defaultIterations,String(Ns)),Mn("cycle.defaultIntervalMs",e.cycle?.defaultIntervalMs,String(du)),Vo("mcp.connectTimeoutMs","ALUY_MCP_CONNECT_TIMEOUT_MS",t.ALUY_MCP_CONNECT_TIMEOUT_MS,e.mcp?.connectTimeoutMs,String($w),"config.mcp.connectTimeoutMs"),Vo("mcp.callTimeoutMs","ALUY_MCP_TIMEOUT_MS",t.ALUY_MCP_TIMEOUT_MS,e.mcp?.callTimeoutMs,String(Nw),"config.mcp.callTimeoutMs"),Mn("session.gcMaxAgeMs",e.session?.gcMaxAgeMs,String($h)),Mn("session.gcMaxCount",e.session?.gcMaxCount,String(Bh)),Mn("session.autoResumeWindowMs",e.session?.autoResumeWindowMs,String(Mm))]}function MZ(t){let e=(o,n)=>{let r=by(t,o);return{path:r,role:n,exists:RZ(r)}};return[e("config.json","configura\xE7\xE3o dur\xE1vel (este comando)"),e("mcp.json","servers MCP (interop; sem credencial \u2014 CLI-SEC-7)"),e("hooks.json","hooks (fronteira de execu\xE7\xE3o; o agente nunca escreve)"),e("providers.json","cat\xE1logo de providers (override do usu\xE1rio)"),e("update-check.json","estado/cache (reescrito pela m\xE1quina)"),e("sessions","hist\xF3rico das sess\xF5es/conversas (retom\xE1vel com --resume)"),e("audit.jsonl","trilha de auditoria dos efeitos (append-only \u2014 CLI-SEC)"),e("cron","tarefas agendadas (aluy cron)"),e("exports","transcri\xE7\xF5es exportadas (/export)"),e("undo","pilha de undo das edi\xE7\xF5es do agente"),e("memory","store do mem0 (chromadb + history)"),e("logs","logs dos sidecars (mem0/ollama/headroom)")]}function PZ(t={}){let e=t.io??jt(),o=t.env??process.env,n=t.baseDir??by(OZ(),".aluy"),s=(t.configStore??new Ge({baseDir:n})).load(),i=D1(o,s),a=MZ(n);if(t.json===!0)return e.out(JSON.stringify({configPath:by(n,"config.json"),settings:i.map(d=>({key:d.key,value:d.value,origin:d.origin,source:d.source})),files:a.map(d=>({path:d.path,role:d.role,exists:d.exists}))},null,2)),0;e.out("aluy config \u2014 configura\xE7\xE3o efetiva (read-only)"),e.out(` arquivo dur\xE1vel: ${by(n,"config.json")}`),e.out(" preced\xEAncia: flag > env (ALUY_*) > config.json > default"),e.out("");let l=Math.max(...i.map(d=>d.key.length),3),c=Math.max(...i.map(d=>d.value.length),5);for(let d of i){let m=LZ[d.origin],u=d.origin==="default"?"":` (${d.source})`;e.out(` ${d.key.padEnd(l)} ${d.value.padEnd(c)} [${m}]${u}`)}e.out(""),e.out(" outros arquivos (fora do config.json de prop\xF3sito \u2014 segredo/interop/execu\xE7\xE3o):");for(let d of a){let m=d.exists?"\xB7":"\u25CB";e.out(` ${m} ${d.path} \u2014 ${d.role}`)}return e.out(""),e.out(" segredos (chave de API/token) ficam no keychain do SO, NUNCA no config.json."),0}var LZ,R1=g(()=>{"use strict";N();Ar();_o();DE();TA();yy();Gl();LZ={env:"env","config.json":"config",default:"default"}});var M1={};xt(M1,{defaultUserAgentsDir:()=>$Z,runAgents:()=>FZ});import{homedir as IZ}from"node:os";import{join as O1}from"node:path";function NZ(){return O1("~",".aluy",Ku)}function FZ(t={}){let e=t.out??(a=>process.stdout.write(a+`
593
+ `}if(this.maxBytes>0&&(await ze.stat(this.filePath(e))).size+Buffer.byteLength(d,"utf-8")>this.maxBytes)throw new Error(`limite de tamanho da sala excedido (${this.maxBytes} bytes). Evicte salas expiradas ou reduza o volume de mensagens.`);await ze.appendFile(this.filePath(e),d)}}finally{await this.releaseLock(e,n)}}async remove(e){try{return await ze.unlink(this.filePath(e)),!0}catch(o){if(o.code==="ENOENT")return!1;throw o}}async evictDead(e){let o=e??Date.now(),n;try{n=await ze.readdir(this.baseDir,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")return 0;throw s}let r=0;for(let s of n){if(!s.isFile()||!s.name.endsWith(".jsonl"))continue;let i=s.name.slice(0,-6);if(!/^[a-f0-9]{32}$/.test(i))continue;let a=cc.join(this.baseDir,s.name);try{let l=await py(a,i);(l.revoked||Es(l,o))&&(await ze.unlink(a),r+=1)}catch{try{await ze.unlink(a),r+=1}catch{}}}return r}}});function f1(t){if(t.config.hooks.some(o=>o.event==="pre-tool"&&o.gate===!0))return async(o,n)=>{let r=Hx(t.config,o.name);if(r.length===0)return{blocked:!1};let s=await t.runner.runGate(r,n);return s.blocked?{blocked:!0,observation:`A tool "${o.name}" foi VETADA por um hook de pre-tool (gate) \u2014 isto N\xC3O \xE9 um erro t\xE9cnico nem um bloqueio da catraca: a pol\xEDtica do dono (hook \`${s.command}\`) decidiu barrar esta chamada (o hook terminou com c\xF3digo de sa\xEDda \u2260 0). N\xC3O repita a mesma chamada \u2014 siga por outro caminho. Sa\xEDda do hook (DADO): ${fZ(s.observation)}`}:{blocked:!1}}}function fZ(t){return typeof t.text=="string"?t.text:""}var p1=g(()=>{"use strict";N()});function h1(t={}){let e=t.env??process.env,o=zo(e),n=t.store??new mo,r=new co({baseUrl:o.identityBaseUrl,clientId:_w,store:n,...t.identityFetch?{fetch:t.identityFetch}:{}},{envToken:()=>e.ALUY_TOKEN}),s=En(e),i=t.brokerClient??Cd({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),a=t.catalogClient??Td({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),l=t.customModelClient??Dd({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),c=t.providersClient??_d({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),d=t.quotaClient??ik({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),m=t.mode??(t.unsafe?"unsafe":"normal"),u=m==="unsafe",p=new fo({...t.workspaceRoot!==void 0?{root:t.workspaceRoot}:{},...u?{unconfined:!0}:{}}),h=t.sessionId??gl(),b=new am({sessionId:h,...t.journalBaseDir!==void 0?{baseDir:t.journalBaseDir}:{}});b.gcOrphans();let y=new gu({store:b,workspace:p,restoreWriter:new cm({workspace:p}),currentReader:new dm({workspace:p})}),w=new hu({journal:y}),k=new Zs({workspace:p}),E=new sa(t.egressAllow!==void 0?{allow:t.egressAllow}:{}),D=cS(e.ALUY_WEB_FETCH_MAX_CHARS,t.advanced?.webFetch?.maxObservationChars),F=zw({egress:E,policy:{maxObservationChars:D,...u?{allowInternalHosts:!0}:{}}}),I=new ss({workspace:p,...t.memoryBaseDir!==void 0?{baseDir:t.memoryBaseDir}:{}}),W=new Ki({store:I}),$=new lm({...t.todoBaseDir!==void 0?{baseDir:t.todoBaseDir}:{},sessionId:h}),U=process.env.ALUY_SANDBOX_BASH?Th():void 0,X=new Wh,te=new Qa,J={fs:k,shell:new tm({workspace:p,timeoutMs:pZ,...U?{sandboxLauncher:U}:{},egressAllows:re=>{let Ne=E.inspect(re);return Ne.hasNetwork&&!Ne.outsideAllowlist}}),search:new om({workspace:p}),journal:y.toolPort,web:F,cwd:p,memory:{remember:(re,Ne,st)=>W.remember(re,Ne,st),searchFacts:(re,Ne)=>W.searchFacts(re,Ne)},todo:$,question:X,graph:te},M=new nm({workspace:p}),H=new Sm({workspace:p,fs:k}),Ae=new To({mode:m,diffPreview:(re,Ne,st)=>st!==void 0?Sl(re,st,Ne,!0):Sl(re,"",Ne,!1),maxMemoryWritesPerSession:PD(t.maxMemoryWritesPerSession,e.ALUY_MAX_MEMORY_WRITES_PER_SESSION,t.limits?.maxMemoryWritesPerSession)}),ne=new qh(t.askTimeoutMs!==void 0?{timeoutMs:t.askTimeoutMs}:{}),ue=(t.hooksConfigStore??new km({workspaceRoot:t.workspaceRoot??process.cwd()})).load(),ie=new cu({permission:Ae,ports:J,askResolver:ne}),pe=f1({runner:ie,config:ue}),P=t.tier??On,ce=P==="custom"?t.model:void 0,me=ce!==void 0?t.provider:void 0,ae=t.activeModelSlug??ce,Oe=dh(P,e,void 0,t.context?.window,zl(t.providerWindows,t.activeProviderId,ae)),Ie=t.effort,Ze=(t.effectiveBackend!=="local"?(t.localBudget===!1&&t.onConfigWarn?.("aluy: budget OFF n\xE3o se aplica ao backend broker \u2014 o or\xE7amento de sess\xE3o est\xE1 SEMPRE ativo no broker. Use --backend local para deslig\xE1-lo (BYO)."),!0):t.localBudget!==!1)?{...Ho,maxIterations:Xf(t.maxIterations,e.ALUY_MAX_ITERATIONS,t.limits?.maxIterations),maxTokens:Vf(t.maxTokens,e.ALUY_MAX_TOKENS,t.limits?.maxTokens)}:{maxIterations:1e4,maxToolCalls:1e4*2},et=MD(t.maxOutputTokens,e.ALUY_MAX_OUTPUT_TOKENS,t.limits?.maxOutputTokens,t.onConfigWarn),xo=kk({flag:t.selfCheck,env:e.ALUY_SELF_CHECK,tier:P,everyKEnv:e.ALUY_SELF_CHECK_EVERY,maxVerificationsEnv:e.ALUY_SELF_CHECK_MAX,...t.advanced?.selfCheck?.everyK!==void 0?{everyKConfig:t.advanced.selfCheck.everyK}:{},...t.advanced?.selfCheck?.maxVerifications!==void 0?{maxVerificationsConfig:t.advanced.selfCheck.maxVerifications}:{}}),So={cwd:p.cwd,tier:P,...ce!==void 0?{model:ce}:{},...t.effectiveBackend!==void 0?{backend:t.effectiveBackend}:{},...t.provider!==void 0?{provider:t.provider}:{},tokens:0,windowPct:0},De=null,vt=new Eu,At=Vn({ollama:e.ALUY_MAESTRO_OLLAMA!=="0",mem0:e.ALUY_MAESTRO_MEM0!=="0"}),j=!1,K=!1,ye=new Gh({client:i,tier:P,...t.headroomUrl!==void 0?{headroomUrl:t.headroomUrl}:{},onHeadroomUsed:re=>vt.record("headroom",re),...ce!==void 0?{model:ce}:{},...me!==void 0?{provider:me}:{},...Ie!==void 0?{effort:Ie}:{},...et!==void 0?{maxTokens:et}:{},sink:{onStart:()=>De?.sink.onStart?.(),onDelta:re=>De?.sink.onDelta(re),onUsage:re=>De?.sink.onUsage?.(re),onQuota:re=>De?.sink.onQuota?.(re),onDone:()=>De?.sink.onDone?.()}}),Ce=new nn({client:i,tier:P,tierSource:ye,maxTokens:gg}),rt=new nn({client:i,tier:P,tierSource:ye,maxTokens:2048}),_e=t.subAgents?.enabled?new nn({client:i,tier:P,tierSource:ye,...et!==void 0?{maxTokens:et}:{}}):void 0,Y=new Map,le,Me=t.subAgents?.enabled?re=>{let Ne=Y.get(re);if(Ne)return Ne;let st=new nn({client:i,tier:re,...et!==void 0?{maxTokens:et}:{}});return le&&st.attachNativeTools(le),Y.set(re,st),st}:void 0,wo=new Map,No="__ALUY_INHERIT_PARENT__",Bn=t.subAgents?.enabled?re=>{let Ne=re??No,st=wo.get(Ne);if(st)return st;let Un=re!==void 0?{tier:"custom",model:re,get provider(){return ye.provider}}:{tier:"custom",get model(){return ye.model},get provider(){return ye.provider}},dr=new nn({client:i,tier:"custom",tierSource:Un,...et!==void 0?{maxTokens:et}:{}});return le&&dr.attachNativeTools(le),wo.set(Ne,dr),dr}:void 0,Ct=t.subAgents?.enabled?{availableNames:async()=>(await a.list()).map(re=>re.key)}:void 0,zt=sS(e.ALUY_ROOM_BACKEND,t.roomsBackend);zt.warning&&t.onConfigWarn&&t.onConfigWarn(zt.warning);let gn=(()=>{switch(zt.backend){case"memory":return new Qr;case"file":return new gy;case"loopback":case"broker":throw new Error(`Room backend "${zt.backend}" n\xE3o implementado ainda. Use "memory" ou "file", ou deixe o default.`);default:return new Qr}})(),Zo=new fy({model:ye,compactionModel:Ce,sideQueryModel:rt,permission:Ae,roomStore:gn,ports:J,askResolver:ne,agentMemory:W,commandWorkspace:p,login:r,questionResolver:X,...pe?{preToolGate:pe}:{},...Ut(ue,"user-prompt-submit").length>0?{onUserPromptSubmit:()=>{ie.runAll(Ut(ue,"user-prompt-submit"))}}:{},meta:So,limits:Ze,...xo.enabled?{selfCheck:xo}:{},...t.autoCompactAt!==void 0?{autoCompactAt:t.autoCompactAt}:{},...t.context?{contextConfig:t.context}:{},...t.cycleConfig?{cycleConfig:t.cycleConfig}:{},contextWindow:Oe,...t.providerWindows!==void 0?{providerWindows:t.providerWindows}:{},...t.activeProviderId!==void 0?{activeProviderId:t.activeProviderId}:{},...t.projectInstructions!==void 0?{projectInstructions:t.projectInstructions}:{},...t.availableAgents!==void 0?{availableAgents:t.availableAgents}:{},...t.sessionCommands!==void 0?{sessionCommands:t.sessionCommands}:{},...t.mcpTools!==void 0?{mcpTools:t.mcpTools}:{},...t.pendingMcpServers!==void 0?{pendingMcpServers:t.pendingMcpServers}:{},...t.headroomUrl!==void 0?{headroomRetrieveTool:TN({baseUrl:t.headroomUrl,onUsed:re=>vt.record("headroom",re)})}:{},...t.subAgents?.enabled?{subAgents:{...t.subAgents,env:t.subAgents.env??e,...t.subagentsConfig?{configDefaults:{...t.subagentsConfig.maxPerCall!==void 0?{maxPerCall:t.subagentsConfig.maxPerCall}:{},...t.subagentsConfig.maxConcurrency!==void 0?{maxConcurrency:t.subagentsConfig.maxConcurrency}:{},...t.subagentsConfig.idleTimeoutMs!==void 0?{idleTimeoutMs:t.subagentsConfig.idleTimeoutMs}:{}}}:{},...Ut(ue,"subagent-stop").length>0?{observer:{onChildEnd:()=>{ie.runAll(Ut(ue,"subagent-stop"))}}}:{}}}:{},...t.subAgents?.enabled&&t.agentRegistry?{agentRegistry:t.agentRegistry}:{},...t.skills&&t.skills.length>0?{skills:t.skills}:{},...t.subAgents?.enabled&&t.reloadProjectAgents?{reloadProjectAgents:t.reloadProjectAgents}:{},..._e?{subAgentModel:_e}:{},...Me?{callerForTier:Me}:{},...Bn?{customCallerFor:Bn}:{},...t.callerForLocalModel?{callerForLocalModel:t.callerForLocalModel}:{},...t.localModelCatalog?{localModelCatalog:t.localModelCatalog}:{},...t.verifyAndRegisterLocalModel?{verifyAndRegisterLocalModel:t.verifyAndRegisterLocalModel}:{},...Ct?{modelProbe:Ct}:{},...t.subAgents?.defaultModel!==void 0?{defaultChildModel:t.subAgents.defaultModel}:{},disableNativeTools:e.ALUY_NATIVE_TOOLS_OFF==="1"||e.ALUY_NATIVE_TOOLS_OFF==="true",watchdogEnv:e,quotaFetcher:()=>d.fetchQuota(),...t.memoryMonitor!==void 0?{memory:{heapLimitMb:t.memoryMonitor.heapLimitMb,sampleHeapUsed:t.memoryMonitor.sampleHeapUsed,env:e,...t.memoryMonitor.sampleIntervalMs!==void 0?{sampleIntervalMs:t.memoryMonitor.sampleIntervalMs}:{},...t.advanced?.memPressure?.compactAt!==void 0?{pressureAtConfig:t.advanced.memPressure.compactAt}:{}}}:{},onUserPrompt:(re,Ne)=>{w.markPrompt(re,Ne)},...(()=>{let re=hh({env:e,usage:vt,...t.services?{services:t.services}:{}});if(j=re!==void 0&&At.has("ollama"),!re)return{};let Ne=iN(e);return Ne?{maestro:re,continuationConfig:Ne}:{maestro:re}})(),...(()=>{let re=sN({env:e,usage:vt,...t.services?{services:t.services}:{}});return K=re!==void 0,re?{memoryEngine:re.memory,memoryScope:re.memoryScope,memoryRecallScopes:re.memoryRecallScopes}:{}})(),onToolsReady:re=>{ye.attachNativeTools(re),_e?.attachNativeTools(re),le=re;for(let Ne of Y.values())Ne.attachNativeTools(re);for(let Ne of wo.values())Ne.attachNativeTools(re)}});return De=Zo,Zo.armSidecarUsage({profile:t.profile??"turbo",enabled:{headroom:t.headroomUrl!==void 0,ollama:j,mem0:K}},vt),{controller:Zo,login:r,engine:Ae,egress:E,workspace:p,askResolver:ne,questionResolver:X,journal:y,journalStore:b,checkpoints:w,fileIndex:M,attachReader:H,catalogClient:a,customModelClient:l,providersClient:c,quotaClient:d,ports:J,memory:W,todoStore:$,hookRunner:ie,hooksConfig:ue}}var On,pZ,Rm=g(()=>{"use strict";N();Ks();oa();DN();Tr();aE();ec();wm();BF();UF();qF();SA();ec();m1();p1();N();as();Qw();N();On="aluy-flux",pZ=12e4});var b1={};xt(b1,{runDoctor:()=>gZ});async function gZ(t={}){let e=t.io??jt(),o=t.env??process.env,n=t.json===!0,r=t.probe??hZ(o,t.deep===!0),s=r.tierTester!==void 0;if(!n){e.out("aluy doctor \u2014 diagn\xF3stico"),e.out("");for(let p of vh(s))e.out(`\u25F7 ${p.label}: testando\u2026`);let c={...r,onCheck:(p,h)=>{let b=kh(p,h);if(!b)return;let y=b.status==="ok"?Zu.ok:b.status==="warn"?Zu.warn:Zu.fail;e.out(`${y} ${b.label}: ${b.detail}`),b.status!=="ok"&&b.fix!==void 0&&e.out(` \u2192 ${b.fix}`)}},d=await Xu(c),m=Qu(d),u=AN(m,Zu);return e.out(""),e.out(u[u.length-1]??""),tE(m)?1:0}let i=await Xu(r),a=Qu(i),l=a.checks.map(c=>({id:c.id,status:c.status,label:c.label,detail:c.detail}));return e.out(JSON.stringify(l)),tE(a)?1:0}function hZ(t,e){return{env:t,getAccessToken:()=>yZ(t),memory:vZ(),makeMcpTransport:()=>new is({cwd:process.cwd(),parentEnv:t}),...e?{tierTester:()=>wh({tier:bZ(),login:y1(t),env:t})}:{}}}function y1(t){let e=zo(t),o=new mo;return new co({...e,baseUrl:e.identityBaseUrl,store:o})}function yZ(t){return y1(t).getAccessToken()}function bZ(){try{let t=new Ge({}).load();return Iu(void 0,t,On)}catch{return On}}function vZ(){return{async count(){try{let t=new fo({}),e=new ss({workspace:t});return(await new Ki({store:e}).list()).length}catch{return null}}}}var v1=g(()=>{"use strict";N();Ar();Ks();Tr();Wl();Iw();Gl();eE();Sh();CN();oE();_o();Rm()});function AA(t,e){return e!==void 0&&e.trim()!==""?!0:t.some(o=>o.kind==="you"||o.kind==="aluy")}function k1(t,e){if(!AA(e.blocks,e.label))return!1;try{return t.save(e)}catch{return!1}}function kZ(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 xZ(t){let e=Math.max(0,Math.floor(t/1e3));if(e<60)return"h\xE1 instantes";let o=Math.floor(e/60);if(o<60)return`h\xE1 ${o} min`;let n=Math.floor(o/60);return n<24?`h\xE1 ${n} h`:`h\xE1 ${Math.floor(n/24)} d`}function x1(t,e){return`\u21BB retomar a conversa anterior (${t} ${t===1?"mensagem":"mensagens"}, ${xZ(e)})? [S/n] `}function S1(t){if(t.length===0)return["nenhuma sess\xE3o salva ainda."];let e=["sess\xF5es salvas (retome com: aluy --resume <id>):",""];for(let o of t){let n=o.title??"(sem objetivo)";e.push(` ${o.id}`),e.push(` ${kZ(o.updatedAt)} \xB7 ${o.cwd} \xB7 ${o.blockCount} blocos`),e.push(` ${n}`)}return e}var CA=g(()=>{"use strict"});function Om(t,e=w1){let o=t.tier.trim();if(o!=="custom")return{tier:o};let n=t.model?.trim();if(n!==void 0&&n!==""){let r=t.provider?.trim();return{tier:"custom",model:n,...r!==void 0&&r!==""?{provider:r}:{}}}return{tier:e,warning:`sess\xE3o Custom anterior sem o modelo salvo \u2014 retomada no tier ${e}. Use /model p/ reescolher o modelo Custom.`}}function E1(t,e=w1){return Om({tier:t.tier??"",...t.model!==void 0?{model:t.model}:{},...t.provider!==void 0?{provider:t.provider}:{}},e)}function SZ(t,e,o){if(t===void 0)return{kind:"none"};if(t.kind==="continue"){let r=e.latestForCwd(o);if(r&&C1(r.blocks)>0)return{kind:"resumed",record:r};for(let s of e.list()){if(s.cwd!==o||s.title===void 0)continue;let i=e.load(s.id);if(i)return{kind:"resumed",record:i}}return{kind:"none"}}if(t.id!==void 0&&t.id.trim()!==""){let r=t.id.trim(),s=e.load(r);if(s)return{kind:"resumed",record:s};let i=r.toLowerCase(),a=e.list().filter(l=>(l.label??"").trim().toLowerCase()===i);if(a.length===1){let l=e.load(a[0].id);if(l)return{kind:"resumed",record:l}}return a.length>1?{kind:"pick",choices:a}:{kind:"not-found",requestedId:r}}let n=e.list().filter(r=>r.title!==void 0||r.label!==void 0);return n.length>0?{kind:"pick",choices:n}:{kind:"none"}}function A1(t){return t!==void 0&&Number.isFinite(t)&&t>0?Math.min(wZ,Math.floor(t)):Mm}function EZ(t){let e=0;for(let o of t)(o.kind==="you"||o.kind==="aluy")&&(e+=1);return e}function C1(t){let e=0;for(let o of t)o.kind==="you"&&(e+=1);return e}function AZ(t,e,o,n,r=Date.now(),s=Mm){if(t!==void 0||e)return{kind:"explicit"};let i=o.latestForCwd(n);if(!i)return{kind:"none"};let a=Math.max(0,r-i.updatedAt);if(a>s)return{kind:"none"};let l=EZ(i.blocks);return l===0?{kind:"none"}:C1(i.blocks)===0?{kind:"none"}:{kind:"offer",record:i,ageMs:a,messageCount:l}}async function T1(t){let e=SZ(t.request,t.store,t.cwd);if(e.kind!=="none"||!t.isTty)return e;let o=AZ(t.request,t.fresh,t.store,t.cwd,t.now??Date.now(),t.windowMs??Mm);if(o.kind!=="offer")return{kind:"none"};let n=!1;try{n=await t.promptYesNo(x1(o.messageCount,o.ageMs))}catch{n=!1}return n?{kind:"resumed",record:o.record}:{kind:"none"}}var w1,Mm,wZ,TA=g(()=>{"use strict";CA();w1="aluy-flux";Mm=1440*60*1e3,wZ=10080*60*1e3});function CZ(t){return(t.entries.find(o=>o.wave===1)??t.entries[0])?.id??"anthropic"}function hy(t){return Kr({flag:t.flag,env:t.env.ALUY_BACKEND,config:t.config.backend})}function DA(t,e){return t==null?void 0:Yt(e,t)?.id}function _A(t){if(t==null)return;let e=t.trim().toLowerCase();if(e==="apikey"||e==="oauth"||e==="none")return e}function TZ(t,e){let o=Yt(e,t)?.auth;return o!==void 0&&o.length>0&&o.every(n=>n==="none")?"none":"apikey"}function dc(t){if(t==null)return;let e=t.trim();return e!==""?e:void 0}function uc(t){let e=t.flags??{},o=t.catalog??vr(),n=DA(e.localProvider,o)??DA(t.env.ALUY_LOCAL_PROVIDER,o)??DA(t.config.localProvider,o)??CZ(o),r=Yt(o,n)?.defaultModel??n,s=dc(e.localModel)??dc(t.env.ALUY_LOCAL_MODEL)??dc(t.config.localModel)??r,i=_A(e.localAuth)??_A(t.env.ALUY_LOCAL_AUTH)??_A(t.config.localAuth)??TZ(n,o),a=dc(e.localBaseUrl)??dc(t.env.ALUY_LOCAL_BASE_URL)??dc(t.config.localBaseUrl);return{provider:n,model:s,auth:i,...a!==void 0?{baseUrl:a}:{}}}var yy=g(()=>{"use strict";N()});var _1={};xt(_1,{collectSettings:()=>D1,runConfig:()=>PZ});import{existsSync as RZ}from"node:fs";import{homedir as OZ}from"node:os";import{join as by}from"node:path";function Vo(t,e,o,n,r,s){let i=o?.trim();return i!==void 0&&i!==""?{key:t,value:i,origin:"env",source:e}:n!=null?{key:t,value:String(n),origin:"config.json",source:s??`config.${t}`}:{key:t,value:r,origin:"default",source:"\u2014"}}function Mn(t,e,o){return e!=null?{key:t,value:String(e),origin:"config.json",source:`config.${t}`}:{key:t,value:o,origin:"default",source:"\u2014"}}function D1(t,e){let o=uc({env:{},config:{}}),n=o.baseUrl??"\u2014";return[Vo("backend","ALUY_BACKEND",t.ALUY_BACKEND,e.backend,hy({env:{},config:{}})),Vo("localProvider","ALUY_LOCAL_PROVIDER",t.ALUY_LOCAL_PROVIDER,e.localProvider,o.provider),Vo("localModel","ALUY_LOCAL_MODEL",t.ALUY_LOCAL_MODEL,e.localModel,o.model),Vo("localAuth","ALUY_LOCAL_AUTH",t.ALUY_LOCAL_AUTH,e.localAuth,o.auth),Vo("localBaseUrl","ALUY_LOCAL_BASE_URL",t.ALUY_LOCAL_BASE_URL,e.localBaseUrl,n),Mn("profile",e.profile,"turbo"),Mn("sidecar.ollama",e.sidecarToggles?.ollama,"on (default)"),Mn("sidecar.mem0",e.sidecarToggles?.mem0,"on (default)"),Mn("sidecar.headroom",e.sidecarToggles?.headroom,"on (default)"),Mn("lang",e.lang,"auto"),Mn("theme",e.theme,"default"),Vo("maxTokens","ALUY_MAX_TOKENS",t.ALUY_MAX_TOKENS,e.limits?.maxTokens,String(1e7),"config.limits.maxTokens"),Vo("maxOutputTokens","ALUY_MAX_OUTPUT_TOKENS",t.ALUY_MAX_OUTPUT_TOKENS,e.limits?.maxOutputTokens,"\u2014 (do servidor/tier)","config.limits.maxOutputTokens"),Vo("maxIterations","ALUY_MAX_ITERATIONS",t.ALUY_MAX_ITERATIONS,e.limits?.maxIterations,String(300),"config.limits.maxIterations"),Vo("limits.maxMemoryWritesPerSession","ALUY_MAX_MEMORY_WRITES_PER_SESSION",t.ALUY_MAX_MEMORY_WRITES_PER_SESSION,e.limits?.maxMemoryWritesPerSession,String(Jc),"config.limits.maxMemoryWritesPerSession"),Vo("subagents.maxPerCall","ALUY_SUBAGENT_MAX_PER_CALL",t.ALUY_SUBAGENT_MAX_PER_CALL,e.subagents?.maxPerCall,String(Ms),"config.subagents.maxPerCall"),Vo("subagents.maxConcurrency","ALUY_SUBAGENT_MAX_CONCURRENCY",t.ALUY_SUBAGENT_MAX_CONCURRENCY,e.subagents?.maxConcurrency,String(Zp),"config.subagents.maxConcurrency"),Vo("subagents.idleTimeoutMs","ALUY_SUBAGENT_IDLE_TIMEOUT",t.ALUY_SUBAGENT_IDLE_TIMEOUT,e.subagents?.idleTimeoutMs,String(eg),"config.subagents.idleTimeoutMs"),Mn("cycle.defaultDurationMs",e.cycle?.defaultDurationMs,String(Is)),Mn("cycle.defaultIterations",e.cycle?.defaultIterations,String(Ns)),Mn("cycle.defaultIntervalMs",e.cycle?.defaultIntervalMs,String(du)),Vo("mcp.connectTimeoutMs","ALUY_MCP_CONNECT_TIMEOUT_MS",t.ALUY_MCP_CONNECT_TIMEOUT_MS,e.mcp?.connectTimeoutMs,String($w),"config.mcp.connectTimeoutMs"),Vo("mcp.callTimeoutMs","ALUY_MCP_TIMEOUT_MS",t.ALUY_MCP_TIMEOUT_MS,e.mcp?.callTimeoutMs,String(Nw),"config.mcp.callTimeoutMs"),Mn("session.gcMaxAgeMs",e.session?.gcMaxAgeMs,String($h)),Mn("session.gcMaxCount",e.session?.gcMaxCount,String(Bh)),Mn("session.autoResumeWindowMs",e.session?.autoResumeWindowMs,String(Mm))]}function MZ(t){let e=(o,n)=>{let r=by(t,o);return{path:r,role:n,exists:RZ(r)}};return[e("config.json","configura\xE7\xE3o dur\xE1vel (este comando)"),e("mcp.json","servers MCP (interop; sem credencial \u2014 CLI-SEC-7)"),e("hooks.json","hooks (fronteira de execu\xE7\xE3o; o agente nunca escreve)"),e("providers.json","cat\xE1logo de providers (override do usu\xE1rio)"),e("update-check.json","estado/cache (reescrito pela m\xE1quina)"),e("sessions","hist\xF3rico das sess\xF5es/conversas (retom\xE1vel com --resume)"),e("audit.jsonl","trilha de auditoria dos efeitos (append-only \u2014 CLI-SEC)"),e("cron","tarefas agendadas (aluy cron)"),e("exports","transcri\xE7\xF5es exportadas (/export)"),e("undo","pilha de undo das edi\xE7\xF5es do agente"),e("memory","store do mem0 (chromadb + history)"),e("logs","logs dos sidecars (mem0/ollama/headroom)")]}function PZ(t={}){let e=t.io??jt(),o=t.env??process.env,n=t.baseDir??by(OZ(),".aluy"),s=(t.configStore??new Ge({baseDir:n})).load(),i=D1(o,s),a=MZ(n);if(t.json===!0)return e.out(JSON.stringify({configPath:by(n,"config.json"),settings:i.map(d=>({key:d.key,value:d.value,origin:d.origin,source:d.source})),files:a.map(d=>({path:d.path,role:d.role,exists:d.exists}))},null,2)),0;e.out("aluy config \u2014 configura\xE7\xE3o efetiva (read-only)"),e.out(` arquivo dur\xE1vel: ${by(n,"config.json")}`),e.out(" preced\xEAncia: flag > env (ALUY_*) > config.json > default"),e.out("");let l=Math.max(...i.map(d=>d.key.length),3),c=Math.max(...i.map(d=>d.value.length),5);for(let d of i){let m=LZ[d.origin],u=d.origin==="default"?"":` (${d.source})`;e.out(` ${d.key.padEnd(l)} ${d.value.padEnd(c)} [${m}]${u}`)}e.out(""),e.out(" outros arquivos (fora do config.json de prop\xF3sito \u2014 segredo/interop/execu\xE7\xE3o):");for(let d of a){let m=d.exists?"\xB7":"\u25CB";e.out(` ${m} ${d.path} \u2014 ${d.role}`)}return e.out(""),e.out(" segredos (chave de API/token) ficam no keychain do SO, NUNCA no config.json."),0}var LZ,R1=g(()=>{"use strict";N();Ar();_o();DE();TA();yy();Gl();LZ={env:"env","config.json":"config",default:"default"}});var M1={};xt(M1,{defaultUserAgentsDir:()=>$Z,runAgents:()=>FZ});import{homedir as IZ}from"node:os";import{join as O1}from"node:path";function NZ(){return O1("~",".aluy",Ku)}function FZ(t={}){let e=t.out??(a=>process.stdout.write(a+`
594
594
  `)),o=t.loadGlobal??(()=>new cs().load()),n=t.loadProject??(()=>new la({workspace:new fo}).load()),r=o(),s=n(),i=Hi({profiles:[...r.profiles,...s.profiles],errors:[...r.errors,...s.errors],globalDir:t.globalDir??NZ()});e(i.title==="agents"?"aluy agents \u2014 perfis .md mapeados":i.title);for(let a of i.lines)e(a);return 0}function $Z(){return O1(IZ(),".aluy",Ku)}var L1=g(()=>{"use strict";N();fh();OE();Wl()});var I1={};xt(I1,{defaultUserSkillsDir:()=>HZ,runSkills:()=>jZ});import{homedir as BZ}from"node:os";import{join as P1}from"node:path";function UZ(){return P1("~",".aluy",bm)}function jZ(t={}){let e=t.out??(a=>process.stdout.write(a+`
595
595
  `)),o=t.loadGlobal??(()=>new Qn().load()),n=t.loadProject??(()=>new Zn({workspace:new fo}).load()),r=o(),s=n(),i=qi({skills:[...r.skills,...s.skills],errors:[...r.errors,...s.errors],globalDir:t.globalDir??UZ()});e("aluy skills \u2014 capacidades SKILL.md mapeadas");for(let a of i.lines)e(a);return 0}function HZ(){return P1(BZ(),".aluy",bm)}var N1=g(()=>{"use strict";N();Uh();FE();Wl()});var $1={};xt($1,{defaultUserWorkflowsDir:()=>zZ,runWorkflows:()=>GZ});import{homedir as qZ}from"node:os";import{join as F1}from"node:path";function WZ(){return F1("~",".aluy",Zl)}function GZ(t={}){let e=t.out??(a=>process.stdout.write(a+`
596
596
  `)),o=t.loadGlobal??(()=>new Cn().load()),n=t.loadProject??(()=>new Tn({workspace:new fo}).load()),r=o(),s=n(),i=Wi({workflows:[...r.workflows,...s.workflows],errors:[...r.errors,...s.errors],globalDir:t.globalDir??WZ(),projectDir:t.projectDir??".claude/workflows"});e("workflows \u2014 fluxos .md mapeados");for(let a of i.lines)e(a);return 0}function zZ(){return F1(qZ(),".aluy",Zl)}var B1=g(()=>{"use strict";N();hm();ym();Wl()});var H1={};xt(H1,{probeModelReachable:()=>U1,runFirstRunWizard:()=>j1,runInit:()=>VZ});import{Entry as KZ}from"@napi-rs/keyring";async function U1(t){let{config:e,env:o}=t,n=uc({env:o,config:e}),r=Yt(vr(),n.provider)?.baseUrl,s=n.baseUrl??r;if(s===void 0||s==="")return!0;let i=t.fetchImpl??globalThis.fetch,a=t.timeoutMs??4e3,l=new AbortController,c=setTimeout(()=>l.abort(),a);try{return await i(`${s.replace(/\/+$/,"")}/models`,{signal:l.signal}),!0}catch{return!1}finally{clearTimeout(c)}}async function j1(t){let{config:e,configStore:o,prompt:n,out:r,err:s,entryFactory:i,isInteractive:a}=t,l=e.localProvider!==void 0,c=e.localModel!==void 0,d=!1,m=e.localProvider;if(m)try{let p=(i??YZ)(Cr,eh(m)).getPassword();d=p!==""&&p!==void 0}catch{}if(l&&c&&d)return!0;if(!a)return s("aluy bootstrap: configura\xE7\xE3o de 1\xAA execu\xE7\xE3o necess\xE1ria (provider + chave + modelo)."),l||s(" \u2717 Falta provider local em ~/.aluy/config.json."),c||s(" \u2717 Falta modelo local em ~/.aluy/config.json."),d||s(" \u2717 Falta chave de API no keychain do SO."),s(""),s(" Rode `aluy bootstrap` interativamente (num terminal com TTY) para o wizard,"),s(" ou configure manualmente:"),s(" 1. `aluy login --provider <anthropic|openrouter|openai>` (grava a chave no keychain)"),s(" 2. Edite ~/.aluy/config.json e adicione:"),s(' "localProvider": "<provider>",'),s(' "localModel": "<modelo-nativo>"'),s(""),!1;if(r(""),r("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"),r("\u2551 Configura\xE7\xE3o de 1\xAA execu\xE7\xE3o \u2014 provider + chave + modelo \u2551"),r("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"),r(""),r("O `aluy bootstrap --agent` usa um modelo de linguagem para instalar"),r("depend\xEAncias. Precisamos de provider, chave de API e modelo."),r("(As credenciais ficam no keychain do SO \u2014 nunca em texto.)"),r(""),l)r(`Provider: ${m} (j\xE1 configurado)`);else{let u=(await n(`Provider (${RA.join("/")}): `)).trim().toLowerCase();if(!RA.includes(u))return s(`Provider inv\xE1lido "${u}". Use: ${RA.join(", ")}.`),!1;m=u,r("")}if(d)r("\u2713 Chave j\xE1 est\xE1 no keychain.");else{let u=m,p=(await n(`API key de ${u}: `,{secret:!0})).trim();if(p==="")return s("Chave vazia \u2014 abortando."),!1;try{if(Hl(u,p,i),r("\u2713 Chave guardada no keychain do SO."),nh({service:Cr}))for(let h of rh($u(u)))s(h)}catch(h){return s(`Falha ao gravar no keychain: ${h instanceof Error?h.message:String(h)}`),s("(Por seguran\xE7a, a credencial nunca \xE9 gravada em texto. Instale o Secret Service no Linux.)"),!1}r("")}if(!c){let u=m,p=(await n("Modelo nativo (ex.: claude-sonnet-4-8): ")).trim();if(p==="")return s("Modelo vazio \u2014 abortando."),!1;o.save({localProvider:u,localModel:p}),r(`\u2713 Provider "${u}" + modelo "${p}" salvos em ~/.aluy/config.json.`),r("")}return r("Configura\xE7\xE3o conclu\xEDda. Seguindo para o provisionamento\u2026"),r(""),!0}function YZ(t,e){return new KZ(t,e)}async function VZ(t){let{out:e,err:o}=t,n=t.configStore??new Ge,r,s,i;try{i=n.load(),r=i.profile,s=i.sidecarToggles}catch{i={}}let a=t.isInteractive!==void 0?t.isInteractive:process.stdin.isTTY===!0&&process.stdout.isTTY===!0;if(t.prompt!==void 0||!a){let d=t.prompt??(async()=>"");if(!await j1({config:i,configStore:n,prompt:d,out:e,err:o,...t.entryFactory!==void 0?{entryFactory:t.entryFactory}:{},isInteractive:a}))return 0}if(e("O Aluy CLI j\xE1 est\xE1 instalado e pronto para uso."),e(""),e("Esta etapa instala os COMPLEMENTOS opcionais (modo turbo): mem\xF3ria, modelos"),e("locais e gest\xE3o de contexto. Eles enriquecem a experi\xEAncia, mas n\xE3o s\xE3o"),e("obrigat\xF3rios \u2014 se algum n\xE3o instalar, voc\xEA usa o Aluy CLI normalmente sem ele."),e(""),e(` Perfil escolhido: ${r??"turbo"}`),r==="leve")return e(" Perfil LEVE: nenhum complemento ser\xE1 instalado \u2014 o Aluy CLI j\xE1 est\xE1 pronto."),e(" Para instal\xE1-los depois, rode `aluy bootstrap` ou troque para o perfil turbo."),0;let l=t.agent!==!1;l&&(await(t.modelProbe??((u,p)=>U1({config:u,env:p})))(i,t.env??process.env)||(e(" \u26A0 O modelo local n\xE3o respondeu \u2014 o instalador via agente precisa dele para rodar."),e(" Caindo no caminho DIRETO (--no-agent), que provisiona sem usar modelo."),e(""),l=!1)),l?(e(" Instalando os complementos com o pr\xF3prio aluy \u2014 ele detecta o sistema, instala o que"),e(" faltar (Python, pip, etc.) e os complementos. \u26A0 Acesso total \xE0 m\xE1quina (com sudo quando"),e(" preciso). Voc\xEA ver\xE1 o progresso de cada um abaixo.")):e(" Instalando os complementos pelo caminho direto (--no-agent; requer Python j\xE1 pronto)..."),e(""),process.env.ALUY_MEM0_EMBEDDER=zg(i);let c=await UP(r,s,{useAgent:l});for(let d of c.targets){let m=d.installed?"\u2713":"\u2717";e(` ${m} ${d.target}: ${d.message}`)}return e(""),c.anySuccess?(e("Complementos instalados. O Aluy CLI est\xE1 pronto, agora com o modo turbo."),c.allFailed&&e("Observa\xE7\xE3o: alguns complementos n\xE3o instalaram \u2014 o Aluy CLI funciona sem eles."),0):c.targets.length===0?(e("Nenhum complemento a instalar \u2014 o Aluy CLI j\xE1 est\xE1 pronto."),0):(o("Nenhum complemento foi instalado agora \u2014 sem problema, o Aluy CLI funciona"),o("normalmente. Voc\xEA pode tentar de novo depois com `aluy bootstrap`."),1)}var RA,q1=g(()=>{"use strict";_o();vw();ta();ww();yy();N();RA=["anthropic","openrouter","openai"]});var W1={};xt(W1,{runUninstall:()=>tee});import{homedir as XZ}from"node:os";import{join as vy}from"node:path";import{rmSync as JZ,existsSync as QZ}from"node:fs";import{spawnSync as ZZ}from"node:child_process";function eee(t){return[{label:"ollama (instala\xE7\xE3o local em ~/.aluy)",path:vy(t,$s)},{label:"mem0 (venv)",path:vy(t,es)},{label:"headroom (venv)",path:vy(t,Bs)}]}function tee(t={},e={}){let o=e.io??jt(),n=e.baseDir??vy(XZ(),".aluy"),r=e.remove??(i=>JZ(i,{recursive:!0,force:!0})),s=e.exists??QZ;o.out("Removendo os complementos gerenciados pelo aluy (em ~/.aluy/)\u2026");for(let i of eee(n)){if(!s(i.path)){o.out(` \xB7 ${i.label}: n\xE3o estava instalado`);continue}try{r(i.path),o.out(` \u2713 ${i.label}: removido`)}catch{o.err(` \u2717 ${i.label}: falha ao remover (${i.path})`)}}return o.out(""),t.agent?nee(o):(o.out("Se o Ollama foi instalado no SISTEMA (via curl/winget), ele N\xC3O fica em ~/.aluy e"),o.out("continua instalado. Para remov\xEA-lo tamb\xE9m: `aluy uninstall --agent` (o aluy remove"),o.out("via o pr\xF3prio agente \u2014 \u26A0 acesso total + sudo). O CLI em si sai com `npm uninstall -g"),o.out("@hiperplano/aluy-cli`; sua config (~/.aluy/config.json) e credenciais N\xC3O s\xE3o tocadas."),0)}function oee(){return"DESINSTALE o Ollama instalado no SISTEMA (fora de ~/.aluy), detectando o SO. No Linux: pare/desabilite o servi\xE7o (`sudo systemctl stop ollama; sudo systemctl disable ollama` se existir), remova o bin\xE1rio (`sudo rm -f /usr/local/bin/ollama` ou onde estiver no PATH) e o usu\xE1rio/servi\xE7o se o install oficial criou. No macOS: encerre o app/servi\xE7o e remova-o. No Windows: `winget uninstall --id Ollama.Ollama`. Pacotes de sistema exigem privil\xE9gio: tente `sudo -n true`; se pedir senha, PE\xC7A ao usu\xE1rio. Opcional: remova os modelos baixados (`~/.ollama/models`). Confirme que `ollama` n\xE3o responde mais em http://127.0.0.1:11434/api/tags. Seja conciso."}function nee(t){let e=process.argv[1];return e?(t.out(" \u2500\u2500 Removendo o Ollama de sistema com o pr\xF3prio aluy \u2500\u2500 (acompanhe abaixo)"),t.out(""),ZZ(process.execPath,[e,"-p",oee(),"--yolo","--no-self-check"],{stdio:"inherit",timeout:6e5,env:{...process.env,ALUY_NO_WEAK_YOLO_WARN:"1",ALUY_PRINT_VERBOSE:"1"}}),0):(t.err("n\xE3o foi poss\xEDvel localizar o bin\xE1rio do aluy p/ delegar ao agente."),0)}var G1=g(()=>{"use strict";N();Ar()});function see(t){let e=/^#?([0-9a-f]{6})$/i.exec(t.trim());return e?`\x1B]11;#${e[1].toUpperCase()}\x07`:""}function iee(t){if(t.NO_COLOR!==void 0)return!1;let e=t.ALUY_SET_BG;if(e===void 0)return!0;let o=e.trim().toLowerCase();return!(o==="0"||o==="false"||o==="no"||o==="off")}function lee(t){if(!t)return null;let e=/rgb:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})/i.exec(t);if(e)return{r:OA(e[1]),g:OA(e[2]),b:OA(e[3])};let o=/#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);return o?{r:parseInt(o[1],16),g:parseInt(o[2],16),b:parseInt(o[3],16)}:null}function OA(t){let e=parseInt(t,16),o=16**t.length-1;return Math.round(e/o*255)}function cee(t){let e=o=>{let n=o/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*e(t.r)+.7152*e(t.g)+.0722*e(t.b)}function dee(t){return cee(t)>=aee?"light":"dark"}function uee(t){let e=lee(t);return e?dee(e):null}function mee(t=process.env){let e=t.ALUY_OSC11_TIMEOUT_MS;if(e!==void 0){let n=Number.parseInt(e,10);if(Number.isFinite(n)&&n>0)return Math.min(n,5e3)}return!!(t.SSH_CONNECTION||t.SSH_TTY||t.SSH_CLIENT)?1e3:500}async function K1(t){let e=t.env??process.env;if(e.NO_COLOR!==void 0||t.stdout.isTTY!==!0||t.stdin.isTTY!==!0)return null;let o=t.timeoutMs??mee(e),n=t.stdin,r=n.isRaw===!0;return await new Promise(s=>{let i="",a=!1,l={},c=()=>{l.id&&clearTimeout(l.id),n.off("data",m);try{r||n.setRawMode(!1),n.pause()}catch{}},d=u=>{a||(a=!0,c(),s(u))},m=u=>{i+=typeof u=="string"?u:u.toString("utf8");let p=uee(i);p!==null&&d(p)};try{n.setRawMode(!0),n.resume(),n.on("data",m),t.stdout.write(ree)}catch{d(null);return}l.id=setTimeout(()=>d(null),o)})}var ree,z1,ky,aee,Y1=g(()=>{"use strict";ree="\x1B]11;?\x07",z1="\x1B]111\x07";ky=class{stdout;enabled;applied=!1;didReset=!1;constructor(e){let o=e.env??process.env;this.stdout=e.stdout,this.enabled=e.stdout.isTTY===!0&&iee(o)}get active(){return this.enabled}apply(e){if(!this.enabled)return"";let o=see(e);return o===""?"":(this.stdout.write(o),this.applied=!0,this.didReset=!1,o)}reset(){return!this.enabled||!this.applied||this.didReset?"":(this.didReset=!0,this.stdout.write(z1),z1)}},aee=.5});import{createContext as fee,useContext as pee}from"react";import{Text as V1}from"ink";import{jsx as xy}from"react/jsx-runtime";function ga(t){return xy(X1.Provider,{value:t.theme,children:t.children})}function V(){return pee(X1)}function f(t){let o=V().role(t.name),n={};return o.color!==void 0&&(n.color=o.color),o.bold!==void 0&&(n.bold=o.bold),o.dimColor!==void 0&&(n.dimColor=o.dimColor),o.inverse!==void 0&&(n.inverse=o.inverse),xy(V1,{...n,children:t.children})}function B(t){let o=V().glyph(t.name);return t.role?xy(f,{name:t.role,children:o}):xy(V1,{children:o})}var X1,J1=g(()=>{"use strict";qg();X1=fee(xn())});var ee=g(()=>{"use strict";$g();Bg();qg();jg();Hs();Y1();J1()});import"react";import{Box as Sy}from"ink";import{jsx as mc,jsxs as Q1}from"react/jsx-runtime";function fs(t){let e=V(),n=(t.columns??80)<Pm,r=e.unicode?"\u039B":"/\\";if(n)return Q1(Sy,{children:[mc(f,{name:"accent",children:r}),mc(f,{name:"accent",children:" luy"})]});let s=e.unicode?fc:Z1,i=e.unicode?Lm:eB;return Q1(Sy,{flexDirection:"row",children:[mc(Sy,{flexDirection:"column",children:s.map((a,l)=>mc(f,{name:"accent",children:a},l))}),mc(Sy,{flexDirection:"column",children:i.map((a,l)=>mc(f,{name:"accent",children:gee+a},l))})]})}var fc,Lm,Z1,eB,gee,Pm,MA,ha=g(()=>{"use strict";ee();Bg();fc=[" \u2588\u2588 "," \u2588\u2588\u2588\u2588 "," \u2588\u2588\u2588 \u2588\u2588\u2588 "," \u2588\u2588\u2588 \u2588\u2588\u2588 ","\u2588\u2588\u2588 \u2588\u2588\u2588"," "],Lm=["\u2588\u2588 ","\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588","\u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588","\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588"," \u2588\u2588\u2588\u2588 "],Z1=[" /\\ "," / \\ "," / \\ "," / \\ ","/ \\"," "],eB=["## ","## ## ## ## ##","## ## ## ## ##","## ## ## #####","## ##### ##"," #### "],gee=" ",Pm=28,MA=fc.length});async function wy(t){let e=t.fetchImpl??fetch,o=t.baseUrl.replace(/\/+$/,""),n=new AbortController,r=setTimeout(()=>n.abort(),t.timeoutMs??15e3);try{let s=t.wireFormat==="anthropic"?await e(`${o}/v1/messages`,{method:"POST",signal:n.signal,headers:{"content-type":"application/json","x-api-key":t.key,"anthropic-version":"2023-06-01"},body:JSON.stringify({model:t.model,max_tokens:1,messages:[{role:"user",content:"ping"}]})}):await e(`${o}/chat/completions`,{method:"POST",signal:n.signal,headers:{"content-type":"application/json",authorization:`Bearer ${t.key}`},body:JSON.stringify({model:t.model,max_tokens:1,messages:[{role:"user",content:"ping"}]})});if(s.ok)return{ok:!0,detail:`HTTP ${s.status}`};let i="";try{i=(await s.text()).replace(/\s+/g," ").slice(0,160)}catch{}let a=s.status===401||s.status===403?" \u2014 chave inv\xE1lida?":s.status===404?" \u2014 modelo ou baseURL errado?":"";return{ok:!1,detail:`HTTP ${s.status}${a} ${i}`.trim()}}catch(s){return{ok:!1,detail:`n\xE3o conectou (baseURL/rede?): ${s instanceof Error?s.message:String(s)}`}}finally{clearTimeout(r)}}function tB(t,e){let o=/^HTTP (\d{3})\b/.exec(e);if(o!==null){let n=Number(o[1]),r=n===401||n===403?" \u2014 chave inv\xE1lida?":n===404?" \u2014 modelo ou baseURL errado?":"";return`modelo local "${t}" n\xE3o respondeu: HTTP ${o[1]}${r}`}return`modelo local "${t}" n\xE3o respondeu (rede/baseURL, ou egress bloqueado pelo anti-SSRF).`}var LA=g(()=>{"use strict"});import{mkdirSync as hee,readFileSync as yee,renameSync as bee,statSync as vee,writeFileSync as kee}from"node:fs";import{dirname as xee,join as See}from"node:path";function oB(t){let e={};for(let o of t.servers){let n={command:o.command,args:[...o.args]};Object.keys(o.env).length>0&&(n.env={...o.env}),o.disabled===!0&&(n.disabled=!0),e[o.name]=n}return JSON.stringify({mcpServers:e},null,2)+`
597
- `}var wee,eo,_r,Im=g(()=>{"use strict";N();wee=256*1024,eo=class extends Error{constructor(e){super(e),this.name="McpWriteError"}},_r=class{file;constructor(e){this.file=e.file}get configPath(){return this.file}load(){let e;try{let n=vee(this.file);if(!n.isFile())throw new eo(`${this.file}: n\xE3o \xE9 um arquivo regular.`);if(n.size>wee)throw new eo(`${this.file}: grande demais p/ editar com seguran\xE7a.`);e=yee(this.file,"utf8")}catch(n){if(n instanceof eo)throw n;return Pe}let o;try{o=JSON.parse(e)}catch{throw new eo(`${this.file}: JSON inv\xE1lido \u2014 conserte \xE0 m\xE3o antes de usar 'aluy mcp'.`)}try{return sn(o)}catch(n){let r=n instanceof be?n.message:String(n);throw new eo(r)}}add(e,o={}){if(!Ol(e.name))throw new eo(`nome de server inv\xE1lido "${e.name}" \u2014 use s\xF3 [A-Za-z0-9_-] (vira prefixo de tool).`);if(e.command.trim().length===0)throw new eo(`server "${e.name}": "command" n\xE3o pode ser vazio.`);if(e.command.trim()==="--")throw new eo(`server "${e.name}": "--" n\xE3o \xE9 um command (\xE9 o separador do 'aluy mcp add'). Use: aluy mcp add ${e.name} -- <command> [args...].`);let n=this.load(),r=n.servers.find(i=>i.name===e.name);if(r&&!o.force)throw new eo(`server "${e.name}" j\xE1 existe em ${this.file} \u2014 use --force p/ sobrescrever.`);let s=[...n.servers.filter(i=>i.name!==e.name),e];return this.write({servers:s}),{replaced:r!==void 0}}remove(e){let o=this.load(),n=o.servers.length,r=o.servers.filter(s=>s.name!==e);return r.length===n?{removed:!1}:(this.write({servers:r}),{removed:!0})}setDisabled(e,o){let n=this.load(),r=n.servers.find(i=>i.name===e);if(!r)return{found:!1};let s={name:r.name,command:r.command,args:r.args,env:r.env,...o?{disabled:!0}:{}};return this.write({servers:n.servers.map(i=>i.name===e?s:i)}),{found:!0}}write(e){let o=xee(this.file);hee(o,{recursive:!0});let n=oB(e),r=See(o,`.mcp.json.${process.pid}.${Date.now()}.tmp`);kee(r,n,{encoding:"utf8",mode:384}),bee(r,this.file)}}});var iB={};xt(iB,{mcpCatalog:()=>sB,runOnboard:()=>Oee});import{useEffect as Eee,useMemo as nB,useState as Oo}from"react";import{render as Aee,Box as ut,useApp as Cee,useInput as Tee}from"ink";import{homedir as rB}from"node:os";import{join as Dee}from"node:path";import{jsx as fe,jsxs as _t}from"react/jsx-runtime";function sB(){return[{id:"playwright",label:"Playwright",hintPt:"automa\xE7\xE3o de navegador (oficial)",hintEn:"browser automation (official)",command:"npx",args:["-y","@playwright/mcp@latest"]},{id:"sequential-thinking",label:"Sequential Thinking",hintPt:"racioc\xEDnio passo-a-passo",hintEn:"step-by-step reasoning",command:"npx",args:["-y","@modelcontextprotocol/server-sequential-thinking"]},{id:"memory",label:"Memory",hintPt:"grafo de conhecimento persistente",hintEn:"persistent knowledge graph",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]},{id:"filesystem",label:"Filesystem",hintPt:"arquivos (escopo: sua home)",hintEn:"files (scope: your home)",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem",rB()]},{id:"rpa",label:"RPA (Aluy)",hintPt:"automa\xE7\xE3o visual de desktop \u2014 OCR/clica/digita \xB7 via uvx",hintEn:"visual desktop automation \u2014 OCR/click/type \xB7 via uvx",command:"uvx",args:["aluy-mcp-rpa"]}]}function _ee(t){let e=Cee(),o=t.store.load(),n=nB(()=>zs().entries,[]),[r,s]=Oo("lang"),[i,a]=Oo(o.lang??"pt-BR"),[l,c]=Oo("local"),[d,m]=Oo("anthropic"),[u,p]=Oo({id:"",url:"",model:""}),[h,b]=Oo(""),[y,w]=Oo(""),[k,E]=Oo("leve"),[D,F]=Oo(Rl),[I,W]=Oo(""),$=nB(()=>sB(),[]),[U,X]=Oo(new Set),[te,J]=Oo(0),[M,H]=Oo(Math.max(0,Xt.findIndex(j=>j.code===i))),[Ae,ne]=Oo(""),[ue,ie]=Oo([]),pe=i==="pt-BR",P=(j,K)=>pe?j:K,ce=[{value:"local",label:P("Local (sua chave / BYO)","Local (your key / BYO)"),hint:P("direto no provider","direct to provider")},{value:"broker",label:P("Broker (conta Aluy)","Broker (Aluy account)"),hint:P("autentica depois com aluy login","authenticate later with aluy login")}],me=[...n.map(j=>({value:j.id,label:j.label,hint:j.defaultModel})),{value:"__custom__",label:P("+ custom (OpenAI-compat\xEDvel)","+ custom (OpenAI-compatible)"),hint:P("ex.: TokenRouter, vLLM\u2026","e.g. TokenRouter, vLLM\u2026")}],ae=[{value:"turbo",label:P("Turbo \u2014 instala tudo","Turbo \u2014 install all"),hint:P("ollama + mem0 + headroom \xB7 pede m\xE1quina razo\xE1vel","ollama + mem0 + headroom \xB7 needs a decent machine")},{value:"leve",label:P("Leve \u2014 nada agora","Lite \u2014 nothing now"),hint:P("liga depois com aluy bootstrap","enable later with aluy bootstrap")}],Oe=Eg.map(j=>({value:j.model,label:j.model,hint:P(j.hintPt,j.hintEn)})),Ie=j=>j==="lang"?Xt.length:j==="backend"?ce.length:j==="provider"?me.length:j==="sidecars"?ae.length:j==="embedder"?Oe.length:0;function Qe(j,K=""){ne(K),s(j)}function Ze(){H(Math.max(0,ae.findIndex(j=>j.value==="leve"))),s("sidecars")}function et(){J(0),s("mcp")}function xo(){let j=d==="__custom__",K=n.find(ye=>ye.id===d);return{wireFormat:j?"openai-compat":K?.wireFormat??"openai-compat",baseUrl:j?u.url.trim():K?.baseUrl??"",model:(j?u.model:y.trim()||K?.defaultModel||"").trim(),key:h.trim()}}Eee(()=>{if(r!=="validating")return;let j=xo();if(l!=="local"||j.key===""||j.baseUrl===""||j.model===""){et();return}let K=!1;return wy(j).then(ye=>{K||(ye.ok?(W(""),et()):(W(ye.detail),s("validate-failed")))}),()=>{K=!0}},[r]);function So(j,K){let ye=[],Ce={lang:i,backend:l};if(l==="local"){Ce.localProvider=d==="__custom__"?u.id.trim():d;let _e=d==="__custom__"?u.model:y;_e.trim()!==""&&(Ce.localModel=_e.trim())}if(Ce.profile=j,j==="turbo"&&K!==void 0&&K!==""&&(Ce.embedder=K),t.store.save(Ce),ye.push(`\u2713 ${P("config","config")}: backend ${l}`),l==="local"&&d==="__custom__"&&u.id.trim()!==""&&u.url.trim()!=="")try{QP({id:u.id.trim(),wireFormat:"openai-compat",baseUrl:u.url.trim(),defaultModel:u.model.trim()||u.id.trim()}),ye.push(P(`\u2713 provider custom "${u.id.trim()}" registrado`,`\u2713 custom provider "${u.id.trim()}" registered`))}catch(_e){ye.push(`\u26A0 providers.json: ${String(_e)}`)}if(l==="local"&&h.trim()!==""){let _e=d==="__custom__"?u.id.trim():d;try{Hl(_e,h.trim()),ye.push(P(`\u2713 chave de "${_e}" no keychain`,`\u2713 "${_e}" key in keychain`))}catch{ye.push(P(`\u26A0 keychain indispon\xEDvel \u2014 rode: aluy login --provider ${_e}`,`\u26A0 keychain unavailable \u2014 run: aluy login --provider ${_e}`))}}let rt=$.filter((_e,Y)=>U.has(Y));if(rt.length>0)try{let _e=new _r({file:Dee(rB(),".aluy","mcp.json")});for(let Y of rt)_e.add({name:Y.id,command:Y.command,args:[...Y.args],env:{}},{force:!0});ye.push(P(`\u2713 ${rt.length} MCP(s) registrado(s): ${rt.map(Y=>Y.id).join(", ")}`,`\u2713 ${rt.length} MCP(s) registered: ${rt.map(Y=>Y.id).join(", ")}`))}catch(_e){ye.push(`\u26A0 mcp.json: ${String(_e)}`)}ye.push(`\u2713 sidecars: ${j}`),j==="turbo"&&K!==void 0&&K!==""&&ye.push(` \u2192 embedder: ${K}`),j==="turbo"&&ye.push(P(" \u2192 instale agora: aluy bootstrap"," \u2192 install now: aluy bootstrap")),I!==""&&ye.push(P("\u26A0 modelo N\xC3O validado \u2014 pode n\xE3o funcionar","\u26A0 model NOT validated \u2014 may not work")),l==="broker"&&ye.push(P("\u2192 broker: autentique com `aluy login`","\u2192 broker: authenticate with `aluy login`")),ie(ye),s("done")}Tee((j,K)=>{if(r==="done"){K.return?(t.onOutcome?.({launch:!0,bootstrap:k==="turbo"}),e.exit()):K.escape&&(t.onOutcome?.({launch:!1,bootstrap:!1}),e.exit());return}if(r==="validating")return;if(r==="validate-failed"){if(K.escape){e.exit();return}let Ce=(j||"").toLowerCase();K.return||Ce==="r"?s("validating"):Ce==="k"?Qe("key",""):Ce==="u"&&d==="__custom__"?Qe("custom-url",u.url):Ce==="c"&&et();return}if(K.escape){e.exit();return}if(r==="mcp"){K.upArrow?J(Ce=>Math.max(0,Ce-1)):K.downArrow?J(Ce=>Math.min($.length-1,Ce+1)):j===" "?X(Ce=>{let rt=new Set(Ce);return rt.has(te)?rt.delete(te):rt.add(te),rt}):K.return&&Ze();return}if(r==="lang"||r==="backend"||r==="provider"||r==="sidecars"||r==="embedder"){let Ce=Ie(r);K.upArrow?H(rt=>Math.max(0,rt-1)):K.downArrow?H(rt=>Math.min(Ce-1,rt+1)):K.return&&De();return}if(K.return){vt();return}if(K.backspace||K.delete){ne(Ce=>Ce.slice(0,-1));return}j&&!K.ctrl&&!K.meta&&!K.upArrow&&!K.downArrow&&!K.leftArrow&&!K.rightArrow&&ne(Ce=>Ce+j)});function De(){if(r==="lang"){let j=Xt[M].code;t.store.saveLang(j),a(j),H(0),s("backend")}else if(r==="backend"){let j=ce[M].value;c(j),j==="broker"?et():(H(0),s("provider"))}else if(r==="provider"){let j=me[M].value;if(m(j),j==="__custom__")Qe("custom-id","");else{let K=n.find(Ce=>Ce.id===j);K?.auth?.length===1&&K.auth[0]==="none"?(b(""),Qe("model",K?.defaultModel??"")):Qe("key","")}}else if(r==="sidecars"){let j=ae[M].value;E(j),j==="turbo"?(H(0),s("embedder")):So(j)}else if(r==="embedder"){let j=Oe[M].value;F(j),So("turbo",j)}}function vt(){let j=Ae.trim();if(r==="custom-id")p(K=>({...K,id:j})),Qe("custom-url","");else if(r==="custom-url")p(K=>({...K,url:j})),Qe("custom-model","");else if(r==="custom-model")p(K=>({...K,model:j})),Qe("key","");else if(r==="key")if(b(Ae),d==="__custom__")s("validating");else{let K=n.find(ye=>ye.id===d)?.defaultModel??"";Qe("model",K)}else r==="model"&&(w(j),s("validating"))}let At=()=>({lang:"1/8",backend:"2/8",provider:"3/8","custom-id":"3/8","custom-url":"3/8","custom-model":"3/8",key:"4/8",model:"5/8",validating:"6/8","validate-failed":"6/8",mcp:"7/8",sidecars:"8/8"})[r]??"";return _t(ut,{flexDirection:"column",paddingY:1,children:[fe(fs,{columns:80}),fe(ut,{paddingTop:1,children:_t(f,{name:"fgDim",children:["aluy v",wn," \xB7 ",P("configura\xE7\xE3o inicial","first-run setup"),r!=="done"?` \xB7 ${At()}`:""]})}),_t(ut,{paddingTop:1,flexDirection:"column",children:[r==="lang"&&fe(Nm,{title:P("Idioma","Language"),opts:Xt.map(j=>({value:j.code,label:j.label})),cursor:M,active:i}),r==="backend"&&fe(Nm,{title:P("Backend do modelo","Model backend"),opts:ce,cursor:M}),r==="provider"&&fe(Nm,{title:P("Provider","Provider"),opts:me,cursor:M,active:d}),r==="mcp"&&fe(Ree,{title:P("MCPs (opcional) \u2014 quais instalar?","MCPs (optional) \u2014 which to install?"),entries:$,cursor:te,selected:U,pt:pe}),r==="sidecars"&&_t(ut,{flexDirection:"column",children:[fe(Nm,{title:P("Complementos (modo turbo)","Complements (turbo mode)"),opts:ae,cursor:M,active:k}),_t(ut,{paddingTop:1,flexDirection:"column",children:[fe(f,{name:"fgDim",children:P("Turbo roda modelos locais (Ollama) + mem\xF3ria \u2014 pede uma m\xE1quina razo\xE1vel:","Turbo runs local models (Ollama) + memory \u2014 needs a decent machine:")}),fe(f,{name:"fgDim",children:P(" ~8GB+ de RAM, alguns GB de disco e uma boa conex\xE3o (baixa o Ollama + modelos)."," ~8GB+ RAM, a few GB of disk and a good connection (downloads Ollama + models).")}),fe(f,{name:"fgDim",children:P(" Em m\xE1quina fraca, escolha Leve \u2014 o aluy funciona normal e voc\xEA liga o turbo depois."," On a weak machine, pick Lite \u2014 aluy works fine and you can enable turbo later.")})]})]}),r==="embedder"&&_t(ut,{flexDirection:"column",children:[fe(Nm,{title:P("Modelo de embedding (mem\xF3ria)","Embedding model (memory)"),opts:Oe,cursor:M,active:D}),_t(ut,{paddingTop:1,flexDirection:"column",children:[fe(f,{name:"fgDim",children:P("O embedder transforma suas mem\xF3rias em vetores p/ o recall sem\xE2ntico do mem0.","The embedder turns your memories into vectors for mem0\u2019s semantic recall.")}),fe(f,{name:"fgDim",children:P(" bge-m3 \xE9 o mais forte (multil\xEDngue, melhor em PT) \u2014 por\xE9m o maior download."," bge-m3 is the strongest (multilingual) \u2014 but the biggest download.")})]})]}),r==="custom-id"&&fe(Fm,{label:P("id do provider (ex.: tokenrouter)","provider id (e.g. tokenrouter)"),value:Ae}),r==="custom-url"&&fe(Fm,{label:P("base URL (https, .../v1)","base URL (https, .../v1)"),value:Ae}),r==="custom-model"&&fe(Fm,{label:P("modelo default","default model"),value:Ae}),r==="key"&&fe(Fm,{label:P(`API key de ${d==="__custom__"?u.id:d} (oculta)`,`${d==="__custom__"?u.id:d} API key (hidden)`),value:Ae,mask:!0}),r==="model"&&_t(ut,{flexDirection:"column",children:[fe(Fm,{label:P("modelo (enter = default)","model (enter = default)"),value:Ae}),(()=>{let j=n.find(K=>K.id===d)?.models??[];return j.length>0?fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:P("sugest\xF5es: ","suggestions: ")+j.join(" \xB7 ")})}):null})()]}),r==="validating"&&_t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:P("Testando o modelo\u2026","Testing the model\u2026")}),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:P("chamada real ao provider (n\xE3o prossigo se falhar)","real call to the provider (won't proceed if it fails)")})})]}),r==="validate-failed"&&_t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:P("\u2717 o modelo N\xC3O respondeu","\u2717 the model did NOT respond")}),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:I})}),fe(ut,{paddingTop:1,children:_t(f,{name:"fgDim",children:[P("enter/r tentar de novo \xB7 k trocar chave","enter/r retry \xB7 k change key"),d==="__custom__"?P(" \xB7 u trocar baseURL"," \xB7 u change baseURL"):"",P(" \xB7 c seguir mesmo assim \xB7 esc sair"," \xB7 c continue anyway \xB7 esc quit")]})})]}),r==="done"&&_t(ut,{flexDirection:"column",children:[ue.map((j,K)=>fe(f,{name:j.startsWith("\u26A0")?"fg":"accent",children:j},K)),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:P("enter p/ entrar no aluy","enter to launch aluy")})})]})]}),r!=="done"&&r!=="validating"&&r!=="validate-failed"&&fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:r==="lang"||r==="backend"||r==="provider"||r==="sidecars"||r==="embedder"?`\u2191\u2193 ${P("navegar","move")} \xB7 enter ${P("escolher","select")} \xB7 esc ${P("sair","quit")}`:`${P("digite","type")} \xB7 enter ${P("confirmar","confirm")} \xB7 esc ${P("sair","quit")}`})})]})}function Nm(t){return _t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:t.title}),fe(ut,{flexDirection:"column",paddingTop:1,children:t.opts.map((e,o)=>_t(ut,{children:[fe(f,{name:o===t.cursor?"accent":"fgDim",children:o===t.cursor?"\u276F ":" "}),fe(f,{name:o===t.cursor?"accent":"fg",children:e.label}),e.hint?_t(f,{name:"fgDim",children:[" \xB7 ",e.hint]}):null,t.active!==void 0&&e.value===t.active?fe(f,{name:"fgDim",children:" \u25CF"}):null]},e.value))})]})}function Ree(t){return _t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:t.title}),fe(ut,{flexDirection:"column",paddingTop:1,children:t.entries.map((e,o)=>{let n=t.selected.has(o),r=o===t.cursor;return _t(ut,{children:[fe(f,{name:r?"accent":"fgDim",children:r?"\u276F ":" "}),fe(f,{name:n?"accent":"fgDim",children:n?"[x] ":"[ ] "}),fe(f,{name:r?"accent":"fg",children:e.label}),_t(f,{name:"fgDim",children:[" \xB7 ",t.pt?e.hintPt:e.hintEn]})]},e.id)})}),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:t.pt?"ESPA\xC7O marca/desmarca \xB7 ENTER segue (pode seguir sem nenhum) \xB7 baixam na 1\xAA vez (npx/uvx)":"SPACE toggles \xB7 ENTER continues (none is fine) \xB7 fetched on first use (npx/uvx)"})})]})}function Fm(t){let e=t.mask?"\u2022".repeat(t.value.length):t.value;return _t(ut,{children:[_t(f,{name:"fg",children:[t.label,": "]}),fe(f,{name:"accent",children:e}),fe(f,{name:"accent",children:"\u258F"})]})}async function Oee(){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stdout.write(`aluy onboard precisa de um terminal interativo.
597
+ `}var wee,eo,_r,Im=g(()=>{"use strict";N();wee=256*1024,eo=class extends Error{constructor(e){super(e),this.name="McpWriteError"}},_r=class{file;constructor(e){this.file=e.file}get configPath(){return this.file}load(){let e;try{let n=vee(this.file);if(!n.isFile())throw new eo(`${this.file}: n\xE3o \xE9 um arquivo regular.`);if(n.size>wee)throw new eo(`${this.file}: grande demais p/ editar com seguran\xE7a.`);e=yee(this.file,"utf8")}catch(n){if(n instanceof eo)throw n;return Pe}let o;try{o=JSON.parse(e)}catch{throw new eo(`${this.file}: JSON inv\xE1lido \u2014 conserte \xE0 m\xE3o antes de usar 'aluy mcp'.`)}try{return sn(o)}catch(n){let r=n instanceof be?n.message:String(n);throw new eo(r)}}add(e,o={}){if(!Ol(e.name))throw new eo(`nome de server inv\xE1lido "${e.name}" \u2014 use s\xF3 [A-Za-z0-9_-] (vira prefixo de tool).`);if(e.command.trim().length===0)throw new eo(`server "${e.name}": "command" n\xE3o pode ser vazio.`);if(e.command.trim()==="--")throw new eo(`server "${e.name}": "--" n\xE3o \xE9 um command (\xE9 o separador do 'aluy mcp add'). Use: aluy mcp add ${e.name} -- <command> [args...].`);let n=this.load(),r=n.servers.find(i=>i.name===e.name);if(r&&!o.force)throw new eo(`server "${e.name}" j\xE1 existe em ${this.file} \u2014 use --force p/ sobrescrever.`);let s=[...n.servers.filter(i=>i.name!==e.name),e];return this.write({servers:s}),{replaced:r!==void 0}}remove(e){let o=this.load(),n=o.servers.length,r=o.servers.filter(s=>s.name!==e);return r.length===n?{removed:!1}:(this.write({servers:r}),{removed:!0})}setDisabled(e,o){let n=this.load(),r=n.servers.find(i=>i.name===e);if(!r)return{found:!1};let s={name:r.name,command:r.command,args:r.args,env:r.env,...o?{disabled:!0}:{}};return this.write({servers:n.servers.map(i=>i.name===e?s:i)}),{found:!0}}write(e){let o=xee(this.file);hee(o,{recursive:!0});let n=oB(e),r=See(o,`.mcp.json.${process.pid}.${Date.now()}.tmp`);kee(r,n,{encoding:"utf8",mode:384}),bee(r,this.file)}}});var iB={};xt(iB,{mcpCatalog:()=>sB,runOnboard:()=>Oee});import{useEffect as Eee,useMemo as nB,useState as Oo}from"react";import{render as Aee,Box as ut,useApp as Cee,useInput as Tee}from"ink";import{homedir as rB}from"node:os";import{join as Dee}from"node:path";import{jsx as fe,jsxs as _t}from"react/jsx-runtime";function sB(){return[{id:"playwright",label:"Playwright",hintPt:"automa\xE7\xE3o de navegador (oficial)",hintEn:"browser automation (official)",command:"npx",args:["-y","@playwright/mcp@latest"]},{id:"sequential-thinking",label:"Sequential Thinking",hintPt:"racioc\xEDnio passo-a-passo",hintEn:"step-by-step reasoning",command:"npx",args:["-y","@modelcontextprotocol/server-sequential-thinking"]},{id:"memory",label:"Memory",hintPt:"grafo de conhecimento persistente",hintEn:"persistent knowledge graph",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]},{id:"filesystem",label:"Filesystem",hintPt:"arquivos (escopo: sua home)",hintEn:"files (scope: your home)",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem",rB()]},{id:"rpa",label:"RPA (Aluy)",hintPt:"automa\xE7\xE3o visual de desktop \u2014 OCR/clica/digita \xB7 via uvx",hintEn:"visual desktop automation \u2014 OCR/click/type \xB7 via uvx",command:"uvx",args:["aluy-mcp-rpa"]}]}function _ee(t){let e=Cee(),o=t.store.load(),n=nB(()=>zs().entries,[]),[r,s]=Oo("lang"),[i,a]=Oo(o.lang??"pt-BR"),[l,c]=Oo("local"),[d,m]=Oo("anthropic"),[u,p]=Oo({id:"",url:"",model:""}),[h,b]=Oo(""),[y,w]=Oo(""),[k,E]=Oo("leve"),[D,F]=Oo(Rl),[I,W]=Oo(""),$=nB(()=>sB(),[]),[U,X]=Oo(new Set),[te,J]=Oo(0),[M,H]=Oo(Math.max(0,Xt.findIndex(j=>j.code===i))),[Ae,ne]=Oo(""),[ue,ie]=Oo([]),pe=i==="pt-BR",P=(j,K)=>pe?j:K,ce=[{value:"local",label:P("Local (sua chave / BYO)","Local (your key / BYO)"),hint:P("direto no provider","direct to provider")},{value:"broker",label:P("Broker (conta Aluy)","Broker (Aluy account)"),hint:P("autentica depois com aluy login","authenticate later with aluy login")}],me=[...n.map(j=>({value:j.id,label:j.label,hint:j.defaultModel})),{value:"__custom__",label:P("+ custom (OpenAI-compat\xEDvel)","+ custom (OpenAI-compatible)"),hint:P("ex.: TokenRouter, vLLM\u2026","e.g. TokenRouter, vLLM\u2026")}],ae=[{value:"turbo",label:P("Turbo \u2014 instala tudo","Turbo \u2014 install all"),hint:P("ollama + mem0 + headroom \xB7 pede m\xE1quina razo\xE1vel","ollama + mem0 + headroom \xB7 needs a decent machine")},{value:"leve",label:P("Leve \u2014 nada agora","Lite \u2014 nothing now"),hint:P("liga depois com aluy bootstrap","enable later with aluy bootstrap")}],Oe=Eg.map(j=>({value:j.model,label:j.model,hint:P(j.hintPt,j.hintEn)})),Ie=j=>j==="lang"?Xt.length:j==="backend"?ce.length:j==="provider"?me.length:j==="sidecars"?ae.length:j==="embedder"?Oe.length:0;function Qe(j,K=""){ne(K),s(j)}function Ze(){H(Math.max(0,ae.findIndex(j=>j.value==="leve"))),s("sidecars")}function et(){J(0),s("mcp")}function xo(){let j=d==="__custom__",K=n.find(ye=>ye.id===d);return{wireFormat:j?"openai-compat":K?.wireFormat??"openai-compat",baseUrl:j?u.url.trim():K?.baseUrl??"",model:(j?u.model:y.trim()||K?.defaultModel||"").trim(),key:h.trim()}}Eee(()=>{if(r!=="validating")return;let j=xo();if(l!=="local"||j.key===""||j.baseUrl===""||j.model===""){et();return}let K=!1;return wy(j).then(ye=>{K||(ye.ok?(W(""),et()):(W(ye.detail),s("validate-failed")))}),()=>{K=!0}},[r]);function So(j,K){let ye=[],Ce={lang:i,backend:l};if(l==="local"){Ce.localProvider=d==="__custom__"?u.id.trim():d;let _e=d==="__custom__"?u.model:y;_e.trim()!==""&&(Ce.localModel=_e.trim())}if(Ce.profile=j,j==="turbo"&&K!==void 0&&K!==""&&(Ce.embedder=K),t.store.save(Ce),ye.push(`\u2713 ${P("config","config")}: backend ${l}`),l==="local"&&d==="__custom__"&&u.id.trim()!==""&&u.url.trim()!=="")try{QP({id:u.id.trim(),wireFormat:"openai-compat",baseUrl:u.url.trim(),defaultModel:u.model.trim()||u.id.trim()}),ye.push(P(`\u2713 provider custom "${u.id.trim()}" registrado`,`\u2713 custom provider "${u.id.trim()}" registered`))}catch(_e){ye.push(`\u26A0 providers.json: ${String(_e)}`)}if(l==="local"&&h.trim()!==""){let _e=d==="__custom__"?u.id.trim():d;try{Hl(_e,h.trim()),ye.push(P(`\u2713 chave de "${_e}" no keychain`,`\u2713 "${_e}" key in keychain`))}catch{ye.push(P(`\u26A0 keychain indispon\xEDvel \u2014 rode: aluy login --provider ${_e}`,`\u26A0 keychain unavailable \u2014 run: aluy login --provider ${_e}`))}}let rt=$.filter((_e,Y)=>U.has(Y));if(rt.length>0)try{let _e=new _r({file:Dee(rB(),".aluy","mcp.json")});for(let Y of rt)_e.add({name:Y.id,command:Y.command,args:[...Y.args],env:{}},{force:!0});ye.push(P(`\u2713 ${rt.length} MCP(s) registrado(s): ${rt.map(Y=>Y.id).join(", ")}`,`\u2713 ${rt.length} MCP(s) registered: ${rt.map(Y=>Y.id).join(", ")}`))}catch(_e){ye.push(`\u26A0 mcp.json: ${String(_e)}`)}ye.push(`\u2713 sidecars: ${j}`),j==="turbo"&&K!==void 0&&K!==""&&ye.push(` \u2192 embedder: ${K}`),j==="turbo"&&ye.push(P(" \u2192 instale agora: aluy bootstrap"," \u2192 install now: aluy bootstrap")),I!==""&&ye.push(P("\u26A0 modelo N\xC3O validado \u2014 pode n\xE3o funcionar","\u26A0 model NOT validated \u2014 may not work")),l==="broker"&&ye.push(P("\u2192 broker: autentique com `aluy login`","\u2192 broker: authenticate with `aluy login`")),ie(ye),s("done")}Tee((j,K)=>{if(r==="done"){K.return?(t.onOutcome?.({launch:!0,bootstrap:k==="turbo"}),e.exit()):K.escape&&(t.onOutcome?.({launch:!1,bootstrap:!1}),e.exit());return}if(r==="validating")return;if(r==="validate-failed"){if(K.escape){e.exit();return}let Ce=(j||"").toLowerCase();K.return||Ce==="r"?s("validating"):Ce==="k"?Qe("key",""):Ce==="u"&&d==="__custom__"?Qe("custom-url",u.url):Ce==="c"&&et();return}if(K.escape){e.exit();return}if(r==="mcp"){K.upArrow?J(Ce=>Math.max(0,Ce-1)):K.downArrow?J(Ce=>Math.min($.length-1,Ce+1)):j===" "?X(Ce=>{let rt=new Set(Ce);return rt.has(te)?rt.delete(te):rt.add(te),rt}):K.return&&Ze();return}if(r==="lang"||r==="backend"||r==="provider"||r==="sidecars"||r==="embedder"){let Ce=Ie(r);K.upArrow?H(rt=>Math.max(0,rt-1)):K.downArrow?H(rt=>Math.min(Ce-1,rt+1)):K.return&&De();return}if(K.return){vt();return}if(K.backspace||K.delete){ne(Ce=>Ce.slice(0,-1));return}j&&!K.ctrl&&!K.meta&&!K.upArrow&&!K.downArrow&&!K.leftArrow&&!K.rightArrow&&ne(Ce=>Ce+j)});function De(){if(r==="lang"){let j=Xt[M].code;t.store.saveLang(j),a(j),H(0),s("backend")}else if(r==="backend"){let j=ce[M].value;c(j),j==="broker"?et():(H(0),s("provider"))}else if(r==="provider"){let j=me[M].value;if(m(j),j==="__custom__")Qe("custom-id","");else{let K=n.find(Ce=>Ce.id===j);K?.auth?.length===1&&K.auth[0]==="none"?(b(""),Qe("model",K?.defaultModel??"")):Qe("key","")}}else if(r==="sidecars"){let j=ae[M].value;E(j),j==="turbo"?(H(0),s("embedder")):So(j)}else if(r==="embedder"){let j=Oe[M].value;F(j),So("turbo",j)}}function vt(){let j=Ae.trim();if(r==="custom-id")p(K=>({...K,id:j})),Qe("custom-url","");else if(r==="custom-url")p(K=>({...K,url:j})),Qe("custom-model","");else if(r==="custom-model")p(K=>({...K,model:j})),Qe("key","");else if(r==="key")if(b(Ae),d==="__custom__")s("validating");else{let K=n.find(ye=>ye.id===d)?.defaultModel??"";Qe("model",K)}else r==="model"&&(w(j),s("validating"))}let At=()=>({lang:"1/8",backend:"2/8",provider:"3/8","custom-id":"3/8","custom-url":"3/8","custom-model":"3/8",key:"4/8",model:"5/8",validating:"6/8","validate-failed":"6/8",mcp:"7/8",sidecars:"8/8"})[r]??"";return _t(ut,{flexDirection:"column",paddingY:1,children:[fe(fs,{columns:80}),fe(ut,{paddingTop:1,children:_t(f,{name:"fgDim",children:["aluy v",wn," \xB7 ",P("configura\xE7\xE3o inicial","first-run setup"),r!=="done"?` \xB7 ${At()}`:""]})}),_t(ut,{paddingTop:1,flexDirection:"column",children:[r==="lang"&&fe(Nm,{title:P("Idioma","Language"),opts:Xt.map(j=>({value:j.code,label:j.label})),cursor:M,active:i}),r==="backend"&&fe(Nm,{title:P("Backend do modelo","Model backend"),opts:ce,cursor:M}),r==="provider"&&fe(Nm,{title:P("Provider","Provider"),opts:me,cursor:M,active:d}),r==="mcp"&&fe(Ree,{title:P("MCPs (opcional) \u2014 quais instalar?","MCPs (optional) \u2014 which to install?"),entries:$,cursor:te,selected:U,pt:pe}),r==="sidecars"&&_t(ut,{flexDirection:"column",children:[fe(Nm,{title:P("Complementos (modo turbo)","Complements (turbo mode)"),opts:ae,cursor:M,active:k}),_t(ut,{paddingTop:1,flexDirection:"column",children:[fe(f,{name:"fgDim",children:P("Turbo roda modelos locais (Ollama) + mem\xF3ria \u2014 pede uma m\xE1quina razo\xE1vel:","Turbo runs local models (Ollama) + memory \u2014 needs a decent machine:")}),fe(f,{name:"fgDim",children:P(" ~8GB+ de RAM, alguns GB de disco e uma boa conex\xE3o (baixa o Ollama + modelos)."," ~8GB+ RAM, a few GB of disk and a good connection (downloads Ollama + models).")}),fe(f,{name:"fgDim",children:P(" Em m\xE1quina fraca, escolha Leve \u2014 o aluy funciona normal e voc\xEA liga o turbo depois."," On a weak machine, pick Lite \u2014 aluy works fine and you can enable turbo later.")})]})]}),r==="embedder"&&_t(ut,{flexDirection:"column",children:[fe(Nm,{title:P("Modelo de embedding (mem\xF3ria)","Embedding model (memory)"),opts:Oe,cursor:M,active:D}),_t(ut,{paddingTop:1,flexDirection:"column",children:[fe(f,{name:"fgDim",children:P("O embedder transforma suas mem\xF3rias em vetores p/ o recall sem\xE2ntico do mem0.","The embedder turns your memories into vectors for mem0\u2019s semantic recall.")}),fe(f,{name:"fgDim",children:P(" bge-m3 \xE9 o mais forte (multil\xEDngue, melhor em PT) \u2014 por\xE9m o maior download."," bge-m3 is the strongest (multilingual) \u2014 but the biggest download.")})]})]}),r==="custom-id"&&fe(Fm,{label:P("id do provider (ex.: tokenrouter)","provider id (e.g. tokenrouter)"),value:Ae}),r==="custom-url"&&fe(Fm,{label:P("base URL (https, .../v1)","base URL (https, .../v1)"),value:Ae}),r==="custom-model"&&fe(Fm,{label:P("modelo default","default model"),value:Ae}),r==="key"&&fe(Fm,{label:P(`API key de ${d==="__custom__"?u.id:d} (oculta)`,`${d==="__custom__"?u.id:d} API key (hidden)`),value:Ae,mask:!0}),r==="model"&&_t(ut,{flexDirection:"column",children:[fe(Fm,{label:P("modelo (enter = default)","model (enter = default)"),value:Ae}),(()=>{let j=n.find(K=>K.id===d)?.models??[];return j.length>0?fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:P("sugest\xF5es: ","suggestions: ")+j.join(" \xB7 ")})}):null})()]}),r==="validating"&&_t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:P("Testando o modelo\u2026","Testing the model\u2026")}),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:P("chamada real ao provider (n\xE3o prossigo se falhar)","real call to the provider (won't proceed if it fails)")})})]}),r==="validate-failed"&&_t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:P("\u2717 o modelo N\xC3O respondeu","\u2717 the model did NOT respond")}),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:I})}),fe(ut,{paddingTop:1,children:_t(f,{name:"fgDim",children:[P("enter/r tentar de novo \xB7 k trocar chave","enter/r retry \xB7 k change key"),d==="__custom__"?P(" \xB7 u trocar baseURL"," \xB7 u change baseURL"):"",P(" \xB7 c seguir mesmo assim \xB7 esc sair"," \xB7 c continue anyway \xB7 esc quit")]})})]}),r==="done"&&_t(ut,{flexDirection:"column",children:[ue.map((j,K)=>fe(f,{name:j.startsWith("\u26A0")?"fg":"accent",children:j},K)),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:P("enter p/ entrar no aluy","enter to launch aluy")})})]})]}),r!=="done"&&r!=="validating"&&r!=="validate-failed"&&fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:r==="lang"||r==="backend"||r==="provider"||r==="sidecars"||r==="embedder"?`\u2191\u2193 ${P("navegar","move")} \xB7 enter ${P("escolher","select")} \xB7 esc ${P("sair","quit")}`:`${P("digite","type")} \xB7 enter ${P("confirmar","confirm")} \xB7 esc ${P("sair","quit")}`})})]})}function Nm(t){return _t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:t.title}),fe(ut,{flexDirection:"column",paddingTop:1,children:t.opts.map((e,o)=>_t(ut,{children:[fe(f,{name:o===t.cursor?"accent":"fgDim",children:o===t.cursor?"\u276F ":" "}),fe(f,{name:o===t.cursor?"accent":"fg",children:e.label}),e.hint?_t(f,{name:"fgDim",children:[" \xB7 ",e.hint]}):null,t.active!==void 0&&e.value===t.active?fe(f,{name:"fgDim",children:" \u25CF"}):null]},e.value))})]})}function Ree(t){return _t(ut,{flexDirection:"column",children:[fe(f,{name:"fg",children:t.title}),fe(ut,{flexDirection:"column",paddingTop:1,children:t.entries.map((e,o)=>{let n=t.selected.has(o),r=o===t.cursor;return _t(ut,{children:[fe(f,{name:r?"accent":"fgDim",children:r?"\u276F ":" "}),fe(f,{name:n?"accent":"fgDim",children:n?"[x] ":"[ ] "}),fe(f,{name:r?"accent":"fg",children:e.label}),_t(f,{name:"fgDim",children:[" \xB7 ",t.pt?e.hintPt:e.hintEn]})]},e.id)})}),fe(ut,{paddingTop:1,children:fe(f,{name:"fgDim",children:t.pt?"ESPA\xC7O marca/desmarca \xB7 ENTER segue (pode seguir sem nenhum) \xB7 baixam na 1\xAA vez (npx/uvx)":"SPACE toggles \xB7 ENTER continues (none is fine) \xB7 fetched on first use (npx/uvx)"})})]})}function Fm(t){let e=t.mask?"\u2022".repeat(t.value.length):t.value;return _t(ut,{children:[_t(f,{name:"fg",children:[t.label,": "]}),fe(f,{name:"accent",children:e}),fe(f,{name:"accent",children:"\u258F"})]})}async function Oee(){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stdout.write(`aluy onboard precisa de um terminal interativo.
598
598
  Abra um terminal e rode: aluy onboard
599
599
  `),{code:0,launch:!1,bootstrap:!1};let t=new Ge,e=xn({}),o={launch:!1,bootstrap:!1};return await Aee(fe(ga,{theme:e,children:fe(_ee,{store:t,onOutcome:r=>{o=r}})})).waitUntilExit(),{code:0,...o}}var aB=g(()=>{"use strict";ha();ee();jl();Il();_o();Bu();ta();LA();Im();N()});function cB(t){return`${Rr}${t};1H`}function Mee(t,e){return`${Rr}${t};${e}H`}function Lee(t){let e=1,o=1;for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="\x1B"&&t[n+1]==="["){let s=n+2;for(;s<t.length&&t[s]>="0"&&t[s]<="?";)s+=1;for(;s<t.length&&t[s]>=" "&&t[s]<="/";)s+=1;n=s;continue}if(r===`
600
600
  `)e+=1,o=1;else if(r==="\r")o=1;else{let s=t.codePointAt(n);s>65535&&(n+=1),o+=ke(String.fromCodePoint(s))}}return{row:e,col:o}}function fB(t){return t.ALUY_SYNC_OUTPUT!=="0"}function pB(t){return t.ALUY_OVERWRITE_RENDER!=="0"}function $A(t){let e=0,o=0;for(;t.startsWith(`${Ey}${NA}`,e);)e+=Ey.length+NA.length,o+=1;if(t.startsWith(`${Ey}${FA}`,e))return e+=Ey.length+FA.length,{lines:o+1,bodyStart:e}}function Pee(t){return t.startsWith(Bm)?"clearterm":$A(t)?"erase":"other"}function Iee(){let t=!1;return{feed(e){return Pee(e)==="clearterm"?(t=!0,!1):t?(t=!1,!0):!1}}}function dB(t){let e="",o="";for(let n=0;n<t.length;n+=1){let r=t[n];r===`
@@ -617,7 +617,7 @@ Abra um terminal e rode: aluy onboard
617
617
  `).map((c,d)=>Ln(Ca,{children:Ln(f,{name:"fgDim",children:c})},d))]})]})}let o=t.status==="err";return or(Ca,{flexDirection:"column",paddingLeft:2,children:[or(Ca,{children:[Ln(B,{name:"tool",role:"depth"}),or(f,{name:"fg",children:[" ",Toe(t.verb)]}),Ln(xC,{children:" "}),Ln(f,{name:"fg",children:t.target}),Ln(xC,{children:" "}),Ln(f,{name:"fgDim",children:t.result}),Ln(xC,{children:" "}),o?Ln(B,{name:"err",role:"danger"}):Ln(B,{name:"ok",role:"success"})]}),o&&t.output&&or(Ca,{flexDirection:"column",paddingLeft:2,children:[or(f,{name:"fgDim",children:[e.box.topLeft," sa\xEDda ",e.box.horizontal.repeat(8)]}),t.output.split(`
618
618
  `).map((n,r)=>or(Ca,{children:[or(f,{name:"fgDim",children:[e.box.vertical," "]}),Ln(f,{name:"danger",children:n})]},r)),or(f,{name:"fgDim",children:[e.box.bottomLeft," ",t.result," ",e.box.horizontal.repeat(4)]})]})]})}var r2,Coe,s2=g(()=>{"use strict";ee();Gy();Nt();Ea();r2=7,Coe=4});import"react";import{Box as Ht,Text as Dc}from"ink";import{jsx as je,jsxs as we}from"react/jsx-runtime";function Doe(t){if(!t)return;let e=t.split(".").pop();return e&&e!==t?e:void 0}function Roe(t){return t.length<=_oe?{head:t,hidden:0,tail:[]}:{head:t.slice(0,i2),hidden:t.length-i2-a2,tail:t.slice(t.length-a2)}}function c2(t){return t.category==="always-ask:destructive"}function Ooe(t){let e=/^\[sub-agente:\s*([^\]]+)\]/.exec(t.reason??"");return e?e[1].trim():null}function Moe(t){let e=t.effect.kind;return e==="diff"||e==="path"?`edit \u2500 ${t.effect.path??t.effect.exact}`:"bash"}function wC(t){let e=V(),o=t.request,n=c2(o),r=o.category==="always-ask:network"||t.egressOutsideAllowlist===!0,s=Ooe(o),i=n?"destrutivo \xB7 ask":"ask";return we(Ht,{flexDirection:"column",paddingLeft:2,children:[we(Ht,{children:[we(f,{name:"accent",children:[e.box.topLeft," "]}),je(B,{name:"ask",role:"accent"}),we(f,{name:"accent",children:[" ",i," \u2500 ",Moe(o)," ",e.box.horizontal.repeat(2),e.box.topRight]})]}),je(f,{name:"accent",children:e.box.vertical}),s!==null&&we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(B,{name:"subagents",role:"accent"}),je(f,{name:"accent",children:" sub-agente: "}),je(f,{name:"fg",children:s})]}),je(Ioe,{request:o}),r&&we(Ht,{flexDirection:"column",children:[we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(B,{name:"ask",role:"accent"}),je(f,{name:"accent",children:" rede \xB7 ask \xB7 destino fora da allowlist"})]}),t.egressTarget&&we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(f,{name:"depth",children:t.egressTarget})]})]}),we(f,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(40),e.box.teeRight]}),n?we(Ht,{flexDirection:"column",children:[we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(B,{name:"ask",role:"accent"}),je(f,{name:"accent",children:" esta a\xE7\xE3o n\xE3o pode ser desfeita"})]}),we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(f,{name:"danger",children:"[n] negar"}),je(Dc,{children:" "}),je(f,{name:"accent",children:"[a] aprovar mesmo assim"})]})]}):we(Ht,{flexDirection:"column",children:[we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(B,{name:"ask",role:"accent"}),we(f,{name:"accent",children:[" ",Poe(o)]})]}),we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(f,{name:"accent",children:"[a] aprovar"}),je(Dc,{children:" "}),o.alwaysAsk===!1&&je(f,{name:"accent",children:"[s] sempre nesta sess\xE3o"})]}),we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(f,{name:"danger",children:"[n] negar"}),je(Dc,{children:" "}),je(f,{name:"fgDim",children:"[e] editar"})]})]}),we(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42),e.box.bottomRight]}),je(f,{name:"fgDim",children:Loe(o,n)})]})}function Loe(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 Poe(t){return t.effect.kind==="diff"||t.effect.kind==="path"?"aplicar esta altera\xE7\xE3o?":"executar este comando?"}function Ioe(t){let e=V(),o=t.request.effect,n=Roe(o.exact.split(`
619
619
  `)),r=c2(t.request)?"":" \u2014 [e] editar mostra tudo",s=a=>we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),we(f,{name:"fgDim",children:["\u2026 (+",n.hidden," linhas ocultas",r,")"]})]},a);if(o.kind==="diff"){let a=bc(Doe(o.path??o.exact)),l=(c,d)=>we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(Noe,{line:c,lang:a??void 0})]},d);return we(Ht,{flexDirection:"column",children:[n.head.map((c,d)=>l(c,`h${d}`)),n.hidden>0&&s("m"),n.tail.map((c,d)=>l(c,`t${d}`))]})}let i=(a,l)=>we(Ht,{children:[we(f,{name:"accent",children:[e.box.vertical," "]}),je(f,{name:"fg",children:a})]},l);return we(Ht,{flexDirection:"column",children:[n.head.map((a,l)=>i(a,`h${l}`)),n.hidden>0&&s("m"),n.tail.map((a,l)=>i(a,`t${l}`))]})}function Noe(t){let e=V(),o=t.line;return o.startsWith("---")||o.startsWith("+++")||o.startsWith("@@")?je(f,{name:"fgDim",children:o}):o.startsWith("-")?we(Dc,{children:[we(f,{name:"danger",children:[e.glyph("diffDel")," "]}),je(l2,{code:o.slice(1),lang:t.lang,fallback:"danger"})]}):o.startsWith("+")?we(Dc,{children:[we(f,{name:"success",children:[e.glyph("diffAdd")," "]}),je(l2,{code:o.slice(1),lang:t.lang,fallback:"success"})]}):je(f,{name:"fgDim",children:o})}function l2(t){if(t.lang===void 0||t.code==="")return je(f,{name:t.fallback,children:t.code});let e=Ym(t.code,t.lang);return je(Dc,{children:e.map((o,n)=>je(f,{name:o.role,children:o.text},n))})}var _oe,i2,a2,d2=g(()=>{"use strict";ee();hC();_oe=14,i2=9,a2=4});import"react";import{Box as nr}from"ink";import{jsx as Lo,jsxs as tt}from"react/jsx-runtime";function $oe(t){return t.kind!=="text"&&t.allowOther!==!1}function AC(t){let e=V(),{spec:o}=t;return tt(nr,{flexDirection:"column",paddingLeft:2,children:[tt(nr,{children:[tt(f,{name:"accent",children:[e.box.topLeft," "]}),Lo(B,{name:"ask",role:"accent"}),tt(f,{name:"accent",children:[" ","Pergunta ",e.box.horizontal.repeat(EC-Foe),e.box.topRight]})]}),Lo(f,{name:"accent",children:e.box.vertical}),o.header!==void 0&&tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"depth",children:o.header})]}),o.question.split(`
620
- `).map((n,r)=>tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"fg",children:n})]},`q-${r}`)),Lo(f,{name:"accent",children:e.box.vertical}),o.kind==="text"?Lo(joe,{theme:e,draft:t.draft??""}):Lo(Boe,{...t}),tt(f,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(EC),e.box.teeRight]}),tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"fgDim",children:Hoe(o,t.editing===!0)})]}),tt(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(EC),e.box.bottomRight]})]})}function Boe(t){let e=V(),{spec:o}=t,n=o.options??[],r=o.kind==="multi",s=t.selected??new Set;return tt(nr,{flexDirection:"column",children:[n.map((i,a)=>{let l=t.cursor===a,c=r?s.has(a)?"[x]":"[ ]":l?"(\u2022)":"( )";return tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),tt(f,{name:l?"accent":"fgDim",children:[l?"\u203A":" "," "]}),tt(f,{name:l?"accent":"fgDim",children:[c," "]}),Lo(f,{name:l?"accent":"fg",children:i.label}),i.description!==void 0&&tt(f,{name:"fgDim",children:[" \u2014 ",i.description]})]},`opt-${a}`)}),$oe(o)&&Lo(Uoe,{theme:e,onCursor:t.cursor===Pr,editing:t.editing===!0&&t.cursor===Pr,draft:t.draft??""})]})}function Uoe(t){let{theme:e,onCursor:o,editing:n,draft:r}=t;return tt(nr,{flexDirection:"column",children:[tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),tt(f,{name:o?"accent":"fgDim",children:[o?"\u203A":" "," "]}),Lo(f,{name:o?"accent":"fg",children:"Outro (resposta livre)"})]}),n&&tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"fg",children:r}),Lo(f,{name:"accent",children:e.glyph("cursor")})]})]})}function joe(t){let{theme:e,draft:o}=t;return tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),tt(f,{name:"depth",children:[e.glyph("prompt")," "]}),Lo(f,{name:"fg",children:o}),Lo(f,{name:"accent",children:e.glyph("cursor")})]})}function Hoe(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"}var Pr,EC,Foe,u2=g(()=>{"use strict";ee();Pr=-1,EC=42,Foe=13});import"react";import{Box as nf}from"ink";import{jsx as zy,jsxs as Pn}from"react/jsx-runtime";function CC(t){let e=V(),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 Pn(nf,{flexDirection:"column",paddingLeft:4,children:[Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.topLeft," "]}),zy(B,{name:"broker",role:"depth"}),Pn(f,{name:"danger",children:[" ",n," ",e.box.horizontal.repeat(4)," "]}),zy(B,{name:"err",role:"danger"})]}),Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.vertical," "]}),zy(f,{name:"fg",children:t.message})]}),(t.status!==void 0||t.attempt!==void 0||t.retryInSeconds!==void 0)&&Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.vertical," "]}),Pn(f,{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})`:""]})]}),Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.vertical," "]}),zy(f,{name:"fgDim",children:r})]}),Pn(f,{name:"danger",children:[e.box.bottomLeft,e.box.horizontal.repeat(40)]})]})}var m2=g(()=>{"use strict";ee()});import"react";import{Box as ai,Text as qoe}from"ink";import{jsx as Ir,jsxs as Ot}from"react/jsx-runtime";function Woe(t){return t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function TC(t){let e=V();return Ot(ai,{flexDirection:"column",paddingLeft:2,children:[Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.topLeft," "]}),Ir(B,{name:"clock",role:"accent"}),Ot(f,{name:"accent",children:[" teto da sess\xE3o ",e.box.horizontal.repeat(6)," pausado"]})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"fg",children:t.reason})]}),t.budgetPct!==void 0&&Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(B,{name:"clock",role:"accent"}),Ot(f,{name:"accent",children:[" ",t.budgetPct,"% do teto da sess\xE3o"]}),t.maxTokens!==void 0&&Ot(f,{name:"fgDim",children:[" (teto: ",Woe(t.maxTokens)," tokens)"]})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir."})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(B,{name:"window",role:"fgDim"}),Ot(f,{name:"fgDim",children:[" janela: ",t.windowPct,"% usada"]})]}),t.canCompact&&Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"accent",children:"[k] compactar"}),Ir(f,{name:"fgDim",children:" resume a conversa e continua (libera a janela)"})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"accent",children:"[c] continuar (+50 itera\xE7\xF5es)"}),Ir(qoe,{children:" "}),Ir(f,{name:"fgDim",children:"[n] encerrar"})]}),Ot(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}var f2=g(()=>{"use strict";ee()});import"react";import{Box as Ta,Text as Goe}from"ink";import{Fragment as Koe,jsx as Nr,jsxs as go}from"react/jsx-runtime";function zoe(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 DC(t){let e=V(),o=zoe(t.kind,t.count,t.sample);return go(Ta,{flexDirection:"column",paddingLeft:2,children:[go(Ta,{children:[go(f,{name:"accent",children:[e.box.topLeft," "]}),Nr(B,{name:"clock",role:"accent"}),go(f,{name:"accent",children:[" parece travado ",e.box.horizontal.repeat(6)," pausado"]})]}),go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"fg",children:o})]}),t.redirecting?go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"accent",children:"[r] "}),Nr(f,{name:"fgDim",children:"digite a nova instru\xE7\xE3o e tecle Enter (esc cancela)."})]}):go(Koe,{children:[go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir o rumo."})]}),go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"accent",children:"[r] redirecionar"}),Nr(f,{name:"fgDim",children:" (dar uma nova instru\xE7\xE3o)"})]}),go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"accent",children:"[c] continuar mesmo assim"}),Nr(Goe,{children:" "}),Nr(f,{name:"fgDim",children:"[n] encerrar"})]})]}),go(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}var p2=g(()=>{"use strict";ee()});import"react";import{Box as Da,Text as g2}from"ink";import{jsx as vs,jsxs as ho}from"react/jsx-runtime";function Yoe(t){let e=t.replace(/\s+/g," ").trim();return e.length<=h2?e:e.slice(0,h2-1)+"\u2026"}function _C(t){let e=V(),o=Yoe(t.reason),n=Math.round(Math.max(0,Math.min(1,t.confidence))*100);return ho(Da,{flexDirection:"column",paddingLeft:2,children:[ho(Da,{children:[ho(f,{name:"accent",children:[e.box.topLeft," "]}),vs(B,{name:"clock",role:"accent"}),ho(f,{name:"accent",children:[" ",t.ceilingLabel," atingido ",e.box.horizontal.repeat(4)," pausado"]})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(f,{name:"fgDim",children:"o teto do ciclo bateu, mas o juiz local sugere continuar."})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(f,{name:"fgDim",children:"motivo do juiz (local \xB7 n\xE3o verificado):"})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(g2,{wrap:"truncate-end",children:vs(f,{name:"fg",children:o})})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),ho(f,{name:"fgDim",children:["confian\xE7a do juiz: ",n,"% (dado \u2014 pondere, n\xE3o obede\xE7a)"]})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(f,{name:"accent",children:"[c] continua"}),vs(f,{name:"fgDim",children:" (estende um teto-worth)"}),vs(g2,{children:" "}),vs(f,{name:"fgDim",children:"[n] encerra"})]}),ho(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}var h2,y2=g(()=>{"use strict";ee();h2=96});import"react";import{Box as pOe}from"ink";import{jsx as yOe,jsxs as bOe}from"react/jsx-runtime";var b2=g(()=>{"use strict";ee()});import Voe from"react";import{Box as _c,Text as Xoe}from"ink";import{Fragment as Qoe,jsx as In,jsxs as li}from"react/jsx-runtime";function Joe(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 li(f,{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 li(Qoe,{children:[li(f,{name:e,children:["/",r]}),In(f,{name:"accent",children:s}),In(f,{name:e,children:i})]})}function Ky(t){let e=t.query??"",o=t.maxRows!==void 0?WF(t.commands,t.selected,t.maxRows,t.columns):{slice:t.commands,hiddenAbove:0,hiddenBelow:0},n=t.selected-o.hiddenAbove,r=null;return li(_c,{flexDirection:"column",children:[In(_c,{children:In(f,{name:"fgDim",children:"/ para comandos \xB7 \u2191\u2193 navega \xB7 enter executa \xB7 esc fecha"})}),o.hiddenAbove>0&&In(_c,{children:li(f,{name:"fgDim",children:[" \u2191 ",o.hiddenAbove," acima"]})}),o.slice.map((s,i)=>{let a=i===n,l=GE(s),c=l!==r?l:null;r=l;let d=Yh(s),m=s.kind==="subcommand",u=a?"\u203A ":m?" ":" ";return li(Voe.Fragment,{children:[c&&In(_c,{children:In(f,{name:"fgDim",children:c==="usu\xE1rio"?"\u2500\u2500\u2500 seus comandos":c})}),li(_c,{children:[In(f,{name:a?"accent":"fgDim",children:u}),In(Joe,{path:d,query:e,sel:a,sub:m}),In(Xoe,{children:" ".repeat(Math.max(1,18-d.length))}),In(f,{name:"fgDim",children:zE(s)})]})]},`${l}:${d}`)}),o.hiddenBelow>0&&In(_c,{children:li(f,{name:"fgDim",children:[" \u2193 ",o.hiddenBelow," mais (refine a busca)"]})})]})}var v2=g(()=>{"use strict";ee();ei()});import"react";import{Box as Rc,Text as Zoe}from"ink";import{Fragment as one,jsx as Xo,jsxs as rf}from"react/jsx-runtime";function ene(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Xo(f,{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(Xo(f,{name:s?"accent":e,children:t.label.slice(r,i)},r)),r=i}return Xo(one,{children:n})}function tne(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 Yy(t){let{t:e}=Se(),o=t.maxRows??8,n=t.query??"",{start:r,slice:s}=tne(t.hits,t.selected,o),i=s.reduce((a,l)=>Math.max(a,l.label.length),0);return rf(Rc,{flexDirection:"column",children:[Xo(Rc,{children:Xo(f,{name:"fgDim",children:e("picker.palette.help")})}),rf(Rc,{children:[Xo(f,{name:"accent",children:"> "}),n===""?Xo(f,{name:"fgDim",children:e("picker.palette.search")}):Xo(f,{name:"fg",children:n})]}),t.hits.length===0?Xo(Rc,{children:rf(f,{name:"fgDim",children:[" ",e("picker.palette.empty",{query:n})]})}):s.map((a,l)=>{let d=r+l===t.selected;return rf(Rc,{children:[Xo(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),Xo(ene,{label:a.label,matched:a.matched,sel:d}),Xo(Zoe,{children:" ".repeat(Math.max(1,i-a.label.length+2))}),Xo(f,{name:"fgDim",children:a.description})]},a.id)}),t.hits.length>s.length&&Xo(Rc,{children:rf(f,{name:"fgDim",children:[" ",e("picker.palette.more",{count:t.hits.length-s.length})]})})]})}var k2=g(()=>{"use strict";ee();St()});import"react";import{Box as sf}from"ink";import{Fragment as sne,jsx as Fr,jsxs as Vy}from"react/jsx-runtime";function x2(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 nne(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Fr(f,{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(Fr(f,{name:s?"accent":e,children:a},r)),r=i}return Fr(sne,{children:n})}function rne(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 RC(t){let{t:e}=Se(),o=t.columns??80,n=t.maxRows??8,r=Math.max(8,o-4),{start:s,slice:i}=rne(t.hits,t.selected,n);return Vy(sf,{flexDirection:"column",children:[Fr(sf,{children:Fr(f,{name:"fgDim",children:e("picker.file.help")})}),t.hits.length===0?Fr(sf,{children:Vy(f,{name:"fgDim",children:[" ",e("picker.file.empty",{query:t.query??""})]})}):i.map((a,l)=>{let d=s+l===t.selected,m=x2(a.path,r),u=m===a.path;return Vy(sf,{children:[Fr(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),u?Fr(nne,{path:a.path,matched:a.matched,sel:d}):Fr(f,{name:d?"accent":"fg",children:m})]},a.path)}),t.hits.length>i.length&&Fr(sf,{children:Vy(f,{name:"fgDim",children:[" ",e("picker.file.more",{count:t.hits.length-i.length})]})})]})}var S2=g(()=>{"use strict";ee();St()});import"react";import{Box as Ve,Text as ine}from"ink";import{Fragment as OC,jsx as oe,jsxs as ot}from"react/jsx-runtime";function Xy(t){let{t:e}=Se();if(t.effortStepOpen)return oe(mne,{...t});if(t.customInputOpen)return oe(lne,{...t});let o=t.tiers.length;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.model.help")})}),t.loading?oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.loading")]})}):ot(OC,{children:[t.tiers.map((n,r)=>{let s=r===t.selected,i=n.key===t.currentTier,a=Hw(n),l=jw(n.costSignal);return ot(Ve,{children:[oe(f,{name:s?"accent":"fgDim",children:s?"\u203A ":" "}),oe(f,{name:i?"accent":"fgDim",children:i?"\u25CF ":" "}),oe(f,{name:s?"accent":"fg",children:n.displayName}),a!==""&&ot(OC,{children:[oe(f,{name:"fgDim",children:" \xB7 "}),oe(f,{name:"depth",children:a})]}),ot(f,{name:"fgDim",children:[" \xB7 ",l]})]},n.key)}),ot(Ve,{children:[oe(f,{name:t.selected===o?"accent":"fgDim",children:t.selected===o?"\u203A ":" "}),oe(f,{name:t.currentTier==="custom"?"accent":"fgDim",children:t.currentTier==="custom"?"\u25CF ":" "}),oe(f,{name:t.selected===o?"accent":"fg",children:"Custom"}),ot(f,{name:"fgDim",children:[" \xB7 ",e("picker.model.customLine")]})]},"__custom__")]}),t.usingFallback===!0&&!t.loading&&oe(Ve,{children:ot(f,{name:"fgDim",children:[" ","\u25CD ",e("picker.model.fallback")]})})]})}function lne(t){return t.customBrowserAvailable===!0?oe(une,{...t}):oe(pne,{...t})}function cne(t){return t.supportsTools===!0?oe(f,{name:"accent",children:"\u2713 tools"}):t.supportsTools===!1?oe(f,{name:"fgDim",children:"\u2014 tools"}):oe(f,{name:"fgDim",children:"\xB7 tools?"})}function dne(t){let{model:e,highlighted:o}=t.row,n=[e.family,e.context].map(r=>r.trim()).filter(r=>r!=="");return ot(Ve,{children:[oe(f,{name:o?"accent":"fgDim",children:o?"\u203A ":" "}),oe(f,{name:o?"accent":"fg",children:e.id}),n.length>0&&ot(OC,{children:[oe(f,{name:"fgDim",children:" "}),oe(f,{name:"depth",children:n.join(" \xB7 ")})]}),oe(ine,{children:" "}),oe(cne,{supportsTools:e.supportsTools})]})}function une(t){let{t:e}=Se(),o=t.customInput??"",n=t.customRows??[],r=t.customFilteredCount??0,s=t.customTotalCount??0,i=t.customToolsOnly===!0,a=t.customNoToolsWarning??null;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.model.browseHelp")})}),ot(Ve,{children:[oe(f,{name:"accent",children:"filtro \u203A "}),oe(f,{name:"fg",children:o}),oe(f,{name:"accent",children:"\u258F"}),ot(f,{name:"fgDim",children:[" ",e("picker.model.browseCount",{filtered:r,total:s}),i?e("picker.model.toolsOnlySuffix"):""]})]}),t.customHasMoreAbove===!0&&oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.moreAbove")]})}),n.length===0?oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.noFilterMatch")]})}):oe(Ve,{flexDirection:"column",children:n.map(l=>oe(dne,{row:l},l.model.id))}),t.customHasMoreBelow===!0&&oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.moreBelow")]})}),a!==null&&oe(Ve,{children:ot(f,{name:"accent",children:[" ",e("picker.model.noTools")]})})]})}function mne(t){let{t:e}=Se();if(t.effortCustomOpen===!0)return oe(fne,{...t});let o=t.effortOptions??[],n=t.effortSelected??0,r=t.currentEffort;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.effort.help")})}),o.map((s,i)=>{let a=i===n,l=s.kind==="level"&&s.value===r||s.kind==="keep"&&(r===void 0||r==="");return ot(Ve,{children:[oe(f,{name:a?"accent":"fgDim",children:a?"\u203A ":" "}),oe(f,{name:l?"accent":"fgDim",children:l?"\u25CF ":" "}),oe(f,{name:a?"accent":"fg",children:e(ane[s.id]??"picker.effort.keep")})]},s.id)})]})}function fne(t){let{t:e}=Se(),o=t.effortCustomInput??"",n=t.effortCustomWarn??null;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.effort.customHelp")})}),ot(Ve,{children:[oe(f,{name:"accent",children:"\u203A "}),oe(f,{name:"fg",children:o}),oe(f,{name:"accent",children:"\u258F"})]}),n!==null&&oe(Ve,{children:ot(f,{name:"accent",children:[" ",e(n==="empty"?"picker.effort.warnEmpty":"picker.effort.warnTooLong")]})})]})}function pne(t){let{t:e}=Se(),o=t.customInput??"",n=t.customSuggestions??[],r=t.customWarnOutOfCatalog===!0;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.model.freeHelp")})}),ot(Ve,{children:[oe(f,{name:"accent",children:"\u203A "}),oe(f,{name:"fg",children:o}),oe(f,{name:"accent",children:"\u258F"})]}),n.length>0&&oe(Ve,{flexDirection:"column",children:n.map(s=>ot(Ve,{children:[oe(f,{name:"fgDim",children:" \u25CD "}),oe(f,{name:"depth",children:s})]},s))}),r&&oe(Ve,{children:ot(f,{name:"accent",children:[" ",e("picker.model.outOfCatalog")]})})]})}var ane,w2=g(()=>{"use strict";ee();St();as();ane={keep:"picker.effort.keep",low:"picker.effort.low",medium:"picker.effort.medium",high:"picker.effort.high",custom:"picker.effort.custom"}});function LC(t,e=MC){let o;try{o=t.list()}catch{return[]}return o.slice(0,Math.max(0,e))}function E2(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 gne(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 af(t,e){let o=Em(t.cwd,e??process.env.HOME??""),n=t.label?.trim();if(n)return`${n} \xB7 ${E2(t.updatedAt)} \xB7 ${o}`;let r=t.title??(t.blocks?gne(t.blocks):void 0)??"(sem objetivo)";return`${E2(t.updatedAt)} \xB7 ${o} \xB7 ${r}`}function hne(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}${af(n,e)}`)}return o}function A2(t,e){e.switchSession({id:t.id,cwd:t.cwd,tier:t.tier}),e.resetContinuation?.(),e.clearScreen(),e.restoreBlocks(t.blocks);let o=aa(t.blocks);o.length>0&&e.seedHistory(o),t.cwd.trim()!==""&&e.setSessionCwd?.(t.cwd)}function C2(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=LC(o.store,o.limit);for(let a of hne(i,o.home))e.write(`[history] ${a}
620
+ `).map((n,r)=>tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"fg",children:n})]},`q-${r}`)),Lo(f,{name:"accent",children:e.box.vertical}),o.kind==="text"?Lo(joe,{theme:e,draft:t.draft??""}):Lo(Boe,{...t}),tt(f,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(EC),e.box.teeRight]}),tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"fgDim",children:Hoe(o,t.editing===!0)})]}),tt(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(EC),e.box.bottomRight]})]})}function Boe(t){let e=V(),{spec:o}=t,n=o.options??[],r=o.kind==="multi",s=t.selected??new Set;return tt(nr,{flexDirection:"column",children:[n.map((i,a)=>{let l=t.cursor===a,c=r?s.has(a)?"[x]":"[ ]":l?"(\u2022)":"( )";return tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),tt(f,{name:l?"accent":"fgDim",children:[l?"\u203A":" "," "]}),tt(f,{name:l?"accent":"fgDim",children:[c," "]}),Lo(f,{name:l?"accent":"fg",children:i.label}),i.description!==void 0&&tt(f,{name:"fgDim",children:[" \u2014 ",i.description]})]},`opt-${a}`)}),$oe(o)&&Lo(Uoe,{theme:e,onCursor:t.cursor===Pr,editing:t.editing===!0&&t.cursor===Pr,draft:t.draft??""})]})}function Uoe(t){let{theme:e,onCursor:o,editing:n,draft:r}=t;return tt(nr,{flexDirection:"column",children:[tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),tt(f,{name:o?"accent":"fgDim",children:[o?"\u203A":" "," "]}),Lo(f,{name:o?"accent":"fg",children:"Outro (resposta livre)"})]}),n&&tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),Lo(f,{name:"fg",children:r}),Lo(f,{name:"accent",children:e.glyph("cursor")})]})]})}function joe(t){let{theme:e,draft:o}=t;return tt(nr,{children:[tt(f,{name:"accent",children:[e.box.vertical," "]}),tt(f,{name:"depth",children:[e.glyph("prompt")," "]}),Lo(f,{name:"fg",children:o}),Lo(f,{name:"accent",children:e.glyph("cursor")})]})}function Hoe(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"}var Pr,EC,Foe,u2=g(()=>{"use strict";ee();Pr=-1,EC=42,Foe=13});import"react";import{Box as nf}from"ink";import{jsx as zy,jsxs as Pn}from"react/jsx-runtime";function CC(t){let e=V(),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 Pn(nf,{flexDirection:"column",paddingLeft:4,children:[Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.topLeft," "]}),zy(B,{name:"broker",role:"depth"}),Pn(f,{name:"danger",children:[" ",n," ",e.box.horizontal.repeat(4)," "]}),zy(B,{name:"err",role:"danger"})]}),Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.vertical," "]}),zy(f,{name:"fg",children:t.message})]}),(t.status!==void 0||t.attempt!==void 0||t.retryInSeconds!==void 0)&&Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.vertical," "]}),Pn(f,{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})`:""]})]}),Pn(nf,{children:[Pn(f,{name:"danger",children:[e.box.vertical," "]}),zy(f,{name:"fgDim",children:r})]}),Pn(f,{name:"danger",children:[e.box.bottomLeft,e.box.horizontal.repeat(40)]})]})}var m2=g(()=>{"use strict";ee()});import"react";import{Box as ai,Text as qoe}from"ink";import{jsx as Ir,jsxs as Ot}from"react/jsx-runtime";function Woe(t){return t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function TC(t){let e=V();return Ot(ai,{flexDirection:"column",paddingLeft:2,children:[Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.topLeft," "]}),Ir(B,{name:"clock",role:"accent"}),Ot(f,{name:"accent",children:[" teto da sess\xE3o ",e.box.horizontal.repeat(6)," pausado"]})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"fg",children:t.reason})]}),t.budgetPct!==void 0&&Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(B,{name:"clock",role:"accent"}),Ot(f,{name:"accent",children:[" ",t.budgetPct,"% do teto da sess\xE3o"]}),t.maxTokens!==void 0&&Ot(f,{name:"fgDim",children:[" (teto: ",Woe(t.maxTokens)," tokens)"]})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir."})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(B,{name:"window",role:"fgDim"}),Ot(f,{name:"fgDim",children:[" janela: ",t.windowPct,"% usada"]})]}),t.canCompact&&Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"accent",children:"[k] compactar"}),Ir(f,{name:"fgDim",children:" resume a conversa e continua (libera a janela)"})]}),Ot(ai,{children:[Ot(f,{name:"accent",children:[e.box.vertical," "]}),Ir(f,{name:"accent",children:"[c] continuar (+50 itera\xE7\xF5es)"}),Ir(qoe,{children:" "}),Ir(f,{name:"fgDim",children:"[n] encerrar"})]}),Ot(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}var f2=g(()=>{"use strict";ee()});import"react";import{Box as Ta,Text as Goe}from"ink";import{Fragment as Koe,jsx as Nr,jsxs as go}from"react/jsx-runtime";function zoe(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 DC(t){let e=V(),o=zoe(t.kind,t.count,t.sample);return go(Ta,{flexDirection:"column",paddingLeft:2,children:[go(Ta,{children:[go(f,{name:"accent",children:[e.box.topLeft," "]}),Nr(B,{name:"clock",role:"accent"}),go(f,{name:"accent",children:[" parece travado ",e.box.horizontal.repeat(6)," pausado"]})]}),go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"fg",children:o})]}),t.redirecting?go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"accent",children:"[r] "}),Nr(f,{name:"fgDim",children:"digite a nova instru\xE7\xE3o e tecle Enter (esc cancela)."})]}):go(Koe,{children:[go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir o rumo."})]}),go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"accent",children:"[r] redirecionar"}),Nr(f,{name:"fgDim",children:" (dar uma nova instru\xE7\xE3o)"})]}),go(Ta,{children:[go(f,{name:"accent",children:[e.box.vertical," "]}),Nr(f,{name:"accent",children:"[c] continuar mesmo assim"}),Nr(Goe,{children:" "}),Nr(f,{name:"fgDim",children:"[n] encerrar"})]})]}),go(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}var p2=g(()=>{"use strict";ee()});import"react";import{Box as Da,Text as g2}from"ink";import{jsx as vs,jsxs as ho}from"react/jsx-runtime";function Yoe(t){let e=t.replace(/\s+/g," ").trim();return e.length<=h2?e:e.slice(0,h2-1)+"\u2026"}function _C(t){let e=V(),o=Yoe(t.reason),n=Math.round(Math.max(0,Math.min(1,t.confidence))*100);return ho(Da,{flexDirection:"column",paddingLeft:2,children:[ho(Da,{children:[ho(f,{name:"accent",children:[e.box.topLeft," "]}),vs(B,{name:"clock",role:"accent"}),ho(f,{name:"accent",children:[" ",t.ceilingLabel," atingido ",e.box.horizontal.repeat(4)," pausado"]})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(f,{name:"fgDim",children:"o teto do ciclo bateu, mas o juiz local sugere continuar."})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(f,{name:"fgDim",children:"motivo do juiz (local \xB7 n\xE3o verificado):"})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(g2,{wrap:"truncate-end",children:vs(f,{name:"fg",children:o})})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),ho(f,{name:"fgDim",children:["confian\xE7a do juiz: ",n,"% (dado \u2014 pondere, n\xE3o obede\xE7a)"]})]}),ho(Da,{children:[ho(f,{name:"accent",children:[e.box.vertical," "]}),vs(f,{name:"accent",children:"[c] continua"}),vs(f,{name:"fgDim",children:" (estende um teto-worth)"}),vs(g2,{children:" "}),vs(f,{name:"fgDim",children:"[n] encerra"})]}),ho(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}var h2,y2=g(()=>{"use strict";ee();h2=96});import"react";import{Box as pOe}from"ink";import{jsx as yOe,jsxs as bOe}from"react/jsx-runtime";var b2=g(()=>{"use strict";ee()});import Voe from"react";import{Box as _c,Text as Xoe}from"ink";import{Fragment as Qoe,jsx as In,jsxs as li}from"react/jsx-runtime";function Joe(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 li(f,{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 li(Qoe,{children:[li(f,{name:e,children:["/",r]}),In(f,{name:"accent",children:s}),In(f,{name:e,children:i})]})}function Ky(t){let e=t.query??"",o=t.maxRows!==void 0?WF(t.commands,t.selected,t.maxRows,t.columns):{slice:t.commands,hiddenAbove:0,hiddenBelow:0},n=t.selected-o.hiddenAbove,r=null;return li(_c,{flexDirection:"column",children:[In(_c,{children:In(f,{name:"fgDim",children:"/ para comandos \xB7 \u2191\u2193 navega \xB7 enter executa \xB7 esc fecha"})}),o.hiddenAbove>0&&In(_c,{children:li(f,{name:"fgDim",children:[" \u2191 ",o.hiddenAbove," acima"]})}),o.slice.map((s,i)=>{let a=i===n,l=GE(s),c=l!==r?l:null;r=l;let d=Yh(s),m=s.kind==="subcommand",u=a?"\u203A ":m?" ":" ";return li(Voe.Fragment,{children:[c&&In(_c,{children:In(f,{name:"fgDim",children:c==="usu\xE1rio"?"\u2500\u2500\u2500 seus comandos":c})}),li(_c,{children:[In(f,{name:a?"accent":"fgDim",children:u}),In(Joe,{path:d,query:e,sel:a,sub:m}),In(Xoe,{children:" ".repeat(Math.max(1,18-d.length))}),In(f,{name:"fgDim",children:zE(s)})]})]},`${l}:${d}`)}),o.hiddenBelow>0&&In(_c,{children:li(f,{name:"fgDim",children:[" \u2193 ",o.hiddenBelow," mais (refine a busca)"]})})]})}var v2=g(()=>{"use strict";ee();ei()});import"react";import{Box as Rc,Text as Zoe}from"ink";import{Fragment as one,jsx as Xo,jsxs as rf}from"react/jsx-runtime";function ene(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Xo(f,{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(Xo(f,{name:s?"accent":e,children:t.label.slice(r,i)},r)),r=i}return Xo(one,{children:n})}function tne(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 Yy(t){let{t:e}=Se(),o=t.maxRows??8,n=t.query??"",{start:r,slice:s}=tne(t.hits,t.selected,o),i=s.reduce((a,l)=>Math.max(a,l.label.length),0);return rf(Rc,{flexDirection:"column",children:[Xo(Rc,{children:Xo(f,{name:"fgDim",children:e("picker.palette.help")})}),rf(Rc,{children:[Xo(f,{name:"accent",children:"> "}),n===""?Xo(f,{name:"fgDim",children:e("picker.palette.search")}):Xo(f,{name:"fg",children:n})]}),t.hits.length===0?Xo(Rc,{children:rf(f,{name:"fgDim",children:[" ",e("picker.palette.empty",{query:n})]})}):s.map((a,l)=>{let d=r+l===t.selected;return rf(Rc,{children:[Xo(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),Xo(ene,{label:a.label,matched:a.matched,sel:d}),Xo(Zoe,{children:" ".repeat(Math.max(1,i-a.label.length+2))}),Xo(f,{name:"fgDim",children:a.description})]},a.id)}),t.hits.length>s.length&&Xo(Rc,{children:rf(f,{name:"fgDim",children:[" ",e("picker.palette.more",{count:t.hits.length-s.length})]})})]})}var k2=g(()=>{"use strict";ee();St()});import"react";import{Box as sf}from"ink";import{Fragment as sne,jsx as Fr,jsxs as Vy}from"react/jsx-runtime";function x2(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 nne(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Fr(f,{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(Fr(f,{name:s?"accent":e,children:a},r)),r=i}return Fr(sne,{children:n})}function rne(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 RC(t){let{t:e}=Se(),o=t.columns??80,n=t.maxRows??8,r=Math.max(8,o-4),{start:s,slice:i}=rne(t.hits,t.selected,n);return Vy(sf,{flexDirection:"column",children:[Fr(sf,{children:Fr(f,{name:"fgDim",children:e("picker.file.help")})}),t.hits.length===0?Fr(sf,{children:Vy(f,{name:"fgDim",children:[" ",e("picker.file.empty",{query:t.query??""})]})}):i.map((a,l)=>{let d=s+l===t.selected,m=x2(a.path,r),u=m===a.path;return Vy(sf,{children:[Fr(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),u?Fr(nne,{path:a.path,matched:a.matched,sel:d}):Fr(f,{name:d?"accent":"fg",children:m})]},a.path)}),t.hits.length>i.length&&Fr(sf,{children:Vy(f,{name:"fgDim",children:[" ",e("picker.file.more",{count:t.hits.length-i.length})]})})]})}var S2=g(()=>{"use strict";ee();St()});import"react";import{Box as Ve,Text as ine}from"ink";import{Fragment as OC,jsx as oe,jsxs as ot}from"react/jsx-runtime";function Xy(t){let{t:e}=Se();if(t.effortStepOpen)return oe(mne,{...t});if(t.customInputOpen)return oe(lne,{...t});let o=t.tiers.length;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.model.help")})}),t.loading?oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.loading")]})}):ot(OC,{children:[t.tiers.map((n,r)=>{let s=r===t.selected,i=n.key===t.currentTier,a=Hw(n),l=jw(n.costSignal);return ot(Ve,{children:[oe(f,{name:s?"accent":"fgDim",children:s?"\u203A ":" "}),oe(f,{name:i?"accent":"fgDim",children:i?"\u25CF ":" "}),oe(f,{name:s?"accent":"fg",children:n.displayName}),a!==""&&ot(OC,{children:[oe(f,{name:"fgDim",children:" \xB7 "}),oe(f,{name:"depth",children:a})]}),ot(f,{name:"fgDim",children:[" \xB7 ",l]})]},n.key)}),ot(Ve,{children:[oe(f,{name:t.selected===o?"accent":"fgDim",children:t.selected===o?"\u203A ":" "}),oe(f,{name:t.currentTier==="custom"?"accent":"fgDim",children:t.currentTier==="custom"?"\u25CF ":" "}),oe(f,{name:t.selected===o?"accent":"fg",children:"Custom"}),ot(f,{name:"fgDim",children:[" \xB7 ",e("picker.model.customLine")]})]},"__custom__")]}),t.usingFallback===!0&&!t.loading&&oe(Ve,{children:ot(f,{name:"fgDim",children:[" ","\u25CD ",e("picker.model.fallback")]})})]})}function lne(t){return t.customBrowserAvailable===!0?oe(une,{...t}):oe(pne,{...t})}function cne(t){return t.supportsTools===!0?oe(f,{name:"accent",children:"\u2713 tools"}):t.supportsTools===!1?oe(f,{name:"fgDim",children:"\u2014 tools"}):oe(f,{name:"fgDim",children:"\xB7 tools?"})}function dne(t){let{model:e,highlighted:o}=t.row,n=[e.family,e.context].map(r=>r.trim()).filter(r=>r!=="");return ot(Ve,{children:[oe(f,{name:o?"accent":"fgDim",children:o?"\u203A ":" "}),oe(f,{name:o?"accent":"fg",children:e.id}),n.length>0&&ot(OC,{children:[oe(f,{name:"fgDim",children:" "}),oe(f,{name:"depth",children:n.join(" \xB7 ")})]}),oe(ine,{children:" "}),oe(cne,{supportsTools:e.supportsTools})]})}function une(t){let{t:e}=Se(),o=t.customInput??"",n=t.customRows??[],r=t.customFilteredCount??0,s=t.customTotalCount??0,i=t.customToolsOnly===!0,a=t.customNoToolsWarning??null;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.model.browseHelp")})}),ot(Ve,{children:[oe(f,{name:"accent",children:"filtro \u203A "}),oe(f,{name:"fg",children:o}),oe(f,{name:"accent",children:"\u258F"}),ot(f,{name:"fgDim",children:[" ",e("picker.model.browseCount",{filtered:r,total:s}),i?e("picker.model.toolsOnlySuffix"):""]})]}),t.customHasMoreAbove===!0&&oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.moreAbove")]})}),n.length===0?oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.noFilterMatch")]})}):oe(Ve,{flexDirection:"column",children:n.map(l=>oe(dne,{row:l},l.model.id))}),t.customHasMoreBelow===!0&&oe(Ve,{children:ot(f,{name:"fgDim",children:[" ",e("picker.model.moreBelow")]})}),a!==null&&oe(Ve,{children:ot(f,{name:"accent",children:[" ",e("picker.model.noTools")]})})]})}function mne(t){let{t:e}=Se();if(t.effortCustomOpen===!0)return oe(fne,{...t});let o=t.effortOptions??[],n=t.effortSelected??0,r=t.currentEffort;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.effort.help")})}),o.map((s,i)=>{let a=i===n,l=s.kind==="level"&&s.value===r||s.kind==="keep"&&(r===void 0||r==="");return ot(Ve,{children:[oe(f,{name:a?"accent":"fgDim",children:a?"\u203A ":" "}),oe(f,{name:l?"accent":"fgDim",children:l?"\u25CF ":" "}),oe(f,{name:a?"accent":"fg",children:e(ane[s.id]??"picker.effort.keep")})]},s.id)})]})}function fne(t){let{t:e}=Se(),o=t.effortCustomInput??"",n=t.effortCustomWarn??null;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.effort.customHelp")})}),ot(Ve,{children:[oe(f,{name:"accent",children:"\u203A "}),oe(f,{name:"fg",children:o}),oe(f,{name:"accent",children:"\u258F"})]}),n!==null&&oe(Ve,{children:ot(f,{name:"accent",children:[" ",e(n==="empty"?"picker.effort.warnEmpty":"picker.effort.warnTooLong")]})})]})}function pne(t){let{t:e}=Se(),o=t.customInput??"",n=t.customSuggestions??[],r=t.customWarnOutOfCatalog===!0;return ot(Ve,{flexDirection:"column",children:[oe(Ve,{children:oe(f,{name:"fgDim",children:e("picker.model.freeHelp")})}),ot(Ve,{children:[oe(f,{name:"accent",children:"\u203A "}),oe(f,{name:"fg",children:o}),oe(f,{name:"accent",children:"\u258F"})]}),n.length>0&&oe(Ve,{flexDirection:"column",children:n.map(s=>ot(Ve,{children:[oe(f,{name:"fgDim",children:" \u25CD "}),oe(f,{name:"depth",children:s})]},s))}),r&&oe(Ve,{children:ot(f,{name:"accent",children:[" ",e("picker.model.outOfCatalog")]})})]})}var ane,w2=g(()=>{"use strict";ee();St();as();ane={keep:"picker.effort.keep",low:"picker.effort.low",medium:"picker.effort.medium",high:"picker.effort.high",custom:"picker.effort.custom"}});function LC(t,e=MC){let o;try{o=t.list()}catch{return[]}return o.slice(0,Math.max(0,e))}function E2(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 gne(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 af(t,e){let o=Em(t.cwd,e??process.env.HOME??""),n=t.label?.trim();if(n)return`${n} \xB7 ${E2(t.updatedAt)} \xB7 ${o}`;let r=t.title??(t.blocks?gne(t.blocks):void 0)??"(sem objetivo)";return`${E2(t.updatedAt)} \xB7 ${o} \xB7 ${r}`}function hne(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}${af(n,e)}`)}return o}function A2(t,e){e.switchSession({id:t.id,cwd:t.cwd,tier:t.tier}),e.resetContinuation?.(),e.clearScreen(),e.restoreBlocks(t.blocks);let o=aa(t.blocks);o.length>0&&e.seedHistory(o),t.cwd.trim()!==""&&e.setSessionCwd?.(t.cwd)}function C2(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=LC(o.store,o.limit);for(let a of hne(i,o.home))e.write(`[history] ${a}
621
621
  `);return!0}let s=o.store.load(r);return s?(o.resume(s),e.write(`[history] sess\xE3o retomada: ${r} (${af(s,o.home)})
622
622
  `),!0):(e.write(`[history] sess\xE3o n\xE3o encontrada: ${r}
623
623
  `),!0)}var MC,Jy=g(()=>{"use strict";ec();_n();MC=15});function $r(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)),l=a,c=a+1,d=s(a),m=!0,u=!0;for(;u;){u=!1;let p=()=>l>0&&d+s(l-1)<=o?(l-=1,d+=s(l),!0):!1,h=()=>c<r&&d+s(c)<=o?(d+=s(c),c+=1,!0):!1;u=m?p()||h():h()||p(),m=!m}return{start:l,slice:t.slice(l,c)}}var Oc=g(()=>{"use strict"});import"react";import{Box as lf,Text as T2}from"ink";import{Fragment as yne,jsx as ci,jsxs as cf}from"react/jsx-runtime";function Qy(t){let e=V(),{t:o}=Se(),n=e.glyph("sessionDot"),r=Math.max(1,t.maxRows??10),s=t.columns,i=s!==void 0&&s>0?c=>{let d=2+(c.label?.trim()?2:0)+ke(af(c,t.home));return Math.max(1,Math.ceil(d/s))}:void 0,{start:a,slice:l}=$r(t.sessions,t.selected,r,i);return cf(lf,{flexDirection:"column",children:[ci(lf,{children:ci(f,{name:"fgDim",children:o("picker.history.help")})}),t.sessions.length===0?ci(lf,{children:cf(f,{name:"fgDim",children:[" ",o("picker.history.empty")]})}):l.map((c,d)=>{let u=a+d===t.selected,p=c.label?.trim(),h=p?e.sessionColor(c.labelColor??p):void 0,b={};return h?.color!==void 0&&(b.color=h.color),h?.bold!==void 0&&(b.bold=h.bold),cf(lf,{children:[ci(f,{name:u?"accent":"fgDim",children:u?"\u203A ":" "}),p&&cf(yne,{children:[ci(T2,{...b,children:n}),ci(T2,{children:" "})]}),ci(f,{name:u?"accent":"fg",children:af(c,t.home)})]},c.id)}),t.sessions.length>l.length&&ci(lf,{children:cf(f,{name:"fgDim",children:[" ",o("picker.history.more",{count:t.sessions.length-l.length})]})})]})}var D2=g(()=>{"use strict";ee();St();Jy();Nt();Oc()});function _2(t,e=30){return[...t].reverse().slice(0,e)}function PC(t){let e=bne(t.ts);return`#${t.ordinal} \xB7 ${e} \xB7 ${t.label}`}function bne(t){let e=new Date(t),o=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${o}:${n}`}var Zy,IC=g(()=>{"use strict";Zy=["both","conversation","code"]});import"react";import{Box as Nn}from"ink";import{jsx as yo,jsxs as _a}from"react/jsx-runtime";function vne(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 eb(t){let{t:e}=Se();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+ke(PC(a)))/n)):void 0,{start:s,slice:i}=$r(t.checkpoints,t.selected,o,r);return _a(Nn,{flexDirection:"column",children:[yo(Nn,{children:yo(f,{name:"fgDim",children:e("picker.rewind.help")})}),t.checkpoints.length===0?yo(Nn,{children:_a(f,{name:"fgDim",children:[" ",e("picker.rewind.empty")]})}):i.map((a,l)=>{let c=s+l===t.selected;return _a(Nn,{children:[yo(f,{name:c?"accent":"fgDim",children:c?"\u203A ":" "}),yo(f,{name:c?"accent":"fg",children:PC(a)})]},a.id)}),t.checkpoints.length>i.length&&yo(Nn,{children:_a(f,{name:"fgDim",children:[" ",e("picker.rewind.more",{count:t.checkpoints.length-i.length})]})})]})}return _a(Nn,{flexDirection:"column",children:[yo(Nn,{children:yo(f,{name:"fgDim",children:e("picker.rewind.action.help")})}),t.target&&yo(Nn,{children:yo(f,{name:"fgDim",children:` \u2192 #${t.target.ordinal} \xB7 ${t.target.label}`})}),t.actions.map((o,n)=>{let r=n===t.selected;return _a(Nn,{children:[yo(f,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),yo(f,{name:r?"accent":"fg",children:e(vne(o))})]},o)}),t.barrierWarnings&&t.barrierWarnings.length>0&&_a(Nn,{flexDirection:"column",marginTop:1,children:[yo(Nn,{children:yo(f,{name:"accent",children:`\u26A0 ${e("picker.rewind.barrier.warn")}:`})}),t.barrierWarnings.map((o,n)=>yo(Nn,{children:yo(f,{name:"fgDim",children:` \xB7 ${o}`})},n))]})]})}var R2=g(()=>{"use strict";ee();St();IC();Nt();Oc()});import kne from"react";import{Box as Po,Text as xne}from"ink";import{Fragment as Ane,jsx as Xe,jsxs as fn}from"react/jsx-runtime";function Sne(t){switch(t){case"mode":return"modo de sess\xE3o \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 sess\xE3o \xB7 enter REVOGA";case"locked":return"TRAVADO por seguran\xE7a \xB7 s\xF3 via --yolo"}}function wne(t){let{row:e,sel:o}=t,n=Xe(f,{name:o?"accent":"fgDim",children:o?"\u203A ":" "});switch(e.kind){case"mode":return fn(Po,{children:[n,Xe(f,{name:o?"accent":"fg",children:"modo: "}),Xe(f,{name:e.mode==="unsafe"?"danger":o?"accent":"fg",children:NC[e.mode]})]});case"safe-tool":return fn(Po,{children:[n,Xe(f,{name:o?"accent":"fg",children:e.tool}),Xe(f,{name:"fgDim",children:" = "}),Xe(f,{name:e.decision==="allow"?"success":"fgDim",children:e.decision})]});case"grant":return fn(Po,{children:[n,Xe(f,{name:"success",children:"\u25CF "}),Xe(f,{name:o?"accent":"fg",children:e.grantKey}),Xe(f,{name:"fgDim",children:" (enter revoga)"})]});case"locked":{let r=e.category.lock==="deny";return fn(Po,{flexDirection:"column",children:[fn(Po,{children:[n,Xe(B,{name:"ask",role:"danger"}),Xe(f,{name:"danger",children:" [travado] "}),Xe(f,{name:o?"accent":"fg",children:e.category.label}),fn(f,{name:"danger",children:[" \xB7 ",r?"deny (nem --yolo)":"sempre pergunta"]})]}),o&&Xe(Po,{paddingLeft:4,children:Xe(f,{name:"fgDim",children:e.category.why})})]})}}}function FC(t){let e=Math.max(1,t.maxRows??14),o=t.columns,n=l=>{switch(l.kind){case"mode":return 8+ke(NC[l.mode]);case"safe-tool":return 5+ke(l.tool)+ke(l.decision);case"grant":return 19+ke(l.grantKey);case"locked":return 28+ke(l.category.label)}},r=o!==void 0&&o>0?l=>Math.max(1,Math.ceil(n(l)/o)):void 0,{start:s,slice:i}=$r(t.rows,t.selected,e,r),a=null;return fn(Po,{flexDirection:"column",children:[Xe(Po,{children:Xe(f,{name:"fgDim",children:"permissoes \xB7 \u2191\u2193 navega \xB7 enter muda \xB7 esc fecha"})}),fn(Po,{children:[Xe(f,{name:"fgDim",children:"modo atual: "}),Xe(f,{name:t.mode==="unsafe"?"danger":"fg",children:NC[t.mode]})]}),t.rows.length===0?Xe(Po,{children:Xe(f,{name:"fgDim",children:" nada a mostrar"})}):fn(Ane,{children:[s>0&&Xe(Po,{children:fn(f,{name:"fgDim",children:[" \u2191 ",s," acima"]})}),i.map((l,c)=>{let d=s+c,m=l.kind!==a?Sne(l.kind):null;return a=l.kind,fn(kne.Fragment,{children:[m&&Xe(Po,{paddingTop:1,children:fn(f,{name:"fgDim",children:["\u2500\u2500\u2500 ",m]})}),Xe(wne,{row:l,sel:d===t.selected})]},Ene(l,d))}),s+i.length<t.rows.length&&Xe(Po,{children:fn(f,{name:"fgDim",children:[" \u2193 ",t.rows.length-(s+i.length)," abaixo"]})})]}),Xe(Po,{paddingTop:1,children:Xe(xne,{children:" "})}),Xe(Po,{children:Xe(f,{name:"fgDim",children:"o painel n\xE3o relaxa as categorias travadas \u2014 o \xFAnico bypass total \xE9 --yolo"})})]})}function Ene(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}`}}var NC,O2=g(()=>{"use strict";ee();Oc();Nt();NC={plan:"PLAN (read-only)",normal:"NORMAL (catraca padr\xE3o)",unsafe:"YOLO (aprova\xE7\xE3o DESLIGADA)"}});import"react";import{Box as $C}from"ink";import{jsx as df,jsxs as BC}from"react/jsx-runtime";function tb(t){let{t:e}=Se();return BC($C,{flexDirection:"column",children:[df($C,{children:df(f,{name:"fgDim",children:e("picker.theme.help")})}),t.themes.map((o,n)=>{let r=n===t.selected,s=o.name===t.currentTheme;return BC($C,{children:[df(f,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),df(f,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),df(f,{name:r?"accent":"fg",children:o.label}),BC(f,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.name)})]})}var M2=g(()=>{"use strict";ee();St()});import"react";import{Box as UC}from"ink";import{jsx as uf,jsxs as jC}from"react/jsx-runtime";function ob(t){let{t:e}=Se();return jC(UC,{flexDirection:"column",children:[uf(UC,{children:uf(f,{name:"fgDim",children:e("picker.lang.help")})}),t.langs.map((o,n)=>{let r=n===t.selected,s=o.code===t.currentLang;return jC(UC,{children:[uf(f,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),uf(f,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),uf(f,{name:r?"accent":"fg",children:o.label}),jC(f,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.code)})]})}var L2=g(()=>{"use strict";ee();St()});import"react";import{Box as mf}from"ink";import{jsx as di,jsxs as ff}from"react/jsx-runtime";function HC(t){let{t:e}=Se(),o=Math.max(1,t.maxRows??10),n=t.columns,r=n!==void 0&&n>0?a=>{let l=4+ke(`${a.label} \xB7 ${a.summary}`)+(a.isDefault?2+ke(e("picker.provider.default")):0);return Math.max(1,Math.ceil(l/n))}:void 0,{start:s,slice:i}=$r(t.providers,t.selected,o,r);return ff(mf,{flexDirection:"column",children:[di(mf,{children:di(f,{name:"fgDim",children:e("picker.provider.help")})}),t.usingFallback===!0?di(mf,{children:di(f,{name:"fgDim",children:e("picker.provider.fallback")})}):null,i.map((a,l)=>{let c=s+l===t.selected,d=a.name===t.currentProvider;return ff(mf,{children:[di(f,{name:c?"accent":"fgDim",children:c?"\u203A ":" "}),di(f,{name:d?"accent":"fgDim",children:d?"\u25CF ":" "}),di(f,{name:c?"accent":"fg",children:a.label}),ff(f,{name:"fgDim",children:[" \xB7 ",a.summary]}),a.isDefault?ff(f,{name:"fgDim",children:[" \xB7 ",e("picker.provider.default")]}):null]},a.name)}),t.providers.length>i.length&&di(mf,{children:ff(f,{name:"fgDim",children:[" ",e("picker.provider.more",{count:t.providers.length-i.length})]})})]})}var P2=g(()=>{"use strict";ee();St();Nt();Oc()});import"react";import{Box as I2,Text as Cne}from"ink";import{jsx as qC,jsxs as N2}from"react/jsx-runtime";function WC(t){if(t.chips.length===0)return null;let e=t.active??-1;return qC(I2,{flexWrap:"wrap",children:t.chips.map((o,n)=>{let r=n===e;return N2(I2,{marginRight:1,children:[N2(f,{name:r?"accent":"depth",children:[r?"\u203A ":"","@",o.path,o.truncated?"~":""]}),qC(Cne,{children:" "}),qC(f,{name:"fgDim",children:"[\u232B]"})]},o.path)})})}var F2=g(()=>{"use strict";ee()});import"react";import{Box as pf,Text as $2}from"ink";import{jsx as rr,jsxs as ui}from"react/jsx-runtime";function GC(t){let e=V(),{t:o}=Se(),n=t.columns??80,r=t.plan??"assinatura",s=e.glyph("wave").repeat(17);return ui(pf,{flexDirection:"column",paddingY:1,children:[rr(fs,{columns:n}),rr(pf,{paddingTop:1,paddingLeft:2,children:rr(f,{name:"fgDim",children:o("boot.tagline")})}),ui(pf,{paddingLeft:2,children:[rr(f,{name:"accent",children:s}),t.version!==void 0&&ui(f,{name:"fgDim",children:[" v",t.version]})]}),ui(pf,{paddingLeft:2,children:[rr(B,{name:"window",role:"fgDim"}),ui(f,{name:"fgDim",children:[" ",r," \xB7 "]}),rr(f,{name:"fgDim",children:t.tier}),rr($2,{children:" "}),rr(f,{name:"fgDim",children:"\xB7 "}),rr(B,{name:"broker",role:"depth"}),ui(f,{name:"depth",children:[" ",o("boot.broker")]})]}),t.status!==void 0&&ui(pf,{paddingTop:1,paddingLeft:2,children:[rr(Sa,{frame:t.frame??0}),rr($2,{children:" "}),ui(f,{name:"fgDim",children:[t.status,"\u2026"]})]})]})}var B2=g(()=>{"use strict";ee();St();Jm();ha()});import"react";import{Box as U2}from"ink";import{jsx as zC,jsxs as KC}from"react/jsx-runtime";function YC(t){let e=t.suggestions??Tne;return KC(U2,{flexDirection:"column",children:[zC(f,{name:"fg",children:t.name?`bom te ver de novo, ${t.name}.`:"bom te ver por aqui."}),zC(f,{name:"fgDim",children:"eu leio e edito arquivos e rodo comandos aqui \u2014 sempre te mostrando o efeito exato antes."}),KC(U2,{paddingTop:1,flexDirection:"column",children:[zC(f,{name:"fgDim",children:"experimente:"}),e.map((o,n)=>KC(f,{name:"fgDim",children:[" \xB7 ",o]},n))]})]})}var Tne,j2=g(()=>{"use strict";ee();Tne=['"explique a estrutura deste repo"','"rode os testes e resuma as falhas"',"/help para comandos \xB7 /login conta \xB7 /quit"]});import"react";import{jsx as kLe}from"react/jsx-runtime";var H2=g(()=>{"use strict";ee()});import"react";import{Box as Dne}from"ink";import{jsx as _ne,jsxs as q2}from"react/jsx-runtime";function VC(t){let{t:e}=Se(),o=(t.columns??80)<60,n=e(o?"banner.yolo.narrow":"banner.yolo");return q2(Dne,{children:[_ne(B,{name:"ask",role:"danger"}),q2(f,{name:"danger",children:[" ",n]})]})}var XC=g(()=>{"use strict";ee();St()});import"react";import{Box as Rne}from"ink";import{jsx as W2,jsxs as JC}from"react/jsx-runtime";function nb(t){let{t:e}=Se();if(t.mode==="unsafe")return W2(VC,{...t.columns!==void 0?{columns:t.columns}:{}});let o=One[t.mode],n=(t.columns??80)<60;return JC(Rne,{children:[W2(B,{name:o.glyph,role:o.role}),JC(f,{name:o.role,children:[" ",e("mode.label")," ",o.word]}),!n&&JC(f,{name:"fgDim",children:[" \xB7 ",e(o.caption)]})]})}var One,G2=g(()=>{"use strict";ee();XC();St();One={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"}}});import"react";import{jsx as QC}from"react/jsx-runtime";function gf(t){let{t:e}=Se();if(t.armedExit===!0)return QC(f,{name:"accent",children:e("hints.ctrlcAgain")});let o=e(Mne[t.state]),n=t.elapsed!==void 0&&t.elapsed!==""&&Lne.has(t.state);return t.suggesting===!0&&t.state==="idle"?QC(f,{name:"fgDim",children:`${o} \xB7 ${e("hints.suggest")}`}):QC(f,{name:"fgDim",children:n?`${o} \xB7 ${t.elapsed}`:o})}var Mne,Lne,z2=g(()=>{"use strict";ee();St();Mne={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"},Lne=new Set(["thinking","streaming","work-subagents"])});import"react";import{Box as ZC}from"ink";import{jsx as eT,jsxs as tT}from"react/jsx-runtime";function rb(t){return tT(ZC,{flexDirection:"column",children:[tT(ZC,{children:[eT(B,{name:"clock",role:"depth"}),tT(f,{name:"depth",children:[" ",t.title]})]}),eT(ZC,{flexDirection:"column",paddingLeft:2,children:t.lines.map((e,o)=>eT(f,{name:"fgDim",children:e},o))})]})}var K2=g(()=>{"use strict";ee()});import"react";import{Box as Ra,Text as Pne}from"ink";import{jsx as sr,jsxs as Fn}from"react/jsx-runtime";function oT(t){let e=V();if(t.status==="running"){let a=Mr(t.liveOutput??"",Ec).replace(/\n+$/,""),l=t.columns&&t.columns>0?t.columns-Ine:0,{text:c,hidden:d}=ms(a,t.maxLines,l);return Fn(Ra,{flexDirection:"column",paddingLeft:2,children:[sr(Aa,{glyph:"toolInflight",glyphRole:"depth",label:`rodando $ ${t.command}`,...t.frame!==void 0?{frame:t.frame}:{}}),c.length>0&&Fn(Ra,{flexDirection:"column",paddingLeft:2,children:[d>0&&Fn(f,{name:"fgDim",children:["\u2026 (",d," linhas acima)"]}),c.split(`
@@ -1,4 +1,4 @@
1
- var E$=Object.create;var Jh=Object.defineProperty;var w$=Object.getOwnPropertyDescriptor;var A$=Object.getOwnPropertyNames;var C$=Object.getPrototypeOf,T$=Object.prototype.hasOwnProperty;var C=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var D$=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}},Qh=(t,e)=>{for(var o in e)Jh(t,o,{get:e[o],enumerable:!0})},_$=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A$(e))!T$.call(t,r)&&r!==o&&Jh(t,r,{get:()=>e[r],enumerable:!(n=w$(e,r))||n.enumerable});return t};var R$=(t,e,o)=>(o=t!=null?E$(C$(t)):{},_$(e||!t||!t.__esModule?Jh(o,"default",{value:t,enumerable:!0}):o,t));var Ol,Dw=C(()=>{"use strict";Ol="1.0.0-rc.110"});function mn(t,e){return t.decide(e)}var ws=C(()=>{"use strict"});var In,ar,lr=C(()=>{"use strict";In="remember",ar="recall"});var Zh,M$,Ki,eg=C(()=>{"use strict";Zh=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}}},M$=200,Ki=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??M$,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 Zh(e,o,n,r??null,i);if(r){let l=this.nodes.get(r);l&&l.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,l=r.closed?0:1;return a!==l?a-l: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 tm(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 Mw(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"&&O$.has(i.status)&&(n=i.status),e){let l=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(l)&&l.length>0){let c=[];for(let d of l){let m=Mw(d,!1);if(typeof m=="string")return m;c.push(m)}r=c}}}if(o===void 0||o.trim()==="")return P$;let s=o.trim().slice(0,L$);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function F$(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=Mw(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 l=`${i} #${a}`;if(!n.has(l))return n.add(l),l}};for(let i=0;i<o.length;i++){let a=o[i],l=r(a.title),c=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=c!==void 0?{...a,title:l,substeps:c}:{...a,title:l}}let s=tm(o).length;return s>_w?{error:`update_plan: no m\xE1ximo ${_w} passos (recebidos ${s}).`}:{steps:o}}function I$(t){let e=tm(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${Ow[r.step.status]} ${r.step.title}`).join(`
1
+ var E$=Object.create;var Jh=Object.defineProperty;var w$=Object.getOwnPropertyDescriptor;var A$=Object.getOwnPropertyNames;var C$=Object.getPrototypeOf,T$=Object.prototype.hasOwnProperty;var C=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var D$=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}},Qh=(t,e)=>{for(var o in e)Jh(t,o,{get:e[o],enumerable:!0})},_$=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A$(e))!T$.call(t,r)&&r!==o&&Jh(t,r,{get:()=>e[r],enumerable:!(n=w$(e,r))||n.enumerable});return t};var R$=(t,e,o)=>(o=t!=null?E$(C$(t)):{},_$(e||!t||!t.__esModule?Jh(o,"default",{value:t,enumerable:!0}):o,t));var Ol,Dw=C(()=>{"use strict";Ol="1.0.0-rc.111"});function mn(t,e){return t.decide(e)}var ws=C(()=>{"use strict"});var In,ar,lr=C(()=>{"use strict";In="remember",ar="recall"});var Zh,M$,Ki,eg=C(()=>{"use strict";Zh=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}}},M$=200,Ki=class{nodes=new Map;maxBoxes;now;constructor(e){this.maxBoxes=e?.maxBoxes??M$,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 Zh(e,o,n,r??null,i);if(r){let l=this.nodes.get(r);l&&l.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,l=r.closed?0:1;return a!==l?a-l: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 tm(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 Mw(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"&&O$.has(i.status)&&(n=i.status),e){let l=i.substeps??i.subtasks??i.subpassos??i.children;if(Array.isArray(l)&&l.length>0){let c=[];for(let d of l){let m=Mw(d,!1);if(typeof m=="string")return m;c.push(m)}r=c}}}if(o===void 0||o.trim()==="")return P$;let s=o.trim().slice(0,L$);return r?{title:s,status:n,substeps:r}:{title:s,status:n}}function F$(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=Mw(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 l=`${i} #${a}`;if(!n.has(l))return n.add(l),l}};for(let i=0;i<o.length;i++){let a=o[i],l=r(a.title),c=a.substeps?.map(d=>({...d,title:r(d.title)}));o[i]=c!==void 0?{...a,title:l,substeps:c}:{...a,title:l}}let s=tm(o).length;return s>_w?{error:`update_plan: no m\xE1ximo ${_w} passos (recebidos ${s}).`}:{steps:o}}function I$(t){let e=tm(t),o=e.filter(r=>r.step.status==="completed").length,n=e.map(r=>`${" ".repeat(r.depth)}${Ow[r.step.status]} ${r.step.title}`).join(`
2
2
  `);return`plano (${o}/${e.length}):
3
3
  ${n}`}function $$(t,e){return e<0?"m\xE9dio":t===e?"curto":t>e?"longo":"m\xE9dio"}function B$(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,l)=>{let c=i.status==="in_progress"?"curto":l,d=o.get(i.title),m=d??Ki.boxId(i.title,0);return d?(i.status!=="completed"&&e.isClosed(d)&&e.reopenBox(d),e.setHorizon(d,c),e.setParent(d,a)):e.openBox(m,c,i.title,a),i.status==="completed"&&!e.isClosed(m)&&e.closeBox(m),o.set(i.title,m),m};t.forEach((i,a)=>{let l=$$(a,n),c=r(i,null,l);for(let d of i.substeps??[])r(d,c,l)});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 U$(t,e){if(!e)return I$(t);let o=new Map;for(let c of e.listBoxes())o.set(c.label,c);let n=new Map;for(let c of e.listBoxes())n.set(c.id,c);let r=new Map,s=(c,d=new Set)=>{let m=r.get(c);if(m!==void 0)return m;let u=n.get(c);if(!u||!u.parentId||d.has(c))return r.set(c,0),0;let p=s(u.parentId,new Set(d).add(c))+1;return r.set(c,p),p},i=tm(t),l=[`plano (${i.filter(c=>c.step.status==="completed").length}/${i.length}):`];for(let{step:c,depth:d}of i){let m=o.get(c.title),u=m?N$[m.horizon]:"",p=m?s(m.id):d,h=" ".repeat(p),y=Ow[c.status];l.push(`${h}${u} ${y} ${c.title}`)}return l.join(`
4
4
  `)}var Ll,O$,_w,L$,P$,Ow,N$,Rw,j$,Lw,om=C(()=>{"use strict";eg();Ll="update_plan";O$=new Set(["pending","in_progress","completed"]),_w=30,L$=120,P$="update_plan: cada passo precisa de um t\xEDtulo (texto) n\xE3o-vazio.";Ow={pending:"\u2610",in_progress:"\u25B6",completed:"\u2611"};N$={longo:"[\u{1F4D0}]",m\u00E9dio:"[\u{1F4CB}]",curto:"[\u{1F4CC}]"};Rw=Object.freeze({type:"string",enum:["pending","in_progress","completed"],description:"pending (a fazer) \xB7 in_progress (em curso) \xB7 completed (feito)."}),j$=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:Rw,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:Rw},required:["title"],additionalProperties:!1}}},required:["title"],additionalProperties:!1}}},required:["steps"],additionalProperties:!1}),Lw={name:Ll,effect:"read",group:"plano",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:j$,async run(t,e){let o=F$(t);return"error"in o?{ok:!1,observation:o.error}:(e.graph&&B$(o.steps,e.graph),e.plan&&e.plan.set(tm(o.steps).map(r=>({title:r.step.title,status:r.step.status}))),{ok:!0,observation:U$(o.steps,e.graph)})}}});function Pw(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)?q$(s):void 0;if(typeof i=="string")return{error:i};let a,l=t.kind??t.type;if(typeof l=="string"&&H$.has(l))a=l;else{if(typeof l=="string"&&l.trim()!=="")return{error:`perguntar: "kind" inv\xE1lido "${l}". 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 c=t.allowOther!==!1;return{spec:{kind:a,question:o,...r!==void 0?{header:r}:{},...a!=="text"&&i!==void 0?{options:i}:{},...a!=="text"?{allowOther:c}:{}}}}function q$(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 W$(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(`
@@ -140,7 +140,7 @@ ${t.trim()}`}}function p_(t,e,o=td){let{older:n,recent:r}=Mf(t,o);if(n.length===
140
140
  `;case"t":return" ";case"r":return"\r";case'"':return'"';case"\\":return"\\";default:throw new fe(`config.toml:${e}: escape n\xE3o suportado "\\${i}".`)}})}function P8(t,e,o){let n=e.trim();if(!n.startsWith("[")||!n.endsWith("]"))throw new fe(`config.toml:${o}: ${t} deve ser um array de strings em uma linha.`);let r=n.slice(1,-1).trim();if(r.length===0)return[];let s=[];for(let i of Y_(r,",")){let a=i.trim();if(a.length===0)continue;let l=dk(a,o);if(l===void 0)throw new fe(`config.toml:${o}: ${t} \u2014 todo item deve ser string.`);s.push(l)}return s}function F8(t,e,o){let n=e.trim();if(!n.startsWith("{")||!n.endsWith("}"))throw new fe(`config.toml:${o}: ${t} deve ser uma tabela inline { K = "v" }.`);let r=n.slice(1,-1).trim(),s={};if(r.length===0)return s;for(let i of Y_(r,",")){let a=i.trim();if(a.length===0)continue;let l=K_(a);if(l===-1)throw new fe(`config.toml:${o}: ${t} \u2014 esperava K = "v".`);let c=ck(a.slice(0,l).trim(),o);if(c.length!==1)throw new fe(`config.toml:${o}: ${t} \u2014 chave inv\xE1lida.`);let d=dk(a.slice(l+1).trim(),o);if(d===void 0)throw new fe(`config.toml:${o}: ${t}["${c[0]}"] deve ser string.`);s[c[0]]=d}return s}function Y_(t,e){let o=[],n=0,r=!1,s="",i=0;for(let a=0;a<t.length;a++){let l=t[a];r?l===s&&t[a-1]!=="\\"&&(r=!1):l==='"'||l==="'"?(r=!0,s=l):l==="["||l==="{"?n++:l==="]"||l==="}"?n--:l===e&&n===0&&(o.push(t.slice(i,a)),i=a+1)}return o.push(t.slice(i)),o}var _8,V_=C(()=>{"use strict";Uf();_8="mcp_servers"});function $8(t){if(t.length<20||/\s/.test(t)||/^[~./]/.test(t)||!/^[A-Za-z0-9_\-+/=.]+$/.test(t))return!1;let e=/[A-Z]/.test(t),o=/[a-z]/.test(t),n=/[0-9]/.test(t);return(e?1:0)+(o?1:0)+(n?1:0)>=2||t.length>=32}function B8(t){let e=t.toLowerCase();return I8.some(o=>e.includes(o))}function uk(t,e){if(N8.test(e.trim()))return{looksLikeSecret:!1,signals:[]};let o=[];return e.length>0&&B8(t)&&o.push("secret-key-name"),$8(e)&&o.push("high-entropy"),{looksLikeSecret:o.length>0,signals:o}}var I8,N8,X_=C(()=>{"use strict";I8=["token","secret","password","passwd","apikey","api_key","access_key","accesskey","private_key","privatekey","credential","auth"],N8=/^\$\{?[A-Za-z_][A-Za-z0-9_]*\}?$|^%[A-Za-z_][A-Za-z0-9_]*%$/});function U8(t,e){return`mcp__${t}__${e}`}function j8(t){return t==="aluy-global"||t==="project"}function id(t,e){let o=[],n=new Map;for(let{origin:s,config:i}of t)for(let a of i.servers)n.has(a.name)||o.push(a.name),n.set(a.name,{origin:s,server:a});let r=e?H8(e):void 0;return o.map(s=>{let{origin:i,server:a}=n.get(s),l=r?.get(s),c=a.disabled===!0?{kind:"disabled"}:l?l.ok?{kind:"ok",toolCount:l.tools.length}:{kind:"error",error:l.error??"falha na conex\xE3o"}:{kind:"unknown"},d=c.kind==="ok"&&l?l.tools:[];return{name:s,origin:i,command:a.command,args:a.args,envKeys:Object.keys(a.env),managed:j8(i),state:c,tools:d}})}function H8(t){let e=new Map;for(let o of t.servers){let n=o.tools.map(r=>({qualifiedName:U8(o.server,r.descriptor.name),...r.descriptor.description!==void 0?{description:r.descriptor.description}:{}}));e.set(o.server,{ok:o.ok,...o.error!==void 0?{error:o.error}:{},tools:n})}return e}function ad(t){if(t.command.trim()!=="--")return;let e=t.args.length>0?t.args.join(" "):"<command> [args...]";return`server "${t.name}" com command inv\xE1lido "--" (separador gravado por engano \u2014 nunca vai conectar). Re-adicione: aluy mcp add ${t.name} --force -- ${e}`}function mk(t){switch(t){case"aluy-global":return"~/.aluy/mcp.json";case"project":return".mcp.json (projeto)";case"codex":return"~/.codex (Codex)"}}var J_=C(()=>{"use strict"});var Q_=C(()=>{"use strict"});function q8(t){return t instanceof Error?t.message:String(t)}async function ld(t,e,o){let n=t.servers.filter(l=>l.disabled!==!0),r=await Promise.all(n.map(async l=>{let c=e(l);try{let m=(await c.connect(l)).map(p=>({server:l.name,descriptor:p,transport:c})),u={server:l.name,ok:!0,tools:m};return o?.onServerResult?.(u),{result:u,transport:c}}catch(d){Z_(c);let m={server:l.name,ok:!1,tools:[],error:q8(d)};return o?.onServerResult?.(m),{result:m}}})),s=[],i=[],a=[];for(let l of r)s.push(l.result),i.push(...l.result.tools),l.transport&&a.push(l.transport);return{servers:s,tools:i,transports:a}}async function fk(t){await Promise.all(t.map(e=>Z_(e)))}async function Z_(t){try{await t.close()}catch{}}var eR=C(()=>{"use strict";Uf()});function nR(t,e){let o=new URL(oR);return t.trim().length>0&&o.searchParams.set("search",t.trim()),o.searchParams.set("limit",String(G8)),e!==void 0&&e.length>0&&o.searchParams.set("cursor",e),o.toString()}async function hk(t,e,o){let n=t.trim(),r=[],s;for(let i=0;i<W8;i++){let a=nR(n,s),l;try{l=await e(a,o)}catch(m){return{ok:!1,query:n,reason:jf(J8(m))}}if(!l.ok)return{ok:!1,query:n,reason:jf(l.reason)};if(l.status<200||l.status>=300)return{ok:!1,query:n,reason:jf(`HTTP ${l.status}`)};let c;try{c=JSON.parse(l.body)}catch{return{ok:!1,query:n,reason:jf("resposta n\xE3o \xE9 JSON v\xE1lido")}}let d=sR(c);for(let m of d.servers)if(rR(m,n)&&r.push(m),r.length>=pk)break;if(r.length>=pk||(s=d.nextCursor,s===void 0||s.length===0))break}return{ok:!0,query:n,results:r}}function jf(t){return`registro MCP indispon\xEDvel (${Ra}): ${t}`}function rR(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 sR(t){if(!gr(t))return{servers:[]};let e=Array.isArray(t.servers)?t.servers:[],o=[];for(let s of e){let i=z8(s);i!==void 0&&o.push(i)}let n=gr(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 z8(t){if(!gr(t))return;let e=gr(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=K8(e);return{name:o,description:n,run:i,...r!==void 0?{title:r}:{},...s!==void 0?{version:s}:{}}}function K8(t){let e=[],o=Array.isArray(t.remotes)?t.remotes:[];for(let r of o)gr(r)&&typeof r.url=="string"&&e.push(r.url);let n=Array.isArray(t.packages)?t.packages:[];for(let r of n){if(!gr(r))continue;let s=Y8(r);if(s!==void 0)return{...s,remoteUrls:e}}return{args:[],env:[],remoteUrls:e}}function Y8(t){let e=Vs(t.registryType)??Vs(t.registry_name),o=Vs(t.identifier)??Vs(t.name);if(o===void 0)return;let n=Vs(t.version),r=Vs(t.runtimeHint),s=gr(t.transport)?Vs(t.transport.type):void 0,i=X8(t.environmentVariables),a=tR(t.runtimeArguments),l=tR(t.packageArguments),c=n!==void 0?`${o}@${n}`:o;return e==="npm"||r==="npx"?{command:"npx",args:V8(["-y",...a,c,...l]),env:i,...s!==void 0?{transport:s}:{}}:e==="pypi"||r==="uvx"||r==="uv"?{command:"uvx",args:[...a,o,...l],env:i,...s!==void 0?{transport:s}:{}}:e==="oci"||r==="docker"?{command:"docker",args:["run","-i","--rm",...a,c,...l],env:i,...s!==void 0?{transport:s}:{}}:{args:[c],env:i,...s!==void 0?{transport:s}:{}}}function V8(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 tR(t){if(!Array.isArray(t))return[];let e=[];for(let o of t)gr(o)&&typeof o.value=="string"&&e.push(o.value);return e}function X8(t){if(!Array.isArray(t))return[];let e=[];for(let o of t)gr(o)&&typeof o.name=="string"&&o.name.length>0&&e.push({name:o.name,required:o.isRequired===!0});return e}function Vs(t){return typeof t=="string"&&t.trim().length>0?t.trim():void 0}function gr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function J8(t){return t instanceof Error?t.message:String(t)}var Ra,oR,W8,G8,pk,iR=C(()=>{"use strict";Ra="registry.modelcontextprotocol.io",oR=`https://${Ra}/v0/servers`,W8=5,G8=100,pk=25});function lR(t){let{command:e,args:o}=t.run;if(e===void 0)return;let n=cR(t.name);return["aluy","mcp","add",aR(n),"--",e,...o.map(aR)].join(" ")}function cR(t){let o=(t.split("/").pop()??t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return o.length>0?o:"server"}function aR(t){return/^[A-Za-z0-9_./@:+=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function gk(t){if(!t.ok)return`\u26A0 ${t.reason}
141
141
  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(Q8(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(`
142
142
  `)}function Q8(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(` ${Z8(t.description,200)}`);let r=lR(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(`
143
- `)}function Z8(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"\u2026"}var dR=C(()=>{"use strict"});var uR=C(()=>{"use strict";Uf();V_();X_();J_();Q_();eR();sb();sm();iR();dR()});function yk(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 mR(t,e){let o=yk(t),n=yk(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 l=typeof i=="number",c=typeof a=="number";return l&&c?i<a?-1:1:l?-1:c?1:i<a?-1:1}return 0}function bk(t,e){return mR(t,e)===1}var fR=C(()=>{"use strict"});function Hf(t,e,o){if(e.size===0)return{kind:"discard",reason:"allowlist vazia (default fechado)"};if(!e.has(t.conversation))return{kind:"discard",reason:`canal ${t.conversation} n\xE3o-allowlistado`};if(t.senderIsBot===!0)return{kind:"discard",reason:"remetente \xE9 bot (anti-loop, TC-6)"};let n=t.content.trim();if(n==="")return{kind:"discard",reason:"mensagem sem conte\xFAdo"};if(o.authIsForgeable)return{kind:"data",text:n};if(t.provenance.kind==="third-party-relayed")return{kind:"data",text:n};let r=t.provenance.embeddedThirdParty?.trim();return r?{kind:"instruction",text:n,forwardedData:r}:{kind:"instruction",text:n}}var vk=C(()=>{"use strict"});function kk(t){let e;if(t.forwarded===!0)e={kind:"third-party-relayed"};else{let o=(t.quotedText??"").trim();e=o?{kind:"author-direct",embeddedThirdParty:o}:{kind:"author-direct"}}return{content:t.text,sender:String(t.fromId),conversation:String(t.chatId),provenance:e,...t.isBot===!0?{senderIsBot:!0}:{}}}function xk(t){let e=new Set;for(let o of t)typeof o=="number"&&Number.isFinite(o)&&Number.isInteger(o)&&e.add(o);return e}var cd,pR=C(()=>{"use strict";vk();cd={id:"telegram",displayName:"Telegram",authIsForgeable:!1}});function Sk(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ma(t){return typeof t=="object"&&t!==null?t:void 0}function Ek(t,e){let o=Ma(t);if(!o||o.ok!==!0||!Array.isArray(o.result))return{updates:[],nextOffset:e};let n=[],r=e-1;for(let s of o.result){let i=Ma(s);if(!i)continue;let a=Sk(i.update_id);a!==void 0&&a>r&&(r=a);let l=Ma(i.message);if(!l)continue;let c=Ma(l.chat),d=Sk(c?.id);if(d===void 0||c?.type!=="private")continue;let m=Ma(l.from),u=Sk(m?.id)??d,p=m?.is_bot===!0,h=typeof l.text=="string"?l.text:"",y=l.forward_origin!==void 0||l.forward_from!==void 0||l.forward_from_chat!==void 0||l.forward_sender_name!==void 0||l.forward_date!==void 0,g=(()=>{let E=Ma(l.quote)?.text;return typeof E=="string"&&E.trim()!==""?E:void 0})();n.push({chatId:d,fromId:u,text:h,...y?{forwarded:!0}:{},...g!==void 0?{quotedText:g}:{},...p?{isBot:!0}:{}})}return{updates:n,nextOffset:r+1}}var hR=C(()=>{"use strict"});var dd,gR=C(()=>{"use strict";dd=class{maxPerWindow;windowMs;stamps=[];constructor(e,o){this.maxPerWindow=e,this.windowMs=o}tryConsume(e){let o=e-this.windowMs;for(;this.stamps.length>0&&this.stamps[0]<=o;)this.stamps.shift();return this.stamps.length>=this.maxPerWindow?!1:(this.stamps.push(e),!0)}get used(){return this.stamps.length}}});function wk(t){return`connector-${t}-token`}function ud(t){let e=t.trim(),o=e.indexOf(":");return o<=0?`\u2026(${e.length} chars)`:`${e.slice(0,o)}:\u2026(${e.length-o-1} chars)`}function Ak(t,e){let o=e.trim();return o.length<8?t:t.split(o).join("\xABREDACTED\xBB")}var yR=C(()=>{"use strict"});var B=C(()=>{"use strict";Dw();eA();mA();NC();$_();xv();z_();uR();tk();yf();fR();vk();pR();hR();gR();yR()});import{posix as vW}from"node:path";function kW(t){return vW.normalize(t)}function Eo(t){let e=kW(t);for(let o of xW)if(o.re.test(e))return o.deny?{kind:"deny",why:o.why}:{kind:"ask",why:o.why};return{kind:"allow"}}function qk(t){return Eo(t).kind==="allow"}var xW,es=C(()=>{"use strict";xW=[{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 mx={};Qh(mx,{UserWorkflowsLoader:()=>Wn,WORKFLOWS_DIRNAME:()=>ux});import{homedir as d6}from"node:os";import{join as dx}from"node:path";import{readdirSync as u6,readFileSync as m6,mkdirSync as f6,statSync as p6}from"node:fs";var h6,ux,g6,y6,Wn,lp=C(()=>{"use strict";B();h6=448,ux="workflows",g6=64*1024,y6=256,Wn=class{dir;constructor(e={}){let o=e.baseDir??dx(d6(),".aluy");this.dir=dx(o,ux)}get workflowsDir(){return this.dir}ensureDir(){try{f6(this.dir,{mode:h6,recursive:!0})}catch{}}load(){let e;try{e=u6(this.dir,{withFileTypes:!0})}catch{return{workflows:[],errors:[]}}let o=e.filter(i=>(i.isFile()||i.isSymbolicLink())&&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>=y6)break;let a=this.readOne(i);if(a!==null){if(Uc(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=dx(this.dir,e);try{let n=p6(o);if(!n.isFile()||n.size>g6)return null;let r=m6(o,"utf8");return jc(e,r,"global")}catch{return null}}}});var px={};Qh(px,{PROJECT_WORKFLOWS_DIRNAMES:()=>fx,ProjectWorkflowsLoader:()=>Gn});import{join as b6}from"node:path";import{readdirSync as v6,readFileSync as k6,statSync as x6}from"node:fs";var fx,S6,E6,Gn,cp=C(()=>{"use strict";B();es();fx=[".claude/workflows",".aluy/workflows"],S6=64*1024,E6=256,Gn=class{workspace;constructor(e){this.workspace=e.workspace}load(){let e=new Set,o=[],n=[];for(let r of fx){let s;try{s=this.workspace.resolveInside(r)}catch{continue}let i;try{i=v6(s,{withFileTypes:!0})}catch{continue}let a=i.filter(l=>(l.isFile()||l.isSymbolicLink())&&l.name.toLowerCase().endsWith(".md")).map(l=>l.name).sort((l,c)=>l.localeCompare(c));for(let l of a){if(o.length>=E6)break;let c=this.readOne(r,s,l);if(c!==null){if(Uc(c)){n.push(c);continue}e.has(c.name)||(e.add(c.name),o.push(c))}}}return{workflows:o,errors:n}}readOne(e,o,n){let r=`${e}/${n}`;if(Eo(r).kind!=="allow")return null;let s=b6(o,n);try{this.workspace.resolveInside(r);let i=x6(s);if(!i.isFile()||i.size>S6)return null;let a=k6(s,"utf8");return jc(n,a,"project")}catch{return null}}}});var zF=D$((NSe,GF)=>{GF.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var un="1.0.0-rc.110";B();var bR=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
143
+ `)}function Z8(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"\u2026"}var dR=C(()=>{"use strict"});var uR=C(()=>{"use strict";Uf();V_();X_();J_();Q_();eR();sb();sm();iR();dR()});function yk(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 mR(t,e){let o=yk(t),n=yk(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 l=typeof i=="number",c=typeof a=="number";return l&&c?i<a?-1:1:l?-1:c?1:i<a?-1:1}return 0}function bk(t,e){return mR(t,e)===1}var fR=C(()=>{"use strict"});function Hf(t,e,o){if(e.size===0)return{kind:"discard",reason:"allowlist vazia (default fechado)"};if(!e.has(t.conversation))return{kind:"discard",reason:`canal ${t.conversation} n\xE3o-allowlistado`};if(t.senderIsBot===!0)return{kind:"discard",reason:"remetente \xE9 bot (anti-loop, TC-6)"};let n=t.content.trim();if(n==="")return{kind:"discard",reason:"mensagem sem conte\xFAdo"};if(o.authIsForgeable)return{kind:"data",text:n};if(t.provenance.kind==="third-party-relayed")return{kind:"data",text:n};let r=t.provenance.embeddedThirdParty?.trim();return r?{kind:"instruction",text:n,forwardedData:r}:{kind:"instruction",text:n}}var vk=C(()=>{"use strict"});function kk(t){let e;if(t.forwarded===!0)e={kind:"third-party-relayed"};else{let o=(t.quotedText??"").trim();e=o?{kind:"author-direct",embeddedThirdParty:o}:{kind:"author-direct"}}return{content:t.text,sender:String(t.fromId),conversation:String(t.chatId),provenance:e,...t.isBot===!0?{senderIsBot:!0}:{}}}function xk(t){let e=new Set;for(let o of t)typeof o=="number"&&Number.isFinite(o)&&Number.isInteger(o)&&e.add(o);return e}var cd,pR=C(()=>{"use strict";vk();cd={id:"telegram",displayName:"Telegram",authIsForgeable:!1}});function Sk(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ma(t){return typeof t=="object"&&t!==null?t:void 0}function Ek(t,e){let o=Ma(t);if(!o||o.ok!==!0||!Array.isArray(o.result))return{updates:[],nextOffset:e};let n=[],r=e-1;for(let s of o.result){let i=Ma(s);if(!i)continue;let a=Sk(i.update_id);a!==void 0&&a>r&&(r=a);let l=Ma(i.message);if(!l)continue;let c=Ma(l.chat),d=Sk(c?.id);if(d===void 0||c?.type!=="private")continue;let m=Ma(l.from),u=Sk(m?.id)??d,p=m?.is_bot===!0,h=typeof l.text=="string"?l.text:"",y=l.forward_origin!==void 0||l.forward_from!==void 0||l.forward_from_chat!==void 0||l.forward_sender_name!==void 0||l.forward_date!==void 0,g=(()=>{let E=Ma(l.quote)?.text;return typeof E=="string"&&E.trim()!==""?E:void 0})();n.push({chatId:d,fromId:u,text:h,...y?{forwarded:!0}:{},...g!==void 0?{quotedText:g}:{},...p?{isBot:!0}:{}})}return{updates:n,nextOffset:r+1}}var hR=C(()=>{"use strict"});var dd,gR=C(()=>{"use strict";dd=class{maxPerWindow;windowMs;stamps=[];constructor(e,o){this.maxPerWindow=e,this.windowMs=o}tryConsume(e){let o=e-this.windowMs;for(;this.stamps.length>0&&this.stamps[0]<=o;)this.stamps.shift();return this.stamps.length>=this.maxPerWindow?!1:(this.stamps.push(e),!0)}get used(){return this.stamps.length}}});function wk(t){return`connector-${t}-token`}function ud(t){let e=t.trim(),o=e.indexOf(":");return o<=0?`\u2026(${e.length} chars)`:`${e.slice(0,o)}:\u2026(${e.length-o-1} chars)`}function Ak(t,e){let o=e.trim();return o.length<8?t:t.split(o).join("\xABREDACTED\xBB")}var yR=C(()=>{"use strict"});var B=C(()=>{"use strict";Dw();eA();mA();NC();$_();xv();z_();uR();tk();yf();fR();vk();pR();hR();gR();yR()});import{posix as vW}from"node:path";function kW(t){return vW.normalize(t)}function Eo(t){let e=kW(t);for(let o of xW)if(o.re.test(e))return o.deny?{kind:"deny",why:o.why}:{kind:"ask",why:o.why};return{kind:"allow"}}function qk(t){return Eo(t).kind==="allow"}var xW,es=C(()=>{"use strict";xW=[{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 mx={};Qh(mx,{UserWorkflowsLoader:()=>Wn,WORKFLOWS_DIRNAME:()=>ux});import{homedir as d6}from"node:os";import{join as dx}from"node:path";import{readdirSync as u6,readFileSync as m6,mkdirSync as f6,statSync as p6}from"node:fs";var h6,ux,g6,y6,Wn,lp=C(()=>{"use strict";B();h6=448,ux="workflows",g6=64*1024,y6=256,Wn=class{dir;constructor(e={}){let o=e.baseDir??dx(d6(),".aluy");this.dir=dx(o,ux)}get workflowsDir(){return this.dir}ensureDir(){try{f6(this.dir,{mode:h6,recursive:!0})}catch{}}load(){let e;try{e=u6(this.dir,{withFileTypes:!0})}catch{return{workflows:[],errors:[]}}let o=e.filter(i=>(i.isFile()||i.isSymbolicLink())&&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>=y6)break;let a=this.readOne(i);if(a!==null){if(Uc(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=dx(this.dir,e);try{let n=p6(o);if(!n.isFile()||n.size>g6)return null;let r=m6(o,"utf8");return jc(e,r,"global")}catch{return null}}}});var px={};Qh(px,{PROJECT_WORKFLOWS_DIRNAMES:()=>fx,ProjectWorkflowsLoader:()=>Gn});import{join as b6}from"node:path";import{readdirSync as v6,readFileSync as k6,statSync as x6}from"node:fs";var fx,S6,E6,Gn,cp=C(()=>{"use strict";B();es();fx=[".claude/workflows",".aluy/workflows"],S6=64*1024,E6=256,Gn=class{workspace;constructor(e){this.workspace=e.workspace}load(){let e=new Set,o=[],n=[];for(let r of fx){let s;try{s=this.workspace.resolveInside(r)}catch{continue}let i;try{i=v6(s,{withFileTypes:!0})}catch{continue}let a=i.filter(l=>(l.isFile()||l.isSymbolicLink())&&l.name.toLowerCase().endsWith(".md")).map(l=>l.name).sort((l,c)=>l.localeCompare(c));for(let l of a){if(o.length>=E6)break;let c=this.readOne(r,s,l);if(c!==null){if(Uc(c)){n.push(c);continue}e.has(c.name)||(e.add(c.name),o.push(c))}}}return{workflows:o,errors:n}}readOne(e,o,n){let r=`${e}/${n}`;if(Eo(r).kind!=="allow")return null;let s=b6(o,n);try{this.workspace.resolveInside(r);let i=x6(s);if(!i.isFile()||i.size>S6)return null;let a=k6(s,"utf8");return jc(n,a,"project")}catch{return null}}}});var zF=D$((NSe,GF)=>{GF.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var un="1.0.0-rc.111";B();var bR=`aluy \u2014 agente de terminal que roda na sua m\xE1quina, com o seu provider de LLM
144
144
 
145
145
  Uso:
146
146
  aluy ["objetivo"] [--plan | --yolo] [--dense] [--tier <tier>] [--lang <pt-BR|en>]
@@ -562,7 +562,7 @@ ${e}${o}${n}
562
562
 
563
563
  Responda APENAS com JSON no formato:
564
564
  {"chosen": "<id da op\xE7\xE3o escolhida>", "confidence": <0.0 a 1.0>, "reasoning": "<racioc\xEDnio curto>"}`}function CL(t,e){let o={chosen:e[0]??"continuar",confidence:0,reasoning:"fallback: parse mal-sucedido, default primeira op\xE7\xE3o",fallback:!0},n=Xx(t);if(n&&Jx(n,e))return Qx(n,!1);let r=n!==void 0,s=t.match(/```(?:json)?\s*([\s\S]*?)```/);if(s?.[1]){let a=Xx(s[1].trim());if(a&&Jx(a,e))return Qx(a,!1);if(a!==void 0)return{...o,fallback:!0}}let i=t.match(/\{[\s\S]*"chosen"[\s\S]*\}/);if(i){let a=Xx(i[0]);if(a&&Jx(a,e))return Qx(a,!1);if(a!==void 0)return{...o,fallback:!0}}if(r)return{...o,fallback:!0};for(let a of e)if(t.includes(a))return{chosen:a,confidence:.5,reasoning:"fallback: id encontrado no texto",fallback:!0};return{...o,fallback:!0}}function Xx(t){try{let e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}catch{return}}function Jx(t,e){let o=t.chosen;if(typeof o!="string"||!e.includes(o))return!1;let n=t.confidence;return!(typeof n!="number"||!Number.isFinite(n)||typeof t.reasoning!="string")}function Qx(t,e){return{chosen:String(t.chosen),confidence:Number(t.confidence),reasoning:String(t.reasoning),fallback:e}}var Yd=class{baseUrl;model;timeoutMs;resolver;fetchFn;onUsed;constructor(e={}){this.baseUrl=e.baseUrl??Zx,this.model=e.model??eS,this.timeoutMs=e.timeoutMs??tS,this.resolver=e.resolver??new zt,this.fetchFn=e.fetchFn??globalThis.fetch,this.onUsed=e.onUsed}report(e){try{this.onUsed?.(e)}catch{}}async judge(e){try{let o=await zs(this.baseUrl,this.resolver);if(!o.ok)return this.fallback(e,`destino recusado: ${o.reason}`);let n=oz(e),r=nz(o.pinnedIp,o.scheme,this.baseUrl),s=new AbortController,i=setTimeout(()=>s.abort(),this.timeoutMs);i.unref?.();let a;try{a=await this.fetchFn(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:this.model,messages:[{role:"user",content:n}],stream:!1}),signal:s.signal})}finally{clearTimeout(i)}if(!a.ok)return this.fallback(e,`Ollama respondeu HTTP ${a.status} (modelo "${this.model}" pode estar ausente \u2014 sem auto-pull)`);let l=await a.text(),c=rz(l);if(!c)return this.fallback(e,"resposta do Ollama sem conte\xFAdo parse\xE1vel");let d=e.options.map(u=>u.id),m=CL(c,d);return m.fallback?this.fallback(e,"parseVerdict usou fallback \u2014 resposta LLM n\xE3o estruturalmente v\xE1lida"):d.includes(m.chosen)?(this.report(!0),{chosen:m.chosen,confidence:sz(m.confidence),reasons:[{optionId:m.chosen,rationale:iz(m.reasoning)}],mode:"llm"}):this.fallback(e,`chosen "${m.chosen}" n\xE3o est\xE1 nas op\xE7\xF5es v\xE1lidas`)}catch(o){let n=o instanceof Error?o.message:String(o),r=n.includes("abort")||n.includes("timeout")||n.includes("cancelado");return this.fallback(e,r?`timeout (${this.timeoutMs}ms)`:`erro: ${n}`)}}fallback(e,o){this.report(!1);let n=e.options[0],r=n?.id??"continuar",s=n?.label??"continuar";return{chosen:r,confidence:.5,reasons:[{optionId:r,rationale:`[degrada\xE7\xE3o heur\xEDstica] ${o}. Fallback para op\xE7\xE3o default "${s}".`}],mode:"heuristic"}}};function nz(t,e,o){let n="11434";try{let s=new URL(o).port;s&&(n=s)}catch{}let r=t.includes(":")?`[${t}]`:t;return`${e}://${r}:${n}/api/chat`}function rz(t){try{let e=JSON.parse(t),o=e?.message?.content;if(typeof o=="string"&&o.trim().length>0)return o.trim();let n=e?.response;return typeof n=="string"&&n.trim().length>0?n.trim():void 0}catch{return}}function sz(t){return Math.max(0,Math.min(1,t))}function iz(t){return t.length<=300?t:t.slice(0,297)+"..."}B();function oS(t){let e=t.env??process.env,o=e[t.urlKey]?.trim();if(o!==void 0&&o!=="")return o;let n=e[t.hostKey]?.trim()||t.cfg?.host||t.defHost,r=e[t.portKey]?.trim(),s=r&&/^\d+$/.test(r)?Number(r):void 0,i=(s!==void 0&&s>=1&&s<=65535?s:void 0)??t.cfg?.port??t.defPort;return`http://${n}:${i}`}function Lp(t,e){return oS({env:t,urlKey:"ALUY_MEM0_URL",hostKey:"ALUY_MEM0_HOST",portKey:"ALUY_MEM0_PORT",cfg:e?.mem0,defHost:Da,defPort:11435})}function Pp(t,e){return oS({env:t,urlKey:"ALUY_OLLAMA_URL",hostKey:"ALUY_OLLAMA_HOST",portKey:"ALUY_OLLAMA_PORT",cfg:e?.ollama,defHost:Da,defPort:11434})}function Op(t,e){return oS({env:t,urlKey:"ALUY_HEADROOM_URL",hostKey:"ALUY_HEADROOM_HOST",portKey:"ALUY_HEADROOM_PORT",cfg:e?.headroom,defHost:Da,defPort:8787})}function TL(t){let e=t.env??{},o=(e.ALUY_HEADROOM_OFF??"").trim().toLowerCase();if(o==="1"||o==="true"||o==="on")return;if((e.ALUY_HEADROOM_URL??"").trim()!=="")return Op(t.env,t.services);let r=t.profile==="turbo"&&t.headroomToggle!==!1,s=t.services?.headroom!==void 0;if(r||s)return Op(t.env,t.services)}import{createHash as az}from"node:crypto";import{basename as lz,resolve as cz}from"node:path";var dz=/[^a-zA-Z0-9]+/g,uz=/^_+|_+$/g;function DL(t){return t.replace(dz,"_").replace(uz,"")}function mz(t){return`proj_${DL(t)}`}function _L(t){let e=cz(t),o=az("sha256").update(e).digest("hex").slice(0,12),r=`proj_${DL(lz(e))||"root"}_${o}`,s=mz(t);return{scope:r,legacy:s,recallScopes:r===s?[r]:[r,s]}}function Fp(t={}){let e=t.env??process.env,o=e.ALUY_MAESTRO,n=e.ALUY_MAESTRO_OFF;if(n&&n!=="0"&&n!=="false"||o==="0"||o==="false")return;let r=Ys({ollama:e.ALUY_MAESTRO_OLLAMA!=="0",mem0:e.ALUY_MAESTRO_MEM0!=="0"}),s=t.bus??new Of,i=t.judge??new Yd({baseUrl:Pp(t.env,t.services),model:Yv,...t.usage?{onUsed:l=>t.usage.record("ollama",l)}:{}});async function a(l){let c=S_(l);if(r.has("ollama")&&l.length>=2)try{let d=await i.judge({question:"Dados os sinais de supervis\xE3o, qual a decis\xE3o de reg\xEAncia?",options:[{id:"continuar",label:"Continuar normalmente"},{id:"pausar",label:"Pausar o loop"},{id:"recuperar",label:"Recuperar contexto"},{id:"parar",label:"Parar o loop"}],context:l.map(m=>`${m.origin}/${m.severity}: ${JSON.stringify(m.payload)}`).join(`
565
- `),hint:"Prefira seguran\xE7a e continuidade."});if(d.mode==="llm"&&d.confidence>.6)return d.chosen==="continuar"&&d.chosen!==c.decision.action&&d.confidence>.8?{action:"continuar",signals:l,reason:`motor-a:${c.decision.action} + judge:continuar@${d.confidence.toFixed(2)} \u2014 judge preferiu FLUIR (Inv. I)`,ts:Date.now()}:{...c.decision,reason:`${c.decision.reason} | judge:${d.chosen}@${d.confidence.toFixed(2)}`}}catch{}return c.decision}return{bus:s,rege:a}}function nS(t,e,o){if(t===void 0||t==="")return o;let n=Number(t);return!Number.isFinite(n)||!Number.isInteger(n)||n<e?o:n}function RL(t){let e=t?.env??process.env,o=e.ALUY_MEM_OFF;if(o&&o!=="0"&&o!=="false"||e.ALUY_MAESTRO_MEM0==="0")return;let n=t?.cwd??process.cwd(),{scope:r,recallScopes:s}=_L(n),i=t?.usage;return{memory:t?.memory??new Ed({mem0Url:Lp(e,t?.services),...i?{onUsed:l=>i.record("mem0",l)}:{}}),memoryScope:r,memoryRecallScopes:s}}function ML(t){let e=t??process.env,o=e.ALUY_CONT_OFF;if(o&&o!=="0"&&o!=="false")return;let n=e.ALUY_CONT;if(n==="0"||n==="false")return;let r=nS(e.ALUY_CONT_MAX,1,6),s=nS(e.ALUY_CONT_NUDGE_AT,1,1),i=Math.min(nS(e.ALUY_CONT_GIVEUP_AT,1,4),r);return{maxContinuations:r,nudgeAt:s,giveUpAt:i}}B();var Tr="aluy-flux",fz=12e4;function rS(t={}){let e=t.env??process.env,o=Wf(e),n=t.store??new Oa,r=new na({baseUrl:o.identityBaseUrl,clientId:Ck,store:n,...t.identityFetch?{fetch:t.identityFetch}:{}},{envToken:()=>e.ALUY_TOKEN}),s=yr(e),i=t.brokerClient??cc({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),a=t.catalogClient??wy({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),l=t.customModelClient??Ay({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),c=t.providersClient??Cy({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),d=t.quotaClient??Ty({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),m=t.mode??(t.unsafe?"unsafe":"normal"),u=m==="unsafe",p=new Qr({...t.workspaceRoot!==void 0?{root:t.workspaceRoot}:{},...u?{unconfined:!0}:{}}),h=t.sessionId??ua(),y=new xd({sessionId:h,...t.journalBaseDir!==void 0?{baseDir:t.journalBaseDir}:{}});y.gcOrphans();let g=new Qc({store:y,workspace:p,restoreWriter:new Ad({workspace:p}),currentReader:new Cd({workspace:p})}),E=new Zc({journal:g}),k=new Zr({workspace:p}),w=new Js(t.egressAllow!==void 0?{allow:t.egressAllow}:{}),D=Mv(e.ALUY_WEB_FETCH_MAX_CHARS,t.advanced?.webFetch?.maxObservationChars),F=Tk({egress:w,policy:{maxObservationChars:D,...u?{allowInternalHosts:!0}:{}}}),L=new Qs({workspace:p,...t.memoryBaseDir!==void 0?{baseDir:t.memoryBaseDir}:{}}),j=new Xc({store:L}),N=new wd({...t.todoBaseDir!==void 0?{baseDir:t.todoBaseDir}:{},sessionId:h}),$=process.env.ALUY_SANDBOX_BASH?Vf():void 0,z=new mp,oe=new Ki,V={fs:k,shell:new hd({workspace:p,timeoutMs:fz,...$?{sandboxLauncher:$}:{},egressAllows:Z=>{let we=w.inspect(Z);return we.hasNetwork&&!we.outsideAllowlist}}),search:new gd({workspace:p}),journal:g.toolPort,web:F,cwd:p,memory:{remember:(Z,we,ze)=>j.remember(Z,we,ze),searchFacts:(Z,we)=>j.searchFacts(Z,we)},todo:N,question:z,graph:oe},P=new yd({workspace:p}),W=new $d({workspace:p,fs:k}),Pe=new ro({mode:m,diffPreview:(Z,we,ze)=>ze!==void 0?ya(Z,ze,we,!0):ya(Z,"",we,!1),maxMemoryWritesPerSession:Gw(t.maxMemoryWritesPerSession,e.ALUY_MAX_MEMORY_WRITES_PER_SESSION,t.limits?.maxMemoryWritesPerSession)}),re=new Bd(t.askTimeoutMs!==void 0?{timeoutMs:t.askTimeoutMs}:{}),le=(t.hooksConfigStore??new Id({workspaceRoot:t.workspaceRoot??process.cwd()})).load(),ne=new zc({permission:Pe,ports:V,askResolver:re}),ue=AL({runner:ne,config:le}),X=t.tier??Tr,se=X==="custom"?t.model:void 0,me=se!==void 0?t.provider:void 0,ie=t.activeModelSlug??se,Oe=_p(X,e,void 0,t.context?.window,Ka(t.providerWindows,t.activeProviderId,ie)),Ce=t.effort,Xe=(t.effectiveBackend!=="local"?(t.localBudget===!1&&t.onConfigWarn?.("aluy: budget OFF n\xE3o se aplica ao backend broker \u2014 o or\xE7amento de sess\xE3o est\xE1 SEMPRE ativo no broker. Use --backend local para deslig\xE1-lo (BYO)."),!0):t.localBudget!==!1)?{...bo,maxIterations:um(t.maxIterations,e.ALUY_MAX_ITERATIONS,t.limits?.maxIterations),maxTokens:dm(t.maxTokens,e.ALUY_MAX_TOKENS,t.limits?.maxTokens)}:{maxIterations:1e4,maxToolCalls:1e4*2},st=qw(t.maxOutputTokens,e.ALUY_MAX_OUTPUT_TOKENS,t.limits?.maxOutputTokens,t.onConfigWarn),Do=Uy({flag:t.selfCheck,env:e.ALUY_SELF_CHECK,tier:X,everyKEnv:e.ALUY_SELF_CHECK_EVERY,maxVerificationsEnv:e.ALUY_SELF_CHECK_MAX,...t.advanced?.selfCheck?.everyK!==void 0?{everyKConfig:t.advanced.selfCheck.everyK}:{},...t.advanced?.selfCheck?.maxVerifications!==void 0?{maxVerificationsConfig:t.advanced.selfCheck.maxVerifications}:{}}),Ho={cwd:p.cwd,tier:X,...se!==void 0?{model:se}:{},...t.effectiveBackend!==void 0?{backend:t.effectiveBackend}:{},tokens:0,windowPct:0},xe=null,dt=new od,Et=Ys({ollama:e.ALUY_MAESTRO_OLLAMA!=="0",mem0:e.ALUY_MAESTRO_MEM0!=="0"}),Mt=!1,Bt=!1,it=new fp({client:i,tier:X,...t.headroomUrl!==void 0?{headroomUrl:t.headroomUrl}:{},onHeadroomUsed:Z=>dt.record("headroom",Z),...se!==void 0?{model:se}:{},...me!==void 0?{provider:me}:{},...Ce!==void 0?{effort:Ce}:{},...st!==void 0?{maxTokens:st}:{},sink:{onStart:()=>xe?.sink.onStart?.(),onDelta:Z=>xe?.sink.onDelta(Z),onUsage:Z=>xe?.sink.onUsage?.(Z),onQuota:Z=>xe?.sink.onQuota?.(Z),onDone:()=>xe?.sink.onDone?.()}}),qo=new Lo({client:i,tier:X,tierSource:it,maxTokens:_f}),Dn=new Lo({client:i,tier:X,tierSource:it,maxTokens:2048}),bt=t.subAgents?.enabled?new Lo({client:i,tier:X,tierSource:it,...st!==void 0?{maxTokens:st}:{}}):void 0,J=new Map,te,Se=t.subAgents?.enabled?Z=>{let we=J.get(Z);if(we)return we;let ze=new Lo({client:i,tier:Z,...st!==void 0?{maxTokens:st}:{}});return te&&ze.attachNativeTools(te),J.set(Z,ze),ze}:void 0,eo=new Map,mo="\0__inherit__",sn=t.subAgents?.enabled?Z=>{let we=Z??mo,ze=eo.get(we);if(ze)return ze;let an=Z!==void 0?{tier:"custom",model:Z,get provider(){return it.provider}}:{tier:"custom",get model(){return it.model},get provider(){return it.provider}},_n=new Lo({client:i,tier:"custom",tierSource:an,...st!==void 0?{maxTokens:st}:{}});return te&&_n.attachNativeTools(te),eo.set(we,_n),_n}:void 0,ut=t.subAgents?.enabled?{availableNames:async()=>(await a.list()).map(Z=>Z.key)}:void 0,Ot=Tv(e.ALUY_ROOM_BACKEND,t.roomsBackend);Ot.warning&&t.onConfigWarn&&t.onConfigWarn(Ot.warning);let Wo=(()=>{switch(Ot.backend){case"memory":return new pr;case"file":return new Kd;case"loopback":case"broker":throw new Error(`Room backend "${Ot.backend}" n\xE3o implementado ainda. Use "memory" ou "file", ou deixe o default.`);default:return new pr}})(),_o=new zd({model:it,compactionModel:qo,sideQueryModel:Dn,permission:Pe,roomStore:Wo,ports:V,askResolver:re,agentMemory:j,commandWorkspace:p,login:r,questionResolver:z,...ue?{preToolGate:ue}:{},...At(le,"user-prompt-submit").length>0?{onUserPromptSubmit:()=>{ne.runAll(At(le,"user-prompt-submit"))}}:{},meta:Ho,limits:Xe,...Do.enabled?{selfCheck:Do}:{},...t.autoCompactAt!==void 0?{autoCompactAt:t.autoCompactAt}:{},...t.context?{contextConfig:t.context}:{},...t.cycleConfig?{cycleConfig:t.cycleConfig}:{},contextWindow:Oe,...t.providerWindows!==void 0?{providerWindows:t.providerWindows}:{},...t.activeProviderId!==void 0?{activeProviderId:t.activeProviderId}:{},...t.projectInstructions!==void 0?{projectInstructions:t.projectInstructions}:{},...t.availableAgents!==void 0?{availableAgents:t.availableAgents}:{},...t.sessionCommands!==void 0?{sessionCommands:t.sessionCommands}:{},...t.mcpTools!==void 0?{mcpTools:t.mcpTools}:{},...t.pendingMcpServers!==void 0?{pendingMcpServers:t.pendingMcpServers}:{},...t.headroomUrl!==void 0?{headroomRetrieveTool:xR({baseUrl:t.headroomUrl,onUsed:Z=>dt.record("headroom",Z)})}:{},...t.subAgents?.enabled?{subAgents:{...t.subAgents,env:t.subAgents.env??e,...t.subagentsConfig?{configDefaults:{...t.subagentsConfig.maxPerCall!==void 0?{maxPerCall:t.subagentsConfig.maxPerCall}:{},...t.subagentsConfig.maxConcurrency!==void 0?{maxConcurrency:t.subagentsConfig.maxConcurrency}:{},...t.subagentsConfig.idleTimeoutMs!==void 0?{idleTimeoutMs:t.subagentsConfig.idleTimeoutMs}:{}}}:{},...At(le,"subagent-stop").length>0?{observer:{onChildEnd:()=>{ne.runAll(At(le,"subagent-stop"))}}}:{}}}:{},...t.subAgents?.enabled&&t.agentRegistry?{agentRegistry:t.agentRegistry}:{},...t.skills&&t.skills.length>0?{skills:t.skills}:{},...t.subAgents?.enabled&&t.reloadProjectAgents?{reloadProjectAgents:t.reloadProjectAgents}:{},...bt?{subAgentModel:bt}:{},...Se?{callerForTier:Se}:{},...sn?{customCallerFor:sn}:{},...t.callerForLocalModel?{callerForLocalModel:t.callerForLocalModel}:{},...t.localModelCatalog?{localModelCatalog:t.localModelCatalog}:{},...t.verifyAndRegisterLocalModel?{verifyAndRegisterLocalModel:t.verifyAndRegisterLocalModel}:{},...ut?{modelProbe:ut}:{},...t.subAgents?.defaultModel!==void 0?{defaultChildModel:t.subAgents.defaultModel}:{},disableNativeTools:e.ALUY_NATIVE_TOOLS_OFF==="1"||e.ALUY_NATIVE_TOOLS_OFF==="true",watchdogEnv:e,quotaFetcher:()=>d.fetchQuota(),...t.memoryMonitor!==void 0?{memory:{heapLimitMb:t.memoryMonitor.heapLimitMb,sampleHeapUsed:t.memoryMonitor.sampleHeapUsed,env:e,...t.memoryMonitor.sampleIntervalMs!==void 0?{sampleIntervalMs:t.memoryMonitor.sampleIntervalMs}:{},...t.advanced?.memPressure?.compactAt!==void 0?{pressureAtConfig:t.advanced.memPressure.compactAt}:{}}}:{},onUserPrompt:(Z,we)=>{E.markPrompt(Z,we)},...(()=>{let Z=Fp({env:e,usage:dt,...t.services?{services:t.services}:{}});if(Mt=Z!==void 0&&Et.has("ollama"),!Z)return{};let we=ML(e);return we?{maestro:Z,continuationConfig:we}:{maestro:Z}})(),...(()=>{let Z=RL({env:e,usage:dt,...t.services?{services:t.services}:{}});return Bt=Z!==void 0,Z?{memoryEngine:Z.memory,memoryScope:Z.memoryScope,memoryRecallScopes:Z.memoryRecallScopes}:{}})(),onToolsReady:Z=>{it.attachNativeTools(Z),bt?.attachNativeTools(Z),te=Z;for(let we of J.values())we.attachNativeTools(Z);for(let we of eo.values())we.attachNativeTools(Z)}});return xe=_o,_o.armSidecarUsage({profile:t.profile??"turbo",enabled:{headroom:t.headroomUrl!==void 0,ollama:Mt,mem0:Bt}},dt),{controller:_o,login:r,engine:Pe,egress:w,workspace:p,askResolver:re,questionResolver:z,journal:g,journalStore:y,checkpoints:E,fileIndex:P,attachReader:W,catalogClient:a,customModelClient:l,providersClient:c,quotaClient:d,ports:V,memory:j,todoStore:N,hookRunner:ne,hooksConfig:le}}import{render as nJ}from"ink";var LL="\x1B[?2026h",sS="\x1B[?2026l",zn="\x1B[",Ip=`${zn}2K`,aS=`${zn}1A`,lS=`${zn}G`,Vd=`${zn}K`,di=`${zn}J`,IL=`${zn}2J`,NL=`${zn}3J`,Va=`${zn}H`,Xd=`${IL}${NL}${Va}`,iS=`${Va}${IL}${NL}`;function PL(t){return`${zn}${t};1H`}function pz(t,e){return`${zn}${t};${e}H`}function hz(t){let e=1,o=1;for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="\x1B"&&t[n+1]==="["){let s=n+2;for(;s<t.length&&t[s]>="0"&&t[s]<="?";)s+=1;for(;s<t.length&&t[s]>=" "&&t[s]<="/";)s+=1;n=s;continue}if(r===`
565
+ `),hint:"Prefira seguran\xE7a e continuidade."});if(d.mode==="llm"&&d.confidence>.6)return d.chosen==="continuar"&&d.chosen!==c.decision.action&&d.confidence>.8?{action:"continuar",signals:l,reason:`motor-a:${c.decision.action} + judge:continuar@${d.confidence.toFixed(2)} \u2014 judge preferiu FLUIR (Inv. I)`,ts:Date.now()}:{...c.decision,reason:`${c.decision.reason} | judge:${d.chosen}@${d.confidence.toFixed(2)}`}}catch{}return c.decision}return{bus:s,rege:a}}function nS(t,e,o){if(t===void 0||t==="")return o;let n=Number(t);return!Number.isFinite(n)||!Number.isInteger(n)||n<e?o:n}function RL(t){let e=t?.env??process.env,o=e.ALUY_MEM_OFF;if(o&&o!=="0"&&o!=="false"||e.ALUY_MAESTRO_MEM0==="0")return;let n=t?.cwd??process.cwd(),{scope:r,recallScopes:s}=_L(n),i=t?.usage;return{memory:t?.memory??new Ed({mem0Url:Lp(e,t?.services),...i?{onUsed:l=>i.record("mem0",l)}:{}}),memoryScope:r,memoryRecallScopes:s}}function ML(t){let e=t??process.env,o=e.ALUY_CONT_OFF;if(o&&o!=="0"&&o!=="false")return;let n=e.ALUY_CONT;if(n==="0"||n==="false")return;let r=nS(e.ALUY_CONT_MAX,1,6),s=nS(e.ALUY_CONT_NUDGE_AT,1,1),i=Math.min(nS(e.ALUY_CONT_GIVEUP_AT,1,4),r);return{maxContinuations:r,nudgeAt:s,giveUpAt:i}}B();var Tr="aluy-flux",fz=12e4;function rS(t={}){let e=t.env??process.env,o=Wf(e),n=t.store??new Oa,r=new na({baseUrl:o.identityBaseUrl,clientId:Ck,store:n,...t.identityFetch?{fetch:t.identityFetch}:{}},{envToken:()=>e.ALUY_TOKEN}),s=yr(e),i=t.brokerClient??cc({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),a=t.catalogClient??wy({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),l=t.customModelClient??Ay({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),c=t.providersClient??Cy({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),d=t.quotaClient??Ty({brokerBaseUrl:s.brokerBaseUrl,login:r,...t.brokerFetch?{fetch:t.brokerFetch}:{}}),m=t.mode??(t.unsafe?"unsafe":"normal"),u=m==="unsafe",p=new Qr({...t.workspaceRoot!==void 0?{root:t.workspaceRoot}:{},...u?{unconfined:!0}:{}}),h=t.sessionId??ua(),y=new xd({sessionId:h,...t.journalBaseDir!==void 0?{baseDir:t.journalBaseDir}:{}});y.gcOrphans();let g=new Qc({store:y,workspace:p,restoreWriter:new Ad({workspace:p}),currentReader:new Cd({workspace:p})}),E=new Zc({journal:g}),k=new Zr({workspace:p}),w=new Js(t.egressAllow!==void 0?{allow:t.egressAllow}:{}),D=Mv(e.ALUY_WEB_FETCH_MAX_CHARS,t.advanced?.webFetch?.maxObservationChars),F=Tk({egress:w,policy:{maxObservationChars:D,...u?{allowInternalHosts:!0}:{}}}),L=new Qs({workspace:p,...t.memoryBaseDir!==void 0?{baseDir:t.memoryBaseDir}:{}}),j=new Xc({store:L}),N=new wd({...t.todoBaseDir!==void 0?{baseDir:t.todoBaseDir}:{},sessionId:h}),$=process.env.ALUY_SANDBOX_BASH?Vf():void 0,z=new mp,oe=new Ki,V={fs:k,shell:new hd({workspace:p,timeoutMs:fz,...$?{sandboxLauncher:$}:{},egressAllows:Z=>{let we=w.inspect(Z);return we.hasNetwork&&!we.outsideAllowlist}}),search:new gd({workspace:p}),journal:g.toolPort,web:F,cwd:p,memory:{remember:(Z,we,ze)=>j.remember(Z,we,ze),searchFacts:(Z,we)=>j.searchFacts(Z,we)},todo:N,question:z,graph:oe},P=new yd({workspace:p}),W=new $d({workspace:p,fs:k}),Pe=new ro({mode:m,diffPreview:(Z,we,ze)=>ze!==void 0?ya(Z,ze,we,!0):ya(Z,"",we,!1),maxMemoryWritesPerSession:Gw(t.maxMemoryWritesPerSession,e.ALUY_MAX_MEMORY_WRITES_PER_SESSION,t.limits?.maxMemoryWritesPerSession)}),re=new Bd(t.askTimeoutMs!==void 0?{timeoutMs:t.askTimeoutMs}:{}),le=(t.hooksConfigStore??new Id({workspaceRoot:t.workspaceRoot??process.cwd()})).load(),ne=new zc({permission:Pe,ports:V,askResolver:re}),ue=AL({runner:ne,config:le}),X=t.tier??Tr,se=X==="custom"?t.model:void 0,me=se!==void 0?t.provider:void 0,ie=t.activeModelSlug??se,Oe=_p(X,e,void 0,t.context?.window,Ka(t.providerWindows,t.activeProviderId,ie)),Ce=t.effort,Xe=(t.effectiveBackend!=="local"?(t.localBudget===!1&&t.onConfigWarn?.("aluy: budget OFF n\xE3o se aplica ao backend broker \u2014 o or\xE7amento de sess\xE3o est\xE1 SEMPRE ativo no broker. Use --backend local para deslig\xE1-lo (BYO)."),!0):t.localBudget!==!1)?{...bo,maxIterations:um(t.maxIterations,e.ALUY_MAX_ITERATIONS,t.limits?.maxIterations),maxTokens:dm(t.maxTokens,e.ALUY_MAX_TOKENS,t.limits?.maxTokens)}:{maxIterations:1e4,maxToolCalls:1e4*2},st=qw(t.maxOutputTokens,e.ALUY_MAX_OUTPUT_TOKENS,t.limits?.maxOutputTokens,t.onConfigWarn),Do=Uy({flag:t.selfCheck,env:e.ALUY_SELF_CHECK,tier:X,everyKEnv:e.ALUY_SELF_CHECK_EVERY,maxVerificationsEnv:e.ALUY_SELF_CHECK_MAX,...t.advanced?.selfCheck?.everyK!==void 0?{everyKConfig:t.advanced.selfCheck.everyK}:{},...t.advanced?.selfCheck?.maxVerifications!==void 0?{maxVerificationsConfig:t.advanced.selfCheck.maxVerifications}:{}}),Ho={cwd:p.cwd,tier:X,...se!==void 0?{model:se}:{},...t.effectiveBackend!==void 0?{backend:t.effectiveBackend}:{},...t.provider!==void 0?{provider:t.provider}:{},tokens:0,windowPct:0},xe=null,dt=new od,Et=Ys({ollama:e.ALUY_MAESTRO_OLLAMA!=="0",mem0:e.ALUY_MAESTRO_MEM0!=="0"}),Mt=!1,Bt=!1,it=new fp({client:i,tier:X,...t.headroomUrl!==void 0?{headroomUrl:t.headroomUrl}:{},onHeadroomUsed:Z=>dt.record("headroom",Z),...se!==void 0?{model:se}:{},...me!==void 0?{provider:me}:{},...Ce!==void 0?{effort:Ce}:{},...st!==void 0?{maxTokens:st}:{},sink:{onStart:()=>xe?.sink.onStart?.(),onDelta:Z=>xe?.sink.onDelta(Z),onUsage:Z=>xe?.sink.onUsage?.(Z),onQuota:Z=>xe?.sink.onQuota?.(Z),onDone:()=>xe?.sink.onDone?.()}}),qo=new Lo({client:i,tier:X,tierSource:it,maxTokens:_f}),Dn=new Lo({client:i,tier:X,tierSource:it,maxTokens:2048}),bt=t.subAgents?.enabled?new Lo({client:i,tier:X,tierSource:it,...st!==void 0?{maxTokens:st}:{}}):void 0,J=new Map,te,Se=t.subAgents?.enabled?Z=>{let we=J.get(Z);if(we)return we;let ze=new Lo({client:i,tier:Z,...st!==void 0?{maxTokens:st}:{}});return te&&ze.attachNativeTools(te),J.set(Z,ze),ze}:void 0,eo=new Map,mo="__ALUY_INHERIT_PARENT__",sn=t.subAgents?.enabled?Z=>{let we=Z??mo,ze=eo.get(we);if(ze)return ze;let an=Z!==void 0?{tier:"custom",model:Z,get provider(){return it.provider}}:{tier:"custom",get model(){return it.model},get provider(){return it.provider}},_n=new Lo({client:i,tier:"custom",tierSource:an,...st!==void 0?{maxTokens:st}:{}});return te&&_n.attachNativeTools(te),eo.set(we,_n),_n}:void 0,ut=t.subAgents?.enabled?{availableNames:async()=>(await a.list()).map(Z=>Z.key)}:void 0,Ot=Tv(e.ALUY_ROOM_BACKEND,t.roomsBackend);Ot.warning&&t.onConfigWarn&&t.onConfigWarn(Ot.warning);let Wo=(()=>{switch(Ot.backend){case"memory":return new pr;case"file":return new Kd;case"loopback":case"broker":throw new Error(`Room backend "${Ot.backend}" n\xE3o implementado ainda. Use "memory" ou "file", ou deixe o default.`);default:return new pr}})(),_o=new zd({model:it,compactionModel:qo,sideQueryModel:Dn,permission:Pe,roomStore:Wo,ports:V,askResolver:re,agentMemory:j,commandWorkspace:p,login:r,questionResolver:z,...ue?{preToolGate:ue}:{},...At(le,"user-prompt-submit").length>0?{onUserPromptSubmit:()=>{ne.runAll(At(le,"user-prompt-submit"))}}:{},meta:Ho,limits:Xe,...Do.enabled?{selfCheck:Do}:{},...t.autoCompactAt!==void 0?{autoCompactAt:t.autoCompactAt}:{},...t.context?{contextConfig:t.context}:{},...t.cycleConfig?{cycleConfig:t.cycleConfig}:{},contextWindow:Oe,...t.providerWindows!==void 0?{providerWindows:t.providerWindows}:{},...t.activeProviderId!==void 0?{activeProviderId:t.activeProviderId}:{},...t.projectInstructions!==void 0?{projectInstructions:t.projectInstructions}:{},...t.availableAgents!==void 0?{availableAgents:t.availableAgents}:{},...t.sessionCommands!==void 0?{sessionCommands:t.sessionCommands}:{},...t.mcpTools!==void 0?{mcpTools:t.mcpTools}:{},...t.pendingMcpServers!==void 0?{pendingMcpServers:t.pendingMcpServers}:{},...t.headroomUrl!==void 0?{headroomRetrieveTool:xR({baseUrl:t.headroomUrl,onUsed:Z=>dt.record("headroom",Z)})}:{},...t.subAgents?.enabled?{subAgents:{...t.subAgents,env:t.subAgents.env??e,...t.subagentsConfig?{configDefaults:{...t.subagentsConfig.maxPerCall!==void 0?{maxPerCall:t.subagentsConfig.maxPerCall}:{},...t.subagentsConfig.maxConcurrency!==void 0?{maxConcurrency:t.subagentsConfig.maxConcurrency}:{},...t.subagentsConfig.idleTimeoutMs!==void 0?{idleTimeoutMs:t.subagentsConfig.idleTimeoutMs}:{}}}:{},...At(le,"subagent-stop").length>0?{observer:{onChildEnd:()=>{ne.runAll(At(le,"subagent-stop"))}}}:{}}}:{},...t.subAgents?.enabled&&t.agentRegistry?{agentRegistry:t.agentRegistry}:{},...t.skills&&t.skills.length>0?{skills:t.skills}:{},...t.subAgents?.enabled&&t.reloadProjectAgents?{reloadProjectAgents:t.reloadProjectAgents}:{},...bt?{subAgentModel:bt}:{},...Se?{callerForTier:Se}:{},...sn?{customCallerFor:sn}:{},...t.callerForLocalModel?{callerForLocalModel:t.callerForLocalModel}:{},...t.localModelCatalog?{localModelCatalog:t.localModelCatalog}:{},...t.verifyAndRegisterLocalModel?{verifyAndRegisterLocalModel:t.verifyAndRegisterLocalModel}:{},...ut?{modelProbe:ut}:{},...t.subAgents?.defaultModel!==void 0?{defaultChildModel:t.subAgents.defaultModel}:{},disableNativeTools:e.ALUY_NATIVE_TOOLS_OFF==="1"||e.ALUY_NATIVE_TOOLS_OFF==="true",watchdogEnv:e,quotaFetcher:()=>d.fetchQuota(),...t.memoryMonitor!==void 0?{memory:{heapLimitMb:t.memoryMonitor.heapLimitMb,sampleHeapUsed:t.memoryMonitor.sampleHeapUsed,env:e,...t.memoryMonitor.sampleIntervalMs!==void 0?{sampleIntervalMs:t.memoryMonitor.sampleIntervalMs}:{},...t.advanced?.memPressure?.compactAt!==void 0?{pressureAtConfig:t.advanced.memPressure.compactAt}:{}}}:{},onUserPrompt:(Z,we)=>{E.markPrompt(Z,we)},...(()=>{let Z=Fp({env:e,usage:dt,...t.services?{services:t.services}:{}});if(Mt=Z!==void 0&&Et.has("ollama"),!Z)return{};let we=ML(e);return we?{maestro:Z,continuationConfig:we}:{maestro:Z}})(),...(()=>{let Z=RL({env:e,usage:dt,...t.services?{services:t.services}:{}});return Bt=Z!==void 0,Z?{memoryEngine:Z.memory,memoryScope:Z.memoryScope,memoryRecallScopes:Z.memoryRecallScopes}:{}})(),onToolsReady:Z=>{it.attachNativeTools(Z),bt?.attachNativeTools(Z),te=Z;for(let we of J.values())we.attachNativeTools(Z);for(let we of eo.values())we.attachNativeTools(Z)}});return xe=_o,_o.armSidecarUsage({profile:t.profile??"turbo",enabled:{headroom:t.headroomUrl!==void 0,ollama:Mt,mem0:Bt}},dt),{controller:_o,login:r,engine:Pe,egress:w,workspace:p,askResolver:re,questionResolver:z,journal:g,journalStore:y,checkpoints:E,fileIndex:P,attachReader:W,catalogClient:a,customModelClient:l,providersClient:c,quotaClient:d,ports:V,memory:j,todoStore:N,hookRunner:ne,hooksConfig:le}}import{render as nJ}from"ink";var LL="\x1B[?2026h",sS="\x1B[?2026l",zn="\x1B[",Ip=`${zn}2K`,aS=`${zn}1A`,lS=`${zn}G`,Vd=`${zn}K`,di=`${zn}J`,IL=`${zn}2J`,NL=`${zn}3J`,Va=`${zn}H`,Xd=`${IL}${NL}${Va}`,iS=`${Va}${IL}${NL}`;function PL(t){return`${zn}${t};1H`}function pz(t,e){return`${zn}${t};${e}H`}function hz(t){let e=1,o=1;for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="\x1B"&&t[n+1]==="["){let s=n+2;for(;s<t.length&&t[s]>="0"&&t[s]<="?";)s+=1;for(;s<t.length&&t[s]>=" "&&t[s]<="/";)s+=1;n=s;continue}if(r===`
566
566
  `)e+=1,o=1;else if(r==="\r")o=1;else{let s=t.codePointAt(n);s>65535&&(n+=1),o+=he(String.fromCodePoint(s))}}return{row:e,col:o}}function $L(t){return t.ALUY_SYNC_OUTPUT!=="0"}function BL(t){return t.ALUY_OVERWRITE_RENDER!=="0"}function cS(t){let e=0,o=0;for(;t.startsWith(`${Ip}${aS}`,e);)e+=Ip.length+aS.length,o+=1;if(t.startsWith(`${Ip}${lS}`,e))return e+=Ip.length+lS.length,{lines:o+1,bodyStart:e}}function gz(t){return t.startsWith(Xd)?"clearterm":cS(t)?"erase":"other"}function yz(){let t=!1;return{feed(e){return gz(e)==="clearterm"?(t=!0,!1):t?(t=!1,!0):!1}}}function FL(t){let e="",o="";for(let n=0;n<t.length;n+=1){let r=t[n];r===`
567
567
  `?(o.endsWith("\r")?e+=o.slice(0,-1)+Vd+`\r
568
568
  `:e+=o+Vd+`
@@ -583,7 +583,7 @@ Responda APENAS com JSON no formato:
583
583
  `).map((c,d)=>Zo(vi,{children:Zo(f,{name:"fgDim",children:c})},d))]})]})}let o=t.status==="err";return kn(vi,{flexDirection:"column",paddingLeft:2,children:[kn(vi,{children:[Zo(I,{name:"tool",role:"depth"}),kn(f,{name:"fg",children:[" ",x7(t.verb)]}),Zo(BS,{children:" "}),Zo(f,{name:"fg",children:t.target}),Zo(BS,{children:" "}),Zo(f,{name:"fgDim",children:t.result}),Zo(BS,{children:" "}),o?Zo(I,{name:"err",role:"danger"}):Zo(I,{name:"ok",role:"success"})]}),o&&t.output&&kn(vi,{flexDirection:"column",paddingLeft:2,children:[kn(f,{name:"fgDim",children:[e.box.topLeft," sa\xEDda ",e.box.horizontal.repeat(8)]}),t.output.split(`
584
584
  `).map((n,r)=>kn(vi,{children:[kn(f,{name:"fgDim",children:[e.box.vertical," "]}),Zo(f,{name:"danger",children:n})]},r)),kn(f,{name:"fgDim",children:[e.box.bottomLeft," ",t.result," ",e.box.horizontal.repeat(4)]})]})]})}import"react";import{Box as Ct,Text as ul}from"ink";import{jsx as Re,jsxs as ye}from"react/jsx-runtime";function S7(t){if(!t)return;let e=t.split(".").pop();return e&&e!==t?e:void 0}var E7=14,pF=9,hF=4;function w7(t){return t.length<=E7?{head:t,hidden:0,tail:[]}:{head:t.slice(0,pF),hidden:t.length-pF-hF,tail:t.slice(t.length-hF)}}function yF(t){return t.category==="always-ask:destructive"}function A7(t){let e=/^\[sub-agente:\s*([^\]]+)\]/.exec(t.reason??"");return e?e[1].trim():null}function C7(t){let e=t.effect.kind;return e==="diff"||e==="path"?`edit \u2500 ${t.effect.path??t.effect.exact}`:"bash"}function jS(t){let e=G(),o=t.request,n=yF(o),r=o.category==="always-ask:network"||t.egressOutsideAllowlist===!0,s=A7(o),i=n?"destrutivo \xB7 ask":"ask";return ye(Ct,{flexDirection:"column",paddingLeft:2,children:[ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.topLeft," "]}),Re(I,{name:"ask",role:"accent"}),ye(f,{name:"accent",children:[" ",i," \u2500 ",C7(o)," ",e.box.horizontal.repeat(2),e.box.topRight]})]}),Re(f,{name:"accent",children:e.box.vertical}),s!==null&&ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(I,{name:"subagents",role:"accent"}),Re(f,{name:"accent",children:" sub-agente: "}),Re(f,{name:"fg",children:s})]}),Re(_7,{request:o}),r&&ye(Ct,{flexDirection:"column",children:[ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(I,{name:"ask",role:"accent"}),Re(f,{name:"accent",children:" rede \xB7 ask \xB7 destino fora da allowlist"})]}),t.egressTarget&&ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(f,{name:"depth",children:t.egressTarget})]})]}),ye(f,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(40),e.box.teeRight]}),n?ye(Ct,{flexDirection:"column",children:[ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(I,{name:"ask",role:"accent"}),Re(f,{name:"accent",children:" esta a\xE7\xE3o n\xE3o pode ser desfeita"})]}),ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(f,{name:"danger",children:"[n] negar"}),Re(ul,{children:" "}),Re(f,{name:"accent",children:"[a] aprovar mesmo assim"})]})]}):ye(Ct,{flexDirection:"column",children:[ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(I,{name:"ask",role:"accent"}),ye(f,{name:"accent",children:[" ",D7(o)]})]}),ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(f,{name:"accent",children:"[a] aprovar"}),Re(ul,{children:" "}),o.alwaysAsk===!1&&Re(f,{name:"accent",children:"[s] sempre nesta sess\xE3o"})]}),ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(f,{name:"danger",children:"[n] negar"}),Re(ul,{children:" "}),Re(f,{name:"fgDim",children:"[e] editar"})]})]}),ye(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42),e.box.bottomRight]}),Re(f,{name:"fgDim",children:T7(o,n)})]})}function T7(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 D7(t){return t.effect.kind==="diff"||t.effect.kind==="path"?"aplicar esta altera\xE7\xE3o?":"executar este comando?"}function _7(t){let e=G(),o=t.request.effect,n=w7(o.exact.split(`
585
585
  `)),r=yF(t.request)?"":" \u2014 [e] editar mostra tudo",s=a=>ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),ye(f,{name:"fgDim",children:["\u2026 (+",n.hidden," linhas ocultas",r,")"]})]},a);if(o.kind==="diff"){let a=tl(S7(o.path??o.exact)),l=(c,d)=>ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(R7,{line:c,lang:a??void 0})]},d);return ye(Ct,{flexDirection:"column",children:[n.head.map((c,d)=>l(c,`h${d}`)),n.hidden>0&&s("m"),n.tail.map((c,d)=>l(c,`t${d}`))]})}let i=(a,l)=>ye(Ct,{children:[ye(f,{name:"accent",children:[e.box.vertical," "]}),Re(f,{name:"fg",children:a})]},l);return ye(Ct,{flexDirection:"column",children:[n.head.map((a,l)=>i(a,`h${l}`)),n.hidden>0&&s("m"),n.tail.map((a,l)=>i(a,`t${l}`))]})}function R7(t){let e=G(),o=t.line;return o.startsWith("---")||o.startsWith("+++")||o.startsWith("@@")?Re(f,{name:"fgDim",children:o}):o.startsWith("-")?ye(ul,{children:[ye(f,{name:"danger",children:[e.glyph("diffDel")," "]}),Re(gF,{code:o.slice(1),lang:t.lang,fallback:"danger"})]}):o.startsWith("+")?ye(ul,{children:[ye(f,{name:"success",children:[e.glyph("diffAdd")," "]}),Re(gF,{code:o.slice(1),lang:t.lang,fallback:"success"})]}):Re(f,{name:"fgDim",children:o})}function gF(t){if(t.lang===void 0||t.code==="")return Re(f,{name:t.fallback,children:t.code});let e=lu(t.code,t.lang);return Re(ul,{children:e.map((o,n)=>Re(f,{name:o.role,children:o.text},n))})}import"react";import{Box as xn}from"ink";import{jsx as lo,jsxs as qe}from"react/jsx-runtime";var Xn=-1,HS=42,M7=13;function O7(t){return t.kind!=="text"&&t.allowOther!==!1}function qS(t){let e=G(),{spec:o}=t;return qe(xn,{flexDirection:"column",paddingLeft:2,children:[qe(xn,{children:[qe(f,{name:"accent",children:[e.box.topLeft," "]}),lo(I,{name:"ask",role:"accent"}),qe(f,{name:"accent",children:[" ","Pergunta ",e.box.horizontal.repeat(HS-M7),e.box.topRight]})]}),lo(f,{name:"accent",children:e.box.vertical}),o.header!==void 0&&qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"depth",children:o.header})]}),o.question.split(`
586
- `).map((n,r)=>qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"fg",children:n})]},`q-${r}`)),lo(f,{name:"accent",children:e.box.vertical}),o.kind==="text"?lo(F7,{theme:e,draft:t.draft??""}):lo(L7,{...t}),qe(f,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(HS),e.box.teeRight]}),qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"fgDim",children:I7(o,t.editing===!0)})]}),qe(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(HS),e.box.bottomRight]})]})}function L7(t){let e=G(),{spec:o}=t,n=o.options??[],r=o.kind==="multi",s=t.selected??new Set;return qe(xn,{flexDirection:"column",children:[n.map((i,a)=>{let l=t.cursor===a,c=r?s.has(a)?"[x]":"[ ]":l?"(\u2022)":"( )";return qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),qe(f,{name:l?"accent":"fgDim",children:[l?"\u203A":" "," "]}),qe(f,{name:l?"accent":"fgDim",children:[c," "]}),lo(f,{name:l?"accent":"fg",children:i.label}),i.description!==void 0&&qe(f,{name:"fgDim",children:[" \u2014 ",i.description]})]},`opt-${a}`)}),O7(o)&&lo(P7,{theme:e,onCursor:t.cursor===Xn,editing:t.editing===!0&&t.cursor===Xn,draft:t.draft??""})]})}function P7(t){let{theme:e,onCursor:o,editing:n,draft:r}=t;return qe(xn,{flexDirection:"column",children:[qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),qe(f,{name:o?"accent":"fgDim",children:[o?"\u203A":" "," "]}),lo(f,{name:o?"accent":"fg",children:"Outro (resposta livre)"})]}),n&&qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"fg",children:r}),lo(f,{name:"accent",children:e.glyph("cursor")})]})]})}function F7(t){let{theme:e,draft:o}=t;return qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),qe(f,{name:"depth",children:[e.glyph("prompt")," "]}),lo(f,{name:"fg",children:o}),lo(f,{name:"accent",children:e.glyph("cursor")})]})}function I7(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 hu}from"ink";import{jsx as nh,jsxs as en}from"react/jsx-runtime";function WS(t){let e=G(),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 en(hu,{flexDirection:"column",paddingLeft:4,children:[en(hu,{children:[en(f,{name:"danger",children:[e.box.topLeft," "]}),nh(I,{name:"broker",role:"depth"}),en(f,{name:"danger",children:[" ",n," ",e.box.horizontal.repeat(4)," "]}),nh(I,{name:"err",role:"danger"})]}),en(hu,{children:[en(f,{name:"danger",children:[e.box.vertical," "]}),nh(f,{name:"fg",children:t.message})]}),(t.status!==void 0||t.attempt!==void 0||t.retryInSeconds!==void 0)&&en(hu,{children:[en(f,{name:"danger",children:[e.box.vertical," "]}),en(f,{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})`:""]})]}),en(hu,{children:[en(f,{name:"danger",children:[e.box.vertical," "]}),nh(f,{name:"fgDim",children:r})]}),en(f,{name:"danger",children:[e.box.bottomLeft,e.box.horizontal.repeat(40)]})]})}import"react";import{Box as cs,Text as N7}from"ink";import{jsx as Jn,jsxs as ht}from"react/jsx-runtime";function $7(t){return t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function GS(t){let e=G();return ht(cs,{flexDirection:"column",paddingLeft:2,children:[ht(cs,{children:[ht(f,{name:"accent",children:[e.box.topLeft," "]}),Jn(I,{name:"clock",role:"accent"}),ht(f,{name:"accent",children:[" teto da sess\xE3o ",e.box.horizontal.repeat(6)," pausado"]})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"fg",children:t.reason})]}),t.budgetPct!==void 0&&ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(I,{name:"clock",role:"accent"}),ht(f,{name:"accent",children:[" ",t.budgetPct,"% do teto da sess\xE3o"]}),t.maxTokens!==void 0&&ht(f,{name:"fgDim",children:[" (teto: ",$7(t.maxTokens)," tokens)"]})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir."})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(I,{name:"window",role:"fgDim"}),ht(f,{name:"fgDim",children:[" janela: ",t.windowPct,"% usada"]})]}),t.canCompact&&ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"accent",children:"[k] compactar"}),Jn(f,{name:"fgDim",children:" resume a conversa e continua (libera a janela)"})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"accent",children:"[c] continuar (+50 itera\xE7\xF5es)"}),Jn(N7,{children:" "}),Jn(f,{name:"fgDim",children:"[n] encerrar"})]}),ht(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as ki,Text as B7}from"ink";import{Fragment as j7,jsx as Qn,jsxs as Yt}from"react/jsx-runtime";function U7(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 zS(t){let e=G(),o=U7(t.kind,t.count,t.sample);return Yt(ki,{flexDirection:"column",paddingLeft:2,children:[Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.topLeft," "]}),Qn(I,{name:"clock",role:"accent"}),Yt(f,{name:"accent",children:[" parece travado ",e.box.horizontal.repeat(6)," pausado"]})]}),Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"fg",children:o})]}),t.redirecting?Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"accent",children:"[r] "}),Qn(f,{name:"fgDim",children:"digite a nova instru\xE7\xE3o e tecle Enter (esc cancela)."})]}):Yt(j7,{children:[Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir o rumo."})]}),Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"accent",children:"[r] redirecionar"}),Qn(f,{name:"fgDim",children:" (dar uma nova instru\xE7\xE3o)"})]}),Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"accent",children:"[c] continuar mesmo assim"}),Qn(B7,{children:" "}),Qn(f,{name:"fgDim",children:"[n] encerrar"})]})]}),Yt(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as xi,Text as bF}from"ink";import{jsx as Lr,jsxs as Vt}from"react/jsx-runtime";var vF=96;function H7(t){let e=t.replace(/\s+/g," ").trim();return e.length<=vF?e:e.slice(0,vF-1)+"\u2026"}function KS(t){let e=G(),o=H7(t.reason),n=Math.round(Math.max(0,Math.min(1,t.confidence))*100);return Vt(xi,{flexDirection:"column",paddingLeft:2,children:[Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.topLeft," "]}),Lr(I,{name:"clock",role:"accent"}),Vt(f,{name:"accent",children:[" ",t.ceilingLabel," atingido ",e.box.horizontal.repeat(4)," pausado"]})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(f,{name:"fgDim",children:"o teto do ciclo bateu, mas o juiz local sugere continuar."})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(f,{name:"fgDim",children:"motivo do juiz (local \xB7 n\xE3o verificado):"})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(bF,{wrap:"truncate-end",children:Lr(f,{name:"fg",children:o})})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Vt(f,{name:"fgDim",children:["confian\xE7a do juiz: ",n,"% (dado \u2014 pondere, n\xE3o obede\xE7a)"]})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(f,{name:"accent",children:"[c] continua"}),Lr(f,{name:"fgDim",children:" (estende um teto-worth)"}),Lr(bF,{children:" "}),Lr(f,{name:"fgDim",children:"[n] encerra"})]}),Vt(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as lve}from"ink";import{jsx as uve,jsxs as mve}from"react/jsx-runtime";import q7 from"react";import{Box as ml,Text as W7}from"ink";import{Fragment as z7,jsx as tn,jsxs as ds}from"react/jsx-runtime";function G7(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 ds(f,{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 ds(z7,{children:[ds(f,{name:e,children:["/",r]}),tn(f,{name:"accent",children:s}),tn(f,{name:e,children:i})]})}function rh(t){let e=t.query??"",o=t.maxRows!==void 0?aO(t.commands,t.selected,t.maxRows,t.columns):{slice:t.commands,hiddenAbove:0,hiddenBelow:0},n=t.selected-o.hiddenAbove,r=null;return ds(ml,{flexDirection:"column",children:[tn(ml,{children:tn(f,{name:"fgDim",children:"/ para comandos \xB7 \u2191\u2193 navega \xB7 enter executa \xB7 esc fecha"})}),o.hiddenAbove>0&&tn(ml,{children:ds(f,{name:"fgDim",children:[" \u2191 ",o.hiddenAbove," acima"]})}),o.slice.map((s,i)=>{let a=i===n,l=Sx(s),c=l!==r?l:null;r=l;let d=gp(s),m=s.kind==="subcommand",u=a?"\u203A ":m?" ":" ";return ds(q7.Fragment,{children:[c&&tn(ml,{children:tn(f,{name:"fgDim",children:c==="usu\xE1rio"?"\u2500\u2500\u2500 seus comandos":c})}),ds(ml,{children:[tn(f,{name:a?"accent":"fgDim",children:u}),tn(G7,{path:d,query:e,sel:a,sub:m}),tn(W7,{children:" ".repeat(Math.max(1,18-d.length))}),tn(f,{name:"fgDim",children:Ex(s)})]})]},`${l}:${d}`)}),o.hiddenBelow>0&&tn(ml,{children:ds(f,{name:"fgDim",children:[" \u2193 ",o.hiddenBelow," mais (refine a busca)"]})})]})}import"react";import{Box as fl,Text as K7}from"ink";import{Fragment as X7,jsx as wo,jsxs as gu}from"react/jsx-runtime";function Y7(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return wo(f,{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(wo(f,{name:s?"accent":e,children:t.label.slice(r,i)},r)),r=i}return wo(X7,{children:n})}function V7(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 sh(t){let{t:e}=ge(),o=t.maxRows??8,n=t.query??"",{start:r,slice:s}=V7(t.hits,t.selected,o),i=s.reduce((a,l)=>Math.max(a,l.label.length),0);return gu(fl,{flexDirection:"column",children:[wo(fl,{children:wo(f,{name:"fgDim",children:e("picker.palette.help")})}),gu(fl,{children:[wo(f,{name:"accent",children:"> "}),n===""?wo(f,{name:"fgDim",children:e("picker.palette.search")}):wo(f,{name:"fg",children:n})]}),t.hits.length===0?wo(fl,{children:gu(f,{name:"fgDim",children:[" ",e("picker.palette.empty",{query:n})]})}):s.map((a,l)=>{let d=r+l===t.selected;return gu(fl,{children:[wo(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),wo(Y7,{label:a.label,matched:a.matched,sel:d}),wo(K7,{children:" ".repeat(Math.max(1,i-a.label.length+2))}),wo(f,{name:"fgDim",children:a.description})]},a.id)}),t.hits.length>s.length&&wo(fl,{children:gu(f,{name:"fgDim",children:[" ",e("picker.palette.more",{count:t.hits.length-s.length})]})})]})}import"react";import{Box as yu}from"ink";import{Fragment as Z7,jsx as Zn,jsxs as ih}from"react/jsx-runtime";function kF(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 J7(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Zn(f,{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(Zn(f,{name:s?"accent":e,children:a},r)),r=i}return Zn(Z7,{children:n})}function Q7(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 YS(t){let{t:e}=ge(),o=t.columns??80,n=t.maxRows??8,r=Math.max(8,o-4),{start:s,slice:i}=Q7(t.hits,t.selected,n);return ih(yu,{flexDirection:"column",children:[Zn(yu,{children:Zn(f,{name:"fgDim",children:e("picker.file.help")})}),t.hits.length===0?Zn(yu,{children:ih(f,{name:"fgDim",children:[" ",e("picker.file.empty",{query:t.query??""})]})}):i.map((a,l)=>{let d=s+l===t.selected,m=kF(a.path,r),u=m===a.path;return ih(yu,{children:[Zn(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),u?Zn(J7,{path:a.path,matched:a.matched,sel:d}):Zn(f,{name:d?"accent":"fg",children:m})]},a.path)}),t.hits.length>i.length&&Zn(yu,{children:ih(f,{name:"fgDim",children:[" ",e("picker.file.more",{count:t.hits.length-i.length})]})})]})}import"react";import{Box as Ue,Text as eK}from"ink";import{Fragment as VS,jsx as Q,jsxs as We}from"react/jsx-runtime";var tK={keep:"picker.effort.keep",low:"picker.effort.low",medium:"picker.effort.medium",high:"picker.effort.high",custom:"picker.effort.custom"};function ah(t){let{t:e}=ge();if(t.effortStepOpen)return Q(iK,{...t});if(t.customInputOpen)return Q(oK,{...t});let o=t.tiers.length;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.model.help")})}),t.loading?Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.loading")]})}):We(VS,{children:[t.tiers.map((n,r)=>{let s=r===t.selected,i=n.key===t.currentTier,a=Hx(n),l=jx(n.costSignal);return We(Ue,{children:[Q(f,{name:s?"accent":"fgDim",children:s?"\u203A ":" "}),Q(f,{name:i?"accent":"fgDim",children:i?"\u25CF ":" "}),Q(f,{name:s?"accent":"fg",children:n.displayName}),a!==""&&We(VS,{children:[Q(f,{name:"fgDim",children:" \xB7 "}),Q(f,{name:"depth",children:a})]}),We(f,{name:"fgDim",children:[" \xB7 ",l]})]},n.key)}),We(Ue,{children:[Q(f,{name:t.selected===o?"accent":"fgDim",children:t.selected===o?"\u203A ":" "}),Q(f,{name:t.currentTier==="custom"?"accent":"fgDim",children:t.currentTier==="custom"?"\u25CF ":" "}),Q(f,{name:t.selected===o?"accent":"fg",children:"Custom"}),We(f,{name:"fgDim",children:[" \xB7 ",e("picker.model.customLine")]})]},"__custom__")]}),t.usingFallback===!0&&!t.loading&&Q(Ue,{children:We(f,{name:"fgDim",children:[" ","\u25CD ",e("picker.model.fallback")]})})]})}function oK(t){return t.customBrowserAvailable===!0?Q(sK,{...t}):Q(lK,{...t})}function nK(t){return t.supportsTools===!0?Q(f,{name:"accent",children:"\u2713 tools"}):t.supportsTools===!1?Q(f,{name:"fgDim",children:"\u2014 tools"}):Q(f,{name:"fgDim",children:"\xB7 tools?"})}function rK(t){let{model:e,highlighted:o}=t.row,n=[e.family,e.context].map(r=>r.trim()).filter(r=>r!=="");return We(Ue,{children:[Q(f,{name:o?"accent":"fgDim",children:o?"\u203A ":" "}),Q(f,{name:o?"accent":"fg",children:e.id}),n.length>0&&We(VS,{children:[Q(f,{name:"fgDim",children:" "}),Q(f,{name:"depth",children:n.join(" \xB7 ")})]}),Q(eK,{children:" "}),Q(nK,{supportsTools:e.supportsTools})]})}function sK(t){let{t:e}=ge(),o=t.customInput??"",n=t.customRows??[],r=t.customFilteredCount??0,s=t.customTotalCount??0,i=t.customToolsOnly===!0,a=t.customNoToolsWarning??null;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.model.browseHelp")})}),We(Ue,{children:[Q(f,{name:"accent",children:"filtro \u203A "}),Q(f,{name:"fg",children:o}),Q(f,{name:"accent",children:"\u258F"}),We(f,{name:"fgDim",children:[" ",e("picker.model.browseCount",{filtered:r,total:s}),i?e("picker.model.toolsOnlySuffix"):""]})]}),t.customHasMoreAbove===!0&&Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.moreAbove")]})}),n.length===0?Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.noFilterMatch")]})}):Q(Ue,{flexDirection:"column",children:n.map(l=>Q(rK,{row:l},l.model.id))}),t.customHasMoreBelow===!0&&Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.moreBelow")]})}),a!==null&&Q(Ue,{children:We(f,{name:"accent",children:[" ",e("picker.model.noTools")]})})]})}function iK(t){let{t:e}=ge();if(t.effortCustomOpen===!0)return Q(aK,{...t});let o=t.effortOptions??[],n=t.effortSelected??0,r=t.currentEffort;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.effort.help")})}),o.map((s,i)=>{let a=i===n,l=s.kind==="level"&&s.value===r||s.kind==="keep"&&(r===void 0||r==="");return We(Ue,{children:[Q(f,{name:a?"accent":"fgDim",children:a?"\u203A ":" "}),Q(f,{name:l?"accent":"fgDim",children:l?"\u25CF ":" "}),Q(f,{name:a?"accent":"fg",children:e(tK[s.id]??"picker.effort.keep")})]},s.id)})]})}function aK(t){let{t:e}=ge(),o=t.effortCustomInput??"",n=t.effortCustomWarn??null;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.effort.customHelp")})}),We(Ue,{children:[Q(f,{name:"accent",children:"\u203A "}),Q(f,{name:"fg",children:o}),Q(f,{name:"accent",children:"\u258F"})]}),n!==null&&Q(Ue,{children:We(f,{name:"accent",children:[" ",e(n==="empty"?"picker.effort.warnEmpty":"picker.effort.warnTooLong")]})})]})}function lK(t){let{t:e}=ge(),o=t.customInput??"",n=t.customSuggestions??[],r=t.customWarnOutOfCatalog===!0;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.model.freeHelp")})}),We(Ue,{children:[Q(f,{name:"accent",children:"\u203A "}),Q(f,{name:"fg",children:o}),Q(f,{name:"accent",children:"\u258F"})]}),n.length>0&&Q(Ue,{flexDirection:"column",children:n.map(s=>We(Ue,{children:[Q(f,{name:"fgDim",children:" \u25CD "}),Q(f,{name:"depth",children:s})]},s))}),r&&Q(Ue,{children:We(f,{name:"accent",children:[" ",e("picker.model.outOfCatalog")]})})]})}import"react";import{Box as vu,Text as wF}from"ink";var XS=15;function JS(t,e=XS){let o;try{o=t.list()}catch{return[]}return o.slice(0,Math.max(0,e))}function xF(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 cK(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 bu(t,e){let o=Ud(t.cwd,e??process.env.HOME??""),n=t.label?.trim();if(n)return`${n} \xB7 ${xF(t.updatedAt)} \xB7 ${o}`;let r=t.title??(t.blocks?cK(t.blocks):void 0)??"(sem objetivo)";return`${xF(t.updatedAt)} \xB7 ${o} \xB7 ${r}`}function dK(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}${bu(n,e)}`)}return o}function SF(t,e){e.switchSession({id:t.id,cwd:t.cwd,tier:t.tier}),e.resetContinuation?.(),e.clearScreen(),e.restoreBlocks(t.blocks);let o=ti(t.blocks);o.length>0&&e.seedHistory(o),t.cwd.trim()!==""&&e.setSessionCwd?.(t.cwd)}function EF(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=JS(o.store,o.limit);for(let a of dK(i,o.home))e.write(`[history] ${a}
586
+ `).map((n,r)=>qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"fg",children:n})]},`q-${r}`)),lo(f,{name:"accent",children:e.box.vertical}),o.kind==="text"?lo(F7,{theme:e,draft:t.draft??""}):lo(L7,{...t}),qe(f,{name:"accent",children:[e.box.teeLeft,e.box.horizontal.repeat(HS),e.box.teeRight]}),qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"fgDim",children:I7(o,t.editing===!0)})]}),qe(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(HS),e.box.bottomRight]})]})}function L7(t){let e=G(),{spec:o}=t,n=o.options??[],r=o.kind==="multi",s=t.selected??new Set;return qe(xn,{flexDirection:"column",children:[n.map((i,a)=>{let l=t.cursor===a,c=r?s.has(a)?"[x]":"[ ]":l?"(\u2022)":"( )";return qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),qe(f,{name:l?"accent":"fgDim",children:[l?"\u203A":" "," "]}),qe(f,{name:l?"accent":"fgDim",children:[c," "]}),lo(f,{name:l?"accent":"fg",children:i.label}),i.description!==void 0&&qe(f,{name:"fgDim",children:[" \u2014 ",i.description]})]},`opt-${a}`)}),O7(o)&&lo(P7,{theme:e,onCursor:t.cursor===Xn,editing:t.editing===!0&&t.cursor===Xn,draft:t.draft??""})]})}function P7(t){let{theme:e,onCursor:o,editing:n,draft:r}=t;return qe(xn,{flexDirection:"column",children:[qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),qe(f,{name:o?"accent":"fgDim",children:[o?"\u203A":" "," "]}),lo(f,{name:o?"accent":"fg",children:"Outro (resposta livre)"})]}),n&&qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),lo(f,{name:"fg",children:r}),lo(f,{name:"accent",children:e.glyph("cursor")})]})]})}function F7(t){let{theme:e,draft:o}=t;return qe(xn,{children:[qe(f,{name:"accent",children:[e.box.vertical," "]}),qe(f,{name:"depth",children:[e.glyph("prompt")," "]}),lo(f,{name:"fg",children:o}),lo(f,{name:"accent",children:e.glyph("cursor")})]})}function I7(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 hu}from"ink";import{jsx as nh,jsxs as en}from"react/jsx-runtime";function WS(t){let e=G(),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 en(hu,{flexDirection:"column",paddingLeft:4,children:[en(hu,{children:[en(f,{name:"danger",children:[e.box.topLeft," "]}),nh(I,{name:"broker",role:"depth"}),en(f,{name:"danger",children:[" ",n," ",e.box.horizontal.repeat(4)," "]}),nh(I,{name:"err",role:"danger"})]}),en(hu,{children:[en(f,{name:"danger",children:[e.box.vertical," "]}),nh(f,{name:"fg",children:t.message})]}),(t.status!==void 0||t.attempt!==void 0||t.retryInSeconds!==void 0)&&en(hu,{children:[en(f,{name:"danger",children:[e.box.vertical," "]}),en(f,{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})`:""]})]}),en(hu,{children:[en(f,{name:"danger",children:[e.box.vertical," "]}),nh(f,{name:"fgDim",children:r})]}),en(f,{name:"danger",children:[e.box.bottomLeft,e.box.horizontal.repeat(40)]})]})}import"react";import{Box as cs,Text as N7}from"ink";import{jsx as Jn,jsxs as ht}from"react/jsx-runtime";function $7(t){return t>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:t>=1e3?`${Math.round(t/1e3)}k`:String(t)}function GS(t){let e=G();return ht(cs,{flexDirection:"column",paddingLeft:2,children:[ht(cs,{children:[ht(f,{name:"accent",children:[e.box.topLeft," "]}),Jn(I,{name:"clock",role:"accent"}),ht(f,{name:"accent",children:[" teto da sess\xE3o ",e.box.horizontal.repeat(6)," pausado"]})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"fg",children:t.reason})]}),t.budgetPct!==void 0&&ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(I,{name:"clock",role:"accent"}),ht(f,{name:"accent",children:[" ",t.budgetPct,"% do teto da sess\xE3o"]}),t.maxTokens!==void 0&&ht(f,{name:"fgDim",children:[" (teto: ",$7(t.maxTokens)," tokens)"]})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir."})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(I,{name:"window",role:"fgDim"}),ht(f,{name:"fgDim",children:[" janela: ",t.windowPct,"% usada"]})]}),t.canCompact&&ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"accent",children:"[k] compactar"}),Jn(f,{name:"fgDim",children:" resume a conversa e continua (libera a janela)"})]}),ht(cs,{children:[ht(f,{name:"accent",children:[e.box.vertical," "]}),Jn(f,{name:"accent",children:"[c] continuar (+50 itera\xE7\xF5es)"}),Jn(N7,{children:" "}),Jn(f,{name:"fgDim",children:"[n] encerrar"})]}),ht(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as ki,Text as B7}from"ink";import{Fragment as j7,jsx as Qn,jsxs as Yt}from"react/jsx-runtime";function U7(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 zS(t){let e=G(),o=U7(t.kind,t.count,t.sample);return Yt(ki,{flexDirection:"column",paddingLeft:2,children:[Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.topLeft," "]}),Qn(I,{name:"clock",role:"accent"}),Yt(f,{name:"accent",children:[" parece travado ",e.box.horizontal.repeat(6)," pausado"]})]}),Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"fg",children:o})]}),t.redirecting?Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"accent",children:"[r] "}),Qn(f,{name:"fgDim",children:"digite a nova instru\xE7\xE3o e tecle Enter (esc cancela)."})]}):Yt(j7,{children:[Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"fgDim",children:"o agente pausou para voc\xEA decidir o rumo."})]}),Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"accent",children:"[r] redirecionar"}),Qn(f,{name:"fgDim",children:" (dar uma nova instru\xE7\xE3o)"})]}),Yt(ki,{children:[Yt(f,{name:"accent",children:[e.box.vertical," "]}),Qn(f,{name:"accent",children:"[c] continuar mesmo assim"}),Qn(B7,{children:" "}),Qn(f,{name:"fgDim",children:"[n] encerrar"})]})]}),Yt(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as xi,Text as bF}from"ink";import{jsx as Lr,jsxs as Vt}from"react/jsx-runtime";var vF=96;function H7(t){let e=t.replace(/\s+/g," ").trim();return e.length<=vF?e:e.slice(0,vF-1)+"\u2026"}function KS(t){let e=G(),o=H7(t.reason),n=Math.round(Math.max(0,Math.min(1,t.confidence))*100);return Vt(xi,{flexDirection:"column",paddingLeft:2,children:[Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.topLeft," "]}),Lr(I,{name:"clock",role:"accent"}),Vt(f,{name:"accent",children:[" ",t.ceilingLabel," atingido ",e.box.horizontal.repeat(4)," pausado"]})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(f,{name:"fgDim",children:"o teto do ciclo bateu, mas o juiz local sugere continuar."})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(f,{name:"fgDim",children:"motivo do juiz (local \xB7 n\xE3o verificado):"})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(bF,{wrap:"truncate-end",children:Lr(f,{name:"fg",children:o})})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Vt(f,{name:"fgDim",children:["confian\xE7a do juiz: ",n,"% (dado \u2014 pondere, n\xE3o obede\xE7a)"]})]}),Vt(xi,{children:[Vt(f,{name:"accent",children:[e.box.vertical," "]}),Lr(f,{name:"accent",children:"[c] continua"}),Lr(f,{name:"fgDim",children:" (estende um teto-worth)"}),Lr(bF,{children:" "}),Lr(f,{name:"fgDim",children:"[n] encerra"})]}),Vt(f,{name:"accent",children:[e.box.bottomLeft,e.box.horizontal.repeat(42)]})]})}import"react";import{Box as lve}from"ink";import{jsx as uve,jsxs as mve}from"react/jsx-runtime";import q7 from"react";import{Box as ml,Text as W7}from"ink";import{Fragment as z7,jsx as tn,jsxs as ds}from"react/jsx-runtime";function G7(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 ds(f,{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 ds(z7,{children:[ds(f,{name:e,children:["/",r]}),tn(f,{name:"accent",children:s}),tn(f,{name:e,children:i})]})}function rh(t){let e=t.query??"",o=t.maxRows!==void 0?aO(t.commands,t.selected,t.maxRows,t.columns):{slice:t.commands,hiddenAbove:0,hiddenBelow:0},n=t.selected-o.hiddenAbove,r=null;return ds(ml,{flexDirection:"column",children:[tn(ml,{children:tn(f,{name:"fgDim",children:"/ para comandos \xB7 \u2191\u2193 navega \xB7 enter executa \xB7 esc fecha"})}),o.hiddenAbove>0&&tn(ml,{children:ds(f,{name:"fgDim",children:[" \u2191 ",o.hiddenAbove," acima"]})}),o.slice.map((s,i)=>{let a=i===n,l=Sx(s),c=l!==r?l:null;r=l;let d=gp(s),m=s.kind==="subcommand",u=a?"\u203A ":m?" ":" ";return ds(q7.Fragment,{children:[c&&tn(ml,{children:tn(f,{name:"fgDim",children:c==="usu\xE1rio"?"\u2500\u2500\u2500 seus comandos":c})}),ds(ml,{children:[tn(f,{name:a?"accent":"fgDim",children:u}),tn(G7,{path:d,query:e,sel:a,sub:m}),tn(W7,{children:" ".repeat(Math.max(1,18-d.length))}),tn(f,{name:"fgDim",children:Ex(s)})]})]},`${l}:${d}`)}),o.hiddenBelow>0&&tn(ml,{children:ds(f,{name:"fgDim",children:[" \u2193 ",o.hiddenBelow," mais (refine a busca)"]})})]})}import"react";import{Box as fl,Text as K7}from"ink";import{Fragment as X7,jsx as wo,jsxs as gu}from"react/jsx-runtime";function Y7(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return wo(f,{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(wo(f,{name:s?"accent":e,children:t.label.slice(r,i)},r)),r=i}return wo(X7,{children:n})}function V7(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 sh(t){let{t:e}=ge(),o=t.maxRows??8,n=t.query??"",{start:r,slice:s}=V7(t.hits,t.selected,o),i=s.reduce((a,l)=>Math.max(a,l.label.length),0);return gu(fl,{flexDirection:"column",children:[wo(fl,{children:wo(f,{name:"fgDim",children:e("picker.palette.help")})}),gu(fl,{children:[wo(f,{name:"accent",children:"> "}),n===""?wo(f,{name:"fgDim",children:e("picker.palette.search")}):wo(f,{name:"fg",children:n})]}),t.hits.length===0?wo(fl,{children:gu(f,{name:"fgDim",children:[" ",e("picker.palette.empty",{query:n})]})}):s.map((a,l)=>{let d=r+l===t.selected;return gu(fl,{children:[wo(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),wo(Y7,{label:a.label,matched:a.matched,sel:d}),wo(K7,{children:" ".repeat(Math.max(1,i-a.label.length+2))}),wo(f,{name:"fgDim",children:a.description})]},a.id)}),t.hits.length>s.length&&wo(fl,{children:gu(f,{name:"fgDim",children:[" ",e("picker.palette.more",{count:t.hits.length-s.length})]})})]})}import"react";import{Box as yu}from"ink";import{Fragment as Z7,jsx as Zn,jsxs as ih}from"react/jsx-runtime";function kF(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 J7(t){let e=t.sel?"accent":"fg",o=new Set(t.matched);if(o.size===0)return Zn(f,{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(Zn(f,{name:s?"accent":e,children:a},r)),r=i}return Zn(Z7,{children:n})}function Q7(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 YS(t){let{t:e}=ge(),o=t.columns??80,n=t.maxRows??8,r=Math.max(8,o-4),{start:s,slice:i}=Q7(t.hits,t.selected,n);return ih(yu,{flexDirection:"column",children:[Zn(yu,{children:Zn(f,{name:"fgDim",children:e("picker.file.help")})}),t.hits.length===0?Zn(yu,{children:ih(f,{name:"fgDim",children:[" ",e("picker.file.empty",{query:t.query??""})]})}):i.map((a,l)=>{let d=s+l===t.selected,m=kF(a.path,r),u=m===a.path;return ih(yu,{children:[Zn(f,{name:d?"accent":"fgDim",children:d?"\u203A ":" "}),u?Zn(J7,{path:a.path,matched:a.matched,sel:d}):Zn(f,{name:d?"accent":"fg",children:m})]},a.path)}),t.hits.length>i.length&&Zn(yu,{children:ih(f,{name:"fgDim",children:[" ",e("picker.file.more",{count:t.hits.length-i.length})]})})]})}import"react";import{Box as Ue,Text as eK}from"ink";import{Fragment as VS,jsx as Q,jsxs as We}from"react/jsx-runtime";var tK={keep:"picker.effort.keep",low:"picker.effort.low",medium:"picker.effort.medium",high:"picker.effort.high",custom:"picker.effort.custom"};function ah(t){let{t:e}=ge();if(t.effortStepOpen)return Q(iK,{...t});if(t.customInputOpen)return Q(oK,{...t});let o=t.tiers.length;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.model.help")})}),t.loading?Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.loading")]})}):We(VS,{children:[t.tiers.map((n,r)=>{let s=r===t.selected,i=n.key===t.currentTier,a=Hx(n),l=jx(n.costSignal);return We(Ue,{children:[Q(f,{name:s?"accent":"fgDim",children:s?"\u203A ":" "}),Q(f,{name:i?"accent":"fgDim",children:i?"\u25CF ":" "}),Q(f,{name:s?"accent":"fg",children:n.displayName}),a!==""&&We(VS,{children:[Q(f,{name:"fgDim",children:" \xB7 "}),Q(f,{name:"depth",children:a})]}),We(f,{name:"fgDim",children:[" \xB7 ",l]})]},n.key)}),We(Ue,{children:[Q(f,{name:t.selected===o?"accent":"fgDim",children:t.selected===o?"\u203A ":" "}),Q(f,{name:t.currentTier==="custom"?"accent":"fgDim",children:t.currentTier==="custom"?"\u25CF ":" "}),Q(f,{name:t.selected===o?"accent":"fg",children:"Custom"}),We(f,{name:"fgDim",children:[" \xB7 ",e("picker.model.customLine")]})]},"__custom__")]}),t.usingFallback===!0&&!t.loading&&Q(Ue,{children:We(f,{name:"fgDim",children:[" ","\u25CD ",e("picker.model.fallback")]})})]})}function oK(t){return t.customBrowserAvailable===!0?Q(sK,{...t}):Q(lK,{...t})}function nK(t){return t.supportsTools===!0?Q(f,{name:"accent",children:"\u2713 tools"}):t.supportsTools===!1?Q(f,{name:"fgDim",children:"\u2014 tools"}):Q(f,{name:"fgDim",children:"\xB7 tools?"})}function rK(t){let{model:e,highlighted:o}=t.row,n=[e.family,e.context].map(r=>r.trim()).filter(r=>r!=="");return We(Ue,{children:[Q(f,{name:o?"accent":"fgDim",children:o?"\u203A ":" "}),Q(f,{name:o?"accent":"fg",children:e.id}),n.length>0&&We(VS,{children:[Q(f,{name:"fgDim",children:" "}),Q(f,{name:"depth",children:n.join(" \xB7 ")})]}),Q(eK,{children:" "}),Q(nK,{supportsTools:e.supportsTools})]})}function sK(t){let{t:e}=ge(),o=t.customInput??"",n=t.customRows??[],r=t.customFilteredCount??0,s=t.customTotalCount??0,i=t.customToolsOnly===!0,a=t.customNoToolsWarning??null;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.model.browseHelp")})}),We(Ue,{children:[Q(f,{name:"accent",children:"filtro \u203A "}),Q(f,{name:"fg",children:o}),Q(f,{name:"accent",children:"\u258F"}),We(f,{name:"fgDim",children:[" ",e("picker.model.browseCount",{filtered:r,total:s}),i?e("picker.model.toolsOnlySuffix"):""]})]}),t.customHasMoreAbove===!0&&Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.moreAbove")]})}),n.length===0?Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.noFilterMatch")]})}):Q(Ue,{flexDirection:"column",children:n.map(l=>Q(rK,{row:l},l.model.id))}),t.customHasMoreBelow===!0&&Q(Ue,{children:We(f,{name:"fgDim",children:[" ",e("picker.model.moreBelow")]})}),a!==null&&Q(Ue,{children:We(f,{name:"accent",children:[" ",e("picker.model.noTools")]})})]})}function iK(t){let{t:e}=ge();if(t.effortCustomOpen===!0)return Q(aK,{...t});let o=t.effortOptions??[],n=t.effortSelected??0,r=t.currentEffort;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.effort.help")})}),o.map((s,i)=>{let a=i===n,l=s.kind==="level"&&s.value===r||s.kind==="keep"&&(r===void 0||r==="");return We(Ue,{children:[Q(f,{name:a?"accent":"fgDim",children:a?"\u203A ":" "}),Q(f,{name:l?"accent":"fgDim",children:l?"\u25CF ":" "}),Q(f,{name:a?"accent":"fg",children:e(tK[s.id]??"picker.effort.keep")})]},s.id)})]})}function aK(t){let{t:e}=ge(),o=t.effortCustomInput??"",n=t.effortCustomWarn??null;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.effort.customHelp")})}),We(Ue,{children:[Q(f,{name:"accent",children:"\u203A "}),Q(f,{name:"fg",children:o}),Q(f,{name:"accent",children:"\u258F"})]}),n!==null&&Q(Ue,{children:We(f,{name:"accent",children:[" ",e(n==="empty"?"picker.effort.warnEmpty":"picker.effort.warnTooLong")]})})]})}function lK(t){let{t:e}=ge(),o=t.customInput??"",n=t.customSuggestions??[],r=t.customWarnOutOfCatalog===!0;return We(Ue,{flexDirection:"column",children:[Q(Ue,{children:Q(f,{name:"fgDim",children:e("picker.model.freeHelp")})}),We(Ue,{children:[Q(f,{name:"accent",children:"\u203A "}),Q(f,{name:"fg",children:o}),Q(f,{name:"accent",children:"\u258F"})]}),n.length>0&&Q(Ue,{flexDirection:"column",children:n.map(s=>We(Ue,{children:[Q(f,{name:"fgDim",children:" \u25CD "}),Q(f,{name:"depth",children:s})]},s))}),r&&Q(Ue,{children:We(f,{name:"accent",children:[" ",e("picker.model.outOfCatalog")]})})]})}import"react";import{Box as vu,Text as wF}from"ink";var XS=15;function JS(t,e=XS){let o;try{o=t.list()}catch{return[]}return o.slice(0,Math.max(0,e))}function xF(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 cK(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 bu(t,e){let o=Ud(t.cwd,e??process.env.HOME??""),n=t.label?.trim();if(n)return`${n} \xB7 ${xF(t.updatedAt)} \xB7 ${o}`;let r=t.title??(t.blocks?cK(t.blocks):void 0)??"(sem objetivo)";return`${xF(t.updatedAt)} \xB7 ${o} \xB7 ${r}`}function dK(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}${bu(n,e)}`)}return o}function SF(t,e){e.switchSession({id:t.id,cwd:t.cwd,tier:t.tier}),e.resetContinuation?.(),e.clearScreen(),e.restoreBlocks(t.blocks);let o=ti(t.blocks);o.length>0&&e.seedHistory(o),t.cwd.trim()!==""&&e.setSessionCwd?.(t.cwd)}function EF(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=JS(o.store,o.limit);for(let a of dK(i,o.home))e.write(`[history] ${a}
587
587
  `);return!0}let s=o.store.load(r);return s?(o.resume(s),e.write(`[history] sess\xE3o retomada: ${r} (${bu(s,o.home)})
588
588
  `),!0):(e.write(`[history] sess\xE3o n\xE3o encontrada: ${r}
589
589
  `),!0)}function er(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)),l=a,c=a+1,d=s(a),m=!0,u=!0;for(;u;){u=!1;let p=()=>l>0&&d+s(l-1)<=o?(l-=1,d+=s(l),!0):!1,h=()=>c<r&&d+s(c)<=o?(d+=s(c),c+=1,!0):!1;u=m?p()||h():h()||p(),m=!m}return{start:l,slice:t.slice(l,c)}}import{Fragment as uK,jsx as us,jsxs as ku}from"react/jsx-runtime";function lh(t){let e=G(),{t:o}=ge(),n=e.glyph("sessionDot"),r=Math.max(1,t.maxRows??10),s=t.columns,i=s!==void 0&&s>0?c=>{let d=2+(c.label?.trim()?2:0)+he(bu(c,t.home));return Math.max(1,Math.ceil(d/s))}:void 0,{start:a,slice:l}=er(t.sessions,t.selected,r,i);return ku(vu,{flexDirection:"column",children:[us(vu,{children:us(f,{name:"fgDim",children:o("picker.history.help")})}),t.sessions.length===0?us(vu,{children:ku(f,{name:"fgDim",children:[" ",o("picker.history.empty")]})}):l.map((c,d)=>{let u=a+d===t.selected,p=c.label?.trim(),h=p?e.sessionColor(c.labelColor??p):void 0,y={};return h?.color!==void 0&&(y.color=h.color),h?.bold!==void 0&&(y.bold=h.bold),ku(vu,{children:[us(f,{name:u?"accent":"fgDim",children:u?"\u203A ":" "}),p&&ku(uK,{children:[us(wF,{...y,children:n}),us(wF,{children:" "})]}),us(f,{name:u?"accent":"fg",children:bu(c,t.home)})]},c.id)}),t.sessions.length>l.length&&us(vu,{children:ku(f,{name:"fgDim",children:[" ",o("picker.history.more",{count:t.sessions.length-l.length})]})})]})}import"react";import{Box as on}from"ink";var ch=["both","conversation","code"];function AF(t,e=30){return[...t].reverse().slice(0,e)}function QS(t){let e=mK(t.ts);return`#${t.ordinal} \xB7 ${e} \xB7 ${t.label}`}function mK(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 Xt,jsxs as Si}from"react/jsx-runtime";function fK(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 dh(t){let{t:e}=ge();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+he(QS(a)))/n)):void 0,{start:s,slice:i}=er(t.checkpoints,t.selected,o,r);return Si(on,{flexDirection:"column",children:[Xt(on,{children:Xt(f,{name:"fgDim",children:e("picker.rewind.help")})}),t.checkpoints.length===0?Xt(on,{children:Si(f,{name:"fgDim",children:[" ",e("picker.rewind.empty")]})}):i.map((a,l)=>{let c=s+l===t.selected;return Si(on,{children:[Xt(f,{name:c?"accent":"fgDim",children:c?"\u203A ":" "}),Xt(f,{name:c?"accent":"fg",children:QS(a)})]},a.id)}),t.checkpoints.length>i.length&&Xt(on,{children:Si(f,{name:"fgDim",children:[" ",e("picker.rewind.more",{count:t.checkpoints.length-i.length})]})})]})}return Si(on,{flexDirection:"column",children:[Xt(on,{children:Xt(f,{name:"fgDim",children:e("picker.rewind.action.help")})}),t.target&&Xt(on,{children:Xt(f,{name:"fgDim",children:` \u2192 #${t.target.ordinal} \xB7 ${t.target.label}`})}),t.actions.map((o,n)=>{let r=n===t.selected;return Si(on,{children:[Xt(f,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),Xt(f,{name:r?"accent":"fg",children:e(fK(o))})]},o)}),t.barrierWarnings&&t.barrierWarnings.length>0&&Si(on,{flexDirection:"column",marginTop:1,children:[Xt(on,{children:Xt(f,{name:"accent",children:`\u26A0 ${e("picker.rewind.barrier.warn")}:`})}),t.barrierWarnings.map((o,n)=>Xt(on,{children:Xt(f,{name:"fgDim",children:` \xB7 ${o}`})},n))]})]})}import pK from"react";import{Box as co,Text as hK}from"ink";import{Fragment as vK,jsx as je,jsxs as Uo}from"react/jsx-runtime";var ZS={plan:"PLAN (read-only)",normal:"NORMAL (catraca padr\xE3o)",unsafe:"YOLO (aprova\xE7\xE3o DESLIGADA)"};function gK(t){switch(t){case"mode":return"modo de sess\xE3o \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 sess\xE3o \xB7 enter REVOGA";case"locked":return"TRAVADO por seguran\xE7a \xB7 s\xF3 via --yolo"}}function yK(t){let{row:e,sel:o}=t,n=je(f,{name:o?"accent":"fgDim",children:o?"\u203A ":" "});switch(e.kind){case"mode":return Uo(co,{children:[n,je(f,{name:o?"accent":"fg",children:"modo: "}),je(f,{name:e.mode==="unsafe"?"danger":o?"accent":"fg",children:ZS[e.mode]})]});case"safe-tool":return Uo(co,{children:[n,je(f,{name:o?"accent":"fg",children:e.tool}),je(f,{name:"fgDim",children:" = "}),je(f,{name:e.decision==="allow"?"success":"fgDim",children:e.decision})]});case"grant":return Uo(co,{children:[n,je(f,{name:"success",children:"\u25CF "}),je(f,{name:o?"accent":"fg",children:e.grantKey}),je(f,{name:"fgDim",children:" (enter revoga)"})]});case"locked":{let r=e.category.lock==="deny";return Uo(co,{flexDirection:"column",children:[Uo(co,{children:[n,je(I,{name:"ask",role:"danger"}),je(f,{name:"danger",children:" [travado] "}),je(f,{name:o?"accent":"fg",children:e.category.label}),Uo(f,{name:"danger",children:[" \xB7 ",r?"deny (nem --yolo)":"sempre pergunta"]})]}),o&&je(co,{paddingLeft:4,children:je(f,{name:"fgDim",children:e.category.why})})]})}}}function eE(t){let e=Math.max(1,t.maxRows??14),o=t.columns,n=l=>{switch(l.kind){case"mode":return 8+he(ZS[l.mode]);case"safe-tool":return 5+he(l.tool)+he(l.decision);case"grant":return 19+he(l.grantKey);case"locked":return 28+he(l.category.label)}},r=o!==void 0&&o>0?l=>Math.max(1,Math.ceil(n(l)/o)):void 0,{start:s,slice:i}=er(t.rows,t.selected,e,r),a=null;return Uo(co,{flexDirection:"column",children:[je(co,{children:je(f,{name:"fgDim",children:"permissoes \xB7 \u2191\u2193 navega \xB7 enter muda \xB7 esc fecha"})}),Uo(co,{children:[je(f,{name:"fgDim",children:"modo atual: "}),je(f,{name:t.mode==="unsafe"?"danger":"fg",children:ZS[t.mode]})]}),t.rows.length===0?je(co,{children:je(f,{name:"fgDim",children:" nada a mostrar"})}):Uo(vK,{children:[s>0&&je(co,{children:Uo(f,{name:"fgDim",children:[" \u2191 ",s," acima"]})}),i.map((l,c)=>{let d=s+c,m=l.kind!==a?gK(l.kind):null;return a=l.kind,Uo(pK.Fragment,{children:[m&&je(co,{paddingTop:1,children:Uo(f,{name:"fgDim",children:["\u2500\u2500\u2500 ",m]})}),je(yK,{row:l,sel:d===t.selected})]},bK(l,d))}),s+i.length<t.rows.length&&je(co,{children:Uo(f,{name:"fgDim",children:[" \u2193 ",t.rows.length-(s+i.length)," abaixo"]})})]}),je(co,{paddingTop:1,children:je(hK,{children:" "})}),je(co,{children:je(f,{name:"fgDim",children:"o painel n\xE3o relaxa as categorias travadas \u2014 o \xFAnico bypass total \xE9 --yolo"})})]})}function bK(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 tE}from"ink";import{jsx as xu,jsxs as oE}from"react/jsx-runtime";function uh(t){let{t:e}=ge();return oE(tE,{flexDirection:"column",children:[xu(tE,{children:xu(f,{name:"fgDim",children:e("picker.theme.help")})}),t.themes.map((o,n)=>{let r=n===t.selected,s=o.name===t.currentTheme;return oE(tE,{children:[xu(f,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),xu(f,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),xu(f,{name:r?"accent":"fg",children:o.label}),oE(f,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.name)})]})}import"react";import{Box as nE}from"ink";import{jsx as Su,jsxs as rE}from"react/jsx-runtime";function mh(t){let{t:e}=ge();return rE(nE,{flexDirection:"column",children:[Su(nE,{children:Su(f,{name:"fgDim",children:e("picker.lang.help")})}),t.langs.map((o,n)=>{let r=n===t.selected,s=o.code===t.currentLang;return rE(nE,{children:[Su(f,{name:r?"accent":"fgDim",children:r?"\u203A ":" "}),Su(f,{name:s?"accent":"fgDim",children:s?"\u25CF ":" "}),Su(f,{name:r?"accent":"fg",children:o.label}),rE(f,{name:"fgDim",children:[" \xB7 ",o.summary]})]},o.code)})]})}import"react";import{Box as Eu}from"ink";import{jsx as ms,jsxs as wu}from"react/jsx-runtime";function sE(t){let{t:e}=ge(),o=Math.max(1,t.maxRows??10),n=t.columns,r=n!==void 0&&n>0?a=>{let l=4+he(`${a.label} \xB7 ${a.summary}`)+(a.isDefault?2+he(e("picker.provider.default")):0);return Math.max(1,Math.ceil(l/n))}:void 0,{start:s,slice:i}=er(t.providers,t.selected,o,r);return wu(Eu,{flexDirection:"column",children:[ms(Eu,{children:ms(f,{name:"fgDim",children:e("picker.provider.help")})}),t.usingFallback===!0?ms(Eu,{children:ms(f,{name:"fgDim",children:e("picker.provider.fallback")})}):null,i.map((a,l)=>{let c=s+l===t.selected,d=a.name===t.currentProvider;return wu(Eu,{children:[ms(f,{name:c?"accent":"fgDim",children:c?"\u203A ":" "}),ms(f,{name:d?"accent":"fgDim",children:d?"\u25CF ":" "}),ms(f,{name:c?"accent":"fg",children:a.label}),wu(f,{name:"fgDim",children:[" \xB7 ",a.summary]}),a.isDefault?wu(f,{name:"fgDim",children:[" \xB7 ",e("picker.provider.default")]}):null]},a.name)}),t.providers.length>i.length&&ms(Eu,{children:wu(f,{name:"fgDim",children:[" ",e("picker.provider.more",{count:t.providers.length-i.length})]})})]})}import"react";import{Box as CF,Text as kK}from"ink";import{jsx as iE,jsxs as TF}from"react/jsx-runtime";function aE(t){if(t.chips.length===0)return null;let e=t.active??-1;return iE(CF,{flexWrap:"wrap",children:t.chips.map((o,n)=>{let r=n===e;return TF(CF,{marginRight:1,children:[TF(f,{name:r?"accent":"depth",children:[r?"\u203A ":"","@",o.path,o.truncated?"~":""]}),iE(kK,{children:" "}),iE(f,{name:"fgDim",children:"[\u232B]"})]},o.path)})})}import"react";import{Box as Au,Text as DF}from"ink";import{jsx as Sn,jsxs as fs}from"react/jsx-runtime";function lE(t){let e=G(),{t:o}=ge(),n=t.columns??80,r=t.plan??"assinatura",s=e.glyph("wave").repeat(17);return fs(Au,{flexDirection:"column",paddingY:1,children:[Sn(ui,{columns:n}),Sn(Au,{paddingTop:1,paddingLeft:2,children:Sn(f,{name:"fgDim",children:o("boot.tagline")})}),fs(Au,{paddingLeft:2,children:[Sn(f,{name:"accent",children:s}),t.version!==void 0&&fs(f,{name:"fgDim",children:[" v",t.version]})]}),fs(Au,{paddingLeft:2,children:[Sn(I,{name:"window",role:"fgDim"}),fs(f,{name:"fgDim",children:[" ",r," \xB7 "]}),Sn(f,{name:"fgDim",children:t.tier}),Sn(DF,{children:" "}),Sn(f,{name:"fgDim",children:"\xB7 "}),Sn(I,{name:"broker",role:"depth"}),fs(f,{name:"depth",children:[" ",o("boot.broker")]})]}),t.status!==void 0&&fs(Au,{paddingTop:1,paddingLeft:2,children:[Sn(gi,{frame:t.frame??0}),Sn(DF,{children:" "}),fs(f,{name:"fgDim",children:[t.status,"\u2026"]})]})]})}import"react";import{Box as _F}from"ink";import{jsx as cE,jsxs as dE}from"react/jsx-runtime";var xK=['"explique a estrutura deste repo"','"rode os testes e resuma as falhas"',"/help para comandos \xB7 /login conta \xB7 /quit"];function uE(t){let e=t.suggestions??xK;return dE(_F,{flexDirection:"column",children:[cE(f,{name:"fg",children:t.name?`bom te ver de novo, ${t.name}.`:"bom te ver por aqui."}),cE(f,{name:"fgDim",children:"eu leio e edito arquivos e rodo comandos aqui \u2014 sempre te mostrando o efeito exato antes."}),dE(_F,{paddingTop:1,flexDirection:"column",children:[cE(f,{name:"fgDim",children:"experimente:"}),e.map((o,n)=>dE(f,{name:"fgDim",children:[" \xB7 ",o]},n))]})]})}import"react";import{jsx as pxe}from"react/jsx-runtime";import"react";import{Box as SK}from"ink";import{jsx as EK,jsxs as RF}from"react/jsx-runtime";function mE(t){let{t:e}=ge(),o=(t.columns??80)<60,n=e(o?"banner.yolo.narrow":"banner.yolo");return RF(SK,{children:[EK(I,{name:"ask",role:"danger"}),RF(f,{name:"danger",children:[" ",n]})]})}import"react";import{Box as wK}from"ink";import{jsx as MF,jsxs as fE}from"react/jsx-runtime";var AK={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 fh(t){let{t:e}=ge();if(t.mode==="unsafe")return MF(mE,{...t.columns!==void 0?{columns:t.columns}:{}});let o=AK[t.mode],n=(t.columns??80)<60;return fE(wK,{children:[MF(I,{name:o.glyph,role:o.role}),fE(f,{name:o.role,children:[" ",e("mode.label")," ",o.word]}),!n&&fE(f,{name:"fgDim",children:[" \xB7 ",e(o.caption)]})]})}import"react";import{jsx as pE}from"react/jsx-runtime";var CK={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"},TK=new Set(["thinking","streaming","work-subagents"]);function Cu(t){let{t:e}=ge();if(t.armedExit===!0)return pE(f,{name:"accent",children:e("hints.ctrlcAgain")});let o=e(CK[t.state]),n=t.elapsed!==void 0&&t.elapsed!==""&&TK.has(t.state);return t.suggesting===!0&&t.state==="idle"?pE(f,{name:"fgDim",children:`${o} \xB7 ${e("hints.suggest")}`}):pE(f,{name:"fgDim",children:n?`${o} \xB7 ${t.elapsed}`:o})}import"react";import{Box as hE}from"ink";import{jsx as gE,jsxs as yE}from"react/jsx-runtime";function ph(t){return yE(hE,{flexDirection:"column",children:[yE(hE,{children:[gE(I,{name:"clock",role:"depth"}),yE(f,{name:"depth",children:[" ",t.title]})]}),gE(hE,{flexDirection:"column",paddingLeft:2,children:t.lines.map((e,o)=>gE(f,{name:"fgDim",children:e},o))})]})}import"react";import{Box as Ei,Text as DK}from"ink";import{jsx as En,jsxs as nn}from"react/jsx-runtime";var _K=4,RK="shell";function bE(t){let e=G();if(t.status==="running"){let a=Yn(t.liveOutput??"",al).replace(/\n+$/,""),l=t.columns&&t.columns>0?t.columns-_K:0,{text:c,hidden:d}=Cr(a,t.maxLines,l);return nn(Ei,{flexDirection:"column",paddingLeft:2,children:[En(bi,{glyph:"toolInflight",glyphRole:"depth",label:`rodando $ ${t.command}`,...t.frame!==void 0?{frame:t.frame}:{}}),c.length>0&&nn(Ei,{flexDirection:"column",paddingLeft:2,children:[d>0&&nn(f,{name:"fgDim",children:["\u2026 (",d," linhas acima)"]}),c.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiperplano/aluy-cli",
3
- "version": "1.0.0-rc.110",
3
+ "version": "1.0.0-rc.111",
4
4
  "description": "Aluy CLI — TUI (Ink) + binário `aluy` + wiring. Consome @hiperplano/aluy-cli-core (engine portável). Credenciais só no keychain do SO.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",