@madh-io/alfred-ai 0.10.53 → 0.10.54
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/bundle/index.js +1 -1
- package/package.json +1 -1
package/bundle/index.js
CHANGED
|
@@ -837,7 +837,7 @@ ${e.allModifiedFiles.map(r=>`- ${r}`).join(`
|
|
|
837
837
|
|
|
838
838
|
**Git:**
|
|
839
839
|
${s.join(`
|
|
840
|
-
`)}`:"";return{...t,data:{...t.data,git:{branch:r.branch,commit:r.commit,pullRequest:r.pullRequest,warnings:r.warnings}},display:(t.display??"")+n}}}});var Xl=_(()=>{"use strict";Kl();Cn();Ii();$i();Si()});var ee={};me(ee,{ActivityTracker:()=>Tt,BMWSkill:()=>$n,BackgroundTaskSkill:()=>es,BriefingSkill:()=>xn,BrowserSkill:()=>Jt,CalculatorSkill:()=>Pt,CalendarProvider:()=>Me,CalendarSkill:()=>_t,ClipboardSkill:()=>Xt,CodeAgentSkill:()=>_r,CodeExecutionSkill:()=>lr,CodeExecutor:()=>$t,ConfigureSkill:()=>ls,ContactsProvider:()=>Ue,ContactsSkill:()=>mr,CrossPlatformSkill:()=>Qt,DelegateSkill:()=>Wt,DockerSkill:()=>_n,DocumentSkill:()=>ss,EmailProvider:()=>Ve,EmailSkill:()=>et,EnergyPriceSkill:()=>vn,FileSkill:()=>Vt,ForgeClient:()=>St,HomeAssistantSkill:()=>fn,HttpSkill:()=>Gt,ImageGenerateSkill:()=>ns,MCPClient:()=>bt,MCPManager:()=>cr,MCPSkillAdapter:()=>Et,MarketplaceSkill:()=>fr,MemorySkill:()=>zt,MicrosoftTodoSkill:()=>An,MonitorSkill:()=>Sn,NoteSkill:()=>Bt,PluginLoader:()=>nn,ProfileSkill:()=>Zt,ProxmoxSkill:()=>pn,ReminderSkill:()=>jt,RoutingSkill:()=>kn,ScheduledTaskSkill:()=>ts,ScreenshotSkill:()=>Yt,ShellSkill:()=>qt,Skill:()=>I,SkillRegistry:()=>Mt,SkillSandbox:()=>Ot,SystemInfoSkill:()=>Ut,TTSSkill:()=>rs,TodoSkill:()=>os,TransitSkill:()=>as,UniFiSkill:()=>hn,WatchSkill:()=>ds,WeatherSkill:()=>Ht,WebSearchSkill:()=>Ft,allUserIds:()=>W,createCalendarProvider:()=>ar,createContactsProvider:()=>ai,createEmailProvider:()=>nr,createForgeClient:()=>ps,effectiveUserId:()=>ie,gitAddRemote:()=>wr,gitGetRemoteUrl:()=>us,gitInitRepo:()=>yr,orchestrate:()=>At,orchestrateWithGit:()=>Tr,parseRemoteUrl:()=>ms});var Z=_(()=>{"use strict";P();Ne();cc();lc();Vo();dc();uc();mc();pc();hc();fc();gc();Tc();_c();bc();vc();Ac();xc();Rc();Dc();Nc();Mc();Bc();Hc();qc();zc();Gc();Kc();Xc();Yc();Jc();Zc();Qc();tl();al();cl();pl();_l();bl();Il();xl();Dl();Ll();Nl();Ol();jl();Bl();Xl()});var br,xi=_(()=>{"use strict";br=class{static{u(this,"ConversationManager")}conversations;constructor(e){this.conversations=e}getOrCreateConversation(e,t,s){let r=this.conversations.findByPlatformChat(e,t);return r?(this.conversations.updateTimestamp(r.id),r):this.conversations.create(e,t,s)}addMessage(e,t,s,r){return this.conversations.addMessage(e,t,s,r)}getHistory(e,t=20){return this.conversations.getMessages(e,t)}pruneMessages(e,t){return this.conversations.pruneMessages(e,t)}}});function Ke(l,e){let t;if(e.platformUserId)t=l.findOrCreate(e.platform,e.platformUserId,e.userName,e.displayName);else if(e.userId)t=l.findById(e.userId)??l.findOrCreate(e.platform,e.userId);else throw new Error("ContextSource must provide either platformUserId or userId");let s="getMasterUserId"in l?l.getMasterUserId(t.id):t.id,r=[];"getLinkedUsers"in l&&(r=l.getLinkedUsers(s).map(a=>a.platformUserId));let n;try{"getProfile"in l?n=l.getProfile(s)?.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone:n=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{n=Intl.DateTimeFormat().resolvedOptions().timeZone}return{context:{userId:t.platformUserId,masterUserId:s,linkedPlatformUserIds:r,chatId:e.chatId,chatType:e.chatType,platform:e.platform,conversationId:e.conversationId??"",timezone:n},user:t,masterUserId:s,linkedPlatformUserIds:r}}var hs=_(()=>{"use strict";u(Ke,"buildSkillContext")});function Yl(l,e){let t=new Set(["core"]),s=!1;for(let[r,n]of Object.entries(kp))e.has(r)&&n.test(l)&&(t.add(r),s=!0);if(!s)for(let r of e)t.add(r);return t}function Jl(l,e){return l.filter(t=>e.has(t.category??"core"))}var kp,Zl=_(()=>{"use strict";kp={productivity:/\b(todo|note|remind|calendar|termin|event|email|e-mail|mail|contact|kontakt|briefing|morgenbriefing|tagesbriefing)\b/i,information:/\b(search|such|weather|wetter|calculat|rechn|time|date|zeit|datum|uhrzeit|system.?info|transit|bahn|zug|bus|tram|u.?bahn|s.?bahn|abfahrt|verbindung|haltestelle|öffi|fahrplan|strom|energy|preis|price|kwh|awattar|marktpreis|spot|günstig|cheapest|netzentgelt)\b/i,media:/\b(voice|stimme|tts|speak|sprech|sprich|screenshot|clipboard|zwischenablage|brows)\b/i,automation:/\b(background|hintergrund|shell|bash|cron|schedul|code.?agent|sandbox|automat|watch|alert|benachrichtig|bescheid|meld|überwach|monitor|tägliche?r?s?|stündliche?r?s?|wöchentliche?r?s?|monatliche?r?s?|jeden\s+(tag|morgen|abend|montag|dienstag|mittwoch|donnerstag|freitag|samstag|sonntag)|um\s+\d{1,2}\s*(uhr|:|h)|alle\s+\d+\s*(min|stund|sekund)|in\s+\d+\s*(min
|
|
840
|
+
`)}`:"";return{...t,data:{...t.data,git:{branch:r.branch,commit:r.commit,pullRequest:r.pullRequest,warnings:r.warnings}},display:(t.display??"")+n}}}});var Xl=_(()=>{"use strict";Kl();Cn();Ii();$i();Si()});var ee={};me(ee,{ActivityTracker:()=>Tt,BMWSkill:()=>$n,BackgroundTaskSkill:()=>es,BriefingSkill:()=>xn,BrowserSkill:()=>Jt,CalculatorSkill:()=>Pt,CalendarProvider:()=>Me,CalendarSkill:()=>_t,ClipboardSkill:()=>Xt,CodeAgentSkill:()=>_r,CodeExecutionSkill:()=>lr,CodeExecutor:()=>$t,ConfigureSkill:()=>ls,ContactsProvider:()=>Ue,ContactsSkill:()=>mr,CrossPlatformSkill:()=>Qt,DelegateSkill:()=>Wt,DockerSkill:()=>_n,DocumentSkill:()=>ss,EmailProvider:()=>Ve,EmailSkill:()=>et,EnergyPriceSkill:()=>vn,FileSkill:()=>Vt,ForgeClient:()=>St,HomeAssistantSkill:()=>fn,HttpSkill:()=>Gt,ImageGenerateSkill:()=>ns,MCPClient:()=>bt,MCPManager:()=>cr,MCPSkillAdapter:()=>Et,MarketplaceSkill:()=>fr,MemorySkill:()=>zt,MicrosoftTodoSkill:()=>An,MonitorSkill:()=>Sn,NoteSkill:()=>Bt,PluginLoader:()=>nn,ProfileSkill:()=>Zt,ProxmoxSkill:()=>pn,ReminderSkill:()=>jt,RoutingSkill:()=>kn,ScheduledTaskSkill:()=>ts,ScreenshotSkill:()=>Yt,ShellSkill:()=>qt,Skill:()=>I,SkillRegistry:()=>Mt,SkillSandbox:()=>Ot,SystemInfoSkill:()=>Ut,TTSSkill:()=>rs,TodoSkill:()=>os,TransitSkill:()=>as,UniFiSkill:()=>hn,WatchSkill:()=>ds,WeatherSkill:()=>Ht,WebSearchSkill:()=>Ft,allUserIds:()=>W,createCalendarProvider:()=>ar,createContactsProvider:()=>ai,createEmailProvider:()=>nr,createForgeClient:()=>ps,effectiveUserId:()=>ie,gitAddRemote:()=>wr,gitGetRemoteUrl:()=>us,gitInitRepo:()=>yr,orchestrate:()=>At,orchestrateWithGit:()=>Tr,parseRemoteUrl:()=>ms});var Z=_(()=>{"use strict";P();Ne();cc();lc();Vo();dc();uc();mc();pc();hc();fc();gc();Tc();_c();bc();vc();Ac();xc();Rc();Dc();Nc();Mc();Bc();Hc();qc();zc();Gc();Kc();Xc();Yc();Jc();Zc();Qc();tl();al();cl();pl();_l();bl();Il();xl();Dl();Ll();Nl();Ol();jl();Bl();Xl()});var br,xi=_(()=>{"use strict";br=class{static{u(this,"ConversationManager")}conversations;constructor(e){this.conversations=e}getOrCreateConversation(e,t,s){let r=this.conversations.findByPlatformChat(e,t);return r?(this.conversations.updateTimestamp(r.id),r):this.conversations.create(e,t,s)}addMessage(e,t,s,r){return this.conversations.addMessage(e,t,s,r)}getHistory(e,t=20){return this.conversations.getMessages(e,t)}pruneMessages(e,t){return this.conversations.pruneMessages(e,t)}}});function Ke(l,e){let t;if(e.platformUserId)t=l.findOrCreate(e.platform,e.platformUserId,e.userName,e.displayName);else if(e.userId)t=l.findById(e.userId)??l.findOrCreate(e.platform,e.userId);else throw new Error("ContextSource must provide either platformUserId or userId");let s="getMasterUserId"in l?l.getMasterUserId(t.id):t.id,r=[];"getLinkedUsers"in l&&(r=l.getLinkedUsers(s).map(a=>a.platformUserId));let n;try{"getProfile"in l?n=l.getProfile(s)?.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone:n=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{n=Intl.DateTimeFormat().resolvedOptions().timeZone}return{context:{userId:t.platformUserId,masterUserId:s,linkedPlatformUserIds:r,chatId:e.chatId,chatType:e.chatType,platform:e.platform,conversationId:e.conversationId??"",timezone:n},user:t,masterUserId:s,linkedPlatformUserIds:r}}var hs=_(()=>{"use strict";u(Ke,"buildSkillContext")});function Yl(l,e){let t=new Set(["core"]),s=!1;for(let[r,n]of Object.entries(kp))e.has(r)&&n.test(l)&&(t.add(r),s=!0);if(!s)for(let r of e)t.add(r);return t}function Jl(l,e){return l.filter(t=>e.has(t.category??"core"))}var kp,Zl=_(()=>{"use strict";kp={productivity:/\b(todo|note|remind|calendar|termin|event|email|e-mail|mail|contact|kontakt|briefing|morgenbriefing|tagesbriefing)\b/i,information:/\b(search|such|weather|wetter|calculat|rechn|time|date|zeit|datum|uhrzeit|system.?info|transit|bahn|zug|bus|tram|u.?bahn|s.?bahn|abfahrt|verbindung|haltestelle|öffi|fahrplan|strom|energy|preis|price|kwh|awattar|marktpreis|spot|günstig|cheapest|netzentgelt)\b/i,media:/\b(voice|stimme|tts|speak|sprech|sprich|screenshot|clipboard|zwischenablage|brows)\b/i,automation:/\b(background|hintergrund|shell|bash|cron|schedul|code.?agent|sandbox|automat|watch|alert|benachrichtig|bescheid|meld|überwach|monitor|tägliche?r?s?|stündliche?r?s?|wöchentliche?r?s?|monatliche?r?s?|jeden\s+(tag|morgen|abend|montag|dienstag|mittwoch|donnerstag|freitag|samstag|sonntag)|um\s+\d{1,2}\s*(uhr|:|h)|alle\s+\d+\s*(min|stund|sekund)|in\s+\d+\s*(minuten?|stunden?|sekunden?|hours?|minutes?|seconds?|min)|daily|hourly|weekly|every\s+(day|hour|morning|evening|night|\d+\s*min))\b/i,files:/\b(file|datei|document|dokument|pdf|http|download|upload)\b/i,infrastructure:/\b(proxmox|vm|container|docker|unifi|wifi|wlan|homeassistant|home.?assistant|smarthome|smart.?home|licht|light|schalter|switch)\b/i,identity:/\b(link|verknüpf|cross.?platform|identity|identität)\b/i,mcp:/\bmcp\b/i};u(Yl,"selectCategories");u(Jl,"filterSkills")});import Ri from"node:fs";import Ql from"node:path";var vp,ed,Sp,td,Ap,Ip,xp,sd,Er,Ci=_(()=>{"use strict";Wo();hs();Zl();vp=15*60*1e3,ed=50,Sp=2,td=.85,Ap=1e5,Ip=2e3,xp=.1,sd=3,Er=class{static{u(this,"MessagePipeline")}promptBuilder;llm;conversationManager;users;logger;skillRegistry;skillSandbox;securityManager;memoryRepo;speechTranscriber;inboxPath;embeddingService;activeLearning;memoryRetriever;maxHistoryMessages;documentProcessor;activeAgents=new Map;agentIdCounter=0;constructor(e){this.llm=e.llm,this.conversationManager=e.conversationManager,this.users=e.users,this.logger=e.logger,this.skillRegistry=e.skillRegistry,this.skillSandbox=e.skillSandbox,this.securityManager=e.securityManager,this.memoryRepo=e.memoryRepo,this.speechTranscriber=e.speechTranscriber,this.inboxPath=e.inboxPath,this.embeddingService=e.embeddingService,this.activeLearning=e.activeLearning,this.memoryRetriever=e.memoryRetriever,this.maxHistoryMessages=e.maxHistoryMessages??100,this.documentProcessor=e.documentProcessor,this.promptBuilder=new Qs}async process(e,t){let s=Date.now();this.logger.info({platform:e.platform,userId:e.userId,chatId:e.chatId},"Processing message");try{let{user:r,masterUserId:n,linkedPlatformUserIds:o,context:i}=Ke(this.users,{platformUserId:e.userId,platform:e.platform,chatId:e.chatId,chatType:e.chatType,userName:e.userName,displayName:e.displayName}),a=this.conversationManager.getOrCreateConversation(e.platform,e.chatId,r.id),c=e.metadata?.skipHistory?[]:this.conversationManager.getHistory(a.id,this.maxHistoryMessages);this.conversationManager.addMessage(a.id,"user",e.text);let d,m=this.isSyntheticLabel(e.text),p=e.attachments?.some(B=>B.type==="audio")??!1,g=m&&!p;if(this.memoryRetriever&&e.text&&!g)try{d=await this.memoryRetriever.retrieve(n,e.text,15,o)}catch(B){this.logger.debug({err:B},"Hybrid memory retrieval failed")}if(!d&&this.memoryRepo&&!g)try{let B=[n,...(o??[]).filter(te=>te!==n)];if(this.embeddingService&&e.text&&this.llm.supportsEmbeddings()){let te=new Set;d=[];for(let ae of B)for(let oe of await this.embeddingService.semanticSearch(ae,e.text,10))te.has(oe.key)||(te.add(oe.key),d.push(oe));for(let ae of B)for(let oe of this.memoryRepo.getRecentForPrompt(ae,5))te.has(oe.key)||(te.add(oe.key),d.push(oe))}else{let te=new Set;d=[];for(let ae of B)for(let oe of this.memoryRepo.getRecentForPrompt(ae,20))te.has(oe.key)||(te.add(oe.key),d.push(oe))}}catch(B){this.logger.debug({err:B},"Memory loading failed")}d&&d.length>0&&(d=this.applyMemoryBudget(d));let f;try{"getProfile"in this.users&&(f=this.users.getProfile(n),f&&!f.displayName&&(f.displayName=r.displayName??r.username))}catch(B){this.logger.debug({err:B},"Profile loading failed")}let h=i.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone,y=this.skillRegistry?this.skillRegistry.getAll().map(B=>B.metadata):void 0,E=y;if(y&&e.text){let B=new Set(y.map(ae=>ae.category??"core")),te=Yl(e.text,B);E=Jl(y,te)}let A=E?this.promptBuilder.buildTools(E):void 0,R=this.promptBuilder.buildSystemPrompt({memories:d,skills:E,userProfile:f}),F=this.buildActiveAgentStatus();F&&(R+=`
|
|
841
841
|
|
|
842
842
|
`+F);let x=this.promptBuilder.buildMessages(c),G=this.collapseRepeatedToolErrors(x),ce=await this.buildUserContent(e,t);G.push({role:"user",content:ce});let se=A?Le(JSON.stringify(A)):0,N=1,K=this.trimToContextWindow(R,G,se,N),q,le=0,de=Date.now(),re="",ne=0,D=0,z=0,Te=[];for(t?.("Thinking...");;){le>0&&this.compressToolLoop(K,R,se);try{q=await this.llm.complete({messages:K,system:R,tools:A&&A.length>0?A:void 0,tier:e.metadata?.tier}),D+=q.usage?.inputTokens??0,z+=q.usage?.outputTokens??0}catch(ke){if((ke instanceof Error?ke.message:String(ke)).includes("prompt is too long")&&N>.3){N*=.5,this.logger.warn({budgetMultiplier:N},"Prompt too long, retrimming with reduced budget"),K=this.trimToContextWindow(R,G,se,N);continue}throw ke}if(!q.toolCalls||q.toolCalls.length===0)break;let B=Date.now()-de;if(B>=vp){let ke=Math.round(B/6e4);this.logger.warn({iteration:le,elapsedMin:ke,pendingToolCalls:q.toolCalls.length},"Tool loop timeout reached"),q=await this.abortToolLoop(K,q,a.id,R,`Das Zeitlimit von ${ke} Minuten f\xFCr Tool-Aufrufe wurde erreicht.`,!1,e.metadata?.tier);break}if(le>=ed){this.logger.warn({iteration:le,pendingToolCalls:q.toolCalls.length},"Tool loop iteration cap reached"),q=await this.abortToolLoop(K,q,a.id,R,`Das Iterationslimit von ${ed} Tool-Aufrufen wurde erreicht.`,!1,e.metadata?.tier);break}le++,this.logger.info({iteration:le,toolCalls:q.toolCalls.length},"Processing tool calls");let te=[];q.content&&te.push({type:"text",text:q.content});for(let ke of q.toolCalls)te.push({type:"tool_use",id:ke.id,name:ke.name,input:ke.input});K.push({role:"assistant",content:te});let ae=await this.executeToolCallsParallel(q.toolCalls,{...i,conversationId:a.id,timezone:h},t),oe=ae.blocks;ae.attachments.length>0&&Te.push(...ae.attachments),this.conversationManager.addMessage(a.id,"assistant",q.content??"",JSON.stringify(q.toolCalls)),this.conversationManager.addMessage(a.id,"user","",JSON.stringify(oe));let Rt=this.buildErrorSignature(oe);if(Rt){if(Rt===re?ne++:(ne=1,re=Rt),ne>=Sp){this.logger.warn({iteration:le,consecutiveErrors:ne,errorSignature:Rt},"Tool loop aborted: same error repeated consecutively"),q=await this.abortToolLoop(K,q,a.id,R,`Der gleiche Tool-Fehler ist ${ne}x hintereinander aufgetreten: "${re.slice(0,200)}". Erkl\xE4re dem User kurz was nicht funktioniert hat und schlage eine Alternative vor.`,!0,e.metadata?.tier);break}}else ne=0,re="";K.push({role:"user",content:oe}),t?.("Thinking...")}let Q=q.content;if(!Q)for(let B=K.length-1;B>=0;B--){let te=K[B];if(te.role==="assistant"&&Array.isArray(te.content)){let ae=te.content.find(oe=>oe.type==="text");if(ae&&"text"in ae&&ae.text){Q=ae.text;break}}}Q||(Q="(no response)"),this.conversationManager.addMessage(a.id,"assistant",Q),this.activeLearning&&this.activeLearning.onMessageProcessed(n,e.text,Q);let Je=Date.now()-s;return this.logger.info({duration:Je,tokens:q.usage,totalTokens:{inputTokens:D,outputTokens:z},stopReason:q.stopReason,toolIterations:le},"Message processed"),{text:Q,attachments:Te.length>0?Te:void 0}}catch(r){throw this.logger.error({err:r},"Failed to process message"),r}}async abortToolLoop(e,t,s,r,n,o=!1,i){if(!o){let d=[];t.content&&d.push({type:"text",text:t.content});for(let m of t.toolCalls)d.push({type:"tool_use",id:m.id,name:m.name,input:m.input});e.push({role:"assistant",content:d})}let a=t.toolCalls.map(d=>({type:"tool_result",tool_use_id:d.id,content:`Error: tool loop aborted \u2014 ${n}`,is_error:!0}));e.push({role:"user",content:a}),o||this.conversationManager.addMessage(s,"assistant",t.content??"",JSON.stringify(t.toolCalls)),this.conversationManager.addMessage(s,"user","",JSON.stringify(a));let c=e[e.length-1];return c&&c.role==="user"&&Array.isArray(c.content)?c.content.push({type:"text",text:`[System: ${n} Fasse dem User kurz zusammen was du bisher geschafft hast und was noch offen ist.]`}):e.push({role:"user",content:`[System: ${n} Fasse dem User kurz zusammen was du bisher geschafft hast und was noch offen ist.]`}),await this.llm.complete({messages:e,system:r,tier:i})}buildErrorSignature(e){let t=[];for(let s of e)s.type==="tool_result"&&s.is_error&&t.push(s.content);return t.length>0?t.join("|"):""}collapseRepeatedToolErrors(e){let t=[],s=0;for(;s<e.length;){let r=e[s];if(r.role==="assistant"&&Array.isArray(r.content)&&r.content.some(n=>n.type==="tool_use")){let n=s+1<e.length?e[s+1]:null;if(n&&n.role==="user"&&Array.isArray(n.content)&&n.content.every(o=>o.type==="tool_result"&&o.is_error)){let o=this.toolPairSignature(r,n),i=1,a=s+2;for(;a+1<e.length;){let c=e[a],d=e[a+1];if(c.role==="assistant"&&d?.role==="user"&&this.toolPairSignature(c,d)===o)i++,a+=2;else break}if(i>1){t.push(r),t.push(n),t.push({role:"user",content:`[System: The above tool error repeated ${i} times with identical input. The loop was aborted.]`}),s=a;continue}}}t.push(r),s++}return t}toolPairSignature(e,t){let s=Array.isArray(e.content)?e.content.filter(n=>n.type==="tool_use").map(n=>`${n.name}:${JSON.stringify(n.input)}`).join(","):"",r=Array.isArray(t.content)?t.content.filter(n=>n.type==="tool_result").map(n=>n.content).join(","):"";return`${s}|${r}`}async executeToolCallsParallel(e,t,s){let r=[],n=u((m,p)=>{let g=p.content;if(p.attachments&&p.attachments.length>0){r.push(...p.attachments);let f=p.attachments.map(h=>h.fileName).join(", ");g+=`
|
|
843
843
|
|