@chatpanel/events 0.295.0 → 0.332.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 (51) hide show
  1. package/agent-card-view.js +1 -1
  2. package/agent-permission.js +2 -2
  3. package/agent-session-open.js +1 -0
  4. package/agent-thread.js +5 -0
  5. package/attached-paths.js +1 -1
  6. package/browser-relay.js +1 -1
  7. package/capability-uses.js +1 -1
  8. package/client-prefs.js +1 -1
  9. package/clock.js +1 -0
  10. package/compaction.js +4 -4
  11. package/context-select.js +2 -0
  12. package/context-window.js +1 -1
  13. package/dialect-a2a.js +1 -1
  14. package/dialect-claude.js +1 -1
  15. package/digest.js +7 -0
  16. package/fetched.js +2 -2
  17. package/find-tool.js +1 -1
  18. package/harness-cards.js +1 -1
  19. package/history-search.js +6 -6
  20. package/identity.js +1 -0
  21. package/index.js +1 -1
  22. package/link-connect.js +1 -1
  23. package/link-protocol.js +1 -1
  24. package/link-routes.js +2 -0
  25. package/memory.js +2 -2
  26. package/model-candidates.js +1 -1
  27. package/note-tool.js +2 -2
  28. package/own-instructions.js +5 -0
  29. package/package.json +25 -1
  30. package/prefetch.js +4 -2
  31. package/provider-presets.js +1 -1
  32. package/research.js +7 -7
  33. package/retrieval-plan.js +1 -0
  34. package/sandbox-policy.js +1 -1
  35. package/search-modes.js +6 -6
  36. package/service-standby.js +1 -0
  37. package/settings-registry.js +1 -1
  38. package/stitch.js +16 -14
  39. package/thread-send.js +1 -0
  40. package/tool-group-data.js +1 -1
  41. package/tool-hints.js +4 -4
  42. package/tool-hub.js +9 -7
  43. package/tool-need.js +3 -3
  44. package/tool-result.js +2 -2
  45. package/turn-intent.js +3 -0
  46. package/turn-loop.js +4 -4
  47. package/vault.js +1 -1
  48. package/voice-intents.js +2 -2
  49. package/voice-sample.js +1 -1
  50. package/weather-tool.js +10 -1
  51. package/weather.js +2 -2
package/weather-tool.js CHANGED
@@ -1 +1,10 @@
1
- import{getWeather as s,isHere as l}from"./weather.js";const d="weather",c="For weather, call `weather` FIRST — it answers the whole question in one request. Only fall back to web_search if it tells you to. Report the location it says it resolved, because a bare town name can geocode to the wrong place.";function w({fetchJson:t}={}){if(typeof t!="function")throw new Error("weatherToolProvider: fetchJson required");return{specs:[{name:"weather",annotations:{readOnlyHint:!0,idempotentHint:!0,openWorldHint:!0},description:"Current conditions and a short forecast for one place, in a single request. Use this for any weather question instead of searching. Returns the location it actually resolved to — say which place the answer is for.",parameters:{type:"object",properties:{location:{type:"string",description:'A place, as the user said it. Add a state or country only if THEY did — "Fairview, OR" if they said so, plain "Fairview" if they did not.'}},required:["location"],additionalProperties:!1}}],system:c,async execute(o,i){if(o!=="weather")return JSON.stringify({error:`Unknown tool: ${o}`});const r=String(i?.location||"").trim(),a=l(r)?"":r,e=await s(a,{fetchJson:t});if(!e.ok){const n=a||"my area";return`The weather service could not answer for "${n}" (${e.reason}). Now call web_search for "weather in ${n}" and answer from the results — do not tell the user a tool failed.`}return{text:e.text,note:"ChatPanel · wttr.in"}}}}export{d as WEATHER_TOOL_NAME,c as WEATHER_TOOL_SYSTEM,w as weatherToolProvider};
1
+ import{getWeather as f,isHere as d}from"./weather.js";const m="weather",w="For weather, call `weather` FIRST — it answers the whole question in one request. Only fall back to web_search if it tells you to. Report the location it says it resolved, because a bare town name can geocode to the wrong place.";function b({fetchJson:c,search:s=null}={}){if(typeof c!="function")throw new Error("weatherToolProvider: fetchJson required");return{specs:[{name:"weather",annotations:{readOnlyHint:!0,idempotentHint:!0,openWorldHint:!0},description:"Current conditions and a short forecast for one place, in a single request. Use this for any weather question instead of searching. Returns the location it actually resolved to — say which place the answer is for.",parameters:{type:"object",properties:{location:{type:"string",description:'A place, as the user said it. Add a state or country only if THEY did — "Fairview, OR" if they said so, plain "Fairview" if they did not.'}},required:["location"],additionalProperties:!1}}],system:w,async execute(r,h){if(r!=="weather")return JSON.stringify({error:`Unknown tool: ${r}`});const i=String(h?.location||"").trim(),a=d(i)?"":i,n=await f(a,{fetchJson:c});if(!n.ok){const e=a||"my area";if(typeof s=="function"){const o=`weather in ${e}`,t=await Promise.resolve().then(()=>s(o)).catch(()=>null),l=typeof t=="string"?t:t?.text,u=y(l);if(u)return{text:`Weather for "${e}", from a web search for "${o}" (the weather service did not know the place). Report it as the forecast for the place the sources name; say which place that is.
2
+
3
+ `+u,note:"ChatPanel · web search"}}return`The weather service could not answer for "${e}" (${n.reason}). Now call web_search for "weather in ${e}" and answer from the results — do not tell the user a tool failed.`}return{text:n.text,note:"ChatPanel · wttr.in"}}}}const p=/(?:-?\d{1,3}\s?°|°\s?[FC]\b|\b(?:high|low|feels like|currently|tonight|today|tomorrow)\b.*\d|\b(?:rain|showers|snow|sunny|sun|cloud(?:y|s)?|overcast|fog|clear|storm|wind|humidity|breeze)\b)/i;function y(c,{maxChars:s=1600}={}){const r=String(c||"");if(!r.trim())return"";const h=r.replace(/<svg[\s\S]*?<\/svg>/gi," ").replace(/<[^>]+>/g," ").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\]\((?:https?:)?[^)]*\)/g,"]"),i=(/(?:^|\n)Sources:\n([\s\S]*?)(?:\n---|\n\n#|$)/.exec(r)?.[1]||"").split(`
4
+ `).filter(o=>/^\[\d+\]/.test(o.trim())).slice(0,5),a=new Set,n=[];for(const o of h.split(`
5
+ `)){const t=o.replace(/[\t ]+/g," ").replace(/^[\s\d.,#*[\]-]{0,6}/,"").trim();if(t.length<4||t.length>200||!p.test(t)||/citation rules|cite it inline|sources section/i.test(t))continue;const l=t.toLowerCase();a.has(l)||(a.add(l),n.push(`- ${t}`))}if(!n.some(o=>/\d\s?°|°\s?[FC]/.test(o)))return"";let e=n.join(`
6
+ `);return e.length>s&&(e=e.slice(0,s).replace(/\n[^\n]*$/,"")),i.length?`${e}
7
+
8
+ Sources:
9
+ ${i.join(`
10
+ `)}`:e}export{m as WEATHER_TOOL_NAME,w as WEATHER_TOOL_SYSTEM,y as weatherFromSearch,b as weatherToolProvider};
package/weather.js CHANGED
@@ -1,2 +1,2 @@
1
- const m="https://wttr.in",F=7e3;class d extends Error{constructor(r,n){super(n),this.name="WeatherError",this.code=r}}function w(e,{host:r=m}={}){const n=String(e??"").trim();if(y(n))return`${r}/?format=j1`;if(n.length>120)throw new d("BAD_LOCATION","location is too long to be one");return`${r}/${encodeURIComponent(n)}?format=j1`}const f=/^(?:(?:right )?here|near me|nearby|around (?:here|me)|my (?:location|area|city|town|place)|(?:my )?current location|where i am|local(?:ly)?|outside|(?:right )?now|currently|today|tonight|tomorrow|(?:this|next|the) (?:morning|afternoon|evening|night|week|weekend)|(?:this |next |on )?(?:mon|tues|wednes|thurs|fri|satur|sun)day)$/i;function y(e){const r=String(e??"").trim().replace(/[?.!,]+$/,"").replace(/\s+/g," ");return!r||f.test(r)||r.split(/\s*(?:,|\band\b|\bor\b)\s*/).every(n=>f.test(n))}const s=e=>{const r=Number(e);return Number.isFinite(r)?r:null},l=e=>String(e??"").trim(),h=e=>Array.isArray(e)?l(e[0]?.value):l(e);function $(e,{query:r=""}={}){if(!e||typeof e!="object")return null;const n=Array.isArray(e.current_condition)?e.current_condition[0]:null;if(!n)return null;const t=s(n.temp_C),u=s(n.temp_F);if(t===null&&u===null)return null;const i=Array.isArray(e.nearest_area)?e.nearest_area[0]:null,o=i?{name:h(i.areaName),region:h(i.region),country:h(i.country),lat:s(i.latitude),lon:s(i.longitude)}:null,c=(Array.isArray(e.weather)?e.weather:[]).slice(0,3).map(a=>({date:l(a.date),maxC:s(a.maxtempC),maxF:s(a.maxtempF),minC:s(a.mintempC),minF:s(a.mintempF),sunrise:l(a.astronomy?.[0]?.sunrise),sunset:l(a.astronomy?.[0]?.sunset),condition:h(a.hourly?.[4]?.weatherDesc)||h(a.hourly?.[0]?.weatherDesc),chanceOfRain:s(a.hourly?.[4]?.chanceofrain)}));return{query:l(r),area:o,now:{tempC:t,tempF:u,feelsLikeC:s(n.FeelsLikeC),feelsLikeF:s(n.FeelsLikeF),condition:h(n.weatherDesc),humidity:s(n.humidity),windKph:s(n.windspeedKmph),windMph:s(n.windspeedMiles),windDir:l(n.winddir16Point),precipMm:s(n.precipMM),uv:s(n.uvIndex),observedAt:l(n.localObsDateTime)},days:c}}function g(e,r=""){if(!e)return r;const n=[e.name,e.region,e.country].map(l).filter(Boolean),t=new Set;return n.filter(i=>{const o=i.toLowerCase();return t.has(o)?!1:(t.add(o),!0)}).join(", ")||r}function C(e){const r=l(e);return r?!/[,]/.test(r)&&r.split(/\s+/).length<=2:!1}const x=e=>Math.round(e*9/5+32),p=(e,r)=>{const n=e===null&&r!==null?Math.round((r-32)*5/9):e,t=r===null&&e!==null?x(e):r;return n===null&&t===null?"":n===null?`${t}°F`:t===null?`${n}°C`:`${t}°F / ${n}°C`};function k(e){if(!e)return"";const r=g(e.area,e.query),n=[];n.push(`Weather for ${r}${e.query&&r.toLowerCase()!==e.query.toLowerCase()?` (asked: "${e.query}")`:""}`);const t=e.now,u=[`Now: ${p(t.tempC,t.tempF)}`];(t.feelsLikeC!==null||t.feelsLikeF!==null)&&u.push(`feels like ${p(t.feelsLikeC,t.feelsLikeF)}`),t.condition&&u.push(t.condition.toLowerCase()),n.push(u.join(", "));const i=[];t.humidity!==null&&i.push(`humidity ${t.humidity}%`),(t.windMph!==null||t.windKph!==null)&&i.push(`wind ${t.windMph!==null?`${t.windMph} mph`:`${t.windKph} km/h`}${t.windDir?` ${t.windDir}`:""}`),t.precipMm!==null&&i.push(`precip ${t.precipMm} mm`),t.uv!==null&&i.push(`UV ${t.uv}`),i.length&&n.push(i.join(" · "));for(const o of e.days){const c=`${p(o.maxC,o.maxF)} high / ${p(o.minC,o.minF)} low`,a=o.chanceOfRain!==null?`, ${o.chanceOfRain}% rain`:"";n.push(`${o.date}: ${c}${o.condition?`, ${o.condition.toLowerCase()}`:""}${a}`)}return t.observedAt&&n.push(`Observed ${t.observedAt} local. Source: wttr.in`),C(e.query)&&n.push("The place name was ambiguous — TELL THE USER which location this is for, and offer to re-check with a state or country if it is the wrong one."),n.join(`
2
- `)}async function L(e,{fetchJson:r,timeoutMs:n=7e3,host:t=m}={}){let u;try{u=w(e,{host:t})}catch(c){return{ok:!1,reason:c.message}}if(typeof r!="function")return{ok:!1,reason:"no fetch was provided"};let i;try{i=await r(u,{timeoutMs:n})}catch(c){return{ok:!1,reason:c?.message||"the weather service did not answer"}}const o=$(i,{query:e});return o?{ok:!0,weather:o,text:k(o)}:{ok:!1,reason:"the weather service returned nothing usable"}}export{m as WEATHER_HOST,F as WEATHER_TIMEOUT_MS,d as WeatherError,g as areaLabel,k as formatWeather,L as getWeather,C as isAmbiguousLocation,y as isHere,$ as parseWeather,w as weatherUrl};
1
+ const f="https://wttr.in",b=7e3;class g extends Error{constructor(n,t){super(t),this.name="WeatherError",this.code=n}}function C(e,{host:n=f}={}){const t=String(e??"").trim();if(x(t))return`${n}/?format=j1`;if(t.length>120)throw new g("BAD_LOCATION","location is too long to be one");return`${n}/${encodeURIComponent(t)}?format=j1`}const d=/^(?:(?:right )?here|near me|nearby|around (?:here|me)|my (?:location|area|city|town|place)|(?:my )?current location|where i am|local(?:ly)?|outside|(?:right )?now|currently|today|tonight|tomorrow|(?:this|next|the) (?:morning|afternoon|evening|night|week|weekend)|(?:this |next |on )?(?:mon|tues|wednes|thurs|fri|satur|sun)day)$/i;function x(e){const n=String(e??"").trim().replace(/[?.!,]+$/,"").replace(/\s+/g," ");return!n||d.test(n)||n.split(/\s*(?:,|\band\b|\bor\b)\s*/).every(t=>d.test(t))}const s=e=>{const n=Number(e);return Number.isFinite(n)?n:null},l=e=>String(e??"").trim(),h=e=>Array.isArray(e)?l(e[0]?.value):l(e);function k(e,{query:n=""}={}){if(!e||typeof e!="object")return null;const t=Array.isArray(e.current_condition)?e.current_condition[0]:null;if(!t)return null;const r=s(t.temp_C),u=s(t.temp_F);if(r===null&&u===null)return null;const i=Array.isArray(e.nearest_area)?e.nearest_area[0]:null,o=i?{name:h(i.areaName),region:h(i.region),country:h(i.country),lat:s(i.latitude),lon:s(i.longitude)}:null,c=(Array.isArray(e.weather)?e.weather:[]).slice(0,3).map(a=>({date:l(a.date),maxC:s(a.maxtempC),maxF:s(a.maxtempF),minC:s(a.mintempC),minF:s(a.mintempF),sunrise:l(a.astronomy?.[0]?.sunrise),sunset:l(a.astronomy?.[0]?.sunset),condition:h(a.hourly?.[4]?.weatherDesc)||h(a.hourly?.[0]?.weatherDesc),chanceOfRain:s(a.hourly?.[4]?.chanceofrain)}));return{query:l(n),area:o,now:{tempC:r,tempF:u,feelsLikeC:s(t.FeelsLikeC),feelsLikeF:s(t.FeelsLikeF),condition:h(t.weatherDesc),humidity:s(t.humidity),windKph:s(t.windspeedKmph),windMph:s(t.windspeedMiles),windDir:l(t.winddir16Point),precipMm:s(t.precipMM),uv:s(t.uvIndex),observedAt:l(t.localObsDateTime)},days:c}}function E(e,n=""){if(!e)return n;const t=[e.name,e.region,e.country].map(l).filter(Boolean),r=new Set;return t.filter(i=>{const o=i.toLowerCase();return r.has(o)?!1:(r.add(o),!0)}).join(", ")||n}function F(e){const n=l(e);return n?!/[,]/.test(n)&&n.split(/\s+/).length<=2:!1}const A=e=>Math.round(e*9/5+32),m=(e,n)=>{const t=e===null&&n!==null?Math.round((n-32)*5/9):e,r=n===null&&e!==null?A(e):n;return t===null&&r===null?"":t===null?`${r}°F`:r===null?`${t}°C`:`${r}°F / ${t}°C`},L=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function y(e){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));return n?L[new Date(Date.UTC(+n[1],+n[2]-1,+n[3])).getUTCDay()]:""}function T(e){if(!e)return"";const n=E(e.area,e.query),t=[];t.push(`Weather for ${n}${e.query&&n.toLowerCase()!==e.query.toLowerCase()?` (asked: "${e.query}")`:""}`);const r=e.now,u=[`Now: ${m(r.tempC,r.tempF)}`];(r.feelsLikeC!==null||r.feelsLikeF!==null)&&u.push(`feels like ${m(r.feelsLikeC,r.feelsLikeF)}`),r.condition&&u.push(r.condition.toLowerCase()),t.push(u.join(", "));const i=[];if(r.humidity!==null&&i.push(`humidity ${r.humidity}%`),(r.windMph!==null||r.windKph!==null)&&i.push(`wind ${r.windMph!==null?`${r.windMph} mph`:`${r.windKph} km/h`}${r.windDir?` ${r.windDir}`:""}`),r.precipMm!==null&&i.push(`precip ${r.precipMm} mm`),r.uv!==null&&i.push(`UV ${r.uv}`),i.length&&t.push(i.join(" · ")),e.days.forEach((o,c)=>{const a=`${m(o.maxC,o.maxF)} high / ${m(o.minC,o.minF)} low`,w=o.chanceOfRain!==null?`, ${o.chanceOfRain}% rain`:"",p=y(o.date),$=c===0?" (today)":c===1?" (tomorrow)":"";t.push(`${p?`${p} `:""}${o.date}${$}: ${a}${o.condition?`, ${o.condition.toLowerCase()}`:""}${w}`)}),e.days.length){const o=y(e.days[e.days.length-1].date);t.push(`This forecast ends ${o?`on ${o}`:"with these days"} — for a later day, say it is not in this forecast.`)}return r.observedAt&&t.push(`Observed ${r.observedAt} local. Source: wttr.in`),F(e.query)&&t.push("The place name was ambiguous — TELL THE USER which location this is for, and offer to re-check with a state or country if it is the wrong one."),t.join(`
2
+ `)}async function M(e,{fetchJson:n,timeoutMs:t=7e3,host:r=f}={}){let u;try{u=C(e,{host:r})}catch(c){return{ok:!1,reason:c.message}}if(typeof n!="function")return{ok:!1,reason:"no fetch was provided"};let i;try{i=await n(u,{timeoutMs:t})}catch(c){return{ok:!1,reason:c?.message||"the weather service did not answer"}}const o=k(i,{query:e});return o?{ok:!0,weather:o,text:T(o)}:{ok:!1,reason:"the weather service returned nothing usable"}}export{f as WEATHER_HOST,b as WEATHER_TIMEOUT_MS,g as WeatherError,E as areaLabel,T as formatWeather,M as getWeather,F as isAmbiguousLocation,x as isHere,k as parseWeather,C as weatherUrl};