@madh-io/alfred-ai 0.10.62 → 0.10.63

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/bundle/index.js +4 -2
  2. package/package.json +1 -1
package/bundle/index.js CHANGED
@@ -755,7 +755,7 @@ ${t.join(`
755
755
 
756
756
  Pendler-Check (Mo\u2013Fr): ${s?r?"\u2705 konfiguriert (Config)":"\u23F3 Adressen werden aus Memories gelesen (oder ALFRED_BRIEFING_HOME/OFFICE_ADDRESS setzen)":"\u274C Routing-Skill nicht verf\xFCgbar"}`}}async runBriefing(e,t){let{home:s}=this.resolveAddresses(t),n=(s?np(s):void 0)??this.alfredConfig.briefing?.location??e.location??"Vienna",o=e.modules,i=this.getAvailableModules();o?.length&&(i=i.filter(h=>o.includes(h.name)));let a=this.resolveHaPreferences(t),c=i.map(h=>{let y={...h.input};if(h.name==="calendar"){let{start:E,end:$}=rp();y.start=E,y.end=$}return h.name==="weather"&&(y.location=n),h.name==="home"&&(a.entities?.length&&(y.entities=a.entities),a.domains?.length&&(y.domains=a.domains)),{module:h,input:y}}),d=await Promise.all(c.map(h=>this.executeModule(h.module,h.input,t))),u=await this.runCommuteCheck(d,t);u&&d.push(u);let p=new Date().toLocaleDateString("de-AT",{weekday:"long",year:"numeric",month:"long",day:"numeric"}),g=[];g.push(`**\u2600\uFE0F Morgenbriefing \u2013 ${p}**
757
757
  `);for(let h of d)h.success&&h.display?g.push(`**${h.label}**
758
- ${h.display}`):h.success&&h.data?g.push(`**${h.label}**
758
+ ${this.cleanDisplay(h.module,h.display)}`):h.success&&h.data?g.push(`**${h.label}**
759
759
  ${typeof h.data=="string"?h.data:JSON.stringify(h.data,null,2)}`):!h.success&&h.error&&g.push(`**${h.label}**
760
760
  \u26A0\uFE0F ${h.error}`);let f=this.buildHighlights(d);return f.length>0&&(g.push("---"),g.push("**Highlights:**"),g.push(f.join(`
761
761
  `))),{success:!0,data:d,display:g.join(`
@@ -764,7 +764,9 @@ ${typeof h.data=="string"?h.data:JSON.stringify(h.data,null,2)}`):!h.success&&h.
764
764
  ${a.display}`):a.error&&d.push(`**Route:** \u26A0\uFE0F ${a.error}`),c?.success&&c.data){let u=this.extractBatteryLevel(c.data);u!=null&&u<30?d.push(`
765
765
  \u26A0\uFE0F **BMW Akku niedrig (${u}%)** \u2014 Laden vor der Fahrt empfohlen!`):u!=null&&d.push(`
766
766
  \u{1F50B} BMW Akku: ${u}% \u2014 ausreichend f\xFCr den Arbeitsweg`)}return d.length===0?null:{module:"commute",label:"Arbeitsweg (Mo\u2013Fr)",success:!0,data:{route:a.data,bmwBattery:this.extractBatteryLevel(c?.data)},display:d.join(`
767
- `)}}resolveAddresses(e){let t=this.alfredConfig.briefing?.homeAddress,s=this.alfredConfig.briefing?.officeAddress;if(!this.memoryRepo)return{home:t,office:s};let r=t,n=s;for(let o of G(e)){let i=this.memoryRepo.search(o,"adresse");for(let a of i){let c=a.key.toLowerCase(),d=a.value;!r&&/heim|home|wohn|zuhause|privat/.test(c)&&(r=d),!n&&/büro|office|arbeit|firma|work/.test(c)&&(n=d)}if(r&&n)break}return{home:r,office:n}}resolveHaPreferences(e){let t=this.alfredConfig.briefing?.homeAssistant?.entities,s=this.alfredConfig.briefing?.homeAssistant?.domains;if(t?.length||s?.length)return{entities:t,domains:s};if(!this.memoryRepo)return{};for(let r of G(e)){let n=this.memoryRepo.search(r,"briefing");for(let o of n){let i=o.key.toLowerCase();if(/ha_entit|home.?assistant.*entit|briefing.*entit/.test(i)){let a=o.value.split(/[,;]\s*/).map(c=>c.trim()).filter(Boolean);if(a.length)return{entities:a}}if(/ha_domain|home.?assistant.*domain|briefing.*domain/.test(i)){let a=o.value.split(/[,;]\s*/).map(c=>c.trim()).filter(Boolean);if(a.length)return{domains:a}}}}return{}}detectExternalAppointment(e){return Array.isArray(e)?e.some(t=>{let s=t.location??t.loc??"";return!s||typeof s!="string"||/teams|zoom|meet\.google|webex|skype/i.test(s)?!1:s.trim().length>0}):!1}buildHighlights(e){let t=[],s=e.find(i=>i.module==="bmw")?.data;if(s){let i=this.extractBatteryLevel(s);i!=null&&i<30&&t.push(`\u{1F697} BMW Akku bei ${i}% \u2014 laden empfohlen`)}let r=e.find(i=>i.module==="infra");r&&(!r.success||r.display?.includes("\u26A0\uFE0F"))&&t.push("\u{1F534} Infrastruktur-Warnung vorhanden");let n=e.find(i=>i.module==="energy")?.data;if(n){let i=n.currentCt,a=n.avgCt;i!=null&&a!=null&&i<a&&t.push(`\u26A1 Aktuell g\xFCnstiger Strom (${i} ct/kWh)`)}let o=e.find(i=>i.module==="calendar")?.data;return Array.isArray(o)&&o.length>0&&t.push(`\u{1F4C5} ${o.length} Termin(e) heute`),t}extractBatteryLevel(e){if(!e||typeof e!="object")return null;let t=e,s=t.chargingLevelPercent??t.batterySoc??t.soc??t.chargingState?.chargingLevelPercent;if(typeof s=="number")return s;if(typeof s=="string"){let r=parseFloat(s);return isNaN(r)?null:r}return null}}});import{spawn as ip}from"node:child_process";import Hl from"node:fs";import Wl from"node:path";function dp(l){let e={};for(let[t,s]of Object.entries(l))e[t]=s.replace(/\$\{(\w+)\}/g,(r,n)=>process.env[n]??"");return e}function up(l,e){return l.map(t=>t.replace(/\{\{prompt\}\}/g,e))}function Rn(l){return l.length<=ql?l:`[...truncated...]
767
+ `)}}resolveAddresses(e){let t=this.alfredConfig.briefing?.homeAddress,s=this.alfredConfig.briefing?.officeAddress;if(!this.memoryRepo)return{home:t,office:s};let r=t,n=s;for(let o of G(e)){let i=this.memoryRepo.search(o,"adresse");for(let a of i){let c=a.key.toLowerCase(),d=a.value;!r&&/heim|home|wohn|zuhause|privat/.test(c)&&(r=d),!n&&/büro|office|arbeit|firma|work/.test(c)&&(n=d)}if(r&&n)break}return{home:r,office:n}}resolveHaPreferences(e){let t=this.alfredConfig.briefing?.homeAssistant?.entities,s=this.alfredConfig.briefing?.homeAssistant?.domains;if(t?.length||s?.length)return{entities:t,domains:s};if(!this.memoryRepo)return{};for(let r of G(e)){let n=this.memoryRepo.search(r,"briefing");for(let o of n){let i=o.key.toLowerCase();if(/ha_entit|home.?assistant.*entit|briefing.*entit/.test(i)){let a=o.value.split(/[,;]\s*/).map(c=>c.trim()).filter(Boolean);if(a.length)return{entities:a}}if(/ha_domain|home.?assistant.*domain|briefing.*domain/.test(i)){let a=o.value.split(/[,;]\s*/).map(c=>c.trim()).filter(Boolean);if(a.length)return{domains:a}}}}return{}}detectExternalAppointment(e){return Array.isArray(e)?e.some(t=>{let s=t.location??t.loc??"";return!s||typeof s!="string"||/teams|zoom|meet\.google|webex|skype/i.test(s)?!1:s.trim().length>0}):!1}cleanDisplay(e,t){let s=t;return s=s.replace(/\s*\[(?:id:)?[A-Za-z0-9+/=]{20,}\]/g,""),e==="email"&&(s=s.replace(/^\d+\.\s*/gm,"- ").replace(/\[UNREAD\]/g,"\u{1F4E9}").replace(/\[ATT\]/g,"\u{1F4CE}").replace(/\n\s+Date:\s+\S+/g,"")),e==="calendar"&&(s=s.replace(/^\d+\s+event\(s\):\n?/i,"")),s=s.replace(/^\[[\w-]+\]\s*/gm,""),s=s.replace(/\n{3,}/g,`
768
+
769
+ `),s.trim()}buildHighlights(e){let t=[],s=e.find(i=>i.module==="bmw")?.data;if(s){let i=this.extractBatteryLevel(s);i!=null&&i<30&&t.push(`\u{1F697} BMW Akku bei ${i}% \u2014 laden empfohlen`)}let r=e.find(i=>i.module==="infra");r&&(!r.success||r.display?.includes("\u26A0\uFE0F"))&&t.push("\u{1F534} Infrastruktur-Warnung vorhanden");let n=e.find(i=>i.module==="energy")?.data;if(n){let i=n.currentCt,a=n.avgCt;i!=null&&a!=null&&i<a&&t.push(`\u26A1 Aktuell g\xFCnstiger Strom (${i} ct/kWh)`)}let o=e.find(i=>i.module==="calendar")?.data;return Array.isArray(o)&&o.length>0&&t.push(`\u{1F4C5} ${o.length} Termin(e) heute`),t}extractBatteryLevel(e){if(!e||typeof e!="object")return null;let t=e,s=t.chargingLevelPercent??t.batterySoc??t.soc??t.chargingState?.chargingLevelPercent;if(typeof s=="number")return s;if(typeof s=="string"){let r=parseFloat(s);return isNaN(r)?null:r}return null}}});import{spawn as ip}from"node:child_process";import Hl from"node:fs";import Wl from"node:path";function dp(l){let e={};for(let[t,s]of Object.entries(l))e[t]=s.replace(/\$\{(\w+)\}/g,(r,n)=>process.env[n]??"");return e}function up(l,e){return l.map(t=>t.replace(/\{\{prompt\}\}/g,e))}function Rn(l){return l.length<=ql?l:`[...truncated...]
768
770
  `+l.slice(-ql)}function zl(l){let e=new Map;function t(s){let r;try{r=Hl.readdirSync(s,{withFileTypes:!0})}catch{return}for(let n of r){if(lp.has(n.name))continue;let o=Wl.join(s,n.name);if(n.isDirectory())t(o);else if(n.isFile())try{let i=Hl.statSync(o);e.set(o,i.mtimeMs)}catch{}}}return m(t,"walk"),t(l),e}function mp(l,e,t){let s=[];for(let[r,n]of e){let o=l.get(r);(o===void 0||n>o)&&s.push(Wl.relative(t,r))}return s.sort()}async function gr(l,e,t={}){let s=t.cwd??l.cwd??process.cwd(),r=t.timeoutMs??l.timeoutMs??ap,n=Math.min(r,cp),o=up(l.argsTemplate,e),i={...process.env,...l.env?dp(l.env):{}},a=process.platform==="win32",c=zl(s),d=Date.now();return new Promise(u=>{let p=ip(l.command,o,{cwd:s,env:i,shell:a,stdio:l.promptVia==="stdin"?["pipe","pipe","pipe"]:["ignore","pipe","pipe"]}),g="",f="",h=!1,y=setTimeout(()=>{h=!0,p.kill("SIGTERM"),setTimeout(()=>p.kill("SIGKILL"),5e3)},n);p.stdout?.on("data",E=>{g+=E.toString()}),p.stderr?.on("data",E=>{let $=E.toString();if(f+=$,t.onProgress){let v=$.trim().split(`
769
771
  `).pop();v&&t.onProgress(`[${l.name}] ${v}`)}}),l.promptVia==="stdin"&&p.stdin&&(p.stdin.write(e),p.stdin.end()),p.on("close",E=>{clearTimeout(y);let $=Date.now()-d,v=zl(s),P=mp(c,v,s);u({stdout:Rn(g),stderr:Rn(f),exitCode:h?124:E??1,durationMs:$,modifiedFiles:P})}),p.on("error",E=>{clearTimeout(y);let $=Date.now()-d;u({stdout:Rn(g),stderr:Rn(f+`
770
772
  `+E.message),exitCode:127,durationMs:$,modifiedFiles:[]})})})}var ap,cp,ql,lp,Cn=_(()=>{"use strict";ap=3e5,cp=9e5,ql=1e5,lp=new Set([".git","node_modules",".next","dist",".cache"]);m(dp,"resolveEnv");m(up,"buildArgs");m(Rn,"truncateOutput");m(zl,"snapshotMtimes");m(mp,"detectModifiedFiles");m(gr,"executeAgent")});import{execFile as pp}from"node:child_process";function Fe(l,e){return new Promise((t,s)=>{pp("git",l,{cwd:e.cwd,maxBuffer:10*1024*1024},(r,n,o)=>{if(r){let i=o?.trim()||r.message;s(new Error(`git ${l[0]} failed: ${i}`));return}t(n.trim())})})}async function Dn(l){try{let e=await Fe(["rev-parse","--abbrev-ref","HEAD"],l),t=await Fe(["status","--porcelain"],l);return{isRepo:!0,branch:e,dirty:t.length>0}}catch{return{isRepo:!1,branch:"",dirty:!1}}}async function Ti(l,e){await Fe(["checkout","-b",l],e)}async function _i(l){await Fe(["add","-A"],l)}async function bi(l,e){await Fe(["commit","-m",l],e);let t=await Fe(["rev-parse","--short","HEAD"],e),r=(await Fe(["diff","--stat","HEAD~1","HEAD"],e)).split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madh-io/alfred-ai",
3
- "version": "0.10.62",
3
+ "version": "0.10.63",
4
4
  "description": "Alfred — Personal AI Assistant across Telegram, Discord, WhatsApp, Matrix & Signal",
5
5
  "type": "module",
6
6
  "bin": {