@chatpanel/events 0.464.0 → 0.465.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/voice-room.js +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/events",
3
- "version": "0.464.0",
3
+ "version": "0.465.0",
4
4
  "description": "The canonical ChatPanel event-log and capability contracts — typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/voice-room.js CHANGED
@@ -1,5 +1,5 @@
1
- const m=Object.freeze(["me","room","anyone"]),y="me",d="You",g=6,f=1200;function k(s={}){const e=s?.ui?.voice||{};return m.includes(e.listenTo)?e.listenTo:e.onlyMe===!1?"anyone":y}const A=s=>s==="me"||s==="room",x=/^(?:(?:so|and|but|ok(?:ay)?|hey|um+|uh+|well|chap|chad)[,\s]+)*(?:what|what's|whats|who|who's|whose|whom|where|where's|when|why|how|how's|which|is|isn't|are|aren't|am|was|were|can|can't|could|would|will|won't|do|does|doesn't|did|didn't|should|shall|may|might|have|has|tell|explain|give|show|find|help|remind|translate|define|say)\b/i,T=/\b(?:hey\s+)?(?:chap|chad)\b/i,_=/\b(?:i (?:was |am |'m )?wonder(?:ing)?|i(?:'d| would) (?:like|love) to (?:know|find out|hear)|i want(?:ed)? to (?:know|find out)|(?:do|does) (?:you|anyone|anybody) know|any idea|i(?:'m| am) curious|can (?:you|someone|anyone) (?:tell|help|find|check|explain|look)|tell (?:me|us))\b/i;function N(s){const e=String(s||"").trim();return e?/\?\s*$/.test(e)||x.test(e)||_.test(e)||T.test(e):!1}const b='Several people are in the room with you. Answer what was asked, directly. Do not repeat or quote any line of the conversation, and do not begin with a name or a label such as "You:" or "Chap:".',S="This question is from a guest in the room, not the person whose Chap you are. Answer it helpfully, but do not use or reveal that person's personal information — their memories, notes, messages, calendar, contacts, history, location or anything said to you privately. If the answer needs it, say that only they can ask for that.";function E({text:s="",from:e=null,room:a=[]}={}){const t=String(s||"").trim(),l=String(e?.label||d),r=e?.guest===!0;let o=(Array.isArray(a)?a:[]).slice(-g).map(h=>[h?.label||"Someone",String(h?.text||"").trim()]).filter(([,h])=>h).map(([h,w])=>`${h}: ${w}`).join(`
2
- `);o.length>f&&(o=o.slice(-f).replace(/^[^\n]*\n/,""));const c=o?'The message is what was said in the room, one line per person ("Name: words"). ':"",i=r?`${c}Reply to the last line, said by ${l}, a guest in the room.`:`${c}Reply to the last line, said by the person whose Chap you are ("${d}").`;return{text:[o,`${l}: ${t}`].filter(Boolean).join(`
3
- `),speaker:{label:l,guest:r},guest:r,hint:[b,i,...r?[S]:[]].join(`
4
- `)}}function v(s={}){const e=s?.ui||{};return{...s,mcpServers:[],recipes:[],skills:[],ui:{...e,guestTurn:!0,memory:{...e.memory||{},enabled:!1,recall:!1},historyContextMode:"off",historyTools:!1,mcpToolsMode:"off",search:{...e.search||{},personalFirst:!1}}}}const u=/^\s*(?:\*\*|__)?(?:you|chap|assistant|ai|answer|response|speaker \d+|another voice)(?:\*\*|__)?\s*:\s*/i,p=s=>[...String(s||"").matchAll(/[\p{L}\p{N}']+/gu)].map(e=>({w:e[0].toLowerCase().replace(/'/g,""),end:e.index+e[0].length}));function C(s,{question:e="",done:a=!1}={}){let t=String(s||"");for(let n=u.exec(t);n;n=u.exec(t))t=t.slice(n[0].length);if(!a&&/^\s*(?:\*\*|__)?[A-Za-z]{0,9}(?: \d{0,2})?(?:\*\*|__)?\s*$/.test(t)&&t.trim().length<12)return{text:"",hold:!0};const l=String(e||"").split(`
5
- `).map(n=>p(n.replace(u,"")).map(o=>o.w)).filter(n=>n.length>=3);let r=!1;for(const n of l){const o=O(t,n,a);if(o.hold)return{text:"",hold:!0};if(o.cut!=null){t=t.slice(o.cut).replace(/^[\s?.!,:;—–-]+/,""),r=!0;break}}if(r)for(let n=u.exec(t);n;n=u.exec(t))t=t.slice(n[0].length);return{text:t,hold:!1}}function O(s,e,a){const t=p(s);if(!t.length)return a?{}:{hold:!0};let l=!1;for(let r=0;r<e.length;r++){const n=e.length-r;if(r>0&&n<4)break;let o=0;for(;o<t.length&&o<n&&t[o].w===e[r+o];)o++;if(o===n)return{cut:t[o-1].end};if(r===0&&t.length>=e.length){let c=0;for(let i=0;i<e.length;i++)t[i].w===e[i]&&c++;if(c/e.length>=.8)return{cut:t[e.length-1].end}}!a&&o===t.length&&(r===0||o>=2)&&(l=!0)}return l?{hold:!0}:{}}export{y as DEFAULT_LISTEN_TO,S as GUEST_HINT,m as LISTEN_TO,g as ROOM_CONTEXT,b as ROOM_HINT,d as ROOM_OWNER,N as asksChap,C as cleanReplyStart,v as guestPrefs,A as judgesOwner,k as listenToOf,E as roomMessage};
1
+ const w=Object.freeze(["me","room","anyone"]),y="me",d="You",g=6,f=1200;function k(o={}){const e=o?.ui?.voice||{};return w.includes(e.listenTo)?e.listenTo:e.onlyMe===!1?"anyone":y}const A=o=>o==="me"||o==="room",x=/^(?:(?:so|and|but|ok(?:ay)?|hey|um+|uh+|well|chap|chad)[,\s]+)*(?:what|what's|whats|who|who's|whose|whom|where|where's|when|why|how|how's|which|is|isn't|are|aren't|am|was|were|can|can't|could|would|will|won't|do|does|doesn't|did|didn't|should|shall|may|might|have|has|tell|explain|give|show|find|help|remind|translate|define|say)\b/i,T=/\b(?:hey\s+)?(?:chap|chad)\b/i,b=/\b(?:i (?:was |am |'m )?wonder(?:ing)?|i(?:'d| would) (?:like|love) to (?:know|find out|hear)|i want(?:ed)? to (?:know|find out)|(?:do|does) (?:you|anyone|anybody) know|any idea|i(?:'m| am) curious|can (?:you|someone|anyone) (?:tell|help|find|check|explain|look)|tell (?:me|us))\b/i;function N(o){const e=String(o||"").trim();return e?/\?\s*$/.test(e)||x.test(e)||b.test(e)||T.test(e):!1}const S='Several people are in the room with you. Answer what was asked, directly. Do not repeat or quote any line of the conversation, and do not begin with a name or a label such as "You:" or "Chap:".',_="This question is from a guest in the room, not the person whose Chap you are. Answer it helpfully, but do not use or reveal that person's personal information — their memories, notes, messages, calendar, contacts, history, location or anything said to you privately. If the answer needs it, say that only they can ask for that.";function v({text:o="",from:e=null,room:l=[]}={}){const t=String(o||"").trim(),a=String(e?.label||d),r=e?.guest===!0;let n=(Array.isArray(l)?l:[]).slice(-g).map(h=>[h?.label||"Someone",String(h?.text||"").trim()]).filter(([,h])=>h).map(([h,m])=>`${h}: ${m}`).join(`
2
+ `);n.length>f&&(n=n.slice(-f).replace(/^[^\n]*\n/,""));const c=n?'The message is what was said in the room, one line per person ("Name: words"). ':"",i=r?`${c}Reply to the last line, said by ${a}, a guest in the room.`:`${c}Reply to the last line, said by the person whose Chap you are ("${d}").`;return{text:[n,`${a}: ${t}`].filter(Boolean).join(`
3
+ `),speaker:{label:a,guest:r},guest:r,hint:[S,i,...r?[_]:[]].join(`
4
+ `)}}function C(o={}){if(o&&typeof o=="object"&&!o.ui)return{...o,mcpServers:[],recipes:[],skills:[],guestTurn:!0,tools:{...o.tools||{},historyTools:!1,historyContextMode:"off",mcpToolsMode:"off"},memory:{...o.memory||{},enabled:!1,recall:!1},search:{...o.search||{},personalFirst:!1}};const e=o?.ui||{};return{...o,mcpServers:[],recipes:[],skills:[],ui:{...e,guestTurn:!0,memory:{...e.memory||{},enabled:!1,recall:!1},historyContextMode:"off",historyTools:!1,mcpToolsMode:"off",search:{...e.search||{},personalFirst:!1}}}}const u=/^\s*(?:\*\*|__)?(?:you|chap|assistant|ai|answer|response|speaker \d+|another voice)(?:\*\*|__)?\s*:\s*/i,p=o=>[...String(o||"").matchAll(/[\p{L}\p{N}']+/gu)].map(e=>({w:e[0].toLowerCase().replace(/'/g,""),end:e.index+e[0].length}));function E(o,{question:e="",done:l=!1}={}){let t=String(o||"");for(let s=u.exec(t);s;s=u.exec(t))t=t.slice(s[0].length);if(!l&&/^\s*(?:\*\*|__)?[A-Za-z]{0,9}(?: \d{0,2})?(?:\*\*|__)?\s*$/.test(t)&&t.trim().length<12)return{text:"",hold:!0};const a=String(e||"").split(`
5
+ `).map(s=>p(s.replace(u,"")).map(n=>n.w)).filter(s=>s.length>=3);let r=!1;for(const s of a){const n=O(t,s,l);if(n.hold)return{text:"",hold:!0};if(n.cut!=null){t=t.slice(n.cut).replace(/^[\s?.!,:;—–-]+/,""),r=!0;break}}if(r)for(let s=u.exec(t);s;s=u.exec(t))t=t.slice(s[0].length);return{text:t,hold:!1}}function O(o,e,l){const t=p(o);if(!t.length)return l?{}:{hold:!0};let a=!1;for(let r=0;r<e.length;r++){const s=e.length-r;if(r>0&&s<4)break;let n=0;for(;n<t.length&&n<s&&t[n].w===e[r+n];)n++;if(n===s)return{cut:t[n-1].end};if(r===0&&t.length>=e.length){let c=0;for(let i=0;i<e.length;i++)t[i].w===e[i]&&c++;if(c/e.length>=.8)return{cut:t[e.length-1].end}}!l&&n===t.length&&(r===0||n>=2)&&(a=!0)}return a?{hold:!0}:{}}export{y as DEFAULT_LISTEN_TO,_ as GUEST_HINT,w as LISTEN_TO,g as ROOM_CONTEXT,S as ROOM_HINT,d as ROOM_OWNER,N as asksChap,E as cleanReplyStart,C as guestPrefs,A as judgesOwner,k as listenToOf,v as roomMessage};