page-agent-sdk 4.1.0 → 4.2.1
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/page-agent-sdk.headless.js +155 -100
- package/dist/page-agent-sdk.iife.js +7 -6
- package/dist/page-agent-sdk.js +110 -55
- package/dist/page-agent-sdk.legacy.js +134 -78
- package/dist/page-agent-sdk.umd.cjs +7 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("zod"),require("@langchain/openai"),require("@langchain/core/tools"),require("@langchain/core/messages"),require("@langchain/core/errors")):typeof define==`function`&&define.amd?define([`exports`,`zod`,`@langchain/openai`,`@langchain/core/tools`,`@langchain/core/messages`,`@langchain/core/errors`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ChatSdk={},e.Zod,e.LangchainOpenAI,e.LangchainCoreTools,e.LangchainCoreMessages,e.LangchainCoreErrors))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:o(u(e)),p(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));function h(e){return!!(e==null||typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||e instanceof URLSearchParams||e instanceof FormData)}function g(e){let t=e.model||`gpt-3.5-turbo`,r=e.temperature,i=e.maxTokens,a=e.baseUrl;if(e.mode===`direct`){let o=!1;try{o=typeof location<`u`&&location.protocol===`https:`&&![`localhost`,`127.0.0.1`,`0.0.0.0`].includes(location.hostname)}catch{}if(o){if(e.throwOnDirectInProduction)throw Error(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式(throwOnDirectInProduction 已启用强安全闸;若确需生产直连,设为 false 显式承认风险)`);console.warn(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式`)}if(!e.apiKey)throw Error(`[page-agent-sdk][proxyLlm] direct 模式需提供 apiKey(开发环境用真实 key)`);return new n.ChatOpenAI({apiKey:e.apiKey,model:t,temperature:r,maxTokens:i,configuration:a?{baseURL:a}:void 0})}a||console.warn(`[page-agent-sdk][proxyLlm] proxy 模式未配 baseUrl,将打到页面 origin(通常不是预期);请传代理地址如 '/api/llm'`);let o=e.userToken||`proxy`,s=null;function c(){return e.refreshToken?(s||=e.refreshToken().finally(()=>{s=null}),s):Promise.resolve(o)}return new n.ChatOpenAI({apiKey:o,model:t,temperature:r,maxTokens:i,configuration:{baseURL:a||`/`,fetch:async(t,n)=>{let r,i;typeof t==`string`?(r=t,i=n?.headers):t instanceof URL?(r=t.toString(),i=n?.headers):(r=t.url,i=n?.headers??t.headers);let a=new Headers(i);if(a.set(`Authorization`,`Bearer ${o}`),e.headers)for(let[t,n]of Object.entries(e.headers))a.set(t,n);let s=()=>fetch(r,{...n,headers:a}),l=await s();if(l.status===401&&e.refreshToken&&h(n?.body))try{o=await c(),a.set(`Authorization`,`Bearer ${o}`),l=await s()}catch{}return l}}})}var _=[{pattern:/deepseek-v4/i,caps:{contextWindow:1048576,maxOutputTokens:393216,thinking:!0}},{pattern:/deepseek-reasoner|deepseek-r1/i,caps:{contextWindow:65536,maxOutputTokens:8192,thinking:!0}},{pattern:/deepseek/i,caps:{contextWindow:131072,maxOutputTokens:8192,thinking:!0}},{pattern:/gpt-5/i,caps:{contextWindow:1048576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4\.1/i,caps:{contextWindow:1047576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4o-mini/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4o/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4-turbo|gpt-4-1106|gpt-4-0125/i,caps:{contextWindow:131072,maxOutputTokens:4096,vision:!0}},{pattern:/gpt-3\.5/i,caps:{contextWindow:16385,maxOutputTokens:4096}},{pattern:/claude-(sonnet|opus)-4|claude-4/i,caps:{contextWindow:2e5,maxOutputTokens:64e3,vision:!0,thinking:!0}},{pattern:/claude-3-7-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0,thinking:!0}},{pattern:/claude-3-5-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0}},{pattern:/claude-3-opus/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/claude-3-haiku/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/qwen2\.5-vl|qwen2-vl|qwen-vl|qvq/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{pattern:/qwen-max|qwen-plus/i,caps:{contextWindow:32768,maxOutputTokens:8192}},{pattern:/qwen2\.5-1m|qwen-1m/i,caps:{contextWindow:1048576,maxOutputTokens:8192}},{pattern:/qwen2\.5/i,caps:{contextWindow:32768,maxOutputTokens:8192}},{pattern:/glm-5\.2/i,caps:{contextWindow:1048576,maxOutputTokens:65536,thinking:!0}},{pattern:/glm-5/i,caps:{contextWindow:2e5,maxOutputTokens:65536}},{pattern:/glm-4v|glm4v/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{pattern:/glm-4\.[6-9]/i,caps:{contextWindow:131072,maxOutputTokens:131072}},{pattern:/glm-4\.5/i,caps:{contextWindow:131072,maxOutputTokens:98304}},{pattern:/glm-4|glm4/i,caps:{contextWindow:131072,maxOutputTokens:4096}},{pattern:/kimi-k3/i,caps:{contextWindow:1048576,maxOutputTokens:65536}},{pattern:/kimi-k2|kimi|moonshot/i,caps:{contextWindow:262144,maxOutputTokens:32768}},{pattern:/yi-34b|yi-large/i,caps:{contextWindow:32768,maxOutputTokens:4096}}],v={contextWindow:32768,maxOutputTokens:4096},y=2e5;function b(e={}){let t=(()=>{if(!e.model)return;let t=_.map(t=>{let n=t.pattern.exec(e.model);return n?{caps:t.caps,matchedLen:n[0].length}:null}).filter(e=>e!==null);if(t.length)return t.sort((e,t)=>t.matchedLen-e.matchedLen),t[0].caps})();return{contextWindow:e.contextWindow??t?.contextWindow??v.contextWindow,maxOutputTokens:e.maxOutputTokens??t?.maxOutputTokens??v.maxOutputTokens,vision:e.vision??t?.vision??!1,thinking:e.thinking??t?.thinking??!1}}function x(e){if(!e)return 0;let t=(e.match(/[\u4e00-\u9fff]/g)||[]).length,n=e.length-t;return Math.ceil(t*1.5+n*.25)}function S(e){return Math.max(2e3,Math.min(2e4,Math.round(e*.035)))}function C(e){let t=S(e);return Math.min(2e5,Math.max(t,Math.round(e*.7)))}function w(e,t){if(!t)return e;if(t===`simple`){let t=e.extraBody&&`thinking`in e.extraBody;if(!t&&!e.thinking)return e;let{thinking:n,...r}=e,i=r;if(t){let{thinking:t,...n}=e.extraBody;i.extraBody=n}return i}if(e.provider===`anthropic`){if(e.thinking?.type===`enabled`&&e.thinking.budget_tokens)return e;let t=e.thinking?.budget_tokens??Math.min(e.maxTokens??4096,8e3);return{...e,thinking:{type:`enabled`,budget_tokens:t}}}let n=e.extraBody?.thinking??{};return{...e,extraBody:{...e.extraBody??{},thinking:{...n,type:`enabled`}}}}function T(e,t,n){if(t)return t;if(e.thinkingMode)return e.thinkingMode;if(!(e.extraBody&&`thinking`in e.extraBody||e.thinking))return n||(b({model:e.model}).thinking?`deep`:void 0)}function E(e,t){if(t?.headers){let e=new Headers(t.headers),n=!1;for(let t of[...e.keys()])t.toLowerCase().startsWith(`x-stainless`)&&(e.delete(t),n=!0);n&&(t={...t,headers:e})}return fetch(e,t)}function D(e){return!e||!e.startsWith(`/`)||typeof location>`u`||!location.origin?e:`${location.origin}${e}`}function ee(e,t={}){return e=w(e,T(e,t.thinkingMode,t.thinkingFallback)),new n.ChatOpenAI({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,configuration:{...e.baseUrl?{baseURL:D(e.baseUrl)}:{},fetch:E,...e.extraConfig},...e.extraBody?{modelKwargs:e.extraBody}:{}})}async function O(e,t={}){if(e=w(e,T(e,t.thinkingMode,t.thinkingFallback)),(e.provider??`openai`)===`openai`)return ee(e,t);let{ChatAnthropic:n}=await import(`@langchain/anthropic`);return new n({apiKey:e.apiKey,model:e.model,temperature:e.thinking?1:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,...e.baseUrl?{anthropicApiUrl:D(e.baseUrl)}:{},...e.extraConfig?{clientOptions:e.extraConfig}:{},...e.thinking?{thinking:e.thinking}:{},...e.cacheControl?{invocationKwargs:{cache_control:{type:`ephemeral`,...e.cacheControl===!0?{}:{ttl:e.cacheControl}}}}:{}})}function k(e){let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:e?.type===`text`&&typeof e.text==`string`?e.text:``).join(``):``}function te(e){let t=e.additional_kwargs||{},n=t.reasoning_content||t.reasoning||``;return!n&&Array.isArray(e.content)&&(n=e.content.map(e=>e?.type===`thinking`?e.thinking??``:e?.type===`thinking_delta`?e.delta??e.thinking??``:``).join(``)),n}function A(e){let t=e,n=[t?.additional_kwargs?.usage,t?.usage_metadata,t?.response_metadata?.usage,t?.response_metadata?.token_usage,t?.response_metadata?.tokenUsage];for(let e of n)if(e&&typeof e==`object`&&j(e))return e}function j(e){return[`prompt_tokens`,`completion_tokens`,`total_tokens`,`promptTokens`,`completionTokens`,`totalTokens`,`input_tokens`,`output_tokens`,`inputTokens`,`outputTokens`].some(t=>typeof e[t]==`number`&&e[t]>0)}function M(e){let t=A(e);if(!t||typeof t!=`object`)return null;let n=t,r=Number(n.prompt_tokens??n.promptTokens??n.input_tokens??n.inputTokens??0)||0,i=Number(n.completion_tokens??n.completionTokens??n.output_tokens??n.outputTokens??0)||0,a=Number(n.total_tokens??n.totalTokens??r+i)||0;if(!r&&!i&&!a)return null;let o=n.input_token_details,s=Number(n.cache_read_input_tokens??n.cacheReadInputTokens??o?.cache_read??0)||0,c=Number(n.cache_creation_input_tokens??n.cacheCreationInputTokens??o?.cache_creation??0)||0,l=n.output_token_details,u=n.completion_tokens_details,d=e,f=Number(l?.reasoning??u?.reasoning_tokens??d?.response_metadata?.usage?.completion_tokens_details?.reasoning_tokens??0)||0;return{prompt_tokens:r,completion_tokens:i,total_tokens:a,...s?{cache_read_input_tokens:s}:{},...c?{cache_creation_input_tokens:c}:{},...f?{reasoning_tokens:f}:{}}}function ne(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var N=process.env.NODE_ENV===`production`?{}:Object.freeze({}),P=process.env.NODE_ENV===`production`?[]:Object.freeze([]),F=()=>{},re=()=>!1,ie=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),ae=e=>e.startsWith(`onUpdate:`),I=Object.assign,oe=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},se=Object.prototype.hasOwnProperty,L=(e,t)=>se.call(e,t),R=Array.isArray,z=e=>fe(e)===`[object Map]`,ce=e=>fe(e)===`[object Set]`,B=e=>fe(e)===`[object Date]`,V=e=>typeof e==`function`,H=e=>typeof e==`string`,le=e=>typeof e==`symbol`,U=e=>typeof e==`object`&&!!e,ue=e=>(U(e)||V(e))&&V(e.then)&&V(e.catch),de=Object.prototype.toString,fe=e=>de.call(e),pe=e=>fe(e).slice(8,-1),me=e=>fe(e)===`[object Object]`,he=e=>H(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,ge=ne(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),_e=ne(`bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo`),ve=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},ye=/-\w/g,be=ve(e=>e.replace(ye,e=>e.slice(1).toUpperCase())),xe=/\B([A-Z])/g,Se=ve(e=>e.replace(xe,`-$1`).toLowerCase()),Ce=ve(e=>e.charAt(0).toUpperCase()+e.slice(1)),we=ve(e=>e?`on${Ce(e)}`:``),Te=(e,t)=>!Object.is(e,t),Ee=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},De=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},Oe=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ke=e=>{let t=H(e)?Number(e):NaN;return isNaN(t)?e:t},Ae,je=()=>Ae||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function Me(e){if(R(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=H(r)?Ie(r):Me(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(H(e)||U(e))return e}var Ne=/;(?![^(]*\))/g,Pe=/:([^]+)/,Fe=/\/\*[^]*?\*\//g;function Ie(e){let t={};return e.replace(Fe,``).split(Ne).forEach(e=>{if(e){let n=e.split(Pe);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function Le(e){let t=``;if(H(e))t=e;else if(R(e))for(let n=0;n<e.length;n++){let r=Le(e[n]);r&&(t+=r+` `)}else if(U(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var Re=`html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot`,ze=`svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view`,Be=`annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics`,Ve=ne(Re),He=ne(ze),Ue=ne(Be),We=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,Ge=ne(We);We+``;function Ke(e){return!!e||e===``}function qe(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=Je(e[r],t[r]);return n}function Je(e,t){if(e===t)return!0;let n=B(e),r=B(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=le(e),r=le(t),n||r)return e===t;if(n=R(e),r=R(t),n||r)return n&&r?qe(e,t):!1;if(n=U(e),r=U(t),n||r){if(!n||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e){let r=e.hasOwnProperty(n),i=t.hasOwnProperty(n);if(r&&!i||!r&&i||!Je(e[n],t[n]))return!1}}return String(e)===String(t)}var Ye=e=>!!(e&&e.__v_isRef===!0),W=e=>H(e)?e:e==null?``:R(e)||U(e)&&(e.toString===de||!V(e.toString))?Ye(e)?W(e.value):JSON.stringify(e,Xe,2):String(e),Xe=(e,t)=>Ye(t)?Xe(e,t.value):z(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Ze(t,r)+` =>`]=n,e),{})}:ce(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Ze(e))}:le(t)?Ze(t):U(t)&&!R(t)&&!me(t)?String(t):t,Ze=(e,t=``)=>le(e)?`Symbol(${e.description??t})`:e;function Qe(e,...t){console.warn(`[Vue warn] ${e}`,...t)}var $e,et=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&$e&&($e.active?(this.parent=$e,this.index=($e.scopes||=[]).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){let t=$e;try{return $e=this,e()}finally{$e=t}}else process.env.NODE_ENV!==`production`&&this._warnOnRun&&Qe(`cannot run an inactive effect scope.`)}on(){++this._on===1&&(this.prevScope=$e,$e=this)}off(){if(this._on>0&&--this._on===0){if($e===this)$e=this.prevScope;else{let e=$e;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function tt(){return $e}function nt(e,t=!1){$e?$e.cleanups.push(e):process.env.NODE_ENV!==`production`&&!t&&Qe(`onScopeDispose() is called when there is no active effect scope to be associated with.`)}var rt,it=new WeakSet,at=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,$e&&($e.active?$e.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,it.has(this)&&(it.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||lt(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,St(this),ft(this);let e=rt,t=vt;rt=this,vt=!0;try{return this.fn()}finally{process.env.NODE_ENV!==`production`&&rt!==this&&Qe(`Active effect was not restored correctly - this is likely a Vue internal bug.`),pt(this),rt=e,vt=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)gt(e);this.deps=this.depsTail=void 0,St(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?it.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){mt(this)&&this.run()}get dirty(){return mt(this)}},ot=0,st,ct;function lt(e,t=!1){if(e.flags|=8,t){e.next=ct,ct=e;return}e.next=st,st=e}function ut(){ot++}function dt(){if(--ot>0)return;if(ct){let e=ct;for(ct=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;st;){let t=st;for(st=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function ft(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function pt(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),gt(r),_t(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function mt(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(ht(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function ht(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Ct)||(e.globalVersion=Ct,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!mt(e))))return;e.flags|=2;let t=e.dep,n=rt,r=vt;rt=e,vt=!0;try{ft(e);let n=e.fn(e._value);(t.version===0||Te(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{rt=n,vt=r,pt(e),e.flags&=-3}}function gt(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),process.env.NODE_ENV!==`production`&&n.subsHead===e&&(n.subsHead=i),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)gt(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function _t(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var vt=!0,yt=[];function bt(){yt.push(vt),vt=!1}function xt(){let e=yt.pop();vt=e===void 0||e}function St(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=rt;rt=void 0;try{t()}finally{rt=e}}}var Ct=0,wt=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},Tt=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0,process.env.NODE_ENV!==`production`&&(this.subsHead=void 0)}track(e){if(!rt||!vt||rt===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==rt)t=this.activeLink=new wt(rt,this),rt.deps?(t.prevDep=rt.depsTail,rt.depsTail.nextDep=t,rt.depsTail=t):rt.deps=rt.depsTail=t,Et(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=rt.depsTail,t.nextDep=void 0,rt.depsTail.nextDep=t,rt.depsTail=t,rt.deps===t&&(rt.deps=e)}return process.env.NODE_ENV!==`production`&&rt.onTrack&&rt.onTrack(I({effect:rt},e)),t}trigger(e){this.version++,Ct++,this.notify(e)}notify(e){ut();try{if(process.env.NODE_ENV!==`production`)for(let t=this.subsHead;t;t=t.nextSub)t.sub.onTrigger&&!(t.sub.flags&8)&&t.sub.onTrigger(I({effect:t.sub},e));for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{dt()}}};function Et(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)Et(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),process.env.NODE_ENV!==`production`&&e.dep.subsHead===void 0&&(e.dep.subsHead=e),e.dep.subs=e}}var Dt=new WeakMap,Ot=Symbol(process.env.NODE_ENV===`production`?``:`Object iterate`),kt=Symbol(process.env.NODE_ENV===`production`?``:`Map keys iterate`),At=Symbol(process.env.NODE_ENV===`production`?``:`Array iterate`);function jt(e,t,n){if(vt&&rt){let r=Dt.get(e);r||Dt.set(e,r=new Map);let i=r.get(n);i||(r.set(n,i=new Tt),i.map=r,i.key=n),process.env.NODE_ENV===`production`?i.track():i.track({target:e,type:t,key:n})}}function Mt(e,t,n,r,i,a){let o=Dt.get(e);if(!o){Ct++;return}let s=o=>{o&&(process.env.NODE_ENV===`production`?o.trigger():o.trigger({target:e,type:t,key:n,newValue:r,oldValue:i,oldTarget:a}))};if(ut(),t===`clear`)o.forEach(s);else{let i=R(e),a=i&&he(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===At||!le(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(At)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(Ot)),z(e)&&s(o.get(kt)));break;case`delete`:i||(s(o.get(Ot)),z(e)&&s(o.get(kt)));break;case`set`:z(e)&&s(o.get(Ot));break}}dt()}function Nt(e){let t=wn(e);return t===e?t:(jt(t,`iterate`,At),Sn(e)?t:t.map(En))}function Pt(e){return jt(e=wn(e),`iterate`,At),e}function Ft(e,t){return xn(e)?Dn(bn(e)?En(t):t):En(t)}var It={__proto__:null,[Symbol.iterator](){return Lt(this,Symbol.iterator,e=>Ft(this,e))},concat(...e){return Nt(this).concat(...e.map(e=>R(e)?Nt(e):e))},entries(){return Lt(this,`entries`,e=>(e[1]=Ft(this,e[1]),e))},every(e,t){return G(this,`every`,e,t,void 0,arguments)},filter(e,t){return G(this,`filter`,e,t,e=>e.map(e=>Ft(this,e)),arguments)},find(e,t){return G(this,`find`,e,t,e=>Ft(this,e),arguments)},findIndex(e,t){return G(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return G(this,`findLast`,e,t,e=>Ft(this,e),arguments)},findLastIndex(e,t){return G(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return G(this,`forEach`,e,t,void 0,arguments)},includes(...e){return Bt(this,`includes`,e)},indexOf(...e){return Bt(this,`indexOf`,e)},join(e){return Nt(this).join(e)},lastIndexOf(...e){return Bt(this,`lastIndexOf`,e)},map(e,t){return G(this,`map`,e,t,void 0,arguments)},pop(){return Vt(this,`pop`)},push(...e){return Vt(this,`push`,e)},reduce(e,...t){return zt(this,`reduce`,e,t)},reduceRight(e,...t){return zt(this,`reduceRight`,e,t)},shift(){return Vt(this,`shift`)},some(e,t){return G(this,`some`,e,t,void 0,arguments)},splice(...e){return Vt(this,`splice`,e)},toReversed(){return Nt(this).toReversed()},toSorted(e){return Nt(this).toSorted(e)},toSpliced(...e){return Nt(this).toSpliced(...e)},unshift(...e){return Vt(this,`unshift`,e)},values(){return Lt(this,`values`,e=>Ft(this,e))}};function Lt(e,t,n){let r=Pt(e),i=r[t]();return r!==e&&!Sn(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var Rt=Array.prototype;function G(e,t,n,r,i,a){let o=Pt(e),s=o!==e&&!Sn(e),c=o[t];if(c!==Rt[t]){let t=c.apply(e,a);return s?En(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,Ft(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function zt(e,t,n,r){let i=Pt(e),a=i!==e&&!Sn(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=Ft(e,t)),n.call(this,t,Ft(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?Ft(e,c):c}function Bt(e,t,n){let r=wn(e);jt(r,`iterate`,At);let i=r[t](...n);return(i===-1||i===!1)&&Cn(n[0])?(n[0]=wn(n[0]),r[t](...n)):i}function Vt(e,t,n=[]){bt(),ut();let r=wn(e)[t].apply(e,n);return dt(),xt(),r}var Ht=ne(`__proto__,__v_isRef,__isVue`),Ut=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(le));function Wt(e){le(e)||(e=String(e));let t=wn(this);return jt(t,`has`,e),t.hasOwnProperty(e)}var Gt=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?pn:fn:i?dn:un).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=R(e);if(!r){let e;if(a&&(e=It[t]))return e;if(t===`hasOwnProperty`)return Wt}let o=Reflect.get(e,t,On(e)?e:n);if((le(t)?Ut.has(t):Ht(t))||(r||jt(e,`get`,t),i))return o;if(On(o)){let e=a&&he(t)?o:o.value;return r&&U(e)?_n(e):e}return U(o)?r?_n(o):hn(o):o}},Kt=class extends Gt{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=R(e)&&he(t);if(!this._isShallow){let r=xn(i);if(!Sn(n)&&!xn(n)&&(i=wn(i),n=wn(n)),!a&&On(i)&&!On(n))return r?(process.env.NODE_ENV!==`production`&&Qe(`Set operation on key "${String(t)}" failed: target is readonly.`,e[t]),!0):(i.value=n,!0)}let o=a?Number(t)<e.length:L(e,t),s=Reflect.set(e,t,n,On(e)?e:r);return e===wn(r)&&s&&(o?Te(n,i)&&Mt(e,`set`,t,n,i):Mt(e,`add`,t,n)),s}deleteProperty(e,t){let n=L(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&Mt(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!le(t)||!Ut.has(t))&&jt(e,`has`,t),n}ownKeys(e){return jt(e,`iterate`,R(e)?`length`:Ot),Reflect.ownKeys(e)}},qt=class extends Gt{constructor(e=!1){super(!0,e)}set(e,t){return process.env.NODE_ENV!==`production`&&Qe(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0}deleteProperty(e,t){return process.env.NODE_ENV!==`production`&&Qe(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},Jt=new Kt,Yt=new qt,Xt=new Kt(!0),Zt=new qt(!0),Qt=e=>e,$t=e=>Reflect.getPrototypeOf(e);function en(e,t,n){return function(...r){let i=this.__v_raw,a=wn(i),o=z(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?Qt:t?Dn:En;return!t&&jt(a,`iterate`,c?kt:Ot),I(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function tn(e){return function(...t){if(process.env.NODE_ENV!==`production`){let n=t[0]?`on key "${t[0]}" `:``;Qe(`${Ce(e)} operation ${n}failed: target is readonly.`,wn(this))}return e===`delete`?!1:e===`clear`?void 0:this}}function nn(e,t){let n={get(n){let r=this.__v_raw,i=wn(r),a=wn(n);e||(Te(n,a)&&jt(i,`get`,n),jt(i,`get`,a));let{has:o}=$t(i),s=t?Qt:e?Dn:En;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&jt(wn(t),`iterate`,Ot),t.size},has(t){let n=this.__v_raw,r=wn(n),i=wn(t);return e||(Te(t,i)&&jt(r,`has`,t),jt(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=wn(a),s=t?Qt:e?Dn:En;return!e&&jt(o,`iterate`,Ot),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return I(n,e?{add:tn(`add`),set:tn(`set`),delete:tn(`delete`),clear:tn(`clear`)}:{add(e){let n=wn(this),r=$t(n),i=wn(e),a=!t&&!Sn(e)&&!xn(e)?i:e;return r.has.call(n,a)||Te(e,a)&&r.has.call(n,e)||Te(i,a)&&r.has.call(n,i)||(n.add(a),Mt(n,`add`,a,a)),this},set(e,n){!t&&!Sn(n)&&!xn(n)&&(n=wn(n));let r=wn(this),{has:i,get:a}=$t(r),o=i.call(r,e);o?process.env.NODE_ENV!==`production`&&ln(r,i,e):(e=wn(e),o=i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?Te(n,s)&&Mt(r,`set`,e,n,s):Mt(r,`add`,e,n),this},delete(e){let t=wn(this),{has:n,get:r}=$t(t),i=n.call(t,e);i?process.env.NODE_ENV!==`production`&&ln(t,n,e):(e=wn(e),i=n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&Mt(t,`delete`,e,void 0,a),o},clear(){let e=wn(this),t=e.size!==0,n=process.env.NODE_ENV===`production`?void 0:z(e)?new Map(e):new Set(e),r=e.clear();return t&&Mt(e,`clear`,void 0,void 0,n),r}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=en(r,e,t)}),n}function rn(e,t){let n=nn(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(L(n,r)&&r in t?n:t,r,i)}var an={get:rn(!1,!1)},on={get:rn(!1,!0)},sn={get:rn(!0,!1)},cn={get:rn(!0,!0)};function ln(e,t,n){let r=wn(n);if(r!==n&&t.call(e,r)){let t=pe(e);Qe(`Reactive ${t} contains both the raw and reactive versions of the same object${t===`Map`?` as keys`:``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}var un=new WeakMap,dn=new WeakMap,fn=new WeakMap,pn=new WeakMap;function mn(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function hn(e){return xn(e)?e:yn(e,!1,Jt,an,un)}function gn(e){return yn(e,!1,Xt,on,dn)}function _n(e){return yn(e,!0,Yt,sn,fn)}function vn(e){return yn(e,!0,Zt,cn,pn)}function yn(e,t,n,r,i){if(!U(e))return process.env.NODE_ENV!==`production`&&Qe(`value cannot be made ${t?`readonly`:`reactive`}: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=mn(pe(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function bn(e){return xn(e)?bn(e.__v_raw):!!(e&&e.__v_isReactive)}function xn(e){return!!(e&&e.__v_isReadonly)}function Sn(e){return!!(e&&e.__v_isShallow)}function Cn(e){return e?!!e.__v_raw:!1}function wn(e){let t=e&&e.__v_raw;return t?wn(t):e}function Tn(e){return!L(e,`__v_skip`)&&Object.isExtensible(e)&&De(e,`__v_skip`,!0),e}var En=e=>U(e)?hn(e):e,Dn=e=>U(e)?_n(e):e;function On(e){return e?e.__v_isRef===!0:!1}function kn(e){return jn(e,!1)}function An(e){return jn(e,!0)}function jn(e,t){return On(e)?e:new Mn(e,t)}var Mn=class{constructor(e,t){this.dep=new Tt,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:wn(e),this._value=t?e:En(e),this.__v_isShallow=t}get value(){return process.env.NODE_ENV===`production`?this.dep.track():this.dep.track({target:this,type:`get`,key:`value`}),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||Sn(e)||xn(e);e=n?e:wn(e),Te(e,t)&&(this._rawValue=e,this._value=n?e:En(e),process.env.NODE_ENV===`production`?this.dep.trigger():this.dep.trigger({target:this,type:`set`,key:`value`,newValue:e,oldValue:t}))}};function Nn(e){e.dep&&(process.env.NODE_ENV===`production`?e.dep.trigger():e.dep.trigger({target:e,type:`set`,key:`value`,newValue:e._value}))}function K(e){return On(e)?e.value:e}var Pn={get:(e,t,n)=>t===`__v_raw`?e:K(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return On(i)&&!On(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function Fn(e){return bn(e)?e:new Proxy(e,Pn)}var In=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new Tt(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Ct-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&rt!==this)return lt(this,!0),!0;process.env.NODE_ENV}get value(){let e=process.env.NODE_ENV===`production`?this.dep.track():this.dep.track({target:this,type:`get`,key:`value`});return ht(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter?this.setter(e):process.env.NODE_ENV!==`production`&&Qe(`Write operation failed: computed value is readonly`)}};function Ln(e,t,n=!1){let r,i;V(e)?r=e:(r=e.get,i=e.set);let a=new In(r,i,n);return process.env.NODE_ENV!==`production`&&t&&!n&&(a.onTrack=t.onTrack,a.onTrigger=t.onTrigger),a}var Rn={},zn=new WeakMap,Bn=void 0;function Vn(e,t=!1,n=Bn){if(n){let t=zn.get(n);t||zn.set(n,t=[]),t.push(e)}else process.env.NODE_ENV!==`production`&&!t&&Qe(`onWatcherCleanup() was called when there was no active watcher to associate with.`)}function Hn(e,t,n=N){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>{(n.onWarn||Qe)(`Invalid watch source: `,e,`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`)},u=e=>i?e:Sn(e)||i===!1||i===0?Un(e,1):Un(e),d,f,p,m,h=!1,g=!1;if(On(e)?(f=()=>e.value,h=Sn(e)):bn(e)?(f=()=>u(e),h=!0):R(e)?(g=!0,h=e.some(e=>bn(e)||Sn(e)),f=()=>e.map(e=>{if(On(e))return e.value;if(bn(e))return u(e);if(V(e))return c?c(e,2):e();process.env.NODE_ENV!==`production`&&l(e)})):V(e)?f=t?c?()=>c(e,2):e:()=>{if(p){bt();try{p()}finally{xt()}}let t=Bn;Bn=d;try{return c?c(e,3,[m]):e(m)}finally{Bn=t}}:(f=F,process.env.NODE_ENV!==`production`&&l(e)),t&&i){let e=f,t=i===!0?1/0:i;f=()=>Un(e(),t)}let _=tt(),v=()=>{d.stop(),_&&_.active&&oe(_.effects,d)};if(a&&t){let e=t;t=(...t)=>{let n=e(...t);return v(),n}}let y=g?Array(e.length).fill(Rn):Rn,b=e=>{if(!(!(d.flags&1)||!d.dirty&&!e))if(t){let n=d.run();if(e||i||h||(g?n.some((e,t)=>Te(e,y[t])):Te(n,y))){p&&p();let e=Bn;Bn=d;try{let e=[n,y===Rn?void 0:g&&y[0]===Rn?[]:y,m];y=n,c?c(t,3,e):t(...e)}finally{Bn=e}}}else d.run()};return s&&s(b),d=new at(f),d.scheduler=o?()=>o(b,!1):b,m=e=>Vn(e,!1,d),p=d.onStop=()=>{let e=zn.get(d);if(e){if(c)c(e,4);else for(let t of e)t();zn.delete(d)}},process.env.NODE_ENV!==`production`&&(d.onTrack=n.onTrack,d.onTrigger=n.onTrigger),t?r?b(!0):y=d.run():o?o(b.bind(null,!0),!0):d.run(),v.pause=d.pause.bind(d),v.resume=d.resume.bind(d),v.stop=v,v}function Un(e,t=1/0,n){if(t<=0||!U(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,On(e))Un(e.value,t,n);else if(R(e))for(let r=0;r<e.length;r++)Un(e[r],t,n);else if(ce(e)||z(e))e.forEach(e=>{Un(e,t,n)});else if(me(e)){for(let r in e)Un(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Un(e[r],t,n)}return e}var Wn=[];function Gn(e){Wn.push(e)}function Kn(){Wn.pop()}var qn=!1;function q(e,...t){if(qn)return;qn=!0,bt();let n=Wn.length?Wn[Wn.length-1].component:null,r=n&&n.appContext.config.warnHandler,i=Jn();if(r)tr(r,n,11,[e+t.map(e=>e.toString?.call(e)??JSON.stringify(e)).join(``),n&&n.proxy,i.map(({vnode:e})=>`at <${nc(n,e.type)}>`).join(`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("zod"),require("@langchain/openai"),require("@langchain/core/tools"),require("@langchain/core/messages"),require("@langchain/core/errors")):typeof define==`function`&&define.amd?define([`exports`,`zod`,`@langchain/openai`,`@langchain/core/tools`,`@langchain/core/messages`,`@langchain/core/errors`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ChatSdk={},e.Zod,e.LangchainOpenAI,e.LangchainCoreTools,e.LangchainCoreMessages,e.LangchainCoreErrors))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:o(u(e)),p(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e));function h(e){return!!(e==null||typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||e instanceof URLSearchParams||e instanceof FormData)}function g(e){let t=e.model||`deepseek-v4-flash`,r=e.temperature,i=e.maxTokens,a=e.baseUrl;if(e.mode===`direct`){let o=!1;try{o=typeof location<`u`&&location.protocol===`https:`&&![`localhost`,`127.0.0.1`,`0.0.0.0`].includes(location.hostname)}catch{}if(o){if(e.throwOnDirectInProduction)throw Error(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式(throwOnDirectInProduction 已启用强安全闸;若确需生产直连,设为 false 显式承认风险)`);console.warn(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式`)}if(!e.apiKey)throw Error(`[page-agent-sdk][proxyLlm] direct 模式需提供 apiKey(开发环境用真实 key)`);return new n.ChatOpenAI({apiKey:e.apiKey,model:t,temperature:r,maxTokens:i,configuration:a?{baseURL:a}:void 0})}a||console.warn(`[page-agent-sdk][proxyLlm] proxy 模式未配 baseUrl,将打到页面 origin(通常不是预期);请传代理地址如 '/api/llm'`);let o=e.userToken||`proxy`,s=null;function c(){return e.refreshToken?(s||=e.refreshToken().finally(()=>{s=null}),s):Promise.resolve(o)}return new n.ChatOpenAI({apiKey:o,model:t,temperature:r,maxTokens:i,configuration:{baseURL:a||`/`,fetch:async(t,n)=>{let r,i;typeof t==`string`?(r=t,i=n?.headers):t instanceof URL?(r=t.toString(),i=n?.headers):(r=t.url,i=n?.headers??t.headers);let a=new Headers(i);if(a.set(`Authorization`,`Bearer ${o}`),e.headers)for(let[t,n]of Object.entries(e.headers))a.set(t,n);let s=()=>fetch(r,{...n,headers:a}),l=await s();if(l.status===401&&e.refreshToken&&h(n?.body))try{o=await c(),a.set(`Authorization`,`Bearer ${o}`),l=await s()}catch{}return l}}})}var _=[{pattern:/deepseek-v4/i,caps:{contextWindow:1048576,maxOutputTokens:393216,thinking:!0}},{pattern:/deepseek-reasoner|deepseek-r1/i,caps:{contextWindow:65536,maxOutputTokens:8192,thinking:!0}},{pattern:/deepseek/i,caps:{contextWindow:131072,maxOutputTokens:8192,thinking:!0}},{pattern:/gpt-5/i,caps:{contextWindow:1048576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4\.1/i,caps:{contextWindow:1047576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4o-mini/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4o/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4-turbo|gpt-4-1106|gpt-4-0125/i,caps:{contextWindow:131072,maxOutputTokens:4096,vision:!0}},{pattern:/gpt-3\.5/i,caps:{contextWindow:16385,maxOutputTokens:4096}},{pattern:/claude-(sonnet|opus)-4|claude-4/i,caps:{contextWindow:2e5,maxOutputTokens:64e3,vision:!0,thinking:!0}},{pattern:/claude-3-7-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0,thinking:!0}},{pattern:/claude-3-5-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0}},{pattern:/claude-3-opus/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/claude-3-haiku/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/qwen2\.5-vl|qwen2-vl|qwen-vl|qvq/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{pattern:/qwen-max|qwen-plus/i,caps:{contextWindow:32768,maxOutputTokens:8192}},{pattern:/qwen2\.5-1m|qwen-1m/i,caps:{contextWindow:1048576,maxOutputTokens:8192}},{pattern:/qwen2\.5/i,caps:{contextWindow:32768,maxOutputTokens:8192}},{pattern:/glm-5\.2/i,caps:{contextWindow:1048576,maxOutputTokens:65536,thinking:!0}},{pattern:/glm-5/i,caps:{contextWindow:2e5,maxOutputTokens:65536}},{pattern:/glm-4v|glm4v/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{pattern:/glm-4\.[6-9]/i,caps:{contextWindow:131072,maxOutputTokens:131072}},{pattern:/glm-4\.5/i,caps:{contextWindow:131072,maxOutputTokens:98304}},{pattern:/glm-4|glm4/i,caps:{contextWindow:131072,maxOutputTokens:4096}},{pattern:/kimi-k3/i,caps:{contextWindow:1048576,maxOutputTokens:65536}},{pattern:/kimi-k2|kimi|moonshot/i,caps:{contextWindow:262144,maxOutputTokens:32768}},{pattern:/yi-34b|yi-large/i,caps:{contextWindow:32768,maxOutputTokens:4096}}],v={contextWindow:32768,maxOutputTokens:4096},y=2e5;function b(e={}){let t=(()=>{if(!e.model)return;let t=_.map(t=>{let n=t.pattern.exec(e.model);return n?{caps:t.caps,matchedLen:n[0].length}:null}).filter(e=>e!==null);if(t.length)return t.sort((e,t)=>t.matchedLen-e.matchedLen),t[0].caps})();return{contextWindow:e.contextWindow??t?.contextWindow??v.contextWindow,maxOutputTokens:e.maxOutputTokens??t?.maxOutputTokens??v.maxOutputTokens,vision:e.vision??t?.vision??!1,thinking:e.thinking??t?.thinking??!1}}function x(e){if(!e)return 0;let t=(e.match(/[\u4e00-\u9fff]/g)||[]).length,n=e.length-t;return Math.ceil(t*1.5+n*.25)}function S(e){return Math.max(2e3,Math.min(2e4,Math.round(e*.035)))}function C(e){let t=S(e);return Math.min(2e5,Math.max(t,Math.round(e*.7)))}function w(e,t){if(!t)return e;if(t===`simple`){let t=e.extraBody&&`thinking`in e.extraBody;if(!t&&!e.thinking)return e;let{thinking:n,...r}=e,i=r;if(t){let{thinking:t,...n}=e.extraBody;i.extraBody=n}return i}if(e.provider===`anthropic`){if(e.thinking?.type===`enabled`&&e.thinking.budget_tokens)return e;let t=e.thinking?.budget_tokens??Math.min(e.maxTokens??4096,8e3);return{...e,thinking:{type:`enabled`,budget_tokens:t}}}let n=e.extraBody?.thinking??{};return{...e,extraBody:{...e.extraBody??{},thinking:{...n,type:`enabled`}}}}function T(e,t,n){if(t)return t;if(e.thinkingMode)return e.thinkingMode;if(!(e.extraBody&&`thinking`in e.extraBody||e.thinking))return n||(b({model:e.model}).thinking?`deep`:void 0)}function E(e,t){if(t?.headers){let e=new Headers(t.headers),n=!1;for(let t of[...e.keys()])t.toLowerCase().startsWith(`x-stainless`)&&(e.delete(t),n=!0);n&&(t={...t,headers:e})}return fetch(e,t)}function D(e){return!e||!e.startsWith(`/`)||typeof location>`u`||!location.origin?e:`${location.origin}${e}`}function ee(e,t={}){return e=w(e,T(e,t.thinkingMode,t.thinkingFallback)),new n.ChatOpenAI({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,configuration:{...e.baseUrl?{baseURL:D(e.baseUrl)}:{},fetch:E,...e.extraConfig},...e.extraBody?{modelKwargs:e.extraBody}:{}})}async function O(e,t={}){if(e=w(e,T(e,t.thinkingMode,t.thinkingFallback)),(e.provider??`openai`)===`openai`)return ee(e,t);let{ChatAnthropic:n}=await import(`@langchain/anthropic`);return new n({apiKey:e.apiKey,model:e.model,temperature:e.thinking?1:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,...e.baseUrl?{anthropicApiUrl:D(e.baseUrl)}:{},...e.extraConfig?{clientOptions:e.extraConfig}:{},...e.thinking?{thinking:e.thinking}:{},...e.cacheControl?{invocationKwargs:{cache_control:{type:`ephemeral`,...e.cacheControl===!0?{}:{ttl:e.cacheControl}}}}:{}})}function k(e){let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:e?.type===`text`&&typeof e.text==`string`?e.text:``).join(``):``}function te(e){let t=e.additional_kwargs||{},n=t.reasoning_content||t.reasoning||``;return!n&&Array.isArray(e.content)&&(n=e.content.map(e=>e?.type===`thinking`?e.thinking??``:e?.type===`thinking_delta`?e.delta??e.thinking??``:``).join(``)),n}function A(e){let t=e,n=[t?.additional_kwargs?.usage,t?.usage_metadata,t?.response_metadata?.usage,t?.response_metadata?.token_usage,t?.response_metadata?.tokenUsage];for(let e of n)if(e&&typeof e==`object`&&j(e))return e}function j(e){return[`prompt_tokens`,`completion_tokens`,`total_tokens`,`promptTokens`,`completionTokens`,`totalTokens`,`input_tokens`,`output_tokens`,`inputTokens`,`outputTokens`].some(t=>typeof e[t]==`number`&&e[t]>0)}function M(e){let t=A(e);if(!t||typeof t!=`object`)return null;let n=t,r=Number(n.prompt_tokens??n.promptTokens??n.input_tokens??n.inputTokens??0)||0,i=Number(n.completion_tokens??n.completionTokens??n.output_tokens??n.outputTokens??0)||0,a=Number(n.total_tokens??n.totalTokens??r+i)||0;if(!r&&!i&&!a)return null;let o=n.input_token_details,s=Number(n.cache_read_input_tokens??n.cacheReadInputTokens??o?.cache_read??0)||0,c=Number(n.cache_creation_input_tokens??n.cacheCreationInputTokens??o?.cache_creation??0)||0,l=n.output_token_details,u=n.completion_tokens_details,d=e,f=Number(l?.reasoning??u?.reasoning_tokens??d?.response_metadata?.usage?.completion_tokens_details?.reasoning_tokens??0)||0;return{prompt_tokens:r,completion_tokens:i,total_tokens:a,...s?{cache_read_input_tokens:s}:{},...c?{cache_creation_input_tokens:c}:{},...f?{reasoning_tokens:f}:{}}}function ne(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var N=process.env.NODE_ENV===`production`?{}:Object.freeze({}),P=process.env.NODE_ENV===`production`?[]:Object.freeze([]),F=()=>{},re=()=>!1,ie=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),ae=e=>e.startsWith(`onUpdate:`),I=Object.assign,oe=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},se=Object.prototype.hasOwnProperty,L=(e,t)=>se.call(e,t),R=Array.isArray,z=e=>fe(e)===`[object Map]`,ce=e=>fe(e)===`[object Set]`,B=e=>fe(e)===`[object Date]`,V=e=>typeof e==`function`,H=e=>typeof e==`string`,le=e=>typeof e==`symbol`,U=e=>typeof e==`object`&&!!e,ue=e=>(U(e)||V(e))&&V(e.then)&&V(e.catch),de=Object.prototype.toString,fe=e=>de.call(e),pe=e=>fe(e).slice(8,-1),me=e=>fe(e)===`[object Object]`,he=e=>H(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,ge=ne(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),_e=ne(`bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo`),ve=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},ye=/-\w/g,be=ve(e=>e.replace(ye,e=>e.slice(1).toUpperCase())),xe=/\B([A-Z])/g,Se=ve(e=>e.replace(xe,`-$1`).toLowerCase()),Ce=ve(e=>e.charAt(0).toUpperCase()+e.slice(1)),we=ve(e=>e?`on${Ce(e)}`:``),Te=(e,t)=>!Object.is(e,t),Ee=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},De=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},Oe=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ke=e=>{let t=H(e)?Number(e):NaN;return isNaN(t)?e:t},Ae,je=()=>Ae||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function Me(e){if(R(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=H(r)?Ie(r):Me(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(H(e)||U(e))return e}var Ne=/;(?![^(]*\))/g,Pe=/:([^]+)/,Fe=/\/\*[^]*?\*\//g;function Ie(e){let t={};return e.replace(Fe,``).split(Ne).forEach(e=>{if(e){let n=e.split(Pe);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function Le(e){let t=``;if(H(e))t=e;else if(R(e))for(let n=0;n<e.length;n++){let r=Le(e[n]);r&&(t+=r+` `)}else if(U(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var Re=`html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot`,ze=`svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view`,Be=`annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics`,Ve=ne(Re),He=ne(ze),Ue=ne(Be),We=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,Ge=ne(We);We+``;function Ke(e){return!!e||e===``}function qe(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=Je(e[r],t[r]);return n}function Je(e,t){if(e===t)return!0;let n=B(e),r=B(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=le(e),r=le(t),n||r)return e===t;if(n=R(e),r=R(t),n||r)return n&&r?qe(e,t):!1;if(n=U(e),r=U(t),n||r){if(!n||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e){let r=e.hasOwnProperty(n),i=t.hasOwnProperty(n);if(r&&!i||!r&&i||!Je(e[n],t[n]))return!1}}return String(e)===String(t)}var Ye=e=>!!(e&&e.__v_isRef===!0),W=e=>H(e)?e:e==null?``:R(e)||U(e)&&(e.toString===de||!V(e.toString))?Ye(e)?W(e.value):JSON.stringify(e,Xe,2):String(e),Xe=(e,t)=>Ye(t)?Xe(e,t.value):z(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Ze(t,r)+` =>`]=n,e),{})}:ce(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Ze(e))}:le(t)?Ze(t):U(t)&&!R(t)&&!me(t)?String(t):t,Ze=(e,t=``)=>le(e)?`Symbol(${e.description??t})`:e;function Qe(e,...t){console.warn(`[Vue warn] ${e}`,...t)}var $e,et=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&$e&&($e.active?(this.parent=$e,this.index=($e.scopes||=[]).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){let t=$e;try{return $e=this,e()}finally{$e=t}}else process.env.NODE_ENV!==`production`&&this._warnOnRun&&Qe(`cannot run an inactive effect scope.`)}on(){++this._on===1&&(this.prevScope=$e,$e=this)}off(){if(this._on>0&&--this._on===0){if($e===this)$e=this.prevScope;else{let e=$e;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function tt(){return $e}function nt(e,t=!1){$e?$e.cleanups.push(e):process.env.NODE_ENV!==`production`&&!t&&Qe(`onScopeDispose() is called when there is no active effect scope to be associated with.`)}var rt,it=new WeakSet,at=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,$e&&($e.active?$e.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,it.has(this)&&(it.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||lt(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,St(this),ft(this);let e=rt,t=vt;rt=this,vt=!0;try{return this.fn()}finally{process.env.NODE_ENV!==`production`&&rt!==this&&Qe(`Active effect was not restored correctly - this is likely a Vue internal bug.`),pt(this),rt=e,vt=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)gt(e);this.deps=this.depsTail=void 0,St(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?it.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){mt(this)&&this.run()}get dirty(){return mt(this)}},ot=0,st,ct;function lt(e,t=!1){if(e.flags|=8,t){e.next=ct,ct=e;return}e.next=st,st=e}function ut(){ot++}function dt(){if(--ot>0)return;if(ct){let e=ct;for(ct=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;st;){let t=st;for(st=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function ft(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function pt(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),gt(r),_t(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function mt(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(ht(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function ht(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Ct)||(e.globalVersion=Ct,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!mt(e))))return;e.flags|=2;let t=e.dep,n=rt,r=vt;rt=e,vt=!0;try{ft(e);let n=e.fn(e._value);(t.version===0||Te(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{rt=n,vt=r,pt(e),e.flags&=-3}}function gt(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),process.env.NODE_ENV!==`production`&&n.subsHead===e&&(n.subsHead=i),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)gt(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function _t(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var vt=!0,yt=[];function bt(){yt.push(vt),vt=!1}function xt(){let e=yt.pop();vt=e===void 0||e}function St(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=rt;rt=void 0;try{t()}finally{rt=e}}}var Ct=0,wt=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},Tt=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0,process.env.NODE_ENV!==`production`&&(this.subsHead=void 0)}track(e){if(!rt||!vt||rt===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==rt)t=this.activeLink=new wt(rt,this),rt.deps?(t.prevDep=rt.depsTail,rt.depsTail.nextDep=t,rt.depsTail=t):rt.deps=rt.depsTail=t,Et(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=rt.depsTail,t.nextDep=void 0,rt.depsTail.nextDep=t,rt.depsTail=t,rt.deps===t&&(rt.deps=e)}return process.env.NODE_ENV!==`production`&&rt.onTrack&&rt.onTrack(I({effect:rt},e)),t}trigger(e){this.version++,Ct++,this.notify(e)}notify(e){ut();try{if(process.env.NODE_ENV!==`production`)for(let t=this.subsHead;t;t=t.nextSub)t.sub.onTrigger&&!(t.sub.flags&8)&&t.sub.onTrigger(I({effect:t.sub},e));for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{dt()}}};function Et(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)Et(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),process.env.NODE_ENV!==`production`&&e.dep.subsHead===void 0&&(e.dep.subsHead=e),e.dep.subs=e}}var Dt=new WeakMap,Ot=Symbol(process.env.NODE_ENV===`production`?``:`Object iterate`),kt=Symbol(process.env.NODE_ENV===`production`?``:`Map keys iterate`),At=Symbol(process.env.NODE_ENV===`production`?``:`Array iterate`);function jt(e,t,n){if(vt&&rt){let r=Dt.get(e);r||Dt.set(e,r=new Map);let i=r.get(n);i||(r.set(n,i=new Tt),i.map=r,i.key=n),process.env.NODE_ENV===`production`?i.track():i.track({target:e,type:t,key:n})}}function Mt(e,t,n,r,i,a){let o=Dt.get(e);if(!o){Ct++;return}let s=o=>{o&&(process.env.NODE_ENV===`production`?o.trigger():o.trigger({target:e,type:t,key:n,newValue:r,oldValue:i,oldTarget:a}))};if(ut(),t===`clear`)o.forEach(s);else{let i=R(e),a=i&&he(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===At||!le(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(At)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(Ot)),z(e)&&s(o.get(kt)));break;case`delete`:i||(s(o.get(Ot)),z(e)&&s(o.get(kt)));break;case`set`:z(e)&&s(o.get(Ot));break}}dt()}function Nt(e){let t=wn(e);return t===e?t:(jt(t,`iterate`,At),Sn(e)?t:t.map(En))}function Pt(e){return jt(e=wn(e),`iterate`,At),e}function Ft(e,t){return xn(e)?Dn(bn(e)?En(t):t):En(t)}var It={__proto__:null,[Symbol.iterator](){return Lt(this,Symbol.iterator,e=>Ft(this,e))},concat(...e){return Nt(this).concat(...e.map(e=>R(e)?Nt(e):e))},entries(){return Lt(this,`entries`,e=>(e[1]=Ft(this,e[1]),e))},every(e,t){return G(this,`every`,e,t,void 0,arguments)},filter(e,t){return G(this,`filter`,e,t,e=>e.map(e=>Ft(this,e)),arguments)},find(e,t){return G(this,`find`,e,t,e=>Ft(this,e),arguments)},findIndex(e,t){return G(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return G(this,`findLast`,e,t,e=>Ft(this,e),arguments)},findLastIndex(e,t){return G(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return G(this,`forEach`,e,t,void 0,arguments)},includes(...e){return Bt(this,`includes`,e)},indexOf(...e){return Bt(this,`indexOf`,e)},join(e){return Nt(this).join(e)},lastIndexOf(...e){return Bt(this,`lastIndexOf`,e)},map(e,t){return G(this,`map`,e,t,void 0,arguments)},pop(){return Vt(this,`pop`)},push(...e){return Vt(this,`push`,e)},reduce(e,...t){return zt(this,`reduce`,e,t)},reduceRight(e,...t){return zt(this,`reduceRight`,e,t)},shift(){return Vt(this,`shift`)},some(e,t){return G(this,`some`,e,t,void 0,arguments)},splice(...e){return Vt(this,`splice`,e)},toReversed(){return Nt(this).toReversed()},toSorted(e){return Nt(this).toSorted(e)},toSpliced(...e){return Nt(this).toSpliced(...e)},unshift(...e){return Vt(this,`unshift`,e)},values(){return Lt(this,`values`,e=>Ft(this,e))}};function Lt(e,t,n){let r=Pt(e),i=r[t]();return r!==e&&!Sn(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var Rt=Array.prototype;function G(e,t,n,r,i,a){let o=Pt(e),s=o!==e&&!Sn(e),c=o[t];if(c!==Rt[t]){let t=c.apply(e,a);return s?En(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,Ft(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function zt(e,t,n,r){let i=Pt(e),a=i!==e&&!Sn(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=Ft(e,t)),n.call(this,t,Ft(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?Ft(e,c):c}function Bt(e,t,n){let r=wn(e);jt(r,`iterate`,At);let i=r[t](...n);return(i===-1||i===!1)&&Cn(n[0])?(n[0]=wn(n[0]),r[t](...n)):i}function Vt(e,t,n=[]){bt(),ut();let r=wn(e)[t].apply(e,n);return dt(),xt(),r}var Ht=ne(`__proto__,__v_isRef,__isVue`),Ut=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(le));function Wt(e){le(e)||(e=String(e));let t=wn(this);return jt(t,`has`,e),t.hasOwnProperty(e)}var Gt=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?pn:fn:i?dn:un).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=R(e);if(!r){let e;if(a&&(e=It[t]))return e;if(t===`hasOwnProperty`)return Wt}let o=Reflect.get(e,t,On(e)?e:n);if((le(t)?Ut.has(t):Ht(t))||(r||jt(e,`get`,t),i))return o;if(On(o)){let e=a&&he(t)?o:o.value;return r&&U(e)?_n(e):e}return U(o)?r?_n(o):hn(o):o}},Kt=class extends Gt{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=R(e)&&he(t);if(!this._isShallow){let r=xn(i);if(!Sn(n)&&!xn(n)&&(i=wn(i),n=wn(n)),!a&&On(i)&&!On(n))return r?(process.env.NODE_ENV!==`production`&&Qe(`Set operation on key "${String(t)}" failed: target is readonly.`,e[t]),!0):(i.value=n,!0)}let o=a?Number(t)<e.length:L(e,t),s=Reflect.set(e,t,n,On(e)?e:r);return e===wn(r)&&s&&(o?Te(n,i)&&Mt(e,`set`,t,n,i):Mt(e,`add`,t,n)),s}deleteProperty(e,t){let n=L(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&Mt(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!le(t)||!Ut.has(t))&&jt(e,`has`,t),n}ownKeys(e){return jt(e,`iterate`,R(e)?`length`:Ot),Reflect.ownKeys(e)}},qt=class extends Gt{constructor(e=!1){super(!0,e)}set(e,t){return process.env.NODE_ENV!==`production`&&Qe(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0}deleteProperty(e,t){return process.env.NODE_ENV!==`production`&&Qe(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},Jt=new Kt,Yt=new qt,Xt=new Kt(!0),Zt=new qt(!0),Qt=e=>e,$t=e=>Reflect.getPrototypeOf(e);function en(e,t,n){return function(...r){let i=this.__v_raw,a=wn(i),o=z(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?Qt:t?Dn:En;return!t&&jt(a,`iterate`,c?kt:Ot),I(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function tn(e){return function(...t){if(process.env.NODE_ENV!==`production`){let n=t[0]?`on key "${t[0]}" `:``;Qe(`${Ce(e)} operation ${n}failed: target is readonly.`,wn(this))}return e===`delete`?!1:e===`clear`?void 0:this}}function nn(e,t){let n={get(n){let r=this.__v_raw,i=wn(r),a=wn(n);e||(Te(n,a)&&jt(i,`get`,n),jt(i,`get`,a));let{has:o}=$t(i),s=t?Qt:e?Dn:En;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&jt(wn(t),`iterate`,Ot),t.size},has(t){let n=this.__v_raw,r=wn(n),i=wn(t);return e||(Te(t,i)&&jt(r,`has`,t),jt(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=wn(a),s=t?Qt:e?Dn:En;return!e&&jt(o,`iterate`,Ot),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return I(n,e?{add:tn(`add`),set:tn(`set`),delete:tn(`delete`),clear:tn(`clear`)}:{add(e){let n=wn(this),r=$t(n),i=wn(e),a=!t&&!Sn(e)&&!xn(e)?i:e;return r.has.call(n,a)||Te(e,a)&&r.has.call(n,e)||Te(i,a)&&r.has.call(n,i)||(n.add(a),Mt(n,`add`,a,a)),this},set(e,n){!t&&!Sn(n)&&!xn(n)&&(n=wn(n));let r=wn(this),{has:i,get:a}=$t(r),o=i.call(r,e);o?process.env.NODE_ENV!==`production`&&ln(r,i,e):(e=wn(e),o=i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?Te(n,s)&&Mt(r,`set`,e,n,s):Mt(r,`add`,e,n),this},delete(e){let t=wn(this),{has:n,get:r}=$t(t),i=n.call(t,e);i?process.env.NODE_ENV!==`production`&&ln(t,n,e):(e=wn(e),i=n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&Mt(t,`delete`,e,void 0,a),o},clear(){let e=wn(this),t=e.size!==0,n=process.env.NODE_ENV===`production`?void 0:z(e)?new Map(e):new Set(e),r=e.clear();return t&&Mt(e,`clear`,void 0,void 0,n),r}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=en(r,e,t)}),n}function rn(e,t){let n=nn(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(L(n,r)&&r in t?n:t,r,i)}var an={get:rn(!1,!1)},on={get:rn(!1,!0)},sn={get:rn(!0,!1)},cn={get:rn(!0,!0)};function ln(e,t,n){let r=wn(n);if(r!==n&&t.call(e,r)){let t=pe(e);Qe(`Reactive ${t} contains both the raw and reactive versions of the same object${t===`Map`?` as keys`:``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}var un=new WeakMap,dn=new WeakMap,fn=new WeakMap,pn=new WeakMap;function mn(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function hn(e){return xn(e)?e:yn(e,!1,Jt,an,un)}function gn(e){return yn(e,!1,Xt,on,dn)}function _n(e){return yn(e,!0,Yt,sn,fn)}function vn(e){return yn(e,!0,Zt,cn,pn)}function yn(e,t,n,r,i){if(!U(e))return process.env.NODE_ENV!==`production`&&Qe(`value cannot be made ${t?`readonly`:`reactive`}: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=mn(pe(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function bn(e){return xn(e)?bn(e.__v_raw):!!(e&&e.__v_isReactive)}function xn(e){return!!(e&&e.__v_isReadonly)}function Sn(e){return!!(e&&e.__v_isShallow)}function Cn(e){return e?!!e.__v_raw:!1}function wn(e){let t=e&&e.__v_raw;return t?wn(t):e}function Tn(e){return!L(e,`__v_skip`)&&Object.isExtensible(e)&&De(e,`__v_skip`,!0),e}var En=e=>U(e)?hn(e):e,Dn=e=>U(e)?_n(e):e;function On(e){return e?e.__v_isRef===!0:!1}function kn(e){return jn(e,!1)}function An(e){return jn(e,!0)}function jn(e,t){return On(e)?e:new Mn(e,t)}var Mn=class{constructor(e,t){this.dep=new Tt,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:wn(e),this._value=t?e:En(e),this.__v_isShallow=t}get value(){return process.env.NODE_ENV===`production`?this.dep.track():this.dep.track({target:this,type:`get`,key:`value`}),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||Sn(e)||xn(e);e=n?e:wn(e),Te(e,t)&&(this._rawValue=e,this._value=n?e:En(e),process.env.NODE_ENV===`production`?this.dep.trigger():this.dep.trigger({target:this,type:`set`,key:`value`,newValue:e,oldValue:t}))}};function Nn(e){e.dep&&(process.env.NODE_ENV===`production`?e.dep.trigger():e.dep.trigger({target:e,type:`set`,key:`value`,newValue:e._value}))}function K(e){return On(e)?e.value:e}var Pn={get:(e,t,n)=>t===`__v_raw`?e:K(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return On(i)&&!On(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function Fn(e){return bn(e)?e:new Proxy(e,Pn)}var In=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new Tt(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Ct-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&rt!==this)return lt(this,!0),!0;process.env.NODE_ENV}get value(){let e=process.env.NODE_ENV===`production`?this.dep.track():this.dep.track({target:this,type:`get`,key:`value`});return ht(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter?this.setter(e):process.env.NODE_ENV!==`production`&&Qe(`Write operation failed: computed value is readonly`)}};function Ln(e,t,n=!1){let r,i;V(e)?r=e:(r=e.get,i=e.set);let a=new In(r,i,n);return process.env.NODE_ENV!==`production`&&t&&!n&&(a.onTrack=t.onTrack,a.onTrigger=t.onTrigger),a}var Rn={},zn=new WeakMap,Bn=void 0;function Vn(e,t=!1,n=Bn){if(n){let t=zn.get(n);t||zn.set(n,t=[]),t.push(e)}else process.env.NODE_ENV!==`production`&&!t&&Qe(`onWatcherCleanup() was called when there was no active watcher to associate with.`)}function Hn(e,t,n=N){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>{(n.onWarn||Qe)(`Invalid watch source: `,e,`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`)},u=e=>i?e:Sn(e)||i===!1||i===0?Un(e,1):Un(e),d,f,p,m,h=!1,g=!1;if(On(e)?(f=()=>e.value,h=Sn(e)):bn(e)?(f=()=>u(e),h=!0):R(e)?(g=!0,h=e.some(e=>bn(e)||Sn(e)),f=()=>e.map(e=>{if(On(e))return e.value;if(bn(e))return u(e);if(V(e))return c?c(e,2):e();process.env.NODE_ENV!==`production`&&l(e)})):V(e)?f=t?c?()=>c(e,2):e:()=>{if(p){bt();try{p()}finally{xt()}}let t=Bn;Bn=d;try{return c?c(e,3,[m]):e(m)}finally{Bn=t}}:(f=F,process.env.NODE_ENV!==`production`&&l(e)),t&&i){let e=f,t=i===!0?1/0:i;f=()=>Un(e(),t)}let _=tt(),v=()=>{d.stop(),_&&_.active&&oe(_.effects,d)};if(a&&t){let e=t;t=(...t)=>{let n=e(...t);return v(),n}}let y=g?Array(e.length).fill(Rn):Rn,b=e=>{if(!(!(d.flags&1)||!d.dirty&&!e))if(t){let n=d.run();if(e||i||h||(g?n.some((e,t)=>Te(e,y[t])):Te(n,y))){p&&p();let e=Bn;Bn=d;try{let e=[n,y===Rn?void 0:g&&y[0]===Rn?[]:y,m];y=n,c?c(t,3,e):t(...e)}finally{Bn=e}}}else d.run()};return s&&s(b),d=new at(f),d.scheduler=o?()=>o(b,!1):b,m=e=>Vn(e,!1,d),p=d.onStop=()=>{let e=zn.get(d);if(e){if(c)c(e,4);else for(let t of e)t();zn.delete(d)}},process.env.NODE_ENV!==`production`&&(d.onTrack=n.onTrack,d.onTrigger=n.onTrigger),t?r?b(!0):y=d.run():o?o(b.bind(null,!0),!0):d.run(),v.pause=d.pause.bind(d),v.resume=d.resume.bind(d),v.stop=v,v}function Un(e,t=1/0,n){if(t<=0||!U(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,On(e))Un(e.value,t,n);else if(R(e))for(let r=0;r<e.length;r++)Un(e[r],t,n);else if(ce(e)||z(e))e.forEach(e=>{Un(e,t,n)});else if(me(e)){for(let r in e)Un(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Un(e[r],t,n)}return e}var Wn=[];function Gn(e){Wn.push(e)}function Kn(){Wn.pop()}var qn=!1;function q(e,...t){if(qn)return;qn=!0,bt();let n=Wn.length?Wn[Wn.length-1].component:null,r=n&&n.appContext.config.warnHandler,i=Jn();if(r)tr(r,n,11,[e+t.map(e=>e.toString?.call(e)??JSON.stringify(e)).join(``),n&&n.proxy,i.map(({vnode:e})=>`at <${nc(n,e.type)}>`).join(`
|
|
2
2
|
`),i]);else{let n=[`[Vue warn]: ${e}`,...t];i.length&&n.push(`
|
|
3
3
|
`,...Yn(i)),console.warn(...n)}xt(),qn=!1}function Jn(){let e=Wn[Wn.length-1];if(!e)return[];let t=[];for(;e;){let n=t[0];n&&n.vnode===e?n.recurseCount++:t.push({vnode:e,recurseCount:0});let r=e.component&&e.component.parent;e=r&&r.vnode}return t}function Yn(e){let t=[];return e.forEach((e,n)=>{t.push(...n===0?[]:[`
|
|
4
4
|
`],...Xn(e))}),t}function Xn({vnode:e,recurseCount:t}){let n=t>0?`... (${t} recursive calls)`:``,r=e.component?e.component.parent==null:!1,i=` at <${nc(e.component,e.type,r)}`,a=`>`+n;return e.props?[i,...Zn(e.props),a]:[i+a]}function Zn(e){let t=[],n=Object.keys(e);return n.slice(0,3).forEach(n=>{t.push(...Qn(n,e[n]))}),n.length>3&&t.push(` ...`),t}function Qn(e,t,n){return H(t)?(t=JSON.stringify(t),n?t:[`${e}=${t}`]):typeof t==`number`||typeof t==`boolean`||t==null?n?t:[`${e}=${t}`]:On(t)?(t=Qn(e,wn(t.value),!0),n?t:[`${e}=Ref<`,t,`>`]):V(t)?[`${e}=fn${t.name?`<${t.name}>`:``}`]:(t=wn(t),n?t:[`${e}=`,t])}function $n(e,t){process.env.NODE_ENV!==`production`&&e!==void 0&&(typeof e==`number`?isNaN(e)&&q(`${t} is NaN - the duration expression might be incorrect.`):q(`${t} is not a valid number - got ${JSON.stringify(e)}.`))}var er={sp:`serverPrefetch hook`,bc:`beforeCreate hook`,c:`created hook`,bm:`beforeMount hook`,m:`mounted hook`,bu:`beforeUpdate hook`,u:`updated`,bum:`beforeUnmount hook`,um:`unmounted hook`,a:`activated hook`,da:`deactivated hook`,ec:`errorCaptured hook`,rtc:`renderTracked hook`,rtg:`renderTriggered hook`,0:`setup function`,1:`render function`,2:`watcher getter`,3:`watcher callback`,4:`watcher cleanup function`,5:`native event handler`,6:`component event handler`,7:`vnode hook`,8:`directive hook`,9:`transition hook`,10:`app errorHandler`,11:`app warnHandler`,12:`ref function`,13:`async component loader`,14:`scheduler flush`,15:`component update`,16:`app unmount cleanup function`};function tr(e,t,n,r){try{return r?e(...r):e()}catch(e){rr(e,t,n)}}function nr(e,t,n,r){if(V(e)){let i=tr(e,t,n,r);return i&&ue(i)&&i.catch(e=>{rr(e,t,n)}),i}if(R(e)){let i=[];for(let a=0;a<e.length;a++)i.push(nr(e[a],t,n,r));return i}else process.env.NODE_ENV!==`production`&&q(`Invalid value type passed to callWithAsyncErrorHandling(): ${typeof e}`)}function rr(e,t,n,r=!0){let i=t?t.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||N;if(t){let r=t.parent,i=t.proxy,o=process.env.NODE_ENV===`production`?`https://vuejs.org/error-reference/#runtime-${n}`:er[n];for(;r;){let t=r.ec;if(t){for(let n=0;n<t.length;n++)if(t[n](e,i,o)===!1)return}r=r.parent}if(a){bt(),tr(a,null,10,[e,i,o]),xt();return}}ir(e,n,i,r,o)}function ir(e,t,n,r=!0,i=!1){if(process.env.NODE_ENV!==`production`){let i=er[t];if(n&&Gn(n),q(`Unhandled error${i?` during execution of ${i}`:``}`),n&&Kn(),r)throw e;console.error(e)}else if(i)throw e;else console.error(e)}var ar=[],or=-1,sr=[],cr=null,lr=0,ur=Promise.resolve(),dr=null,fr=100;function pr(e){let t=dr||ur;return e?t.then(this?e.bind(this):e):t}function mr(e){let t=or+1,n=ar.length;for(;t<n;){let r=t+n>>>1,i=ar[r],a=br(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function hr(e){if(!(e.flags&1)){let t=br(e),n=ar[ar.length-1];!n||!(e.flags&2)&&t>=br(n)?ar.push(e):ar.splice(mr(t),0,e),e.flags|=1,gr()}}function gr(){dr||=ur.then(xr)}function _r(e){R(e)?sr.push(...e):cr&&e.id===-1?cr.splice(lr+1,0,e):e.flags&1||(sr.push(e),e.flags|=1),gr()}function vr(e,t,n=or+1){for(process.env.NODE_ENV!==`production`&&(t||=new Map);n<ar.length;n++){let r=ar[n];if(r&&r.flags&2){if(e&&r.id!==e.uid||process.env.NODE_ENV!==`production`&&Sr(t,r))continue;ar.splice(n,1),n--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function yr(e){if(sr.length){let t=[...new Set(sr)].sort((e,t)=>br(e)-br(t));if(sr.length=0,cr){cr.push(...t);return}for(cr=t,process.env.NODE_ENV!==`production`&&(e||=new Map),lr=0;lr<cr.length;lr++){let t=cr[lr];process.env.NODE_ENV!==`production`&&Sr(e,t)||(t.flags&4&&(t.flags&=-2),t.flags&8||t(),t.flags&=-2)}cr=null,lr=0}}var br=e=>e.id==null?e.flags&2?-1:1/0:e.id;function xr(e){process.env.NODE_ENV!==`production`&&(e||=new Map);let t=process.env.NODE_ENV===`production`?F:t=>Sr(e,t);try{for(or=0;or<ar.length;or++){let e=ar[or];if(e&&!(e.flags&8)){if(process.env.NODE_ENV!==`production`&&t(e))continue;e.flags&4&&(e.flags&=-2),tr(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2)}}}finally{for(;or<ar.length;or++){let e=ar[or];e&&(e.flags&=-2)}or=-1,ar.length=0,yr(e),dr=null,(ar.length||sr.length)&&xr(e)}}function Sr(e,t){let n=e.get(t)||0;if(n>fr){let e=t.i,n=e&&tc(e.type);return rr(`Maximum recursive updates exceeded${n?` in component <${n}>`:``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,null,10),!0}return e.set(t,n+1),!1}var Cr=!1,wr=e=>{try{return Cr}finally{Cr=e}},Tr=new Map;process.env.NODE_ENV!==`production`&&(je().__VUE_HMR_RUNTIME__={createRecord:Pr(kr),rerender:Pr(jr),reload:Pr(Mr)});var Er=new Map;function Dr(e){let t=e.type.__hmrId,n=Er.get(t);n||=(kr(t,e.type),Er.get(t)),n.instances.add(e)}function Or(e){Er.get(e.type.__hmrId).instances.delete(e)}function kr(e,t){return Er.has(e)?!1:(Er.set(e,{initialDef:Ar(t),instances:new Set}),!0)}function Ar(e){return rc(e)?e.__vccOpts:e}function jr(e,t){let n=Er.get(e);n&&(n.initialDef.render=t,[...n.instances].forEach(e=>{t&&(e.render=t,Ar(e.type).render=t),e.renderCache=[],Cr=!0,e.job.flags&8||e.update(),Cr=!1}))}function Mr(e,t){let n=Er.get(e);if(!n)return;t=Ar(t),Nr(n.initialDef,t);let r=[...n.instances];for(let e=0;e<r.length;e++){let i=r[e],a=Ar(i.type),o=Tr.get(a);o||(a!==n.initialDef&&Nr(a,t),Tr.set(a,o=new Set)),o.add(i),i.appContext.propsCache.delete(i.type),i.appContext.emitsCache.delete(i.type),i.appContext.optionsCache.delete(i.type),i.ceReload?(o.add(i),i.ceReload(t.styles),o.delete(i)):i.parent?hr(()=>{i.job.flags&8||(Cr=!0,i.parent.update(),Cr=!1,o.delete(i))}):i.appContext.reload?i.appContext.reload():typeof window<`u`?window.location.reload():console.warn(`[HMR] Root or manually mounted instance modified. Full reload required.`),i.root.ce&&i!==i.root&&i.root.ce._removeChildStyle(a)}_r(()=>{Tr.clear()})}function Nr(e,t){I(e,t);for(let n in e)n!==`__file`&&!(n in t)&&delete e[n]}function Pr(e){return(t,n)=>{try{return e(t,n)}catch(e){console.error(e),console.warn(`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`)}}}var Fr,Ir=[],Lr=!1;function Rr(e,...t){Fr?Fr.emit(e,...t):Lr||Ir.push({event:e,args:t})}function zr(e,t){Fr=e,Fr?(Fr.enabled=!0,Ir.forEach(({event:e,args:t})=>Fr.emit(e,...t)),Ir=[]):typeof window<`u`&&window.HTMLElement&&!(window.navigator?.userAgent)?.includes(`jsdom`)?((t.__VUE_DEVTOOLS_HOOK_REPLAY__=t.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push(e=>{zr(e,t)}),setTimeout(()=>{Fr||(t.__VUE_DEVTOOLS_HOOK_REPLAY__=null,Lr=!0,Ir=[])},3e3)):(Lr=!0,Ir=[])}function Br(e,t){Rr(`app:init`,e,t,{Fragment:J,Text:ns,Comment:rs,Static:is})}function Vr(e){Rr(`app:unmount`,e)}var Hr=Kr(`component:added`),Ur=Kr(`component:updated`),Wr=Kr(`component:removed`),Gr=e=>{Fr&&typeof Fr.cleanupBuffer==`function`&&!Fr.cleanupBuffer(e)&&Wr(e)};function Kr(e){return t=>{Rr(e,t.appContext.app,t.uid,t.parent?t.parent.uid:void 0,t)}}var qr=Yr(`perf:start`),Jr=Yr(`perf:end`);function Yr(e){return(t,n,r)=>{Rr(e,t.appContext.app,t.uid,t,n,r)}}function Xr(e,t,n){Rr(`component:emit`,e.appContext.app,e,t,n)}var Zr=null,Qr=null;function $r(e){let t=Zr;return Zr=e,Qr=e&&e.type.__scopeId||null,t}function ei(e,t=Zr,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&ls(-1);let i=$r(t),a;try{a=e(...n)}finally{$r(i),r._d&&ls(1)}return process.env.NODE_ENV!==`production`&&Ur(t),a};return r._n=!0,r._c=!0,r._d=!0,r}function ti(e){_e(e)&&q(`Do not use built-in directive ids as custom directive id: `+e)}function ni(e,t){if(Zr===null)return process.env.NODE_ENV!==`production`&&q(`withDirectives can only be used inside render functions.`),e;let n=Qs(Zr),r=e.dirs||=[];for(let e=0;e<t.length;e++){let[i,a,o,s=N]=t[e];i&&(V(i)&&(i={mounted:i,updated:i}),i.deep&&Un(a),r.push({dir:i,instance:n,value:a,oldValue:void 0,arg:o,modifiers:s}))}return e}function ri(e,t,n,r){let i=e.dirs,a=t&&t.dirs;for(let o=0;o<i.length;o++){let s=i[o];a&&(s.oldValue=a[o].value);let c=s.dir[r];c&&(bt(),nr(c,n,8,[e.el,s,e,t]),xt())}}function ii(e,t){if(process.env.NODE_ENV!==`production`&&(!Ms||Ms.isMounted)&&q(`provide() can only be used inside setup().`),Ms){let n=Ms.provides,r=Ms.parent&&Ms.parent.provides;r===n&&(n=Ms.provides=Object.create(r)),n[e]=t}}function ai(e,t,n=!1){let r=Ns();if(r||Wa){let i=Wa?Wa._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(i&&e in i)return i[e];if(arguments.length>1)return n&&V(t)?t.call(r&&r.proxy):t;process.env.NODE_ENV!==`production`&&q(`injection "${String(e)}" not found.`)}else process.env.NODE_ENV!==`production`&&q(`inject() can only be used inside setup() or functional components.`)}var oi=Symbol.for(`v-scx`),si=()=>{{let e=ai(oi);return e||process.env.NODE_ENV!==`production`&&q(`Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`),e}};function ci(e,t,n){return process.env.NODE_ENV!==`production`&&!V(t)&&q("`watch(fn, options?)` signature has been moved to a separate API. Use `watchEffect(fn, options?)` instead. `watch` now only supports `watch(source, cb, options?) signature."),li(e,t,n)}function li(e,t,n=N){let{immediate:r,deep:i,flush:a,once:o}=n;process.env.NODE_ENV!==`production`&&!t&&(r!==void 0&&q(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`),i!==void 0&&q(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`),o!==void 0&&q(`watch() "once" option is only respected when using the watch(source, callback, options?) signature.`));let s=I({},n);process.env.NODE_ENV!==`production`&&(s.onWarn=q);let c=t&&r||!t&&a!==`post`,l;if(Vs){if(a===`sync`){let e=si();l=e.__watcherHandles||=[]}else if(!c){let e=()=>{};return e.stop=F,e.resume=F,e.pause=F,e}}let u=Ms;s.call=(e,t,n)=>nr(e,u,t,n);let d=!1;a===`post`?s.scheduler=e=>{Uo(e,u&&u.suspense)}:a!==`sync`&&(d=!0,s.scheduler=(e,t)=>{t?e():hr(e)}),s.augmentJob=e=>{t&&(e.flags|=4),d&&(e.flags|=2,u&&(e.id=u.uid,e.i=u))};let f=Hn(e,t,s);return Vs&&(l?l.push(f):c&&f()),f}function ui(e,t,n){let r=this.proxy,i=H(e)?e.includes(`.`)?di(r,e):()=>r[e]:e.bind(r,r),a;V(t)?a=t:(a=t.handler,n=t);let o=Is(this),s=li(i,a.bind(r),n);return o(),s}function di(e,t){let n=t.split(`.`);return()=>{let t=e;for(let e=0;e<n.length&&t;e++)t=t[n[e]];return t}}var fi=new WeakMap,pi=Symbol(`_vte`),mi=e=>e.__isTeleport,hi=e=>e&&(e.disabled||e.disabled===``),gi=e=>e&&(e.defer||e.defer===``),_i=e=>typeof SVGElement<`u`&&e instanceof SVGElement,vi=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,yi=(e,t)=>{let n=e&&e.to;if(H(n))if(t){let r=t(n);return process.env.NODE_ENV!==`production`&&!r&&!hi(e)&&q(`Failed to locate Teleport target with selector "${n}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`),r}else return process.env.NODE_ENV!==`production`&&q(`Current renderer does not support string target for Teleports. (missing querySelector renderer option)`),null;else return process.env.NODE_ENV!==`production`&&!n&&!hi(e)&&q(`Invalid Teleport target: ${n}`),n},bi={name:`Teleport`,__isTeleport:!0,process(e,t,n,r,i,a,o,s,c,l){let{mc:u,pc:d,pbc:f,o:{insert:p,querySelector:m,createText:h,createComment:g,parentNode:_}}=l,v=hi(t.props),{dynamicChildren:y}=t;process.env.NODE_ENV!==`production`&&Cr&&(c=!1,y=null);let b=(e,t,n)=>{e.shapeFlag&16&&u(e.children,t,n,i,a,o,s,c)},x=(e=t)=>{let n=hi(e.props),r=e.target=yi(e.props,m),a=Ti(r,e,h,p);r?(o!==`svg`&&_i(r)?o=`svg`:o!==`mathml`&&vi(r)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(r),n||(b(e,r,a),wi(e,!1))):process.env.NODE_ENV!==`production`&&!n&&q(`Invalid Teleport target on mount:`,r,`(${typeof r})`)},S=e=>{let t=()=>{if(fi.get(e)===t){if(fi.delete(e),hi(e.props)){let t=_(e.el)||n;b(e,t,e.anchor),wi(e,!0)}x(e)}};fi.set(e,t),Uo(t,a)};if(e==null){let e=t.el=process.env.NODE_ENV===`production`?h(``):g(`teleport start`),i=t.anchor=process.env.NODE_ENV===`production`?h(``):g(`teleport end`);if(p(e,n,r),p(i,n,r),gi(t.props)||a&&a.pendingBranch){S(t);return}v&&(b(t,n,i),wi(t,!0)),x()}else{t.el=e.el;let r=t.anchor=e.anchor,u=fi.get(e);if(u){u.flags|=8,fi.delete(e),S(t);return}t.targetStart=e.targetStart;let p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=hi(e.props),_=g?n:p,b=g?r:h;if(o===`svg`||_i(p)?o=`svg`:(o===`mathml`||vi(p))&&(o=`mathml`),y?(f(e.dynamicChildren,y,_,i,a,o,s),Yo(e,t,process.env.NODE_ENV===`production`)):c||d(e,t,_,b,i,a,o,s,!1),v)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):xi(t,n,r,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=yi(t.props,m);e?(t.target=e,xi(t,e,null,l,0)):process.env.NODE_ENV!==`production`&&q(`Invalid Teleport target on update:`,p,`(${typeof p})`)}else g&&xi(t,p,h,l,1);wi(t,v)}},remove(e,t,n,{um:r,o:{remove:i}},a){let{shapeFlag:o,children:s,anchor:c,targetStart:l,targetAnchor:u,target:d,props:f}=e,p=hi(f),m=a||!p,h=fi.get(e);if(h&&(h.flags|=8,fi.delete(e)),d&&(i(l),i(u)),a&&i(c),!h&&(p||d)&&o&16)for(let e=0;e<s.length;e++){let i=s[e];r(i,t,n,m,!!i.dynamicChildren)}},move:xi,hydrate:Si};function xi(e,t,n,{o:{insert:r},m:i},a=2){a===0&&r(e.targetAnchor,t,n);let{el:o,anchor:s,shapeFlag:c,children:l,props:u}=e,d=a===2;if(d&&r(o,t,n),!fi.has(e)&&(!d||hi(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function Si(e,t,n,r,i,a,{o:{nextSibling:o,parentNode:s,querySelector:c,insert:l,createText:u}},d){function f(e,n){let r=n;for(;r;){if(r&&r.nodeType===8){if(r.data===`teleport start anchor`)t.targetStart=r;else if(r.data===`teleport anchor`){t.targetAnchor=r,e._lpa=t.targetAnchor&&o(t.targetAnchor);break}}r=o(r)}}function p(e,t){t.anchor=d(o(e),t,s(e),n,r,i,a)}let m=t.target=yi(t.props,c),h=hi(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||Ti(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||Ti(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),wi(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var Ci=bi;function wi(e,t){let n=e.ctx;if(n&&n.ut){let r,i;for(t?(r=e.el,i=e.anchor):(r=e.targetStart,i=e.targetAnchor);r&&r!==i;)r.nodeType===1&&r.setAttribute(`data-v-owner`,n.uid),r=r.nextSibling;n.ut()}}function Ti(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[pi]=o,e&&(r(a,e,i),r(o,e,i)),o}var Ei=Symbol(`_leaveCb`),Di=Symbol(`_enterCb`);function Oi(){let e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return ra(()=>{e.isMounted=!0}),oa(()=>{e.isUnmounting=!0}),e}var ki=[Function,Array],Ai={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:ki,onEnter:ki,onAfterEnter:ki,onEnterCancelled:ki,onBeforeLeave:ki,onLeave:ki,onAfterLeave:ki,onLeaveCancelled:ki,onBeforeAppear:ki,onAppear:ki,onAfterAppear:ki,onAppearCancelled:ki},ji=e=>{let t=e.subTree;return t.component?ji(t.component):t},Mi={name:`BaseTransition`,props:Ai,setup(e,{slots:t}){let n=Ns(),r=Oi();return()=>{let i=t.default&&Bi(t.default(),!0),a=i&&i.length?Ni(i):n.subTree?Q():void 0;if(!a)return;let o=wn(e),{mode:s}=o;if(process.env.NODE_ENV!==`production`&&s&&s!==`in-out`&&s!==`out-in`&&s!=="default"&&q(`invalid <transition> mode: ${s}`),r.isLeaving)return Li(a);let c=Ri(a);if(!c)return Li(a);let l=Ii(c,o,r,n,e=>l=e);c.type!==rs&&zi(c,l);let u=n.subTree&&Ri(n.subTree);if(u&&u.type!==rs&&!ps(u,c)&&ji(n).type!==rs){let e=Ii(u,o,r,n);if(zi(u,e),s===`out-in`&&c.type!==rs)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete e.afterLeave,u=void 0},Li(a);s===`in-out`&&c.type!==rs?e.delayLeave=(e,t,n)=>{let i=Fi(r,u);i[String(u.key)]=u,e[Ei]=()=>{t(),e[Ei]=void 0,delete l.delayedLeave,u=void 0},l.delayedLeave=()=>{n(),delete l.delayedLeave,u=void 0}}:u=void 0}else u&&=void 0;return a}}};function Ni(e){let t=e[0];if(e.length>1){let n=!1;for(let r of e)if(r.type!==rs){if(process.env.NODE_ENV!==`production`&&n){q(`<transition> can only be used on a single element or component. Use <transition-group> for lists.`);break}if(t=r,n=!0,process.env.NODE_ENV===`production`)break}}return t}var Pi=Mi;function Fi(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function Ii(e,t,n,r,i){let{appear:a,mode:o,persisted:s=!1,onBeforeEnter:c,onEnter:l,onAfterEnter:u,onEnterCancelled:d,onBeforeLeave:f,onLeave:p,onAfterLeave:m,onLeaveCancelled:h,onBeforeAppear:g,onAppear:_,onAfterAppear:v,onAppearCancelled:y}=t,b=String(e.key),x=Fi(n,e),S=(e,t)=>{e&&nr(e,r,9,t)},C=(e,t)=>{let n=t[1];S(e,t),R(e)?e.every(e=>e.length<=1)&&n():e.length<=1&&n()},w={mode:o,persisted:s,beforeEnter(t){let r=c;if(!n.isMounted)if(a)r=g||c;else return;t[Ei]&&t[Ei](!0);let i=x[b];i&&ps(e,i)&&i.el[Ei]&&i.el[Ei](),S(r,[t])},enter(t){if(!Cr&&x[b]===e)return;let r=l,i=u,o=d;if(!n.isMounted)if(a)r=_||l,i=v||u,o=y||d;else return;let s=!1;t[Di]=e=>{s||(s=!0,S(e?o:i,[t]),w.delayedLeave&&w.delayedLeave(),t[Di]=void 0)};let c=t[Di].bind(null,!1);r?C(r,[t,c]):c()},leave(t,r){let i=String(e.key);if(t[Di]&&t[Di](!0),n.isUnmounting)return r();S(f,[t]);let a=!1;t[Ei]=n=>{a||(a=!0,r(),S(n?h:m,[t]),t[Ei]=void 0,x[i]===e&&delete x[i])};let o=t[Ei].bind(null,!1);x[i]=e,p?C(p,[t,o]):o()},clone(e){let a=Ii(e,t,n,r,i);return i&&i(a),a}};return w}function Li(e){if(Yi(e))return e=xs(e),e.children=null,e}function Ri(e){if(!Yi(e))return mi(e.type)&&e.children?Ni(e.children):e;if(e.component)return e.component.subTree;let{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&V(n.default))return n.default()}}function zi(e,t){e.shapeFlag&6&&e.component?(e.transition=t,zi(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function Bi(e,t=!1,n){let r=[],i=0;for(let a=0;a<e.length;a++){let o=e[a],s=n==null?o.key:String(n)+String(o.key==null?a:o.key);o.type===J?(o.patchFlag&128&&i++,r=r.concat(Bi(o.children,t,s))):(t||o.type!==rs)&&r.push(s==null?o:xs(o,{key:s}))}if(i>1)for(let e=0;e<r.length;e++)r[e].patchFlag=-2;return r}function Vi(e,t){return V(e)?I({name:e.name},t,{setup:e}):e}function Hi(e){e.ids=[e.ids[0]+e.ids[2]+++`-`,0,0]}var Ui=new WeakSet;function Wi(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var Gi=new WeakMap;function Ki(e,t,n,r,i=!1){if(R(e)){e.forEach((e,a)=>Ki(e,t&&(R(t)?t[a]:t),n,r,i));return}if(Ji(r)&&!i){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&Ki(e,t,n,r.component.subTree);return}let a=r.shapeFlag&4?Qs(r.component):r.el,o=i?null:a,{i:s,r:c}=e;if(process.env.NODE_ENV!==`production`&&!s){q(`Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`);return}let l=t&&t.r,u=s.refs===N?s.refs={}:s.refs,d=s.setupState,f=wn(d),p=d===N?re:e=>process.env.NODE_ENV!==`production`&&(L(f,e)&&!On(f[e])&&q(`Template ref "${e}" used on a non-ref value. It will not work in the production build.`),Ui.has(f[e]))||Wi(u,e)?!1:L(f,e),m=(e,t)=>!(process.env.NODE_ENV!==`production`&&Ui.has(e)||t&&Wi(u,t));if(l!=null&&l!==c){if(qi(t),H(l))u[l]=null,p(l)&&(d[l]=null);else if(On(l)){let e=t;m(l,e.k)&&(l.value=null),e.k&&(u[e.k]=null)}}if(V(c)){bt();try{tr(c,s,12,[o,u])}finally{xt()}}else{let t=H(c),r=On(c);if(t||r){let s=()=>{if(e.f){let n=t?p(c)?d[c]:u[c]:m(c)||!e.k?c.value:u[e.k];if(i)R(n)&&oe(n,a);else if(R(n))n.includes(a)||n.push(a);else if(t)u[c]=[a],p(c)&&(d[c]=u[c]);else{let t=[a];m(c,e.k)&&(c.value=t),e.k&&(u[e.k]=t)}}else t?(u[c]=o,p(c)&&(d[c]=o)):r?(m(c,e.k)&&(c.value=o),e.k&&(u[e.k]=o)):process.env.NODE_ENV!==`production`&&q(`Invalid template ref type:`,c,`(${typeof c})`)};if(o){let t=()=>{s(),Gi.delete(e)};t.id=-1,Gi.set(e,t),Uo(t,n)}else qi(e),s()}else process.env.NODE_ENV!==`production`&&q(`Invalid template ref type:`,c,`(${typeof c})`)}}function qi(e){let t=Gi.get(e);t&&(t.flags|=8,Gi.delete(e))}je().requestIdleCallback,je().cancelIdleCallback;var Ji=e=>!!e.type.__asyncLoader,Yi=e=>e.type.__isKeepAlive;function Xi(e,t){Qi(e,`a`,t)}function Zi(e,t){Qi(e,`da`,t)}function Qi(e,t,n=Ms){let r=e.__wdc||=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()};if(ea(t,r,n),n){let e=n.parent;for(;e&&e.parent;)Yi(e.parent.vnode)&&$i(r,t,n,e),e=e.parent}}function $i(e,t,n,r){let i=ea(t,e,r,!0);sa(()=>{oe(r[t],i)},n)}function ea(e,t,n=Ms,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{bt();let i=Is(n),a=nr(t,n,e,r);return i(),xt(),a};return r?i.unshift(a):i.push(a),a}else process.env.NODE_ENV!==`production`&&q(`${we(er[e].replace(/ hook$/,``))} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`)}var ta=e=>(t,n=Ms)=>{(!Vs||e===`sp`)&&ea(e,(...e)=>t(...e),n)},na=ta(`bm`),ra=ta(`m`),ia=ta(`bu`),aa=ta(`u`),oa=ta(`bum`),sa=ta(`um`),ca=ta(`sp`),la=ta(`rtg`),ua=ta(`rtc`);function da(e,t=Ms){ea(`ec`,e,t)}var fa=Symbol.for(`v-ndc`);function pa(e,t,n,r){let i,a=n&&n[r],o=R(e);if(o||H(e)){let n=o&&bn(e),r=!1,s=!1;n&&(r=!Sn(e),s=xn(e),e=Pt(e)),i=Array(e.length);for(let n=0,o=e.length;n<o;n++)i[n]=t(r?s?Dn(En(e[n])):En(e[n]):e[n],n,void 0,a&&a[n])}else if(typeof e==`number`)if(process.env.NODE_ENV!==`production`&&(!Number.isInteger(e)||e<0))q(`The v-for range expects a positive integer value but got ${e}.`),i=[];else{i=Array(e);for(let n=0;n<e;n++)i[n]=t(n+1,n,void 0,a&&a[n])}else if(U(e))if(e[Symbol.iterator])i=Array.from(e,(e,n)=>t(e,n,void 0,a&&a[n]));else{let n=Object.keys(e);i=Array(n.length);for(let r=0,o=n.length;r<o;r++){let o=n[r];i[r]=t(e[o],o,r,a&&a[r])}}else i=[];return n&&(n[r]=i),i}function ma(e,t,n={},r,i){if(Zr.ce||Zr.parent&&Ji(Zr.parent)&&Zr.parent.ce){let e=Object.keys(n).length>0;return t!=="default"&&(n.name=t),Y(),ds(J,null,[vs(`slot`,n,r&&r())],e?-2:64)}let a=e[t];process.env.NODE_ENV!==`production`&&a&&a.length>1&&(q(`SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`),a=()=>[]),a&&a._c&&(a._d=!1),Y();let o=a&&ha(a(n)),s=n.key||o&&o.key,c=ds(J,{key:(s&&!le(s)?s:`_${t}`)+(!o&&r?`_fb`:``)},o||(r?r():[]),o&&e._===1?64:-2);return!i&&c.scopeId&&(c.slotScopeIds=[c.scopeId+`-s`]),a&&a._c&&(a._d=!0),c}function ha(e){return e.some(e=>!fs(e)||!(e.type===rs||e.type===J&&!ha(e.children)))?e:null}var ga=e=>e?Bs(e)?Qs(e):ga(e.parent):null,_a=I(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>process.env.NODE_ENV===`production`?e.props:vn(e.props),$attrs:e=>process.env.NODE_ENV===`production`?e.attrs:vn(e.attrs),$slots:e=>process.env.NODE_ENV===`production`?e.slots:vn(e.slots),$refs:e=>process.env.NODE_ENV===`production`?e.refs:vn(e.refs),$parent:e=>ga(e.parent),$root:e=>ga(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>ja(e),$forceUpdate:e=>e.f||=()=>{hr(e.update)},$nextTick:e=>e.n||=pr.bind(e.proxy),$watch:e=>ui.bind(e)}),va=e=>e===`_`||e===`$`,ya=(e,t)=>e!==N&&!e.__isScriptSetup&&L(e,t),ba={get({_:e},t){if(t===`__v_skip`)return!0;let{ctx:n,setupState:r,data:i,props:a,accessCache:o,type:s,appContext:c}=e;if(process.env.NODE_ENV!==`production`&&t===`__isVue`)return!0;if(t[0]!==`$`){let e=o[t];if(e!==void 0)switch(e){case 1:return r[t];case 2:return i[t];case 4:return n[t];case 3:return a[t]}else if(ya(r,t))return o[t]=1,r[t];else if(i!==N&&L(i,t))return o[t]=2,i[t];else if(L(a,t))return o[t]=3,a[t];else if(n!==N&&L(n,t))return o[t]=4,n[t];else Ea&&(o[t]=0)}let l=_a[t],u,d;if(l)return t===`$attrs`?(jt(e.attrs,`get`,``),process.env.NODE_ENV!==`production`&&Za()):process.env.NODE_ENV!==`production`&&t===`$slots`&&jt(e,`get`,t),l(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==N&&L(n,t))return o[t]=4,n[t];if(d=c.config.globalProperties,L(d,t))return d[t];process.env.NODE_ENV!==`production`&&Zr&&(!H(t)||t.indexOf(`__v`)!==0)&&(i!==N&&va(t[0])&&L(i,t)?q(`Property ${JSON.stringify(t)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`):e===Zr&&q(`Property ${JSON.stringify(t)} was accessed during render but is not defined on instance.`))},set({_:e},t,n){let{data:r,setupState:i,ctx:a}=e;return ya(i,t)?(i[t]=n,!0):process.env.NODE_ENV!==`production`&&i.__isScriptSetup&&L(i,t)?(q(`Cannot mutate <script setup> binding "${t}" from Options API.`),!1):r!==N&&L(r,t)?(r[t]=n,!0):L(e.props,t)?(process.env.NODE_ENV!==`production`&&q(`Attempting to mutate prop "${t}". Props are readonly.`),!1):t[0]===`$`&&t.slice(1)in e?(process.env.NODE_ENV!==`production`&&q(`Attempting to mutate public property "${t}". Properties starting with $ are reserved and readonly.`),!1):(process.env.NODE_ENV!==`production`&&t in e.appContext.config.globalProperties?Object.defineProperty(a,t,{enumerable:!0,configurable:!0,value:n}):a[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:i,props:a,type:o}},s){let c;return!!(n[s]||e!==N&&s[0]!==`$`&&L(e,s)||ya(t,s)||L(a,s)||L(r,s)||L(_a,s)||L(i.config.globalProperties,s)||(c=o.__cssModules)&&c[s])},defineProperty(e,t,n){return n.get==null?L(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};process.env.NODE_ENV!==`production`&&(ba.ownKeys=e=>(q(`Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`),Reflect.ownKeys(e)));function xa(e){let t={};return Object.defineProperty(t,"_",{configurable:!0,enumerable:!1,get:()=>e}),Object.keys(_a).forEach(n=>{Object.defineProperty(t,n,{configurable:!0,enumerable:!1,get:()=>_a[n](e),set:F})}),t}function Sa(e){let{ctx:t,propsOptions:[n]}=e;n&&Object.keys(n).forEach(n=>{Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>e.props[n],set:F})})}function Ca(e){let{ctx:t,setupState:n}=e;Object.keys(wn(n)).forEach(e=>{if(!n.__isScriptSetup){if(va(e[0])){q(`setup() return property ${JSON.stringify(e)} should not start with "$" or "_" which are reserved prefixes for Vue internals.`);return}Object.defineProperty(t,e,{enumerable:!0,configurable:!0,get:()=>n[e],set:F})}})}function wa(e){return R(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}function Ta(){let e=Object.create(null);return(t,n)=>{e[n]?q(`${t} property "${n}" is already defined in ${e[n]}.`):e[n]=t}}var Ea=!0;function Da(e){let t=ja(e),n=e.proxy,r=e.ctx;Ea=!1,t.beforeCreate&&ka(t.beforeCreate,e,`bc`);let{data:i,computed:a,methods:o,watch:s,provide:c,inject:l,created:u,beforeMount:d,mounted:f,beforeUpdate:p,updated:m,activated:h,deactivated:g,beforeDestroy:_,beforeUnmount:v,destroyed:y,unmounted:b,render:x,renderTracked:S,renderTriggered:C,errorCaptured:w,serverPrefetch:T,expose:E,inheritAttrs:D,components:ee,directives:O,filters:k}=t,te=process.env.NODE_ENV===`production`?null:Ta();if(process.env.NODE_ENV!==`production`){let[t]=e.propsOptions;if(t)for(let e in t)te(`Props`,e)}if(l&&Oa(l,r,te),o)for(let e in o){let t=o[e];V(t)?(process.env.NODE_ENV===`production`?r[e]=t.bind(n):Object.defineProperty(r,e,{value:t.bind(n),configurable:!0,enumerable:!0,writable:!0}),process.env.NODE_ENV!==`production`&&te(`Methods`,e)):process.env.NODE_ENV!==`production`&&q(`Method "${e}" has type "${typeof t}" in the component definition. Did you reference the function correctly?`)}if(i){process.env.NODE_ENV!==`production`&&!V(i)&&q(`The data option must be a function. Plain object usage is no longer supported.`);let t=i.call(n,n);if(process.env.NODE_ENV!==`production`&&ue(t)&&q(`data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`),!U(t))process.env.NODE_ENV!==`production`&&q(`data() should return an object.`);else if(e.data=hn(t),process.env.NODE_ENV!==`production`)for(let e in t)te(`Data`,e),va(e[0])||Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:()=>t[e],set:F})}if(Ea=!0,a)for(let e in a){let t=a[e],i=V(t)?t.bind(n,n):V(t.get)?t.get.bind(n,n):F;process.env.NODE_ENV!==`production`&&i===F&&q(`Computed property "${e}" has no getter.`);let o=ic({get:i,set:!V(t)&&V(t.set)?t.set.bind(n):process.env.NODE_ENV===`production`?F:()=>{q(`Write operation failed: computed property "${e}" is readonly.`)}});Object.defineProperty(r,e,{enumerable:!0,configurable:!0,get:()=>o.value,set:e=>o.value=e}),process.env.NODE_ENV!==`production`&&te(`Computed`,e)}if(s)for(let e in s)Aa(s[e],r,n,e);if(c){let e=V(c)?c.call(n):c;Reflect.ownKeys(e).forEach(t=>{ii(t,e[t])})}u&&ka(u,e,`c`);function A(e,t){R(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(A(na,d),A(ra,f),A(ia,p),A(aa,m),A(Xi,h),A(Zi,g),A(da,w),A(ua,S),A(la,C),A(oa,v),A(sa,b),A(ca,T),R(E))if(E.length){let t=e.exposed||={};E.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t,enumerable:!0})})}else e.exposed||={};x&&e.render===F&&(e.render=x),D!=null&&(e.inheritAttrs=D),ee&&(e.components=ee),O&&(e.directives=O),T&&Hi(e)}function Oa(e,t,n=F){R(e)&&(e=Ia(e));for(let r in e){let i=e[r],a;a=U(i)?`default`in i?ai(i.from||r,i.default,!0):ai(i.from||r):ai(i),On(a)?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>a.value,set:e=>a.value=e}):t[r]=a,process.env.NODE_ENV!==`production`&&n(`Inject`,r)}}function ka(e,t,n){nr(R(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function Aa(e,t,n,r){let i=r.includes(`.`)?di(n,r):()=>n[r];if(H(e)){let n=t[e];V(n)?ci(i,n):process.env.NODE_ENV!==`production`&&q(`Invalid watch handler specified by key "${e}"`,n)}else if(V(e))ci(i,e.bind(n));else if(U(e))if(R(e))e.forEach(e=>Aa(e,t,n,r));else{let r=V(e.handler)?e.handler.bind(n):t[e.handler];V(r)?ci(i,r,e):process.env.NODE_ENV!==`production`&&q(`Invalid watch handler specified by key "${e.handler}"`,r)}else process.env.NODE_ENV!==`production`&&q(`Invalid watch option: "${r}"`,e)}function ja(e){let t=e.type,{mixins:n,extends:r}=t,{mixins:i,optionsCache:a,config:{optionMergeStrategies:o}}=e.appContext,s=a.get(t),c;return s?c=s:!i.length&&!n&&!r?c=t:(c={},i.length&&i.forEach(e=>Ma(c,e,o,!0)),Ma(c,t,o)),U(t)&&a.set(t,c),c}function Ma(e,t,n,r=!1){let{mixins:i,extends:a}=t;a&&Ma(e,a,n,!0),i&&i.forEach(t=>Ma(e,t,n,!0));for(let i in t)if(r&&i===`expose`)process.env.NODE_ENV!==`production`&&q(`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`);else{let r=Na[i]||n&&n[i];e[i]=r?r(e[i],t[i]):t[i]}return e}var Na={data:Pa,props:za,emits:za,methods:Ra,computed:Ra,beforeCreate:La,created:La,beforeMount:La,mounted:La,beforeUpdate:La,updated:La,beforeDestroy:La,beforeUnmount:La,destroyed:La,unmounted:La,activated:La,deactivated:La,errorCaptured:La,serverPrefetch:La,components:Ra,directives:Ra,watch:Ba,provide:Pa,inject:Fa};function Pa(e,t){return t?e?function(){return I(V(e)?e.call(this,this):e,V(t)?t.call(this,this):t)}:t:e}function Fa(e,t){return Ra(Ia(e),Ia(t))}function Ia(e){if(R(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function La(e,t){return e?[...new Set([].concat(e,t))]:t}function Ra(e,t){return e?I(Object.create(null),e,t):t}function za(e,t){return e?R(e)&&R(t)?[...new Set([...e,...t])]:I(Object.create(null),wa(e),wa(t??{})):t}function Ba(e,t){if(!e)return t;if(!t)return e;let n=I(Object.create(null),e);for(let r in t)n[r]=La(e[r],t[r]);return n}function Va(){return{app:null,config:{isNativeTag:re,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var Ha=0;function Ua(e,t){return function(n,r=null){V(n)||(n=I({},n)),r!=null&&!U(r)&&(process.env.NODE_ENV!==`production`&&q(`root props passed to app.mount() must be an object.`),r=null);let i=Va(),a=new WeakSet,o=[],s=!1,c=i.app={_uid:Ha++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:sc,get config(){return i.config},set config(e){process.env.NODE_ENV!==`production`&&q(`app.config cannot be replaced. Modify individual options instead.`)},use(e,...t){return a.has(e)?process.env.NODE_ENV!==`production`&&q(`Plugin has already been applied to target app.`):e&&V(e.install)?(a.add(e),e.install(c,...t)):V(e)?(a.add(e),e(c,...t)):process.env.NODE_ENV!==`production`&&q(`A plugin must either be a function or an object with an "install" function.`),c},mixin(e){return i.mixins.includes(e)?process.env.NODE_ENV!==`production`&&q(`Mixin has already been applied to target app`+(e.name?`: ${e.name}`:``)):i.mixins.push(e),c},component(e,t){return process.env.NODE_ENV!==`production`&&zs(e,i.config),t?(process.env.NODE_ENV!==`production`&&i.components[e]&&q(`Component "${e}" has already been registered in target app.`),i.components[e]=t,c):i.components[e]},directive(e,t){return process.env.NODE_ENV!==`production`&&ti(e),t?(process.env.NODE_ENV!==`production`&&i.directives[e]&&q(`Directive "${e}" has already been registered in target app.`),i.directives[e]=t,c):i.directives[e]},mount(a,o,l){if(s)process.env.NODE_ENV!==`production`&&q("App has already been mounted.\nIf you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. `const createMyApp = () => createApp(App)`");else{process.env.NODE_ENV!==`production`&&a.__vue_app__&&q("There is already an app instance mounted on the host container.\n If you want to mount another app on the same host container, you need to unmount the previous app by calling `app.unmount()` first.");let u=c._ceVNode||vs(n,r);return u.appContext=i,l===!0?l=`svg`:l===!1&&(l=void 0),process.env.NODE_ENV!==`production`&&(i.reload=()=>{let t=xs(u);t.el=null,e(t,a,l)}),o&&t?t(u,a):e(u,a,l),s=!0,c._container=a,a.__vue_app__=c,process.env.NODE_ENV!==`production`&&(c._instance=u.component,Br(c,sc)),Qs(u.component)}},onUnmount(e){process.env.NODE_ENV!==`production`&&typeof e!=`function`&&q(`Expected function as first argument to app.onUnmount(), but got ${typeof e}`),o.push(e)},unmount(){s?(nr(o,c._instance,16),e(null,c._container),process.env.NODE_ENV!==`production`&&(c._instance=null,Vr(c)),delete c._container.__vue_app__):process.env.NODE_ENV!==`production`&&q(`Cannot unmount an app that is not mounted.`)},provide(e,t){return process.env.NODE_ENV!==`production`&&e in i.provides&&(L(i.provides,e)?q(`App already provides property with key "${String(e)}". It will be overwritten with the new value.`):q(`App already provides property with key "${String(e)}" inherited from its parent element. It will be overwritten with the new value.`)),i.provides[e]=t,c},runWithContext(e){let t=Wa;Wa=c;try{return e()}finally{Wa=t}}};return c}}var Wa=null,Ga=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${be(t)}Modifiers`]||e[`${Se(t)}Modifiers`];function Ka(e,t,...n){if(e.isUnmounted)return;let r=e.vnode.props||N;if(process.env.NODE_ENV!==`production`){let{emitsOptions:r,propsOptions:[i]}=e;if(r)if(!(t in r))(!i||!(we(be(t))in i))&&q(`Component emitted event "${t}" but it is neither declared in the emits option nor as an "${we(be(t))}" prop.`);else{let e=r[t];V(e)&&(e(...n)||q(`Invalid event arguments: event validation failed for event "${t}".`))}}let i=n,a=t.startsWith(`update:`),o=a&&Ga(r,t.slice(7));if(o&&(o.trim&&(i=n.map(e=>H(e)?e.trim():e)),o.number&&(i=n.map(Oe))),process.env.NODE_ENV!==`production`&&Xr(e,t,i),process.env.NODE_ENV!==`production`){let n=t.toLowerCase();n!==t&&r[we(n)]&&q(`Event "${n}" is emitted in component ${nc(e,e.type)} but the handler is registered for "${t}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${Se(t)}" instead of "${t}".`)}let s,c=r[s=we(t)]||r[s=we(be(t))];!c&&a&&(c=r[s=we(Se(t))]),c&&nr(c,e,6,i);let l=r[s+`Once`];if(l){if(!e.emitted)e.emitted={};else if(e.emitted[s])return;e.emitted[s]=!0,nr(l,e,6,i)}}var qa=new WeakMap;function Ja(e,t,n=!1){let r=n?qa:t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={},s=!1;if(!V(e)){let r=e=>{let n=Ja(e,t,!0);n&&(s=!0,I(o,n))};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}return!a&&!s?(U(e)&&r.set(e,null),null):(R(a)?a.forEach(e=>o[e]=null):I(o,a),U(e)&&r.set(e,o),o)}function Ya(e,t){return!e||!ie(t)?!1:(t=t.slice(2),t=t===`Once`?t:t.replace(/Once$/,``),L(e,t[0].toLowerCase()+t.slice(1))||L(e,Se(t))||L(e,t))}var Xa=!1;function Za(){Xa=!0}function Qa(e){let{type:t,vnode:n,proxy:r,withProxy:i,propsOptions:[a],slots:o,attrs:s,emit:c,render:l,renderCache:u,props:d,data:f,setupState:p,ctx:m,inheritAttrs:h}=e,g=$r(e),_,v;process.env.NODE_ENV!==`production`&&(Xa=!1);try{if(n.shapeFlag&4){let e=i||r,t=process.env.NODE_ENV!==`production`&&p.__isScriptSetup?new Proxy(e,{get(e,t,n){return q(`Property '${String(t)}' was accessed via 'this'. Avoid using 'this' in templates.`),Reflect.get(e,t,n)}}):e;_=ws(l.call(t,e,u,process.env.NODE_ENV===`production`?d:vn(d),p,f,m)),v=s}else{let e=t;process.env.NODE_ENV!==`production`&&s===d&&Za(),_=ws(e.length>1?e(process.env.NODE_ENV===`production`?d:vn(d),process.env.NODE_ENV===`production`?{attrs:s,slots:o,emit:c}:{get attrs(){return Za(),vn(s)},slots:o,emit:c}):e(process.env.NODE_ENV===`production`?d:vn(d),null)),v=t.props?s:to(s)}}catch(t){as.length=0,rr(t,e,1),_=vs(rs)}let y=_,b;if(process.env.NODE_ENV!==`production`&&_.patchFlag>0&&_.patchFlag&2048&&([y,b]=$a(_)),v&&h!==!1){let e=Object.keys(v),{shapeFlag:t}=y;if(e.length){if(t&7)a&&e.some(ae)&&(v=no(v,a)),y=xs(y,v,!1,!0);else if(process.env.NODE_ENV!==`production`&&!Xa&&y.type!==rs){let e=Object.keys(s),t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=e[r];ie(i)?ae(i)||t.push(i[2].toLowerCase()+i.slice(3)):n.push(i)}n.length&&q(`Extraneous non-props attributes (${n.join(`, `)}) were passed to component but could not be automatically inherited because component renders fragment or text or teleport root nodes.`),t.length&&q(`Extraneous non-emits event listeners (${t.join(`, `)}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`)}}}return n.dirs&&(process.env.NODE_ENV!==`production`&&!ro(y)&&q(`Runtime directive used on component with non-element root node. The directives will not function as intended.`),y=xs(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&(process.env.NODE_ENV!==`production`&&!ro(y)&&q(`Component inside <Transition> renders non-element root node that cannot be animated.`),zi(y,n.transition)),process.env.NODE_ENV!==`production`&&b?b(y):_=y,$r(g),_}var $a=e=>{let t=e.children,n=e.dynamicChildren,r=eo(t,!1);if(!r)return[e,void 0];if(process.env.NODE_ENV!==`production`&&r.patchFlag>0&&r.patchFlag&2048)return $a(r);let i=t.indexOf(r),a=n?n.indexOf(r):-1;return[ws(r),r=>{t[i]=r,n&&(a>-1?n[a]=r:r.patchFlag>0&&(e.dynamicChildren=[...n,r]))}]};function eo(e,t=!0){let n;for(let r=0;r<e.length;r++){let i=e[r];if(fs(i)){if(i.type!==rs||i.children===`v-if`){if(n)return;if(n=i,process.env.NODE_ENV!==`production`&&t&&n.patchFlag>0&&n.patchFlag&2048)return eo(n.children)}}else return}return n}var to=e=>{let t;for(let n in e)(n===`class`||n===`style`||ie(n))&&((t||={})[n]=e[n]);return t},no=(e,t)=>{let n={};for(let r in e)(!ae(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n},ro=e=>e.shapeFlag&7||e.type===rs;function io(e,t,n){let{props:r,children:i,component:a}=e,{props:o,children:s,patchFlag:c}=t,l=a.emitsOptions;if(process.env.NODE_ENV!==`production`&&(i||s)&&Cr||t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return r?ao(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(oo(o,r,n)&&!Ya(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?!o||ao(r,o,l):!!o;return!1}function ao(e,t,n){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let i=0;i<r.length;i++){let a=r[i];if(oo(t,e,a)&&!Ya(n,a))return!0}return!1}function oo(e,t,n){let r=e[n],i=t[n];return n===`style`&&U(r)&&U(i)?!Je(r,i):r!==i}function so({vnode:e,parent:t,suspense:n},r){for(;t;){let n=t.subTree;if(n.suspense&&n.suspense.activeBranch===e&&(n.suspense.vnode.el=n.el=r,e=n),n===e)(e=t.vnode).el=r,t=t.parent;else break}n&&n.activeBranch===e&&(n.vnode.el=r)}var co={},lo=()=>Object.create(co),uo=e=>Object.getPrototypeOf(e)===co;function fo(e,t,n,r=!1){let i={},a=lo();e.propsDefaults=Object.create(null),ho(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);process.env.NODE_ENV!==`production`&&xo(t||{},i,e),n?e.props=r?i:gn(i):e.type.props?e.props=i:e.props=a,e.attrs=a}function po(e){for(;e;){if(e.type.__hmrId)return!0;e=e.parent}}function mo(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=wn(i),[c]=e.propsOptions,l=!1;if(!(process.env.NODE_ENV!==`production`&&po(e))&&(r||o>0)&&!(o&16)){if(o&8){let n=e.vnode.dynamicProps;for(let r=0;r<n.length;r++){let o=n[r];if(Ya(e.emitsOptions,o))continue;let u=t[o];if(c)if(L(a,o))u!==a[o]&&(a[o]=u,l=!0);else{let t=be(o);i[t]=go(c,s,t,u,e,!1)}else u!==a[o]&&(a[o]=u,l=!0)}}}else{ho(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!L(t,a)&&((r=Se(a))===a||!L(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=go(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!L(t,e))&&(delete a[e],l=!0)}l&&Mt(e.attrs,`set`,``),process.env.NODE_ENV!==`production`&&xo(t||{},i,e)}function ho(e,t,n,r){let[i,a]=e.propsOptions,o=!1,s;if(t)for(let c in t){if(ge(c))continue;let l=t[c],u;i&&L(i,u=be(c))?!a||!a.includes(u)?n[u]=l:(s||={})[u]=l:Ya(e.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(a){let t=wn(n),r=s||N;for(let o=0;o<a.length;o++){let s=a[o];n[s]=go(i,t,s,r[s],e,!L(r,s))}}return o}function go(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=L(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&V(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=Is(i);r=a[n]=e.call(null,t),o()}}else r=e;i.ce&&i.ce._setProp(n,r)}o[0]&&(a&&!e?r=!1:o[1]&&(r===``||r===Se(n))&&(r=!0))}return r}var _o=new WeakMap;function vo(e,t,n=!1){let r=n?_o:t.propsCache,i=r.get(e);if(i)return i;let a=e.props,o={},s=[],c=!1;if(!V(e)){let r=e=>{c=!0;let[n,r]=vo(e,t,!0);I(o,n),r&&s.push(...r)};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}if(!a&&!c)return U(e)&&r.set(e,P),P;if(R(a))for(let e=0;e<a.length;e++){process.env.NODE_ENV!==`production`&&!H(a[e])&&q(`props must be strings when using array syntax.`,a[e]);let t=be(a[e]);yo(t)&&(o[t]=N)}else if(a){process.env.NODE_ENV!==`production`&&!U(a)&&q(`invalid props options`,a);for(let e in a){let t=be(e);if(yo(t)){let n=a[e],r=o[t]=R(n)||V(n)?{type:n}:I({},n),i=r.type,c=!1,l=!0;if(R(i))for(let e=0;e<i.length;++e){let t=i[e],n=V(t)&&t.name;if(n===`Boolean`){c=!0;break}else n===`String`&&(l=!1)}else c=V(i)&&i.name===`Boolean`;r[0]=c,r[1]=l,(c||L(r,`default`))&&s.push(t)}}}let l=[o,s];return U(e)&&r.set(e,l),l}function yo(e){return e[0]!==`$`&&!ge(e)?!0:(process.env.NODE_ENV!==`production`&&q(`Invalid prop name: "${e}" is a reserved property.`),!1)}function bo(e){return e===null?`null`:typeof e==`function`?e.name||``:typeof e==`object`&&e.constructor&&e.constructor.name||``}function xo(e,t,n){let r=wn(t),i=n.propsOptions[0],a=Object.keys(e).map(e=>be(e));for(let e in i){let t=i[e];t!=null&&So(e,r[e],t,process.env.NODE_ENV===`production`?r:vn(r),!a.includes(e))}}function So(e,t,n,r,i){let{type:a,required:o,validator:s,skipCheck:c}=n;if(o&&i){q(`Missing required prop: "`+e+`"`);return}if(!(t==null&&!o)){if(a!=null&&a!==!0&&!c){let n=!1,r=R(a)?a:[a],i=[];for(let e=0;e<r.length&&!n;e++){let{valid:a,expectedType:o}=wo(t,r[e]);i.push(o||``),n=a}if(!n){q(To(e,t,i));return}}s&&!s(t,r)&&q(`Invalid prop: custom validator check failed for prop "`+e+`".`)}}var Co=ne(`String,Number,Boolean,Function,Symbol,BigInt`);function wo(e,t){let n,r=bo(t);if(r===`null`)n=e===null;else if(Co(r)){let i=typeof e;n=i===r.toLowerCase(),!n&&i===`object`&&(n=e instanceof t)}else n=r===`Object`?U(e):r===`Array`?R(e):e instanceof t;return{valid:n,expectedType:r}}function To(e,t,n){if(n.length===0)return`Prop type [] for prop "${e}" won't match anything. Did you mean to use type Array instead?`;let r=`Invalid prop: type check failed for prop "${e}". Expected ${n.map(Ce).join(` | `)}`,i=n[0],a=pe(t),o=Eo(t,i),s=Eo(t,a);return n.length===1&&Do(i)&&Oo(i,a)&&(r+=` with value ${o}`),r+=`, got ${a} `,Do(a)&&(r+=`with value ${s}.`),r}function Eo(e,t){return le(e)?e.toString():t===`String`?`"${e}"`:t===`Number`?`${Number(e)}`:`${e}`}function Do(e){return[`string`,`number`,`boolean`].some(t=>e.toLowerCase()===t)}function Oo(...e){return e.every(e=>{let t=e.toLowerCase();return t!==`boolean`&&t!==`symbol`})}var ko=e=>e===`_`||e===`_ctx`||e===`$stable`,Ao=e=>R(e)?e.map(ws):[ws(e)],jo=(e,t,n)=>{if(t._n)return t;let r=ei((...r)=>(process.env.NODE_ENV!==`production`&&Ms&&!(n===null&&Zr)&&!(n&&n.root!==Ms.root)&&q(`Slot "${e}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`),Ao(t(...r))),n);return r._c=!1,r},Mo=(e,t,n)=>{let r=e._ctx;for(let n in e){if(ko(n))continue;let i=e[n];if(V(i))t[n]=jo(n,i,r);else if(i!=null){process.env.NODE_ENV!==`production`&&q(`Non-function value encountered for slot "${n}". Prefer function slots for better performance.`);let e=Ao(i);t[n]=()=>e}}},No=(e,t)=>{process.env.NODE_ENV!==`production`&&!Yi(e.vnode)&&q(`Non-function value encountered for default slot. Prefer function slots for better performance.`);let n=Ao(t);e.slots.default=()=>n},Po=(e,t,n)=>{for(let r in t)(n||!ko(r))&&(e[r]=t[r])},Fo=(e,t,n)=>{let r=e.slots=lo();if(e.vnode.shapeFlag&32){let e=t._;e?(Po(r,t,n),n&&De(r,`_`,e,!0)):Mo(t,r)}else t&&No(e,t)},Io=(e,t,n)=>{let{vnode:r,slots:i}=e,a=!0,o=N;if(r.shapeFlag&32){let r=t._;r?process.env.NODE_ENV!==`production`&&Cr?(Po(i,t,n),Mt(e,`set`,`$slots`)):n&&r===1?a=!1:Po(i,t,n):(a=!t.$stable,Mo(t,i)),o=t}else t&&(No(e,t),o={default:1});if(a)for(let e in i)!ko(e)&&o[e]==null&&delete i[e]},Lo,Ro;function zo(e,t){e.appContext.config.performance&&Vo()&&Ro.mark(`vue-${t}-${e.uid}`),process.env.NODE_ENV!==`production`&&qr(e,t,Vo()?Ro.now():Date.now())}function Bo(e,t){if(e.appContext.config.performance&&Vo()){let n=`vue-${t}-${e.uid}`,r=n+`:end`,i=`<${nc(e,e.type)}> ${t}`;Ro.mark(r),Ro.measure(i,n,r),Ro.clearMeasures(i),Ro.clearMarks(n),Ro.clearMarks(r)}process.env.NODE_ENV!==`production`&&Jr(e,t,Vo()?Ro.now():Date.now())}function Vo(){return Lo===void 0&&(typeof window<`u`&&window.performance?(Lo=!0,Ro=window.performance):Lo=!1),Lo}function Ho(){let e=[];if(process.env.NODE_ENV!==`production`&&e.length){let t=e.length>1;console.warn(`Feature flag${t?`s`:``} ${e.join(`, `)} ${t?`are`:`is`} not explicitly defined. You are running the esm-bundler build of Vue, which expects these compile-time feature flags to be globally injected via the bundler config in order to get better tree-shaking in the production bundle.
|
|
@@ -32,7 +32,7 @@ self.onmessage = async (e) => {
|
|
|
32
32
|
`),`请核实并处理:① 路径写错 → 用 update_todo 修正 evidence 为本次实际写入的 jsonPath;② 实际未完成 → 改回 pending 继续执行,不要谎报完成;③ 工作经委派子 agent 等未走主写路径完成 → 修正 evidence 为如实说明(不含路径样式文字)。`].join(`
|
|
33
33
|
`)}function Jd(e,t){return t?{...e,...t}:e}async function Yd(e,t){let n=t;for(let t of e)t.beforeAgent&&(n=Jd(n,await t.beforeAgent(n)));return n}function Xd(e,t){let n=t.state;for(let r of e)r.beforeModel&&(n=Jd(n,r.beforeModel({messages:t.messages,state:n})));return n}function Zd(e,t,n){let r=n;for(let n=e.length-1;n>=0;n--){let i=e[n];i.afterModel&&(r=Jd(r,i.afterModel(t,r)))}return r}async function Qd(e,t){let n=t;for(let t=e.length-1;t>=0;t--){let r=e[t];r.afterAgent&&(n=Jd(n,await r.afterAgent(n)))}return n}async function $d(e,t){let n=[];for(let r of e){if(!r.beforeReturn)continue;let e=await r.beforeReturn(t);e&&n.push(e)}return n.length?n.join(`
|
|
34
34
|
|
|
35
|
-
`):null}function ef(e,t){return e.reduceRight((e,t)=>n=>t.wrapModelCall?t.wrapModelCall(n,e):e(n),t)}function tf(e,t){return e.reduceRight((e,t)=>n=>t.wrapToolCall?t.wrapToolCall(n,e):e(n),t)}function nf(e){return e?/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e):!1}function rf(e){if(!e)return``;let t=e.search(/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<function_call>|<invoke\s+name=/i);return(t>=0?e.slice(0,t):e).trim()}var af=/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>/i;function of(e){return e.replace(/```[\w-]*\n?[\s\S]*?```/g,``)}function sf(e){if(!e||!nf(e))return null;let t=of(e);if(!af.test(t))return null;t=t.replace(/<|(?!|)[^|<>]*?|>/g,``);let n=/<(?:||?DSML||?)?\s*invoke\s+name=["']([^"']+)["'][^>]*>/gi,r=[],i;for(;(i=n.exec(t))!==null;)r.push({name:i[1],tagStart:i.index,after:n.lastIndex});if(!r.length)return null;let a=/<\/?\s*(?:||?DSML||?)?\/?\s*invoke\s*>/i,o=/<(?:||?DSML||?)?\s*parameter\s+name=["']([^"']+)["'][^>]*>([\s\S]*?)<\/?\s*(?:||?DSML||?)?\/?\s*parameter\s*>/gi,s=/<(?:||?DSML||?)?\s*parameter\s+name=["'][^"']+["'][^>]*>/gi,c=/<\/?\s*(?:||?DSML||?)?\/?\s*parameter\s*>/gi,l=[];for(let e=0;e<r.length;e++){let n=e+1<r.length?r[e+1].tagStart:t.length,i=t.slice(r[e].after,n),u=i.match(a);if(u&&u.index!==void 0&&(i=i.slice(0,u.index)),(i.match(s)||[]).length>(i.match(c)||[]).length)continue;let d={};o.lastIndex=0;let f;for(;(f=o.exec(i))!==null;)d[f[1]]=cf(f[2].trim());l.push({id:`dsml_${e}_${Date.now().toString(36)}`,name:r[e].name,args:d})}return l.length?l:null}function cf(e){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`null`)return null;try{return JSON.parse(e)}catch{return e}}var lf=30,uf=300,df=6e3;function ff(e,t){let n=e=>x(typeof e.content==`string`?e.content:JSON.stringify(e.content)),r=e.reduce((e,t)=>e+n(t),0);if(r<=t)return e;let a=0,o=r-t,s=Math.max(100,Math.min(400,Math.round(t/500))),c=e.map(e=>{if(a>=o||!(e instanceof i.ToolMessage))return e;let t=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(t.length<=400)return e;let n=`…[已自动压缩 ${t.length} 字符,保留首 ${s}]\n`+t.slice(0,s);return a+=x(t)-x(n),new i.ToolMessage({tool_call_id:e.tool_call_id,content:n})}),l=c.reduce((e,t)=>e+n(t),0);return l>t&&console.warn(`[page-agent-sdk] trim 后仍超窗口:${l} > ${t} tokens(系统段/历史超预算,见 Phase 5/P3)`),c}function pf(e,t){return t??Math.max(e*3,30)}function mf(e,t,n){if(t<=0||e<0)return``;let r=t-e;return r<=0?``:r<=2?`⚠️ 轮次预算告急:本轮任务已用 ${e}/${t} 轮工具调用,仅剩 ${r} 轮。立即停止扩展性操作(查询/重读/优化),完成手头最关键的一步写入或委派,然后用纯文本给出诚实结论:哪些已完成、哪些未做(用 update_todo 如实标记),用户可回复「继续」续跑。`:e>=Math.ceil(t*.7)?`⚠️ 轮次预算提醒:本轮任务已用 ${e}/${t} 轮工具调用,剩余 ${r} 轮。${n?`剩余任务多且重时,可并行分段委派(多个 spawn_agent 各带 writablePaths=段前缀,task 写明改动目标与验收),子 agent 过程隔离不占你的轮次与上下文;`:`剩余任务多且重时优先做最关键的部分;`}砍掉非必要的查询与重复读;若预估剩余步骤超出预算,先做最重要的部分并如实标记未完成项,不要等被打断。`:``}var hf=new Set([`write`,`draft_commit`]);function gf(e){if(!e||typeof e!=`object`)return``;let t=e;if(typeof t.jsonPath==`string`)return t.jsonPath;let n=t.patch;if(n&&typeof n.jsonPath==`string`)return n.jsonPath;let r=t.patches;return Array.isArray(r)&&r.length&&r[0]&&typeof r[0].jsonPath==`string`?r[0].jsonPath:``}function _f(e){let{apiKey:t,baseUrl:r,model:a=`
|
|
35
|
+
`):null}function ef(e,t){return e.reduceRight((e,t)=>n=>t.wrapModelCall?t.wrapModelCall(n,e):e(n),t)}function tf(e,t){return e.reduceRight((e,t)=>n=>t.wrapToolCall?t.wrapToolCall(n,e):e(n),t)}function nf(e){return e?/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e):!1}function rf(e){if(!e)return``;let t=e.search(/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<function_call>|<invoke\s+name=/i);return(t>=0?e.slice(0,t):e).trim()}var af=/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>/i;function of(e){return e.replace(/```[\w-]*\n?[\s\S]*?```/g,``)}function sf(e){if(!e||!nf(e))return null;let t=of(e);if(!af.test(t))return null;t=t.replace(/<|(?!|)[^|<>]*?|>/g,``);let n=/<(?:||?DSML||?)?\s*invoke\s+name=["']([^"']+)["'][^>]*>/gi,r=[],i;for(;(i=n.exec(t))!==null;)r.push({name:i[1],tagStart:i.index,after:n.lastIndex});if(!r.length)return null;let a=/<\/?\s*(?:||?DSML||?)?\/?\s*invoke\s*>/i,o=/<(?:||?DSML||?)?\s*parameter\s+name=["']([^"']+)["'][^>]*>([\s\S]*?)<\/?\s*(?:||?DSML||?)?\/?\s*parameter\s*>/gi,s=/<(?:||?DSML||?)?\s*parameter\s+name=["'][^"']+["'][^>]*>/gi,c=/<\/?\s*(?:||?DSML||?)?\/?\s*parameter\s*>/gi,l=[];for(let e=0;e<r.length;e++){let n=e+1<r.length?r[e+1].tagStart:t.length,i=t.slice(r[e].after,n),u=i.match(a);if(u&&u.index!==void 0&&(i=i.slice(0,u.index)),(i.match(s)||[]).length>(i.match(c)||[]).length)continue;let d={};o.lastIndex=0;let f;for(;(f=o.exec(i))!==null;)d[f[1]]=cf(f[2].trim());l.push({id:`dsml_${e}_${Date.now().toString(36)}`,name:r[e].name,args:d})}return l.length?l:null}function cf(e){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`null`)return null;try{return JSON.parse(e)}catch{return e}}var lf=30,uf=300,df=6e3;function ff(e,t){let n=e=>x(typeof e.content==`string`?e.content:JSON.stringify(e.content)),r=e.reduce((e,t)=>e+n(t),0);if(r<=t)return e;let a=0,o=r-t,s=Math.max(100,Math.min(400,Math.round(t/500))),c=e.map(e=>{if(a>=o||!(e instanceof i.ToolMessage))return e;let t=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(t.length<=400)return e;let n=`…[已自动压缩 ${t.length} 字符,保留首 ${s}]\n`+t.slice(0,s);return a+=x(t)-x(n),new i.ToolMessage({tool_call_id:e.tool_call_id,content:n})}),l=c.reduce((e,t)=>e+n(t),0);return l>t&&console.warn(`[page-agent-sdk] trim 后仍超窗口:${l} > ${t} tokens(系统段/历史超预算,见 Phase 5/P3)`),c}function pf(e,t){return t??Math.max(e*3,30)}function mf(e,t,n){if(t<=0||e<0)return``;let r=t-e;return r<=0?``:r<=2?`⚠️ 轮次预算告急:本轮任务已用 ${e}/${t} 轮工具调用,仅剩 ${r} 轮。立即停止扩展性操作(查询/重读/优化),完成手头最关键的一步写入或委派,然后用纯文本给出诚实结论:哪些已完成、哪些未做(用 update_todo 如实标记),用户可回复「继续」续跑。`:e>=Math.ceil(t*.7)?`⚠️ 轮次预算提醒:本轮任务已用 ${e}/${t} 轮工具调用,剩余 ${r} 轮。${n?`剩余任务多且重时,可并行分段委派(多个 spawn_agent 各带 writablePaths=段前缀,task 写明改动目标与验收),子 agent 过程隔离不占你的轮次与上下文;`:`剩余任务多且重时优先做最关键的部分;`}砍掉非必要的查询与重复读;若预估剩余步骤超出预算,先做最重要的部分并如实标记未完成项,不要等被打断。`:``}var hf=new Set([`write`,`draft_commit`]);function gf(e){if(!e||typeof e!=`object`)return``;let t=e;if(typeof t.jsonPath==`string`)return t.jsonPath;let n=t.patch;if(n&&typeof n.jsonPath==`string`)return n.jsonPath;let r=t.patches;return Array.isArray(r)&&r.length&&r[0]&&typeof r[0].jsonPath==`string`?r[0].jsonPath:``}function _f(e){let{apiKey:t,baseUrl:r,model:a=`deepseek-v4-flash`,temperature:o=.7,maxTokens:s,extraBody:c,extraConfig:l,systemPrompt:u,tools:d=[],middleware:f=[],maxToolRounds:p,maxIterations:m,maxRetries:h=2,retryDelayMs:g=500,stallMs:_=Cu,streamMaxMs:v=Tu,toolTimeoutMs:y,maxParallelTools:w=1,maxVerifyAttempts:T=0,roundTokenBudget:ee=0,onLog:O,onLlmChange:A,imageContentFormat:j=`openai`,staleReadInvalidation:ne=!0,debug:N=!1}=e,P=p??lf;(!Number.isFinite(P)||P<1)&&(console.warn(`[page-agent-sdk] maxToolRounds=${P} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`),P=1);let F=b({model:a,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens,vision:e.vision}),re=s??F.maxOutputTokens,ie=S(F.contextWindow),ae=C(F.contextWindow);function I(e){F=e,ie=S(F.contextWindow),ae=C(F.contextWindow)}let oe=An([]),se=0,L=new Set;function R(e,t){let n={timestamp:Date.now(),type:e,data:t};oe.value.push(n),oe.value.length>uf&&oe.value.splice(0,oe.value.length-uf),Nn(oe),O?.(n),N&&console.log(`%c[Agent] ${e}`,`color:#667eea;font-weight:bold`,t)}let z=e=>{oe.value.push(e),oe.value.length>uf&&oe.value.splice(0,oe.value.length-uf),Nn(oe)},ce=[...f.flatMap(e=>e.tools||[]),...d],B=e.llm??new n.ChatOpenAI({apiKey:t,model:a,temperature:o,maxTokens:re,configuration:{...r?{baseURL:D(r)}:{},fetch:E,...l},...c?{modelKwargs:c}:{}}),V=ce.length>0?B.bindTools?.(ce)??B:B,H=()=>{let e=B;return(typeof e.model==`string`&&e.model?e.model:typeof e.modelName==`string`&&e.modelName?e.modelName:``)||a};function le(){V=ce.length>0?B.bindTools?.(ce)??B:B}let U=hu();e.__pgIsSubagent&&(U.__pgIsSubagent=!0);let ue=.25,de=new Set([`mission`,`workingMemory`,`intentGuard`,`resumeNotice`]);function fe(){let e=u||`你是一个智能助手。`,t=[];for(let e of f)if(e.augmentPrompt){let n=e.augmentPrompt(U);n&&t.push({name:e.name,text:n,tokens:x(n),pin:de.has(e.name)})}let n=Math.max(2e3,Math.round(F.contextWindow*ue)),r=x(e)+t.reduce((e,t)=>e+t.tokens,0);if(r>n){let e=r,i=[];for(let e of t.filter(e=>!e.pin).sort((e,t)=>t.tokens-e.tokens)){if(r<=n)break;i.push(`${e.name}(${e.tokens})`),r-=e.tokens,e.text=``}i.length&&console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${F.contextWindow} 的 ${ue*100}%),drop 非核心段:${i.join(`, `)}(保 base/mission/workingMemory)`)}return[e,...t.filter(e=>e.text).map(e=>e.text)].join(`
|
|
36
36
|
|
|
37
37
|
`)}function pe(e){let t=[new i.SystemMessage(fe())];for(let n of e)if(n.role===`user`){let e=F.vision&&n.images?.length?Xl(n.content,n.images,j):null;e?t.push(new i.HumanMessage({content:e})):n.images?.some(e=>e.description)?t.push(new i.HumanMessage(Zl(n.content,n.images))):t.push(new i.HumanMessage(n.content))}else n.role===`assistant`?t.push(new i.AIMessage(n.content)):n.role===`system`&&t.push(new i.SystemMessage(n.content));return t}function me(e,t){let n=e[0]&&_e(e[0])===`system`?e.slice(1):e.slice(),r=fe();return[new i.SystemMessage(t?`${r}\n\n${t}`:r),...n]}async function he(e,t,n,r){let a=r??V,o={signal:n,maxRetries:h,baseDelayMs:g,onRetry:({attempt:e,error:t,waitMs:n})=>{let r=t?.message??String(t);R(`error`,{stage:`model_retry`,attempt:e,waitMs:n,error:r}),console.warn(`[Agent] 模型调用失败,第 ${e}/${h} 次重试(等 ${n}ms):${r}`)}},s=new AbortController;n&&(n.aborted?s.abort():n.addEventListener(`abort`,()=>s.abort(),{once:!0}));let c;try{let t;try{c=await bu(()=>{clearTimeout(t);let n=_>0?_:Cu,r=a.stream(e.messages,{signal:s.signal});return _>0?Promise.race([r,new Promise((e,r)=>{t=setTimeout(()=>r(new xu(n)),n)})]):r},o)}finally{clearTimeout(t)}}catch(a){if(gu(a,n))return{message:new i.AIMessage(``),toolCalls:[],content:``,aborted:!0};if(Du(a)&&!e._ctxRetry){e._ctxRetry=!0;let i=e=>x(typeof e.content==`string`?e.content:JSON.stringify(e.content)),a=e.messages.reduce((e,t)=>e+i(t),0),o=ve(e.messages,Math.round(F.contextWindow*.3)),s=o.reduce((e,t)=>e+i(t),0);return R(`error`,{stage:`context_overflow_retry`,at:`launch`,beforeTokens:a,afterTokens:s,window:F.contextWindow}),console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`),he({...e,messages:o},t,n,r)}throw Au(a)&&R(`error`,{stage:`model_unavailable`,at:`launch`,status:a?.status}),a}if(!c)return{message:new i.AIMessage(``),toolCalls:[],content:``,aborted:!0};let l=null,u=``;try{for await(let e of Eu(c,_,v)){l=l?l.concat(e):e;let n=k(e);n&&t&&(u+=n,t({type:`text`,delta:n}));let r=te(e);r&&t&&t({type:`reasoning`,delta:r})}}catch(a){if(a instanceof xu)throw s.abort(),R(`error`,{stage:a instanceof Su?`stream_max_duration`:`stream_stalled`,waitedMs:a.waitedMs,stallMs:_,streamMaxMs:v}),a;if(gu(a,n))return{message:l??new i.AIMessage(u),toolCalls:[],content:u,aborted:!0};if(Du(a)&&l===null&&u===``&&!e._ctxRetry){e._ctxRetry=!0;let i=e=>x(typeof e.content==`string`?e.content:JSON.stringify(e.content)),a=e.messages.reduce((e,t)=>e+i(t),0),o=ve(e.messages,Math.round(F.contextWindow*.3)),s=o.reduce((e,t)=>e+i(t),0);return R(`error`,{stage:`context_overflow_retry`,beforeTokens:a,afterTokens:s,window:F.contextWindow}),console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${F.contextWindow})`),he({...e,messages:o},t,n,r)}throw Au(a)&&R(`error`,{stage:`model_unavailable`,at:`iterate`,status:a?.status}),a}if(l===null){if(!e._emptyRetry)return e._emptyRetry=!0,R(`error`,{stage:`empty_llm_response_retry`,hint:`流正常结束但零 chunk(网关 200+错误体形态),自动重试 1 次`}),he(e,t,n,r);throw R(`error`,{stage:`empty_llm_response`,retried:!0,hint:`重试后仍零 chunk,抛 EmptyLLMResponseError 显式报错`}),new wu}let d=l;return{message:d,toolCalls:d.tool_calls||[],content:u}}async function ge(e){let t=ce.find(t=>t.name===e.name);if(!t){let t=ce.map(e=>e.name).filter(e=>!e.startsWith(`__`));return{content:`工具 "${e.name}" 不存在(当前上下文可用工具:${t.join(`, `)})`,status:`error`}}try{let n={__pgDataScope:``,...e.callConfig??{}},r=pu(t,y??12e4)?y??12e4:0,i;if(r>0)try{i=await mu(Promise.resolve().then(()=>t.invoke(e.args,{configurable:n})),r)}catch(t){if(t instanceof du)return R(`error`,{stage:`tool_timeout`,name:e.name,timeoutMs:r,hint:`集成方工具超时,看门狗兜底(底层调用无法取消,可能仍在后台执行)`}),{content:`工具执行超时:${e.name} 超过 ${r}ms 未返回,已放弃等待。该工具可能卡住(底层调用无法取消,或仍在后台执行),请勿原样重试;请改用其他方式完成,或向用户如实说明该工具当前不可用。`,status:`error`};throw t}else i=await t.invoke(e.args,{configurable:n});let a=typeof i==`string`?i:JSON.stringify(i),o=ce.some(e=>e.name===`vfs_read`);return a=cu(a,{files:e.state.files,vfsAvailable:!!e.state.files&&o,toolName:e.name,threshold:ie,passThroughChars:ae}).content,{content:a,status:`done`}}catch(e){return{content:`工具执行出错:${Vl(e,`recoverable`).message}`,status:`error`}}}function _e(e){return e instanceof i.HumanMessage?`human`:e instanceof i.AIMessage?`ai`:e instanceof i.SystemMessage?`system`:e instanceof i.ToolMessage?`tool`:`unknown`}function ve(e,t){return ff(e,t)}function ye(e){return!N&&!O?[]:e.map(e=>{let t=_e(e),n={role:t===`human`?`user`:t===`ai`?`assistant`:t},r=typeof e.content==`string`?e.content:JSON.stringify(e.content);r&&(n.content=r.length>df?r.slice(0,df)+`…(截断 ${r.length-df} 字符)`:r);let i=e.tool_calls;Array.isArray(i)&&i.length&&(n.tool_calls=i.map(e=>({id:e.id,type:`function`,function:{name:e.name,arguments:typeof e.args==`string`?e.args:JSON.stringify(e.args)}})));let a=e.tool_call_id;return a&&(n.tool_call_id=a),n})}async function be(t,n,r){U=hu(),e.__pgIsSubagent&&(U.__pgIsSubagent=!0),U.messages=t,U=await Yd(f,U);let a=t;for(let e of f)if(e.compressInput){let t=await e.compressInput(a);a=Array.isArray(t)?t:t.messages,t&&!Array.isArray(t)&&t.stats&&(U={...U,lastCompression:t.stats})}{let e=x(u||`你是一个智能助手。`),t=Math.max(2e3,Math.round(F.contextWindow*ue));if(e>t){let r=`[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${F.contextWindow} 的 ${ue*100}%);请缩减 systemPrompt 或换更大窗口模型`;return console.error(r),n({type:`error`,message:r,severity:`fatal`,code:`SYSTEM_PROMPT_OVER_BUDGET`}),n({type:`done`,content:``}),``}}let o=pe(a);R(`context`,{model:H(),tools:ce.map(e=>e.name),middleware:f.map(e=>e.name)});let s=ef(f,e=>he(e,n,r)),c=tf(f,ge),l={rounds:0,maxToolRounds:P,invokeUsage:{prompt_tokens:0,completion_tokens:0,total_tokens:0},writeFailures:{},budgetHinted:!1};U.loopProgress=l;let d={counts:{},writePaths:[],failures:0},p=Bd(),h=new Map((U.todos??[]).map(e=>[e.id,{status:e.status,content:e.content}])),g=new Map,_=0,v=e=>{let t=ce.find(t=>t.name===e);return t&&`writeCapable`in t?typeof t.writeCapable==`function`||t.writeCapable===!0:hf.has(e)},y=0,b=0,S=pf(P,m),C=null,E=0,D=!1,O=!1;try{for(;(y<P||O)&&b<S&&(b++,!r?.aborted);){if(ee>0&&l.invokeUsage.total_tokens>ee){let e=`本轮 token 预算(约 ${ee})已用尽:任务在 ${y} 轮工具调用后中断,已完成的部分均保留。可继续对话,指定下一步(如「继续完成」/「只改 X」/「提高预算重试」)。`;return R(`error`,{stage:`round_token_budget_exceeded`,used:l.invokeUsage.total_tokens,budget:ee,rounds:y}),n({type:`error`,message:e,severity:`observable`,code:`ROUND_TOKEN_BUDGET_EXCEEDED`,context:{used:l.invokeUsage.total_tokens,budget:ee}}),n({type:`done`,content:e}),e}n({type:`round_start`,round:b}),U=Xd(f,{messages:o,state:U}),o=me(o,mf(y,P,e.hasSubagent)),o=ve(o,Math.round(F.contextWindow*.6)),R(`llm_request`,{round:y+1,model:H(),tools:ce.map(e=>e.name),messages:ye(o)});let t=await s({messages:o,state:U});o.push(t.message);let a=M(t.message);if(R(`llm_response`,{round:y+1,content:t.content,toolCalls:t.toolCalls,...a?{usage:a}:{}}),a&&(l.invokeUsage.prompt_tokens+=a.prompt_tokens??0,l.invokeUsage.completion_tokens+=a.completion_tokens??0,l.invokeUsage.total_tokens+=a.total_tokens??0),U=Zd(f,t,U),t.aborted)return n({type:`done`,content:t.content}),t.content;if(!t.toolCalls.length){{let e=t.message?.response_metadata??t.message?.responseMetadata,n=e?.stop_reason??e?.finish_reason,r=M(t.message);if((n===`length`||!t.content&&(r?.completion_tokens??0)>=4e3)&&!D){D=!0,O=!0,R(`error`,{stage:`completion_truncated_retry`,completionTokens:r?.completion_tokens,stopReason:n??null,hint:`空输出且 completion 达上限,疑似 max_tokens 截断;回灌分步写入指引`}),o.push(new i.HumanMessage(`⚠️ 你上一轮输出为空(疑似被 max_tokens 截断:单次输出过长,常见于把完整大段代码塞进一次工具调用参数)。请改用分步方式:① 先用工具写入小体积骨架/占位结构,② 再逐步用增量工具调用补充内容;或大幅精简单次输出。不要一次性输出完整大段内容。`));continue}}let e=nf(t.content),r=e?sf(t.content):null;if(r&&r.length){t.toolCalls=r;let e=t.message;e&&(e.tool_calls=r.map(e=>({id:e.id,name:e.name,args:e.args,type:`tool_call`}))),R(`middleware`,{stage:`dsml_parsed`,count:r.length,names:r.map(e=>e.name)})}else{if(e&&E<2){E+=1,O=!0,R(`middleware`,{stage:`format_retry`,attempt:E,content:t.content.slice(0,200)}),o.push(new i.HumanMessage(`⚠️ 你刚才把工具调用写成了文本(伪 XML/标签/DSML 标记,如 <|tool_calls|>、<||DSML||>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。`));continue}e&&(R(`error`,{stage:`garbled_exhausted`,retries:E,content:t.content.slice(0,200)}),n({type:`error`,message:`模型连续 2 次输出无法解析的工具调用格式(DSML/伪标签),任务可能未完成。请重试或换模型。`,severity:`observable`,code:`GARBLED_TOOL_CALL_EXHAUSTED`,context:{content:t.content.slice(0,200)}}));let r=Gd({state:p,garbled:e,rounds:y,finalContent:t.content,todos:U.todos,isSubagent:!!U.__pgIsSubagent,turnUsage:d,isWriteToolByName:v,messages:o,sessionWritePaths:L,todosStatusAtStart:h});if(r?.kind===`feedback`){O=!0,R(`middleware`,{stage:r.gate.stage,attempt:r.gate.attempt,...r.gate.logData??{},content:t.content.slice(0,160)}),o.push(new i.HumanMessage(r.gate.feedback));continue}if(r?.kind===`observable`&&n({type:`error`,message:r.obs.message,severity:`observable`,code:r.obs.code,context:r.obs.context}),!e&&T>0&&U.verifyAttempts<T){let e=await $d(f,{messages:o,state:U,response:t,log:(e,t)=>R(e,t)});if(e){C=t.content,U.verifyAttempts+=1,o.push(new i.HumanMessage(`⚠️ 验证未通过,请修正:${e}`)),R(`middleware`,{stage:`verify_retry`,attempt:U.verifyAttempts,feedback:e});continue}}O=!1;let a=t.content;if(e){let e=rf(a);a=e?`${e}\n\n(注:此后模型输出了无法解析的工具调用文本,该调用未执行,任务可能未完成。)`:`模型多次输出无法解析的工具调用格式,本次任务可能未完成。请重试或继续指示。`}return n({type:`done`,content:a}),a}}O=!1;let u=t.toolCalls,m=u.map(e=>{let t=e.id||`call_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return{id:t,call:e,ctx:{id:t,name:e.name,args:e.args,state:U,signal:r,emit:n,logSink:z}}});if(u.some(e=>!e.id)){let e=t.message;e?.tool_calls&&(e.tool_calls=e.tool_calls.map((e,t)=>e&&e.id?e:{...e,id:m[t]?.id,type:e?.type??`tool_call`}))}let x=await lu(m,w,async e=>{if(r?.aborted)return;let t=Date.now();n({type:`tool_call`,name:e.call.name,args:e.call.args,id:e.id}),R(`tool_call`,{round:y+1,name:e.call.name,args:e.call.args,id:e.id});let i;try{i=await c(e.ctx)}catch(e){if(gu(e,r))throw e;i={content:`工具执行出错:${Vl(e,`recoverable`).message}`,status:`error`}}let a=Date.now()-t;return n({type:`tool_result`,name:e.call.name,result:i.content,status:i.status,durationMs:a,id:e.id}),R(`tool_result`,{round:y+1,name:e.call.name,result:i.content,status:i.status,durationMs:a}),i},r);for(let e=0;e<m.length;e++){let t=x[e];if(!t)continue;let n=e=>e&&typeof e==`object`&&!Array.isArray(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,n(e[t])])):e,r=`${m[e].call.name}|${JSON.stringify(n(m[e].call.args??{}))}`,a=t.status===`error`||typeof t.content==`string`&&t.content.startsWith(`ERROR:`),s=t.content;if(a){let e=(g.get(r)??0)+1;g.set(r,e),e>=2&&(s=`${t.content}\n(提示:同参数已连续失败 ${e} 次,原样重试大概率仍失败;请检查参数/换路径/换方法,或向用户如实说明困难)`)}else g.delete(r);if(m[e].call.name===`read`&&!a){let t=m[e].call.args??{};t.jsonPath&&!t.jsonPaths?.length?(_++,_>=2&&(s=`${s}\n(提示:还需读多个路径时,用 read({jsonPaths:["路径1","路径2",…]}) 一次取回省轮次;多路径单项标错不整批失败)`)):t.jsonPaths?.length&&(_=0)}o.push(new i.ToolMessage({tool_call_id:m[e].id,content:s}))}for(let e=0;e<m.length;e++){let t=x[e];if(!t||!hf.has(m[e].call.name))continue;let n=gf(m[e].call.args);t.status===`error`?l.writeFailures[n]=(l.writeFailures[n]??0)+1:delete l.writeFailures[n]}let S=[];for(let e=0;e<m.length;e++){let t=x[e];if(!t)continue;let n=m[e].call.name;if(d.counts[n]=(d.counts[n]??0)+1,t.status===`error`&&(d.failures+=1),ju(ce.find(e=>e.name===n),m[e].call.args,t)){let t=gf(m[e].call.args);d.writePaths.push(t||`(整体)`),S.push({name:n,args:m[e].call.args,callIndex:e});let r=sd({name:n,args:m[e].call.args,callIndex:e});if(r)for(let e of r.paths)L.add(e)}}if(ne&&S.length){let e=ld(o,S,{round:y+1,maxParallelTools:w});e.invalidatedCount>0&&(o=e.messages,se+=e.invalidatedCount,R(`middleware`,{stage:`stale_read_invalidated`,round:y+1,writtenPaths:S.map(e=>gf(e.args)||`(整体)`),invalidatedCount:e.invalidatedCount}))}if(r?.aborted)break;y++,l.rounds=y}if(r?.aborted)return n({type:`done`,content:``}),``;let t=`\n\n(提示:工具调用次数已达上限(${P} 轮 / ${S} 次迭代),以上为基于已完成操作的阶段性结果,任务可能未完成。回复「继续」或告诉我下一步重点,即可接着做。)`;R(`error`,{stage:`react_call_limit_exceeded`,rounds:y,maxToolRounds:P,iterations:b,maxIterations:S}),n({type:`error`,message:`ReAct 循环达到调用上限(rounds=${y}/${P},iterations=${b}/${S}),已强制收口,可回复「继续」。`,severity:`observable`,code:`REACT_CALL_LIMIT_EXCEEDED`,context:{rounds:y,maxToolRounds:P,iterations:b,maxIterations:S}});let a=Kd(U.todos??[],h,L);if(a.length){let e=a.map(e=>({id:e.id,evidence:e.evidence}));R(`middleware`,{stage:`evidence_audit_flagged`,offenders:e}),n({type:`error`,message:`轮次耗尽收口:${a.length} 项已完成任务的 evidence 路径与写入记录不符,最终回复中的完成声明可能不实`,severity:`observable`,code:`AUDIT_EVIDENCE_SUSPECT`,context:{offenders:e}})}if(C!=null){let e=C+t;return n({type:`done`,content:e}),e}let u=o[o.length-1];if(u&&_e(u)===`tool`){let e=o[0]&&_e(o[0])===`system`?o.slice(1):o.slice(),a=[new i.SystemMessage(fe()+`
|
|
38
38
|
|
|
@@ -49,8 +49,8 @@ self.onmessage = async (e) => {
|
|
|
49
49
|
提示:改某组件深层字段前,先 schema_data({jsonPath}) 查完整约束;或 read 子路径见实际值。`}return n}return e?.description||`(用 read 查看实际形状)`}var np=/(?:改|加|删|生成|查询|分析|创建|修改|配置|实现|检查|对比|整理|转换|设计|搭建|编排|布局|调整|更新)/;function rp(e){return!e||e.trim().length<8||/^(你好|hi|hello|ok|好的|继续|嗯|谢谢|hey|哈喽|收到|明白)/i.test(e.trim())||e.length>2e3?!1:np.test(e)}function ip(e){for(let t=0;t<e.length;t++){if(e[t].role!==`user`)continue;let n=e[t].content;if(rp(n))return{goal:n.length>200?n.slice(0,200)+`…`:n,sourceMessageIdx:t,capturedAt:Date.now(),explicit:!1}}}function ap(){let e,t=!1;return{name:`mission`,beforeAgent:n=>(!e&&!t&&(e=ip(n.messages)),e?{mission:e}:{}),augmentPrompt:()=>{if(!e)return;let t=[`## 当前主线目标`,e.goal];return e.acceptanceCriteria?.length&&(t.push(`完成标准:`),e.acceptanceCriteria.forEach((e,n)=>t.push(`${n+1}. ${e}`))),t.push(`(每步操作应服务此目标;偏离时回到主线)`),t.join(`
|
|
50
50
|
`)},setMission:n=>{if(Object.keys(n).length===0){e=void 0,t=!0;return}t=!1,e={goal:n.goal??e?.goal??``,acceptanceCriteria:n.acceptanceCriteria??e?.acceptanceCriteria,sourceMessageIdx:n.sourceMessageIdx??e?.sourceMessageIdx??-1,capturedAt:n.capturedAt??e?.capturedAt??Date.now(),explicit:n.explicit??!0}},getMission:()=>e,reset:()=>{e=void 0,t=!1}}}var op=/(为什么|为啥|多少|几个|能不能|可不可以|是否|有没有|怎样|咋)/,sp=/(是什么|是啥|怎么用|如何用|有哪些|什么意思|干嘛的|干什么用)/,cp=/(吗|呢)[??]?\s*$/;function lp(e){let t=(e||``).trim();return t?!!(/[??]\s*$/.test(t)||sp.test(t)||op.test(t)&&cp.test(t)):!1}var up=[`[本轮消息为咨询] 用户最新消息是提问/咨询,不是操作指令。`,`请先作答:用 read / query / search / list_components / rag 等工具查证后基于事实回答,不要凭空猜测。`,`不要执行生成/修改/删除操作 —— 除非用户在同一条消息里同时明确提出了操作要求(如「顺便把 X 改成 Y」)。`].join(`
|
|
51
51
|
`);function dp(e){let t=null;return{name:`intentGuard`,augmentPrompt:n=>{for(let r=n.messages.length-1;r>=0;r--){let i=n.messages[r];if(i.role===`user`)return lp(i.content)?(e&&t!==i.content&&(t=i.content,e(i.content.slice(0,60))),up):void 0}}}}var fp=[`[本会话从历史记录恢复] 你不在场期间,宿主页面数据可能已发生变化:`,`- 页面刷新可能使数据回退到上次保存的状态(未保存的修改已不存在);用户或宿主也可能改动过数据。`,`- 历史对话与已完成的任务记录不代表当前实际数据。`,`纪律:断言「已生成/已存在/已完成」前,先用 read / list_components 等工具核实当前状态;`,`用户要求重做历史工作(如「重新生成」)时,先核实缺失了哪些部分,再补齐或重做,勿直接回复「已完成/完毕」。`].join(`
|
|
52
|
-
`);function pp(e){let t=!1,n=!1;return{name:`resumeNotice`,markResumed:()=>{t=!0,n=!1},reset:()=>{t=!1,n=!1},isPending:()=>t,augmentPrompt:()=>{if(t)return e&&!n&&(n=!0,e()),fp},afterAgent:()=>{t=!1}}}var mp=new Set([`__proto__`,`constructor`,`prototype`]);function hp(e){return e.split(`.`).some(e=>mp.has(e))}function gp(e,t){if(!(!t||typeof t!=`object`||Array.isArray(t)))for(let n of Object.keys(t))mp.has(n)||(e[n]=t[n])}function _p(e,t){if(!t)return e;if(hp(t))return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r}function vp(e,t,n){if(!t||hp(t))return;let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];(i[t]==null||typeof i[t]!=`object`)&&(i[t]={}),i=i[t]}i[r[r.length-1]]=n}function yp(e,t){if(!t||hp(t))return!1;let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return!1;r=r[n[e]]}let i=n[n.length-1];return r==null||!(i in r)?!1:(Array.isArray(r)&&/^\d+$/.test(i)?r.splice(Number(i),1):delete r[i],!0)}function bp(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch(t){let n=xp(e);throw n?Error(`数据存在循环引用(${n});数据槽/快照不支持环形结构,请检查宿主 bind 或写入值`):t}}function xp(e){let t=new WeakSet,n=(e,r)=>{if(typeof e!=`object`||!e)return;let i=e;if(t.has(i))return r;if(t.add(i),Array.isArray(e))for(let t=0;t<e.length;t++){let i=n(e[t],`${r}[${t}]`);if(i)return i}else for(let t of Object.keys(e)){let i=n(e[t],`${r}.${t}`);if(i)return i}t.delete(i)};return n(e,`$`)}function Sp(e){if(typeof e!=`string`)return{parsed:e};let t=e.trim();if(!t)return{parsed:e};let n=t[0]===`{`||t[0]===`[`;try{return{parsed:JSON.parse(t)}}catch(t){return n?{parseError:t}:{parsed:e}}}function Cp(e,t){if(typeof e!=`object`||!e)return e;let n=new Set(t);if(Array.isArray(e))return e.map(e=>Cp(e,t));let r={};for(let t of Object.keys(e))n.has(t)&&(r[t]=e[t]);return r}function wp(e,t){if(typeof e!=`object`||!e)return e;if(t<=0)return Array.isArray(e)?`[...${e.length}]`:`{...}`;if(Array.isArray(e))return e.map(e=>wp(e,t-1));let n={};for(let r of Object.keys(e))n[r]=wp(e[r],t-1);return n}function Tp(e,t=1/0,n){let r=new WeakSet,i;try{i=JSON.stringify(e,(e,t)=>{if(!(n&&e&&n.has(e))){if(typeof t==`function`)return`[Function]`;if(typeof t==`bigint`)return t.toString();if(typeof t==`object`&&t){if(typeof HTMLElement<`u`&&t instanceof HTMLElement)return`[HTMLElement: <${t.tagName.toLowerCase()}>]`;if(typeof Node<`u`&&t instanceof Node)return`[Node: type=${t.nodeType}]`;if(r.has(t))return`[Circular]`;r.add(t)}return t}},0)}catch(e){i=`[无法序列化: ${e?.message||String(e)}]`}return i.length>t&&(i=i.slice(0,t)+`\n…[已截断,原长度 ${i.length}]`),i}function Ep(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function Dp(e,t){return Ep(Tp(e,1/0,t)).toString(36)}function Op(e,t){let n=[],r=e=>{if(Array.isArray(e)){e.forEach(r);return}if(e&&typeof e==`object`)for(let[i,a]of Object.entries(e))t.has(i)&&n.push(`${i}=${Tp(a)}`),r(a)};return r(e),n.sort(),Ep(n.join(`\0`)).toString(36)}function kp(e,t,n,r){if(t===`set`)return n?(vp(e,n,r),null):`set 操作需要 jsonPath(整体替换请用 write({value}))`;if(t===`remove`)return n?yp(e,n)?null:`remove 路径不存在: ${n}(数组索引越界或字段缺失;请先 read 最新结构确认索引)`:`remove 操作需要 jsonPath`;if(t===`merge`){let t=n?_p(e,n):e;return typeof t!=`object`||!t||Array.isArray(t)?`merge 目标${n?`(${n})`:`(根)`}不是对象`:(gp(t,r),null)}if(t===`move`)return jp(e,n,r);let i=n?_p(e,n):e;return Array.isArray(i)?(Array.isArray(r)?i.push(...r):i.push(r),null):`append 目标${n?`(${n})`:`(根)`}
|
|
53
|
-
`),`仅操作上述 ${t.length} 个聚焦子树${t.length>1?`之一`:``},用户未指明目标的指令默认作用于聚焦组件(「增加/修改/删除 X」类指令优先理解为对聚焦组件本身的改动 —— 如为其加页签/子项,写焦点路径的子路径;仅用户明确要求新建独立组件时才需解除焦点);不要改动其他组件;${a}
|
|
52
|
+
`);function pp(e){let t=!1,n=!1;return{name:`resumeNotice`,markResumed:()=>{t=!0,n=!1},reset:()=>{t=!1,n=!1},isPending:()=>t,augmentPrompt:()=>{if(t)return e&&!n&&(n=!0,e()),fp},afterAgent:()=>{t=!1}}}var mp=new Set([`__proto__`,`constructor`,`prototype`]);function hp(e){return e.split(`.`).some(e=>mp.has(e))}function gp(e,t){if(!(!t||typeof t!=`object`||Array.isArray(t)))for(let n of Object.keys(t))mp.has(n)||(e[n]=t[n])}function _p(e,t){if(!t)return e;if(hp(t))return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r}function vp(e,t,n){if(!t||hp(t))return;let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];(i[t]==null||typeof i[t]!=`object`)&&(i[t]={}),i=i[t]}i[r[r.length-1]]=n}function yp(e,t){if(!t||hp(t))return!1;let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return!1;r=r[n[e]]}let i=n[n.length-1];return r==null||!(i in r)?!1:(Array.isArray(r)&&/^\d+$/.test(i)?r.splice(Number(i),1):delete r[i],!0)}function bp(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch(t){let n=xp(e);throw n?Error(`数据存在循环引用(${n});数据槽/快照不支持环形结构,请检查宿主 bind 或写入值`):t}}function xp(e){let t=new WeakSet,n=(e,r)=>{if(typeof e!=`object`||!e)return;let i=e;if(t.has(i))return r;if(t.add(i),Array.isArray(e))for(let t=0;t<e.length;t++){let i=n(e[t],`${r}[${t}]`);if(i)return i}else for(let t of Object.keys(e)){let i=n(e[t],`${r}.${t}`);if(i)return i}t.delete(i)};return n(e,`$`)}function Sp(e){if(typeof e!=`string`)return{parsed:e};let t=e.trim();if(!t)return{parsed:e};let n=t[0]===`{`||t[0]===`[`;try{return{parsed:JSON.parse(t)}}catch(t){return n?{parseError:t}:{parsed:e}}}function Cp(e,t){if(typeof e!=`object`||!e)return e;let n=new Set(t);if(Array.isArray(e))return e.map(e=>Cp(e,t));let r={};for(let t of Object.keys(e))n.has(t)&&(r[t]=e[t]);return r}function wp(e,t){if(typeof e!=`object`||!e)return e;if(t<=0)return Array.isArray(e)?`[...${e.length}]`:`{...}`;if(Array.isArray(e))return e.map(e=>wp(e,t-1));let n={};for(let r of Object.keys(e))n[r]=wp(e[r],t-1);return n}function Tp(e,t=1/0,n){let r=new WeakSet,i;try{i=JSON.stringify(e,(e,t)=>{if(!(n&&e&&n.has(e))){if(typeof t==`function`)return`[Function]`;if(typeof t==`bigint`)return t.toString();if(typeof t==`object`&&t){if(typeof HTMLElement<`u`&&t instanceof HTMLElement)return`[HTMLElement: <${t.tagName.toLowerCase()}>]`;if(typeof Node<`u`&&t instanceof Node)return`[Node: type=${t.nodeType}]`;if(r.has(t))return`[Circular]`;r.add(t)}return t}},0)}catch(e){i=`[无法序列化: ${e?.message||String(e)}]`}return i.length>t&&(i=i.slice(0,t)+`\n…[已截断,原长度 ${i.length}]`),i}function Ep(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function Dp(e,t){return Ep(Tp(e,1/0,t)).toString(36)}function Op(e,t){let n=[],r=e=>{if(Array.isArray(e)){e.forEach(r);return}if(e&&typeof e==`object`)for(let[i,a]of Object.entries(e))t.has(i)&&n.push(`${i}=${Tp(a)}`),r(a)};return r(e),n.sort(),Ep(n.join(`\0`)).toString(36)}function kp(e,t,n,r){if(t===`set`)return n?(vp(e,n,r),null):`set 操作需要 jsonPath(整体替换请用 write({value}))`;if(t===`remove`)return n?yp(e,n)?null:`remove 路径不存在: ${n}(数组索引越界或字段缺失;请先 read 最新结构确认索引)`:`remove 操作需要 jsonPath`;if(t===`merge`){let t=n?_p(e,n):e;return typeof t!=`object`||!t||Array.isArray(t)?`merge 目标${n?`(${n})`:`(根)`}不是对象`:(gp(t,r),null)}if(t===`move`)return jp(e,n,r);let i=n?_p(e,n):e;return typeof i==`string`?typeof r==`string`?(vp(e,n,i+r),null):`append 目标(${n})是字符串,value 必须也是字符串(拼接语义)`:Array.isArray(i)?(Array.isArray(r)?i.push(...r):i.push(r),null):`append 目标${n?`(${n})`:`(根)`}不是数组(也不支持非字符串标量拼接)`}function Ap(e,t){let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return null;r=r[n[e]]}return[r,n[n.length-1]]}function jp(e,t,n){if(!t)return`move 操作需要 jsonPath(源数组元素路径,如 components.2)`;if(typeof n!=`string`||!n)return`move 的 value 必须是目标路径字符串(数组本身=追加,如 "sections.1.children";数组内下标=插入,如 "components.0")`;if(hp(n))return`move 目标路径 "${n}" 含非法段`;let r=Ap(e,t);if(!r||!Array.isArray(r[0]))return`move 源的父级不是数组(仅支持数组元素移动,jsonPath 应指向数组下标,如 components.2)`;let i=Number(r[1]);if(!Number.isInteger(i)||i<0||i>=r[0].length)return`move 源下标越界:${t}(父数组长度 ${r[0].length})`;let a=r[0][i];r[0].splice(i,1);let o=_p(e,n);if(Array.isArray(o))return o.push(a),null;if(o===void 0){let t=Ap(e,n);if(t&&t[0]!=null&&typeof t[0]==`object`&&!/^\d+$/.test(t[1]))return t[0][t[1]]=[a],null}let s=Ap(e,n);if(s&&Array.isArray(s[0])&&/^\d+$/.test(s[1])){let e=Math.min(Number(s[1]),s[0].length);return s[0].splice(e,0,a),null}return`move 目标 "${n}" 不是数组(目标须为数组本身(追加)或数组内某下标(插入))`}function Mp(e,t,n,r){if(t===`set`)vp(e,n,r);else if(t===`remove`)yp(e,n);else if(t===`merge`)gp(n?_p(e,n):e,r);else if(t===`move`)jp(e,n,r);else{let t=n?_p(e,n):e;Array.isArray(r)?t.push(...r):t.push(r)}}function Np(e,t){typeof e==`object`&&e&&Pp(e,t)}function Pp(e,t){if(Array.isArray(e)){e.length=0,Array.isArray(t)&&e.push(...t);return}let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{};for(let t of Object.keys(e))t in n||delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function Fp(e,t,n,r=``){let i=[],a=e=>typeof e==`object`&&!!e;if(!a(t))return i;if(Array.isArray(t)){let a=Array.isArray(e)?e:[],o=Array.isArray(n)?n:[],s=new Set(a.map(e=>JSON.stringify(e)));return t.forEach((e,t)=>{s.has(JSON.stringify(e))||i.push(...Fp(a[t],e,o[t],r?`${r}.${t}`:String(t)))}),i}let o=t,s=a(n)&&!Array.isArray(n)?n:null,c=a(e)&&!Array.isArray(e)?e:null;for(let e of Object.keys(o)){let t=r?`${r}.${e}`:e;e.startsWith(`__pg`)||(s&&!(e in s)?(!c||!(e in c))&&i.push(t):s&&e in s&&i.push(...Fp(c?.[e],o[e],s[e],t)))}return i}function Ip(e,t,n=``){let r=[];if(!(typeof e==`object`&&e)||!(typeof t==`object`&&t)||Array.isArray(e)!==Array.isArray(t))return e!==t&&r.push({path:n||`(root)`,from:e,to:t}),r;if(Array.isArray(e)&&Array.isArray(t)){let i=Math.max(e.length,t.length);for(let a=0;a<i;a++){let i=n?`${n}.${a}`:`${a}`;a>=e.length?r.push({path:i,from:void 0,to:t[a]}):a>=t.length?r.push({path:i,from:e[a],to:void 0}):r.push(...Ip(e[a],t[a],i))}return r}let i=e,a=t,o=new Set([...Object.keys(i),...Object.keys(a)]);for(let e of o){let t=n?`${n}.${e}`:e;e in i?e in a?r.push(...Ip(i[e],a[e],t)):r.push({path:t,from:i[e],to:void 0}):r.push({path:t,from:void 0,to:a[e]})}return r}var Lp=new Set([`write`,`draft_commit`]);function Rp(e){let t=e??{},n=new Set;if(typeof t.jsonPath==`string`&&t.jsonPath&&n.add(t.jsonPath),typeof t.path==`string`&&t.path&&n.add(t.path),t.patch&&typeof t.patch.jsonPath==`string`&&t.patch.jsonPath&&n.add(t.patch.jsonPath),Array.isArray(t.patches))for(let e of t.patches)e&&typeof e.jsonPath==`string`&&e.jsonPath&&n.add(e.jsonPath);return[...n]}function zp(e,t){return e===t||e.startsWith(t+`.`)}function Bp(e,t){if(!t||typeof t!=`object`)return!1;let n=e.lastIndexOf(`.`);if(n<0)return!1;let r=e.slice(0,n),i=e.slice(n+1);if(!/^\d+$/.test(i))return!1;let a=_p(t,r);return Array.isArray(a)&&Number(i)>=a.length}function Vp(e){let t=e.initialFocuses?[...e.initialFocuses]:[],n=()=>e.onChange?.([...t]),r=e.unfocusGuidance??`tool`,i=e=>`若你的意图是修改聚焦组件本身(如给它新增页签/子项),请改写焦点路径的子路径重试${e?`(如 ${e})`:``};`,a=r===`tool`?`需改其他组件请先 remove_focus / clear_focus 或换焦点。${i()}`:r===`ask-user`?`焦点由用户在输入框设定与移除(聚焦 chip ✕);用户要求改其他组件时,提示用户移除聚焦后重试,勿尝试写焦点外(会被拒)。${i()}`:`需改其他组件时,在收口回复中说明需先取消焦点(焦点由主会话管理),勿尝试越界写。${i()}`,o=e=>r===`tool`?`${i(e)}需操作焦点外组件请先 remove_focus / clear_focus 或换焦点后重试。`:r===`ask-user`?`${i(e)}焦点由用户在输入框管理,请提示用户移除输入框中的聚焦 chip 后重试(当前模式无 focus 工具)。`:`${i(e)}请只改焦点子树;需改其他组件时,在收口回复中说明需先取消焦点。`;return{name:`focus`,beforeAgent:()=>t.length?{focuses:[...t],focus:t[0]}:{},augmentPrompt:()=>{if(!t.length)return;let n=[`## 当前精修目标`,t.map(e=>`· ${e.path}${e.label?`(${e.label})`:``}`).join(`
|
|
53
|
+
`),`仅操作上述 ${t.length} 个聚焦子树${t.length>1?`之一`:``},用户未指明目标的指令默认作用于聚焦组件(「增加/修改/删除 X」类指令优先理解为对聚焦组件本身的改动 —— 如为其加页签/子项,写焦点路径的子路径;仅用户明确要求新建独立组件时才需解除焦点);不要改动其他组件;${a}`,`用户用指示代词提问(「这是啥/这个/它是干什么的」等)时,所指默认是聚焦目标 —— 先 read 聚焦子树,再围绕聚焦组件回答,勿泛答整页`,`read 不带路径时默认只返回聚焦子树;需要全量主数据时显式列顶层键(read({jsonPaths:[...]}) )`],r=e.getSchema();if(r){let e=t.map(e=>{let t=xf(r,e.path);return t?ep(t):null}).filter(e=>!!e);e.length&&n.push(``,`## 焦点子树结构(仅此范围可操作)`,...e)}return n.join(`
|
|
54
54
|
`)},wrapToolCall:async(n,r)=>{if(t.length){let i=t.map(e=>e.label?`${e.path}(${e.label})`:e.path).join(`, `),a=t.length===1?`${t[0].path}.props.xxx`:void 0,s=e=>({content:`PATH_DENIED · 聚焦越界:当前聚焦 [${i}],不可操作「${e}」。${o(a)}`,status:`error`});if(n.name===`eval_script`){if(n.args?.mode!==`transform`)return r(n);let i=Rp(n.args);if(!i.length)return s(`(整体数据)`);for(let n of i)if(!t.some(e=>zp(n,e.path))&&!Bp(n,e.getBind?.()))return s(n);return r(n)}if(Lp.has(n.name)){let r=Rp(n.args);if(!r.length)return s(`(整体数据)`);for(let n of r)if(!t.some(e=>zp(n,e.path))&&!Bp(n,e.getBind?.()))return s(n)}if(n.name===`read`){n.callConfig={...n.callConfig??{},__pgFullTextPaths:t.map(e=>e.path)};let e=n.args;if(!e?.jsonPath&&!e?.jsonPaths){let i=t.map(e=>e.path),a=await r({...n,args:{...e,jsonPaths:i}}),o=`【聚焦模式】read 未带路径 → 默认返回聚焦子树(${i.join(`, `)});需要全量主数据时显式列顶层键,如 read({jsonPaths:['<顶层键1>','<顶层键2>']})\n`;return{...a,content:o+a.content}}}}return r(n)},setFocus:e=>{t=e?[e]:[],n()},getFocus:()=>t[0],getFocuses:()=>[...t],addFocus:e=>{let r=t.findIndex(t=>t.path===e.path);r>=0?t[r]=e:t.push(e),n()},removeFocus:e=>{t=t.filter(t=>t.path!==e),n()},clearFocus:()=>{t=[],n()},reset:()=>{t=[],n()}}}function Hp(e){return e}var Up=/^https?:\/\//i;function Wp(e){return Up.test(e)||e.startsWith(`//`)?`http`:`vfs`}function Gp(e){return e.replace(/^vfs:\/\//,``).replace(/^\/+/,``).replace(/\/+/g,`/`)}var Kp=3e4;async function qp(e){let t=new AbortController,n=setTimeout(()=>t.abort(),Kp);try{return await fetch(e,{signal:t.signal})}finally{clearTimeout(n)}}async function Jp(e,t){if(Wp(e)===`http`)try{let t=await qp(e);return t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`HTTP ${t.status} ${t.statusText}(${e})`}}catch(t){if(t?.name===`AbortError`)return{ok:!1,error:`读取超时(${Kp/1e3}s):${e}`};let n=t?.message||String(t);return/Failed to fetch|NetworkError|CORS|blocked/i.test(n)?{ok:!1,error:`CORS 跨域或网络错误(${n});浏览器仅能 GET 同源或已配 CORS 的资源`}:{ok:!1,error:n}}if(!t)return{ok:!1,error:`skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`};let n=t(Gp(e));return n==null?{ok:!1,error:`未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`}:{ok:!0,content:n}}function Yp(e){if(e.length)return[`## 可用 Skills(渐进式披露)`,e.map(e=>`- ${e.name}: ${e.description}`).join(`
|
|
55
55
|
`),`当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。`].join(`
|
|
56
56
|
`)}function Xp(e){return e.references?.length?`\n\n## 参考文档(按需加载,勿整包请求)\n${e.references.map(e=>`- ${e.name}${e.description?`: ${e.description}`:``}`).join(`
|
|
@@ -91,11 +91,11 @@ self.onmessage = async (e) => {
|
|
|
91
91
|
`)}`:`虚拟工作区为空。`},{name:`vfs_ls`,description:`列出虚拟工作区所有文件。`,schema:t.z.object({})}),(0,r.tool)(async({pattern:t})=>{let n;try{n=ng(t)}catch(e){return $({code:`GLOB_INVALID`,message:`glob 模式无效: ${e.message}`,hint:`* 匹配非斜杠,** 匹配任意;避免未闭合的字符类`,details:{pattern:t}})}let r=Object.keys(e.files).filter(e=>n.test(e));return r.length?`匹配 ${t}:\n${r.map(e=>`- ${e}`).join(`
|
|
92
92
|
`)}`:`无匹配 ${t} 的文件。`},{name:`vfs_glob`,description:`按 glob 模式匹配虚拟工作区文件名(* 匹配非斜杠,** 匹配任意)。`,schema:t.z.object({pattern:t.z.string().describe(`glob 模式,如 "**/*.md"`)})}),(0,r.tool)(async({pattern:t,path:n})=>{let r;try{r=new RegExp(t)}catch(e){return $({code:`REGEX_INVALID`,path:n,message:`正则表达式无效: ${e.message}`,hint:`检查括号/量词是否闭合;若想搜普通字符串可先转义特殊字符`,details:{pattern:t}})}let i=n?[tg(n)]:Object.keys(e.files),a=[];for(let t of i){let n=e.files[t];n&&n.content.split(`
|
|
93
93
|
`).forEach((e,n)=>{r.test(e)&&a.push(`${t}:${n+1}: ${e}`)})}return a.length?`找到 ${a.length} 处:\n${a.slice(0,50).join(`
|
|
94
|
-
`)}`:`未找到匹配 /${t}/ 的内容。`},{name:`vfs_grep`,description:`在虚拟工作区文件内容中正则搜索。`,schema:t.z.object({pattern:t.z.string().describe(`正则表达式`),path:t.z.string().optional().describe(`限定单个文件,不传则搜索全部`)})}),(0,r.tool)(async({path:t,jsonPath:n})=>{let r=tg(t),i=e.files[r];if(!i)return $({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return $({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_read 要求文件内容是合法 JSON;先 vfs_read 查看实际内容,或 vfs_write({jsonString:true}) 重写为合法 JSON`})}if(n){let e=_p(a,n);return e===void 0?$({code:`VFS_PATH_NOT_FOUND`,path:t,message:`jsonPath "${n}" 不存在`,hint:`不传 jsonPath 整体读查看结构,或核对路径段`}):`${t}#${n} (JSON):\n${JSON.stringify(e)}`}return`${t} (JSON):\n${JSON.stringify(a)}`},{name:`vfs_json_read`,description:`把虚拟工作区文件当 JSON 读取:先 parse 整文件,再按 jsonPath 取子树(省略返整体)。文件非合法 JSON 报 VFS_JSON_INVALID。适合结构化读取 vfs 内大 JSON。`,schema:t.z.object({path:t.z.string().describe(`文件路径(内容须为合法 JSON)`),jsonPath:t.z.string().optional().describe(`点分隔子路径(如 components.0.title);省略读整体`)})}),(0,r.tool)(async({path:t,patches:n})=>{let r=tg(t),i=e.files[r];if(!i)return $({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return $({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_patch 要求文件内容是合法 JSON`})}let o=bp(a),s=[];for(let e of n){let n=kp(o,e.op,e.jsonPath,e.value);if(n)return $({code:`PATCH_FAILED`,path:t,message:n,hint:`修正 patches 后重试(原文件未改动)`,details:{failedPatch:e}});s.push(e.jsonPath||`(根)`)}let c=JSON.stringify(o);return e.files[r]={content:c,updatedAt:rg()},`已对 ${t} 应用 ${n.length} 个 patch(影响 ${s.length} 处:${s.join(`, `)}),文件现 ${c.length} 字符`},{name:`vfs_json_patch`,description:`在虚拟工作区 JSON 文件内做原子 jsonPath patch(set/remove/merge/append)。先 parse → clone 上应用全部 patches → 任一失败或 JSON 非法则整体不写回(原文件不变)。`,schema:t.z.object({path:t.z.string().describe(`文件路径(内容须为合法 JSON)`),patches:t.z.array(t.z.object({op:t.z.enum([`set`,`remove`,`merge`,`append`]).describe(`操作`),jsonPath:t.z.string().describe(`点分隔路径(如 components.0.title);merge/append 目标可为根(空串)`),value:t.z.any().optional().describe(`set/merge/append 的值(remove 不需要)`)})).describe(`按顺序应用的 patch 列表(原子:任一失败整体不写回)`)})}),(0,r.tool)(async({path:t})=>{let n=tg(t);return e.files[n]?(delete e.files[n],`已删除 ${t}`):$({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}",无需删除`,hint:`用 vfs_ls 查看虚拟工作区文件列表`})},{name:`vfs_rm`,description:`删除虚拟工作区文件(清理中间产物 / drafts 下草稿,补「只进不出」的闭环)。不存在返回 NOT_FOUND。`,schema:t.z.object({path:t.z.string().describe(`要删除的文件路径`)})})]}function og(e){return{name:`vfs`,tools:ag(e),beforeAgent:()=>({files:e.files})}}var sg=`⟦frozen:`,cg=`⟦res:`,lg=`⟧`;function ug(e){return`${sg}${e}${lg}`}function dg(e){return`${cg}${e}${lg}`}function fg(e){return typeof e==`string`?e.startsWith(sg)&&e.endsWith(lg)?{type:`frozen`,path:e.slice(8,e.length-1)}:e.startsWith(cg)&&e.endsWith(lg)?{type:`res`,handle:e.slice(5,e.length-1)}:null:null}function pg(e){return String(e??``).trim().replace(/^\.+/,``)}function mg(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return(t>>>0).toString(16).padStart(8,`0`).slice(0,8)}function hg(e,t){return e===t?!0:e&&t&&typeof e==`object`&&typeof t==`object`?JSON.stringify(e)===JSON.stringify(t):!1}function gg(e,t){let n=pg(e);if(!n)return;let r=t.get(n);if(r)return{spec:r,relation:`exact`,protectedPath:n};let i;for(let[e,r]of t)n!==e&&(n.startsWith(e+`.`)?(!i||e.length>i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`descendant`}):e.startsWith(n+`.`)&&(!i||e.length<i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`ancestor`}));return i}var _g=class{vfs;constructor(e){this.vfs=e}key(e){return`resources/${e}.json`}ensure(e,t,n){let r=mg(e),i={path:e,mode:n,value:t,handle:r};return this.vfs.files[this.key(r)]={content:JSON.stringify(i),updatedAt:Date.now()},r}get(e){return this.readEntry(this.key(e))||this.readEntry(this.key(mg(e)))}readEntry(e){let t=this.vfs.files[e];if(t)try{let e=JSON.parse(t.content);return e&&typeof e.path==`string`?e:void 0}catch{return}}update(e,t){let n=this.get(e);this.ensure(e,t,n?.mode??`verbatim`)}delete(e){let t=this.get(e)?.handle??mg(e),n=this.key(t),r=!!this.vfs.files[n];return r&&delete this.vfs.files[n],r}list(){let e=[];for(let[t,n]of Object.entries(this.vfs.files))if(t.startsWith(`resources/`))try{let t=JSON.parse(n.content);t&&typeof t.path==`string`&&e.push({path:t.path,mode:t.mode,handle:t.handle,bytes:n.content.length})}catch{}return e}clear(){for(let e of Object.keys(this.vfs.files))e.startsWith(`resources/`)&&delete this.vfs.files[e]}};function vg(e){let{jp:t,resolved:n,resourcesByPath:r,resourceStore:i}=e;if(!r.size)return n;let a=!1;for(let e of r.keys())if(t===``||e===t||e.startsWith(t+`.`)){a=!0;break}if(!a)return n;let o=bp(n);for(let[e,n]of r){if(t!==``&&e!==t&&!e.startsWith(t+`.`))continue;if(e===t){if(o===void 0)continue;return n.mode===`freeze`?ug(e):i?dg(i.ensure(e,o,`verbatim`)):o}let r=t===``?e:e.slice(t.length+1),a=_p(o,r);a!==void 0&&(n.mode===`freeze`?vp(o,r,ug(e)):i&&vp(o,r,dg(i.ensure(e,a,`verbatim`))))}return o}function yg(e,t,n,r){if(!r)return{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 无法展开(资源池未启用)`,hint:`verbatim 保护需启用 vfs(capabilities.vfs 默认开);集成方经 createChatSdk 配 data.resources 时自动提供 vfsStore`};let i=r.get(e);return i?n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,hint:`该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构`}:hg(i.value,n)?{value:i.value}:(r.update(t,n),{value:n}):n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,hint:`重新 read 该字段触发懒注册`}:{code:`RESOURCE_EVICTED`,message:`字段 "${t}" 的 verbatim 资源已被淘汰(资源池 LRU)`,hint:`重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧`}}function bg(e,t){let n=t.getBind();for(let[r,i]of t.resourcesByPath){let a=_p(n,r),o=_p(e,r);if(o===void 0){a!==void 0&&vp(e,r,a);continue}if(i.mode===`freeze`){if(o===ug(r)){vp(e,r,a);continue}if(!hg(o,a))return{ok:!1,code:`FROZEN_FIELD`,path:r,message:`字段 "${r}" 已冻结(freeze 保护),不可修改`,hint:`该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值`}}else{let n=fg(o);if(n&&n.type===`res`){let i=yg(n.handle,r,a,t.resourceStore);if(`value`in i){vp(e,r,i.value);continue}return{ok:!1,code:i.code,path:r,message:i.message,hint:i.hint}}if(!hg(o,a))return{ok:!1,code:`VERBATIM_MISMATCH`,path:r,message:`字段 "${r}" 为 verbatim 保护(精确原样保留),写入值与原值不符`,hint:`要改该值请先 resource_update({path, value}) 更新资源池,再写回句柄 ⟦res:<handle>⟧;或写回原值(经 resource_get 取到的值)保持不变`}}}return{ok:!0}}function xg(e,t,n){let r=t===void 0?e.message:`patches[${t}]${n?` @ "${n}"`:``}: ${e.message}`;return $({code:e.code,path:e.path,message:r,hint:e.hint,...t===void 0?{}:{details:{patchIndex:t,patchJsonPath:n??null}}})}function Sg(e){let{value:t,ctx:n}=e;if(!n||!n.resourcesByPath.size)return{ok:!0,value:t};let r=bp(t),i=bg(r,n);return i.ok?{ok:!0,value:r}:{ok:!1,error:xg(i)}}function Cg(e){let{patches:t,clone:n,ctx:r}=e;if(!r||!r.resourcesByPath.size)return{ok:!0};for(let e=0;e<t.length;e++){let n=t[e];if(n.op===`remove`){let t=gg(n.jsonPath||``,r.resourcesByPath);if(t){let r=t.spec.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,i=t.spec.mode===`freeze`?`冻结字段不可删。如需移除请联系集成方调整 data.resources 配置`:`verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删`;return{ok:!1,error:$({code:r,path:t.protectedPath,message:`patches[${e}] @ "${n.jsonPath}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,hint:i,details:{patchIndex:e,patchJsonPath:n.jsonPath??``}})}}}}let i=bg(n,r);if(!i.ok){let e=wg(i.path,t);return{ok:!1,error:xg(i,e>=0?e:void 0,e>=0?t[e].jsonPath:void 0)}}return{ok:!0}}function wg(e,t){let n=pg(e);for(let e=0;e<t.length;e++){let r=pg(t[e].jsonPath||``);if(r&&(r===n||n.startsWith(r+`.`)||r.startsWith(n+`.`)))return e}return-1}function Tg(e,t){if(!e)return null;let n=(t?xf(e,t):e)?.shape;return n&&typeof n==`object`?Object.keys(n):null}var Eg=e=>e&&e.length?`(可用字段:${e.slice(0,12).join(`, `)}${e.length>12?` …`:``})`:``,Dg=e=>/[.[]/.test(e)?e.replace(/[.[][^.[]*$/,``):``;function Og(e){let{schema:t,allowKeys:n,value:r,bindRef:i}=e,a=[];if(n){if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:Rl(``,[{path:[],code:`invalid_type`,message:`整体 set 需为 JSON 对象(当前为 ${Array.isArray(r)?`array`:r===null?`null`:typeof r})`,expected:`object`}]),notices:a};let e=i&&typeof i==`object`&&!Array.isArray(i)?i:{},n=r,o={};for(let r of Object.keys(n)){if(r.startsWith(`__pg`))continue;let i=n[r],s=Tf(t,r,i);if(!s.ok){if(s.resolution===`missing`){if(r in e)continue;return{ok:!1,error:$({code:`SCHEMA_STRIP`,message:`字段 ${r} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${Eg(Tg(t,``))}`,path:r,details:{stripped:[r]}}),notices:a}}return{ok:!1,error:Rl(r,s.issues??[]),notices:a}}s.resolution===`open`&&a.push(`${r}=开放节点放行`);let c=Fp(e[r],i,s.data,r);if(c.length)return{ok:!1,error:$({code:`SCHEMA_STRIP`,message:`字段 ${c.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${Eg(Tg(t,Dg(String(c[0]))))}`,path:c[0],details:{stripped:c}}),notices:a};o[r]=s.data}return Ef(t)&&a.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`),{ok:!0,assembly:o,wholeParsed:null,notices:a}}let o=t.safeParse(r);if(!o.success)return{ok:!1,error:Rl(``,o.error.issues),notices:a};let s=Fp(i,r,o.data);return s.length?{ok:!1,error:$({code:`SCHEMA_STRIP`,message:`字段 ${s.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:s[0],details:{stripped:s}}),notices:a}:{ok:!0,assembly:o.data,wholeParsed:o.data,notices:a}}function kg(e){let{schema:t,bindRef:n,clone:r,patches:i,schemaErrorMode:a=`zod`,appendCaptures:o,moveCaptures:s}=e,c=[],l=t=>{let n=_p(r,t);return n===void 0?e.valueAt?.(t):n},u=(e,t)=>a===`schema_invalid`?$({code:`SCHEMA_INVALID`,message:`patches 应用后局部校验失败 @ "${e}",未写入`,hint:`确认该路径的值符合 schema;兄弟节点的既有数据不影响本次写入`,details:Ll(t)}):Rl(e,t),d=e=>$({code:`SCHEMA_STRIP`,message:`字段 ${e.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:e[0],details:{stripped:e}}),f=[];Ef(t)&&c.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`);let p=0,m=0;for(let e of i){let i=e.op??`set`,a=e.jsonPath||``;if(i===`remove`){let e=a.lastIndexOf(`.`);if(e>0&&/^\d+$/.test(a.slice(e+1))){let n=a.slice(0,e),i=wf(t,n);if(i.kind===`schemas`){let e=_p(r,n);if(Array.isArray(e))for(let t of i.schemas){let r=Df(t);if(r!==null&&e.length<r)return{ok:!1,error:u(n,[{path:[n],code:`too_small`,message:`删除后数组长度 ${e.length} 低于 schema 最小约束 ${r}`,expected:`>=${r}`}]),writeBacks:[],notices:c}}}}f.push({op:`remove`,jp:a});continue}if(i===`move`){let n=s[m++];if(n&&n.elem!==void 0){let e=n.toPath.lastIndexOf(`.`),r=e>0&&/^\d+$/.test(n.toPath.slice(e+1))?n.toPath.slice(0,e):n.toPath,i=wf(t,r);if(i.kind===`schemas`){let e=Of(i.schemas);if(e.length){let t=[],r=!1;for(let i of e){let e=i.safeParse(n.elem);if(e.success){r=!0;break}t.push(...e.error?.issues??[])}if(!r)return{ok:!1,error:u(n.toPath,t),writeBacks:[],notices:c}}}else i.kind===`open`&&c.push(`${r}=开放节点放行`)}f.push({op:`move`,jp:a,toPath:String(e.value)});continue}if(i===`append`){let e=o[p++]?.elems??[];if(!e.length){f.push({op:`appendElems`,jp:a,elems:[]});continue}let n=wf(t,a);if(n.kind===`missing`)return{ok:!1,error:d([a||`(根)`]),writeBacks:[],notices:c};if(n.kind===`open`){c.push(`${a||`(根)`}=开放节点放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let r=Of(n.schemas);if(!r.length){c.push(`${a||`(根)`}:目标非 schema 声明数组,元素未校验放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let i=[];for(let t=0;t<e.length;t++){let n=[],o,s=!1;for(let i of r){let r=i.safeParse(e[t]);if(r.success){s=!0,o=r.data;break}n.push(...r.error?.issues??[])}if(!s)return{ok:!1,error:u(`${a||`(根)`}[新增元素${t}]`,n),writeBacks:[],notices:c};let l=Fp(void 0,e[t],o,a?`${a}.${t}`:String(t));if(l.length)return{ok:!1,error:d(l),writeBacks:[],notices:c};i.push(o)}f.push({op:`appendElems`,jp:a,elems:i});continue}if(i===`merge`){let r=e.value;if(typeof r==`string`){let e=Sp(r);if(e.parseError)return{ok:!1,error:zl(`patches merge`,r,e.parseError),writeBacks:[],notices:c};r=e.parsed}if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:$({code:`PATCH_FAILED`,message:`merge 的 value 需为对象`,hint:`merge 合并对象键;整体替换用 set`}),writeBacks:[],notices:c};let i=[];for(let e of Object.keys(r)){if(e.startsWith(`__pg`)||mp.has(e))continue;let r=a?`${a}.${e}`:e,o=l(r),s=Tf(t,r,o);if(!s.ok){if(s.resolution===`missing`){if(_p(n,r)===void 0)return{ok:!1,error:d([r]),writeBacks:[],notices:c};i.push([e,o]);continue}return{ok:!1,error:u(r,s.issues??[]),writeBacks:[],notices:c}}s.resolution===`open`&&c.push(`${r}=开放节点放行`);let f=Fp(_p(n,r),o,s.data,r);if(f.length)return{ok:!1,error:d(f),writeBacks:[],notices:c};i.push([e,s.data])}f.push({op:`mergeKeys`,jp:a,entries:i});continue}let h=l(a),g=a.lastIndexOf(`.`);if(g>0&&/^\d+$/.test(a.slice(g+1))){let e=_p(r,a.slice(0,g));if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!(t in e))return{ok:!1,error:$({code:`PATCH_FAILED`,message:`set @ "${a}" 越界数组索引产生稀疏空洞(父数组长度 ${e.length})`,hint:`数组索引须连续(≤ 当前长度);追加请用 op:"append"`}),writeBacks:[],notices:c}}}let _=Tf(t,a,h);if(!_.ok){if(_.resolution===`missing`){if(_p(n,a)===void 0)return{ok:!1,error:d([a]),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:h});continue}return{ok:!1,error:u(a,_.issues??[]),writeBacks:[],notices:c}}_.resolution===`open`&&c.push(`${a||`(根)`}=开放节点放行`);let v=Fp(_p(n,a),h,_.data,a);if(v.length)return{ok:!1,error:d(v),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:_.data})}return{ok:!0,writeBacks:f,notices:c}}function Ag(e){let{bindRef:t,schema:n,allowKeys:r,snapshots:i,maxSnapshots:a,audit:o,dryRun:s,op:c=`set`,protectedCtx:l,snapshotLabel:u}=e,d=e.value,f=e.internalAfterWrite?bp(t):null,p=Mg(d);if(p)return{ok:!1,error:Ng(p)};if(l){let e=Sg({value:d,ctx:l});if(!e.ok)return{ok:!1,error:e.error};d=e.value}let m=Og({schema:n,allowKeys:r,value:d,bindRef:t});if(!m.ok)return{ok:!1,error:m.error};let h=m.assembly;if(s)return{ok:!0,hash:``,data:h,notices:m.notices};if(typeof t!=`object`||!t)return{ok:!1,error:$({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${t===null?`null`:typeof t}),无法就地替换外部持有的值引用`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:"x"})或集成方通过 sdk.setData 替换 bind`})};let g=bp(t),_=i.length?i[i.length-1].id+1:1;for(i.push({id:_,ts:Date.now(),op:c,value:g,...u?{label:u}:{}});i.length>a;)i.shift();return typeof h==`object`&&h&&(m.wholeParsed?Pp(t,h):gp(t,h)),o({op:c,value:h,timestamp:Date.now()}),e.onWrite?.(),e.internalAfterWrite?.(t,f),{ok:!0,hash:e.hashFn?e.hashFn():Dp(t),data:h,notices:m.notices}}function jg(e){let{bindRef:t,patches:n,schema:r,allowKeys:i,snapshots:a,maxSnapshots:o,markDataDirty:s,schemaErrorMode:c=`zod`,snapshotLabel:l,dryRun:u,protectedCtx:d}=e,f=e.internalAfterWrite?bp(t):null,p=bp(t),m=[],h=[],g=[],_=[],v=(e,t)=>{(e===`set`||e===`merge`)&&_.push({jp:t,val:_p(p,t)})};for(let e=0;e<n.length;e++){let t=n[e],a=t.jsonPath||``;if(hp(a))return{ok:!1,error:$({code:`PATH_UNSAFE`,message:`patches[${e}] jsonPath "${a}" 含非法段`,hint:`使用正常属性路径,如 components.0.text`})};if(!yf(a,r,i))return{ok:!1,error:$({code:`PATH_DENIED`,message:`patches[${e}] @ "${a}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可写${Eg(Tg(r,Dg(a)))}`})};let o=t.op??`set`,s;if(o!==`remove`){if(t.value===void 0||t.value===``&&o===`move`)return{ok:!1,error:$({code:`MISSING_VALUE`,message:`patches[${e}] ${o} 操作需要 value`,hint:`op 为 ${o} 时 value 必填;删除请用 op:'remove'`})};let n=Sp(t.value);if(n.parseError)return{ok:!1,error:zl(`patches[${e}]`,t.value,n.parseError)};if(s=n.parsed,o!==`move`){let t=Mg(s);if(t)return{ok:!1,error:Ng(t,`patches[${e}] @ "${a}"`)}}if(o===`move`&&typeof s==`string`&&!yf(s,r,i))return{ok:!1,error:$({code:`PATH_DENIED`,message:`patches[${e}] move 目标 "${s}" 不在 schema 声明字段内`,hint:`move 的 value(目标路径)也须在 schema 声明字段内${Eg(Tg(r,Dg(String(s))))}`})}}o===`append`&&h.push({jp:a,elems:Array.isArray(s)?[...s]:[s]}),o===`move`&&g.push({jp:a,toPath:String(s),elem:_p(p,a)});let c=kp(p,o,a,s);if(c)return{ok:!1,error:$({code:`PATCH_FAILED`,message:`patches[${e}]: ${c}`,hint:`检查 op 与目标类型:merge 需对象,append 需数组`})};v(o,a),m.push({op:o,jp:a,value:s})}if(d){let e=Cg({patches:n,clone:p,ctx:d});if(!e.ok)return{ok:!1,error:e.error}}let y=kg({schema:r,bindRef:t,clone:p,patches:n,schemaErrorMode:c,appendCaptures:h,moveCaptures:g,valueAt:e=>_.find(t=>t.jp===e)?.val});if(!y.ok)return{ok:!1,error:y.error};if(u)return{ok:!0,applied:m,clone:p,notices:y.notices};let b=a.length?a[a.length-1].id+1:1;for(a.push({id:b,ts:Date.now(),op:`edit`,value:f??bp(t),...l?{label:l}:{}});a.length>o;)a.shift();for(let e of y.writeBacks)if(e.op===`remove`)yp(t,e.jp);else if(e.op===`set`)vp(t,e.jp,e.value);else if(e.op===`move`)jp(t,e.jp,e.toPath);else if(e.op===`mergeKeys`){let n=e.jp?_p(t,e.jp):t;if(n&&typeof n==`object`&&!Array.isArray(n))for(let[t,r]of e.entries??[])n[t]=r}else if(e.op===`appendElems`){let n=e.jp?_p(t,e.jp):t;Array.isArray(n)&&e.elems?.length&&n.push(...e.elems)}return e.internalAfterWrite?.(t,f),s?.(),{ok:!0,applied:m,clone:p,notices:y.notices}}function Mg(e){let t=/^<[A-Za-z_][\w.-]*\s[\d.]+[KMG]?B>$/,n=e=>{if(typeof e==`string`)return e.includes(`<subtree `)||t.test(e)?e.slice(0,60):null;if(Array.isArray(e)){for(let t of e){let e=n(t);if(e)return e}return null}if(e&&typeof e==`object`)for(let t of Object.values(e)){let e=n(t);if(e)return e}return null};return n(e)}var Ng=(e,t)=>$({code:`PLACEHOLDER_LEAK`,path:t||void 0,message:`写入值包含摘要占位符 "${e}"(read/query 为省上下文返回的体积占位,非真实数据),已拒绝写入`,hint:`占位符子树的真实内容需先窄读获取:read({jsonPath:"<该子树路径>"}) 结果根豁免返回全文;聚焦该区域可用 set_focus。基于真实值重新构造写入内容`});function Pg(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var Fg=3072;function Ig(e){return typeof e==`string`?e.length+2:typeof e==`number`||typeof e==`boolean`?8:4}function Lg(e,t,n,r,i){if(!t||e==null)return e;let a=new Set(n.map(e=>e.field)),o=r,s=Fg,c=i?.rootExempt??!1,l=i?.rootPath??``,u=i?.fullTextPrefixes??[],d=bp(e),f=i?.onSummarized,p=e=>u.some(t=>t&&(e===t||e.startsWith(t+`.`)||e.startsWith(t+`[`))),m=(e,t)=>{let n=`#`+String(Dp(e)).slice(0,8);if(Array.isArray(e))return`<subtree ${Pg(t)} children:${e.length} ${n}>`;let r=Object.keys(e),i=r.slice(0,6).join(`,`)+(r.length>6?`,…`:``);return`<subtree ${Pg(t)} keys:[${i}] ${n}>`},h=(e,t,n)=>{if(typeof e!=`object`||!e)return{node:e,eff:Ig(e)};if(p(t))return{node:e,eff:40};if(Array.isArray(e)){let r=2;for(let n=0;n<e.length;n++){let i=h(e[n],`${t}.${n}`,!1);e[n]=i.node,r+=i.eff}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}}let r=2;for(let n of Object.keys(e)){let i=e[n],s=t?`${t}.${n}`:n;if(typeof i==`string`&&a.has(n)&&i.length>=o&&!p(s))e[n]=`<${n} ${Pg(i.length)}>`,f?.(s),r+=e[n].length+n.length+2;else{let t=h(i,s,!1);e[n]=t.node,r+=t.eff+n.length+2}}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}};return h(d,l,!0).node}var Rg=0;function zg(){return Rg++,`c_`+Math.random().toString(36).slice(2,8)+Rg.toString(36)}function Bg(e,t){if(!(!e||typeof e!=`object`))for(let n of t){let t=_p(e,n);if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&!(`__pgId`in e)&&(e.__pgId=zg())}}function Vg(e){(function e(t){if(Array.isArray(t))t.forEach(e);else if(t&&typeof t==`object`)for(let n of Object.keys(t))n.startsWith(`__pg`)?delete t[n]:e(t[n])})(e)}function Hg(e,n={}){let i=n.pgIdPaths??[],a=i.length?(e,t)=>{if(t&&typeof t==`object`)for(let n of i){let r=_p(t,n),i=_p(e,n);if(!Array.isArray(r)||!Array.isArray(i))continue;let a=e=>{if(!e||typeof e!=`object`)return e;let t={...e};return delete t.__pgId,t},o=new Set;for(let e=0;e<i.length;e++){let t=i[e];if(!(!t||typeof t!=`object`||`__pgId`in t))for(let e=0;e<r.length;e++){if(o.has(e))continue;let n=r[e];if(!(!n||typeof n!=`object`||!n.__pgId)&&hg(a(n),a(t))){t.__pgId=n.__pgId,o.add(e);break}}}for(let e=0;e<r.length&&e<i.length;e++){if(o.has(e))continue;let t=r[e]?.__pgId,n=i[e];t&&n&&typeof n==`object`&&!(`__pgId`in n)&&(n.__pgId=t,o.add(e))}}Bg(e,i)}:void 0,o=i.length?Kf(e.schema,i).schema:e.schema,s=e.bind,c=e.description??`主数据对象`,l=vf(o),u=new Map,d=n.vfsStore?new _g(n.vfsStore):void 0;function f(e){if(u.clear(),e)for(let t of e){let e=pg(t.path);u.set(e,{path:e,mode:t.mode})}}f(e.resources);let p=u.size?{resourcesByPath:u,resourceStore:d,getBind:()=>s}:void 0,m=[],h=n.maxSnapshots??20,g=new Map,_=``,v=e=>e?.configurable?.__pgDataScope??_,y=e=>{let t=e?.configurable?.__pgFullTextPaths;return Array.isArray(t)?t.map(String):void 0},b=new Set,x=e=>{for(b.add(e);b.size>500;)b.delete(b.values().next().value)},S=e=>g.get(e??_),C=(e,t)=>{let n=t??_;e===void 0?g.delete(n):g.set(n,e)},w=n.conflictWatchFields??[],T=!w.includes(`*`)&&w.length?new Set(w):void 0,E=w.length>0,D=()=>T?Op(s,T):Dp(s),ee=(n.maxParallelTools??1)>1&&E,O=!1,k=[];async function te(){if(!ee)return{release:()=>{},reacquire:async()=>{}};O?await new Promise(e=>k.push(e)):O=!0;let e=!0;return{release:()=>{if(!e)return;e=!1;let t=k.shift();t?t():O=!1},reacquire:async()=>{e||=(O?await new Promise(e=>k.push(e)):O=!0,!0)}}}(n.maxParallelTools??1)>1&&!E&&console.warn(`[page-agent-sdk] maxParallelTools>1 且未声明 conflictWatchFields:并发写不互锁(后写覆盖前写,既有明文语义);声明 conflictWatchFields 后自动启用写互锁与乐观锁校验`);let A=e=>{let t=D();return C(t,e),t},j=n.largeTextThreshold??200,M=(n.largeTextPaths??[]).map(e=>{let t=e.lastIndexOf(`.`);return t>0?{arrayPath:e.slice(0,t),field:e.slice(t+1)}:null}).filter(e=>e!==null),ne=!0;function N(){ne=!0}let P={get:()=>({schema:o,bind:s,description:c}),set:e=>{o=i.length?Kf(e.schema,i).schema:e.schema,s=e.bind,c=e.description??`主数据对象`,l=vf(o),m.length=0,g.clear(),f(e.resources),d?.clear(),N()},update:e=>{s=e,m.length=0,g.clear(),N()},markDataDirty:N,consumeDataDirty:()=>{let e=ne;return ne=!1,e},enterScope:e=>{let t=_;return _=e,()=>{_=t}},exitScope:e=>{g.delete(e)},recomputeBaseline:e=>{g.set(e??``,D())},recomputeAllBaselines:()=>{let e=D();for(let t of g.keys())g.set(t,e)},hasBaselines:()=>g.size>0,getSummarizedPaths:()=>[...b],clearSummarizedPaths:()=>b.clear(),getResourcesSnapshot:()=>{let e=[];for(let[t,n]of u)if(n.mode===`verbatim`){let r=d?.get(t);e.push(r?.handle?{path:t,mode:n.mode,handle:r.handle}:{path:t,mode:n.mode})}else e.push({path:t,mode:n.mode});return e},createResource:d?(e,t)=>{let n=pg(e),r=u.get(n),i=t===void 0?_p(s,n):t;return d.ensure(n,i,r?.mode??`verbatim`)}:void 0,getResource:d?e=>{let t=d.get(e);return t?{path:t.path,mode:t.mode,value:t.value,handle:t.handle}:void 0}:void 0,updateResource:d?(e,t)=>{let n=pg(e);d.update(n,t),vp(s,n,t),N(),C(D(),``)}:void 0,deleteResource:d?e=>d.delete(e):void 0,listResources:d?()=>d.list():void 0},F=e=>{n.onAudit?.(e)};function re(e,t){let n=bp(s),r=m.length?m[m.length-1].id+1:1;for(m.push({id:r,ts:Date.now(),op:e,label:t,value:n});m.length>h;)m.shift();return r}async function ie(e,t,r,i){if(!t||t===``)return null;let a=D();if(a===t)return null;if(!n.onConflict)return $({code:`VERSION_CONFLICT`,message:`乐观锁冲突:expectedHash=${t} 但当前 hash=${a}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入。当前值:${Tp(s,400)}`});i?.release();let o=await n.onConflict({op:e,agentValue:r,currentValue:s,currentHash:a,expectedHash:t,snapshotId:0});if(o.action===`keep_external`)return`已保留外部修改(未写入)。当前值:${Tp(s,400)} (hash=${a})。请重新 read 拿最新值与 hash 再改。`;if(o.action===`restore`){if(await i?.reacquire(),!m.length)return`无历史快照可回退(本次为首次操作)。当前值:${Tp(s,400)} (hash=${a})。请重新 read 再改或选「强制覆盖」。`;let e=m[m.length-1];return Np(s,bp(e.value)),N(),C(D()),`已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${Tp(s,400)} (hash=${D()})。请基于回退后的值重写或停止。`}await i?.reacquire();let c=D();return c===a?(C(D()),null):(F({op:`conflict_recheck`,detail:`裁决基于 ${a} 恢复时 ${c}(ask 窗口新修改落地,overwrite 被拦)`,timestamp:Date.now()}),$({code:`VERSION_CONFLICT`,message:`裁决恢复点校验失败:裁决基于 hash=${a},恢复时主数据已变为 hash=${c}(裁决等待期间又有新修改落地,裁决者未见过)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入(单次校验,不再二次挂起)。`}))}let ae=(e,t=!0)=>{e.writeCapable=t},I=(0,r.tool)(async()=>[`说明: ${c}`,`格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误,含具体字段与期望类型)。`].join(`
|
|
94
|
+
`)}`:`未找到匹配 /${t}/ 的内容。`},{name:`vfs_grep`,description:`在虚拟工作区文件内容中正则搜索。`,schema:t.z.object({pattern:t.z.string().describe(`正则表达式`),path:t.z.string().optional().describe(`限定单个文件,不传则搜索全部`)})}),(0,r.tool)(async({path:t,jsonPath:n})=>{let r=tg(t),i=e.files[r];if(!i)return $({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return $({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_read 要求文件内容是合法 JSON;先 vfs_read 查看实际内容,或 vfs_write({jsonString:true}) 重写为合法 JSON`})}if(n){let e=_p(a,n);return e===void 0?$({code:`VFS_PATH_NOT_FOUND`,path:t,message:`jsonPath "${n}" 不存在`,hint:`不传 jsonPath 整体读查看结构,或核对路径段`}):`${t}#${n} (JSON):\n${JSON.stringify(e)}`}return`${t} (JSON):\n${JSON.stringify(a)}`},{name:`vfs_json_read`,description:`把虚拟工作区文件当 JSON 读取:先 parse 整文件,再按 jsonPath 取子树(省略返整体)。文件非合法 JSON 报 VFS_JSON_INVALID。适合结构化读取 vfs 内大 JSON。`,schema:t.z.object({path:t.z.string().describe(`文件路径(内容须为合法 JSON)`),jsonPath:t.z.string().optional().describe(`点分隔子路径(如 components.0.title);省略读整体`)})}),(0,r.tool)(async({path:t,patches:n})=>{let r=tg(t),i=e.files[r];if(!i)return $({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return $({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_patch 要求文件内容是合法 JSON`})}let o=bp(a),s=[];for(let e of n){let n=kp(o,e.op,e.jsonPath,e.value);if(n)return $({code:`PATCH_FAILED`,path:t,message:n,hint:`修正 patches 后重试(原文件未改动)`,details:{failedPatch:e}});s.push(e.jsonPath||`(根)`)}let c=JSON.stringify(o);return e.files[r]={content:c,updatedAt:rg()},`已对 ${t} 应用 ${n.length} 个 patch(影响 ${s.length} 处:${s.join(`, `)}),文件现 ${c.length} 字符`},{name:`vfs_json_patch`,description:`在虚拟工作区 JSON 文件内做原子 jsonPath patch(set/remove/merge/append)。先 parse → clone 上应用全部 patches → 任一失败或 JSON 非法则整体不写回(原文件不变)。`,schema:t.z.object({path:t.z.string().describe(`文件路径(内容须为合法 JSON)`),patches:t.z.array(t.z.object({op:t.z.enum([`set`,`remove`,`merge`,`append`]).describe(`操作`),jsonPath:t.z.string().describe(`点分隔路径(如 components.0.title);merge/append 目标可为根(空串)`),value:t.z.any().optional().describe(`set/merge/append 的值(remove 不需要)`)})).describe(`按顺序应用的 patch 列表(原子:任一失败整体不写回)`)})}),(0,r.tool)(async({path:t})=>{let n=tg(t);return e.files[n]?(delete e.files[n],`已删除 ${t}`):$({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}",无需删除`,hint:`用 vfs_ls 查看虚拟工作区文件列表`})},{name:`vfs_rm`,description:`删除虚拟工作区文件(清理中间产物 / drafts 下草稿,补「只进不出」的闭环)。不存在返回 NOT_FOUND。`,schema:t.z.object({path:t.z.string().describe(`要删除的文件路径`)})})]}function og(e){return{name:`vfs`,tools:ag(e),beforeAgent:()=>({files:e.files})}}var sg=`⟦frozen:`,cg=`⟦res:`,lg=`⟧`;function ug(e){return`${sg}${e}${lg}`}function dg(e){return`${cg}${e}${lg}`}function fg(e){return typeof e==`string`?e.startsWith(sg)&&e.endsWith(lg)?{type:`frozen`,path:e.slice(8,e.length-1)}:e.startsWith(cg)&&e.endsWith(lg)?{type:`res`,handle:e.slice(5,e.length-1)}:null:null}function pg(e){return String(e??``).trim().replace(/^\.+/,``)}function mg(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return(t>>>0).toString(16).padStart(8,`0`).slice(0,8)}function hg(e,t){return e===t?!0:e&&t&&typeof e==`object`&&typeof t==`object`?JSON.stringify(e)===JSON.stringify(t):!1}function gg(e,t){let n=pg(e);if(!n)return;let r=t.get(n);if(r)return{spec:r,relation:`exact`,protectedPath:n};let i;for(let[e,r]of t)n!==e&&(n.startsWith(e+`.`)?(!i||e.length>i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`descendant`}):e.startsWith(n+`.`)&&(!i||e.length<i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`ancestor`}));return i}var _g=class{vfs;constructor(e){this.vfs=e}key(e){return`resources/${e}.json`}ensure(e,t,n){let r=mg(e),i={path:e,mode:n,value:t,handle:r};return this.vfs.files[this.key(r)]={content:JSON.stringify(i),updatedAt:Date.now()},r}get(e){return this.readEntry(this.key(e))||this.readEntry(this.key(mg(e)))}readEntry(e){let t=this.vfs.files[e];if(t)try{let e=JSON.parse(t.content);return e&&typeof e.path==`string`?e:void 0}catch{return}}update(e,t){let n=this.get(e);this.ensure(e,t,n?.mode??`verbatim`)}delete(e){let t=this.get(e)?.handle??mg(e),n=this.key(t),r=!!this.vfs.files[n];return r&&delete this.vfs.files[n],r}list(){let e=[];for(let[t,n]of Object.entries(this.vfs.files))if(t.startsWith(`resources/`))try{let t=JSON.parse(n.content);t&&typeof t.path==`string`&&e.push({path:t.path,mode:t.mode,handle:t.handle,bytes:n.content.length})}catch{}return e}clear(){for(let e of Object.keys(this.vfs.files))e.startsWith(`resources/`)&&delete this.vfs.files[e]}};function vg(e){let{jp:t,resolved:n,resourcesByPath:r,resourceStore:i}=e;if(!r.size)return n;let a=!1;for(let e of r.keys())if(t===``||e===t||e.startsWith(t+`.`)){a=!0;break}if(!a)return n;let o=bp(n);for(let[e,n]of r){if(t!==``&&e!==t&&!e.startsWith(t+`.`))continue;if(e===t){if(o===void 0)continue;return n.mode===`freeze`?ug(e):i?dg(i.ensure(e,o,`verbatim`)):o}let r=t===``?e:e.slice(t.length+1),a=_p(o,r);a!==void 0&&(n.mode===`freeze`?vp(o,r,ug(e)):i&&vp(o,r,dg(i.ensure(e,a,`verbatim`))))}return o}function yg(e,t,n,r){if(!r)return{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 无法展开(资源池未启用)`,hint:`verbatim 保护需启用 vfs(capabilities.vfs 默认开);集成方经 createChatSdk 配 data.resources 时自动提供 vfsStore`};let i=r.get(e);return i?n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,hint:`该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构`}:hg(i.value,n)?{value:i.value}:(r.update(t,n),{value:n}):n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,hint:`重新 read 该字段触发懒注册`}:{code:`RESOURCE_EVICTED`,message:`字段 "${t}" 的 verbatim 资源已被淘汰(资源池 LRU)`,hint:`重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧`}}function bg(e,t,n){let r=t.getBind();for(let[i,a]of t.resourcesByPath){let o=_p(r,i),s=_p(e,i);if(s===void 0){if(o===void 0)continue;let t=i.split(`.`);if(_p(e,t.length>1?t.slice(0,-1).join(`.`):``)!==void 0){vp(e,i,o);continue}if(!(e&&typeof e==`object`&&t[0]in e)){if(n)continue;vp(e,i,o);continue}return{ok:!1,code:a.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,path:i,message:`整体替换会移除受保护字段 "${i}"(${a.mode}),已拒绝`,hint:a.mode===`freeze`?`含冻结字段的容器不可整体清空/替换:保留包含该字段的元素(补齐其必填字段,如 type),或逐个 remove 其余元素;彻底移除该字段需集成方调整 data.resources`:`含 verbatim 字段的容器不可整体清空/替换:保留包含该字段的元素,或先 resource_delete({path}) 释放保护后再整体替换`}}if(a.mode===`freeze`){if(s===ug(i)){vp(e,i,o);continue}if(!hg(s,o))return{ok:!1,code:`FROZEN_FIELD`,path:i,message:`字段 "${i}" 已冻结(freeze 保护),不可修改`,hint:`该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值`}}else{let n=fg(s);if(n&&n.type===`res`){let r=yg(n.handle,i,o,t.resourceStore);if(`value`in r){vp(e,i,r.value);continue}return{ok:!1,code:r.code,path:i,message:r.message,hint:r.hint}}if(!hg(s,o))return{ok:!1,code:`VERBATIM_MISMATCH`,path:i,message:`字段 "${i}" 为 verbatim 保护(精确原样保留),写入值与原值不符`,hint:`要改该值请先 resource_update({path, value}) 更新资源池,再写回句柄 ⟦res:<handle>⟧;或写回原值(经 resource_get 取到的值)保持不变`}}}return{ok:!0}}function xg(e,t,n){let r=t===void 0?e.message:`patches[${t}]${n?` @ "${n}"`:``}: ${e.message}`;return $({code:e.code,path:e.path,message:r,hint:e.hint,...t===void 0?{}:{details:{patchIndex:t,patchJsonPath:n??null}}})}function Sg(e){let{value:t,ctx:n,mergeMode:r}=e;if(!n||!n.resourcesByPath.size)return{ok:!0,value:t};let i=bp(t),a=bg(i,n,r);return a.ok?{ok:!0,value:i}:{ok:!1,error:xg(a)}}function Cg(e){let{patches:t,clone:n,ctx:r}=e;if(!r||!r.resourcesByPath.size)return{ok:!0};for(let e=0;e<t.length;e++){let n=t[e];if(n.op===`remove`){let t=gg(n.jsonPath||``,r.resourcesByPath);if(t){let r=t.spec.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,i=t.spec.mode===`freeze`?`冻结字段不可删。如需移除请联系集成方调整 data.resources 配置`:`verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删`;return{ok:!1,error:$({code:r,path:t.protectedPath,message:`patches[${e}] @ "${n.jsonPath}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,hint:i,details:{patchIndex:e,patchJsonPath:n.jsonPath??``}})}}}}let i=bg(n,r);if(!i.ok){let e=wg(i.path,t);return{ok:!1,error:xg(i,e>=0?e:void 0,e>=0?t[e].jsonPath:void 0)}}return{ok:!0}}function wg(e,t){let n=pg(e);for(let e=0;e<t.length;e++){let r=pg(t[e].jsonPath||``);if(r&&(r===n||n.startsWith(r+`.`)||r.startsWith(n+`.`)))return e}return-1}function Tg(e,t){if(!e)return null;let n=(t?xf(e,t):e)?.shape;return n&&typeof n==`object`?Object.keys(n):null}var Eg=e=>e&&e.length?`(可用字段:${e.slice(0,12).join(`, `)}${e.length>12?` …`:``})`:``,Dg=e=>/[.[]/.test(e)?e.replace(/[.[][^.[]*$/,``):``;function Og(e){let{schema:t,allowKeys:n,value:r,bindRef:i}=e,a=[];if(n){if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:Rl(``,[{path:[],code:`invalid_type`,message:`整体 set 需为 JSON 对象(当前为 ${Array.isArray(r)?`array`:r===null?`null`:typeof r})`,expected:`object`}]),notices:a};let e=i&&typeof i==`object`&&!Array.isArray(i)?i:{},n=r,o={};for(let r of Object.keys(n)){if(r.startsWith(`__pg`))continue;let i=n[r],s=Tf(t,r,i);if(!s.ok){if(s.resolution===`missing`){if(r in e)continue;return{ok:!1,error:$({code:`SCHEMA_STRIP`,message:`字段 ${r} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${Eg(Tg(t,``))}`,path:r,details:{stripped:[r]}}),notices:a}}return{ok:!1,error:Rl(r,s.issues??[]),notices:a}}s.resolution===`open`&&a.push(`${r}=开放节点放行`);let c=Fp(e[r],i,s.data,r);if(c.length)return{ok:!1,error:$({code:`SCHEMA_STRIP`,message:`字段 ${c.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${Eg(Tg(t,Dg(String(c[0]))))}`,path:c[0],details:{stripped:c}}),notices:a};o[r]=s.data}return Ef(t)&&a.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`),{ok:!0,assembly:o,wholeParsed:null,notices:a}}let o=t.safeParse(r);if(!o.success)return{ok:!1,error:Rl(``,o.error.issues),notices:a};let s=Fp(i,r,o.data);return s.length?{ok:!1,error:$({code:`SCHEMA_STRIP`,message:`字段 ${s.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:s[0],details:{stripped:s}}),notices:a}:{ok:!0,assembly:o.data,wholeParsed:o.data,notices:a}}function kg(e){let{schema:t,bindRef:n,clone:r,patches:i,schemaErrorMode:a=`zod`,appendCaptures:o,moveCaptures:s}=e,c=[],l=t=>{let n=_p(r,t);return n===void 0?e.valueAt?.(t):n},u=(e,t)=>a===`schema_invalid`?$({code:`SCHEMA_INVALID`,message:`patches 应用后局部校验失败 @ "${e}",未写入`,hint:`确认该路径的值符合 schema;兄弟节点的既有数据不影响本次写入`,details:Ll(t)}):Rl(e,t),d=e=>$({code:`SCHEMA_STRIP`,message:`字段 ${e.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:e[0],details:{stripped:e}}),f=[];Ef(t)&&c.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`);let p=0,m=0;for(let e of i){let i=e.op??`set`,a=e.jsonPath||``;if(i===`remove`){let e=a.lastIndexOf(`.`);if(e>0&&/^\d+$/.test(a.slice(e+1))){let n=a.slice(0,e),i=wf(t,n);if(i.kind===`schemas`){let e=_p(r,n);if(Array.isArray(e))for(let t of i.schemas){let r=Df(t);if(r!==null&&e.length<r)return{ok:!1,error:u(n,[{path:[n],code:`too_small`,message:`删除后数组长度 ${e.length} 低于 schema 最小约束 ${r}`,expected:`>=${r}`}]),writeBacks:[],notices:c}}}}f.push({op:`remove`,jp:a});continue}if(i===`move`){let n=s[m++];if(n&&n.elem!==void 0){let e=n.toPath.lastIndexOf(`.`),r=e>0&&/^\d+$/.test(n.toPath.slice(e+1))?n.toPath.slice(0,e):n.toPath,i=wf(t,r);if(i.kind===`schemas`){let e=Of(i.schemas);if(e.length){let t=[],r=!1;for(let i of e){let e=i.safeParse(n.elem);if(e.success){r=!0;break}t.push(...e.error?.issues??[])}if(!r)return{ok:!1,error:u(n.toPath,t),writeBacks:[],notices:c}}}else i.kind===`open`&&c.push(`${r}=开放节点放行`)}f.push({op:`move`,jp:a,toPath:String(e.value)});continue}if(i===`append`){let e=o[p++]?.elems??[],r=_p(n,a);if(typeof r==`string`&&typeof e[0]==`string`){let n=e[0],i=wf(t,a);if(i.kind===`missing`)return{ok:!1,error:d([a]),writeBacks:[],notices:c};let o=r+n;if(i.kind!==`open`){let e=i.schemas.map(e=>e.safeParse(o)).find(e=>!e.success);if(e)return{ok:!1,error:u(a,e.error?.issues??[]),writeBacks:[],notices:c}}f.push({op:`appendStr`,jp:a,str:n});continue}if(!e.length){f.push({op:`appendElems`,jp:a,elems:[]});continue}let i=wf(t,a);if(i.kind===`missing`)return{ok:!1,error:d([a||`(根)`]),writeBacks:[],notices:c};if(i.kind===`open`){c.push(`${a||`(根)`}=开放节点放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let s=Of(i.schemas);if(!s.length){c.push(`${a||`(根)`}:目标非 schema 声明数组,元素未校验放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let l=[];for(let t=0;t<e.length;t++){let n=[],r,i=!1;for(let a of s){let o=a.safeParse(e[t]);if(o.success){i=!0,r=o.data;break}n.push(...o.error?.issues??[])}if(!i)return{ok:!1,error:u(`${a||`(根)`}[新增元素${t}]`,n),writeBacks:[],notices:c};let o=Fp(void 0,e[t],r,a?`${a}.${t}`:String(t));if(o.length)return{ok:!1,error:d(o),writeBacks:[],notices:c};l.push(r)}f.push({op:`appendElems`,jp:a,elems:l});continue}if(i===`merge`){let r=e.value;if(typeof r==`string`){let e=Sp(r);if(e.parseError)return{ok:!1,error:zl(`patches merge`,r,e.parseError),writeBacks:[],notices:c};r=e.parsed}if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:$({code:`PATCH_FAILED`,message:`merge 的 value 需为对象`,hint:`merge 合并对象键;整体替换用 set`}),writeBacks:[],notices:c};let i=[];for(let e of Object.keys(r)){if(e.startsWith(`__pg`)||mp.has(e))continue;let r=a?`${a}.${e}`:e,o=l(r),s=Tf(t,r,o);if(!s.ok){if(s.resolution===`missing`){if(_p(n,r)===void 0)return{ok:!1,error:d([r]),writeBacks:[],notices:c};i.push([e,o]);continue}return{ok:!1,error:u(r,s.issues??[]),writeBacks:[],notices:c}}s.resolution===`open`&&c.push(`${r}=开放节点放行`);let f=Fp(_p(n,r),o,s.data,r);if(f.length)return{ok:!1,error:d(f),writeBacks:[],notices:c};i.push([e,s.data])}f.push({op:`mergeKeys`,jp:a,entries:i});continue}let h=l(a),g=a.lastIndexOf(`.`);if(g>0&&/^\d+$/.test(a.slice(g+1))){let e=_p(r,a.slice(0,g));if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!(t in e))return{ok:!1,error:$({code:`PATCH_FAILED`,message:`set @ "${a}" 越界数组索引产生稀疏空洞(父数组长度 ${e.length})`,hint:`数组索引须连续(≤ 当前长度);追加请用 op:"append"`}),writeBacks:[],notices:c}}}let _=Tf(t,a,h);if(!_.ok){if(_.resolution===`missing`){if(_p(n,a)===void 0)return{ok:!1,error:d([a]),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:h});continue}return{ok:!1,error:u(a,_.issues??[]),writeBacks:[],notices:c}}_.resolution===`open`&&c.push(`${a||`(根)`}=开放节点放行`);let v=Fp(_p(n,a),h,_.data,a);if(v.length)return{ok:!1,error:d(v),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:_.data})}return{ok:!0,writeBacks:f,notices:c}}function Ag(e){let{bindRef:t,schema:n,allowKeys:r,snapshots:i,maxSnapshots:a,audit:o,dryRun:s,op:c=`set`,protectedCtx:l,snapshotLabel:u}=e,d=e.value,f=e.internalAfterWrite?bp(t):null,p=Mg(d);if(p)return{ok:!1,error:Ng(p)};if(l){let e=Sg({value:d,ctx:l,mergeMode:!!r});if(!e.ok)return{ok:!1,error:e.error};d=e.value}let m=Og({schema:n,allowKeys:r,value:d,bindRef:t});if(!m.ok)return{ok:!1,error:m.error};let h=m.assembly;if(s)return{ok:!0,hash:``,data:h,notices:m.notices};if(typeof t!=`object`||!t)return{ok:!1,error:$({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${t===null?`null`:typeof t}),无法就地替换外部持有的值引用`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:"x"})或集成方通过 sdk.setData 替换 bind`})};let g=bp(t),_=i.length?i[i.length-1].id+1:1;for(i.push({id:_,ts:Date.now(),op:c,value:g,...u?{label:u}:{}});i.length>a;)i.shift();return typeof h==`object`&&h&&(m.wholeParsed?Pp(t,h):gp(t,h)),o({op:c,value:h,timestamp:Date.now()}),e.onWrite?.(),e.internalAfterWrite?.(t,f),{ok:!0,hash:e.hashFn?e.hashFn():Dp(t),data:h,notices:m.notices}}function jg(e){let{bindRef:t,patches:n,schema:r,allowKeys:i,snapshots:a,maxSnapshots:o,markDataDirty:s,schemaErrorMode:c=`zod`,snapshotLabel:l,dryRun:u,protectedCtx:d}=e,f=e.internalAfterWrite?bp(t):null,p=bp(t),m=[],h=[],g=[],_=[],v=(e,t)=>{(e===`set`||e===`merge`)&&_.push({jp:t,val:_p(p,t)})};for(let e=0;e<n.length;e++){let t=n[e],a=t.jsonPath||``;if(hp(a))return{ok:!1,error:$({code:`PATH_UNSAFE`,message:`patches[${e}] jsonPath "${a}" 含非法段`,hint:`使用正常属性路径,如 components.0.text`})};if(!yf(a,r,i))return{ok:!1,error:$({code:`PATH_DENIED`,message:`patches[${e}] @ "${a}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可写${Eg(Tg(r,Dg(a)))}`})};let o=t.op??`set`,s;if(o!==`remove`){if(t.value===void 0||t.value===``&&o===`move`)return{ok:!1,error:$({code:`MISSING_VALUE`,message:`patches[${e}] ${o} 操作需要 value`,hint:`op 为 ${o} 时 value 必填;删除请用 op:'remove'`})};let n=Sp(t.value);if(n.parseError)return{ok:!1,error:zl(`patches[${e}]`,t.value,n.parseError)};if(s=n.parsed,o!==`move`){let t=Mg(s);if(t)return{ok:!1,error:Ng(t,`patches[${e}] @ "${a}"`)}}if(o===`move`&&typeof s==`string`&&!yf(s,r,i))return{ok:!1,error:$({code:`PATH_DENIED`,message:`patches[${e}] move 目标 "${s}" 不在 schema 声明字段内`,hint:`move 的 value(目标路径)也须在 schema 声明字段内${Eg(Tg(r,Dg(String(s))))}`})}}o===`append`&&h.push({jp:a,elems:Array.isArray(s)?[...s]:[s]}),o===`move`&&g.push({jp:a,toPath:String(s),elem:_p(p,a)});let c=kp(p,o,a,s);if(c)return{ok:!1,error:$({code:`PATCH_FAILED`,message:`patches[${e}]: ${c}`,hint:`检查 op 与目标类型:merge 需对象,append 需数组或字符串`})};v(o,a),m.push({op:o,jp:a,value:s})}if(d){let e=Cg({patches:n,clone:p,ctx:d});if(!e.ok)return{ok:!1,error:e.error}}let y=kg({schema:r,bindRef:t,clone:p,patches:n,schemaErrorMode:c,appendCaptures:h,moveCaptures:g,valueAt:e=>_.find(t=>t.jp===e)?.val});if(!y.ok)return{ok:!1,error:y.error};if(u)return{ok:!0,applied:m,clone:p,notices:y.notices};let b=a.length?a[a.length-1].id+1:1;for(a.push({id:b,ts:Date.now(),op:`edit`,value:f??bp(t),...l?{label:l}:{}});a.length>o;)a.shift();for(let e of y.writeBacks)if(e.op===`remove`)yp(t,e.jp);else if(e.op===`set`)vp(t,e.jp,e.value);else if(e.op===`move`)jp(t,e.jp,e.toPath);else if(e.op===`mergeKeys`){let n=e.jp?_p(t,e.jp):t;if(n&&typeof n==`object`&&!Array.isArray(n))for(let[t,r]of e.entries??[])n[t]=r}else if(e.op===`appendElems`){let n=e.jp?_p(t,e.jp):t;Array.isArray(n)&&e.elems?.length&&n.push(...e.elems)}else if(e.op===`appendStr`){let n=e.jp?_p(t,e.jp):t;typeof n==`string`&&typeof e.str==`string`&&vp(t,e.jp,n+e.str)}return e.internalAfterWrite?.(t,f),s?.(),{ok:!0,applied:m,clone:p,notices:y.notices}}function Mg(e){let t=/^<[A-Za-z_][\w.-]*\s[\d.]+[KMG]?B>$/,n=e=>{if(typeof e==`string`)return e.includes(`<subtree `)||t.test(e)?e.slice(0,60):null;if(Array.isArray(e)){for(let t of e){let e=n(t);if(e)return e}return null}if(e&&typeof e==`object`)for(let t of Object.values(e)){let e=n(t);if(e)return e}return null};return n(e)}var Ng=(e,t)=>$({code:`PLACEHOLDER_LEAK`,path:t||void 0,message:`写入值包含摘要占位符 "${e}"(read/query 为省上下文返回的体积占位,非真实数据),已拒绝写入`,hint:`占位符子树的真实内容需先窄读获取:read({jsonPath:"<该子树路径>"}) 结果根豁免返回全文;聚焦该区域可用 set_focus。基于真实值重新构造写入内容`});function Pg(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var Fg=3072;function Ig(e){return typeof e==`string`?e.length+2:typeof e==`number`||typeof e==`boolean`?8:4}function Lg(e,t,n,r,i){if(!t||e==null)return e;let a=new Set(n.map(e=>e.field)),o=r,s=Fg,c=i?.rootExempt??!1,l=i?.rootPath??``,u=i?.fullTextPrefixes??[],d=bp(e),f=i?.onSummarized,p=e=>u.some(t=>t&&(e===t||e.startsWith(t+`.`)||e.startsWith(t+`[`))),m=(e,t)=>{let n=`#`+String(Dp(e)).slice(0,8);if(Array.isArray(e))return`<subtree ${Pg(t)} children:${e.length} ${n}>`;let r=Object.keys(e),i=r.slice(0,6).join(`,`)+(r.length>6?`,…`:``);return`<subtree ${Pg(t)} keys:[${i}] ${n}>`},h=(e,t,n)=>{if(typeof e!=`object`||!e)return{node:e,eff:Ig(e)};if(p(t))return{node:e,eff:40};if(Array.isArray(e)){let r=2;for(let n=0;n<e.length;n++){let i=h(e[n],`${t}.${n}`,!1);e[n]=i.node,r+=i.eff}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}}let r=2;for(let n of Object.keys(e)){let i=e[n],s=t?`${t}.${n}`:n;if(typeof i==`string`&&a.has(n)&&i.length>=o&&!p(s))e[n]=`<${n} ${Pg(i.length)}>`,f?.(s),r+=e[n].length+n.length+2;else{let t=h(i,s,!1);e[n]=t.node,r+=t.eff+n.length+2}}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}};return h(d,l,!0).node}var Rg=0;function zg(){return Rg++,`c_`+Math.random().toString(36).slice(2,8)+Rg.toString(36)}function Bg(e,t){if(!(!e||typeof e!=`object`))for(let n of t){let t=_p(e,n);if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&!(`__pgId`in e)&&(e.__pgId=zg())}}function Vg(e){(function e(t){if(Array.isArray(t))t.forEach(e);else if(t&&typeof t==`object`)for(let n of Object.keys(t))n.startsWith(`__pg`)?delete t[n]:e(t[n])})(e)}function Hg(e,n={}){let i=n.pgIdPaths??[],a=i.length?(e,t)=>{if(t&&typeof t==`object`)for(let n of i){let r=_p(t,n),i=_p(e,n);if(!Array.isArray(r)||!Array.isArray(i))continue;let a=e=>{if(!e||typeof e!=`object`)return e;let t={...e};return delete t.__pgId,t},o=new Set;for(let e=0;e<i.length;e++){let t=i[e];if(!(!t||typeof t!=`object`||`__pgId`in t))for(let e=0;e<r.length;e++){if(o.has(e))continue;let n=r[e];if(!(!n||typeof n!=`object`||!n.__pgId)&&hg(a(n),a(t))){t.__pgId=n.__pgId,o.add(e);break}}}for(let e=0;e<r.length&&e<i.length;e++){if(o.has(e))continue;let t=r[e]?.__pgId,n=i[e];t&&n&&typeof n==`object`&&!(`__pgId`in n)&&(n.__pgId=t,o.add(e))}}Bg(e,i)}:void 0,o=i.length?Kf(e.schema,i).schema:e.schema,s=e.bind,c=e.description??`主数据对象`,l=vf(o),u=new Map,d=n.vfsStore?new _g(n.vfsStore):void 0;function f(e){if(u.clear(),e)for(let t of e){let e=pg(t.path);u.set(e,{path:e,mode:t.mode})}}f(e.resources);let p=u.size?{resourcesByPath:u,resourceStore:d,getBind:()=>s}:void 0,m=[],h=n.maxSnapshots??20,g=new Map,_=``,v=e=>e?.configurable?.__pgDataScope??_,y=e=>{let t=e?.configurable?.__pgFullTextPaths;return Array.isArray(t)?t.map(String):void 0},b=new Set,x=e=>{for(b.add(e);b.size>500;)b.delete(b.values().next().value)},S=e=>g.get(e??_),C=(e,t)=>{let n=t??_;e===void 0?g.delete(n):g.set(n,e)},w=n.conflictWatchFields??[],T=!w.includes(`*`)&&w.length?new Set(w):void 0,E=w.length>0,D=()=>T?Op(s,T):Dp(s),ee=(n.maxParallelTools??1)>1&&E,O=!1,k=[];async function te(){if(!ee)return{release:()=>{},reacquire:async()=>{}};O?await new Promise(e=>k.push(e)):O=!0;let e=!0;return{release:()=>{if(!e)return;e=!1;let t=k.shift();t?t():O=!1},reacquire:async()=>{e||=(O?await new Promise(e=>k.push(e)):O=!0,!0)}}}(n.maxParallelTools??1)>1&&!E&&console.warn(`[page-agent-sdk] maxParallelTools>1 且未声明 conflictWatchFields:并发写不互锁(后写覆盖前写,既有明文语义);声明 conflictWatchFields 后自动启用写互锁与乐观锁校验`);let A=e=>{let t=D();return C(t,e),t},j=n.largeTextThreshold??200,M=(n.largeTextPaths??[]).map(e=>{let t=e.lastIndexOf(`.`);return t>0?{arrayPath:e.slice(0,t),field:e.slice(t+1)}:null}).filter(e=>e!==null),ne=!0;function N(){ne=!0}let P={get:()=>({schema:o,bind:s,description:c}),set:e=>{o=i.length?Kf(e.schema,i).schema:e.schema,s=e.bind,c=e.description??`主数据对象`,l=vf(o),m.length=0,g.clear(),f(e.resources),d?.clear(),N()},update:e=>{s=e,m.length=0,g.clear(),N()},markDataDirty:N,consumeDataDirty:()=>{let e=ne;return ne=!1,e},enterScope:e=>{let t=_;return _=e,()=>{_=t}},exitScope:e=>{g.delete(e)},recomputeBaseline:e=>{g.set(e??``,D())},recomputeAllBaselines:()=>{let e=D();for(let t of g.keys())g.set(t,e)},hasBaselines:()=>g.size>0,getSummarizedPaths:()=>[...b],clearSummarizedPaths:()=>b.clear(),getResourcesSnapshot:()=>{let e=[];for(let[t,n]of u)if(n.mode===`verbatim`){let r=d?.get(t);e.push(r?.handle?{path:t,mode:n.mode,handle:r.handle}:{path:t,mode:n.mode})}else e.push({path:t,mode:n.mode});return e},createResource:d?(e,t)=>{let n=pg(e),r=u.get(n),i=t===void 0?_p(s,n):t;return d.ensure(n,i,r?.mode??`verbatim`)}:void 0,getResource:d?e=>{let t=d.get(e);return t?{path:t.path,mode:t.mode,value:t.value,handle:t.handle}:void 0}:void 0,updateResource:d?(e,t)=>{let n=pg(e);d.update(n,t),vp(s,n,t),N(),C(D(),``)}:void 0,deleteResource:d?e=>d.delete(e):void 0,listResources:d?()=>d.list():void 0},F=e=>{n.onAudit?.(e)};function re(e,t){let n=bp(s),r=m.length?m[m.length-1].id+1:1;for(m.push({id:r,ts:Date.now(),op:e,label:t,value:n});m.length>h;)m.shift();return r}async function ie(e,t,r,i){if(!t||t===``)return null;let a=D();if(a===t)return null;if(!n.onConflict)return $({code:`VERSION_CONFLICT`,message:`乐观锁冲突:expectedHash=${t} 但当前 hash=${a}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入。当前值:${Tp(s,400)}`});i?.release();let o=await n.onConflict({op:e,agentValue:r,currentValue:s,currentHash:a,expectedHash:t,snapshotId:0});if(o.action===`keep_external`)return`已保留外部修改(未写入)。当前值:${Tp(s,400)} (hash=${a})。请重新 read 拿最新值与 hash 再改。`;if(o.action===`restore`){if(await i?.reacquire(),!m.length)return`无历史快照可回退(本次为首次操作)。当前值:${Tp(s,400)} (hash=${a})。请重新 read 再改或选「强制覆盖」。`;let e=m[m.length-1];return Np(s,bp(e.value)),N(),C(D()),`已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${Tp(s,400)} (hash=${D()})。请基于回退后的值重写或停止。`}await i?.reacquire();let c=D();return c===a?(C(D()),null):(F({op:`conflict_recheck`,detail:`裁决基于 ${a} 恢复时 ${c}(ask 窗口新修改落地,overwrite 被拦)`,timestamp:Date.now()}),$({code:`VERSION_CONFLICT`,message:`裁决恢复点校验失败:裁决基于 hash=${a},恢复时主数据已变为 hash=${c}(裁决等待期间又有新修改落地,裁决者未见过)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入(单次校验,不再二次挂起)。`}))}let ae=(e,t=!0)=>{e.writeCapable=t},I=(0,r.tool)(async()=>[`说明: ${c}`,`格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误,含具体字段与期望类型)。`].join(`
|
|
95
95
|
`),{name:`describe_data`,description:`获取主数据的说明与格式要求。`,schema:t.z.object({})}),oe=(0,r.tool)(async({id:e},t)=>{let n=v(t);if(!m.length)return $({code:`NO_SNAPSHOT`,message:`无快照可回退`,hint:`write 各写意图会自动存快照;或 history_data({list:true}) 查看可用快照`});let r=e===void 0?m[m.length-1]:m.find(t=>t.id===e);if(!r)return $({code:`SNAPSHOT_NOT_FOUND`,message:`未找到快照 #${e}`,hint:`用 history_data({list:true}) 查看可用快照序号`});let i=o.safeParse(r.value);return i.success?(Np(s,bp(r.value)),N(),F({op:`restore`,detail:`#${r.id}`,timestamp:Date.now()}),C(D(),n),`已回退主数据到快照 #${r.id}[${r.op}]${r.label?`(${r.label})`:``}。`):$({code:`SNAPSHOT_SCHEMA_INVALID`,message:`快照 #${r.id} 的值不符合当前 schema,无法回退`,hint:`schema 可能已变更;该快照已过期,选其他快照或重新设置`,details:Ll(i.error.issues)})},{name:`restore_data`,description:`把主数据回退到某个快照(就地还原,保留响应式)。不传 id 则回退最近一次(快速回退)。可用 history_data({list:true}) 查看快照列表。`,schema:t.z.object({id:t.z.number().int().optional().describe(`指定快照序号;不传则回退最近一次`)})});ae(oe);let se=(0,r.tool)(async({id:e,jsonPath:t,list:n})=>{if(n){if(!m.length)return`无快照。set/edit/delete 会自动存快照。`;let e=m.map(e=>{let t=JSON.stringify(e.value??``).length,n=new Date(e.ts).toLocaleTimeString(`zh-CN`,{hour12:!1});return` #${e.id} [${e.op}]${e.label?` "${e.label}"`:``} ${n} 修改前≈${t}字符`});return`主数据快照时间线(共 ${m.length} 条,默认最近一次):\n${e.join(`
|
|
96
96
|
`)}\n用 history_data({id}) 查看某条快照内容;restore_data({id}) 回退;diff_data({snapshotId}) 对比差异。`}if(!m.length)return $({code:`NO_SNAPSHOT`,message:`无历史快照可查看`,hint:`set/edit/delete 会自动存快照;或 history_data({list:true}) 查看可用序号`});let r=e===void 0?m[m.length-1]:m.find(t=>t.id===e);if(!r)return $({code:`SNAPSHOT_NOT_FOUND`,message:`未找到快照 #${e}`,hint:`不传 id 查看最近一次;或 history_data({list:true}) 查看可用序号`});let i=bp(r.value),a=t||``;if(a){if(hp(a))return $({code:`PATH_UNSAFE`,message:`jsonPath "${a}" 含非法段`,hint:`使用正常属性路径`});if(!yf(a,o,l))return $({code:`PATH_DENIED`,message:`history_data @ "${a}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可读`});i=_p(i,a);let e=xf(o,a);e&&(i=Pf(i,e))}else l&&(i=Pf(i,o));return`快照 #${r.id}[${r.op}]${r.label?`(${r.label})`:``}${a?` @ ${a}`:``} = ${Tp(i)}`},{name:`history_data`,description:`查看主数据快照(只读不回退当前)。list:true 列时间线;传 id 看某次快照内容(默认最近),jsonPath 可只看子路径。冲突诊断/看上一版用;对比差异用 diff_data;回退用 restore_data。`,schema:t.z.object({id:t.z.number().int().optional().describe(`快照序号;不传则最近一次(list:true 时忽略)`),jsonPath:t.z.string().optional().describe(`只看快照的某子路径(相对主数据根);不传则整个快照`),list:t.z.boolean().optional().describe(`true 则列出快照时间线元信息(序号/操作/标签/时间/大小);不传则查看单条快照内容`)})}),L=(0,r.tool)(async({expr:e,limit:t},n)=>{let r=v(n);if(typeof s!=`object`||!s)return $({code:`NOT_OBJECT`,message:`主数据不是对象/数组,无法查询(当前为 ${s===void 0?`undefined`:typeof s})`,hint:`query 仅适用于对象/数组;叶子用 read 读`});let i=l?Pf(s,o):s,a;try{a=Gu(i,e)}catch(t){return $({code:`JSONPATH_SYNTAX`,message:`JSONPath 解析错误: ${t.message}`,hint:`语法子集:$ .key [n] ["key"] [*] [?(filter)] ..key ..*;filter:@.field op literal,&&/||/();对象根需先点出数组字段再过滤,如 $.components[?(@.x>1)]`,details:{expr:e}})}let c=t??50,u=a.slice(0,c),d=y(n),f=u.map(e=>`{"path":${JSON.stringify(e.path)},"index":${e.index===void 0?`null`:e.index},"value":${Tp(Lg(e.value,r===``,M,j,{rootExempt:!1,rootPath:String(e.path??``),fullTextPrefixes:d,onSummarized:x}))}}`);return`{"matched":${a.length},"returned":${u.length},"truncated":${a.length>c},"results":[${f.join(`,`)}]}`},{name:`query_data`,description:`用 JSONPath 查询主数据(只读):$ 根/.key/[n]/[*]/[?(==/!=/</<=/>/>=,&&/||)]/..key 递归。返回匹配元素 path/index/value(path 可作 write patch 的 jsonPath);大数组筛选定位用它。`,schema:t.z.object({expr:t.z.string().describe(`JSONPath 表达式,如 $.components[?(@.type=="card" && @.price<100)] 或 $..title(递归找所有 title)`),limit:t.z.number().int().min(1).max(200).optional().describe(`返回结果上限,默认 50`)})}),R=(0,r.tool)(async({query:e,mode:t,fuzzyThreshold:n,matchKey:r,limit:i})=>{if(s==null)return $({code:`EMPTY`,message:`主数据为空,无可搜索内容`});try{let a=qu(l?Pf(s,o):s,e,{mode:t,fuzzyThreshold:n,matchKey:r,limit:i??50});return Tp({matched:a.length,results:a})}catch(t){return $({code:`REGEX_INVALID`,message:`搜索错误: ${t.message}`,hint:`regex 模式下 query 须为合法正则;改 mode 为 substring/fuzzy 可避免正则语法问题`,details:{query:e}})}},{name:`search_data`,description:`主数据内文本搜索(只读)。mode:substring(默认,不区分大小写)/regex(i 标志)/fuzzy(Levenshtein ≤ fuzzyThreshold)。递归遍历叶子值返回命中 path+value(超 200 字符截断);找名字记不清的元素用它。`,schema:t.z.object({query:t.z.string().describe(`搜索词(substring/regex/fuzzy 共用)`),mode:t.z.enum([`substring`,`regex`,`fuzzy`]).optional().describe(`匹配模式,默认 substring`),fuzzyThreshold:t.z.number().int().min(0).max(5).optional().describe(`fuzzy 模式最大编辑距离,默认 2`),matchKey:t.z.boolean().optional().describe(`是否同时匹配 key 名,默认 true`),limit:t.z.number().int().min(1).max(200).optional().describe(`返回上限,默认 50`)})}),z=(0,r.tool)(async({script:e,mode:t,jsonPath:n},r)=>{let i=v(r);if(e.length>8e3)return $({code:`SCRIPT_TOO_LARGE`,message:`脚本过长(${e.length} 字符,上限 8000)`,hint:`精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval`});let c=n||``,u;if(c){if(!yf(c,o,l))return $({code:`PATH_DENIED`,message:`eval_script @ "${c}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可作为子树`});if(u=_p(s,c),l){let e=xf(o,c);e&&(u=Pf(u,e))}}else u=l?Pf(s,o):s;let d=bp(u),f=await Yu(d,e,c&&JSON.stringify(d).length>1e5?8e3:3e3);if(!f.ok){let t=/超时/.test(f.error||``);return $({code:t?`SCRIPT_TIMEOUT`:`SCRIPT_ERROR`,message:`脚本执行失败: ${f.error}`,hint:t?`脚本可能有死循环或过重计算;加边界检查/分批;transform 返回完整新值勿返回巨大中间结果`:`检查脚本语法与运行时错误;入参为 data(主数据深拷贝),沙箱内禁用 fetch/XHR/WebSocket`,details:{elapsedMs:f.elapsedMs,scriptLen:e.length}})}if(t===`transform`){let e=f.result;if(c){let t=await te();try{let t=jg({bindRef:s,patches:[{op:`set`,jsonPath:c,value:e}],schema:o,allowKeys:l,snapshots:m,maxSnapshots:h,markDataDirty:N,schemaErrorMode:`schema_invalid`,snapshotLabel:`eval_transform_subtree`,internalAfterWrite:a,protectedCtx:p});return t.ok?(F({op:`edit`,detail:`eval_transform_subtree @ ${c}`,timestamp:Date.now()}),C(D(),i),`已通过脚本 transform 子树 @ ${c} 更新(耗时 ${f.elapsedMs}ms)。当前值: ${Tp(s,600)}`):t.error}finally{t.release()}}if(e&&typeof e==`object`&&!Array.isArray(e)&&`patches`in e&&Array.isArray(e.patches)){if(typeof s!=`object`||!s)return $({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${s===null?`null`:typeof s}),eval transform(patches) 无法就地替换`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind`});let t=await te();try{let t=jg({bindRef:s,patches:e.patches,schema:o,allowKeys:l,snapshots:m,maxSnapshots:h,markDataDirty:N,schemaErrorMode:`schema_invalid`,snapshotLabel:`eval_transform`,internalAfterWrite:a,protectedCtx:p});return t.ok?(F({op:`edit`,detail:`eval_transform(${t.applied.length} patches)`,timestamp:Date.now()}),C(D(),i),`已通过脚本 transform(patches) 更新主数据(${t.applied.length} 个 patch,耗时 ${f.elapsedMs}ms)。当前值: ${Tp(s,600)}`):t.error}finally{t.release()}}let t=e,n=Mg(t);if(n)return Ng(n);if(p){let e=Sg({value:t,ctx:p});if(!e.ok)return e.error;t=e.value}if(typeof s!=`object`||!s)return $({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${s===null?`null`:typeof s}),eval transform 无法就地替换外部持有的值引用`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind`});let r=await te();try{let e=Og({schema:o,allowKeys:l,value:t,bindRef:s});return e.ok?(re(`edit`,`eval_transform`),e.wholeParsed?Pp(s,e.assembly):e.assembly!==null&&typeof e.assembly==`object`&&gp(s,e.assembly),N(),F({op:`edit`,detail:`eval_transform`,timestamp:Date.now()}),C(D(),i),`已通过脚本 transform 更新主数据(耗时 ${f.elapsedMs}ms)。当前值: ${Tp(s,600)}`):$({code:`SCHEMA_INVALID`,message:`脚本返回值校验失败,未写入(transform 模式要求返回主数据的完整新值或顶层 key 子集)`,hint:`确认脚本 return 了完整新值(非部分);或返回 {patches:[...]} 走增量模式;按 describe_data() 查看格式`,details:(e.error.match(/"details":\s*(\[[^\]]*\])/)?.[1]??``)||e.error})}finally{r.release()}}return Tp({ok:!0,result:f.result,elapsedMs:f.elapsedMs})},{name:`eval_script`,description:`在 Worker 沙箱对主数据跑自定义 JS(无 window/fetch,超时 3s)。入参 data(深拷贝),返回值即结果。mode:query 只读回给 LLM(过滤/映射/聚合)/transform 落地(返回完整新值或 {patches:[...]} 增量)。jsonPath 可只对子树执行。`,schema:t.z.object({script:t.z.string().describe(`JS 脚本体,如 data.filter(c=>c.stock>0).map(c=>c.id);入参名 data;末尾表达式或 return 即返回值`),mode:t.z.enum([`query`,`transform`]).optional().describe(`query=只读返回结果(默认),transform=校验后落地为新值`),jsonPath:t.z.string().optional().describe(`子树模式:仅对 jsonPath 指向的子树执行(降低大 JSON 成本);transform 时返回值作为该子树新值`)})});ae(z,e=>e?.mode===`transform`);let ce=(0,r.tool)(async({jsonPath:e,jsonPaths:t,fields:n,depth:r,offset:i,limit:a},u)=>{let d=v(u),f=y(u),m=D();if(t&&t.length){let e=!1,i=t.map(t=>{let i=t||``;if(!yf(i,o,l))return`- ${i||`(根)`}: [PATH_DENIED: 不在 schema 声明字段内]`;e=!0;let a=i?_p(s,i):s;if(!i&&l)a=Pf(a,o);else if(l){let e=xf(o,i);e&&(a=Pf(a,e))}let c=a;return p&&(c=vg({jp:i,resolved:c,resourcesByPath:p.resourcesByPath,resourceStore:p.resourceStore})),n&&n.length&&(c=Cp(c,n)),r!=null&&(c=wp(c,r)),c=Lg(c,d===``,M,j,{rootExempt:!0,rootPath:i,fullTextPrefixes:f,onSummarized:x}),c===void 0?`- ${i} = (undefined)`:`- ${i} = ${Tp(c)}`});return e&&C(m,d),`多路径读取(共 ${t.length} 项,hash=${m}):\n${i.join(`
|
|
97
97
|
`)}`}let h=e||``;if(hp(h))return $({code:`PATH_UNSAFE`,message:`jsonPath "${h}" 含非法段(__proto__/constructor/prototype)`,hint:`使用正常属性路径,如 components.0.text(数组索引数字)`});let g=(e,t)=>Tg(o,e)??(t&&typeof t==`object`&&!Array.isArray(t)?Object.keys(t):[]);if(!yf(h,o,l)){let e=/[.[]/.test(h)?h.replace(/[.[][^.[]*$/,``):``,t=g(e,e?_p(s,e):s),n=t.length?`;父级 "${e||`(root)`}" 的可用字段:${t.slice(0,12).join(`, `)}${t.length>12?` …`:``}`:``;return $({code:`PATH_DENIED`,message:`read @ "${h}" 不在 schema 声明字段内`,hint:`主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它${n}`})}let _=h?_p(s,h):s;if(h&&_===void 0){let e=xf(o,h);if(!(e&&typeof e.isOptional==`function`&&e.isOptional())){let e=/[.[]/.test(h)?h.replace(/[.[][^.[]*$/,``):``,t=e?_p(s,e):s,n=g(e,t),r=Array.isArray(t)?`父级 "${e||`(root)`}" 是 ${t.length} 元数组,有效索引 0-${Math.max(t.length-1,0)};先 read({jsonPath:"${e}"}) 确认现状,追加元素走 write 的 append`:n.length?`父级 "${e||`(root)`}" 的可用字段:${n.slice(0,12).join(`, `)}${n.length>12?` …`:``};先 read({jsonPath:"${e}"}) 确认`:`父级 "${e||`(root)`}" 不存在或不是容器;先 read() 不传 jsonPath 查看顶层字段`;return $({code:`PATH_NOT_FOUND`,path:h,message:`路径 "${h}" 不存在`,hint:r})}}if(!h&&l)_=Pf(_,o);else if(l){let e=xf(o,h);e&&(_=Pf(_,e))}let b=_;p&&(b=vg({jp:h,resolved:b,resourcesByPath:p.resourcesByPath,resourceStore:p.resourceStore})),C(m,d),n&&n.length&&(b=Cp(b,n)),r!=null&&(b=wp(b,r)),b=Lg(b,d===``,M,j,{rootExempt:!0,rootPath:h,fullTextPrefixes:f,onSummarized:x});let S=e?``:`主数据说明: ${c}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`,w=n&&n.length?`(字段裁剪:${n.join(`,`)})`:``,T=r==null?``:`(深度≤${r})`,E=w||T?` ${w}${T}`:``;if((i!==void 0||a!==void 0)&&Array.isArray(b)){let e=b.length,t=Math.max(0,i??0),n=Math.min(200,Math.max(1,a??50)),r=b.slice(t,t+n),o=t+n<e;return`${S}主数据${h?` @ ${h}`:``} 数组分页[offset=${t},limit=${n}]${E} = ${Tp(r)} (total=${e}, hasMore=${o}) (hash=${m})`}return b===void 0?`${S}主数据${h?` @ ${h}`:``}${E} = (undefined) (hash=${m})`:`${S}主数据${h?` @ ${h}`:``}${E} = ${Tp(b)} (hash=${m})`},{name:`read`,description:`读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示(含字段约束);传 jsonPath → 返回该子路径当前值 + hash;传 jsonPaths → 一次读多个不相关子路径(省多轮往返)。hash 用于乐观锁(声明 conflictWatchFields 后 write 自动比对;未声明不自动校验)。fields(字段裁剪)/depth(深度截断)减体积;offset+limit 对数组目标分页(返回切片 + total/hasMore)。`,schema:t.z.object({jsonPath:t.z.string().optional().describe(`要读的子路径(相对主数据根,如 components.0.text);不传则读整个主数据并返回说明`),jsonPaths:t.z.array(t.z.string()).optional().describe(`多路径读取:一次读多个不相关子路径(与 jsonPath 互斥,优先于 jsonPath);返回各路径值,非法路径单项标错不整批失败`),fields:t.z.array(t.z.string()).optional().describe(`字段裁剪:只返回指定字段(对对象/数组元素投影),减少返回体积,如 ["id","title"]`),depth:t.z.number().int().min(0).optional().describe(`嵌套深度限制:0=只根占位,1=根+子,递归到 depth 层后用 {...}/[...] 占位截断,减少深层返回体积`),offset:t.z.number().int().min(0).optional().describe(`数组分页起始偏移(仅当读取目标是数组时生效,默认 0),配合 limit 分页读大数组`),limit:t.z.number().int().min(1).max(200).optional().describe(`数组分页每页条数(默认 50,上限 200;仅数组时生效),返回切片 + total/hasMore`)})}),B=(0,r.tool)(async({value:e,patch:t,patches:n,del:r,dryRun:c},u)=>{let d=v(u),f=`set`;r?f=`delete`:(n&&n.length||t)&&(f=`edit`);let g=t?.value===void 0?e:t.value,_=await te();try{let e=E?S(d):void 0;if(c&&e!==void 0){let t=D();if(t!==e)return $({code:`VERSION_CONFLICT`,message:`dryRun 预检发现乐观锁冲突: expectedHash=${e} 当前 hash=${t}(主数据在你 read 后被改)`,hint:`重新 read 拿最新 hash 再预检/写`})}if(f===`delete`){if(!t?.jsonPath)return $({code:`MISSING_VALUE`,message:`delete 需要 patch.jsonPath 指定要删的子路径(主数据整体不可删,用 write(value) 整体替换)`,hint:`如 patch:{jsonPath:"components.0"}, del:true`});if(hp(t.jsonPath))return $({code:`PATH_UNSAFE`,message:`jsonPath "${t.jsonPath}" 含非法段`,hint:`使用正常属性路径`});if(!yf(t.jsonPath,o,l))return $({code:`PATH_DENIED`,message:`write delete @ "${t.jsonPath}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可删`});if(p){let e=gg(t.jsonPath,p.resourcesByPath);if(e)return $({code:e.spec.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,message:`write delete @ "${t.jsonPath}" 命中受保护字段 "${e.protectedPath}"(${e.spec.mode}),不可删除`,hint:e.spec.mode===`freeze`?`冻结字段不可删`:`verbatim 字段不可直接删;先 resource_delete 释放`})}let n=await ie(`delete`,e,void 0,_);if(n!==null)return n;if(c){let e=bp(s);return yp(e,t.jsonPath)?`dryRun(delete): 将删除 @ ${t.jsonPath}。预览剩余:${Tp(e,600)}。未实际写入、未入快照。`:`dryRun(delete): @ ${t.jsonPath} 不存在(无需删除)。未实际写入。`}re(`delete`);let r=yp(s,t.jsonPath);return N(),F({op:`delete`,detail:t.jsonPath,timestamp:Date.now()}),a&&(a(s,null),N()),C(D(),d),r?`已删除主数据 @ ${t.jsonPath}`:`主数据 @ ${t.jsonPath} 不存在(无需删除)`}if(f===`edit`){if(typeof s!=`object`||!s)return $({code:`NOT_OBJECT`,message:`edit 仅适用于对象/数组主数据,当前是 ${s===void 0?`undefined`:typeof s}`,hint:`叶子用 write(value) 整体设置`});let r=await ie(`edit`,e,void 0,_);if(r!==null)return r;let i=n&&n.length?n:[{op:t.op??`set`,jsonPath:t.jsonPath||``,value:g}],u=jg({bindRef:s,patches:i,schema:o,allowKeys:l,snapshots:m,maxSnapshots:h,markDataDirty:N,schemaErrorMode:`zod`,dryRun:c,internalAfterWrite:a,protectedCtx:p});if(!u.ok)return u.error;if(c)return`dryRun(edit): ${u.applied.length} 个 patch 预检通过(schema 校验 OK)。预览结果:${Tp(u.clone,600)}。未实际写入、未入快照。`;F({op:`edit`,detail:`${u.applied.length} 个 patch${u.applied.length>1?`(批量)`:``}`,value:u.applied.map(e=>`${e.op}@${e.jp}`),timestamp:Date.now()});let f=A(d);return Vg(u.clone),`已 write(edit) 主数据(${u.applied.length} 个 patch)。当前值:${Tp(u.clone,600)} (新 hash=${f})`}let r=Sp(g);if(r.parseError)return zl(``,g,r.parseError);let u=await ie(`set`,e,g,_);if(u!==null)return u;let v=Ag({bindRef:s,value:r.parsed,schema:o,allowKeys:l,snapshots:m,maxSnapshots:h,audit:F,dryRun:c,onWrite:N,internalAfterWrite:a,protectedCtx:p,hashFn:D});if(!v.ok)return v.error;if(c)return`dryRun(set): schema 校验通过。预览新值:${Tp(v.data,600)}。未实际写入、未入快照。`;let y=v.hash??D();C(y,d);let b=i.length?bp(v.data):v.data;return Vg(b),`已 write(set) 主数据 = ${Tp(b,600)} (新 hash=${y})${l?`(白名单模式:仅更新 schema 声明字段,未声明字段保留)`:``}`}finally{_.release()}},{name:`write`,description:`写入主数据(高层入口,合并 set/edit/delete + 自动乐观锁 + 自动快照)。四意图:① 整体替换 write({value:整个对象});② 增量 write({patch:{op,jsonPath,value}}) op=set/remove/merge/append/move(move 的 value=目标路径字符串);③ 批量原子 write({patches:[...]})(任一失败整批回滚);④ 删子路径 write({patch:{jsonPath},del:true})。dryRun:true 预检不落盘。写入自动 schema 校验(失败不写,按错误修正重试)+ 自动快照。详细用法见系统提示「能力使用提示」。`,schema:t.z.object({value:t.z.unknown().optional().describe(`JSON 对象(推荐,如 {title:"x"})或 JSON 字符串;set 整体或单个 patch 的 set/merge/append 必填`),patch:t.z.object({op:t.z.enum([`set`,`remove`,`merge`,`append`,`move`]).optional().describe(`增量操作:set 设值/remove 删/merge 合并对象/append 追加数组/move 移动数组元素(value=目标路径字符串)。单 patch edit 缺省按 set;del 模式(write({patch:{jsonPath},del:true}))不读 op 可省略`),jsonPath:t.z.string().optional().describe(`相对主数据根的点号路径(如 components.0.text);set/remove 必填,merge/append 不填则作用于根`),value:t.z.unknown().optional().describe(`该 patch 的值(JSON 直传或 JSON 字符串);set/merge/append 必填,remove 不需。与顶层 value 二选一:优先 patch.value,未填则回退顶层 value(向后兼容)。推荐用 patch.value(自带,与 patches 元素一致,无歧义)`)}).optional().describe(`单个增量编辑(自带 value,与 patches 元素一致);传 patch(无 patches)走单 patch edit 语义`),patches:t.z.array(t.z.object({op:t.z.enum([`set`,`remove`,`merge`,`append`,`move`]),jsonPath:t.z.string().optional().describe(`相对主数据根的点号路径;set/remove 必填,merge/append 不填则作用于根`),value:t.z.unknown().optional().describe(`JSON 值(推荐直传)或 JSON 字符串;set/merge/append 必填,remove 不需`)})).optional().describe(`批量增量编辑:一次原子应用多个 patch(任一失败则整体不写入,clone 试跑全部 + schema 校验通过才落 live)。适合一次改多处,减少多轮往返`),del:t.z.boolean().optional().describe(`true 则删除 patch.jsonPath 指定的子路径`),dryRun:t.z.boolean().optional().describe(`预检模式:走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘、不入快照,返回预览。四意图(value/patch/patches/del)均支持;乐观锁冲突照常检测(返回 VERSION_CONFLICT 不挂起)`)})});ae(B);let V=(0,r.tool)(async({jsonPath:e})=>{let t=e||``,n=t?xf(o,t):o;return n?`schema${t?` @ ${t}`:``} = ${Tp(Vf(n))}`:$({code:`PATH_DENIED`,message:`schema @ "${t}" 不存在`,hint:`jsonPath 需在 schema 声明字段内(用 read() 不传 jsonPath 查看顶层字段)`})},{name:`schema_data`,description:`查看主数据(或子路径)的字段约束:类型/min/max/enum/必填/默认值/嵌套 shape。写前查约束,避免写错重试。不传 jsonPath 查根;传子路径(如 components.0)查该位置约束。`,schema:t.z.object({jsonPath:t.z.string().optional().describe(`要查约束的子路径;不传查根 schema`)})}),H=(0,r.tool)(async({snapshotId:e,against:t})=>{let n=t!=null,r,i;if(n){let e=t;if(typeof e==`string`){let t=Sp(e);t.parseError||(e=t.parsed)}r=e,i=`against`}else{if(!m.length)return $({code:`NO_SNAPSHOT`,message:`无快照可对比`,hint:`set/edit/delete 自动存快照;或传 against 一段 JSON 值直接对比`});let t=e===void 0?m[m.length-1]:m.find(t=>t.id===e);if(!t)return $({code:`SNAPSHOT_NOT_FOUND`,message:`未找到快照 #${e}`,hint:`不传 snapshotId 用最近一次;或传 against`});r=t.value,i=`快照 #${t.id}`}let a=l?Pf(s,o):s,c=Ip(r,bp(a));return c.length?`差异(当前 vs ${i},共 ${c.length} 处):\n${c.map(e=>` ${e.path}: ${Tp(e.from)} → ${Tp(e.to)}`).join(`
|
|
98
|
-
`)}`:`无差异:当前主数据与 ${i} 完全相同。`},{name:`diff_data`,description:`对比当前主数据与某快照(默认最近)或一段 JSON(against)的差异,返回结构化 {path, from→to} 列表。供 verify 自纠/冲突诊断/操作审计("刚才改了啥")。snapshotId 指定快照;against 传一段 JSON 值(与 snapshotId 互斥,传则忽略快照)。`,schema:t.z.object({snapshotId:t.z.number().int().optional().describe(`对比的快照序号;不传则最近一次`),against:t.z.unknown().optional().describe(`对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)`)})}),le=[];if(n.vfsStore){let e=n.vfsStore,i=e=>`drafts/${e}.json`,c=(0,r.tool)(({draftId:t,chunk:n,mode:r})=>{let a=i(t),o=e.files[a],s=r===`append`&&o,c=s?o.content+n:n;return e.files[a]={content:c,updatedAt:Date.now()},JSON.stringify({draftId:t,bytes:c.length,mode:s?`append`:`start`})},{name:`draft_write`,description:`分块写 JSON 草稿到 drafts 池(单次 write 受 max_tokens 限制装不下时用)。mode:"start" 新建/"append" 追加拼接;返回 {draftId,bytes} 看累计进度。累积完 draft_commit 提交;拼接不合法返回 JSON_INVALID 草稿保留。`,schema:t.z.object({draftId:t.z.string().describe(`草稿标识(自起,如 "page-gen-1")`),chunk:t.z.string().describe(`JSON 片段字符串(分块输出,append 拼接成完整 JSON;如 '{"components":[' / '{"type":"heading",...},' / ']}')`),mode:t.z.enum([`start`,`append`]).optional().describe(`start=新建/覆盖(默认);append=追加 chunk 到已有草稿`)})}),u=(0,r.tool)(async({draftId:t},n)=>{let r=v(n),c=i(t),u=e.files[c];if(!u)return $({code:`DRAFT_NOT_FOUND`,message:`草稿 "${t}" 不存在`,hint:`先 draft_write({draftId, chunk, mode:"start"}) 新建,再 append 累积分块`});let d;try{d=JSON.parse(u.content)}catch(e){return $({code:`JSON_INVALID`,message:`草稿 "${t}" 拼接后非合法 JSON: ${e.message}`,hint:`检查 chunk 拼接(逗号/括号/引号是否匹配,首尾是否闭合);草稿保留未删,可继续 draft_write 修正后重 commit`,details:{bytes:u.content.length,preview:u.content.slice(0,200)+(u.content.length>200?`…`:``)}})}let f=await te();try{let n=await ie(`set`,E?S(r):void 0,d,f);if(n!==null)return n;let i=Ag({bindRef:s,value:d,schema:o,allowKeys:l,snapshots:m,maxSnapshots:h,audit:F,op:`draft_commit`,onWrite:N,internalAfterWrite:a,protectedCtx:p,hashFn:D});return i.ok?(C(i.hash,r),delete e.files[c],`已 draft_commit 草稿 "${t}" → 主数据 = ${Tp(i.data,600)} (新 hash=${i.hash})${l?`(白名单模式:仅更新 schema 声明字段)`:``}。草稿已清理。`):i.error}finally{f.release()}},{name:`draft_commit`,description:`把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。`,schema:t.z.object({draftId:t.z.string().describe(`要提交的草稿标识(对应 draft_write 的 draftId)`)})});ae(u),le.push(c,u)}let U=[];if(e.resources?.length&&d){let e=(0,r.tool)(async({path:e,handle:t})=>{let n=e;if(!n&&t&&(n=d.get(t)?.path),!n)return $({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)`});let r=pg(n);if(!u.has(r))return $({code:`RESOURCE_NOT_FOUND`,message:`"${n}" 不是受保护字段`,hint:`resource_get 仅查集成方在 data.resources 声明的路径`});let i=d.get(r);if(i)return Tp({path:i.path,mode:i.mode,value:i.value,handle:i.handle});let a=_p(s,r);if(a===void 0)return $({code:`RESOURCE_NOT_FOUND`,message:`字段 "${n}" 当前无值,无法注册`,hint:`该字段可能在 bind 中不存在;先 read 触发懒注册`});let o=u.get(r),c=d.ensure(r,a,o.mode);return Tp({path:r,mode:o.mode,value:a,handle:c})},{name:`resource_get`,description:`取受保护字段(freeze/verbatim)的真实值(占位符背后的精确值)。仅受保护路径(集成方在 data.resources 声明)。read 返回 ⟦frozen:path⟧/⟦res:handle⟧ 占位符,确需真值时用此工具。传 path 或 handle。`,schema:t.z.object({path:t.z.string().optional().describe(`受保护字段路径(data.resources 声明的)`),handle:t.z.string().optional().describe(`占位符 ⟦res:handle⟧ 里的句柄(与 path 二选一)`)})}),n=(0,r.tool)(async({path:e,value:t},n)=>{let r=v(n);if(!e)return $({code:`MISSING_VALUE`,message:`resource_update 需要 path`,hint:`传要更新的 verbatim 受保护字段路径`});let i=pg(e),a=u.get(i);if(!a)return $({code:`RESOURCE_NOT_FOUND`,message:`"${e}" 不是受保护字段`,hint:`resource_update 仅改 data.resources 声明的字段`});if(a.mode===`freeze`)return $({code:`FROZEN_FIELD`,message:`字段 "${e}" 已冻结,resource_update 也不可改`,hint:`冻结字段完全只读`});let c=xf(o,i);if(c){let n=c.safeParse(t);if(!n.success)return $({code:`SCHEMA_INVALID`,message:`resource_update 值不符合 "${e}" 的类型`,hint:`按字段类型传值`,details:Ll(n.error.issues)})}d.update(i,t),vp(s,i,t),C(D(),r),N();let l=d.get(i)?.handle;return`已更新 verbatim 资源 "${e}" = ${Tp(t,200)}(handle ${l??`(未知)`} 不变)。后续 write 该字段写回句柄 ⟦res:${l}⟧ 或新值`},{name:`resource_update`,description:`更新 verbatim 受保护字段的真实值(改精确原值,如刷新 token/hash)。仅 verbatim 可改;freeze 拒。更新后同步 bind + 标脏,后续 write 写回句柄即用新值。`,schema:t.z.object({path:t.z.string().describe(`要更新的 verbatim 受保护字段路径`),value:t.z.unknown().describe(`新值(需符合字段 schema 类型)`)})});ae(n);let i=(0,r.tool)(async()=>{let e=d.list();return e.length
|
|
98
|
+
`)}`:`无差异:当前主数据与 ${i} 完全相同。`},{name:`diff_data`,description:`对比当前主数据与某快照(默认最近)或一段 JSON(against)的差异,返回结构化 {path, from→to} 列表。供 verify 自纠/冲突诊断/操作审计("刚才改了啥")。snapshotId 指定快照;against 传一段 JSON 值(与 snapshotId 互斥,传则忽略快照)。`,schema:t.z.object({snapshotId:t.z.number().int().optional().describe(`对比的快照序号;不传则最近一次`),against:t.z.unknown().optional().describe(`对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)`)})}),le=[];if(n.vfsStore){let e=n.vfsStore,i=e=>`drafts/${e}.json`,c=(0,r.tool)(({draftId:t,chunk:n,mode:r})=>{let a=i(t),o=e.files[a],s=r===`append`&&o,c=s?o.content+n:n;return e.files[a]={content:c,updatedAt:Date.now()},JSON.stringify({draftId:t,bytes:c.length,mode:s?`append`:`start`})},{name:`draft_write`,description:`分块写 JSON 草稿到 drafts 池(单次 write 受 max_tokens 限制装不下时用)。mode:"start" 新建/"append" 追加拼接;返回 {draftId,bytes} 看累计进度。累积完 draft_commit 提交;拼接不合法返回 JSON_INVALID 草稿保留。`,schema:t.z.object({draftId:t.z.string().describe(`草稿标识(自起,如 "page-gen-1")`),chunk:t.z.string().describe(`JSON 片段字符串(分块输出,append 拼接成完整 JSON;如 '{"components":[' / '{"type":"heading",...},' / ']}')`),mode:t.z.enum([`start`,`append`]).optional().describe(`start=新建/覆盖(默认);append=追加 chunk 到已有草稿`)})}),u=(0,r.tool)(async({draftId:t},n)=>{let r=v(n),c=i(t),u=e.files[c];if(!u)return $({code:`DRAFT_NOT_FOUND`,message:`草稿 "${t}" 不存在`,hint:`先 draft_write({draftId, chunk, mode:"start"}) 新建,再 append 累积分块`});let d;try{d=JSON.parse(u.content)}catch(e){return $({code:`JSON_INVALID`,message:`草稿 "${t}" 拼接后非合法 JSON: ${e.message}`,hint:`检查 chunk 拼接(逗号/括号/引号是否匹配,首尾是否闭合);草稿保留未删,可继续 draft_write 修正后重 commit`,details:{bytes:u.content.length,preview:u.content.slice(0,200)+(u.content.length>200?`…`:``)}})}let f=await te();try{let n=await ie(`set`,E?S(r):void 0,d,f);if(n!==null)return n;let i=Ag({bindRef:s,value:d,schema:o,allowKeys:l,snapshots:m,maxSnapshots:h,audit:F,op:`draft_commit`,onWrite:N,internalAfterWrite:a,protectedCtx:p,hashFn:D});return i.ok?(C(i.hash,r),delete e.files[c],`已 draft_commit 草稿 "${t}" → 主数据 = ${Tp(i.data,600)} (新 hash=${i.hash})${l?`(白名单模式:仅更新 schema 声明字段)`:``}。草稿已清理。`):i.error}finally{f.release()}},{name:`draft_commit`,description:`把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。`,schema:t.z.object({draftId:t.z.string().describe(`要提交的草稿标识(对应 draft_write 的 draftId)`)})});ae(u),le.push(c,u)}let U=[];if(e.resources?.length&&d){let e=(0,r.tool)(async({path:e,handle:t})=>{let n=e;if(!n&&t&&(n=d.get(t)?.path),!n)return $({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)`});let r=pg(n);if(!u.has(r))return $({code:`RESOURCE_NOT_FOUND`,message:`"${n}" 不是受保护字段`,hint:`resource_get 仅查集成方在 data.resources 声明的路径`});let i=d.get(r);if(i)return Tp({path:i.path,mode:i.mode,value:i.value,handle:i.handle});let a=_p(s,r);if(a===void 0)return $({code:`RESOURCE_NOT_FOUND`,message:`字段 "${n}" 当前无值,无法注册`,hint:`该字段可能在 bind 中不存在;先 read 触发懒注册`});let o=u.get(r),c=d.ensure(r,a,o.mode);return Tp({path:r,mode:o.mode,value:a,handle:c})},{name:`resource_get`,description:`取受保护字段(freeze/verbatim)的真实值(占位符背后的精确值)。仅受保护路径(集成方在 data.resources 声明)。read 返回 ⟦frozen:path⟧/⟦res:handle⟧ 占位符,确需真值时用此工具。传 path 或 handle。`,schema:t.z.object({path:t.z.string().optional().describe(`受保护字段路径(data.resources 声明的)`),handle:t.z.string().optional().describe(`占位符 ⟦res:handle⟧ 里的句柄(与 path 二选一)`)})}),n=(0,r.tool)(async({path:e,value:t},n)=>{let r=v(n);if(!e)return $({code:`MISSING_VALUE`,message:`resource_update 需要 path`,hint:`传要更新的 verbatim 受保护字段路径`});let i=pg(e),a=u.get(i);if(!a)return $({code:`RESOURCE_NOT_FOUND`,message:`"${e}" 不是受保护字段`,hint:`resource_update 仅改 data.resources 声明的字段`});if(a.mode===`freeze`)return $({code:`FROZEN_FIELD`,message:`字段 "${e}" 已冻结,resource_update 也不可改`,hint:`冻结字段完全只读`});let c=xf(o,i);if(c){let n=c.safeParse(t);if(!n.success)return $({code:`SCHEMA_INVALID`,message:`resource_update 值不符合 "${e}" 的类型`,hint:`按字段类型传值`,details:Ll(n.error.issues)})}d.update(i,t),vp(s,i,t),C(D(),r),N();let l=d.get(i)?.handle;return`已更新 verbatim 资源 "${e}" = ${Tp(t,200)}(handle ${l??`(未知)`} 不变)。后续 write 该字段写回句柄 ⟦res:${l}⟧ 或新值`},{name:`resource_update`,description:`更新 verbatim 受保护字段的真实值(改精确原值,如刷新 token/hash)。仅 verbatim 可改;freeze 拒。更新后同步 bind + 标脏,后续 write 写回句柄即用新值。`,schema:t.z.object({path:t.z.string().describe(`要更新的 verbatim 受保护字段路径`),value:t.z.unknown().describe(`新值(需符合字段 schema 类型)`)})});ae(n);let i=(0,r.tool)(async()=>{let e=d.list();if(!e.length){let e=[...p.resourcesByPath.entries()].filter(([,e])=>e.mode===`freeze`).map(([e])=>e);return e.length?`资源池为空,但集成方静态配置了 freeze 只读字段:${e.join(`、 `)}(freeze 无句柄、不可释放;resource_delete 仅对 verbatim 生效)`:`当前无已注册的受保护资源(read 受保护路径会懒注册)`}return Tp({resources:e})},{name:`resource_list`,description:`列出所有已注册的受保护资源(path/mode/handle/bytes)。`,schema:t.z.object({})}),a=(0,r.tool)(async({path:e,handle:t})=>{let n=e;return!n&&t&&(n=d.get(t)?.path),n?d.delete(n)?`已释放资源 "${n}"(后续 read 该字段会重新懒注册)`:p.resourcesByPath.get(n)?.mode===`freeze`?$({code:`FROZEN_FIELD`,message:`字段 "${n}" 为 freeze 静态保护(不在资源池、无句柄、不可释放)`,hint:`freeze 由集成方在 data.resources 静态配置,只读不可解;含冻结字段的元素无法整体删除,请保留该元素或由集成方调整 data.resources`}):`资源 "${n}" 不存在(无需释放)`:$({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传要释放的受保护字段 path 或 handle`})},{name:`resource_delete`,description:`释放受保护资源(从资源池删除,后续 read 重新懒注册)。用于不再需要保护的字段或释放空间。`,schema:t.z.object({path:t.z.string().optional().describe(`要释放的受保护字段路径`),handle:t.z.string().optional().describe(`占位符句柄(与 path 二选一)`)})});ae(a),U.push(e,n,i,a)}let ue=[I,oe,se,L,R,z,ce,B,V,H,...le,...U];Object.defineProperty(ue,"controller",{value:P,enumerable:!1,configurable:!1,writable:!1});for(let e of ue)Object.defineProperty(e,"__dataOpsScoped",{value:!0,enumerable:!1,configurable:!1});return ue}var Ug=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Wg=new Set([`script`,`style`]);function Gg(e){let t=[],n=e.length;if(!e.trim())return t;let r=[0];for(let t=0;t<n;t++)e[t]===`
|
|
99
99
|
`&&r.push(t+1);let i=e=>{let t=0,n=r.length-1;for(;t<n;){let i=t+n+1>>1;r[i]<=e?t=i:n=i-1}return t+1},a=[],o=0;for(;o<n;){let r=e.indexOf(`<`,o);if(r<0)break;if(e.startsWith(`<!--`,r)){let n=e.indexOf(`-->`,r+4);if(n<0){t.push({line:i(r),code:`UNCLOSED_COMMENT`,message:`注释 <!-- 未闭合(缺 -->)`});break}o=n+3;continue}if(e[r+1]===`!`){let t=e.indexOf(`>`,r);o=t<0?n:t+1;continue}let s=e[r+1]===`/`,c=s?r+2:r+1,l=e[c]??``;if(!/[a-zA-Z]/.test(l)){o=r+1;continue}let u=c,d=``;for(;u<n;){let t=e[u];if(d)t===d&&(d=``);else if(t===`"`||t===`'`)d=t;else if(t===`>`)break;u++}if(u>=n){t.push({line:i(r),code:`UNCLOSED_TAG`,message:`标签 ${e.slice(r,Math.min(r+20,n))} 未写完(缺 >)`});break}let f=e.slice(c,u),p=(f.match(/^[a-zA-Z][a-zA-Z0-9-]*/)??[``])[0].toLowerCase(),m=!s&&/\/\s*$/.test(f);if(o=u+1,p){if(s){let e=a.length-1;if(e>=0&&a[e].name===p)a.pop();else{let e=a.findIndex(e=>e.name===p);if(e>=0){let n=a.splice(e);for(let e of n.slice(1))t.push({line:i(e.idx),code:`UNCLOSED_TAG`,message:`<${e.name}> 未闭合(先遇到 </${p}>)`})}else t.push({line:i(r),code:`STRAY_CLOSE_TAG`,message:`</${p}> 无匹配的开标签`})}continue}if(!(Ug.has(p)||m)){if(Wg.has(p)){let n=RegExp(`</${p}\\s*>`,`i`).exec(e.slice(o));if(!n){t.push({line:i(r),code:`UNCLOSED_TAG`,message:`<${p}> 未闭合(缺 </${p}>)`});break}o+=n.index+n[0].length;continue}a.push({name:p,idx:r})}}}for(let e of a)t.push({line:i(e.idx),code:`UNCLOSED_TAG`,message:`<${e.name}> 未闭合`});return t}var Kg=`__pgTouched`,qg=`__pgFinalText`,Jg=`__pgCodeHashes`,Yg=`__pgKeepExternal`,Xg=`__pgNotes`,Zg=200;function Qg(e){let t=[];for(let n of e.split(`
|
|
100
100
|
`)){let e=n.match(/^\s*[-*]?\s*\[note\]\s*(.*)$/i);e&&e[1].trim()&&t.push(`[note] `+e[1].trim())}return[...new Set(t)]}function $g(e,t){let n=Array.isArray(e[Xg])?e[Xg].filter(e=>typeof e==`string`):[];e[Xg]=[...new Set([...n,...t])].map(e=>e.length>Zg?e.slice(0,Zg)+`…`:e).slice(-5)}function e_(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(16)}function t_(e,t){let n=[];return r_(e,t,e=>{typeof e.name==`string`&&e.name&&n.push(e.name)}),n}function n_(e,t){if(!e.startsWith(t))return null;let n=e.slice(t.length),r=n.lastIndexOf(`.`);return(r>0?n.slice(0,r):r===0?``:n)||null}function r_(e,t,n){if(!(!e||typeof e!=`object`))for(let r of t){let t=_p(e,r);if(Array.isArray(t))for(let e=0;e<t.length;e++){let i=t[e];i&&typeof i==`object`&&typeof i.__pgId==`string`&&n(i,r,e)}}}function i_(e,t,n){let r=new Set;if(!e||typeof e!=`object`)return r;for(let i of t){let t=_p(e,i);if(Array.isArray(t))for(let e=0;e<t.length;e++){let a=t[e];if(!a||typeof a!=`object`)continue;let o=a.__pgId;if(typeof o!=`string`)continue;let s=`${i}.${e}`;for(let e of n)if(e.path===s||e.path.startsWith(s+`.`)){r.add(o);break}}}return r}function a_(e){let{writablePaths:t,codeVfsPrefix:n,ext:r,codeField:i=`code`,onWarning:a,getController:o,vfsStore:s,craftNotes:c=!0}=e,l=s,u=l.__pgLastCheckout??=new Map,d=l.__pgPendingRetry??=new Set;return{name:`code-asset-checkout-commit`,beforeAgent:e=>{let c=o()?.get?.().bind;c&&Bg(c,t);let l=0,f=0,p=new Map;if(r_(c,t,e=>{l++;let t=_p(e,i);if(typeof t==`string`){f++;let i=e.__pgId,a=e_(t);p.set(i,a);let o=`${n}${i}.${r}`,c=s.files[o],l=u.get(i);c&&typeof c.content==`string`&&c.content!==t&&l===a?d.add(o):(s.files[o]={content:t,updatedAt:Date.now()},d.delete(o)),u.set(i,a)}}),l>0&&f===0&&a){let e=``;for(let n of t){let t=_p(c,n);if(Array.isArray(t)&&t.length){e=Object.keys(t[0]??{}).join(`,`);break}}a(`codeField '${i}' 在当前 ${l} 个组件中均未命中 string 值。组件实际字段:[${e}]。若预期有代码组件请核对 codeField 路径;若当前确无代码组件可忽略。`)}return{files:s.files,[Kg]:new Set,[qg]:{text:``},[Jg]:p,[Yg]:[]}},wrapModelCall:async(e,t)=>{let n=await t(e),r=e.state[qg];return r&&!(n.toolCalls&&n.toolCalls.length)&&typeof n.content==`string`&&n.content&&(r.text=n.content),n},augmentPrompt:()=>{let e=o()?.get?.().bind,i=[],a=0;if(r_(e,t,(e,t,o)=>{a++;let l=typeof e.name==`string`&&e.name?e.name:``,u=l?`${l} [${o}]`:`(未命名 [${o}])`,d=`${n}${e.__pgId}.${r}`,f=!!s.files[d];if(i.push(`- ${u} → ${d}${f?``:`(尚未检出,先 vfs_write 创建)`}`),c){let t=Array.isArray(e[Xg])?e[Xg].filter(e=>typeof e==`string`):[];if(t.length){let e=t[t.length-1];i.push(` 📝 笔记×${t.length}(最近):${e.length>120?e.slice(0,120)+`…`:e}`)}}}),!i.length)return;let l=``;for(let n of t){let t=_p(e,n);if(Array.isArray(t)){l=`\n新建组件追加索引:write({patch:{op:'set',jsonPath:'${n}.${t.length}',value:{...}}})(当前共 ${t.length} 个,勿覆盖已有索引)`;break}}return`## 组件代码文件地图(改组件时按 name 直接改对应 vfs 文件;框架自动 checkout/commit)${c?`
|
|
101
101
|
📝 笔记 = 前任维护者交接(设计决策/用户反馈/踩坑),改该组件时遵循;收口回复末行必须附一行 [note] 交接笔记(本组件本次的实现要点),框架存进组件转交下任`:``}\n${i.join(`
|
|
@@ -150,6 +150,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
|
|
|
150
150
|
- **机械决定一次定**:写法选择(read 回读 vs 复制、vfs 草稿 vs 直写 data、并行 vs 串行)快速选一个,**不在思考里反复权衡 token 成本**(为之纠结反更费 token)。
|
|
151
151
|
- **禁止在思考里整段写出完整代码草稿**:CSS/JS/HTML 代码只写进 write / vfs_write / vfs_edit 工具调用(代码只出现一次);思考里只做高层设计(结构 / 字段 / 方案选择),不要先逐行预写一遍代码再在工具里重复一遍 —— 那会让代码 token 翻倍。
|
|
152
152
|
- **终稿纪律(一次写成)**:动手前要点清单一次定稿(≤10 条:结构 + DOM 分层/z-index + 关键尺寸 + 动画时序),清单齐了**直接在工具调用里写终稿**;① 不先写一版再推翻重写第二版(整段重写 = 代码 token 翻倍,写前多花 30 秒把清单想齐);② 同一几何/层级约束(bottom 定位/遮挡/z-index)**只推演一次**,不重复推导第二遍;③ 写完发现小问题(遮挡/重叠/命名),只改那一处,不重写整段。
|
|
153
|
+
- **大段 code 分块写(超长代码硬约束)**:预计 code 超过 ~8K 字符时,**一次工具调用装不下会被 max_tokens 掐断** —— 必须分块:① 首块用 write 把组件连同 code 第一段写入(如 code 写到 CSS 中段即止);② 后续每段用 write({op:'append', jsonPath:'${n}.N.${t}', value:'下一段文本'}) 逐块尾接(每块 ≤4K 字符);③ 全部拼完再 validate_code。**禁止**在任何一次调用里塞完整超长代码(截断 = 静默失败重来,token 全废)。
|
|
153
154
|
- **代码字符串不纠结转义**:代码字段(${t})/ content 参数就是普通字符串,直接写完整代码文本(换行、引号照常写),不要纠结「\n」转义、单双引号、字面换行会不会被拒 —— 框架自动序列化,反复权衡纯属浪费 token。
|
|
154
155
|
- 一次想清楚 → 动手 → 验证 → 收口。**思考是手段不是目的,产出代码才是**。
|
|
155
156
|
8. **收口格式(必守,最后一行)**:收口回复 = 简短结果总结 + **末行交接笔记** \`[note] <一句话实现要点>\` —— 关键设计决策 / 用户偏好 / 踩坑(如「[note] 液面用 height keyframes 4.2s 循环;装饰仅灯串+光斑 2 类」)。框架只识别末尾 [note] 行存进组件、自动转交下次维护该组件的子 agent;**漏写 = 下任失去交接**(真 LLM 实测漏写率 3/4,务必末行带上)。一行内,只写可复用结论。`}function R_(e,t){return`# HTML 完整页面生成规范
|