@yeaft/webchat-agent 1.0.546 → 1.0.547
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.547"}
|
|
@@ -740,7 +740,7 @@ ${String(e||"").trim()}
|
|
|
740
740
|
</button>
|
|
741
741
|
</div>
|
|
742
742
|
<pre><code${s}${o}>${n}</code></pre>
|
|
743
|
-
</div>`})}function ek(e){return e.replace(/<table>([\s\S]*?)<\/table>/g,t=>`<div class="table-scroll-wrapper">${t}</div>`)}function tk(){if(typeof mermaid>"u")return!1;let e=document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default";if(ff===e)return!0;try{return mermaid.initialize({startOnLoad:!1,theme:e,securityLevel:"strict"}),ff=e,!0}catch{return!1}}async function Wt(e){if(!e||!tk())return;let t=e.querySelectorAll("pre code.language-mermaid:not([data-mermaid-error])");for(let s of t){let n=s.closest("pre");if(!n||n.dataset.mermaidRendered==="true")continue;let r=n.closest(".code-block-wrapper"),i=zw(s)||s.textContent||"";if(i.trim()){n.dataset.mermaidRendered="true";try{let o=`mermaid-${Date.now()}-${jw++}`,{svg:a}=await mermaid.render(o,i),l=document.createElement("div");l.className="mermaid-rendered",l.innerHTML=a,l.dataset.mermaidSource=i,l.appendChild(Zw(l,i)),(r||n).replaceWith(l)}catch{n.dataset.mermaidRendered="false",s.dataset.mermaidError="true"}}}}function sk(e){if(!e||typeof e!="string")return"";let t=s=>{let n=document.createElement("div");return n.textContent=s,n.innerHTML};return e.replace(/```(\w*)\n([\s\S]*?)```/g,(s,n,r)=>{let i=r.trim(),o=n==="mermaid"?` data-mermaid-source="${encodeURIComponent(i)}"`:"";return`<div class="code-block-wrapper"><pre><code class="language-${n}"${o}>${t(i)}</code></pre></div>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\n/g,"<br>")}function nk(e){if(!e||typeof e!="string")return"";let t=e;return t=t.replace(/---\s*ROUTE\s*---[\s\S]*?---\s*(?:END[_ \-]?ROUTE|ENDROUTE|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?---\s*(?:END[_ \-]?TASKS|ENDTASKS|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*ROUTE\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*ROUTE)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*TASKS)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t}function bf(e){if(!e||typeof e!="string"||(e=nk(e),!e))return"";let t=ci.get(e);if(t!==void 0)return t;Sc();let s;if(typeof marked<"u")try{s=ek(Jw(marked.parse(e)))}catch{}if(s||(s=sk(e)),ci.size>=rk){let n=ci.keys().next().value;ci.delete(n)}return ci.set(e,s),s}var gf,ff,jw,ci,rk,di=B(()=>{ss();pf();gf=!1,ff=null,jw=0;ci=new Map,rk=2e3});function Es(e,{htmlEncoded:t=!0}={}){if(typeof e!="string")return null;let s=t?or(e.trim()):e.trim();if(!s||s.startsWith("#")||s.startsWith("//"))return null;if(/^file:\/\//i.test(s))try{let i=new URL(s);s=(i.pathname||"")+i.hash,i.hostname&&i.hostname!=="localhost"?s=`//${i.hostname}${s}`:/^\/[A-Za-z]:\//.test(s)&&(s=s.slice(1))}catch{return null}try{s=decodeURIComponent(s)}catch{}if(ok.test(s)||/[\u0000-\u001f\u007f]/.test(s))return null;let n=null,r=s.match(ak);if(r)n=Number(r[1]),s=s.slice(0,r.index);else{let i=s.match(lk);i&&(n=Number(i[1]),s=s.slice(0,i.index))}return ik.test(s)&&!wf.test(s)||(s=s.split(/[?#]/,1)[0]?.trim()||"",!s||s.endsWith("/")||!gk(s))?null:{path:s,line:Number.isFinite(n)&&n>0?n:null}}function or(e){if(!e.includes("&"))return e;if(typeof document<"u"){let t=document.createElement("textarea");return t.innerHTML=e.replace(/</g,"<"),t.value}return e.replace(/&(?:amp|lt|gt|quot|apos|nbsp|copy|#\d+|#x[\da-f]+);/gi,t=>{let s={"&":"&","<":"<",">":">",""":'"',"'":"'"," ":"\xA0","©":"\xA9"};if(s[t.toLowerCase()])return s[t.toLowerCase()];let n=t[2]?.toLowerCase()==="x",r=Number.parseInt(t.slice(n?3:2,-1),n?16:10);return r>0&&r<=1114111?String.fromCodePoint(r):t})}function fk(e,t){let s=or(e||"");for(let n of s.matchAll(kf)){let r=If(n[0]),i=Es(r,{htmlEncoded:!1});i&&t.add(i.path)}}function ui(e,t=""){if(typeof e!="string")return null;let s=or(e.trim());if(!s||/^\/\//.test(s)||/^\/(?:api|assets)(?:\/|$)/i.test(s))return null;if(s.startsWith("/")&&!/^file:\/\//i.test(s)){let r=s.split(/[?#]/,1)[0].replaceAll("\\","/"),i=String(t||"").replaceAll("\\","/").replace(/\/+$/,"");if(!i||r!==i&&!r.startsWith(`${i}/`))return null}let n=Es(s,{htmlEncoded:!1});return n&&uk.test(n.path)?n:null}function Ic(e,t=""){if(typeof e!="string"||!e)return[];let s=new Set;for(let n of e.matchAll(/<img\b[^>]*?src=(['"])(.*?)\1[^>]*>/gi)){let r=ui(n[2],t);r&&s.add(r.path)}return[...s]}function Cf(e,t=""){if(typeof e!="string"||!e)return[];let s=new Set;e.replace(Sf,(n,r,i,o)=>{if(r){if(/^<pre\b/i.test(r))return"";let a=r.match(/^<a\s+[^>]*?href=(['"])(.*?)\1/i);if(a){let d=Es(a[2]);return d&&s.add(d.path),""}let l=r.replace(/^<code\b[^>]*>|<\/code>$/gi,""),c=Es(l);return c&&s.add(c.path),""}return i||fk(o,s),""});for(let n of Ic(e,t))s.add(n);return[...s]}function hk(e,t){let s=or(e),n="",r=0;for(let i of s.matchAll(kf)){let o=If(i[0]),a=Es(o,{htmlEncoded:!1}),l=a&&t.get(a.path);if(!a||!l)continue;let c=i.index+i[0].indexOf(o);n+=jt(s.slice(r,c)),n+=`<a href="${jt(o)}" data-resolved-file-path="${jt(l)}" class="message-file-reference">${jt(o)}</a>`,r=c+o.length}return r?n+jt(s.slice(r)):e}function Af(e,t={},s={},n=""){if(typeof e!="string"||!e)return e||"";let r=t instanceof Map?t:new Map(Object.entries(t||{})),i=s instanceof Map?s:new Map(Object.entries(s||{}));return e.replace(/<img\b([^>]*?)src=(['"])(.*?)\2([^>]*)>/gi,(c,d,u,g,p)=>{let f=ui(g,n);if(!f)return c;let m=i.get(f.path);return m?`<img${d}src="${jt(m)}"${p} data-local-image-path="${jt(f.path)}">`:`<span class="message-local-image-pending" data-local-image-path="${jt(f.path)}"></span>`}).replace(/<a\s+([^>]*?href=(['"])(.*?)\2[^>]*)>([\s\S]*?)<\/a>/gi,(c,d,u,g,p)=>{let f=Es(g);if(!f)return c;let m=r.get(f.path);return
|
|
743
|
+
</div>`})}function ek(e){return e.replace(/<table>([\s\S]*?)<\/table>/g,t=>`<div class="table-scroll-wrapper">${t}</div>`)}function tk(){if(typeof mermaid>"u")return!1;let e=document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default";if(ff===e)return!0;try{return mermaid.initialize({startOnLoad:!1,theme:e,securityLevel:"strict"}),ff=e,!0}catch{return!1}}async function Wt(e){if(!e||!tk())return;let t=e.querySelectorAll("pre code.language-mermaid:not([data-mermaid-error])");for(let s of t){let n=s.closest("pre");if(!n||n.dataset.mermaidRendered==="true")continue;let r=n.closest(".code-block-wrapper"),i=zw(s)||s.textContent||"";if(i.trim()){n.dataset.mermaidRendered="true";try{let o=`mermaid-${Date.now()}-${jw++}`,{svg:a}=await mermaid.render(o,i),l=document.createElement("div");l.className="mermaid-rendered",l.innerHTML=a,l.dataset.mermaidSource=i,l.appendChild(Zw(l,i)),(r||n).replaceWith(l)}catch{n.dataset.mermaidRendered="false",s.dataset.mermaidError="true"}}}}function sk(e){if(!e||typeof e!="string")return"";let t=s=>{let n=document.createElement("div");return n.textContent=s,n.innerHTML};return e.replace(/```(\w*)\n([\s\S]*?)```/g,(s,n,r)=>{let i=r.trim(),o=n==="mermaid"?` data-mermaid-source="${encodeURIComponent(i)}"`:"";return`<div class="code-block-wrapper"><pre><code class="language-${n}"${o}>${t(i)}</code></pre></div>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\n/g,"<br>")}function nk(e){if(!e||typeof e!="string")return"";let t=e;return t=t.replace(/---\s*ROUTE\s*---[\s\S]*?---\s*(?:END[_ \-]?ROUTE|ENDROUTE|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?---\s*(?:END[_ \-]?TASKS|ENDTASKS|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*ROUTE\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*ROUTE)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*TASKS)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t}function bf(e){if(!e||typeof e!="string"||(e=nk(e),!e))return"";let t=ci.get(e);if(t!==void 0)return t;Sc();let s;if(typeof marked<"u")try{s=ek(Jw(marked.parse(e)))}catch{}if(s||(s=sk(e)),ci.size>=rk){let n=ci.keys().next().value;ci.delete(n)}return ci.set(e,s),s}var gf,ff,jw,ci,rk,di=B(()=>{ss();pf();gf=!1,ff=null,jw=0;ci=new Map,rk=2e3});function Es(e,{htmlEncoded:t=!0}={}){if(typeof e!="string")return null;let s=t?or(e.trim()):e.trim();if(!s||s.startsWith("#")||s.startsWith("//"))return null;if(/^file:\/\//i.test(s))try{let i=new URL(s);s=(i.pathname||"")+i.hash,i.hostname&&i.hostname!=="localhost"?s=`//${i.hostname}${s}`:/^\/[A-Za-z]:\//.test(s)&&(s=s.slice(1))}catch{return null}try{s=decodeURIComponent(s)}catch{}if(ok.test(s)||/[\u0000-\u001f\u007f]/.test(s))return null;let n=null,r=s.match(ak);if(r)n=Number(r[1]),s=s.slice(0,r.index);else{let i=s.match(lk);i&&(n=Number(i[1]),s=s.slice(0,i.index))}return ik.test(s)&&!wf.test(s)||(s=s.split(/[?#]/,1)[0]?.trim()||"",!s||s.endsWith("/")||!gk(s))?null:{path:s,line:Number.isFinite(n)&&n>0?n:null}}function or(e){if(!e.includes("&"))return e;if(typeof document<"u"){let t=document.createElement("textarea");return t.innerHTML=e.replace(/</g,"<"),t.value}return e.replace(/&(?:amp|lt|gt|quot|apos|nbsp|copy|#\d+|#x[\da-f]+);/gi,t=>{let s={"&":"&","<":"<",">":">",""":'"',"'":"'"," ":"\xA0","©":"\xA9"};if(s[t.toLowerCase()])return s[t.toLowerCase()];let n=t[2]?.toLowerCase()==="x",r=Number.parseInt(t.slice(n?3:2,-1),n?16:10);return r>0&&r<=1114111?String.fromCodePoint(r):t})}function fk(e,t){let s=or(e||"");for(let n of s.matchAll(kf)){let r=If(n[0]),i=Es(r,{htmlEncoded:!1});i&&t.add(i.path)}}function ui(e,t=""){if(typeof e!="string")return null;let s=or(e.trim());if(!s||/^\/\//.test(s)||/^\/(?:api|assets)(?:\/|$)/i.test(s))return null;if(s.startsWith("/")&&!/^file:\/\//i.test(s)){let r=s.split(/[?#]/,1)[0].replaceAll("\\","/"),i=String(t||"").replaceAll("\\","/").replace(/\/+$/,"");if(!i||r!==i&&!r.startsWith(`${i}/`))return null}let n=Es(s,{htmlEncoded:!1});return n&&uk.test(n.path)?n:null}function Ic(e,t=""){if(typeof e!="string"||!e)return[];let s=new Set;for(let n of e.matchAll(/<img\b[^>]*?src=(['"])(.*?)\1[^>]*>/gi)){let r=ui(n[2],t);r&&s.add(r.path)}return[...s]}function Cf(e,t=""){if(typeof e!="string"||!e)return[];let s=new Set;e.replace(Sf,(n,r,i,o)=>{if(r){if(/^<pre\b/i.test(r))return"";let a=r.match(/^<a\s+[^>]*?href=(['"])(.*?)\1/i);if(a){let d=Es(a[2]);return d&&s.add(d.path),""}let l=r.replace(/^<code\b[^>]*>|<\/code>$/gi,""),c=Es(l);return c&&s.add(c.path),""}return i||fk(o,s),""});for(let n of Ic(e,t))s.add(n);return[...s]}function hk(e,t){let s=or(e),n="",r=0;for(let i of s.matchAll(kf)){let o=If(i[0]),a=Es(o,{htmlEncoded:!1}),l=a&&t.get(a.path);if(!a||!l)continue;let c=i.index+i[0].indexOf(o);n+=jt(s.slice(r,c)),n+=`<a href="${jt(o)}" data-resolved-file-path="${jt(l)}" class="message-file-reference">${jt(o)}</a>`,r=c+o.length}return r?n+jt(s.slice(r)):e}function Af(e,t={},s={},n=""){if(typeof e!="string"||!e)return e||"";let r=t instanceof Map?t:new Map(Object.entries(t||{})),i=s instanceof Map?s:new Map(Object.entries(s||{}));return e.replace(/<img\b([^>]*?)src=(['"])(.*?)\2([^>]*)>/gi,(c,d,u,g,p)=>{let f=ui(g,n);if(!f)return c;let m=i.get(f.path);return m?`<img${d}src="${jt(m)}"${p} data-local-image-path="${jt(f.path)}">`:`<span class="message-local-image-pending" data-local-image-path="${jt(f.path)}"></span>`}).replace(/<a\s+([^>]*?href=(['"])(.*?)\2[^>]*)>([\s\S]*?)<\/a>/gi,(c,d,u,g,p)=>{let f=Es(g);if(!f)return c;let m=r.get(f.path)||f.path;return`<a href="${jt(or(g))}" data-resolved-file-path="${jt(m)}" class="message-file-reference">${p}</a>`}).replace(/(<pre\b[^>]*>[\s\S]*?<\/pre>|<a\b[^>]*>[\s\S]*?<\/a>)|<code>([^<]+)<\/code>/gi,(c,d,u)=>{if(d||!u)return c;let g=or(u),p=Es(g,{htmlEncoded:!1});if(!p)return c;let f=r.get(p.path)||p.path;return`<a href="${jt(g)}" data-resolved-file-path="${jt(f)}" class="message-file-reference"><code>${u}</code></a>`}).replace(Sf,(c,d,u,g)=>d||u?c:hk(g,r))}var wf,ik,ok,ak,lk,ck,dk,uk,pk,kf,Sf,gk,jt,If,xf=B(()=>{wf=/^[A-Za-z]:[\\/]/,ik=/^[A-Za-z][A-Za-z\d+.-]*:/,ok=/^\/api(?:\/|$)/i,ak=/#L(\d+)(?:C\d+)?(?:[-–]L?\d+(?:C\d+)?)?$/i,lk=/:(\d+)(?::\d+)?(?:[-–]\d+(?::\d+)?)?$/,ck=/^v?\d+(?:\.\d+){1,}(?:[-+][A-Za-z\d.-]+)?$/i,dk=/\.(?:7z|bz2?|gz|rar|tar|tgz|xz|zip|zst)$/i,uk=/\.(?:png|jpe?g|gif|webp|bmp|ico)$/i,pk=/^(?:README|LICENSE|CHANGELOG|CONTRIBUTING|Dockerfile|Makefile)(?:[-_.][A-Za-z\d-]+)?$/i,kf=/(?<![\p{L}\p{N}\p{M}\p{S}_.@%&+\\/~-])(?:[A-Za-z][A-Za-z\d+.-]*:\d+(?::\d+)?(?:[-–]\d+(?::\d+)?)?(?=$|[\s)\]},;!?,。;()])|[A-Za-z][A-Za-z\d+.-]*:[^\s<>"',。;()]+|\/\/[^\s<>"',。;()]+|(?:[A-Za-z]:[\\/]|(?:\.{1,2}|~)?[\\/])?(?:&[A-Za-z][A-Za-z\d]*;|[\p{L}\p{N}\p{M}\p{S}\u00a0_.@%&+-])+(?:[\\/](?:&[A-Za-z][A-Za-z\d]*;|[\p{L}\p{N}\p{M}\p{S}\u00a0_.@%&+-])+)*(?:#L\d+(?:C\d+)?(?:[-–]L?\d+(?:C\d+)?)?|:\d+(?::\d+)?(?:[-–]\d+(?::\d+)?)?)?)/giu,Sf=/(<pre\b[^>]*>[\s\S]*?<\/pre>|<a\b[^>]*>[\s\S]*?<\/a>|<code\b[^>]*>[\s\S]*?<\/code>)|(<[^>]+>)|([^<]+)/gi,gk=e=>{let t=e.split(/[\\/]/).pop()||"";return!t||dk.test(t)?!1:wf.test(e)||/^(?:\/|\.\.?[\\/]|~[\\/])/.test(e)?!0:ck.test(t)?!1:t.startsWith(".")&&t.length>1||pk.test(t)?!0:/\.[A-Za-z\d][A-Za-z\d_-]*$/.test(t)};jt=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),If=e=>e.replace(/^[('"`]+/,"").replace(/[.)'"`,;!?]+$/,"")});var ar,Do=B(()=>{bc();nf();wc();li();vc();lf();di();ai();js();xf();ar={name:"AssistantTurn",components:{ToolLine:_o,AskCard:sf,VpSpeakerHeader:Eo},props:{turn:{type:Object,required:!0},conversationId:{type:String,default:null},hideSpeakerHeader:{type:Boolean,default:!1},actionsExpanded:{type:Boolean,default:null},toolExpandStates:{type:Object,default:null},toolStatePrefix:{type:String,default:""},responseCollapsible:{type:Boolean,default:!1},responseCollapsed:{type:Boolean,default:!1},responseToggleLabel:{type:String,default:""},sessionActions:{type:Boolean,default:!1},quoteAuthor:{type:String,default:""},originMessageId:{type:String,default:""},showDebugAction:{type:Boolean,default:!1},debugActionTitle:{type:String,default:""}},emits:["update-actions-expanded","update-tool-expanded","toggle-response-collapse","quote","open-debug"],template:`
|
|
744
744
|
<div
|
|
745
745
|
class="assistant-turn"
|
|
746
746
|
ref="turnRef"
|
|
Binary file
|
package/package.json
CHANGED
package/workbench/file-ops.js
CHANGED
|
@@ -10,14 +10,27 @@ export const MAX_WORKBENCH_PREVIEW_BYTES = 20 * 1024 * 1024;
|
|
|
10
10
|
export const WORKBENCH_FILE_CHUNK_BYTES = 1024 * 1024;
|
|
11
11
|
export const WORKBENCH_VIDEO_CHUNK_BYTES = 1024 * 1024;
|
|
12
12
|
|
|
13
|
-
async function
|
|
13
|
+
async function canonicalWorkspaceReadPath(filePath, workDir, errorMessage = 'File is outside the active workspace.') {
|
|
14
14
|
const canonicalRoot = await realpath(resolve(workDir));
|
|
15
15
|
const canonicalFile = await realpath(resolveAndValidatePath(filePath, canonicalRoot));
|
|
16
16
|
const relativePath = relative(canonicalRoot, canonicalFile);
|
|
17
17
|
const outside = relativePath === '..'
|
|
18
18
|
|| relativePath.startsWith(`..${platform() === 'win32' ? '\\' : '/'}`)
|
|
19
19
|
|| isAbsolute(relativePath);
|
|
20
|
-
if (outside)
|
|
20
|
+
if (outside) {
|
|
21
|
+
const error = new Error(errorMessage);
|
|
22
|
+
error.code = 'FILE_OUTSIDE_WORKSPACE';
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
return canonicalFile;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function validateResponseImagePath(filePath, workDir) {
|
|
29
|
+
const canonicalFile = await canonicalWorkspaceReadPath(
|
|
30
|
+
filePath,
|
|
31
|
+
workDir,
|
|
32
|
+
'Response image is outside the active workspace.',
|
|
33
|
+
);
|
|
21
34
|
const mimeType = BINARY_EXTENSIONS[extname(canonicalFile).toLowerCase()];
|
|
22
35
|
if (!mimeType?.startsWith('image/')) throw new Error('Response preview only supports image files.');
|
|
23
36
|
return canonicalFile;
|
|
@@ -169,7 +182,7 @@ export async function handleReadFile(msg) {
|
|
|
169
182
|
try {
|
|
170
183
|
const resolved = msg.responseImagePreview
|
|
171
184
|
? await validateResponseImagePath(filePath, workDir)
|
|
172
|
-
:
|
|
185
|
+
: await canonicalWorkspaceReadPath(filePath, workDir);
|
|
173
186
|
const ext = extname(resolved).toLowerCase();
|
|
174
187
|
if (VIDEO_EXTENSIONS[ext]) {
|
|
175
188
|
const error = new Error('Video files require the Workbench streaming protocol.');
|