hablas-ai 1.3.8 → 1.3.9

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.
Files changed (2) hide show
  1. package/dist/index.js +4 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1085,9 +1085,9 @@ ${t.content}`).join(`
1085
1085
  `)}persistKV(){if(this.kvStore.size===0)return;let e=this.read("CONTEXT.md")||mg,t=Array.from(this.kvStore.entries()).map(([i,o])=>`- **${i}**: ${o}`).join(`
1086
1086
  `),s=/## Notes\n[\s\S]*$/,r=e.replace(s,`## Notes
1087
1087
  ${t}
1088
- `);this.write("CONTEXT.md",r)}ensureDir(){re.existsSync(this.contextDir)||re.mkdirSync(this.contextDir,{recursive:!0})}}});function Bl(n){return xe.find(e=>e.role===n)?.name||n}var xs,yg=L(()=>{"use strict";Ns();Hl();xs=class{channel;runner;chat;constructor(e,t,s,r){this.channel=e,this.runner=t,this.chat=s,this.runner.setChannel(e),this.chat.resetBudget()}async run(e,t,s,r={}){this.chat.setAbortSignal(r.abortSignal);let i=r.peerReview!==!1,o=new Dn(process.cwd());this.runner.setSharedContext(o),this.channel.emitEvent({type:"phase",agent:"System",content:"Delegating to the team"});let a=t.tasks.filter(h=>h.role!=="hablas").map(h=>({role:h.role,task:`${h.description}
1088
+ `);this.write("CONTEXT.md",r)}ensureDir(){re.existsSync(this.contextDir)||re.mkdirSync(this.contextDir,{recursive:!0})}}});function Bl(n){return xe.find(e=>e.role===n)?.name||n}var xs,yg=L(()=>{"use strict";Ns();Hl();xs=class{channel;runner;chat;constructor(e,t,s,r){this.channel=e,this.runner=t,this.chat=s,this.runner.setChannel(e),this.chat.resetBudget()}async run(e,t,s,r={}){this.chat.setAbortSignal(r.abortSignal);let i=r.peerReview!==!1,o=r.centralizedToLeader===!0,a=new Dn(process.cwd());this.runner.setSharedContext(a),this.channel.emitEvent({type:"phase",agent:"System",content:"Delegating to the team"});let l=t.tasks.filter(m=>m.role!=="hablas").map(m=>({role:m.role,task:`${m.description}
1089
1089
 
1090
- Original request: ${e}`})),l=[],u="hablas",d=null;for(let h of a){if(r.abortSignal?.aborted)break;let m=xe.find($=>$.role===h.role);if(!m)continue;this.channel.emitEvent({type:"handoff",agent:Bl(u),to:m.name});let p=await this.chat.generateHandoffLine(u,h.role,h.task);this.channel.emitEvent({type:"speak",agent:Bl(u),to:m.name,content:p});let g=await this.chat.generateAckLine(h.role,u);this.channel.emitEvent({type:"speak",agent:m.name,to:Bl(u),content:g});let x=Date.now(),w=await this.runner.runAgent(h.role,h.task,void 0,s,{abortSignal:r.abortSignal});l.push(w),w.success&&w.output?(this.channel.emitEvent({type:"summary",agent:m.name,durationMs:Date.now()-x}),h.role==="alex"&&(d=w.output),i&&h.role==="alex"&&t.tasks.some($=>$.role==="bob")&&d&&await this.runPeerReview("bob","alex",d,r.abortSignal)):w.error&&this.channel.emitEvent({type:"error",agent:m.name,content:w.error}),u=h.role}this.channel.emitEvent({type:"phase",agent:"System",content:"Hablas compiling final report"});let f=await this.synthesize(e,l,s,r.abortSignal);return this.channel.emitEvent({type:"done",agent:"Hablas"}),f}async runPeerReview(e,t,s,r){let i=xe.find(u=>u.role===e),o=xe.find(u=>u.role===t);if(!i||!o)return;let a=await this.chat.generateReviewLine(e,t,s);this.channel.emitEvent({type:"review",agent:i.name,to:o.name,content:a});let l=await this.chat.generateReviewAck(t,e);this.channel.emitEvent({type:"speak",agent:o.name,to:i.name,content:l}),r?.aborted}async synthesize(e,t,s,r){let i=t.filter(d=>d.success&&d.output);if(i.length===0)return{results:t,finalSynthesis:"The team encountered errors and could not complete the task. Please review the logs and try again.",synthesisOk:!1};let o=i.map(d=>{let f=xe.find(h=>h.role===d.agent);return`### Report from @${d.agentName} (${f?.title??d.agent}):
1090
+ Original request: ${e}`})),u=[],d="hablas",f=null;for(let m of l){if(r.abortSignal?.aborted)break;let p=xe.find(w=>w.role===m.role);if(!p)continue;if(this.channel.emitEvent({type:"handoff",agent:Bl(d),to:p.name}),!o){let w=await this.chat.generateHandoffLine(d,m.role,m.task);this.channel.emitEvent({type:"speak",agent:Bl(d),to:p.name,content:w});let $=await this.chat.generateAckLine(m.role,d);this.channel.emitEvent({type:"speak",agent:p.name,to:Bl(d),content:$})}let g=Date.now(),x=await this.runner.runAgent(m.role,m.task,void 0,s,{abortSignal:r.abortSignal});u.push(x),x.success&&x.output?(this.channel.emitEvent({type:"summary",agent:p.name,durationMs:Date.now()-g}),m.role==="alex"&&(f=x.output),i&&m.role==="alex"&&t.tasks.some(w=>w.role==="bob")&&f&&await this.runPeerReview("bob","alex",f,r.abortSignal,o)):x.error&&this.channel.emitEvent({type:"error",agent:p.name,content:x.error}),d=m.role}this.channel.emitEvent({type:"phase",agent:"System",content:"Hablas compiling final report"});let h=await this.synthesize(e,u,s,r.abortSignal);return this.channel.emitEvent({type:"done",agent:"Hablas"}),h}async runPeerReview(e,t,s,r,i=!1){let o=xe.find(l=>l.role===e),a=xe.find(l=>l.role===t);if(!(!o||!a)){if(!i){let l=await this.chat.generateReviewLine(e,t,s);this.channel.emitEvent({type:"review",agent:o.name,to:a.name,content:l});let u=await this.chat.generateReviewAck(t,e);this.channel.emitEvent({type:"speak",agent:a.name,to:o.name,content:u})}r?.aborted}}async synthesize(e,t,s,r){let i=t.filter(d=>d.success&&d.output);if(i.length===0)return{results:t,finalSynthesis:"The team encountered errors and could not complete the task. Please review the logs and try again.",synthesisOk:!1};let o=i.map(d=>{let f=xe.find(h=>h.role===d.agent);return`### Report from @${d.agentName} (${f?.title??d.agent}):
1091
1091
  ${d.output}`}).join(`
1092
1092
 
1093
1093
  `),a=`You are Hablas, the Team Leader. Your team has completed a multi-agent workflow for the user's request: "${e}".
@@ -1241,10 +1241,10 @@ ${U}`,{priority:"low",tags:["auto-inject"]})}if(n.team?.enabled&&Re){let U=n.tea
1241
1241
  ${c.warning("\u26A0")} ${c.strong("@Consul")}: a teammate locked ${c.highlight(G)} first. Halting to avoid a conflict.
1242
1242
  `);continue}}Re.setActivity(ce.slice(0,80))}let Fe=U=>{let ue=U.trim().toLowerCase();return ue.length<12||["hi","hey","\u0627\u0647","ok","thanks","\u0634\u0643\u0631\u0627","yo","hello","\u0635\u0628\u0627\u062D","\u0645\u0633\u0627\u0621","how are","what's up","\u0643\u064A\u0641\u0643","\u062A\u0645\u0627\u0645","\u0627\u064A\u0647","\u0627\u0647","lol","haha"].some(G=>ue.includes(G))?!0:!["build","create","fix","add","implement","design","make","write","update","remove","deploy","test","plan","generate","complete","setup"].some(G=>ue.includes(G))&&ue.length<40},ye=n.agents.enabled&&!Fe(ce);try{if(m&&n.agents.enabled){let U=`User input: "${ce}"
1243
1243
 
1244
- Decide the professional routing for this engineering interaction.`,ue=await m.runAgent("gate",U,void 0,i.getOllamaTools(),{abortSignal:k?.signal});if(ue.success&&ue.output){let Pe=ue.output.toLowerCase();Pe.includes("mode: casual")||Pe.includes("casual")?ye=!1:(Pe.includes("mode: build")||Pe.includes("build")||Pe.includes("mode: design"))&&(ye=!0)}}}catch{}if(ye){let U=["hablas","bob","alex","david","emma"];for(let ee of U)I=Fi(I,ee);dn(I),p.reset(),x.resetBudget();let ue={id:"build-"+Date.now(),description:ce.substring(0,100),tasks:[{role:"emma",description:"Analyze the request from product/requirements perspective and clarify if needed."},{role:"bob",description:"Provide architecture, design or structural guidance."},{role:"alex",description:"Execute the core implementation, coding or action based on the input."},{role:"david",description:"Research, data analysis or supporting information."}],strategy:"mixed",createdAt:new Date,approved:!0},Pe=i.getOllamaTools(),D=new xs(p,m,x,n),G=[],P="The team operation completed.",V=!1;try{let ee=await D.run(ce,ue,Pe,{abortSignal:k?.signal,peerReview:!0});G=ee.results||[],P=ee.finalSynthesis||P,V=!!ee.synthesisOk}catch(ee){let de=ee?.message||String(ee);de.includes("Aborted")||ee?.name==="AbortError"?(console.log(` ${c.warning("Operation aborted.")}`),P="Team operation was aborted. Provide more details or try a focused request."):(console.log(ke(`Team error: ${de}`)),P="The team encountered an error during execution. Please review logs and retry."),V=!1}console.log(mn("Hablas","Team Leader")),console.log(gn(P)),T.addAssistantMessage(V?P:`[Team Summary]
1244
+ Decide the professional routing for this engineering interaction.`,ue=await m.runAgent("gate",U,void 0,i.getOllamaTools(),{abortSignal:k?.signal});if(ue.success&&ue.output){let Pe=ue.output.toLowerCase();Pe.includes("mode: casual")||Pe.includes("casual")?ye=!1:(Pe.includes("mode: build")||Pe.includes("build")||Pe.includes("mode: design"))&&(ye=!0)}}}catch{}if(ye){let U=["hablas","bob","alex","david","emma"];for(let ee of U)I=Fi(I,ee);dn(I),p.reset(),x.resetBudget();let ue={id:"build-"+Date.now(),description:ce.substring(0,100),tasks:[{role:"emma",description:"Analyze the request from product/requirements perspective and clarify if needed."},{role:"bob",description:"Provide architecture, design or structural guidance."},{role:"alex",description:"Execute the core implementation, coding or action based on the input."},{role:"david",description:"Research, data analysis or supporting information."}],strategy:"mixed",createdAt:new Date,approved:!0},Pe=i.getOllamaTools(),D=new xs(p,m,x,n),G=[],P="The team operation completed.",V=!1;try{let ee=await D.run(ce,ue,Pe,{abortSignal:k?.signal,peerReview:!0,centralizedToLeader:!0});G=ee.results||[],P=ee.finalSynthesis||P,V=!!ee.synthesisOk}catch(ee){let de=ee?.message||String(ee);de.includes("Aborted")||ee?.name==="AbortError"?(console.log(` ${c.warning("Operation aborted.")}`),P="Team operation was aborted. Provide more details or try a focused request."):(console.log(ke(`Team error: ${de}`)),P="The team encountered an error during execution. Please review logs and retry."),V=!1}console.log(mn("Hablas","Team Leader")),console.log(gn(P)),T.addAssistantMessage(V?P:`[Team Summary]
1245
1245
  `+P),await Dg(n,t);continue}else T.addUserMessage(ce);k=new AbortController,S.startTurn(),_.resetTurn(),await Fg(T,r,i,o,{interactive:!0,autoMode:W,input:a,logger:e,config:n,abortSignal:k.signal,reactEngine:S,errorRecovery:_,skipTools:!1,onToolCall:()=>{F++,I=Li(I,"tool_call"),dn(I)}}),await Dg(n,t)}catch(Z){if(Z.code==="ERR_USE_AFTER_CLOSE")break;if(Z.name==="AbortError")continue;console.log(ke(Z.message)),e.error(Z,"REPL error")}a.close(),Re&&await Re.shutdown(),console.log(Yi({turns:C,duration:Date.now()-H,toolCalls:F}))}async function $0(n,e,t,s="build"){let r=e.workingDirectory==="."?process.cwd():e.workingDirectory;e.agents.enabled=!0;let i=Me(e),o=new En(r,e),a=new bs(e);a.setToolRegistry(o);let l=new vs,u=new _s(l,{hideActs:!0}).attach(),d=new ws(e,{tokenBudget:500,maxChars:140});a.setChannel(l),l.onEvent(w=>{w.type==="phase"?console.log(`
1246
1246
  ${c.accent("\u25C6")} ${c.strong(w.content)}`):w.type==="handoff"?console.log(` ${c.muted("\u2605")} ${w.agent} \u2501\u2501\u25B6 ${w.to}`):w.type==="speak"?console.log(` ${c.primary(w.agent)}: ${w.content}`):w.type==="act"||w.type==="tool"?console.log(` ${c.warning("\u{1F527}")} [${w.agent}] ${w.content||w.toolName}`):w.type==="summary"||w.type==="observe"?console.log(` ${c.success("\u2713")} ${w.agent||""} ${w.content||""}`):w.type==="error"&&console.log(` ${c.error("\u2717")} ${w.agent}: ${w.content}`)}),console.log(`
1247
- ${c.accent("\u2605")} ${c.strong("FULL TEAM "+s.toUpperCase())} \u2014 ${e.model} (classification deleted, max power)`);let f={id:`${s}-`+Date.now(),description:n.substring(0,100),tasks:[{role:"emma",description:"Analyze the request from product/requirements perspective and clarify if needed."},{role:"bob",description:"Provide architecture, design or structural guidance."},{role:"alex",description:"Execute the core implementation, coding or action based on the input."},{role:"david",description:"Research, data analysis or supporting information."}],strategy:"mixed",createdAt:new Date,approved:!0},h=o.getOllamaTools(),m=new xs(l,a,d,e),{results:p,finalSynthesis:g,synthesisOk:x}=await m.run(n,f,h,{peerReview:!0});console.log(`
1247
+ ${c.accent("\u2605")} ${c.strong("FULL TEAM "+s.toUpperCase())} \u2014 ${e.model} (classification deleted, max power)`);let f={id:`${s}-`+Date.now(),description:n.substring(0,100),tasks:[{role:"emma",description:"Analyze the request from product/requirements perspective and clarify if needed."},{role:"bob",description:"Provide architecture, design or structural guidance."},{role:"alex",description:"Execute the core implementation, coding or action based on the input."},{role:"david",description:"Research, data analysis or supporting information."}],strategy:"mixed",createdAt:new Date,approved:!0},h=o.getOllamaTools(),m=new xs(l,a,d,e),{results:p,finalSynthesis:g,synthesisOk:x}=await m.run(n,f,h,{peerReview:!0,centralizedToLeader:!0});console.log(`
1248
1248
  ${mn("Hablas","Team Leader")}`),console.log(gn(g||"Team completed the task.")),console.log(`
1249
1249
  ${c.muted("Full team execution complete. "+(x?"Synthesis OK.":"Used fallback summary."))}`)}async function C0(n,e,t){let s=e.workingDirectory==="."?process.cwd():e.workingDirectory,r=Me(e),i=new En(s,e),o=new tn(e),a=new us(s),l=await bn(s,e),u=vn(Wn,l,a),d=new nn(u,e.historySize),f=Ng(n,s);d.addUserMessage(f),await Fg(d,r,i,o,{interactive:!1,autoMode:e.autoMode||!1,logger:t,config:e})}function Ng(n,e){let t=/#([\w./-]+)/g,s=n,r;for(;(r=t.exec(n))!==null;){let i=r[1],o=Ft.resolve(e,i);mt.existsSync(o)&&(s=s.replace(`#${i}`,i))}return s}async function Dg(n,e){if(!(n.team?.enabled&&Re))return;if(await Re.releaseAllMyLocks(),!n.workspace?.autoPush){console.log(`
1250
1250
  ${c.info("\u2139")} ${c.strong("@Consul")}: "Changes tracked. Auto-push is off \u2014 commit & push manually when ready."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hablas-ai",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "Premium multi-agent AI coding agent for your terminal — local-first via Ollama, NVIDIA NIM, or any OpenAI-compatible API. Watch the team work in front of you.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {