@chatpanel/gateway 0.100.0 → 0.103.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/package.json +3 -3
- package/src/agent.js +1 -3
- package/src/budget.js +1 -1
- package/src/capability-adapters.js +1 -1
- package/src/capability-embedded.js +1 -1
- package/src/capability-endpoints.js +1 -1
- package/src/capability-providers.js +1 -3
- package/src/capability-proxy.js +1 -1
- package/src/capability-tools.js +1 -3
- package/src/cloudevents.js +1 -4
- package/src/cross-encoder.js +1 -1
- package/src/embedded-models.js +1 -1
- package/src/embedder.js +1 -0
- package/src/engine-pacer.js +1 -1
- package/src/engine.js +1 -1
- package/src/event-stats.js +1 -1
- package/src/event-sync.js +1 -1
- package/src/event.js +1 -1
- package/src/extract/handler.js +1 -1
- package/src/extract-capability.js +1 -5
- package/src/extraction.js +1 -4
- package/src/gate.js +1 -1
- package/src/inference-lane.js +1 -0
- package/src/job.js +1 -5
- package/src/kb-store.js +4 -0
- package/src/kb.js +2 -0
- package/src/knowledge.js +1 -3
- package/src/mcp.js +23 -20
- package/src/memory.js +1 -2
- package/src/model-ledger.js +1 -1
- package/src/ner-engine.js +1 -1
- package/src/observability.js +1 -1
- package/src/openai.js +2 -2
- package/src/order.js +1 -1
- package/src/project.js +1 -1
- package/src/providers.js +1 -1
- package/src/read-document.js +1 -10
- package/src/recruit.js +1 -4
- package/src/ref.js +1 -1
- package/src/rrf.js +1 -1
- package/src/scorecard.js +1 -1
- package/src/search-api.js +1 -1
- package/src/search-outcome.js +1 -1
- package/src/search-searxng.js +1 -1
- package/src/serp-anchors.js +1 -1
- package/src/server.js +29 -29
- package/src/site-policy.js +1 -1
- package/src/structured.js +1 -4
- package/src/subject-kinds.js +1 -1
- package/src/subject-name.js +1 -1
- package/src/team-board.js +1 -6
- package/src/team-record.js +1 -1
- package/src/team.js +1 -1
- package/src/version.js +1 -1
- package/src/web-search-tool.js +1 -19
- package/src/web-search.js +1 -1
package/src/site-policy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@chatpanel/events/site-policy.js";
|
package/src/structured.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`)}function A(e){switch(e.type){case"enum":return e.values.map(t=>JSON.stringify(t)).join("|");case"string[]":return"[string, …]";case"number[]":return"[number, …]";case"object[]":return`[{${e.order.map(t=>`${JSON.stringify(t)}: ${A(e.fields[t])}`).join(", ")}}, …]`;case"integer":return"integer";case"number":return"number";case"boolean":return"true|false";default:return"string"}}function U(e,{strict:t=!0}={}){const r={};for(const i of e.order)r[i]=_(e.fields[i]);const n=t?e.order.slice():e.order.filter(i=>e.fields[i].required);return{type:"object",properties:r,required:n,additionalProperties:!1}}function _(e){const t=e.describe?{description:e.describe}:{};switch(e.type){case"enum":return{...t,type:"string",enum:e.values.slice()};case"integer":return{...t,type:"integer"};case"number":return{...t,type:"number"};case"boolean":return{...t,type:"boolean"};case"string[]":return{...t,type:"array",items:{type:"string"}};case"number[]":return{...t,type:"array",items:{type:"number"}};case"object[]":return{...t,type:"array",items:{type:"object",properties:Object.fromEntries(e.order.map(r=>[r,_(e.fields[r])])),required:e.order.slice(),additionalProperties:!1}};default:return{...t,type:"string"}}}function se(e,{mode:t="schema",strict:r=!0}={}){return t==="none"?null:t==="object"?{response_format:{type:"json_object"}}:{response_format:{type:"json_schema",json_schema:{name:e.name.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)||"answer",strict:r,schema:U(e,{strict:r})}}}}const le=Object.freeze(["schema","object","none"]);function v(e){let t=String(e??"").trim();const r=t.match(/```(?:json|jsonc|json5)?\s*\n?([\s\S]*?)(?:```|$)/i);r&&r[1].trim()&&(t=r[1].trim());const n=t.replace(K,"");return n!==t&&/^[[{"]/.test(n)&&(t=n),t.trim()}function F(e){const t=String(e??"");let r=null;for(let n=0;n<t.length;n++){const i=t[n];if(i!=="{"&&i!=="[")continue;const l=W(t,n);if(l.complete)return{text:t.slice(n,l.end),start:n,end:l.end,complete:!0};r||(r={text:t.slice(n),start:n,end:t.length,complete:!1})}return r}function W(e,t){const r=[];let n=!1,i='"';for(let l=t;l<e.length;l++){const s=e[l];if(n){if(s==="\\"){l++;continue}s===i&&(n=!1);continue}if(j.has(s)){n=!0,i=j.get(s);continue}if(s==="{"||s==="["){r.push(s);continue}if((s==="}"||s==="]")&&(r.pop(),!r.length))return{end:l+1,complete:!0,depth:0,inStr:!1}}return{end:e.length,complete:!1,depth:r.length,inStr:n}}const B=new Map([["true","true"],["false","false"],["null","null"],["True","true"],["False","false"],["None","null"],["TRUE","true"],["FALSE","false"],["NULL","null"],["yes","true"],["no","false"],["Yes","true"],["No","false"],["undefined","null"],["NaN","null"],["Infinity","null"]]),j=new Map([['"','"'],["'","'"],["“","”"],["”","”"],["‘","’"],["’","’"]]),D=e=>j.has(e);function z(e,{partial:t=!1}={}){const r=String(e??"");let n="";const i=[],l=new Set;let s=!1,o=null,u=-1,d=-1,f=!1;const g=()=>i[i.length-1]||null,x=()=>{s&&(d=n.length,n+=",",s=!1)},$=()=>{const c=g();c&&c.kind==="{"?(i.length===1&&o&&l.add(o),c.expect="comma"):c&&(c.expect="comma")};for(let c=0;c<r.length;c++){const p=r[c];if(/\s/.test(p)){n&&!/\s$/.test(n)&&(n+=" ");continue}if(p==="/"&&(r[c+1]==="/"||r[c+1]==="*")){if(r[c+1]==="/")for(;c<r.length&&r[c]!==`
|
|
3
|
-
`;)c++;else{const a=r.indexOf("*/",c+2);c=a<0?r.length:a+1}continue}if(p==="{"||p==="["){x(),i.push({kind:p,expect:p==="{"?"key":"value"}),n+=p;continue}if(p==="}"||p==="]"){s=!1;const a=g();if(!a)continue;a.kind==="{"&&(a.expect==="colon"||a.expect==="value"&&n.endsWith(":"))&&O(),i.pop(),n+=a.kind==="{"?"}":"]",$();continue}if(p===":"){n+=":";const a=g();a&&(a.expect="value");continue}if(p===","){s=!0;const a=g();a&&(a.expect=a.kind==="{"?"key":"value");continue}if(D(p)){x();const a=g(),k=!!a&&a.kind==="{"&&a.expect!=="value";k&&(u=n.length);const y=G(r,c,p);if(c=y.end,!y.closed){if(f=!0,!t)return{json:null,complete:!1,settled:l,truncated:!0};if(k){O();break}n+=`${JSON.stringify(y.value)}`,i.length;break}n+=JSON.stringify(y.value),k?(i.length===1&&(o=y.value),a&&(a.expect="colon")):$();continue}const h=H(r,c);if(!h.value)continue;c=h.end,x();const S=g();if(!!S&&S.kind==="{"&&S.expect!=="value"){u=n.length,n+=JSON.stringify(h.value),i.length===1&&(o=h.value),S.expect="colon";continue}const J=B.get(h.value);J?n+=J:/^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/.test(h.value)?n+=h.value:n+=JSON.stringify(h.value),t&&h.end>=r.length-1?f=!0:$()}function O(){u<0||(n=n.slice(0,d>=0&&d>=u-1?d:u),n.endsWith(",")&&(n=n.slice(0,-1)),u=-1,i.length===1&&(o=null))}if(i.length){if(f=!0,!t)return{json:null,complete:!1,settled:l,truncated:!0};const c=g();for(c&&c.kind==="{"&&c.expect==="colon"&&O(),n.trimEnd().endsWith(":")&&(n+="null"),n.trimEnd().endsWith(",")&&(n=n.trimEnd().slice(0,-1));i.length;)n+=i.pop().kind==="{"?"}":"]"}return{json:n.trim(),complete:!f,settled:l,truncated:f}}function G(e,t,r){const n=j.get(r)||'"';let i="";for(let l=t+1;l<e.length;l++){const s=e[l];if(s==="\\"){const o=e[l+1];if(o===void 0)return{value:i,end:e.length,closed:!1};o==="n"?i+=`
|
|
4
|
-
`:o==="t"?i+=" ":o==="r"?i+="\r":o==="u"&&/^[0-9a-fA-F]{4}$/.test(e.slice(l+2,l+6))?(i+=String.fromCharCode(parseInt(e.slice(l+2,l+6),16)),l+=4):i+=o,l++;continue}if(s===n)return{value:i,end:l,closed:!0};i+=s}return{value:i,end:e.length,closed:!1}}function H(e,t){let r=t;for(;r<e.length&&!/[\s,:{}[\]"']/.test(e[r]);)r++;return{value:e.slice(t,r),end:r-1}}function oe(e,{partial:t=!1}={}){const r=F(v(e));return r?z(r.text,{partial:t}).json:null}function C(e,t,{partial:r=!1}={}){const n=String(e??"").trim();if(!n)return null;const i=v(n);if(E.test(i)||t.nothingIf?.test(i))return N(t);const l=F(i);let s=null,o=!1,u=new Set;if(l){const f=z(l.text,{partial:r});if(o=f.complete&&l.complete,u=f.settled,f.json)try{s=JSON.parse(f.json)}catch{s=null}}if(s==null){const f=V(i,t);if(f){const g=R(f,t,{partial:r});if(g===w)return N(t);if(g)return{value:g,complete:!0,settled:t.order.slice(),source:"fallback"}}return null}if(Array.isArray(s)){const f=q(t);if(!f)return null;s={[f]:s}}if(!b(s))return null;const d=R(s,t,{partial:r});return d===w?N(t):d==null?null:{value:d,complete:o,settled:[...u].filter(f=>t.order.includes(f)),source:"json"}}const w=Symbol("nothing");function N(e){return e.nothing==null?null:{value:e.nothing,complete:!0,settled:e.order.slice(),source:"nothing"}}function ue(e,t,r){return C(e,t,r)?.value??null}function V(e,t){if(typeof t.fallback=="function")try{const s=t.fallback(e);return b(s)?s:null}catch{return null}if(t.fallback!=="lines")return null;const r=q(t);if(!r)return null;const n=e.split(/\r?\n/).map(s=>s.trim()).filter(Boolean),i=n.filter(s=>/^(?:[-*+•]|\d+[.)])\s+/.test(s));if(!i.length&&n.length<2)return null;const l=(i.length?i:n).map(s=>s.replace(/^(?:[-*+•]|\d+[.)])\s*/,"").replace(/^["'`]|["'`]$/g,"").trim()).filter(Boolean);return l.length?{[r]:l}:null}function R(e,t,{partial:r}){const n={};let i=!1,l=!1,s=!1;for(const o of t.order){const u=t.fields[o],d=Q(e,o),f=M(d,u);if(f===void 0){u.required&&(i=!0),u.default!==void 0?n[o]=u.default:r||(n[o]=Z(u));continue}s=!0,n[o]=f,u.required&&Y(f)&&(l=!0)}return s?r?n:l?w:i&&t.strictRequired?null:n:null}const Y=e=>e===""||e===null||Array.isArray(e)&&e.length===0;function Q(e,t){if(t in e)return e[t];const r=t.toLowerCase().replace(/[^a-z0-9]/g,"");for(const n of Object.keys(e))if(n.toLowerCase().replace(/[^a-z0-9]/g,"")===r)return e[n]}function Z(e){return I(e.type)?[]:e.type==="boolean"?!1:e.type==="number"||e.type==="integer"?null:e.type==="enum"?e.default??e.values[0]:""}function M(e,t){if(e!=null)switch(t.type){case"string":{const r=T(e,t);return r===void 0?void 0:r}case"enum":{const r=String(typeof e=="string"?e:e?.value??e).trim().toLowerCase().replace(/[.!]+$/,""),n=t.aliasMap.get(r)??t.aliasMap.get(r.replace(/^(?:a|an|the)\s+/,""));return n||(t.default!==void 0?t.default:void 0)}case"number":case"integer":{const r=typeof e=="number"?e:Number(String(e).replace(/[^0-9.eE+-]/g,""));if(!Number.isFinite(r))return;const n=t.type==="integer"?Math.round(r):r;return t.min!=null&&n<t.min?t.min:t.max!=null&&n>t.max?t.max:n}case"boolean":{if(typeof e=="boolean")return e;const r=String(e).trim().toLowerCase();return/^(?:true|yes|y|1)$/.test(r)?!0:/^(?:false|no|n|0)$/.test(r)?!1:void 0}case"string[]":case"number[]":case"object[]":{const r=Array.isArray(e)?e:e===""?[]:[e],n=t.type==="string[]"?s=>T(s,{max:t.itemMax,emptyIf:t.itemEmptyIf}):t.type==="number[]"?s=>M(s,{type:"number",min:t.min,max:t.max}):s=>b(s)?R(s,{order:t.order,fields:t.fields,strictRequired:!0},{partial:!1}):void 0,i=[],l=new Set;for(const s of r){const o=n(s);if(!(o==null||o===""||o===w)){if(t.dedupe!==!1){const u=typeof o=="object"?JSON.stringify(o):String(o).toLowerCase();if(l.has(u))continue;l.add(u)}if(i.push(o),t.maxItems&&i.length>=t.maxItems)break}}return i}default:return}}function T(e,t={}){if(e==null)return;let n=(typeof e=="string"?e:b(e)?String(e.value??e.text??e.name??""):String(e)).replace(/\s+/g," ").trim();if(t.emptyIf&&t.emptyIf.test(n)||E.test(n))return"";if(n=n.replace(/^["'`]+|["'`]+$/g,"").trim(),t.max&&n.length>t.max){const i=n.slice(0,t.max);n=/\s/.test(i)?i.replace(/\s+\S*$/,""):i}return n}function ce(e){return E.test(String(e??"").trim())}const X=/[{}[\]",:]/,ee=12;function fe(e,{onChange:t=null}={}){let r="",n=0,i=null,l="";const s=o=>{const u=C(r,e,{partial:o});if(u){i=u;const d=JSON.stringify(u.value);d!==l&&(l=d,t?.(u.value,u.settled))}return n=0,i};return{push(o){const u=String(o??"");return u&&(r+=u,n+=u.length),u&&(X.test(u)||n>=ee)&&s(!0),this.snapshot()},end(){return s(!1),i||s(!0),this.snapshot()},snapshot(){return{value:i?.value??null,settled:i?.settled??[],complete:!!i?.complete,source:i?.source??null,text:r}},reset(){r="",n=0,i=null,l=""},get text(){return r}}}export{P as FIELD_TYPES,le as RESPONSE_MODES,m as StructuredError,C as coerce,fe as createStructuredStream,re as defineSchema,ie as describeSchema,F as findJson,ce as isNothing,ue as parseStructured,oe as repairJson,se as responseFormat,z as rewriteJson,U as toJsonSchema,v as unfence};
|
|
1
|
+
export*from"@chatpanel/events/structured.js";
|
package/src/subject-kinds.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@chatpanel/events/subject-kinds.js";
|
package/src/subject-name.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@chatpanel/events/subject-name.js";
|
package/src/team-board.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
${F(B)}`}function Y(d,{role:i,taskId:n}={}){const f=String(d||"").trim();if(!f)return[];const t=q(f,B),o=Array.isArray(t?.value?.findings)?t.value.findings.filter(u=>u&&String(u.text||"").trim()):[],a=(u,c)=>({id:`${n||"t"}:${c+1}`,kind:N.includes(u.kind)?u.kind:"claim",text:String(u.text).trim().slice(0,2e3),refs:Array.isArray(u.refs)?u.refs.map(String).filter(Boolean).slice(0,8):[],confidence:Number.isFinite(Number(u.confidence))&&Number(u.confidence)>0?Math.min(1,Number(u.confidence)):null,role:i||null,taskId:n||null});if(o.length)return o.slice(0,E).map(a);const m=f.replace(/```json[\s\S]*$/i,"").trim()||f;return[a({kind:"draft",text:m.slice(0,2e3),refs:[]},0)]}const P=Object.freeze(["task","ask","discussion","proposal"]),D=Object.freeze(["open","waiting","resolved","failed","approved","rejected"]),K=Object.freeze(["finding","note","question","answer","draft","decision","request"]),X=Object.freeze(["open","proposed","approved","rejected"]),L=Object.freeze(["info","budget","permission","direction"]),v="runner",x="person",U=4e3,j=(d,i)=>String(d||"").trim().slice(0,i),G=d=>Array.isArray(d)?d.map(String).filter(Boolean).slice(0,8):[];function O(){return{threads:[],posts:[]}}function J(d,i){const n=d&&Array.isArray(d.threads)&&Array.isArray(d.posts)?d:O(),f=String(i?.type||""),t=i?.payload&&typeof i.payload=="object"?i.payload:i||{};if(f==="board.thread"&&t.thread?.id)n.threads.some(o=>o.id===t.thread.id)||n.threads.push({...t.thread});else if(f==="board.post"&&t.post?.id){if(Array.isArray(n.removed)&&n.removed.includes(t.post.threadId))return n;n.posts.some(a=>a.id===t.post.id)||n.posts.push({...t.post});const o=n.threads.find(a=>a.id===t.post.threadId);o&&(o.lastAt=t.post.at,o.lastBy=t.post.by,o.posts=(o.posts||0)+1)}else if(f==="board.decision"&&t.postId){const o=n.posts.find(a=>a.id===t.postId);o&&(o.status=t.status,o.decidedBy=t.by,o.decidedAt=t.at??i?.at)}else if(f==="board.thread-status"&&t.threadId){const o=n.threads.find(a=>a.id===t.threadId);o&&(o.status=t.status,t.status!=="waiting"&&(o.waitingOn=null),t.holder&&(o.holder=t.holder))}else f==="board.thread-removed"&&t.threadId&&(n.threads=n.threads.filter(o=>o.id!==t.threadId),n.posts=n.posts.filter(o=>o.threadId!==t.threadId),Array.isArray(n.removed)||(n.removed=[]),n.removed.includes(t.threadId)||n.removed.push(t.threadId));return n}function Q({now:d=()=>Date.now(),newId:i=null,state:n=null,onEvent:f=null}={}){const t=n&&Array.isArray(n.threads)?{threads:n.threads.map(e=>({...e})),posts:(n.posts||[]).map(e=>({...e})),...Array.isArray(n.removed)&&n.removed.length?{removed:[...n.removed]}:{}}:O(),o=new Set;let a=t.posts.length+t.threads.length;const m=e=>i?i(e):`${e}_${(++a).toString(36)}${Math.random().toString(36).slice(2,6)}`,u=(e,r)=>{const l={type:e,at:d(),...r};return f&&f(e,l),l},c=e=>t.threads.find(r=>r.id===e),p=e=>t.posts.find(r=>r.id===e),w=e=>t.threads.find(r=>r.kind==="task"&&r.taskId===e),h={openThread({id:e=null,taskId:r=null,kind:l="discussion",title:s="",by:y=v,status:g="open",ask:S=null,parent:b=null,holder:k=null}={}){if(l==="task"&&r){const $=w(r);if($)return $}const A={id:e||m("th"),kind:P.includes(l)?l:"discussion",taskId:r,title:j(s,200),by:y,status:D.includes(g)?g:"open",at:d(),posts:0,...S?{ask:S}:{},...b?{parent:b}:{},...k?{holder:k}:{}};return t.threads.push(A),u("board.thread",{thread:{...A}}),A},post({id:e=null,threadId:r,by:l,kind:s="note",text:y="",refs:g=[],replyTo:S=null,status:b="open",finding:k=null,ask:A=null,proposal:$=null}={}){const I=c(r);if(!I)throw new Error(`no thread ${r}`);if(e&&p(e))return p(e);const T={id:e||m("p"),threadId:r,by:String(l||v),kind:K.includes(s)?s:"note",text:j(y,U),refs:G(g),replyTo:S,status:X.includes(b)?b:"open",at:d(),...k?{finding:k}:{},...A?{ask:A}:{},...$&&typeof $=="object"?{proposal:$}:{}};t.posts.push(T),I.lastAt=T.at,I.lastBy=T.by,I.posts=(I.posts||0)+1,u("board.post",{post:{...T}});for(const z of o)z(T);return T},reply({postId:e,...r}){const l=p(e||r.replyTo);if(!l)throw new Error(`no post ${e}`);return h.post({...r,threadId:l.threadId,replyTo:l.id})},decide(e,r,l=x){const s=p(e);return!s||!["approved","rejected","proposed","open"].includes(r)?null:(s.status=r,s.decidedBy=l,s.decidedAt=d(),u("board.decision",{postId:e,status:r,by:l,at:s.decidedAt}),s)},setThreadStatus(e,r,l={}){const s=c(e);return!s||!D.includes(r)?null:(s.status=r,r!=="waiting"&&(s.waitingOn=null),Object.assign(s,l),u("board.thread-status",{threadId:e,status:r,...l}),s)},removeThread(e,{by:r=x}={}){const l=c(e);return!l||l.kind==="ask"&&l.status==="waiting"?null:(t.threads=t.threads.filter(s=>s.id!==e),t.posts=t.posts.filter(s=>s.threadId!==e),(t.removed||=[]).push(e),u("board.thread-removed",{threadId:e,by:r}),l)},ask({taskId:e=null,by:r,type:l="info",text:s,options:y=[],timeoutMs:g=0,title:S=""}={}){const b={type:L.includes(l)?l:"info",options:(Array.isArray(y)?y:[]).map(String).slice(0,6),timeoutMs:g},k=h.openThread({taskId:e,kind:"ask",title:S||j(s,120),by:r,status:"waiting",ask:b});k.waitingOn=x;const A=h.post({threadId:k.id,by:r,kind:"question",text:s,ask:b});return{thread:k,post:A}},answer(e,{id:r=null,text:l,by:s=x}={}){if(!c(e))return null;const g=h.post({id:r,threadId:e,by:s,kind:"answer",text:l});return h.setThreadStatus(e,"resolved",{answeredAt:g.at}),g},thread:c,threadForTask:w,threads:()=>t.threads.map(e=>({...e})),posts:(e=null)=>t.posts.filter(r=>!e||r.threadId===e).map(r=>({...r})),postById:p,waiting:()=>t.threads.filter(e=>e.kind==="ask"&&e.status==="waiting").map(e=>({...e})),state:()=>({threads:t.threads.map(e=>({...e})),posts:t.posts.map(e=>({...e})),...t.removed?.length?{removed:[...t.removed]}:{}}),add(e,{by:r=null}={}){let l=0;for(const s of Array.isArray(e)?e:[e]){if(!s||!s.text)continue;const y=s.taskId?w(s.taskId)||h.openThread({taskId:s.taskId,kind:"task",title:s.taskId}):t.threads.find(g=>g.kind==="discussion"&&g.title==="findings")||h.openThread({kind:"discussion",title:"findings"});h.post({id:s.id,threadId:y.id,by:r||s.role||v,kind:"finding",text:s.text,refs:s.refs,finding:{kind:s.kind||"claim",confidence:s.confidence??null}}),l+=1}return l},all:()=>t.posts.filter(e=>e.kind==="finding").map(_(t)),byTask:e=>h.all().filter(r=>r.taskId===e),byRole:e=>h.all().filter(r=>r.role===e),onFinding(e){const r=l=>{l.kind==="finding"&&e(_(t)(l))};return o.add(r),()=>o.delete(r)},get size(){return t.posts.filter(e=>e.kind==="finding").length}};return h}function _(d){return i=>{const n=d.threads.find(f=>f.id===i.threadId);return{id:i.id,kind:i.finding?.kind||"claim",text:i.text,refs:i.refs||[],confidence:i.finding?.confidence??null,role:i.by,taskId:n?.taskId||null,at:i.at,status:i.status,...i.finding?.prior?{prior:!0}:{}}}}function Z(d){const i=d&&Array.isArray(d.posts)?d:O();return i.posts.filter(n=>n.kind==="finding").map(_(i))}function ee(d,{taskIds:i=null,max:n=M,role:f=null}={}){const t=d&&typeof d.state=="function"?d.state():d&&Array.isArray(d.posts)?d:null,o=t?C(t,{taskIds:i,role:f}):H(d,i);if(!o.length)return"";const a=t?"The board so far":"Findings so far",m=o.join(`
|
|
3
|
-
`);if(m.length<=n)return`${a}:
|
|
4
|
-
${m}`;const u=[];let c=0;for(let p=o.length-1;p>=0&&!(c+o[p].length+1>n);p-=1)u.unshift(o[p]),c+=o[p].length+1;return`${a} (${o.length-u.length} earlier lines omitted for length):
|
|
5
|
-
${u.join(`
|
|
6
|
-
`)}`}function H(d,i){return(d||[]).filter(n=>!i||i.includes(n.taskId)).map(n=>`- [${n.kind}${n.role?` · ${n.role}`:""}${n.confidence!=null?` · ${Math.round(n.confidence*100)}%`:""}] ${n.text}${n.refs?.length?` (refs: ${n.refs.join(", ")})`:""}`)}function C(d,{taskIds:i,role:n}){const f=[],t=d.posts,o=d.threads.filter(a=>a.kind==="task"?!i||i.includes(a.taskId):a.kind==="ask"?a.status==="resolved"&&(!n||a.by===n||a.by===v):a.kind==="discussion");for(const a of o){const m=t.filter(c=>c.threadId===a.id&&c.status!=="rejected");if(!m.length)continue;f.push(`## ${a.kind}${a.by&&a.by!==v?` by ${a.by}`:""}: ${a.title}${a.holder?` (held by ${a.holder})`:""}${a.status==="resolved"&&a.kind==="ask"?" (answered)":""}`);const u=(c,p)=>{const w=[c.kind==="finding"?c.finding?.kind||"claim":c.kind,c.by,c.finding?.confidence!=null?`${Math.round(c.finding.confidence*100)}%`:null,c.status==="approved"?"APPROVED":c.status==="proposed"?"proposed":null,c.kind==="decision"||c.by===x?"SETTLED":null].filter(Boolean).join(" · ");f.push(`${" ".repeat(p)}- [${w}] ${c.text}${c.refs?.length?` (refs: ${c.refs.join(", ")})`:""}`);for(const h of m.filter(e=>e.replyTo===c.id))u(h,p+1)};for(const c of m.filter(p=>!p.replyTo))u(c,0)}return f}function te(d){return(d||[]).filter(i=>i.kind==="claim"&&i.text).map(i=>({text:i.text,refs:(i.refs||[]).map(n=>{const f=/^([a-z][a-z0-9_-]*):(?!\/\/)(.+)$/.exec(String(n));return f?{kind:f[1],id:f[2]}:{kind:"url",id:String(n)}}),by:i.role||"team",confidence:i.confidence}))}export{L as ASK_TYPES,M as BOARD_TEXT_MAX,B as FINDINGS_SCHEMA,N as FINDING_KINDS,E as MAX_FINDINGS_PER_TASK,U as MAX_POST_TEXT,x as PERSON,K as POST_KINDS,X as POST_STATUSES,v as RUNNER,P as THREAD_KINDS,D as THREAD_STATUSES,ee as boardText,Q as createBoard,O as emptyBoardState,W as findingsInstruction,Z as findingsOf,J as foldBoard,Y as parseFindings,te as toBriefClaims};
|
|
1
|
+
export*from"@chatpanel/events/team-board.js";
|
package/src/team-record.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@chatpanel/events/team-record.js";
|
package/src/team.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@chatpanel/events/team.js";
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.
|
|
1
|
+
const o="0.103.0";export{o as VERSION};
|
package/src/web-search-tool.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`),a=e.results[0].url,t=`Web search results for "${e.query}" (engines: ${i.join(", ")}).
|
|
3
|
-
|
|
4
|
-
Citation rules: when a claim draws on a result below, cite it inline as a markdown link to that result's URL — e.g. ([1](${a})). Cite multiple sources as separate links: ([1](url)) ([3](url)). Do NOT output HTML, <sup>, or bare bracket numbers like [1] — every citation must be a clickable markdown link. Finish with a "Sources" section that repeats, as markdown links, each source you cited.
|
|
5
|
-
|
|
6
|
-
Sources:
|
|
7
|
-
${u}`,o=e.results.map(n=>`### [${n.rank}] ${n.title}
|
|
8
|
-
<${n.url}>
|
|
9
|
-
|
|
10
|
-
${n.text}`).join(`
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
`);return`${t}
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
Result details:
|
|
18
|
-
|
|
19
|
-
${o}`}function m({search:e}={}){if(typeof e!="function")throw new Error("webSearchToolProvider: search required");return{specs:[g],system:y,async execute(i,u){if(i!==c)return JSON.stringify({error:`Unknown tool: ${i}`});const a=String(u?.query||"").trim();if(!a)return"No query provided to web_search.";try{const t=await e(a),o=[...new Set((t?.results||[]).map(s=>s.engine).filter(Boolean))].map(s=>h(s)),n=(o.length?o:t?.engines||[]).join(", "),r=!t?.results?.length&&Array.isArray(t?.asked)?d[l(t).status]:"";return{text:p(t),note:r?`ChatPanel · ${r}`:n?`ChatPanel · ${n}`:"ChatPanel"}}catch(t){return`web_search failed: ${t?.message||t}`}}}}export{g as WEB_SEARCH_SPEC,c as WEB_SEARCH_TOOL_NAME,y as WEB_SEARCH_TOOL_SYSTEM,p as searchResultsToText,m as webSearchToolProvider};
|
|
1
|
+
export*from"@chatpanel/events/web-search-tool.js";
|
package/src/web-search.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@chatpanel/events/web-search.js";
|