@opencxh/domain 1.127.0 → 1.130.0

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/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=140;function A(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim()}function k(e){const t=e.trim();return t.length<=d?t:t.slice(0,d-1).trimEnd()+"…"}function l(e){if(!e||e<0)return"";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}function V(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const t=e.payload,n=t.bodySnippet?.trim()||A(t.body??"");return t.subject?`${t.subject} — ${n}`:n}case"CHAT_MESSAGE_SENT":case"CHAT_MESSAGE_RECEIVED":return e.payload.text??"";case"CHAT_RENAMED":return`Hernoemd naar "${e.payload.newName}"`;case"CHAT_MEMBER_JOINED":return`${e.payload.members.map(t=>t.name).join(", ")} toegevoegd`;case"CHAT_MEMBER_LEFT":return`${e.payload.members.map(t=>t.name).join(", ")} verlaten`;case"CHAT_CALL_STARTED":return"Gesprek gestart";case"CHAT_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"CHAT_EVENT":return e.payload.text??e.payload.eventType;case"VOICE_CALL_STARTED":case"VIDEO_CALL_STARTED":return"Gesprek gestart";case"VOICE_CALL_ANSWERED":case"VIDEO_CALL_ANSWERED":return"Gesprek aangenomen";case"VOICE_CALL_HOLD":case"VIDEO_CALL_HOLD":return"In de wacht";case"VOICE_CALL_UNHOLD":case"VIDEO_CALL_UNHOLD":return"Hervat";case"VOICE_CALL_ENDED":case"VIDEO_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"VOICE_CALL_MISSED":case"VIDEO_CALL_MISSED":return"Gemiste oproep";case"VOICE_CALL_FAILED":case"VIDEO_CALL_FAILED":return"Gesprek mislukt";case"VOICE_CALL_VOICEMAIL":return e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen";case"TRANSCRIPT_ADDED":return(e.payload.segments??[]).map(t=>t.text).join(" ");case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";case"AI_ACTION_PROPOSED":return`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`;case"PLAYBOOK_STARTED":return`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`;case"PLAYBOOK_COMPLETED":return"Playbook afgerond";case"PLAYBOOK_ESCALATED":return"Playbook geëscaleerd naar een mens";case"MEETING_SCHEDULED":return`Vergadering gepland: ${e.payload.title}`;case"MEETING_STARTED":return`Vergadering gestart: ${e.payload.title}`;case"MEETING_ENDED":return`Vergadering beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"MEETING_PARTICIPANT_JOINED":return`${e.payload.name} deelgenomen`;case"MEETING_PARTICIPANT_LEFT":return`${e.payload.name} verlaten`;case"COMMENT_ADDED":return e.payload.text??"";case"FILE_UPLOADED":return`Bestand: ${e.payload.fileName}`;case"INTERACTION_CREATED":return"Interactie aangemaakt";case"INTERACTION_STATUS_CHANGED":return`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;case"INTERACTION_ASSIGNED":return"Interactie toegewezen";default:return""}}function G(e){return{activityId:e.id,type:e.type,snippet:k(V(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function $(e,t,n=[]){const r=e.createdAt;if(!r)return[];const a=new Set(n);return e.author.type==="user"&&e.author.id&&a.add(e.author.id),Object.entries(t).filter(([s,i])=>i>=r&&!a.has(s)).map(([s])=>s)}const w=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function H(e){const t=[];for(const n of Object.keys(e))for(const r of Object.keys(e[n]))t.push({lang:n,key:r,value:e[n][r]});return t}function c(e){return e<10?`0${e}`:`${e}`}function I(e,t){const n=new Date(e),r=`${n.getUTCFullYear()}-${c(n.getUTCMonth()+1)}-${c(n.getUTCDate())}`;return t==="day"?r:`${r}T${c(n.getUTCHours())}`}function S(e,t){const n=new Date(e);return n.setUTCMinutes(0,0,0),t==="day"&&n.setUTCHours(0),n.getTime()}const B=36e5,x=864e5;function F(e,t,n){const r=n==="hour"?B:x,a=[];for(let s=S(e,n);s<=t;s+=r)a.push(I(s,n));return a}const b=[{id:"resource",label:"Resource",labelSource:"raw"},{id:"origin",label:"Herkomst",labelSource:"raw"}],_=b.map(e=>e.id);function m(e,t){return`${e}.usage.${t}`}function v(e,t){return t.map(n=>({id:m(e,n.unit),label:n.label,category:"Verbruik",valueType:n.valueType??"count",aggregation:"sum",supportedDimensions:["provider",..._,...n.extraDimensions??[],"time"]}))}function W(e){return(e.startsWith("tool:")?e.slice(5):e).replace(/__/g," · ").replace(/\./g," · ").replace(/_/g," ")}const j=[{name:"text",type:"string"},{name:"subject",type:"string"},{name:"from",type:"string"},{name:"type",type:"string"},{name:"direction",type:"string"},{name:"channelId",type:"string"},{name:"interactionId",type:"string"},{name:"activityId",type:"string"},{name:"authorType",type:"string"},{name:"authorName",type:"string"},{name:"textRaw",type:"string"}],K={topics:[{name:"topic",type:"string"},{name:"confidence",type:"number"}],question:[{name:"answer",type:"boolean"},{name:"confidence",type:"number"}],extract:[]};function T(e){switch(e.kind){case"user":return`user:${e.userId}`;case"team":return`team:${e.teamId}`;case"org":return"org"}}function Y(e){if(typeof e!="string")return;const t=e.trim();if(t==="org")return{kind:"org"};const n=t.indexOf(":");if(n<=0)return;const r=t.slice(0,n),a=t.slice(n+1).trim();if(a){if(r==="user")return{kind:"user",userId:a};if(r==="team")return{kind:"team",teamId:a}}}function R(e){return T(e)}function q(e){switch(e.kind){case"personal":return{kind:"user",userId:e.userId};case"team":return{kind:"team",teamId:e.teamId};case"org":return{kind:"org"}}}function z(e){return R(e)}const N=["done","escalated","failed","timed_out","stopped"],M=["awaiting_approval","awaiting_reply"];function D(e){return N.includes(e)}function J(e){return D(e)}function Q(e){return M.includes(e)}const u=[{id:"openai",label:"OpenAI",capabilities:["chat","transcription","embedding"],defaultModel:"gpt-5-mini",baseUrl:"https://api.openai.com/v1"},{id:"gemini",label:"Google Gemini",capabilities:["chat","transcription","embedding"],defaultModel:"gemini-3.5-flash",baseUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"anthropic",label:"Anthropic",capabilities:["chat"],defaultModel:"claude-haiku-4-5",baseUrl:"https://api.anthropic.com/v1"},{id:"elevenlabs",label:"ElevenLabs",capabilities:["transcription"],baseUrl:"https://api.elevenlabs.io/v1"},{id:"moonshot",label:"Moonshot (Kimi)",capabilities:["chat"],defaultModel:"kimi-k3",baseUrl:"https://api.moonshot.ai/v1"},{id:"deepseek",label:"DeepSeek",capabilities:["chat"],defaultModel:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1"},{id:"groq",label:"Groq",capabilities:["chat"],defaultModel:"openai/gpt-oss-120b",baseUrl:"https://api.groq.com/openai/v1"},{id:"mistral",label:"Mistral",capabilities:["chat"],defaultModel:"mistral-large-latest",baseUrl:"https://api.mistral.ai/v1"},{id:"openrouter",label:"OpenRouter",capabilities:["chat"],defaultModel:"openrouter/auto",baseUrl:"https://openrouter.ai/api/v1"},{id:"ollama",label:"Ollama (self-hosted)",capabilities:["chat"],defaultModel:"llama3.3"},{id:"openai-compatible",label:"OpenAI-compatible (eigen endpoint)",capabilities:["chat"],defaultModel:"default"}];function o(e){return u.find(t=>t.id===e)}function X(e){return o(e)?.label??e}function Z(e,t="gpt-5-mini"){return o(e)?.defaultModel??t}function ee(e){return u.filter(t=>t.capabilities.includes(e))}function te(e){const t=o(e);return!!t&&!t.baseUrl}const ne=new Set(["mail","message"]);function O(e,t){const n=e.settings?.signatures?.[t];return!n||!n.enabled||!n.body||n.body.trim()===""?null:n}function re(e,t,n,r="html"){if(!e)return n;const a=O(e,t);return a?`${n}${r==="text"?`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=140;function T(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim()}function Y(e){const n=e.trim();return n.length<=m?n:n.slice(0,m-1).trimEnd()+"…"}function d(e){if(!e||e<0)return"";const n=Math.floor(e/60),t=Math.floor(e%60);return`${n}:${t.toString().padStart(2,"0")}`}function j(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const n=e.payload,t=n.bodySnippet?.trim()||T(n.body??"");return n.subject?`${n.subject} — ${t}`:t}case"CHAT_MESSAGE_SENT":case"CHAT_MESSAGE_RECEIVED":return e.payload.text??"";case"CHAT_RENAMED":return`Hernoemd naar "${e.payload.newName}"`;case"CHAT_MEMBER_JOINED":return`${e.payload.members.map(n=>n.name).join(", ")} toegevoegd`;case"CHAT_MEMBER_LEFT":return`${e.payload.members.map(n=>n.name).join(", ")} verlaten`;case"CHAT_CALL_STARTED":return"Gesprek gestart";case"CHAT_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"CHAT_EVENT":return e.payload.text??e.payload.eventType;case"VOICE_CALL_STARTED":case"VIDEO_CALL_STARTED":return"Gesprek gestart";case"VOICE_CALL_ANSWERED":case"VIDEO_CALL_ANSWERED":return"Gesprek aangenomen";case"VOICE_CALL_HOLD":case"VIDEO_CALL_HOLD":return"In de wacht";case"VOICE_CALL_UNHOLD":case"VIDEO_CALL_UNHOLD":return"Hervat";case"VOICE_CALL_ENDED":case"VIDEO_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"VOICE_CALL_MISSED":case"VIDEO_CALL_MISSED":return"Gemiste oproep";case"VOICE_CALL_FAILED":case"VIDEO_CALL_FAILED":return"Gesprek mislukt";case"VOICE_CALL_VOICEMAIL":return e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen";case"TRANSCRIPT_ADDED":return(e.payload.segments??[]).map(n=>n.text).join(" ");case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";case"AI_ACTION_PROPOSED":return`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`;case"PLAYBOOK_STARTED":return`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`;case"PLAYBOOK_COMPLETED":return"Playbook afgerond";case"PLAYBOOK_ESCALATED":return"Playbook geëscaleerd naar een mens";case"MEETING_SCHEDULED":return`Vergadering gepland: ${e.payload.title}`;case"MEETING_STARTED":return`Vergadering gestart: ${e.payload.title}`;case"MEETING_ENDED":return`Vergadering beëindigd${e.payload.duration?` (${d(e.payload.duration)})`:""}`;case"MEETING_PARTICIPANT_JOINED":return`${e.payload.name} deelgenomen`;case"MEETING_PARTICIPANT_LEFT":return`${e.payload.name} verlaten`;case"COMMENT_ADDED":return e.payload.text??"";case"FILE_UPLOADED":return`Bestand: ${e.payload.fileName}`;case"INTERACTION_CREATED":return"Interactie aangemaakt";case"INTERACTION_STATUS_CHANGED":return`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;case"INTERACTION_ASSIGNED":return"Interactie toegewezen";default:return""}}function K(e){return{activityId:e.id,type:e.type,snippet:Y(j(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function z(e,n,t=[]){const r=e.createdAt;if(!r)return[];const a=new Set(t);return e.author.type==="user"&&e.author.id&&a.add(e.author.id),Object.entries(n).filter(([i,o])=>o>=r&&!a.has(i)).map(([i])=>i)}const q=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function X(e){const n=[];for(const t of Object.keys(e))for(const r of Object.keys(e[t]))n.push({lang:t,key:r,value:e[t][r]});return n}function p(e){return e<10?`0${e}`:`${e}`}function D(e,n){const t=new Date(e),r=`${t.getUTCFullYear()}-${p(t.getUTCMonth()+1)}-${p(t.getUTCDate())}`;return n==="day"?r:`${r}T${p(t.getUTCHours())}`}function h(e,n){const t=new Date(e);return t.setUTCMinutes(0,0,0),n==="day"&&t.setUTCHours(0),t.getTime()}const J=36e5,Q=864e5;function Z(e,n,t){const r=t==="hour"?J:Q,a=[];for(let i=h(e,t);i<=n;i+=r)a.push(D(i,t));return a}const N=[{id:"resource",label:"Resource",labelSource:"raw"},{id:"origin",label:"Herkomst",labelSource:"raw"}],R=N.map(e=>e.id);function O(e,n){return`${e}.usage.${n}`}function ee(e,n){return n.map(t=>({id:O(e,t.unit),label:t.label,category:"Verbruik",valueType:t.valueType??"count",aggregation:"sum",supportedDimensions:["provider",...R,...t.extraDimensions??[],"time"]}))}function ne(e){return(e.startsWith("tool:")?e.slice(5):e).replace(/__/g," · ").replace(/\./g," · ").replace(/_/g," ")}const te=[{name:"text",type:"string"},{name:"subject",type:"string"},{name:"from",type:"string"},{name:"type",type:"string"},{name:"direction",type:"string"},{name:"channelId",type:"string"},{name:"interactionId",type:"string"},{name:"activityId",type:"string"},{name:"authorType",type:"string"},{name:"authorName",type:"string"},{name:"textRaw",type:"string"},{name:"fromStatus",type:"string"},{name:"toStatus",type:"string"},{name:"contactId",type:"string"},{name:"companyId",type:"string"}],re={topics:[{name:"topic",type:"string"},{name:"confidence",type:"number"}],question:[{name:"answer",type:"boolean"},{name:"confidence",type:"number"}],extract:[]};function C(e){switch(e.kind){case"user":return`user:${e.userId}`;case"team":return`team:${e.teamId}`;case"org":return"org"}}function ae(e){if(typeof e!="string")return;const n=e.trim();if(n==="org")return{kind:"org"};const t=n.indexOf(":");if(t<=0)return;const r=n.slice(0,t),a=n.slice(t+1).trim();if(a){if(r==="user")return{kind:"user",userId:a};if(r==="team")return{kind:"team",teamId:a}}}function L(e){return C(e)}function ie(e){switch(e.kind){case"personal":return{kind:"user",userId:e.userId};case"team":return{kind:"team",teamId:e.teamId};case"org":return{kind:"org"}}}function oe(e){return L(e)}const y=["done","escalated","failed","timed_out","stopped"],U=["awaiting_approval","awaiting_reply"];function P(e){return y.includes(e)}function se(e){return P(e)}function le(e){return U.includes(e)}const f=[{id:"openai",label:"OpenAI",capabilities:["chat","transcription","embedding"],defaultModel:"gpt-5-mini",baseUrl:"https://api.openai.com/v1"},{id:"gemini",label:"Google Gemini",capabilities:["chat","transcription","embedding"],defaultModel:"gemini-3.5-flash",baseUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"anthropic",label:"Anthropic",capabilities:["chat"],defaultModel:"claude-haiku-4-5",baseUrl:"https://api.anthropic.com/v1"},{id:"elevenlabs",label:"ElevenLabs",capabilities:["transcription"],baseUrl:"https://api.elevenlabs.io/v1"},{id:"moonshot",label:"Moonshot (Kimi)",capabilities:["chat"],defaultModel:"kimi-k3",baseUrl:"https://api.moonshot.ai/v1"},{id:"deepseek",label:"DeepSeek",capabilities:["chat"],defaultModel:"deepseek-v4-flash",baseUrl:"https://api.deepseek.com/v1"},{id:"groq",label:"Groq",capabilities:["chat"],defaultModel:"openai/gpt-oss-120b",baseUrl:"https://api.groq.com/openai/v1"},{id:"mistral",label:"Mistral",capabilities:["chat"],defaultModel:"mistral-large-latest",baseUrl:"https://api.mistral.ai/v1"},{id:"openrouter",label:"OpenRouter",capabilities:["chat"],defaultModel:"openrouter/auto",baseUrl:"https://openrouter.ai/api/v1"},{id:"ollama",label:"Ollama (self-hosted)",capabilities:["chat"],defaultModel:"llama3.3"},{id:"openai-compatible",label:"OpenAI-compatible (eigen endpoint)",capabilities:["chat"],defaultModel:"default"}];function c(e){return f.find(n=>n.id===e)}function ce(e){return c(e)?.label??e}function ue(e,n="gpt-5-mini"){return c(e)?.defaultModel??n}function de(e){return f.filter(n=>n.capabilities.includes(e))}function pe(e){const n=c(e);return!!n&&!n.baseUrl}const Ee=new Set(["mail","message"]);function k(e,n){const t=e.settings?.signatures?.[n];return!t||!t.enabled||!t.body||t.body.trim()===""?null:t}function fe(e,n,t,r="html"){if(!e)return t;const a=k(e,n);return a?`${t}${r==="text"?`
2
2
 
3
- `:t==="mail"?"<br><br>-- <br>":"<br><br>"}${a.body}`:n}function ae(e){return e.endpoints??[]}const se=e=>!!e.assignedUserId||!!e.assignedInboxId,ie=e=>e.status==="closed",oe=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,le=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function ce(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}const ue=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],p=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,de=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function pe(e){const t=e.split(`
4
- `);for(let n=0;n<t.length;n++)if(de.test(t[n])||p.test(t[n])&&t.slice(n+1,n+4).some(r=>p.test(r)))return t.slice(0,n).join(`
5
- `).trim();return e}function E(e){let t=e;return t=t.replace(/<(script|style)[\s\S]*?<\/\1>/gi,""),t=t.replace(/<br\s*\/?>/gi,`
6
- `),t=t.replace(/<\/(p|div|li|tr|h[1-6]|ul|ol|table)>/gi,`
7
- `),t=t.replace(/<[^>]+>/g,""),t=t.replace(/<[^>]*$/,""),t}function g(e){return e.replace(/&nbsp;/gi," ").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/&#(\d+);/g,(t,n)=>String.fromCharCode(Number(n))).replace(/&amp;/gi,"&")}function f(e){return e.replace(/\r/g,"").replace(/[ \t]+/g," ").replace(/ *\n */g,`
3
+ `:n==="mail"?"<br><br>-- <br>":"<br><br>"}${a.body}`:t}function ge(e){return e.endpoints??[]}const me=e=>!!e.assignedUserId||!!e.assignedInboxId,Ae=e=>e.status==="closed",Ie=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,_e=(e,n=30)=>e.title?.length<=n?e.title:`${e.title.substring(0,n)}...`;function Se(e,n){return e.lastActivityAt?!(e.seenBy??[]).includes(n):!1}const Me=2e3,be=500,Te=12e3,De=4e3,x=["contact","company"];function he(e){if(!e)return!1;const n=e.slice(0,e.indexOf(":"));return x.includes(n)}const u={NL:{callingCode:"31",trunkPrefix:"0",nsnMin:7,nsnMax:9},BE:{callingCode:"32",trunkPrefix:"0",nsnMin:8,nsnMax:9},LU:{callingCode:"352",nsnMin:6,nsnMax:9},DE:{callingCode:"49",trunkPrefix:"0",nsnMin:6,nsnMax:13},FR:{callingCode:"33",trunkPrefix:"0",nsnMin:9,nsnMax:9},GB:{callingCode:"44",trunkPrefix:"0",nsnMin:9,nsnMax:10},IE:{callingCode:"353",trunkPrefix:"0",nsnMin:7,nsnMax:9},ES:{callingCode:"34",nsnMin:9,nsnMax:9},PT:{callingCode:"351",nsnMin:9,nsnMax:9},IT:{callingCode:"39",nsnMin:6,nsnMax:11},AT:{callingCode:"43",trunkPrefix:"0",nsnMin:7,nsnMax:13},CH:{callingCode:"41",trunkPrefix:"0",nsnMin:9,nsnMax:9},DK:{callingCode:"45",nsnMin:8,nsnMax:8},SE:{callingCode:"46",trunkPrefix:"0",nsnMin:7,nsnMax:13},NO:{callingCode:"47",nsnMin:8,nsnMax:8},FI:{callingCode:"358",trunkPrefix:"0",nsnMin:5,nsnMax:12},PL:{callingCode:"48",nsnMin:9,nsnMax:9},US:{callingCode:"1",nsnMin:10,nsnMax:10},CA:{callingCode:"1",nsnMin:10,nsnMax:10}},$="NL",Ne=15,Re=8,Oe=Array.from(new Set(Object.values(u).map(e=>e.callingCode))).sort((e,n)=>n.length-e.length);function A(e){if(e)return u[e.trim().toUpperCase()]}function l(e,n){return e.length>=n.nsnMin&&e.length<=n.nsnMax}function I(e){if(e.length>Ne)return null;for(const n of Oe){if(!e.startsWith(n))continue;const t=e.slice(n.length);for(const r of Object.values(u)){if(r.callingCode!==n)continue;const a=r.trunkPrefix,i=a&&t.startsWith(a)?t.slice(a.length):t;if(l(i,r))return`+${n}${i}`}return null}return e.length<Re?null:`+${e}`}function Ce(e){let n=e.trim();const t=n.match(/^(sips?|tel|whatsapp):/i);t&&(n=n.slice(t[0].length));const r=n.indexOf("@");return r>=0&&(n=n.slice(0,r)),n.trim()}function Le(e){if(!e)return!1;const n=e.indexOf("@");if(n<=0)return!1;const t=e.slice(0,n).trim();return!/^[+\d\s().-]+$/.test(t)}function E(e,n){if(!e)return null;const t=Ce(e);if(!t)return null;const r=t.startsWith("+"),a=t.replace(/\D/g,"");if(!a)return null;if(r)return I(a);if(a.startsWith("00"))return I(a.slice(2));const i=A(n)??A($);if(!i)return null;const o=i.trunkPrefix;if(o&&a.startsWith(o)){const s=a.slice(o.length);return l(s,i)?`+${i.callingCode}${s}`:null}if(a.startsWith(i.callingCode)){const s=a.slice(i.callingCode.length);if(l(s,i))return`+${i.callingCode}${s}`}return!o&&l(a,i)?`+${i.callingCode}${a}`:null}function ye(e,n=9){const t=(e??"").replace(/\D/g,"");return t.length<n?null:t.slice(-n)}function g(e){if(!e)return null;const n=e.trim().toLowerCase(),t=n.lastIndexOf("@");if(t<=0||t===n.length-1)return null;const r=n.slice(0,t).split("+")[0],a=n.slice(t+1);return!r||!a.includes(".")?null:`${r}@${a}`}function Ue(e){const n=g(e);return n?n.slice(n.lastIndexOf("@")+1):null}const Pe=new Set(["co.uk","org.uk","gov.uk","ac.uk","com.au","co.nz","com.br","co.za"]);function G(e){if(!e)return null;const n=e.trim().toLowerCase().replace(/\.$/,"").split(".").filter(Boolean);if(n.length<2)return null;const t=n.slice(-2).join(".");return Pe.has(t)&&n.length>=3?n.slice(-3).join("."):t}const V=new Set(["gmail.com","googlemail.com","outlook.com","hotmail.com","hotmail.nl","hotmail.be","hotmail.co.uk","live.com","live.nl","live.be","msn.com","yahoo.com","yahoo.co.uk","ymail.com","icloud.com","me.com","mac.com","aol.com","gmx.net","gmx.de","web.de","protonmail.com","proton.me","pm.me","tutanota.com","zoho.com","mail.com","ziggo.nl","kpnmail.nl","planet.nl","home.nl","casema.nl","chello.nl","xs4all.nl","telfort.nl","hetnet.nl","zonnet.nl","upcmail.nl","quicknet.nl","telenet.be","skynet.be","proximus.be","scarlet.be"]);function ke(e){const n=G(e);return n?V.has(n):!1}function xe(e){if(!e)return!1;const n=e.trim().toLowerCase();return n==="tel"||n==="sms"||n==="whatsapp"||n==="fax"}function $e(e,n,t){if(!e||!n)return null;const r=e.trim().toLowerCase();if(r==="tel"||r==="sms"||r==="whatsapp"){const i=E(n,t);return i?`tel:${i}`:null}if(r==="fax"){const i=E(n,t);return i?`fax:${i}`:null}if(r==="mailto"||r==="email"){const i=g(n);return i?`mailto:${i}`:null}const a=n.trim().toLowerCase();return a?`${r}:${a}`:null}const Ge=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],_=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,Ve=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function we(e){const n=e.split(`
4
+ `);for(let t=0;t<n.length;t++)if(Ve.test(n[t])||_.test(n[t])&&n.slice(t+1,t+4).some(r=>_.test(r)))return n.slice(0,t).join(`
5
+ `).trim();return e}function S(e){let n=e;return n=n.replace(/<(script|style)[\s\S]*?<\/\1>/gi,""),n=n.replace(/<br\s*\/?>/gi,`
6
+ `),n=n.replace(/<\/(p|div|li|tr|h[1-6]|ul|ol|table)>/gi,`
7
+ `),n=n.replace(/<[^>]+>/g,""),n=n.replace(/<[^>]*$/,""),n}function M(e){return e.replace(/&nbsp;/gi," ").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/&#(\d+);/g,(n,t)=>String.fromCharCode(Number(t))).replace(/&amp;/gi,"&")}function b(e){return e.replace(/\r/g,"").replace(/[ \t]+/g," ").replace(/ *\n */g,`
8
8
  `).replace(/\n{3,}/g,`
9
9
 
10
- `).trim()}function Ee(e){if(typeof e!="string"||!e)return"";let t=e.length;for(const s of ue){const i=e.search(s);i>=0&&i<t&&(t=i)}const n=e.slice(0,t);let r=f(g(E(n)));return r||(r=f(g(E(e)))),pe(r)||r}const ge=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,fe=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function Ae(e,t){return!!(e&&ge.test(e)||t&&fe.test(t))}const h=3,y=600;function Ie(e,t){return e>=h||t>=y}function L(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},a=t.intents.filter(i=>!n.has(i.intent)).map(i=>be(i,r[i.intent]));if(!e.extraIntents||e.extraIntents.length===0)return a;const s=new Set(a.map(i=>i.intent));for(const i of e.extraIntents)s.has(i.intent)||(a.push(i),s.add(i.intent));return a}function C(e,t){const n={};for(const r of e.intents){if(!r.togglable)continue;const a=t?.[r.intent];n[r.intent]=a??r.defaultEnabled??!0}return n}function Se(e,t){const n=C(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function be(e,t){return t?{intent:t.intent??e.intent,targetSchemes:t.targetSchemes??e.targetSchemes,transport:t.transport??e.transport}:e}function _e(e,t){const n=[];for(const r of e){if(!r.enabled)continue;const a=t[r.providerId];if(a)for(const s of L(r,a))n.push({channel:r,description:a,capability:s})}return n}function me(e,t){return t.filter(n=>n.capability.intent===e)}function U(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function Te(e,t){return U(e.scheme,t)}function Re(e,t,n){const r=[];for(const a of e)for(const s of n)s.capability.intent===t&&s.capability.targetSchemes.includes(a.scheme)&&r.push({channelIntent:s,endpoint:a});return r}var P=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(P||{});const Ne="message_window",Me="message_templates",De={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},Oe=(e,t)=>({intent:e,...t}),he="folder_management",ye="remote_search",Le={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},Ce=9e4,Ue="installation-id";exports.AI_VENDORS=u;exports.CLASSIFY_VARS=K;exports.CORE_DIMENSIONS=w;exports.CommunicationScheme=P;exports.FEATURE_FOLDER_MANAGEMENT=he;exports.FEATURE_REMOTE_SEARCH=ye;exports.INSTALLATION_HEADER=Ue;exports.InteractionParticipantRole=De;exports.PAUSED_RUN_STATUSES=M;exports.PRESENCE_ONLINE_WINDOW_MS=Ce;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=Me;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=Ne;exports.SIGNATURE_INTENTS=ne;exports.SUMMARY_MIN_LAST_CHARS=y;exports.SUMMARY_MIN_MESSAGES=h;exports.TERMINAL_RUN_STATUSES=N;exports.TRIGGER_VARS=j;exports.UNSUPPORTED=Le;exports.USAGE_DIMENSIONS=b;exports.USAGE_DIMENSION_IDS=_;exports.actingIdentityKey=R;exports.actorKey=z;exports.aiVendorDefaultModel=Z;exports.aiVendorLabel=X;exports.aiVendorNeedsBaseUrl=te;exports.aiVendorsWith=ee;exports.applySignature=re;exports.buildActivityPreview=G;exports.buildChannelIntents=_e;exports.cleanMessageText=Ee;exports.defineIntent=Oe;exports.disabledIntentsFromCapabilities=Se;exports.filterByEndpoint=Te;exports.filterByIntent=me;exports.filterByTargetScheme=U;exports.findAiVendor=o;exports.flattenLocales=H;exports.floorToPeriod=S;exports.formatActingIdentity=T;exports.formatPeriod=I;exports.getActivitySeenUserIds=$;exports.getContactEndpoints=ae;exports.getShortTitle=le;exports.getUrgencyScore=oe;exports.humanizeAction=W;exports.isAssigned=se;exports.isClosed=ie;exports.isInteractionUnseen=ce;exports.isLikelyBulk=Ae;exports.isPaused=Q;exports.isRetryable=J;exports.isTerminal=D;exports.isThreadLongEnough=Ie;exports.matchContactToIntents=Re;exports.parseActingIdentity=Y;exports.periodsInRange=F;exports.playbookActor=q;exports.resolveAccountCapabilities=C;exports.resolveChannelIntents=L;exports.resolveSignature=O;exports.stripHtml=A;exports.usageMetricId=m;exports.usageMetrics=v;
10
+ `).trim()}function Be(e){if(typeof e!="string"||!e)return"";let n=e.length;for(const i of Ge){const o=e.search(i);o>=0&&o<n&&(n=o)}const t=e.slice(0,n);let r=b(M(S(t)));return r||(r=b(M(S(e)))),we(r)||r}const He=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,Fe=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function ve(e,n){return!!(e&&He.test(e)||n&&Fe.test(n))}const w=3,B=600;function We(e,n){return e>=w||n>=B}function H(e,n){const t=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},a=n.intents.filter(o=>!t.has(o.intent)).map(o=>je(o,r[o.intent]));if(!e.extraIntents||e.extraIntents.length===0)return a;const i=new Set(a.map(o=>o.intent));for(const o of e.extraIntents)i.has(o.intent)||(a.push(o),i.add(o.intent));return a}function F(e,n){const t={};for(const r of e.intents){if(!r.togglable)continue;const a=n?.[r.intent];t[r.intent]=a??r.defaultEnabled??!0}return t}function Ye(e,n){const t=F(e,n);return Object.entries(t).filter(([,r])=>!r).map(([r])=>r)}function je(e,n){return n?{intent:n.intent??e.intent,targetSchemes:n.targetSchemes??e.targetSchemes,transport:n.transport??e.transport}:e}function Ke(e,n){const t=[];for(const r of e){if(!r.enabled)continue;const a=n[r.providerId];if(a)for(const i of H(r,a))t.push({channel:r,description:a,capability:i})}return t}function ze(e,n){return n.filter(t=>t.capability.intent===e)}function v(e,n){return n.filter(t=>t.capability.targetSchemes.includes(e))}function qe(e,n){return v(e.scheme,n)}function Xe(e,n,t){const r=[];for(const a of e)for(const i of t)i.capability.intent===n&&i.capability.targetSchemes.includes(a.scheme)&&r.push({channelIntent:i,endpoint:a});return r}var W=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(W||{});const Je="message_window",Qe="message_templates",Ze={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},en=(e,n)=>({intent:e,...n}),nn="folder_management",tn="remote_search",rn={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},an=9e4,on="installation-id";exports.AI_VENDORS=f;exports.CLASSIFY_VARS=re;exports.CORE_DIMENSIONS=q;exports.CommunicationScheme=W;exports.DEFAULT_MEMORY_BUDGET=De;exports.DEFAULT_PHONE_REGION=$;exports.FEATURE_FOLDER_MANAGEMENT=nn;exports.FEATURE_REMOTE_SEARCH=tn;exports.INSTALLATION_HEADER=on;exports.InteractionParticipantRole=Ze;exports.MAX_MEMORY_BUDGET=Te;exports.MAX_MEMORY_CHARS=Me;exports.MIN_MEMORY_BUDGET=be;exports.PAUSED_RUN_STATUSES=U;exports.PHONE_REGIONS=u;exports.PRESENCE_ONLINE_WINDOW_MS=an;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=Qe;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=Je;exports.PUBLIC_EMAIL_DOMAINS=V;exports.RELATED_SUBJECT_KINDS=x;exports.SIGNATURE_INTENTS=Ee;exports.SUMMARY_MIN_LAST_CHARS=B;exports.SUMMARY_MIN_MESSAGES=w;exports.TERMINAL_RUN_STATUSES=y;exports.TRIGGER_VARS=te;exports.UNSUPPORTED=rn;exports.USAGE_DIMENSIONS=N;exports.USAGE_DIMENSION_IDS=R;exports.actingIdentityKey=L;exports.actorKey=oe;exports.aiVendorDefaultModel=ue;exports.aiVendorLabel=ce;exports.aiVendorNeedsBaseUrl=pe;exports.aiVendorsWith=de;exports.applySignature=fe;exports.buildActivityPreview=K;exports.buildChannelIntents=Ke;exports.cleanMessageText=Be;exports.defineIntent=en;exports.disabledIntentsFromCapabilities=Ye;exports.emailDomain=Ue;exports.endpointKey=$e;exports.filterByEndpoint=qe;exports.filterByIntent=ze;exports.filterByTargetScheme=v;exports.findAiVendor=c;exports.flattenLocales=X;exports.floorToPeriod=h;exports.formatActingIdentity=C;exports.formatPeriod=D;exports.getActivitySeenUserIds=z;exports.getContactEndpoints=ge;exports.getShortTitle=_e;exports.getUrgencyScore=Ie;exports.humanizeAction=ne;exports.isAssigned=me;exports.isClosed=Ae;exports.isInteractionUnseen=Se;exports.isLikelyBulk=ve;exports.isPaused=le;exports.isPublicEmailDomain=ke;exports.isRetryable=se;exports.isTerminal=P;exports.isThreadLongEnough=We;exports.looksLikeEmail=Le;exports.matchContactToIntents=Xe;exports.needsPhoneRegion=xe;exports.normalizeEmail=g;exports.parseActingIdentity=ae;exports.periodsInRange=Z;exports.phoneSuffix=ye;exports.playbookActor=ie;exports.registrableDomain=G;exports.relatedByDefault=he;exports.resolveAccountCapabilities=F;exports.resolveChannelIntents=H;exports.resolveSignature=k;exports.stripHtml=T;exports.toE164=E;exports.usageMetricId=O;exports.usageMetrics=ee;
package/dist/index.d.ts CHANGED
@@ -12,12 +12,15 @@ export * from './entities/ai-profile';
12
12
  export * from './entities/mcp';
13
13
  export * from './entities/channel';
14
14
  export * from './entities/communication';
15
+ export * from './entities/company';
15
16
  export * from './entities/contact';
17
+ export * from './entities/contact-source';
16
18
  export * from './entities/custom-field-def';
17
19
  export * from './entities/calendar-event';
18
20
  export * from './entities/draft';
19
21
  export * from './entities/inbox';
20
22
  export * from './entities/interaction';
23
+ export * from './entities/memory';
21
24
  export * from './entities/task';
22
25
  export * from './entities/note';
23
26
  export * from './entities/read-state';
@@ -28,6 +31,7 @@ export * from './entities/shopify';
28
31
  export * from './entities/transcript';
29
32
  export * from './entities/user';
30
33
  export * from './entities/webhook';
34
+ export * from './text/endpoint';
31
35
  export * from './text/message';
32
36
  export * from './text/triage';
33
37
  export * from './platform/ai-tools';