@whoz-oss/coday-server 0.53.0 → 0.53.1

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/package.json +1 -1
  2. package/server.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whoz-oss/coday-server",
3
- "version": "0.53.0",
3
+ "version": "0.53.1",
4
4
  "repository": "https://github.com/whoz-oss/coday",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
package/server.js CHANGED
@@ -317,7 +317,7 @@ ${a}\r
317
317
  `)[0],f=`${l.commandWord}: ${u}`;return a.set(f,l.commandWord),f});s.push("exit: Cancel and return"),a.set("exit: Cancel and return","exit");let o=await this.interactor.chooseOption(s,"Select a command:","Enter your choice"),c=a.get(o);return!c||c==="exit"?t:this.handle(`${this.commandWord} ${c}`,t)}buildHelpText(t){let n=[];return t&&n.push(`Sub-command '${t}' not understood.`),n.push("Available commands:"),[...this.handlers].filter(a=>!a.isInternal).sort((a,s)=>a.commandWord.localeCompare(s.commandWord)).forEach(a=>{let s=a.description.split(`
318
318
  `).map((o,c)=>c===0?o:` ${o}`).join(`
319
319
  `);n.push(` - ${a.commandWord}: ${s}`)}),n.join(`
320
- `)}displayHelp(t){let n=this.buildHelpText(t);this.interactor.displayText(n)}};var cQ=yr(qs(),1);var sp=class{constructor(e,t){this.aiProviderConfig=e;this.logger=t;this.apiKey=e.apiKey}models=[];apiKey;killed=!1;thinkingInterval=3e3;charsPerToken=3;username;activeThinkingIntervals=new Set;activeDelays=new Set;isShuttingDown=!1;mergeModels(e){let t=new Map(e.map(n=>[n.alias??n.name,n]));this.aiProviderConfig.models?.forEach(n=>t.set(n.alias??n.name,n)),this.models=Array.from(t.values())}kill(){this.killed=!0,this.cleanup()}cleanup(){this.isShuttingDown=!0;for(let e of this.activeDelays)clearTimeout(e);this.activeDelays.clear();for(let e of this.activeThinkingIntervals)clearInterval(e);this.activeThinkingIntervals.clear()}async delay(e,t){if(this.isShuttingDown)throw new Error("Client is shutting down");return new Promise((n,i)=>{let a=setTimeout(()=>{this.activeDelays.delete(a),n()},e);this.activeDelays.add(a),this.isShuttingDown&&(clearTimeout(a),this.activeDelays.delete(a),i(new Error(`Delay interrupted by shutdown${t?`: ${t}`:""}`)))})}startThinkingInterval(){let e=setInterval(()=>this.interactor.thinking(),this.thinkingInterval);return this.activeThinkingIntervals.add(e),e}stopThinkingInterval(e){clearInterval(e),this.activeThinkingIntervals.delete(e)}getCompactor(e,t){return async n=>{if(this.interactor.debug(`\u{1F5DC}\uFE0F Starting compaction for ${n.length} messages (budget: ${t} chars)`),t<500)return this.interactor.warn(`\u26A0\uFE0F Budget too small for compaction (${t} chars). Using truncation marker.`),new Wi({summary:"[Previous conversation truncated due to context window constraints]"});let i=n.filter(p=>p instanceof zt).map(p=>` - ${p.role}: ${p.getTextContent()}`).join(`
320
+ `)}displayHelp(t){let n=this.buildHelpText(t);this.interactor.displayText(n)}};var cQ=yr(qs(),1);var sp=class{constructor(e,t){this.aiProviderConfig=e;this.logger=t;this.apiKey=e.apiKey}models=[];apiKey;killed=!1;thinkingInterval=1e3;charsPerToken=3;username;activeThinkingIntervals=new Set;activeDelays=new Set;isShuttingDown=!1;mergeModels(e){let t=new Map(e.map(n=>[n.alias??n.name,n]));this.aiProviderConfig.models?.forEach(n=>t.set(n.alias??n.name,n)),this.models=Array.from(t.values())}kill(){this.killed=!0,this.cleanup()}cleanup(){this.isShuttingDown=!0;for(let e of this.activeDelays)clearTimeout(e);this.activeDelays.clear();for(let e of this.activeThinkingIntervals)clearInterval(e);this.activeThinkingIntervals.clear()}async delay(e,t){if(this.isShuttingDown)throw new Error("Client is shutting down");return new Promise((n,i)=>{let a=setTimeout(()=>{this.activeDelays.delete(a),n()},e);this.activeDelays.add(a),this.isShuttingDown&&(clearTimeout(a),this.activeDelays.delete(a),i(new Error(`Delay interrupted by shutdown${t?`: ${t}`:""}`)))})}startThinkingInterval(){let e=setInterval(()=>this.interactor.thinking(),this.thinkingInterval);return this.activeThinkingIntervals.add(e),e}stopThinkingInterval(e){clearInterval(e),this.activeThinkingIntervals.delete(e)}getCompactor(e,t){return async n=>{if(this.interactor.debug(`\u{1F5DC}\uFE0F Starting compaction for ${n.length} messages (budget: ${t} chars)`),t<500)return this.interactor.warn(`\u26A0\uFE0F Budget too small for compaction (${t} chars). Using truncation marker.`),new Wi({summary:"[Previous conversation truncated due to context window constraints]"});let i=n.filter(p=>p instanceof zt).map(p=>` - ${p.role}: ${p.getTextContent()}`).join(`
321
321
  `);this.interactor.debug(`\u{1F4DD} Built transcript from ${n.filter(p=>p instanceof zt).length} messages (${i.length} chars)`);let a=Math.max(100,Math.floor(t/20)),s=150,o=.2,c=Math.max(0,Math.floor((t-s-a)*(1-o)));this.interactor.debug(`\u{1F4CA} Compaction budget: summary=${a} chars, max transcript=${c} chars (overhead=${s}, margin=${Math.round(o*100)}%)`);let l=i,u=!1;i.length>c&&(l="..."+i.slice(-(c-3)),u=!0,this.interactor.debug(`\u2702\uFE0F Transcript truncated: ${i.length} \u2192 ${l.length} chars (removed ${i.length-l.length} chars from beginning)`));let f=`Here is a transcript of a conversation:
322
322
  <transcript>${l}</transcript>
323
323