dsh-edge 0.27.0 → 0.27.2
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/worker/direct/index.js
CHANGED
|
@@ -164,7 +164,7 @@ Known schemas:
|
|
|
164
164
|
- `)}`,new Error(at)}let Nt=`${c}/$ref`,vt=ha(e,Ke,n,r,i,s,o,Nt,l);if(vt.valid||Me.push({instanceLocation:o,keyword:"$ref",keywordLocation:Nt,error:"A subschema had errors."},...vt.errors),n==="4"||n==="7")return{valid:Me.length===0,errors:Me}}if(Array.isArray(f)){let tt=f.length,Ke=!1;for(let Nt=0;Nt<tt;Nt++)if(d===f[Nt]||f[Nt]==="integer"&&d==="number"&&e%1===0&&e===e){Ke=!0;break}Ke||Me.push({instanceLocation:o,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${d}" is invalid. Expected "${f.join('", "')}".`})}else f==="integer"?(d!=="number"||e%1||e!==e)&&Me.push({instanceLocation:o,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`}):f!==void 0&&d!==f&&Me.push({instanceLocation:o,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`});if(g!==void 0&&(d==="object"||d==="array"?SI(e,g)||Me.push({instanceLocation:o,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):e!==g&&Me.push({instanceLocation:o,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),v!==void 0&&(d==="object"||d==="array"?v.some(tt=>SI(e,tt))||Me.push({instanceLocation:o,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(tt=>e===tt)||Me.push({instanceLocation:o,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),b!==void 0){let tt=`${c}/not`;ha(e,b,n,r,i,s,o,tt).valid&&Me.push({instanceLocation:o,keyword:"not",keywordLocation:tt,error:'Instance matched "not" schema.'})}let St=[];if(w!==void 0){let tt=`${c}/anyOf`,Ke=Me.length,Nt=!1;for(let vt=0;vt<w.length;vt++){let at=w[vt],Ot=Object.create(l),qe=ha(e,at,n,r,i,m===!0?s:null,o,`${tt}/${vt}`,Ot);Me.push(...qe.errors),Nt=Nt||qe.valid,qe.valid&&St.push(Ot)}Nt?Me.length=Ke:Me.splice(Ke,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:tt,error:"Instance does not match any subschemas."})}if(k!==void 0){let tt=`${c}/allOf`,Ke=Me.length,Nt=!0;for(let vt=0;vt<k.length;vt++){let at=k[vt],Ot=Object.create(l),qe=ha(e,at,n,r,i,m===!0?s:null,o,`${tt}/${vt}`,Ot);Me.push(...qe.errors),Nt=Nt&&qe.valid,qe.valid&&St.push(Ot)}Nt?Me.length=Ke:Me.splice(Ke,0,{instanceLocation:o,keyword:"allOf",keywordLocation:tt,error:"Instance does not match every subschema."})}if(E!==void 0){let tt=`${c}/oneOf`,Ke=Me.length,Nt=E.filter((vt,at)=>{let Ot=Object.create(l),qe=ha(e,vt,n,r,i,m===!0?s:null,o,`${tt}/${at}`,Ot);return Me.push(...qe.errors),qe.valid&&St.push(Ot),qe.valid}).length;Nt===1?Me.length=Ke:Me.splice(Ke,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:tt,error:`Instance does not match exactly one subschema (${Nt} matches).`})}if((d==="object"||d==="array")&&Object.assign(l,...St),A!==void 0){let tt=`${c}/if`;if(ha(e,A,n,r,i,s,o,tt,l).valid){if(I!==void 0){let Nt=ha(e,I,n,r,i,s,o,`${c}/then`,l);Nt.valid||Me.push({instanceLocation:o,keyword:"if",keywordLocation:tt,error:'Instance does not match "then" schema.'},...Nt.errors)}}else if(M!==void 0){let Nt=ha(e,M,n,r,i,s,o,`${c}/else`,l);Nt.valid||Me.push({instanceLocation:o,keyword:"if",keywordLocation:tt,error:'Instance does not match "else" schema.'},...Nt.errors)}}if(d==="object"){if(x!==void 0)for(let vt of x)vt in e||Me.push({instanceLocation:o,keyword:"required",keywordLocation:`${c}/required`,error:`Instance does not have required property "${vt}".`});let tt=Object.keys(e);if(R!==void 0&&tt.length<R&&Me.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${c}/minProperties`,error:`Instance does not have at least ${R} properties.`}),W!==void 0&&tt.length>W&&Me.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${c}/maxProperties`,error:`Instance does not have at least ${W} properties.`}),C!==void 0){let vt=`${c}/propertyNames`;for(let at in e){let Ot=`${o}/${ph(at)}`,qe=ha(at,C,n,r,i,s,Ot,vt);qe.valid||Me.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:vt,error:`Property name "${at}" does not match schema.`},...qe.errors)}}if(O!==void 0){let vt=`${c}/dependantRequired`;for(let at in O)if(at in e){let Ot=O[at];for(let qe of Ot)qe in e||Me.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:vt,error:`Instance has "${at}" but does not have "${qe}".`})}}if(D!==void 0)for(let vt in D){let at=`${c}/dependentSchemas`;if(vt in e){let Ot=ha(e,D[vt],n,r,i,s,o,`${at}/${ph(vt)}`,l);Ot.valid||Me.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:at,error:`Instance has "${vt}" but does not match dependant schema.`},...Ot.errors)}}if(U!==void 0){let vt=`${c}/dependencies`;for(let at in U)if(at in e){let Ot=U[at];if(Array.isArray(Ot))for(let qe of Ot)qe in e||Me.push({instanceLocation:o,keyword:"dependencies",keywordLocation:vt,error:`Instance has "${at}" but does not have "${qe}".`});else{let qe=ha(e,Ot,n,r,i,s,o,`${vt}/${ph(at)}`);qe.valid||Me.push({instanceLocation:o,keyword:"dependencies",keywordLocation:vt,error:`Instance has "${at}" but does not match dependant schema.`},...qe.errors)}}}let Ke=Object.create(null),Nt=!1;if($!==void 0){let vt=`${c}/properties`;for(let at in $){if(!(at in e))continue;let Ot=`${o}/${ph(at)}`,qe=ha(e[at],$[at],n,r,i,s,Ot,`${vt}/${ph(at)}`);if(qe.valid)l[at]=Ke[at]=!0;else if(Nt=i,Me.push({instanceLocation:o,keyword:"properties",keywordLocation:vt,error:`Property "${at}" does not match schema.`},...qe.errors),Nt)break}}if(!Nt&&L!==void 0){let vt=`${c}/patternProperties`;for(let at in L){let Ot=new RegExp(at,"u"),qe=L[at];for(let Bt in e){if(!Ot.test(Bt))continue;let gn=`${o}/${ph(Bt)}`,It=ha(e[Bt],qe,n,r,i,s,gn,`${vt}/${ph(at)}`);It.valid?l[Bt]=Ke[Bt]=!0:(Nt=i,Me.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:vt,error:`Property "${Bt}" matches pattern "${at}" but does not match associated schema.`},...It.errors))}}}if(!Nt&&B!==void 0){let vt=`${c}/additionalProperties`;for(let at in e){if(Ke[at])continue;let Ot=`${o}/${ph(at)}`,qe=ha(e[at],B,n,r,i,s,Ot,vt);qe.valid?l[at]=!0:(Nt=i,Me.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:vt,error:`Property "${at}" does not match additional properties schema.`},...qe.errors))}}else if(!Nt&&ee!==void 0){let vt=`${c}/unevaluatedProperties`;for(let at in e)if(!l[at]){let Ot=`${o}/${ph(at)}`,qe=ha(e[at],ee,n,r,i,s,Ot,vt);qe.valid?l[at]=!0:Me.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:vt,error:`Property "${at}" does not match unevaluated properties schema.`},...qe.errors)}}}else if(d==="array"){he!==void 0&&e.length>he&&Me.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${c}/maxItems`,error:`Array has too many items (${e.length} > ${he}).`}),be!==void 0&&e.length<be&&Me.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${c}/minItems`,error:`Array has too few items (${e.length} < ${be}).`});let tt=e.length,Ke=0,Nt=!1;if(F!==void 0){let vt=`${c}/prefixItems`,at=Math.min(F.length,tt);for(;Ke<at;Ke++){let Ot=ha(e[Ke],F[Ke],n,r,i,s,`${o}/${Ke}`,`${vt}/${Ke}`);if(l[Ke]=!0,!Ot.valid&&(Nt=i,Me.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:vt,error:"Items did not match schema."},...Ot.errors),Nt))break}}if(K!==void 0){let vt=`${c}/items`;if(Array.isArray(K)){let at=Math.min(K.length,tt);for(;Ke<at;Ke++){let Ot=ha(e[Ke],K[Ke],n,r,i,s,`${o}/${Ke}`,`${vt}/${Ke}`);if(l[Ke]=!0,!Ot.valid&&(Nt=i,Me.push({instanceLocation:o,keyword:"items",keywordLocation:vt,error:"Items did not match schema."},...Ot.errors),Nt))break}}else for(;Ke<tt;Ke++){let at=ha(e[Ke],K,n,r,i,s,`${o}/${Ke}`,vt);if(l[Ke]=!0,!at.valid&&(Nt=i,Me.push({instanceLocation:o,keyword:"items",keywordLocation:vt,error:"Items did not match schema."},...at.errors),Nt))break}if(!Nt&&Z!==void 0){let at=`${c}/additionalItems`;for(;Ke<tt;Ke++){let Ot=ha(e[Ke],Z,n,r,i,s,`${o}/${Ke}`,at);l[Ke]=!0,Ot.valid||(Nt=i,Me.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:at,error:"Items did not match additional items schema."},...Ot.errors))}}}if(V!==void 0)if(tt===0&&oe===void 0)Me.push({instanceLocation:o,keyword:"contains",keywordLocation:`${c}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(oe!==void 0&&tt<oe)Me.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array has less items (${tt}) than minContains (${oe}).`});else{let vt=`${c}/contains`,at=Me.length,Ot=0;for(let qe=0;qe<tt;qe++){let Bt=ha(e[qe],V,n,r,i,s,`${o}/${qe}`,vt);Bt.valid?(l[qe]=!0,Ot++):Me.push(...Bt.errors)}Ot>=(oe||0)&&(Me.length=at),oe===void 0&&Te===void 0&&Ot===0?Me.splice(at,0,{instanceLocation:o,keyword:"contains",keywordLocation:vt,error:"Array does not contain item matching schema."}):oe!==void 0&&Ot<oe?Me.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array must contain at least ${oe} items matching schema. Only ${Ot} items were found.`}):Te!==void 0&&Ot>Te&&Me.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${c}/maxContains`,error:`Array may contain at most ${Te} items matching schema. ${Ot} items were found.`})}if(!Nt&&ne!==void 0){let vt=`${c}/unevaluatedItems`;for(Ke;Ke<tt;Ke++){if(l[Ke])continue;let at=ha(e[Ke],ne,n,r,i,s,`${o}/${Ke}`,vt);l[Ke]=!0,at.valid||Me.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:vt,error:"Items did not match unevaluated items schema."},...at.errors)}}if(Ae)for(let vt=0;vt<tt;vt++){let at=e[vt],Ot=typeof at=="object"&&at!==null;for(let qe=0;qe<tt;qe++){if(vt===qe)continue;let Bt=e[qe];(at===Bt||Ot&&(typeof Bt=="object"&&Bt!==null)&&SI(at,Bt))&&(Me.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${c}/uniqueItems`,error:`Duplicate items at indexes ${vt} and ${qe}.`}),vt=Number.MAX_SAFE_INTEGER,qe=Number.MAX_SAFE_INTEGER)}}}else if(d==="number"){if(n==="4"?(Re!==void 0&&(de===!0&&e<=Re||e<Re)&&Me.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${e} is less than ${de?"or equal to ":""} ${Re}.`}),me!==void 0&&(et===!0&&e>=me||e>me)&&Me.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${e} is greater than ${et?"or equal to ":""} ${me}.`})):(Re!==void 0&&e<Re&&Me.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${e} is less than ${Re}.`}),me!==void 0&&e>me&&Me.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${e} is greater than ${me}.`}),de!==void 0&&e<=de&&Me.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${c}/exclusiveMinimum`,error:`${e} is less than ${de}.`}),et!==void 0&&e>=et&&Me.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${c}/exclusiveMaximum`,error:`${e} is greater than or equal to ${et}.`})),Xe!==void 0){let tt=e%Xe;Math.abs(0-tt)>=11920929e-14&&Math.abs(Xe-tt)>=11920929e-14&&Me.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${c}/multipleOf`,error:`${e} is not a multiple of ${Xe}.`})}}else if(d==="string"){let tt=gt===void 0&&Fe===void 0?0:uQe(e);gt!==void 0&&tt<gt&&Me.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${c}/minLength`,error:`String is too short (${tt} < ${gt}).`}),Fe!==void 0&&tt>Fe&&Me.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${c}/maxLength`,error:`String is too long (${tt} > ${Fe}).`}),Oe!==void 0&&!new RegExp(Oe,"u").test(e)&&Me.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${c}/pattern`,error:"String does not match pattern."}),N!==void 0&&m0e[N]&&!m0e[N](e)&&Me.push({instanceLocation:o,keyword:"format",keywordLocation:`${c}/format`,error:`String does not match format "${N}".`})}return{valid:Me.length===0,errors:Me}}var y0e=j(()=>{h0e();eB();f0e();ZW();g0e();a(ha,"validate")});var tB,dQe=j(()=>{eB();y0e();tB=class{static{a(this,"Validator")}schema;draft;shortCircuit;lookup;constructor(t,n="2019-09",r=!0){this.schema=t,this.draft=n,this.shortCircuit=r,this.lookup=W1(t)}validate(t){return ha(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,n){n&&(t={...t,$id:n}),W1(t,this.lookup)}}});var pQe=j(()=>{h0e();eB();f0e();ZW();lQe();g0e();y0e();dQe()});var nB,hQe=j(()=>{pQe();nB=class{static{a(this,"CfWorkerJsonSchemaValidator")}constructor(t){this.shortcircuit=t?.shortcircuit??!0,this.draft=t?.draft??"2020-12"}getValidator(t){let n=new tB(t,this.draft,this.shortcircuit);return r=>{let i=n.validate(r);return i.valid?{valid:!0,data:r,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:i.errors.map(s=>`${s.instanceLocation}: ${s.error}`).join("; ")}}}}});var cc,rB=j(()=>{"use strict";cc={probeTimeoutMs:3e4,callTimeoutMs:6e4,maxToolsPerServer:128,maxCatalogPages:10,maxCatalogBytes:131072,maxDescriptionLength:512,maxErrorMessageChars:300,maxPublicNameLength:64,maxInstructionsLength:1024,metaToolThreshold:20}});import{createHash as Hcn}from"node:crypto";function Vcn(e){let t=e.replace(/[.*+?^${}()|[\]\\]/gu,n=>n==="*"?"\0":`\\${n}`);return new RegExp(`^${t.replaceAll("\0",".*")}$`)}function mQe(e,t,n){let r=t??"read_only";return r==="allow_all"?"allow":r==="approve_all"?"ask":n===!0?"allow":n===!1?"ask":Gcn.some(i=>Vcn(i).test(e))?"allow":"ask"}function q0(e){return e.replace(/Bearer\s+[^\s"']+/giu,"Bearer ***").replace(/(https?:\/\/[^\s"'?]+)\?[^\s"']*/giu,"$1?***").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/gu,"").slice(0,cc.maxErrorMessageChars)}function fQe(e,t){let n=`mcp__${e}__${t}`,r=n.replace(/[^A-Za-z0-9_-]/gu,"_");if(r===n&&r.length<=cc.maxPublicNameLength)return r;let i=Kcn(e,t),s=cc.maxPublicNameLength-i.length-1;return`${r.slice(0,s)}_${i}`}function Kcn(e,t){return Hcn("sha256").update(`${e}\0${t}`).digest("hex").slice(0,12)}function gQe(e){if(!(e==null||typeof e!="object"))try{let t=JSON.parse(JSON.stringify(e));return ck(t),t}catch{return}}function Ycn(e){return Qcn.has(e)}function yQe(e){return e.type!=="image"||e.data===void 0||e.mimeType===void 0||!Ycn(e.mimeType)||!Jcn.test(e.data)?void 0:{data:Uint8Array.from(atob(e.data),n=>n.charCodeAt(0)),mediaType:e.mimeType}}function vQe(e){return e.some(t=>t.type==="image"&&t.data!==void 0)}function pO(e){if(e.isError)return[{type:"text",text:e.content.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(`
|
|
165
165
|
`)||"MCP tool returned an error."}];let t=[],n=[];for(let r of e.content)if(r.type==="text"&&typeof r.text=="string")n.push(r.text);else if(r.type==="resource_link"&&r.uri!==void 0)n.push(`Resource: ${r.name??"unnamed"} (${r.uri})`);else if(r.type==="image"&&r.data!==void 0)n.push(``);else if(r.type==="image")n.push(`[image: ${r.mimeType??"unknown type"}]`);else if(r.type==="audio")n.push("[audio result unsupported on Cloudflare Workers]");else if(r.type==="resource"&&r.resource?.text!==void 0){let i=r.resource.uri??"embedded resource";n.push(`--- ${i} ---
|
|
166
166
|
${r.resource.text}`)}else r.type==="resource"?n.push("[embedded resource: binary content not displayed]"):n.push(`[unsupported MCP content type: ${r.type}]`);return n.length>0&&t.push({type:"text",text:n.join(`
|
|
167
|
-
`)}),t.length>0?t:[{type:"text",text:"(empty MCP result)"}]}var Gcn,Qcn,Jcn,iB=j(()=>{"use strict";Qo();rB();Gcn=["get_*","list_*","read_*","search_*","find_*","fetch_*","describe_*"];a(Vcn,"globToRegExp");a(mQe,"evaluateMcpToolPolicy");a(q0,"scrubMcpErrorMessage");a(fQe,"publicToolName");a(Kcn,"hashSuffix");a(gQe,"supportedOutputSchema");Qcn=new Set(["image/png","image/jpeg"]),Jcn=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;a(Ycn,"isImageMediaType");a(yQe,"decodeImageBlock");a(vQe,"containsImage");a(pO,"mapMcpResultToContentBlocks")});var v0e,xQe=j(()=>{v0e={name:"dsh-edge",version:"0.27.0",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.2.1-rc.2"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dev:container":"pnpm run bundle:isolated && node scripts/dev.mjs container","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","check:startup":"node scripts/check-startup.mjs","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:container":"pnpm run bundle:isolated && node tests/container.integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.1","jsonc-parser":"^3.3.1",wrangler:"4.129.0",yaml:"2.9.0"},devDependencies:{"@cfworker/json-schema":"^4.1.1","@cloudflare/computer":"0.3.1","@cloudflare/workers-types":"5.20260904.1","@deepseek-ai/cordis":"4.0.5","@deepseek-ai/cosmokit":"1.8.6","@deepseek-ai/dsh-agent":"0.2.1-rc.2","@deepseek-ai/dsh-agent-instructions":"0.2.1-rc.2","@deepseek-ai/dsh-agent-loop":"0.2.1-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.2.1-rc.2","@deepseek-ai/dsh-api-gateway":"0.2.1-rc.2","@deepseek-ai/dsh-api-job-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-remote-access":"0.2.1-rc.2","@deepseek-ai/dsh-api-remotes":"0.2.1-rc.2","@deepseek-ai/dsh-api-session-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-settings-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-workspace-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-workspace-files":"0.2.1-rc.2","@deepseek-ai/dsh-attachment":"0.2.1-rc.2","@deepseek-ai/dsh-brand":"0.2.1-rc.2","@deepseek-ai/dsh-client-connection":"0.2.1-rc.2","@deepseek-ai/dsh-client-locale":"0.2.1-rc.2","@deepseek-ai/dsh-client-store":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-chat":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-conversation":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-settings":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-settings-general":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-theme":"0.2.1-rc.2","@deepseek-ai/dsh-command-compact":"0.2.1-rc.2","@deepseek-ai/dsh-command-feedback":"0.2.1-rc.2","@deepseek-ai/dsh-command-goal":"0.2.1-rc.2","@deepseek-ai/dsh-commands":"0.2.1-rc.2","@deepseek-ai/dsh-compaction":"0.2.1-rc.2","@deepseek-ai/dsh-compaction-basic":"0.2.1-rc.2","@deepseek-ai/dsh-compaction-image-offload":"0.2.1-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.2.1-rc.2","@deepseek-ai/dsh-credentials":"0.2.1-rc.2","@deepseek-ai/dsh-file-reference":"0.2.1-rc.2","@deepseek-ai/dsh-fs":"0.2.1-rc.2","@deepseek-ai/dsh-fs-observation-policy":"0.2.1-rc.2","@deepseek-ai/dsh-goal":"0.2.1-rc.2","@deepseek-ai/dsh-goal-round-driver":"0.2.1-rc.2","@deepseek-ai/dsh-home-paths":"0.2.1-rc.2","@deepseek-ai/dsh-host-directory-picker":"0.2.1-rc.2","@deepseek-ai/dsh-host-plugin-inventory":"0.2.1-rc.2","@deepseek-ai/dsh-jobs":"0.2.1-rc.2","@deepseek-ai/dsh-jobs-local":"0.2.1-rc.2","@deepseek-ai/dsh-launch-environment":"0.2.1-rc.2","@deepseek-ai/dsh-llm":"0.2.1-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.2.1-rc.2","@deepseek-ai/dsh-llm-deepseek-api-key":"0.2.1-rc.2","@deepseek-ai/dsh-llm-pi-ai":"0.2.1-rc.2","@deepseek-ai/dsh-llm-retry":"0.2.1-rc.2","@deepseek-ai/dsh-message-feedback":"0.2.1-rc.2","@deepseek-ai/dsh-output-retention":"0.2.1-rc.2","@deepseek-ai/dsh-plan-mode":"0.2.1-rc.2","@deepseek-ai/dsh-ptc-runtime":"0.2.1-rc.2","@deepseek-ai/dsh-repeat-tool-reminder":"0.2.1-rc.2","@deepseek-ai/dsh-sandbox":"0.2.1-rc.2","@deepseek-ai/dsh-schedule":"0.2.1-rc.2","@deepseek-ai/dsh-scope":"0.2.1-rc.2","@deepseek-ai/dsh-session":"0.2.1-rc.2","@deepseek-ai/dsh-session-checkpoint-policy":"0.2.1-rc.2","@deepseek-ai/dsh-session-log-export":"0.2.1-rc.2","@deepseek-ai/dsh-session-format":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-catalog":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v0-to-v1":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v1-to-v2":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v2-to-v3":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v3-to-v4":"0.2.1-rc.2","@deepseek-ai/dsh-session-persistence":"0.2.1-rc.2","@deepseek-ai/dsh-session-projection":"0.2.1-rc.2","@deepseek-ai/dsh-session-projection-cache":"0.2.1-rc.2","@deepseek-ai/dsh-session-stats":"0.2.1-rc.2","@deepseek-ai/dsh-session-turn-outline":"0.2.1-rc.2","@deepseek-ai/dsh-session-query":"0.2.1-rc.2","@deepseek-ai/dsh-session-reference":"0.2.1-rc.2","@deepseek-ai/dsh-session-title":"0.2.1-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.2.1-rc.2","@deepseek-ai/dsh-shell-env":"0.2.1-rc.2","@deepseek-ai/dsh-session-title-llm":"0.2.1-rc.2","@deepseek-ai/dsh-settings":"0.2.1-rc.2","@deepseek-ai/dsh-skill":"0.2.1-rc.2","@deepseek-ai/dsh-spill":"0.2.1-rc.2","@deepseek-ai/dsh-spill-policy":"0.2.1-rc.2","@deepseek-ai/dsh-storage":"0.2.1-rc.2","@deepseek-ai/dsh-storage-domain":"0.2.1-rc.2","@deepseek-ai/dsh-subagent":"0.2.1-rc.2","@deepseek-ai/dsh-subagent-fork-in-process":"0.2.1-rc.2","@deepseek-ai/dsh-subagent-spawn-in-process":"0.2.1-rc.2","@deepseek-ai/dsh-system-prompt":"0.2.1-rc.2","@deepseek-ai/dsh-time-context":"0.2.1-rc.2","@deepseek-ai/dsh-timeout":"0.2.1-rc.2","@deepseek-ai/dsh-token-meter":"0.2.1-rc.2","@deepseek-ai/dsh-tool-ask-user":"0.2.1-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.2.1-rc.2","@deepseek-ai/dsh-tool-fs":"0.2.1-rc.2","@deepseek-ai/dsh-tool-fs-search":"0.2.1-rc.2","@deepseek-ai/dsh-tool-goal":"0.2.1-rc.2","@deepseek-ai/dsh-tool-jobs":"0.2.1-rc.2","@deepseek-ai/dsh-tool-schedule":"0.2.1-rc.2","@deepseek-ai/dsh-tool-skill":"0.2.1-rc.2","@deepseek-ai/dsh-tool-subagent":"0.2.1-rc.2","@deepseek-ai/dsh-tool-subagent-control":"0.2.1-rc.2","@deepseek-ai/dsh-tool-present":"0.2.1-rc.2","@deepseek-ai/dsh-tool-todo":"0.2.1-rc.2","@deepseek-ai/dsh-tool-web":"0.2.1-rc.2","@deepseek-ai/dsh-tool-workflow":"0.2.1-rc.2","@deepseek-ai/dsh-tool-working-directory":"0.2.1-rc.2","@deepseek-ai/dsh-tools":"0.2.1-rc.2","@deepseek-ai/dsh-typert-protocol":"0.2.1-rc.2","@deepseek-ai/dsh-typert-registry":"0.2.1-rc.2","@deepseek-ai/dsh-user-approval":"0.2.1-rc.2","@deepseek-ai/dsh-user-questions":"0.2.1-rc.2","@deepseek-ai/dsh-util-values":"0.2.1-rc.2","@deepseek-ai/dsh-web":"0.2.1-rc.2","@deepseek-ai/dsh-web-deepseek-api":"0.2.1-rc.2","@deepseek-ai/dsh-web-fetch-http":"0.2.1-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.2.1-rc.2","@deepseek-ai/dsh-workflow":"0.2.1-rc.2","@deepseek-ai/dsh-working-directory":"0.2.1-rc.2","@deepseek-ai/dsh-workspace":"0.2.1-rc.2","@deepseek-ai/schemastery":"3.18.5","@mixmark-io/domino":"2.2.0","@modelcontextprotocol/sdk":"1.30.0",acorn:"8.18.0","fast-png":"8.0.0",fflate:"0.8.3","jpeg-js":"0.4.4","just-bash":"3.4.2",minimatch:"10.2.6",playwright:"^1.49.0",re2js:"1.3.3",sucrase:"3.35.1",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}}});var u_,bQe,wQe,hO=j(()=>{"use strict";xQe();u_=v0e.version,bQe=v0e.dshEdge.upstreamVersion,wQe=`npx dsh-edge@${u_.includes("-")?"next":"latest"} upgrade`});function nln(e){let t=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/iu.exec(e);if(t!==null)return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(e);if(n!==null){let r=parseInt(n[1],16),i=parseInt(n[2],16);return`${String(r>>8)}.${String(r&255)}.${String(i>>8)}.${String(i&255)}`}}function rln(e){return/^\d+\.\d+\.\d+\.\d+$/u.test(e)||e.includes(":")}function B1(e){let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("MCP server URL must use http: or https: protocol.");let n=t.hostname.toLowerCase(),r=n.endsWith(".")?n.slice(0,-1):n,i=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(!(i==="localhost"||i==="127.0.0.1"||i==="::1")){for(let s of Zcn)if(i.endsWith(s))throw new Error(`MCP server hostname "${i}" is blocked.`);if(rln(i)){let s=nln(i),o=s??i;for(let c of eln)if(c.test(o))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`);if(s===void 0){for(let c of tln)if(c.test(i))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`)}}}}function iln(e){return e?.type==="bearer"&&e.token!==void 0?{Authorization:`Bearer ${e.token}`}:{}}async function kQe(e,t,n){B1(e);let r=new XW(new URL(e),{requestInit:{headers:iln(t),signal:n},fetch:d_}),i=new JW({name:"dsh-edge",version:u_},{capabilities:{},jsonSchemaValidator:sln});return await i.connect(r),{client:i,close:a(async()=>{await i.close().catch(()=>{})},"close")}}async function _Qe(e,t,n){let r=AbortSignal.timeout(cc.probeTimeoutMs),i;try{i=await kQe(t,n,r)}catch(c){throw new Error(q0(c instanceof Error?c.message:String(c)))}let{client:s,close:o}=i;try{let c=[],l=new Set,u=new Set,d;for(let m=0;m<cc.maxCatalogPages;m++){let f=await s.listTools(d===void 0?void 0:{cursor:d},{signal:r});for(let g of f.tools){if(c.length>=cc.maxToolsPerServer)break;let v=fQe(e,g.name);if(l.has(v))throw new Error(`Server listed tool "${g.name}" more than once`);l.add(v);let x=g.annotations?.readOnlyHint,b=gQe(g.outputSchema);c.push({name:g.name,publicName:v,description:g.description??"",inputSchema:g.inputSchema??{type:"object"},...b!==void 0?{outputSchema:b}:{},...x!==void 0?{annotations:{readOnlyHint:x}}:{}})}if(c.length>=cc.maxToolsPerServer||(d=f.nextCursor??void 0,d===void 0))break;if(u.has(d))throw new Error("Server repeated a tools/list continuation cursor");u.add(d)}let p=s.getServerVersion?.(),h=s.getInstructions?.();return{tools:c,serverInfo:p?{name:p.name,version:p.version}:void 0,instructions:typeof h=="string"&&h.length>0?h.slice(0,cc.maxInstructionsLength):void 0}}finally{await o()}}async function sB(e,t,n,r,i,s){let o=s??cc.callTimeoutMs,c=i?AbortSignal.any([i,AbortSignal.timeout(o)]):AbortSignal.timeout(o),l;try{l=await kQe(e,r,c)}catch(u){throw new Error(q0(u instanceof Error?u.message:String(u)))}try{let u=await l.client.callTool({name:t,arguments:n},void 0,{signal:c});return{content:u.content??[],structuredContent:u.structuredContent,isError:u.isError===!0}}catch(u){throw new Error(q0(u instanceof Error?u.message:String(u)))}finally{await l.close()}}var Zcn,eln,tln,sln,d_,mO=j(()=>{"use strict";TKe();sQe();hQe();iB();rB();hO();Zcn=[".internal",".local",".localhost"],eln=[/^127\./u,/^10\./u,/^172\.(1[6-9]|2\d|3[01])\./u,/^192\.168\./u,/^0\./u,/^169\.254\./u],tln=[/^::1$/u,/^fc/iu,/^fd/iu,/^fe[89ab][0-9a-f]:/iu];a(nln,"extractMappedIPv4");a(rln,"isIpAddress");a(B1,"assertSafeUrl");a(iln,"buildHeaders");sln=new nB,d_=a(async(e,t)=>{let n=await globalThis.fetch(e,{...t,redirect:"manual"});if(n.status>=300&&n.status<400)throw new Error(`MCP server returned HTTP ${String(n.status)} redirect; redirects are blocked for security.`);return n},"noRedirectFetch");a(kQe,"connectClient");a(_Qe,"probe");a(sB,"callTool")});var aB={};qt(aB,{buildAuthorizationUrl:()=>mln,discoverEndpoints:()=>pln,exchangeCode:()=>fln,isTokenExpired:()=>yln,refreshToken:()=>gln,registerClient:()=>hln});function AQe(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("").slice(0,e)}async function dln(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=/gu,"")}async function pln(e){let t=AbortSignal.timeout(oB),n=new URL(e),r=n.pathname==="/"?"/.well-known/oauth-protected-resource":`/.well-known/oauth-protected-resource${n.pathname}`,i=new URL(r,n.origin);B1(i.href);let s=await d_(i.href,{signal:t});if(!s.ok)throw new Error(`PRM discovery failed: HTTP ${s.status}`);let c=(await s.json()).authorization_servers?.[0];if(typeof c!="string")throw new Error("No authorization server in PRM");let l=new URL(c),u=l.pathname==="/"?"/.well-known/oauth-authorization-server":`/.well-known/oauth-authorization-server${l.pathname}`,d=new URL(u,l.origin);B1(d.href);let p=await d_(d.href,{signal:t});if(!p.ok)throw new Error(`AS metadata failed: HTTP ${p.status}`);let h=await p.json();if(typeof h.authorization_endpoint!="string"||typeof h.token_endpoint!="string")throw new Error("Missing required endpoints in AS metadata");return{authorization:h.authorization_endpoint,token:h.token_endpoint,registration:h.registration_endpoint}}async function hln(e,t,n){let r=AbortSignal.timeout(oB);B1(e);let i=await d_(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:n,redirect_uris:[t],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}),signal:r});if(!i.ok)throw new Error(`DCR failed: HTTP ${i.status}`);let s=await i.json();if(typeof s.client_id!="string")throw new Error("DCR response missing client_id");return{clientId:s.client_id,clientSecret:s.client_secret}}async function mln(e,t,n,r,i){let s=AQe(32),o=AQe(64),c=await dln(o),l=new URL(e.authorization);for(let[u,d]of Object.entries({response_type:"code",client_id:t.clientId,redirect_uri:n,state:s,code_challenge:c,code_challenge_method:"S256",resource:i}))l.searchParams.set(u,d);return{authorizationUrl:l.href,pendingFlow:{state:s,codeVerifier:o,redirectUri:n,serverName:r,serverUrl:i,stagedClient:t,createdAt:Date.now()}}}async function fln(e,t,n,r,i,s){let o=AbortSignal.timeout(oB),c=new URLSearchParams({grant_type:"authorization_code",code:n,redirect_uri:i,client_id:t.clientId,code_verifier:r});s!==void 0&&c.set("resource",s),t.clientSecret!==void 0&&c.set("client_secret",t.clientSecret),B1(e);let l=await d_(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:c.toString(),signal:o});if(!l.ok)throw new Error(`Token exchange failed: HTTP ${l.status}`);return IQe(await l.json())}async function gln(e,t,n,r){let i=AbortSignal.timeout(oB),s=new URLSearchParams({grant_type:"refresh_token",refresh_token:n,client_id:t.clientId});r!==void 0&&s.set("resource",r),t.clientSecret!==void 0&&s.set("client_secret",t.clientSecret),B1(e);let o=await d_(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:s.toString(),signal:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return IQe(await o.json())}function IQe(e){let t=e;if(typeof t.access_token!="string")throw new Error("Missing access_token");let n=typeof t.expires_in=="number"?t.expires_in:void 0;return{accessToken:t.access_token,refreshToken:typeof t.refresh_token=="string"?t.refresh_token:void 0,expiresAt:n!==void 0?Date.now()+n*1e3:void 0,tokenType:typeof t.token_type=="string"?t.token_type:"Bearer",scope:typeof t.scope=="string"?t.scope:void 0}}function yln(e){return e.expiresAt===void 0?!1:Date.now()>e.expiresAt-12e4}var oB,cB=j(()=>{"use strict";mO();oB=1e4;a(AQe,"randomString");a(dln,"sha256Base64Url");a(pln,"discoverEndpoints");a(hln,"registerClient");a(mln,"buildAuthorizationUrl");a(fln,"exchangeCode");a(gln,"refreshToken");a(IQe,"parseTokenResponse");a(yln,"isTokenExpired")});var wr,DQe,EI=j(()=>{dr();Fr();wr=class extends Li{static{a(this,"FsError")}code;constructor(e,t,n){super(e,t,n),this.code=t}},DQe=class extends Lt{static{a(this,"FileSystem")}constructor(e){super(e,"fs")}watch(e,t,n){return n.throwIfAborted(),Promise.reject(new wr("Filesystem watching is not supported by this provider.","FS_IO_ERROR"))}get sandboxMode(){}processPathFromHostPath(e){}}});function xO(e){return xB.test(e)}function bB(e){return e.invocation.modelInvocable}function AI(e){return e.invocation.userInvocable}function $0e(e){let t=tdn(e);return[`<skill_content name="${ndn(e.name)}">`,"<skill_resources>",...t,"</skill_resources>","","<skill_instructions>",e.content,"</skill_instructions>","</skill_content>"].join(`
|
|
167
|
+
`)}),t.length>0?t:[{type:"text",text:"(empty MCP result)"}]}var Gcn,Qcn,Jcn,iB=j(()=>{"use strict";Qo();rB();Gcn=["get_*","list_*","read_*","search_*","find_*","fetch_*","describe_*"];a(Vcn,"globToRegExp");a(mQe,"evaluateMcpToolPolicy");a(q0,"scrubMcpErrorMessage");a(fQe,"publicToolName");a(Kcn,"hashSuffix");a(gQe,"supportedOutputSchema");Qcn=new Set(["image/png","image/jpeg"]),Jcn=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;a(Ycn,"isImageMediaType");a(yQe,"decodeImageBlock");a(vQe,"containsImage");a(pO,"mapMcpResultToContentBlocks")});var v0e,xQe=j(()=>{v0e={name:"dsh-edge",version:"0.27.2",description:"Your DeepSeek Harness, anywhere \u2014 deploy a persistent personal coding agent to Cloudflare Workers in one command",author:"pawaca",license:"MIT",type:"module",bin:{"dsh-edge":"scripts/cli.mjs"},files:["dist","worker","scripts/*.d.mts","scripts/*.mjs","wrangler.jsonc","README.md","README.zh.md","LICENSE","THIRD_PARTY_NOTICES.md"],repository:{type:"git",url:"git+https://github.com/pawaca/dsh-edge.git",directory:"apps/dsh-edge"},homepage:"https://github.com/pawaca/dsh-edge#readme",bugs:{url:"https://github.com/pawaca/dsh-edge/issues"},keywords:["deepseek","deepseek-harness","ai-agents","byok","cloudflare-workers","durable-objects","self-hosted"],engines:{node:">=22.14.0"},publishConfig:{access:"public"},dshEdge:{upstreamVersion:"0.2.1-rc.2"},scripts:{"bundle:direct":"pnpm run web:build && pnpm --dir standalone run build:worker:direct && node standalone/scripts/promote.mjs direct","bundle:isolated":"pnpm run web:build && pnpm --dir standalone run build:worker:isolated && node standalone/scripts/promote.mjs isolated","bundle:workers":"pnpm --dir standalone run build && pnpm --dir standalone run verify && node standalone/scripts/promote.mjs all",dev:"pnpm run bundle:direct && node scripts/dev.mjs direct","dev:isolated":"pnpm run bundle:isolated && node scripts/dev.mjs isolated","dev:container":"pnpm run bundle:isolated && node scripts/dev.mjs container","dsh-edge":"node scripts/cli.mjs","example:install":"node examples/install-keyless.mjs","install:cloudflare":"pnpm run bundle:workers && node scripts/cli.mjs install","legal:write":"node scripts/legal-files.mjs write","check:startup":"node scripts/check-startup.mjs","pack:verify":"node scripts/verify-packed.mjs",prepack:"node scripts/legal-files.mjs verify && pnpm run bundle:workers","web:build":"pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",test:"vitest run --root ../.. --project edge-runtime","test:integration":"pnpm run bundle:workers && node tests/run-session-integration.mjs","test:container":"pnpm run bundle:isolated && node tests/container.integration.mjs","test:snapshot":"vitest run --root ../.. --config apps/dsh-edge/vitest.snapshot.config.ts",typecheck:"tsc --noEmit"},dependencies:{"@clack/prompts":"1.7.0","compare-versions":"6.1.1",execa:"^10.0.1","jsonc-parser":"^3.3.1",wrangler:"4.129.0",yaml:"2.9.0"},devDependencies:{"@cfworker/json-schema":"^4.1.1","@cloudflare/computer":"0.3.1","@cloudflare/workers-types":"5.20260904.1","@deepseek-ai/cordis":"4.0.5","@deepseek-ai/cosmokit":"1.8.6","@deepseek-ai/dsh-agent":"0.2.1-rc.2","@deepseek-ai/dsh-agent-instructions":"0.2.1-rc.2","@deepseek-ai/dsh-agent-loop":"0.2.1-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.2.1-rc.2","@deepseek-ai/dsh-api-gateway":"0.2.1-rc.2","@deepseek-ai/dsh-api-job-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-remote-access":"0.2.1-rc.2","@deepseek-ai/dsh-api-remotes":"0.2.1-rc.2","@deepseek-ai/dsh-api-session-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-settings-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-workspace-controller":"0.2.1-rc.2","@deepseek-ai/dsh-api-workspace-files":"0.2.1-rc.2","@deepseek-ai/dsh-attachment":"0.2.1-rc.2","@deepseek-ai/dsh-brand":"0.2.1-rc.2","@deepseek-ai/dsh-client-connection":"0.2.1-rc.2","@deepseek-ai/dsh-client-locale":"0.2.1-rc.2","@deepseek-ai/dsh-client-store":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-chat":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-conversation":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-settings":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-settings-general":"0.2.1-rc.2","@deepseek-ai/dsh-client-ui-theme":"0.2.1-rc.2","@deepseek-ai/dsh-command-compact":"0.2.1-rc.2","@deepseek-ai/dsh-command-feedback":"0.2.1-rc.2","@deepseek-ai/dsh-command-goal":"0.2.1-rc.2","@deepseek-ai/dsh-commands":"0.2.1-rc.2","@deepseek-ai/dsh-compaction":"0.2.1-rc.2","@deepseek-ai/dsh-compaction-basic":"0.2.1-rc.2","@deepseek-ai/dsh-compaction-image-offload":"0.2.1-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.2.1-rc.2","@deepseek-ai/dsh-credentials":"0.2.1-rc.2","@deepseek-ai/dsh-file-reference":"0.2.1-rc.2","@deepseek-ai/dsh-fs":"0.2.1-rc.2","@deepseek-ai/dsh-fs-observation-policy":"0.2.1-rc.2","@deepseek-ai/dsh-goal":"0.2.1-rc.2","@deepseek-ai/dsh-goal-round-driver":"0.2.1-rc.2","@deepseek-ai/dsh-home-paths":"0.2.1-rc.2","@deepseek-ai/dsh-host-directory-picker":"0.2.1-rc.2","@deepseek-ai/dsh-host-plugin-inventory":"0.2.1-rc.2","@deepseek-ai/dsh-jobs":"0.2.1-rc.2","@deepseek-ai/dsh-jobs-local":"0.2.1-rc.2","@deepseek-ai/dsh-launch-environment":"0.2.1-rc.2","@deepseek-ai/dsh-llm":"0.2.1-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.2.1-rc.2","@deepseek-ai/dsh-llm-deepseek-api-key":"0.2.1-rc.2","@deepseek-ai/dsh-llm-pi-ai":"0.2.1-rc.2","@deepseek-ai/dsh-llm-retry":"0.2.1-rc.2","@deepseek-ai/dsh-message-feedback":"0.2.1-rc.2","@deepseek-ai/dsh-output-retention":"0.2.1-rc.2","@deepseek-ai/dsh-plan-mode":"0.2.1-rc.2","@deepseek-ai/dsh-ptc-runtime":"0.2.1-rc.2","@deepseek-ai/dsh-repeat-tool-reminder":"0.2.1-rc.2","@deepseek-ai/dsh-sandbox":"0.2.1-rc.2","@deepseek-ai/dsh-schedule":"0.2.1-rc.2","@deepseek-ai/dsh-scope":"0.2.1-rc.2","@deepseek-ai/dsh-session":"0.2.1-rc.2","@deepseek-ai/dsh-session-checkpoint-policy":"0.2.1-rc.2","@deepseek-ai/dsh-session-log-export":"0.2.1-rc.2","@deepseek-ai/dsh-session-format":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-catalog":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v0-to-v1":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v1-to-v2":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v2-to-v3":"0.2.1-rc.2","@deepseek-ai/dsh-session-format-v3-to-v4":"0.2.1-rc.2","@deepseek-ai/dsh-session-persistence":"0.2.1-rc.2","@deepseek-ai/dsh-session-projection":"0.2.1-rc.2","@deepseek-ai/dsh-session-projection-cache":"0.2.1-rc.2","@deepseek-ai/dsh-session-stats":"0.2.1-rc.2","@deepseek-ai/dsh-session-turn-outline":"0.2.1-rc.2","@deepseek-ai/dsh-session-query":"0.2.1-rc.2","@deepseek-ai/dsh-session-reference":"0.2.1-rc.2","@deepseek-ai/dsh-session-title":"0.2.1-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.2.1-rc.2","@deepseek-ai/dsh-shell-env":"0.2.1-rc.2","@deepseek-ai/dsh-session-title-llm":"0.2.1-rc.2","@deepseek-ai/dsh-settings":"0.2.1-rc.2","@deepseek-ai/dsh-skill":"0.2.1-rc.2","@deepseek-ai/dsh-spill":"0.2.1-rc.2","@deepseek-ai/dsh-spill-policy":"0.2.1-rc.2","@deepseek-ai/dsh-storage":"0.2.1-rc.2","@deepseek-ai/dsh-storage-domain":"0.2.1-rc.2","@deepseek-ai/dsh-subagent":"0.2.1-rc.2","@deepseek-ai/dsh-subagent-fork-in-process":"0.2.1-rc.2","@deepseek-ai/dsh-subagent-spawn-in-process":"0.2.1-rc.2","@deepseek-ai/dsh-system-prompt":"0.2.1-rc.2","@deepseek-ai/dsh-time-context":"0.2.1-rc.2","@deepseek-ai/dsh-timeout":"0.2.1-rc.2","@deepseek-ai/dsh-token-meter":"0.2.1-rc.2","@deepseek-ai/dsh-tool-ask-user":"0.2.1-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.2.1-rc.2","@deepseek-ai/dsh-tool-fs":"0.2.1-rc.2","@deepseek-ai/dsh-tool-fs-search":"0.2.1-rc.2","@deepseek-ai/dsh-tool-goal":"0.2.1-rc.2","@deepseek-ai/dsh-tool-jobs":"0.2.1-rc.2","@deepseek-ai/dsh-tool-schedule":"0.2.1-rc.2","@deepseek-ai/dsh-tool-skill":"0.2.1-rc.2","@deepseek-ai/dsh-tool-subagent":"0.2.1-rc.2","@deepseek-ai/dsh-tool-subagent-control":"0.2.1-rc.2","@deepseek-ai/dsh-tool-present":"0.2.1-rc.2","@deepseek-ai/dsh-tool-todo":"0.2.1-rc.2","@deepseek-ai/dsh-tool-web":"0.2.1-rc.2","@deepseek-ai/dsh-tool-workflow":"0.2.1-rc.2","@deepseek-ai/dsh-tool-working-directory":"0.2.1-rc.2","@deepseek-ai/dsh-tools":"0.2.1-rc.2","@deepseek-ai/dsh-typert-protocol":"0.2.1-rc.2","@deepseek-ai/dsh-typert-registry":"0.2.1-rc.2","@deepseek-ai/dsh-user-approval":"0.2.1-rc.2","@deepseek-ai/dsh-user-questions":"0.2.1-rc.2","@deepseek-ai/dsh-util-values":"0.2.1-rc.2","@deepseek-ai/dsh-web":"0.2.1-rc.2","@deepseek-ai/dsh-web-deepseek-api":"0.2.1-rc.2","@deepseek-ai/dsh-web-fetch-http":"0.2.1-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.2.1-rc.2","@deepseek-ai/dsh-workflow":"0.2.1-rc.2","@deepseek-ai/dsh-working-directory":"0.2.1-rc.2","@deepseek-ai/dsh-workspace":"0.2.1-rc.2","@deepseek-ai/schemastery":"3.18.5","@mixmark-io/domino":"2.2.0","@modelcontextprotocol/sdk":"1.30.0",acorn:"8.18.0","fast-png":"8.0.0",fflate:"0.8.3","jpeg-js":"0.4.4","just-bash":"3.4.2",minimatch:"10.2.6",playwright:"^1.49.0",re2js:"1.3.3",sucrase:"3.35.1",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}}});var u_,bQe,wQe,hO=j(()=>{"use strict";xQe();u_=v0e.version,bQe=v0e.dshEdge.upstreamVersion,wQe=`npx dsh-edge@${u_.includes("-")?"next":"latest"} upgrade`});function nln(e){let t=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/iu.exec(e);if(t!==null)return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/iu.exec(e);if(n!==null){let r=parseInt(n[1],16),i=parseInt(n[2],16);return`${String(r>>8)}.${String(r&255)}.${String(i>>8)}.${String(i&255)}`}}function rln(e){return/^\d+\.\d+\.\d+\.\d+$/u.test(e)||e.includes(":")}function B1(e){let t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("MCP server URL must use http: or https: protocol.");let n=t.hostname.toLowerCase(),r=n.endsWith(".")?n.slice(0,-1):n,i=r.startsWith("[")&&r.endsWith("]")?r.slice(1,-1):r;if(!(i==="localhost"||i==="127.0.0.1"||i==="::1")){for(let s of Zcn)if(i.endsWith(s))throw new Error(`MCP server hostname "${i}" is blocked.`);if(rln(i)){let s=nln(i),o=s??i;for(let c of eln)if(c.test(o))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`);if(s===void 0){for(let c of tln)if(c.test(i))throw new Error(`MCP server address "${i}" is a private IP and is blocked.`)}}}}function iln(e){return e?.type==="bearer"&&e.token!==void 0?{Authorization:`Bearer ${e.token}`}:{}}async function kQe(e,t,n){B1(e);let r=new XW(new URL(e),{requestInit:{headers:iln(t),signal:n},fetch:d_}),i=new JW({name:"dsh-edge",version:u_},{capabilities:{},jsonSchemaValidator:sln});return await i.connect(r),{client:i,close:a(async()=>{await i.close().catch(()=>{})},"close")}}async function _Qe(e,t,n){let r=AbortSignal.timeout(cc.probeTimeoutMs),i;try{i=await kQe(t,n,r)}catch(c){throw new Error(q0(c instanceof Error?c.message:String(c)))}let{client:s,close:o}=i;try{let c=[],l=new Set,u=new Set,d;for(let m=0;m<cc.maxCatalogPages;m++){let f=await s.listTools(d===void 0?void 0:{cursor:d},{signal:r});for(let g of f.tools){if(c.length>=cc.maxToolsPerServer)break;let v=fQe(e,g.name);if(l.has(v))throw new Error(`Server listed tool "${g.name}" more than once`);l.add(v);let x=g.annotations?.readOnlyHint,b=gQe(g.outputSchema);c.push({name:g.name,publicName:v,description:g.description??"",inputSchema:g.inputSchema??{type:"object"},...b!==void 0?{outputSchema:b}:{},...x!==void 0?{annotations:{readOnlyHint:x}}:{}})}if(c.length>=cc.maxToolsPerServer||(d=f.nextCursor??void 0,d===void 0))break;if(u.has(d))throw new Error("Server repeated a tools/list continuation cursor");u.add(d)}let p=s.getServerVersion?.(),h=s.getInstructions?.();return{tools:c,serverInfo:p?{name:p.name,version:p.version}:void 0,instructions:typeof h=="string"&&h.length>0?h.slice(0,cc.maxInstructionsLength):void 0}}finally{await o()}}async function sB(e,t,n,r,i,s){let o=s??cc.callTimeoutMs,c=i?AbortSignal.any([i,AbortSignal.timeout(o)]):AbortSignal.timeout(o),l;try{l=await kQe(e,r,c)}catch(u){throw new Error(q0(u instanceof Error?u.message:String(u)))}try{let u=await l.client.callTool({name:t,arguments:n},void 0,{signal:c});return{content:u.content??[],structuredContent:u.structuredContent,isError:u.isError===!0}}catch(u){throw new Error(q0(u instanceof Error?u.message:String(u)))}finally{await l.close()}}var Zcn,eln,tln,sln,d_,mO=j(()=>{"use strict";TKe();sQe();hQe();iB();rB();hO();Zcn=[".internal",".local",".localhost"],eln=[/^127\./u,/^10\./u,/^172\.(1[6-9]|2\d|3[01])\./u,/^192\.168\./u,/^0\./u,/^169\.254\./u],tln=[/^::1$/u,/^fc/iu,/^fd/iu,/^fe[89ab][0-9a-f]:/iu];a(nln,"extractMappedIPv4");a(rln,"isIpAddress");a(B1,"assertSafeUrl");a(iln,"buildHeaders");sln=new nB,d_=a(async(e,t)=>{let n=await globalThis.fetch(e,{...t,redirect:"manual"});if(n.status>=300&&n.status<400)throw new Error(`MCP server returned HTTP ${String(n.status)} redirect; redirects are blocked for security.`);return n},"noRedirectFetch");a(kQe,"connectClient");a(_Qe,"probe");a(sB,"callTool")});var aB={};qt(aB,{buildAuthorizationUrl:()=>mln,discoverEndpoints:()=>pln,exchangeCode:()=>fln,isTokenExpired:()=>yln,refreshToken:()=>gln,registerClient:()=>hln});function AQe(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("").slice(0,e)}async function dln(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return btoa(String.fromCharCode(...new Uint8Array(n))).replace(/\+/gu,"-").replace(/\//gu,"_").replace(/=/gu,"")}async function pln(e){let t=AbortSignal.timeout(oB),n=new URL(e),r=n.pathname==="/"?"/.well-known/oauth-protected-resource":`/.well-known/oauth-protected-resource${n.pathname}`,i=new URL(r,n.origin);B1(i.href);let s=await d_(i.href,{signal:t});if(!s.ok)throw new Error(`PRM discovery failed: HTTP ${s.status}`);let c=(await s.json()).authorization_servers?.[0];if(typeof c!="string")throw new Error("No authorization server in PRM");let l=new URL(c),u=l.pathname==="/"?"/.well-known/oauth-authorization-server":`/.well-known/oauth-authorization-server${l.pathname}`,d=new URL(u,l.origin);B1(d.href);let p=await d_(d.href,{signal:t});if(!p.ok)throw new Error(`AS metadata failed: HTTP ${p.status}`);let h=await p.json();if(typeof h.authorization_endpoint!="string"||typeof h.token_endpoint!="string")throw new Error("Missing required endpoints in AS metadata");return{authorization:h.authorization_endpoint,token:h.token_endpoint,registration:h.registration_endpoint}}async function hln(e,t,n){let r=AbortSignal.timeout(oB);B1(e);let i=await d_(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:n,redirect_uris:[t],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}),signal:r});if(!i.ok)throw new Error(`DCR failed: HTTP ${i.status}`);let s=await i.json();if(typeof s.client_id!="string")throw new Error("DCR response missing client_id");return{clientId:s.client_id,clientSecret:s.client_secret}}async function mln(e,t,n,r,i){let s=AQe(32),o=AQe(64),c=await dln(o),l=new URL(e.authorization);for(let[u,d]of Object.entries({response_type:"code",client_id:t.clientId,redirect_uri:n,state:s,code_challenge:c,code_challenge_method:"S256",resource:i}))l.searchParams.set(u,d);return{authorizationUrl:l.href,pendingFlow:{state:s,codeVerifier:o,redirectUri:n,serverName:r,serverUrl:i,stagedClient:t,createdAt:Date.now()}}}async function fln(e,t,n,r,i,s){let o=AbortSignal.timeout(oB),c=new URLSearchParams({grant_type:"authorization_code",code:n,redirect_uri:i,client_id:t.clientId,code_verifier:r});s!==void 0&&c.set("resource",s),t.clientSecret!==void 0&&c.set("client_secret",t.clientSecret),B1(e);let l=await d_(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:c.toString(),signal:o});if(!l.ok)throw new Error(`Token exchange failed: HTTP ${l.status}`);return IQe(await l.json())}async function gln(e,t,n,r){let i=AbortSignal.timeout(oB),s=new URLSearchParams({grant_type:"refresh_token",refresh_token:n,client_id:t.clientId});r!==void 0&&s.set("resource",r),t.clientSecret!==void 0&&s.set("client_secret",t.clientSecret),B1(e);let o=await d_(e,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:s.toString(),signal:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return IQe(await o.json())}function IQe(e){let t=e;if(typeof t.access_token!="string")throw new Error("Missing access_token");let n=typeof t.expires_in=="number"?t.expires_in:void 0;return{accessToken:t.access_token,refreshToken:typeof t.refresh_token=="string"?t.refresh_token:void 0,expiresAt:n!==void 0?Date.now()+n*1e3:void 0,tokenType:typeof t.token_type=="string"?t.token_type:"Bearer",scope:typeof t.scope=="string"?t.scope:void 0}}function yln(e){return e.expiresAt===void 0?!1:Date.now()>e.expiresAt-12e4}var oB,cB=j(()=>{"use strict";mO();oB=1e4;a(AQe,"randomString");a(dln,"sha256Base64Url");a(pln,"discoverEndpoints");a(hln,"registerClient");a(mln,"buildAuthorizationUrl");a(fln,"exchangeCode");a(gln,"refreshToken");a(IQe,"parseTokenResponse");a(yln,"isTokenExpired")});var wr,DQe,EI=j(()=>{dr();Fr();wr=class extends Li{static{a(this,"FsError")}code;constructor(e,t,n){super(e,t,n),this.code=t}},DQe=class extends Lt{static{a(this,"FileSystem")}constructor(e){super(e,"fs")}watch(e,t,n){return n.throwIfAborted(),Promise.reject(new wr("Filesystem watching is not supported by this provider.","FS_IO_ERROR"))}get sandboxMode(){}processPathFromHostPath(e){}}});function xO(e){return xB.test(e)}function bB(e){return e.invocation.modelInvocable}function AI(e){return e.invocation.userInvocable}function $0e(e){let t=tdn(e);return[`<skill_content name="${ndn(e.name)}">`,"<skill_resources>",...t,"</skill_resources>","","<skill_instructions>",e.content,"</skill_instructions>","</skill_content>"].join(`
|
|
168
168
|
`)}function tdn(e){let t=e.resourceBase;if(t===void 0)return[`Resources for this skill are managed by provider "${TI(e.provider)}".`,"Load referenced resources only as needed."];switch(t.kind){case"directory":return[`Base directory for this skill: ${TI(t.path)}`,"Resolve relative paths mentioned by this skill against the base directory before using them. Load referenced resources only as needed."];case"url":return[`Base URL for this skill: ${TI(t.url)}`,"Resolve relative URLs mentioned by this skill against the base URL before using them. Load referenced resources only as needed."];case"opaque":return[`Resources for this skill: ${TI(t.description)}`,"Load referenced resources only as needed."];default:return Ur(t,"SkillResourceBase.kind")}}function ndn(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}function TI(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function idn(e,t){if(Array.isArray(e))return{candidates:e,complete:!0};if(e===null||typeof e!="object")throw iJe(t);let n=e;if(!Array.isArray(n.candidates)||typeof n.complete!="boolean")throw iJe(t);return n}function iJe(e){return new TypeError(`skill provider "${e}" list() must return an array or { candidates, complete } observation`)}function odn(e){return{name:e.name,description:e.description,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},invocation:e.invocation,source:e.source,provider:e.provider,...e.resourceBase!==void 0?{resourceBase:e.resourceBase}:{},rank:edn,locator:e,...e.path!==void 0?{path:e.path}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}function adn(e,t){if(typeof e.name!="string")throw new TypeError(`skill provider "${t}" returned a non-string skill name`);if(!xB.test(e.name))throw new Error(`skill provider "${t}" returned invalid skill name "${e.name}"`);if(typeof e.description!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string description`);if(e.description.length===0)throw new Error(`skill provider "${t}" returned skill "${e.name}" without a description`);if(U0e(e.invocation,`skill provider "${t}" returned skill "${e.name}"`),e.whenToUse!==void 0&&typeof e.whenToUse!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string whenToUse`);if(typeof e.source!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string source`);if(typeof e.rank!="number"||!Number.isFinite(e.rank))throw new Error(`skill provider "${t}" returned skill "${e.name}" with an invalid rank`);if(typeof e.provider!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string provider`);if(e.provider!==t)throw new Error(`skill provider "${t}" returned skill "${e.name}" for provider "${e.provider}"`);if(e.path!==void 0&&typeof e.path!="string")throw new TypeError(`skill provider "${t}" returned skill "${e.name}" with a non-string path`)}function cdn(e){if(!xB.test(e.name))throw new Error(`invalid skill name "${e.name}"`);if(e.description.length===0)throw new Error(`skill "${e.name}" requires a description`);U0e(e.invocation,`runtime skill "${e.name}"`)}function ldn(e){let t=e.name,n=e.description,r=e.whenToUse,i=e.invocation,s=e.source,o=e.provider,c=e.content,l=e.path;if(typeof t!="string")throw new TypeError("loaded skill name must be a string");if(!xB.test(t))throw new Error(`loaded skill has invalid name "${t}"`);if(typeof n!="string")throw new TypeError(`loaded skill "${t}" description must be a string`);if(n.length===0)throw new Error(`loaded skill "${t}" requires a description`);if(U0e(i,`loaded skill "${t}"`),r!==void 0&&typeof r!="string")throw new TypeError(`loaded skill "${t}" whenToUse must be a string`);if(typeof s!="string")throw new TypeError(`loaded skill "${t}" source must be a string`);if(typeof o!="string")throw new TypeError(`loaded skill "${t}" provider must be a string`);if(typeof c!="string")throw new TypeError(`loaded skill "${t}" content must be a string`);if(l!==void 0&&typeof l!="string")throw new TypeError(`loaded skill "${t}" path must be a string`)}function udn(e){let{name:t,description:n,whenToUse:r,invocation:i,source:s,provider:o,resourceBase:c}=e;return{name:t,...e.path===void 0?{}:{path:e.path},description:n,...r!==void 0?{whenToUse:r}:{},invocation:i,source:s,provider:o,...c!==void 0?{resourceBase:c}:{}}}function U0e(e,t){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`${t} with a non-object invocation policy`);let n=e;if(typeof n.modelInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.modelInvocable`);if(typeof n.userInvocable!="boolean")throw new TypeError(`${t} with a non-boolean invocation.userInvocable`)}function ddn(e,t){return cJe(e.name,t.name)}function cJe(e,t){return e<t?-1:e>t?1:0}function pdn(e,t){return e.candidate.rank-t.candidate.rank||e.providerOrder-t.providerOrder||e.localOrder-t.localOrder}function hdn(e,t,n=1){if(!Number.isInteger(t)||t<n)throw new Error(`skill: ${e} must be an integer greater than or equal to ${n}`)}function sJe(e,t){return t===void 0?e:(vO(t),new Promise((n,r)=>{let i=a(()=>{t.removeEventListener("abort",s)},"cleanup"),s=a(()=>{i(),r(vB(t.reason))},"onAbort");t.addEventListener("abort",s,{once:!0}),e.then(o=>{i(),n(o)},o=>{i(),r(vB(o))})}))}function vO(e){if(e?.aborted===!0)throw vB(e.reason)}function vB(e){try{if(e instanceof Error)return e}catch{}return new Error(yB(e))}function yB(e){try{return String(e)}catch{return"[unrenderable thrown value]"}}var xB,rJe,Zun,gB,edn,oJe,rdn,aJe,sdn,h_=j(()=>{dr();fs();wu();Rn();xB=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,rJe=128,Zun=2,gB="runtime",edn=250,oJe=600;a(xO,"isSkillName");a(bB,"isModelInvocable");a(AI,"isUserInvocable");a($0e,"renderSkillContent");a(tdn,"renderResourceHint");a(ndn,"escapeAttr");a(TI,"escapeText");rdn=class{static{a(this,"SkillLayer")}providers;runtime=new Map;constructor(e){this.providers=new p0(t=>new Error(e===void 0?`a skill provider named "${t}" is already registered`:`a skill provider named "${t}" is already registered in this scope`))}isEmpty(){return this.providers.isEmpty()&&this.runtime.size===0}},aJe=class extends Lt{static{a(this,"SkillRegistry")}static Config=q.object({collectCacheMaxEntries:q.number().default(rJe)});collectCacheMaxEntries;layers=new h0(e=>new rdn(e),()=>{this.invalidateCache()});collectCache=new Map;revision=0;nextProviderOrder=0;scopeIds=new WeakMap;nextScopeId=1;constructor(e,t={}){super(e,"skills"),this.collectCacheMaxEntries=t.collectCacheMaxEntries??rJe,hdn("collectCacheMaxEntries",this.collectCacheMaxEntries)}registerProvider(e){let t=new AbortController,n,r,i={signal:t.signal,invalidate:a(()=>{let s=n;s!==void 0&&s.layer.providers.get(s.name)?.provider===r&&this.invalidateCache()},"invalidate")};try{r=e(i);let s=r.name;if(s===gB)throw new Error(`"${gB}" is reserved for runtime skill registrations`);let o=this.nextProviderOrder;return this.nextProviderOrder+=1,this.layers.effect(this.ctx,c=>{let l=c.providers.insert(s,{provider:r,order:o});return n={layer:c,name:s},()=>{n=void 0,l(),t.abort(new Error(`skill provider "${s}" disposed`))}},{label:"skills.registerProvider()"})}catch(s){throw t.abort(s),s}}register(e){cdn(e);let t=jl(this.ctx),n=t===void 0?this.layers.global:this.layers.peek(t);if(n!==void 0&&n.runtime.has(e.name))return this.ctx.logger.warn(`runtime skill "${e.name}" ignored because it is already registered`),()=>{};let r={...e,invocation:e.invocation??{modelInvocable:!0,userInvocable:!0},provider:e.provider??gB};return this.layers.effect(this.ctx,i=>(i.runtime.set(r.name,r),()=>{i.runtime.delete(r.name)}),{label:"skills.register()"})}async list(e={}){return(await this.snapshot(e)).skills}async snapshot(e={}){let t=await this.collect(e);return{skills:[...t.entries.values()].map(n=>udn(n.candidate)).sort(ddn),complete:t.cacheable}}async get(e,t={}){if(!xO(e))return;let n=await this.collect(t);vO(t.signal);let r=n.entries.get(e);if(r===void 0)return;let i=await sJe(r.provider.get(r.candidate,t),t.signal);if(i!==void 0){if(ldn(i),i.name!==r.candidate.name){this.invalidateEntry(r);return}return i}}async collect(e){vO(e.signal);let t=1;for(;;){let n=this.revision,r=this.collectCacheKey(e.cwd,q3(e.scope),n),i=this.collectCache.get(r);if(i!==void 0)return{entries:i,cacheable:!0};let s=await this.collectFresh(e);if(vO(e.signal),n!==this.revision){if(t<Zun){t+=1;continue}return{entries:s.entries,cacheable:!1}}if(s.cacheable&&(this.collectCache.set(r,s.entries),this.collectCache.size>this.collectCacheMaxEntries)){let o=this.collectCache.keys().next();this.collectCache.delete(o.value)}return s}}async collectFresh(e){let t=[this.layers.global,...this.layers.chainLayers(e.scope)],n=new Map,r=!0;for(let i of t){let s=await this.collectLayer(i,e);s.cacheable||(r=!1);for(let o of s.entries)n.set(o.candidate.name,o)}return{entries:n,cacheable:r}}async collectLayer(e,t){let n=await this.listLayerCandidates(e,t);n.entries.sort(pdn);let r=new Set,i=[];for(let s of n.entries){let o=s.candidate;if(r.has(o.name)){this.ctx.logger.warn(`skill "${o.name}" from ${o.source} ignored because a higher-priority skill already exists`);continue}r.add(o.name),i.push(s)}return{entries:i,cacheable:n.cacheable}}async listLayerCandidates(e,t){vO(t.signal);let n=[],r=!0,i=0;for(let s of[...e.runtime.values()].sort((o,c)=>cJe(o.name,c.name)))n.push({candidate:odn(s),provider:sdn,providerOrder:-1,localOrder:i,layer:e}),i+=1;for(let{provider:s,order:o}of[...e.providers.values()]){let c=0,l;try{l=await sJe(s.list(t),t.signal)}catch(d){if(t.signal?.aborted===!0)throw vB(t.signal.reason);r=!1,this.ctx.logger.warn(`skill provider "${s.name}" skipped: ${yB(d)}`)}if(l===void 0)continue;let u=idn(l,s.name);u.complete||(r=!1);for(let d of u.candidates)adn(d,s.name),n.push({candidate:d,provider:s,providerOrder:o,localOrder:c,layer:e}),c+=1}return{entries:n,cacheable:r}}invalidateCache(){this.revision+=1,this.collectCache.clear(),this.notifyChange()}invalidateEntry(e){e.layer.providers.get(e.provider.name)?.provider===e.provider&&this.invalidateCache()}scopeId(e){let t=this.scopeIds.get(e);return t===void 0&&(t=this.nextScopeId,this.nextScopeId+=1,this.scopeIds.set(e,t)),t}collectCacheKey(e,t,n){return JSON.stringify({cwd:e,scopes:t.map(r=>this.scopeId(r)),revision:n})}notifyChange(){for(let e of this.ctx.events.dispatch("emit",["skills/change"]))try{let t=e();Promise.resolve(t).catch(n=>{this.ctx.logger.warn(`skills/change listener rejected: ${yB(n)}`)})}catch(t){this.ctx.logger.warn(`skills/change listener threw: ${yB(t)}`)}}};a(idn,"normalizeProviderObservation");a(iJe,"invalidProviderObservation");sdn={name:gB,list(){return Promise.resolve([])},get(e){return Promise.resolve(e.locator)}};a(odn,"runtimeCandidate");a(adn,"validateCandidate");a(cdn,"validateRuntimeSkill");a(ldn,"validateDefinition");a(udn,"toSummary");a(U0e,"validateInvocation");a(ddn,"compareSkillSummary");a(cJe,"compareCodePoints");a(pdn,"compareIndexedCandidates");a(hdn,"assertPositiveInteger");a(sJe,"waitWithAbort");a(vO,"throwIfAborted");a(vB,"toError");a(yB,"errorMessage")});var mm,LI=j(()=>{mm=class{static{a(this,"Deque")}buffer=new Array(16);head=0;count=0;get size(){return this.count}pushBack(e){this.ensureCapacity();let t=this.head+this.count;this.buffer[t<this.buffer.length?t:t-this.buffer.length]=e,this.count+=1}pushFront(e){this.ensureCapacity(),this.head=this.head===0?this.buffer.length-1:this.head-1,this.buffer[this.head]=e,this.count+=1}popFront(){if(this.count===0)return;let e=this.buffer[this.head];return this.buffer[this.head]=void 0,this.head+=1,this.head===this.buffer.length&&(this.head=0),this.count-=1,this.compact(),e}clear(){this.buffer=new Array(16),this.head=0,this.count=0}ensureCapacity(){this.count<this.buffer.length||this.resize(this.buffer.length*2)}compact(){if(this.count===0){this.head=0;return}this.buffer.length>16&&this.count<=this.buffer.length/4&&this.resize(Math.max(16,this.buffer.length/2))}resize(e){let t=new Array(e),n=this.head;for(let r=0;r<this.count;r+=1)t[r]=this.buffer[n],n+=1,n===this.buffer.length&&(n=0);this.buffer=t,this.head=0}}});var K1,kXe,Gye=j(()=>{dr();K1=class extends Error{static{a(this,"DirectoryPickerError")}code;path;constructor(e,t,n){super(n),this.code=e,this.path=t,this.name="DirectoryPickerError"}},kXe=class extends Lt{static{a(this,"DirectoryPicker")}constructor(e){super(e,"directoryPicker")}}});var OG,Y1e,Ua,ig=j(()=>{OG=class{static{a(this,"FifoQueue")}incoming=[];outgoing=[];get length(){return this.incoming.length+this.outgoing.length}enqueue(t){this.incoming.push(t)}dequeue(){if(this.outgoing.length===0)for(;this.incoming.length>0;)this.outgoing.push(this.incoming.pop());return this.outgoing.pop()}},Y1e=class{static{a(this,"EventStream")}queue=new OG;waiting=new OG;done=!1;finalResultPromise;resolveFinalResult;isComplete;extractResult;constructor(t,n){this.isComplete=t,this.extractResult=n,this.finalResultPromise=new Promise(r=>{this.resolveFinalResult=r})}push(t){if(this.done)return;this.isComplete(t)&&(this.done=!0,this.resolveFinalResult(this.extractResult(t)));let n=this.waiting.dequeue();n?n({value:t,done:!1}):this.queue.enqueue(t)}end(t){for(this.done=!0,t!==void 0&&this.resolveFinalResult(t);this.waiting.length>0;)this.waiting.dequeue()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.dequeue();else{if(this.done)return;{let t=await new Promise(n=>this.waiting.enqueue(n));if(t.done)return;yield t.value}}}result(){return this.finalResultPromise}},Ua=class extends Y1e{static{a(this,"AssistantMessageEventStream")}#e=Date.now();#n=performance.now();constructor(){super(t=>t.type==="done"||t.type==="error",t=>{if(t.type==="done")return t.message;if(t.type==="error")return t.error;throw new Error("Unexpected event type for final result")})}push(t){t.type==="done"?this.#r(t.message):t.type==="error"&&this.#r(t.error),super.push(t)}end(t){t!==void 0&&this.#r(t),super.end(t)}#r(t){this.done||t.durationMs!==void 0||t.timestamp<this.#e||(t.durationMs=Math.max(0,Math.round(performance.now()-this.#n)))}}});function uvn(e,t,n){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:n}}function dvn(e){return typeof e.result=="function"}async function pvn(e,t){for await(let n of t)e.push(n);e.end(dvn(t)?await t.result():void 0)}function gm(e,t){let n=Date.now(),r=new Ua;return t().then(i=>pvn(r,i)).catch(i=>{let s=uvn(e,i,n);r.push({type:"error",reason:"error",error:s}),r.end(s)}),r}function Ic(e,t){let n={stream:a((r,i,s)=>gm(r,async()=>(await e()).stream(r,i,s)),"stream"),streamSimple:a((r,i,s)=>gm(r,async()=>(await e()).streamSimple(r,i,s)),"streamSimple")};return t?.fetchDeferred&&(n.fetchDeferred=(r,i,s)=>gm(r,async()=>{let o=await e();if(!o.fetchDeferred)throw new Error("API does not support deferred responses");return o.fetchDeferred(r,i,s)})),t?.cancelDeferred&&(n.cancelDeferred=async(r,i,s)=>{let o=await e();if(!o.cancelDeferred)throw new Error("API cannot cancel deferred responses");await o.cancelDeferred(r,i,s)}),n}var yh=j(()=>{ig();a(uvn,"createSetupErrorMessage");a(dvn,"hasResult");a(pvn,"forwardStream");a(gm,"lazyStream");a(Ic,"lazyApi")});function mvn(){return globalThis.process?.env}function ztt(){return{async env(e){let t=mvn()?.[e];return typeof t=="string"&&t.trim().length>0?t:void 0},async fileExists(e){try{let t=await Btt("node:fs/promises"),n=e;return n.startsWith("~")&&(n=(await Btt("node:os")).homedir()+n.slice(1)),await t.access(n),!0}catch{return!1}}}}var hvn,Btt,Htt=j(()=>{hvn=function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,i,s,o){return r?t?".jsx":".js":i&&(!s||!o)?n:i+s+"."+o.toLowerCase()+"js"}):e},Btt=a(e=>import(hvn(e)),"importNodeModule");a(mvn,"getProcessEnv");a(ztt,"defaultProviderAuthContext")});function Gtt(e){if(e.reason!==void 0)return e.reason;let t=new Error("The operation was aborted");return t.name="AbortError",t}function ym(e){return e??new AbortController().signal}function vm(e,t){return t.aborted?(e.catch(()=>{}),Promise.reject(Gtt(t))):new Promise((n,r)=>{let i=!1,s=a(()=>t.removeEventListener("abort",o),"cleanup"),o=a(()=>{i||(i=!0,s(),r(Gtt(t)))},"onAbort");t.addEventListener("abort",o,{once:!0}),e.then(c=>{i||(i=!0,s(),n(c))},c=>{i||(i=!0,s(),r(c))}),t.aborted&&o()})}var MG=j(()=>{a(Gtt,"abortReason");a(ym,"operationSignal");a(vm,"raceWithAbortSignal")});var NG,Vtt=j(()=>{MG();NG=class{static{a(this,"InMemoryCredentialStore")}credentials=new Map;chains=new Map;enqueue(t,n,r){let i=ym(r?.signal),s=this.chains.get(t)??Promise.resolve(),o=(async()=>(await s.catch(()=>{}),i.throwIfAborted(),n()))(),c=o.catch(()=>{});return this.chains.set(t,c),c.then(()=>{this.chains.get(t)===c&&this.chains.delete(t)}),vm(o,i)}async read(t,n){return n?.signal?.throwIfAborted(),this.credentials.get(t)}async list(t){return t?.signal?.throwIfAborted(),[...this.credentials].map(([n,r])=>({providerId:n,type:r.type}))}modify(t,n,r){return this.enqueue(t,async()=>{let i=this.credentials.get(t),s=await n(i);return r?.signal?.throwIfAborted(),s!==void 0&&this.credentials.set(t,s),s??i},r)}delete(t,n){return this.enqueue(t,async()=>{this.credentials.delete(t)},n)}}});function $b(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:String(e)}function fvn(e){if(!(e instanceof Error))return{name:"ThrownValue",message:$b(e)};let t=e.code;return{name:e.name||void 0,message:e.message||e.name,stack:e.stack,code:typeof t=="string"||typeof t=="number"?t:void 0}}function LG(e,t,n){return{type:e,timestamp:Date.now(),error:fvn(t),details:n}}function Ub(e,t){e.diagnostics=[...e.diagnostics??[],t]}var iM=j(()=>{a($b,"formatThrownValue");a(fvn,"extractDiagnosticError");a(LG,"createAssistantMessageDiagnostic");a(Ub,"appendAssistantMessageDiagnostic")});function gvn(e,t){if(t==null)return e;let n=$b(t).trim();return!n||e.includes(n)?e:`${e}: ${n}`}var rs,DG=j(()=>{iM();rs=class extends Error{static{a(this,"ModelsError")}code;constructor(t,n,r){super(gvn(n,r?.cause),r),this.name="ModelsError",this.code=t}};a(gvn,"withCauseDetail")});function Z1e(e,t,n,r){let i=ym(r?.signal);return vm(yvn(e,t,n,r,i),i)}async function yvn(e,t,n,r,i){i.throwIfAborted();let s=r?.env?vvn(n,r.env):n;if(r?.apiKey!==void 0&&e.auth.apiKey)return X1e(s,e.auth.apiKey,e.id,{type:"api_key",key:r.apiKey,env:r.env},i);let o=await kvn(t,e.id,i);if(o){if(o.type==="oauth"&&e.auth.oauth)return wvn(t,e.id,e.auth.oauth,o,i,r?.minOAuthValidityMs);if(o.type==="api_key"&&e.auth.apiKey){let c=r?.env?{...o,env:{...o.env,...r.env}}:o;return X1e(s,e.auth.apiKey,e.id,c,i)}return}return e.auth.apiKey?X1e(s,e.auth.apiKey,e.id,void 0,i):void 0}function vvn(e,t){return{env:a(async n=>t[n]||await e.env(n),"env"),fileExists:a(n=>e.fileExists(n),"fileExists")}}async function eve(e,t,n,r,i){let s,o=new AbortController,c=a(()=>o.abort(i.reason),"cancelLockWait");i.addEventListener("abort",c,{once:!0}),i.aborted&&c();try{s=await e.modify(t,async l=>{if(i.removeEventListener("abort",c),i.throwIfAborted(),l?.type==="oauth"&&r(l))try{return await n.refresh(l,AbortSignal.timeout(bvn))}catch(u){throw new rs("oauth",`OAuth refresh failed for ${t}`,{cause:u})}},{signal:o.signal})}catch(l){throw l instanceof rs?l:(i.throwIfAborted(),new rs("auth",`Credential store modify failed for ${t}`,{cause:l}))}finally{i.removeEventListener("abort",c)}return s?.type==="oauth"?s:void 0}async function wvn(e,t,n,r,i,s){let o=Math.max(xvn,s??0),c=a(u=>Date.now()+o>=u.expires,"expiresSoon"),l=r;if(c(l)){let u=await eve(e,t,n,c,i);if(!u)return;if(l=u,s!==void 0&&c(l))throw new rs("oauth",`OAuth refresh returned a token that expires too soon for ${t}`)}try{return{auth:await n.toAuth(l),source:"OAuth"}}catch(u){throw new rs("oauth",`OAuth auth derivation failed for ${t}`,{cause:u})}}async function X1e(e,t,n,r,i){try{return await t.resolve({ctx:e,credential:r,signal:i})}catch(s){throw new rs("auth",`API key auth failed for provider ${n}`,{cause:s})}}async function kvn(e,t,n){try{return await e.read(t,{signal:n})}catch(r){throw new rs("auth",`Credential store read failed for ${t}`,{cause:r})}}var xvn,bvn,Ktt=j(()=>{MG();DG();DG();a(Z1e,"resolveProviderAuth");a(yvn,"resolveProviderAuthWithSignal");a(vvn,"overlayEnvAuthContext");xvn=300*1e3,bvn=15e3;a(eve,"refreshStoredOAuthCredential");a(wvn,"resolveStoredOAuth");a(X1e,"resolveApiKey");a(kvn,"readCredential")});var $G,Qtt=j(()=>{$G=class{static{a(this,"InMemoryModelsStore")}entries=new Map;async read(t,n){n?.signal?.throwIfAborted();let r=this.entries.get(t);return r?structuredClone(r):void 0}async write(t,n,r){r?.signal?.throwIfAborted(),this.entries.set(t,structuredClone(n))}async delete(t,n){n?.signal?.throwIfAborted(),this.entries.delete(t)}}});function e6(e){return e.type??"chat"}function sg(e,t){return e6(e)===t}function Jtt(e){if(!sg(e,"chat"))throw new rs("provider",`Model ${e.provider}/${e.id} is not a chat model`)}function Ytt(e){if(!sg(e,"image"))throw new rs("provider",`Model ${e.provider}/${e.id} is not an image model`)}function Xtt(e){if(!sg(e,"classifier"))throw new rs("provider",`Model ${e.provider}/${e.id} is not a classifier model`)}function Ztt(e,t){if(t.images?.length&&!e.input.includes("image"))throw new rs("provider",`Model ${e.provider}/${e.id} does not accept image input`)}function tve(e,t,n=!1){return{api:e.api,provider:e.provider,model:e.id,output:[],stopReason:n?"aborted":"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function nve(e,t,n=!1){return{api:e.api,provider:e.provider,model:e.id,answers:{},stopReason:n?"aborted":"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}var rve=j(()=>{DG();a(e6,"getModelType");a(sg,"isModelType");a(Jtt,"assertChatModel");a(Ytt,"assertImageModel");a(Xtt,"assertClassifierModel");a(Ztt,"assertClassifierInputSupported");a(tve,"imageErrorResult");a(nve,"classifierErrorResult")});function UG(e,t=`
|
|
169
169
|
`){return typeof e=="string"?e:e.filter(n=>n.type==="text").map(n=>n.text).join(t)}function Zl(e){let t=[UG(e.content)];for(let n of Object.values(e.sections??{}))n!==null&&t.push(n);return t.filter(n=>n.length>0).join(`
|
|
170
170
|
|
|
@@ -6698,7 +6698,7 @@ ${hXe}
|
|
|
6698
6698
|
The previews above omit projected conversation text. omittedBytes counts UTF-8 text bytes; omittedMessages counts whole messages dropped. Full snapshots remain untrusted background information.
|
|
6699
6699
|
`+Bye(f));return{content:l,additionalContext:Qn({source:{kind:"session-reference",form:"recall",version:1,references:h.map((v,x)=>({sessionId:v.data.sessionId,label:v.data.label,capturedFormatVersion:v.capturedFormatVersion,capturedThroughSeq:v.data.capturedThroughSeq,...v.stats,inputIndex:x}))},content:[{type:"text",text:g}]})}}async referenceBudget(i,s){if(this.config.maxReferenceBytes!==void 0)return this.config.maxReferenceBytes;let{provider:o,model:c}=this.assembledRoutes.get(i)??i.options,l=this.ctx.get("llm");if(o===void 0||c===void 0||l===void 0)return XB;let u;try{u=await ZB(l.resolveModelInfo(o,c,s),s)}catch(d){if(!(d instanceof xt)||d.code!=="NO_ADAPTER")throw d;return XB}return u.context===void 0?XB:Math.max(XB,Math.floor(u.context.contextWindow*4*this.config.referenceContextFraction))}renderSources(i,s){let o=[];for(let c of i){let l=ugn(c.snapshot,c.input.label,s);if(l===void 0)throw new fh("referenced session snapshot cannot fit the configured byte budget","SESSION_REFERENCE_BUDGET_EXCEEDED");o.push({...l,capturedFormatVersion:c.snapshot.session.version})}return o}}})();function kgn(e,t,n){let r=new Set,i=[];for(let s of t){if(typeof s!="object"||s===null)throw new fh("session reference must be an object","SESSION_REFERENCE_INVALID_REFERENCE");let o=s;if(typeof o.sessionId!="string"||o.label!==void 0&&typeof o.label!="string")throw new fh("session reference must contain a string sessionId and optional string label","SESSION_REFERENCE_INVALID_REFERENCE");if(o.sessionId===e)throw new fh(`session ${JSON.stringify(e)} cannot reference itself`,"SESSION_REFERENCE_SELF_REFERENCE");r.has(o.sessionId)||(r.add(o.sessionId),i.push({sessionId:o.sessionId,label:o.label??o.sessionId}))}if(i.length>n)throw new fh(`a message may reference at most ${n} sessions`,"SESSION_REFERENCE_TOO_MANY");return i}a(kgn,"normalizeReferences");function _gn(e){return`${bgn}${Bye(e)}${wgn}`}a(_gn,"renderPrompt");function Sgn(e){let t=e?.values.title;return t??void 0}a(Sgn,"titleOf");function pXe(e,t){return e!==void 0&&t!==void 0&&e===t?0:e===void 0?1:2}a(pXe,"candidateRank");function MO(e){if(e?.aborted===!0)throw zye(e)}a(MO,"assertNotCancelled");function ZB(e,t){return t===void 0?e:new Promise((n,r)=>{let i=a(()=>{r(zye(t))},"onAbort");t.addEventListener("abort",i,{once:!0}),e.then(s=>{t.removeEventListener("abort",i),n(s)},s=>{t.removeEventListener("abort",i),r(s instanceof Error?s:new Error(String(s)))}),t.aborted&&i()})}a(ZB,"settleWithCancellation");function zye(e){return new fh("session reference preparation was cancelled","SESSION_REFERENCE_CANCELLED",{cause:e.reason})}a(zye,"cancelled");EI();import{AsyncLocalStorage as Egn}from"node:async_hooks";function Hye(e,t){return t.startsWith("/")?gXe(t):gXe(`${e}/${t}`)}a(Hye,"resolvePath");function gXe(e){let t=[];for(let n of e.split("/"))if(!(n===""||n===".")){if(n===".."){t.pop();continue}t.push(n)}return`/${t.join("/")}`}a(gXe,"normalizePath");function Rb(e){return e.replace(/\r\n/g,`
|
|
6700
6700
|
`).replace(/\r/g,`
|
|
6701
|
-
`)}a(Rb,"normalizeLineEndings");function x_(e,t){return`${String(e)}:${String(t)}`}a(x_,"versionOf");async function yXe(e,t){let{mtime:n}=await e.stat(t);for(;Date.now()<=n;)await new Promise(r=>setTimeout(r,1))}a(yXe,"waitPastModification");function vXe(e){return e.isFile?"file":e.isDirectory?"directory":"other"}a(vXe,"entryType");function Tgn(e){return e.isSymbolicLink?"symlink":e.isFile?"file":e.isDirectory?"directory":"other"}a(Tgn,"pathType");var ez=class e extends DQe{static{a(this,"EdgeFileSystem")}static storage=new Egn;locks=new Map;constructor(t){super(t)}bind(t,n){return()=>{}}runInScope(t,n,r){return e.storage.run({vfs:t,cwd:n},r)}searchScope(){return this.requireBinding()}requireBinding(){let t=e.storage.getStore();if(t===void 0)throw new wr("File operations are only available during an active turn.","FS_IO_ERROR");return t}get sandboxMode(){}async resolve(t,n){if(n?.signal?.aborted)throw new wr("resolve aborted","FS_ABORTED");if(t.trim().length===0)throw new wr("file_path must be a non-empty string","FS_NOT_FOUND");let r=this.requireBinding(),i=Hye(n?.cwd??r.cwd,t);return{targetKey:i,displayPath:i}}processPath(t){return String(t.targetKey)}fileUrl(t){return`file://${this.processPath(t)}`}async watch(t,n,r){if(r.aborted)throw new wr("watch aborted","FS_ABORTED");let i=this.processPath(t),s=this.ctx.on("fs/observed",o=>{let c=this.processPath(o);(c===i||(c.slice(0,c.lastIndexOf("/"))||"/")===i)&&n()});return async()=>{s()}}contains(t,n){let r=this.processPath(t),i=this.processPath(n);return i===r||i.startsWith(`${r}/`)}async stat(t,n){if(n?.aborted)throw new wr("stat aborted","FS_ABORTED");let r=this.requireBinding(),i=r.vfs;try{let s=await i.stat(this.processPath(t));return{version:x_(s.mtime,s.size),type:vXe(s),size:s.size}}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ENOENT")return this.processPath(t)===Hye(r.cwd,".")?{version:x_(0,0),type:"directory",size:0}:void 0;throw new wr(`cannot stat "${t.displayPath}":${s instanceof Error?s.message:String(s)}`,"FS_IO_ERROR",{cause:s})}}async lstat(t,n,r){if(r?.aborted)throw new wr("lstat aborted","FS_ABORTED");if(t.trim().length===0)throw new wr("file_path must be a non-empty string","FS_NOT_FOUND");let i=this.requireBinding(),s=Hye(n?.cwd??i.cwd,t),o=i.vfs;try{let c=await o.lstat(s);return{version:x_(c.mtime,c.size),type:Tgn(c),size:c.size}}catch(c){if(c instanceof Error&&"code"in c&&c.code==="ENOENT")return;throw new wr(`cannot lstat "${t}": ${c instanceof Error?c.message:String(c)}`,"FS_IO_ERROR",{cause:c})}}async readText(t,n){if(n?.aborted)throw new wr("readText aborted","FS_ABORTED");let r=this.requireBinding().vfs,i=this.processPath(t);try{let s=await r.readFile(i,"utf8"),o=await r.stat(i),c=x_(o.mtime,o.size);return this.ctx.emit("fs/observed",t,{kind:"present",version:c},void 0),Rb(s)}catch(s){throw new wr(`cannot read "${t.displayPath}": ${s instanceof Error?s.message:String(s)}`,"FS_IO_ERROR",{cause:s})}}async openReadStream(t,n){let r=a(s=>{throw s instanceof wr||n?.aborted&&s===n.reason||s instanceof Error&&s.name==="AbortError"?s:new wr(`cannot read "${t.displayPath}": ${s instanceof Error?s.message:String(s)}`,"FS_IO_ERROR",{cause:s})},"classify"),i;try{i=(await this.requireBinding().vfs.readFile(this.processPath(t))).getReader()}catch(s){return r(s)}return{async read(){n?.throwIfAborted();try{return await i.read()}catch(s){return r(s)}},async close(s){try{await i.cancel()}catch(o){s||r(o)}finally{i.releaseLock()}}}}async streamText(t,n){n?.throwIfAborted();let r=await this.openReadStream(t,n);return(async function*(){let i=new TextDecoder("utf-8",{fatal:!0}),s="",o=!1;try{for(;;){n?.throwIfAborted();let{done:l,value:u}=await r.read();if(l)break;let d=s+i.decode(u,{stream:!0});if(d.includes("\0"))throw new wr("File is not text.","FS_NOT_TEXT");s=d.endsWith("\r")?"\r":"",yield Rb(s===""?d:d.slice(0,-1))}let c=s+i.decode();c!==""&&(yield Rb(c))}catch(c){throw o=!0,n?.aborted&&c===n.reason?c:c instanceof TypeError?new wr("File is not valid UTF-8 text.","FS_NOT_TEXT",{cause:c}):c}finally{await r.close(o)}})()}async readByteRange(t,n,r){r?.throwIfAborted();let i=await this.openReadStream(t,r),s=[],o=0,c=0,l=!1;try{for(;c<n.length;){r?.throwIfAborted();let{done:p,value:h}=await i.read();if(p)break;let m=Math.min(h.byteLength,Math.max(0,n.offset-o));o+=h.byteLength;let f=h.subarray(m,Math.min(h.byteLength,m+n.length-c));f.byteLength>0&&(s.push(f.slice()),c+=f.byteLength)}let u=new Uint8Array(c),d=0;for(let p of s)u.set(p,d),d+=p.byteLength;return u}catch(u){throw l=!0,u}finally{await i.close(l)}}async readBytes(t,n,r){if(n?.aborted)throw new wr("readBytes aborted","FS_ABORTED");let i=this.requireBinding().vfs,s=this.processPath(t);try{let c=(await i.readFile(s)).getReader(),l=[],u=0;for(;;){let{done:h,value:m}=await c.read();if(h)break;if(u+=m.byteLength,u>r)throw await c.cancel(),new wr(`"${t.displayPath}" exceeds the ${String(r)}-byte read limit`,"FS_TOO_LARGE");l.push(m)}let d=new Uint8Array(u),p=0;for(let h of l)d.set(h,p),p+=h.byteLength;return d}catch(o){throw o instanceof wr?o:new wr(`cannot read "${t.displayPath}": ${o instanceof Error?o.message:String(o)}`,"FS_IO_ERROR",{cause:o})}}async listDir(t,n){if(n?.aborted)throw new wr("listDir aborted","FS_ABORTED");let r=this.requireBinding().vfs,i=this.processPath(t);try{return(await r.readdir(i)).map(o=>({name:o.name,type:vXe(o),target:{targetKey:`${i}/${o.name}`,displayPath:`${i}/${o.name}`},version:x_(o.mtime,o.size),size:o.size}))}catch(s){throw new wr(`cannot list "${t.displayPath}": ${s instanceof Error?s.message:String(s)}`,"FS_NOT_DIRECTORY",{cause:s})}}writeText(t,n,r,i){return this.withLock(t.targetKey,()=>this.writeTextLocked(t,n,r,i))}async writeTextLocked(t,n,r,i){if(i?.aborted)throw new wr("writeText aborted","FS_ABORTED");let s=this.requireBinding().vfs,o=this.processPath(t),c=await this.stat(t);if(c!==void 0&&c.type!=="file")throw new wr(`cannot write "${t.displayPath}": not a regular file`,"FS_NOT_REGULAR_FILE");if(r?.kind==="replaceIfVersion"){if(c===void 0)throw new wr(`cannot write "${t.displayPath}": file no longer exists`,"FS_STALE_VERSION");if(c.version!==r.version)throw new wr(`cannot write "${t.displayPath}": file changed since it was read`,"FS_STALE_VERSION")}else if(r?.kind==="createIfAbsent"&&c!==void 0)throw new wr(`cannot overwrite existing "${t.displayPath}" without reading it first`,"FS_NOT_OBSERVED");let l=null;if(c!==void 0)try{l=Rb(await s.readFile(o,"utf8"))}catch{}let u=o.substring(0,o.lastIndexOf("/"))||"/";try{await s.mkdir(u,{recursive:!0})}catch{}c!==void 0&&await yXe(s,o),await s.writeFile(o,n);let p=(await this.stat(t))?.version??x_(Date.now(),n.length);return this.ctx.emit("fs/observed",t,{kind:"present",version:p},void 0),{operation:c!==void 0?"update":"create",version:p,before:l,after:Rb(n)}}editText(t,n,r,i){return this.withLock(t.targetKey,()=>this.editTextLocked(t,n,r,i))}async editTextLocked(t,n,r,i){if(i?.aborted)throw new wr("editText aborted","FS_ABORTED");let s=this.requireBinding().vfs,o=this.processPath(t),c=await this.stat(t);if(c===void 0)throw new wr(`cannot edit "${t.displayPath}": file not found`,"FS_STALE_VERSION");if(c.type!=="file")throw new wr(`cannot edit "${t.displayPath}": not a regular file`,"FS_NOT_REGULAR_FILE");if(r!==void 0&&c.version!==r.version)throw new wr(`cannot edit "${t.displayPath}": file changed since it was read`,"FS_STALE_VERSION");let l=Rb(await s.readFile(o,"utf8")),u=Rb(n.oldString);if(u.length===0)throw new wr("old_string must be a non-empty string","FS_EDIT_NOT_FOUND");let d=l.split(u).length-1;if(d===0)throw new wr(`old_string was not found in "${t.displayPath}"`,"FS_EDIT_NOT_FOUND");if(!n.replaceAll&&d>1)throw new wr(`old_string matched ${String(d)} times in "${t.displayPath}"; provide a more specific old_string or set replace_all to true`,"FS_AMBIGUOUS_EDIT");let p=Rb(n.newString),h=l.split(u).join(p);await yXe(s,o),await s.writeFile(o,h);let f=(await this.stat(t))?.version??x_(Date.now(),h.length);return this.ctx.emit("fs/observed",t,{kind:"present",version:f},void 0),{version:f,before:l,after:h}}async withLock(t,n){let r=(this.locks.get(t)??Promise.resolve()).then(n,n),i=r.then(()=>{},()=>{});this.locks.set(t,i);try{return await r}finally{this.locks.get(t)===i&&this.locks.delete(t)}}};dr();var xXe='Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @"..." quotes a path containing spaces.',bXe=class extends Lt{static{a(this,"FileReferenceService")}constructor(e){super(e,"fileReferences")}};var Agn=20,Ign="/workspace",tz=class extends bXe{static{a(this,"EdgeFileReferenceService")}withFiles;maxResults;constructor(t,n){if(super(t),this.withFiles=r=>n.withFiles(r),this.maxResults=n.maxResults??Agn,!Number.isSafeInteger(this.maxResults)||this.maxResults<=0)throw new Error("dsh-edge: file reference maxResults must be a positive safe integer");t.inject(["systemPrompt"],r=>{r.systemPrompt.section({name:"context:file-reference",order:r.systemPrompt.getSectionOrder("FILE_REFERENCE"),text:xXe})})}async list(t,n,r){r.throwIfAborted();let i=this.ctx.get("workingDirectory")?.get(t.session)??t.session.header.cwd??Ign,s=Rgn(n);if(s===void 0)return[];let o=Cgn(i,s.directory);if(o===void 0)return[];let c;try{c=await this.withFiles(l=>l.readdir(o))}catch{return r.throwIfAborted(),[]}return r.throwIfAborted(),Pgn(c,s,this.maxResults)}};function Rgn(e){let t=e.replaceAll("\\","/");for(let r of t){let i=r.codePointAt(0)??0;if(i<32||i===127||r==='"')return}let n=t.lastIndexOf("/");return n<0?{directory:"",fragment:t}:{directory:t.slice(0,n+1),fragment:t.slice(n+1)}}a(Rgn,"splitQuery");function Cgn(e,t){let n=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."){if(n.length===0)return;n.pop();continue}n.push(i)}let r=e.endsWith("/")?e.slice(0,-1):e;return n.length===0?r===""?"/":r:`${r}/${n.join("/")}`}a(Cgn,"resolveWithin");function Pgn(e,t,n){let r=t.fragment.toLowerCase(),i=[];for(let s of e){if(s.name.startsWith(".")&&!t.fragment.startsWith("."))continue;let o=s.isDirectory?"directory":s.isFile?"file":void 0;if(o===void 0)continue;let c=Ogn(s.name.toLowerCase(),r,o);c!==void 0&&i.push({candidate:{path:`${t.directory}${s.name}`,kind:o},score:c})}return i.sort((s,o)=>o.score-s.score||wXe(s.candidate.kind)-wXe(o.candidate.kind)||Mgn(s.candidate.path,o.candidate.path)),i.slice(0,n).map(s=>s.candidate)}a(Pgn,"rankCandidates");function Ogn(e,t,n){let r=n==="directory"?25:0;if(t==="")return r;if(e===t)return 1e3+r;if(e.startsWith(t))return 900+r;if(e.includes(t))return 700+r}a(Ogn,"scoreName");function wXe(e){return e==="directory"?0:1}a(wXe,"kindRank");function Mgn(e,t){return e<t?-1:e>t?1:0}a(Mgn,"compareText");Gye();var Ngn="/workspace",Lgn=1e3,nz=class extends kXe{static{a(this,"EdgeDirectoryPicker")}withFiles;root;maxEntries;browseCapability={kind:"browse",list:a((t,n)=>this.list(t,n),"list"),createDirectory:a((t,n)=>this.createDirectory(t,n),"createDirectory")};constructor(t,n){if(super(t),this.withFiles=r=>n.withFiles(r),this.root=$gn(n.root??Ngn),this.maxEntries=n.maxEntries??Lgn,!Number.isSafeInteger(this.maxEntries)||this.maxEntries<=0)throw new Error("dsh-edge: directory picker maxEntries must be a positive safe integer")}capability(){return this.browseCapability}async list(t,n){n?.throwIfAborted();let r=t===void 0?this.root:Vye(this.root,t);if(r===void 0)throw new K1("directory-unreadable",t??this.root,`cannot list "${t??""}": not an absolute path under ${this.root}`);let i;try{i=await this.withFiles(l=>l.readdir(r))}catch(l){if(n?.throwIfAborted(),r===this.root&&_Xe(l))i=[];else throw new K1("directory-unreadable",r,`cannot list ${r}: ${SXe(l)}`)}n?.throwIfAborted();let s=i.filter(l=>l.isDirectory).map(l=>l.name).sort((l,u)=>l.localeCompare(u)),o=s.length>this.maxEntries,c=s.slice(0,this.maxEntries).map(l=>({name:l,path:`${r==="/"?"":r}/${l}`,hidden:l.startsWith(".")}));return{path:r,home:this.root,crumbs:Dgn(this.root,r),entries:c,truncated:o}}async createDirectory(t,n){let r=Vye(this.root,t);if(r===void 0)throw new K1("directory-create-failed",t,`cannot create under "${t}": not an absolute path under ${this.root}`);if(!Ugn(n))throw new K1("directory-create-failed",`${r==="/"?"":r}/${n}`,`"${n}" is not a single path segment`);let i=`${r==="/"?"":r}/${n}`,s=!1;try{if(s=await this.withFiles(async o=>{try{return await o.stat(i),!0}catch(c){if(_Xe(c))return!1;throw c}}),!s)return await this.withFiles(async o=>{r===this.root&&await o.mkdir(this.root,{recursive:!0}),await o.mkdir(i)}),i}catch(o){throw new K1("directory-create-failed",i,`cannot create ${i}: ${SXe(o)}`)}throw new K1("directory-exists",i,`${i} already exists`)}};function Vye(e,t){if(!t.startsWith("/")||EXe(t))return;let n=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."){if(n.length===0)return;n.pop();continue}n.push(i)}let r=n.length===0?"/":`/${n.join("/")}`;if(!(r!==e&&!r.startsWith(e==="/"?"/":`${e}/`)))return r}a(Vye,"resolveWithinRoot");function Dgn(e,t){let n=[{name:e,path:e,hidden:!1}];if(t===e)return n;let r=t.slice(e==="/"?1:e.length+1),i=e==="/"?"":e;for(let s of r.split("/"))i=`${i}/${s}`,n.push({name:s,path:i,hidden:!1});return n}a(Dgn,"directoryCrumbs");function $gn(e){let t=Vye("/",e);if(t===void 0)throw new Error("dsh-edge: directory picker root must be an absolute path");return t}a($gn,"normalizeRoot");function Ugn(e){return e.trim()!==""&&e!=="."&&e!==".."&&!/[/\\]/u.test(e)&&!EXe(e)}a(Ugn,"isSingleSegment");function EXe(e){for(let t of e){let n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}a(EXe,"hasControlCharacter");function _Xe(e){return e instanceof Error&&"code"in e&&e.code==="ENOENT"}a(_Xe,"isNotFound");function SXe(e){return e instanceof Error?e.message:String(e)}a(SXe,"messageOf");dr();var TXe=[{id:"@deepseek-ai/dsh-typert-registry",inject:[],immediately:!0},{id:"@deepseek-ai/dsh-api-gateway",inject:["@deepseek-ai/dsh-typert-registry","@deepseek-ai/dsh-client-connection"],immediately:!0},{id:"@deepseek-ai/dsh-api-remote-access",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-ui-renderer"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-client-ui-open-in-app",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-sidebar-documentpreview"]},{id:"@deepseek-ai/dsh-api-session-controller",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-file-upload"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-api-job-controller",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-connection"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-api-workspace-files",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-resources"]},{id:"@deepseek-ai/dsh-api-workspace-controller",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-connection"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-client-modules",inject:[],immediately:!0},{id:"@deepseek-ai/dsh-client-connection",inject:[],immediately:!0},{id:"@deepseek-ai/dsh-client-file-upload",inject:["@deepseek-ai/dsh-api-remotes"],immediately:!0},{id:"@deepseek-ai/dsh-api-remotes",inject:["@deepseek-ai/dsh-api-gateway"],immediately:!0},{id:"@deepseek-ai/dsh-client-ui-theme",inject:["@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-api-remotes"],immediately:!0},{id:"@deepseek-ai/dsh-client-locale",inject:["@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-api-remotes"],immediately:!0},{id:"@deepseek-ai/dsh-client-shortcuts",inject:["@deepseek-ai/dsh-client-locale"]},{id:"@deepseek-ai/dsh-client-ui-shortcuts",inject:["@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-layout",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-theme","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-renderer",immediately:!0},{id:"@deepseek-ai/dsh-client-ui-session",inject:["@deepseek-ai/dsh-api-remote-access","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-resources",inject:["@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-ui-sidebar",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-right",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-documentpreview",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-api-workspace-files","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-browser",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-files",inject:["@deepseek-ai/dsh-api-workspace-files","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-settings",inject:["@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-general",inject:["@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-sidebar","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-modules","@deepseek-ai/dsh-client-ui-layout"]},{id:"@deepseek-ai/dsh-client-ui-settings-models",inject:["@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-plugin-inventory",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-agent-preset","@deepseek-ai/dsh-client-modules"]},{id:"@deepseek-ai/dsh-client-ui-conversation",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-file-upload","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-approval",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-chat",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-brand-official",inject:["@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-sidebar"]},{id:"@deepseek-ai/dsh-client-ui-attachment",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-trajectory","@deepseek-ai/dsh-client-ui-tool"]},{id:"@deepseek-ai/dsh-client-ui-tool",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation"]},{id:"@deepseek-ai/dsh-client-ui-deliverables",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-tool","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-workspace",inject:["@deepseek-ai/dsh-api-remote-access","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-sidebar"]},{id:"@deepseek-ai/dsh-client-ui-workflow-run",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-input-trigger",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-ui-commands",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-conversation"]},{id:"@deepseek-ai/dsh-client-ui-skill",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-tool","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-sidebar-right"]},{id:"@deepseek-ai/dsh-client-ui-subagent",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-primitives","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-reference",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-sidebar-right"]},{id:"@deepseek-ai/dsh-client-ui-secret-mask",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-ui-jobs",inject:["@deepseek-ai/dsh-api-job-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-primitives"]},{id:"@deepseek-ai/dsh-client-ui-schedule",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-sidebar","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-tool","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-client-ui-primitives"]},{id:"@deepseek-ai/dsh-client-ui-goal",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-message-feedback",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-commands"]},{id:"@deepseek-ai/dsh-client-ui-model-selection",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-commands","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-deepseek-model-label-1017",inject:["@deepseek-ai/dsh-client-ui-model-selection","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-locale"]},{id:"@deepseek-ai/dsh-client-ui-agent-preset",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-plugins",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-settings-agent-loop",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings","dsh-edge-client-ui"]},{id:"@deepseek-ai/dsh-client-ui-settings-subagent",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings","dsh-edge-client-ui","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-web-search",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings","dsh-edge-client-ui","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-plan",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-user-questions","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-api-session-controller"]},{id:"@deepseek-ai/dsh-client-ui-user-questions",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-chat"]},{id:"@deepseek-ai/dsh-client-ui-trajectory",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-directory-picker-browse",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-client-locale"]},{id:"dsh-edge-client-ui",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings-plugins"]}];var AXe={tree:{ctx:{baseUrl:void 0}}},jgn="host:",qgn="web:",Wgn=2,rz=class extends Lt{static{a(this,"EdgeLoader")}constructor(t){super(t,"loader")}*entries(){let t=new Map;for(let[,n]of this.ctx.registry.entries()){let r=n.name;if(r===void 0||r==="")continue;let i=(t.get(r)??0)+1;t.set(r,i);let s=Bgn(n);yield{id:`${jgn}${r}${i===1?"":`#${String(i)}`}`,options:{name:r},disabled:!1,parent:AXe,...s===void 0?{}:{fiber:s}}}for(let n of TXe)yield{id:`${qgn}${n.id}`,options:{name:n.id},disabled:!1,parent:AXe,fiber:{state:Wgn}}}};function Bgn(e){for(let t of e.fibers)return t}a(Bgn,"rootFiber");var e1e={};qt(e1e,{apply:()=>Vgn,deleteSkill:()=>Xye,inject:()=>Ggn,listSkillNames:()=>Zye,name:()=>Hgn,putSkill:()=>Yye});h_();var iz="dsh-edge:skill-meta:",zgn="dsh-edge:skill-body:",Kye="edge",Hgn="edge-skill-provider",Ggn=["skills"];function Vgn(e,t){let{storage:n}=t;e.effect(()=>e.skills.registerProvider(r=>({name:Kye,async list(i){let s=await n.list({prefix:iz}),o=[];for(let[,c]of s)typeof c!="object"||c===null||o.push(Kgn(c));return o},async get(i,s){let o=await n.get(Qye(i.name));if(o===void 0)return;let c=await n.get(Jye(i.name));return{name:o.name,description:o.description,content:c??"",invocation:{modelInvocable:o.modelInvocable??!0,userInvocable:o.userInvocable??!0},source:"custom",provider:Kye,...o.whenToUse!==void 0?{whenToUse:o.whenToUse}:{},...o.metadata!==void 0?{metadata:o.metadata}:{}}}})))}a(Vgn,"apply");function Kgn(e){return{name:e.name,description:e.description,invocation:{modelInvocable:e.modelInvocable??!0,userInvocable:e.userInvocable??!0},source:"custom",provider:Kye,rank:oJe,locator:e.name,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}a(Kgn,"toCandidate");function Qye(e){return`${iz}${e}`}a(Qye,"metaKey");function Jye(e){return`${zgn}${e}`}a(Jye,"contentKey");async function Yye(e,t){let{content:n,...r}=t;await e.put({[Qye(t.name)]:r,[Jye(t.name)]:n})}a(Yye,"putSkill");async function Xye(e,t){return await e.delete([Qye(t),Jye(t)])>0}a(Xye,"deleteSkill");async function Zye(e){let t=await e.list({prefix:iz}),n=[];for(let[r]of t)n.push(r.slice(iz.length));return n}a(Zye,"listSkillNames");var M1e={};qt(M1e,{MAX_ENTRIES_PER_ROOT:()=>KI,MAX_FINGERPRINTS:()=>bZe,MAX_PROJECT_ROOT_DEPTH:()=>wZe,MAX_SKILL_FILE_BYTES:()=>eM,apply:()=>R0n,inject:()=>I0n,name:()=>A0n,parseFrontmatter:()=>TZe,parseInvocationPolicy:()=>AZe});h_();var sz=Symbol.for("yaml.alias"),oz=Symbol.for("yaml.document"),Gf=Symbol.for("yaml.map"),t1e=Symbol.for("yaml.pair"),gh=Symbol.for("yaml.scalar"),Q1=Symbol.for("yaml.seq"),Ad=Symbol.for("yaml.node.type"),Vf=a(e=>!!e&&typeof e=="object"&&e[Ad]===sz,"isAlias"),V0=a(e=>!!e&&typeof e=="object"&&e[Ad]===oz,"isDocument"),Kf=a(e=>!!e&&typeof e=="object"&&e[Ad]===Gf,"isMap"),Gi=a(e=>!!e&&typeof e=="object"&&e[Ad]===t1e,"isPair"),pi=a(e=>!!e&&typeof e=="object"&&e[Ad]===gh,"isScalar"),Qf=a(e=>!!e&&typeof e=="object"&&e[Ad]===Q1,"isSeq");function Cs(e){if(e&&typeof e=="object")switch(e[Ad]){case Gf:case Q1:return!0}return!1}a(Cs,"isCollection");function ns(e){if(e&&typeof e=="object")switch(e[Ad]){case sz:case Gf:case gh:case Q1:return!0}return!1}a(ns,"isNode");var az=a(e=>(pi(e)||Cs(e))&&!!e.anchor,"hasAnchor");var fp=Symbol("break visit"),IXe=Symbol("skip children"),K0=Symbol("remove node");function Q0(e,t){let n=RXe(t);V0(e)?$I(null,e.contents,n,Object.freeze([e]))===K0&&(e.contents=null):$I(null,e,n,Object.freeze([]))}a(Q0,"visit");Q0.BREAK=fp;Q0.SKIP=IXe;Q0.REMOVE=K0;function $I(e,t,n,r){let i=CXe(e,t,n,r);if(ns(i)||Gi(i))return PXe(e,r,i),$I(e,i,n,r);if(typeof i!="symbol"){if(Cs(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=$I(s,t.items[s],n,r);if(typeof o=="number")s=o-1;else{if(o===fp)return fp;o===K0&&(t.items.splice(s,1),s-=1)}}}else if(Gi(t)){r=Object.freeze(r.concat(t));let s=$I("key",t.key,n,r);if(s===fp)return fp;s===K0&&(t.key=null);let o=$I("value",t.value,n,r);if(o===fp)return fp;o===K0&&(t.value=null)}}return i}a($I,"visit_");async function cz(e,t){let n=RXe(t);V0(e)?await UI(null,e.contents,n,Object.freeze([e]))===K0&&(e.contents=null):await UI(null,e,n,Object.freeze([]))}a(cz,"visitAsync");cz.BREAK=fp;cz.SKIP=IXe;cz.REMOVE=K0;async function UI(e,t,n,r){let i=await CXe(e,t,n,r);if(ns(i)||Gi(i))return PXe(e,r,i),UI(e,i,n,r);if(typeof i!="symbol"){if(Cs(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=await UI(s,t.items[s],n,r);if(typeof o=="number")s=o-1;else{if(o===fp)return fp;o===K0&&(t.items.splice(s,1),s-=1)}}}else if(Gi(t)){r=Object.freeze(r.concat(t));let s=await UI("key",t.key,n,r);if(s===fp)return fp;s===K0&&(t.key=null);let o=await UI("value",t.value,n,r);if(o===fp)return fp;o===K0&&(t.value=null)}}return i}a(UI,"visitAsync_");function RXe(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}a(RXe,"initVisitor");function CXe(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(Kf(t))return n.Map?.(e,t,r);if(Qf(t))return n.Seq?.(e,t,r);if(Gi(t))return n.Pair?.(e,t,r);if(pi(t))return n.Scalar?.(e,t,r);if(Vf(t))return n.Alias?.(e,t,r)}a(CXe,"callVisitor");function PXe(e,t,n){let r=t[t.length-1];if(Cs(r))r.items[e]=n;else if(Gi(r))e==="key"?r.key=n:r.value=n;else if(V0(r))r.contents=n;else{let i=Vf(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}a(PXe,"replaceNode");var Qgn={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Jgn=a(e=>e.replace(/[!,[\]{}]/g,t=>Qgn[t]),"escapeTagName"),J0=class e{static{a(this,"Directives")}constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[s,o]=r;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{let o=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,o),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(i)}catch(o){return n(String(o)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+Jgn(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),i;if(t&&r.length>0&&ns(t.contents)){let s={};Q0(t.contents,(o,c)=>{ns(c)&&c.tag&&(s[c.tag]=!0)}),i=Object.keys(s)}else i=[];for(let[s,o]of r)s==="!!"&&o==="tag:yaml.org,2002:"||(!t||i.some(c=>c.startsWith(o)))&&n.push(`%TAG ${s} ${o}`);return n.join(`
|
|
6701
|
+
`)}a(Rb,"normalizeLineEndings");function x_(e,t){return`${String(e)}:${String(t)}`}a(x_,"versionOf");async function yXe(e,t){let{mtime:n}=await e.stat(t);for(;Date.now()<=n;)await new Promise(r=>setTimeout(r,1))}a(yXe,"waitPastModification");function vXe(e){return e.isFile?"file":e.isDirectory?"directory":"other"}a(vXe,"entryType");function Tgn(e){return e.isSymbolicLink?"symlink":e.isFile?"file":e.isDirectory?"directory":"other"}a(Tgn,"pathType");var ez=class e extends DQe{static{a(this,"EdgeFileSystem")}static storage=new Egn;locks=new Map;constructor(t){super(t)}bind(t,n){return()=>{}}runInScope(t,n,r){return e.storage.run({vfs:t,cwd:n},r)}searchScope(){return this.requireBinding()}requireBinding(){let t=e.storage.getStore();if(t===void 0)throw new wr("File operations are only available during an active turn.","FS_IO_ERROR");return t}get sandboxMode(){}async resolve(t,n){if(n?.signal?.aborted)throw new wr("resolve aborted","FS_ABORTED");if(t.trim().length===0)throw new wr("file_path must be a non-empty string","FS_NOT_FOUND");let r=this.requireBinding(),i=Hye(n?.cwd??r.cwd,t);return{targetKey:i,displayPath:i}}processPath(t){return String(t.targetKey)}fileUrl(t){return`file://${this.processPath(t)}`}async watch(t,n,r){if(r.aborted)throw new wr("watch aborted","FS_ABORTED");let i=this.processPath(t),s=this.ctx.on("fs/observed",o=>{let c=this.processPath(o);(c===i||(c.slice(0,c.lastIndexOf("/"))||"/")===i)&&n()});return async()=>{s()}}contains(t,n){let r=this.processPath(t),i=this.processPath(n);return i===r||i.startsWith(`${r}/`)}async stat(t,n){if(n?.aborted)throw new wr("stat aborted","FS_ABORTED");let r=this.requireBinding(),i=r.vfs;try{let s=await i.stat(this.processPath(t));return{version:x_(s.mtime,s.size),type:vXe(s),size:s.size}}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ENOENT")return this.processPath(t)===Hye(r.cwd,".")?{version:x_(0,0),type:"directory",size:0}:void 0;throw new wr(`cannot stat "${t.displayPath}":${s instanceof Error?s.message:String(s)}`,"FS_IO_ERROR",{cause:s})}}async lstat(t,n,r){if(r?.aborted)throw new wr("lstat aborted","FS_ABORTED");if(t.trim().length===0)throw new wr("file_path must be a non-empty string","FS_NOT_FOUND");let i=this.requireBinding(),s=Hye(n?.cwd??i.cwd,t),o=i.vfs;try{let c=await o.lstat(s);return{version:x_(c.mtime,c.size),type:Tgn(c),size:c.size}}catch(c){if(c instanceof Error&&"code"in c&&c.code==="ENOENT")return;throw new wr(`cannot lstat "${t}": ${c instanceof Error?c.message:String(c)}`,"FS_IO_ERROR",{cause:c})}}async readText(t,n){if(n?.aborted)throw new wr("readText aborted","FS_ABORTED");let r=this.requireBinding().vfs,i=this.processPath(t);try{let s=await r.readFile(i,"utf8"),o=await r.stat(i),c=x_(o.mtime,o.size);return this.ctx.emit("fs/observed",t,{kind:"present",version:c},void 0),Rb(s)}catch(s){throw new wr(`cannot read "${t.displayPath}": ${s instanceof Error?s.message:String(s)}`,"FS_IO_ERROR",{cause:s})}}async openReadStream(t,n){let r=a(s=>{throw s instanceof wr||n?.aborted&&s===n.reason||s instanceof Error&&s.name==="AbortError"?s:new wr(`cannot read "${t.displayPath}": ${s instanceof Error?s.message:String(s)}`,"FS_IO_ERROR",{cause:s})},"classify"),i;try{i=(await this.requireBinding().vfs.readFile(this.processPath(t))).getReader()}catch(s){return r(s)}return{async read(){n?.throwIfAborted();try{return await i.read()}catch(s){return r(s)}},async close(s){try{await i.cancel()}catch(o){s||r(o)}finally{i.releaseLock()}}}}async streamText(t,n){n?.throwIfAborted();let r=await this.openReadStream(t,n);return(async function*(){let i=new TextDecoder("utf-8",{fatal:!0}),s="",o=!1;try{for(;;){n?.throwIfAborted();let{done:l,value:u}=await r.read();if(l)break;let d=s+i.decode(u,{stream:!0});if(d.includes("\0"))throw new wr("File is not text.","FS_NOT_TEXT");s=d.endsWith("\r")?"\r":"",yield Rb(s===""?d:d.slice(0,-1))}let c=s+i.decode();c!==""&&(yield Rb(c))}catch(c){throw o=!0,n?.aborted&&c===n.reason?c:c instanceof TypeError?new wr("File is not valid UTF-8 text.","FS_NOT_TEXT",{cause:c}):c}finally{await r.close(o)}})()}async readByteRange(t,n,r){r?.throwIfAborted();let i=await this.openReadStream(t,r),s=[],o=0,c=0,l=!1;try{for(;c<n.length;){r?.throwIfAborted();let{done:p,value:h}=await i.read();if(p)break;let m=Math.min(h.byteLength,Math.max(0,n.offset-o));o+=h.byteLength;let f=h.subarray(m,Math.min(h.byteLength,m+n.length-c));f.byteLength>0&&(s.push(f.slice()),c+=f.byteLength)}let u=new Uint8Array(c),d=0;for(let p of s)u.set(p,d),d+=p.byteLength;return u}catch(u){throw l=!0,u}finally{await i.close(l)}}async readBytes(t,n,r){if(n?.aborted)throw new wr("readBytes aborted","FS_ABORTED");let i=this.requireBinding().vfs,s=this.processPath(t);try{let c=(await i.readFile(s)).getReader(),l=[],u=0;for(;;){let{done:h,value:m}=await c.read();if(h)break;if(u+=m.byteLength,u>r)throw await c.cancel(),new wr(`"${t.displayPath}" exceeds the ${String(r)}-byte read limit`,"FS_TOO_LARGE");l.push(m)}let d=new Uint8Array(u),p=0;for(let h of l)d.set(h,p),p+=h.byteLength;return d}catch(o){throw o instanceof wr?o:new wr(`cannot read "${t.displayPath}": ${o instanceof Error?o.message:String(o)}`,"FS_IO_ERROR",{cause:o})}}async listDir(t,n){if(n?.aborted)throw new wr("listDir aborted","FS_ABORTED");let r=this.requireBinding().vfs,i=this.processPath(t);try{return(await r.readdir(i)).map(o=>({name:o.name,type:vXe(o),target:{targetKey:`${i}/${o.name}`,displayPath:`${i}/${o.name}`},version:x_(o.mtime,o.size),size:o.size}))}catch(s){throw new wr(`cannot list "${t.displayPath}": ${s instanceof Error?s.message:String(s)}`,"FS_NOT_DIRECTORY",{cause:s})}}writeText(t,n,r,i){return this.withLock(t.targetKey,()=>this.writeTextLocked(t,n,r,i))}async writeTextLocked(t,n,r,i){if(i?.aborted)throw new wr("writeText aborted","FS_ABORTED");let s=this.requireBinding().vfs,o=this.processPath(t),c=await this.stat(t);if(c!==void 0&&c.type!=="file")throw new wr(`cannot write "${t.displayPath}": not a regular file`,"FS_NOT_REGULAR_FILE");if(r?.kind==="replaceIfVersion"){if(c===void 0)throw new wr(`cannot write "${t.displayPath}": file no longer exists`,"FS_STALE_VERSION");if(c.version!==r.version)throw new wr(`cannot write "${t.displayPath}": file changed since it was read`,"FS_STALE_VERSION")}else if(r?.kind==="createIfAbsent"&&c!==void 0)throw new wr(`cannot overwrite existing "${t.displayPath}" without reading it first`,"FS_NOT_OBSERVED");let l=null;if(c!==void 0)try{l=Rb(await s.readFile(o,"utf8"))}catch{}let u=o.substring(0,o.lastIndexOf("/"))||"/";try{await s.mkdir(u,{recursive:!0})}catch{}c!==void 0&&await yXe(s,o),await s.writeFile(o,n);let p=(await this.stat(t))?.version??x_(Date.now(),n.length);return this.ctx.emit("fs/observed",t,{kind:"present",version:p},void 0),{operation:c!==void 0?"update":"create",version:p,before:l,after:Rb(n)}}editText(t,n,r,i){return this.withLock(t.targetKey,()=>this.editTextLocked(t,n,r,i))}async editTextLocked(t,n,r,i){if(i?.aborted)throw new wr("editText aborted","FS_ABORTED");let s=this.requireBinding().vfs,o=this.processPath(t),c=await this.stat(t);if(c===void 0)throw new wr(`cannot edit "${t.displayPath}": file not found`,"FS_STALE_VERSION");if(c.type!=="file")throw new wr(`cannot edit "${t.displayPath}": not a regular file`,"FS_NOT_REGULAR_FILE");if(r!==void 0&&c.version!==r.version)throw new wr(`cannot edit "${t.displayPath}": file changed since it was read`,"FS_STALE_VERSION");let l=Rb(await s.readFile(o,"utf8")),u=Rb(n.oldString);if(u.length===0)throw new wr("old_string must be a non-empty string","FS_EDIT_NOT_FOUND");let d=l.split(u).length-1;if(d===0)throw new wr(`old_string was not found in "${t.displayPath}"`,"FS_EDIT_NOT_FOUND");if(!n.replaceAll&&d>1)throw new wr(`old_string matched ${String(d)} times in "${t.displayPath}"; provide a more specific old_string or set replace_all to true`,"FS_AMBIGUOUS_EDIT");let p=Rb(n.newString),h=l.split(u).join(p);await yXe(s,o),await s.writeFile(o,h);let f=(await this.stat(t))?.version??x_(Date.now(),h.length);return this.ctx.emit("fs/observed",t,{kind:"present",version:f},void 0),{version:f,before:l,after:h}}async withLock(t,n){let r=(this.locks.get(t)??Promise.resolve()).then(n,n),i=r.then(()=>{},()=>{});this.locks.set(t,i);try{return await r}finally{this.locks.get(t)===i&&this.locks.delete(t)}}};dr();var xXe='Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @"..." quotes a path containing spaces.',bXe=class extends Lt{static{a(this,"FileReferenceService")}constructor(e){super(e,"fileReferences")}};var Agn=20,Ign="/workspace",tz=class extends bXe{static{a(this,"EdgeFileReferenceService")}withFiles;maxResults;constructor(t,n){if(super(t),this.withFiles=r=>n.withFiles(r),this.maxResults=n.maxResults??Agn,!Number.isSafeInteger(this.maxResults)||this.maxResults<=0)throw new Error("dsh-edge: file reference maxResults must be a positive safe integer");t.inject(["systemPrompt"],r=>{r.systemPrompt.section({name:"context:file-reference",order:r.systemPrompt.getSectionOrder("FILE_REFERENCE"),text:xXe})})}async list(t,n,r){r.throwIfAborted();let i=this.ctx.get("workingDirectory")?.get(t.session)??t.session.header.cwd??Ign,s=Rgn(n);if(s===void 0)return[];let o=Cgn(i,s.directory);if(o===void 0)return[];let c;try{c=await this.withFiles(l=>l.readdir(o))}catch{return r.throwIfAborted(),[]}return r.throwIfAborted(),Pgn(c,s,this.maxResults)}};function Rgn(e){let t=e.replaceAll("\\","/");for(let r of t){let i=r.codePointAt(0)??0;if(i<32||i===127||r==='"')return}let n=t.lastIndexOf("/");return n<0?{directory:"",fragment:t}:{directory:t.slice(0,n+1),fragment:t.slice(n+1)}}a(Rgn,"splitQuery");function Cgn(e,t){let n=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."){if(n.length===0)return;n.pop();continue}n.push(i)}let r=e.endsWith("/")?e.slice(0,-1):e;return n.length===0?r===""?"/":r:`${r}/${n.join("/")}`}a(Cgn,"resolveWithin");function Pgn(e,t,n){let r=t.fragment.toLowerCase(),i=[];for(let s of e){if(s.name.startsWith(".")&&!t.fragment.startsWith("."))continue;let o=s.isDirectory?"directory":s.isFile?"file":void 0;if(o===void 0)continue;let c=Ogn(s.name.toLowerCase(),r,o);c!==void 0&&i.push({candidate:{path:`${t.directory}${s.name}`,kind:o},score:c})}return i.sort((s,o)=>o.score-s.score||wXe(s.candidate.kind)-wXe(o.candidate.kind)||Mgn(s.candidate.path,o.candidate.path)),i.slice(0,n).map(s=>s.candidate)}a(Pgn,"rankCandidates");function Ogn(e,t,n){let r=n==="directory"?25:0;if(t==="")return r;if(e===t)return 1e3+r;if(e.startsWith(t))return 900+r;if(e.includes(t))return 700+r}a(Ogn,"scoreName");function wXe(e){return e==="directory"?0:1}a(wXe,"kindRank");function Mgn(e,t){return e<t?-1:e>t?1:0}a(Mgn,"compareText");Gye();var Ngn="/workspace",Lgn=1e3,nz=class extends kXe{static{a(this,"EdgeDirectoryPicker")}withFiles;root;maxEntries;browseCapability={kind:"browse",list:a((t,n)=>this.list(t,n),"list"),createDirectory:a((t,n)=>this.createDirectory(t,n),"createDirectory")};constructor(t,n){if(super(t),this.withFiles=r=>n.withFiles(r),this.root=$gn(n.root??Ngn),this.maxEntries=n.maxEntries??Lgn,!Number.isSafeInteger(this.maxEntries)||this.maxEntries<=0)throw new Error("dsh-edge: directory picker maxEntries must be a positive safe integer")}capability(){return this.browseCapability}async list(t,n){n?.throwIfAborted();let r=t===void 0?this.root:Vye(this.root,t);if(r===void 0)throw new K1("directory-unreadable",t??this.root,`cannot list "${t??""}": not an absolute path under ${this.root}`);let i;try{i=await this.withFiles(l=>l.readdir(r))}catch(l){if(n?.throwIfAborted(),r===this.root&&_Xe(l))i=[];else throw new K1("directory-unreadable",r,`cannot list ${r}: ${SXe(l)}`)}n?.throwIfAborted();let s=i.filter(l=>l.isDirectory).map(l=>l.name).sort((l,u)=>l.localeCompare(u)),o=s.length>this.maxEntries,c=s.slice(0,this.maxEntries).map(l=>({name:l,path:`${r==="/"?"":r}/${l}`,hidden:l.startsWith(".")}));return{path:r,home:this.root,crumbs:Dgn(this.root,r),entries:c,truncated:o}}async createDirectory(t,n){let r=Vye(this.root,t);if(r===void 0)throw new K1("directory-create-failed",t,`cannot create under "${t}": not an absolute path under ${this.root}`);if(!Ugn(n))throw new K1("directory-create-failed",`${r==="/"?"":r}/${n}`,`"${n}" is not a single path segment`);let i=`${r==="/"?"":r}/${n}`,s=!1;try{if(s=await this.withFiles(async o=>{try{return await o.stat(i),!0}catch(c){if(_Xe(c))return!1;throw c}}),!s)return await this.withFiles(async o=>{r===this.root&&await o.mkdir(this.root,{recursive:!0}),await o.mkdir(i)}),i}catch(o){throw new K1("directory-create-failed",i,`cannot create ${i}: ${SXe(o)}`)}throw new K1("directory-exists",i,`${i} already exists`)}};function Vye(e,t){if(!t.startsWith("/")||EXe(t))return;let n=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."){if(n.length===0)return;n.pop();continue}n.push(i)}let r=n.length===0?"/":`/${n.join("/")}`;if(!(r!==e&&!r.startsWith(e==="/"?"/":`${e}/`)))return r}a(Vye,"resolveWithinRoot");function Dgn(e,t){let n=[{name:e,path:e,hidden:!1}];if(t===e)return n;let r=t.slice(e==="/"?1:e.length+1),i=e==="/"?"":e;for(let s of r.split("/"))i=`${i}/${s}`,n.push({name:s,path:i,hidden:!1});return n}a(Dgn,"directoryCrumbs");function $gn(e){let t=Vye("/",e);if(t===void 0)throw new Error("dsh-edge: directory picker root must be an absolute path");return t}a($gn,"normalizeRoot");function Ugn(e){return e.trim()!==""&&e!=="."&&e!==".."&&!/[/\\]/u.test(e)&&!EXe(e)}a(Ugn,"isSingleSegment");function EXe(e){for(let t of e){let n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}a(EXe,"hasControlCharacter");function _Xe(e){return e instanceof Error&&"code"in e&&e.code==="ENOENT"}a(_Xe,"isNotFound");function SXe(e){return e instanceof Error?e.message:String(e)}a(SXe,"messageOf");dr();var TXe=[{id:"@deepseek-ai/dsh-typert-registry",inject:[],immediately:!0},{id:"@deepseek-ai/dsh-api-gateway",inject:["@deepseek-ai/dsh-typert-registry","@deepseek-ai/dsh-client-connection"],immediately:!0},{id:"@deepseek-ai/dsh-api-remote-access",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-ui-renderer"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-session-log-export",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-commands","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-open-in-app",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-sidebar-documentpreview"]},{id:"@deepseek-ai/dsh-api-session-controller",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-file-upload"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-api-job-controller",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-connection"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-api-workspace-files",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-resources"]},{id:"@deepseek-ai/dsh-api-workspace-controller",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-client-connection"],external:["@deepseek-ai/dsh-api-gateway/client"]},{id:"@deepseek-ai/dsh-client-modules",inject:[],immediately:!0},{id:"@deepseek-ai/dsh-client-connection",inject:[],immediately:!0},{id:"@deepseek-ai/dsh-client-file-upload",inject:["@deepseek-ai/dsh-api-remotes"],immediately:!0},{id:"@deepseek-ai/dsh-api-remotes",inject:["@deepseek-ai/dsh-api-gateway"],immediately:!0},{id:"@deepseek-ai/dsh-client-ui-theme",inject:["@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-api-remotes"],immediately:!0},{id:"@deepseek-ai/dsh-client-locale",inject:["@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-api-remotes"],immediately:!0},{id:"@deepseek-ai/dsh-client-shortcuts",inject:["@deepseek-ai/dsh-client-locale"]},{id:"@deepseek-ai/dsh-client-ui-shortcuts",inject:["@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-layout",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-theme","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-renderer",immediately:!0},{id:"@deepseek-ai/dsh-client-ui-session",inject:["@deepseek-ai/dsh-api-remote-access","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-resources",inject:["@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-ui-sidebar",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-right",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-documentpreview",inject:["@deepseek-ai/dsh-api-gateway","@deepseek-ai/dsh-api-workspace-files","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-browser",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-sidebar-files",inject:["@deepseek-ai/dsh-api-workspace-files","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-shortcuts"]},{id:"@deepseek-ai/dsh-client-ui-settings",inject:["@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-general",inject:["@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-sidebar","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-modules","@deepseek-ai/dsh-client-ui-layout"]},{id:"@deepseek-ai/dsh-client-ui-settings-models",inject:["@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-plugin-inventory",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-agent-preset","@deepseek-ai/dsh-client-modules"]},{id:"@deepseek-ai/dsh-client-ui-conversation",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-file-upload","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-approval",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-chat",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-brand-official",inject:["@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-sidebar"]},{id:"@deepseek-ai/dsh-client-ui-attachment",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-trajectory","@deepseek-ai/dsh-client-ui-tool"]},{id:"@deepseek-ai/dsh-client-ui-tool",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation"]},{id:"@deepseek-ai/dsh-client-ui-deliverables",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-tool","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-workspace",inject:["@deepseek-ai/dsh-api-remote-access","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-shortcuts","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-sidebar"]},{id:"@deepseek-ai/dsh-client-ui-workflow-run",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-input-trigger",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-ui-commands",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-conversation"]},{id:"@deepseek-ai/dsh-client-ui-skill",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-tool","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-sidebar-right"]},{id:"@deepseek-ai/dsh-client-ui-subagent",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-primitives","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-workspace"]},{id:"@deepseek-ai/dsh-client-ui-reference",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-input-trigger","@deepseek-ai/dsh-client-ui-sidebar-right"]},{id:"@deepseek-ai/dsh-client-ui-secret-mask",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer"]},{id:"@deepseek-ai/dsh-client-ui-jobs",inject:["@deepseek-ai/dsh-api-job-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-primitives"]},{id:"@deepseek-ai/dsh-client-ui-schedule",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-layout","@deepseek-ai/dsh-client-ui-sidebar","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-tool","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-client-ui-primitives"]},{id:"@deepseek-ai/dsh-client-ui-goal",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-message-feedback",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-commands"]},{id:"@deepseek-ai/dsh-client-ui-model-selection",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-commands","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-deepseek-model-label-1017",inject:["@deepseek-ai/dsh-client-ui-model-selection","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-locale"]},{id:"@deepseek-ai/dsh-client-ui-agent-preset",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-plugins",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings"]},{id:"@deepseek-ai/dsh-client-ui-settings-agent-loop",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings","dsh-edge-client-ui"]},{id:"@deepseek-ai/dsh-client-ui-settings-subagent",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings","dsh-edge-client-ui","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-settings-web-search",inject:["@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings","dsh-edge-client-ui","@deepseek-ai/dsh-api-remotes"]},{id:"@deepseek-ai/dsh-client-ui-plan",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-sidebar-right","@deepseek-ai/dsh-client-ui-chat","@deepseek-ai/dsh-client-ui-user-questions","@deepseek-ai/dsh-client-resources","@deepseek-ai/dsh-api-session-controller"]},{id:"@deepseek-ai/dsh-client-ui-user-questions",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session","@deepseek-ai/dsh-client-ui-chat"]},{id:"@deepseek-ai/dsh-client-ui-trajectory",inject:["@deepseek-ai/dsh-api-session-controller","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-conversation","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-session"]},{id:"@deepseek-ai/dsh-client-ui-directory-picker-browse",inject:["@deepseek-ai/dsh-api-remotes","@deepseek-ai/dsh-client-ui-renderer","@deepseek-ai/dsh-client-ui-workspace","@deepseek-ai/dsh-client-locale"]},{id:"dsh-edge-client-ui",inject:["@deepseek-ai/dsh-api-workspace-controller","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-locale","@deepseek-ai/dsh-client-ui-settings-plugins"]}];var AXe={tree:{ctx:{baseUrl:void 0}}},jgn="host:",qgn="web:",Wgn=2,rz=class extends Lt{static{a(this,"EdgeLoader")}constructor(t){super(t,"loader")}*entries(){let t=new Map;for(let[,n]of this.ctx.registry.entries()){let r=n.name;if(r===void 0||r==="")continue;let i=(t.get(r)??0)+1;t.set(r,i);let s=Bgn(n);yield{id:`${jgn}${r}${i===1?"":`#${String(i)}`}`,options:{name:r},disabled:!1,parent:AXe,...s===void 0?{}:{fiber:s}}}for(let n of TXe)yield{id:`${qgn}${n.id}`,options:{name:n.id},disabled:!1,parent:AXe,fiber:{state:Wgn}}}};function Bgn(e){for(let t of e.fibers)return t}a(Bgn,"rootFiber");var e1e={};qt(e1e,{apply:()=>Vgn,deleteSkill:()=>Xye,inject:()=>Ggn,listSkillNames:()=>Zye,name:()=>Hgn,putSkill:()=>Yye});h_();var iz="dsh-edge:skill-meta:",zgn="dsh-edge:skill-body:",Kye="edge",Hgn="edge-skill-provider",Ggn=["skills"];function Vgn(e,t){let{storage:n}=t;e.effect(()=>e.skills.registerProvider(r=>({name:Kye,async list(i){let s=await n.list({prefix:iz}),o=[];for(let[,c]of s)typeof c!="object"||c===null||o.push(Kgn(c));return o},async get(i,s){let o=await n.get(Qye(i.name));if(o===void 0)return;let c=await n.get(Jye(i.name));return{name:o.name,description:o.description,content:c??"",invocation:{modelInvocable:o.modelInvocable??!0,userInvocable:o.userInvocable??!0},source:"custom",provider:Kye,...o.whenToUse!==void 0?{whenToUse:o.whenToUse}:{},...o.metadata!==void 0?{metadata:o.metadata}:{}}}})))}a(Vgn,"apply");function Kgn(e){return{name:e.name,description:e.description,invocation:{modelInvocable:e.modelInvocable??!0,userInvocable:e.userInvocable??!0},source:"custom",provider:Kye,rank:oJe,locator:e.name,...e.whenToUse!==void 0?{whenToUse:e.whenToUse}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}a(Kgn,"toCandidate");function Qye(e){return`${iz}${e}`}a(Qye,"metaKey");function Jye(e){return`${zgn}${e}`}a(Jye,"contentKey");async function Yye(e,t){let{content:n,...r}=t;await e.put({[Qye(t.name)]:r,[Jye(t.name)]:n})}a(Yye,"putSkill");async function Xye(e,t){return await e.delete([Qye(t),Jye(t)])>0}a(Xye,"deleteSkill");async function Zye(e){let t=await e.list({prefix:iz}),n=[];for(let[r]of t)n.push(r.slice(iz.length));return n}a(Zye,"listSkillNames");var M1e={};qt(M1e,{MAX_ENTRIES_PER_ROOT:()=>KI,MAX_FINGERPRINTS:()=>bZe,MAX_PROJECT_ROOT_DEPTH:()=>wZe,MAX_SKILL_FILE_BYTES:()=>eM,apply:()=>R0n,inject:()=>I0n,name:()=>A0n,parseFrontmatter:()=>TZe,parseInvocationPolicy:()=>AZe});h_();var sz=Symbol.for("yaml.alias"),oz=Symbol.for("yaml.document"),Gf=Symbol.for("yaml.map"),t1e=Symbol.for("yaml.pair"),gh=Symbol.for("yaml.scalar"),Q1=Symbol.for("yaml.seq"),Ad=Symbol.for("yaml.node.type"),Vf=a(e=>!!e&&typeof e=="object"&&e[Ad]===sz,"isAlias"),V0=a(e=>!!e&&typeof e=="object"&&e[Ad]===oz,"isDocument"),Kf=a(e=>!!e&&typeof e=="object"&&e[Ad]===Gf,"isMap"),Gi=a(e=>!!e&&typeof e=="object"&&e[Ad]===t1e,"isPair"),pi=a(e=>!!e&&typeof e=="object"&&e[Ad]===gh,"isScalar"),Qf=a(e=>!!e&&typeof e=="object"&&e[Ad]===Q1,"isSeq");function Cs(e){if(e&&typeof e=="object")switch(e[Ad]){case Gf:case Q1:return!0}return!1}a(Cs,"isCollection");function ns(e){if(e&&typeof e=="object")switch(e[Ad]){case sz:case Gf:case gh:case Q1:return!0}return!1}a(ns,"isNode");var az=a(e=>(pi(e)||Cs(e))&&!!e.anchor,"hasAnchor");var fp=Symbol("break visit"),IXe=Symbol("skip children"),K0=Symbol("remove node");function Q0(e,t){let n=RXe(t);V0(e)?$I(null,e.contents,n,Object.freeze([e]))===K0&&(e.contents=null):$I(null,e,n,Object.freeze([]))}a(Q0,"visit");Q0.BREAK=fp;Q0.SKIP=IXe;Q0.REMOVE=K0;function $I(e,t,n,r){let i=CXe(e,t,n,r);if(ns(i)||Gi(i))return PXe(e,r,i),$I(e,i,n,r);if(typeof i!="symbol"){if(Cs(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=$I(s,t.items[s],n,r);if(typeof o=="number")s=o-1;else{if(o===fp)return fp;o===K0&&(t.items.splice(s,1),s-=1)}}}else if(Gi(t)){r=Object.freeze(r.concat(t));let s=$I("key",t.key,n,r);if(s===fp)return fp;s===K0&&(t.key=null);let o=$I("value",t.value,n,r);if(o===fp)return fp;o===K0&&(t.value=null)}}return i}a($I,"visit_");async function cz(e,t){let n=RXe(t);V0(e)?await UI(null,e.contents,n,Object.freeze([e]))===K0&&(e.contents=null):await UI(null,e,n,Object.freeze([]))}a(cz,"visitAsync");cz.BREAK=fp;cz.SKIP=IXe;cz.REMOVE=K0;async function UI(e,t,n,r){let i=await CXe(e,t,n,r);if(ns(i)||Gi(i))return PXe(e,r,i),UI(e,i,n,r);if(typeof i!="symbol"){if(Cs(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=await UI(s,t.items[s],n,r);if(typeof o=="number")s=o-1;else{if(o===fp)return fp;o===K0&&(t.items.splice(s,1),s-=1)}}}else if(Gi(t)){r=Object.freeze(r.concat(t));let s=await UI("key",t.key,n,r);if(s===fp)return fp;s===K0&&(t.key=null);let o=await UI("value",t.value,n,r);if(o===fp)return fp;o===K0&&(t.value=null)}}return i}a(UI,"visitAsync_");function RXe(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}a(RXe,"initVisitor");function CXe(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(Kf(t))return n.Map?.(e,t,r);if(Qf(t))return n.Seq?.(e,t,r);if(Gi(t))return n.Pair?.(e,t,r);if(pi(t))return n.Scalar?.(e,t,r);if(Vf(t))return n.Alias?.(e,t,r)}a(CXe,"callVisitor");function PXe(e,t,n){let r=t[t.length-1];if(Cs(r))r.items[e]=n;else if(Gi(r))e==="key"?r.key=n:r.value=n;else if(V0(r))r.contents=n;else{let i=Vf(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}a(PXe,"replaceNode");var Qgn={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Jgn=a(e=>e.replace(/[!,[\]{}]/g,t=>Qgn[t]),"escapeTagName"),J0=class e{static{a(this,"Directives")}constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[s,o]=r;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{let o=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,o),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(i)}catch(o){return n(String(o)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+Jgn(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),i;if(t&&r.length>0&&ns(t.contents)){let s={};Q0(t.contents,(o,c)=>{ns(c)&&c.tag&&(s[c.tag]=!0)}),i=Object.keys(s)}else i=[];for(let[s,o]of r)s==="!!"&&o==="tag:yaml.org,2002:"||(!t||i.some(c=>c.startsWith(o)))&&n.push(`%TAG ${s} ${o}`);return n.join(`
|
|
6702
6702
|
`)}};J0.defaultYaml={explicit:!1,version:"1.2"};J0.defaultTags={"!!":"tag:yaml.org,2002:"};function lz(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}a(lz,"anchorIsValid");function n1e(e){let t=new Set;return Q0(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}a(n1e,"anchorNames");function r1e(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}a(r1e,"findNewAnchor");function OXe(e,t){let n=[],r=new Map,i=null;return{onAnchor:a(s=>{n.push(s),i??(i=n1e(e));let o=r1e(t,i);return i.add(o),o},"onAnchor"),setAnchors:a(()=>{for(let s of n){let o=r.get(s);if(typeof o=="object"&&o.anchor&&(pi(o.node)||Cs(o.node)))o.node.anchor=o.anchor;else{let c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=s,c}}},"setAnchors"),sourceObjects:r}}a(OXe,"createNodeAnchors");function Cb(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,s=r.length;i<s;++i){let o=r[i],c=Cb(e,r,String(i),o);c===void 0?delete r[i]:c!==o&&(r[i]=c)}else if(r instanceof Map)for(let i of Array.from(r.keys())){let s=r.get(i),o=Cb(e,r,i,s);o===void 0?r.delete(i):o!==s&&r.set(i,o)}else if(r instanceof Set)for(let i of Array.from(r)){let s=Cb(e,r,i,i);s===void 0?r.delete(i):s!==i&&(r.delete(i),r.add(s))}else for(let[i,s]of Object.entries(r)){let o=Cb(e,r,i,s);o===void 0?delete r[i]:o!==s&&(r[i]=o)}return e.call(t,n,r)}a(Cb,"applyReviver");function Yc(e,t,n){if(Array.isArray(e))return e.map((r,i)=>Yc(r,String(i),n));if(e&&typeof e.toJSON=="function"){if(!n||!az(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=s=>{r.res=s,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e=="bigint"&&!n?.keep?Number(e):e}a(Yc,"toJS");var Pb=class{static{a(this,"NodeBase")}constructor(t){Object.defineProperty(this,Ad,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:s}={}){if(!V0(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=Yc(this,"",o);if(typeof i=="function")for(let{count:l,res:u}of o.anchors.values())i(u,l);return typeof s=="function"?Cb(s,{"":c},"",c):c}};var J1=class extends Pb{static{a(this,"Alias")}constructor(t){super(sz),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Q0(t,{Node:a((s,o)=>{(Vf(o)||az(o))&&r.push(o)},"Node")}),n&&(n.aliasResolveCache=r));let i;for(let s of r){if(s===this)break;s.anchor===this.source&&(i=s)}return i}toJSON(t,n){if(!n)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:s}=n,o=this.resolve(i,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let c=r.get(o);if(c||(Yc(o,null,n),c=r.get(o)),c?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(s>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=uz(i,o,r)),c.count*c.aliasCount>s)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return c.res}toString(t,n,r){let i=`*${this.source}`;if(t){if(lz(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(t.implicitKey)return`${i} `}return i}};function uz(e,t,n){if(Vf(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Cs(t)){let r=0;for(let i of t.items){let s=uz(e,i,n);s>r&&(r=s)}return r}else if(Gi(t)){let r=uz(e,t.key,n),i=uz(e,t.value,n);return Math.max(r,i)}return 1}a(uz,"getAliasCount");var dz=a(e=>!e||typeof e!="function"&&typeof e!="object","isScalarValue"),Wn=class extends Pb{static{a(this,"Scalar")}constructor(t){super(gh),this.value=t}toJSON(t,n){return n?.keep?this.value:Yc(this.value,t,n)}toString(){return String(this.value)}};Wn.BLOCK_FOLDED="BLOCK_FOLDED";Wn.BLOCK_LITERAL="BLOCK_LITERAL";Wn.PLAIN="PLAIN";Wn.QUOTE_DOUBLE="QUOTE_DOUBLE";Wn.QUOTE_SINGLE="QUOTE_SINGLE";var Ygn="tag:yaml.org,2002:";function Xgn(e,t,n){if(t){let r=n.filter(s=>s.tag===t),i=r.find(s=>!s.format)??r[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(r=>r.identify?.(e)&&!r.format)}a(Xgn,"findTagObject");function Y1(e,t,n){if(V0(e)&&(e=e.contents),ns(e))return e;if(Gi(e)){let p=n.schema[Gf].createNode?.(n.schema,null,n);return p.items.push(e),p}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:s,schema:o,sourceObjects:c}=n,l;if(r&&e&&typeof e=="object"){if(l=c.get(e),l)return l.anchor??(l.anchor=i(e)),new J1(l.anchor);l={anchor:null,node:null},c.set(e,l)}t?.startsWith("!!")&&(t=Ygn+t.slice(2));let u=Xgn(e,t,o.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let p=new Wn(e);return l&&(l.node=p),p}u=e instanceof Map?o[Gf]:Symbol.iterator in Object(e)?o[Q1]:o[Gf]}s&&(s(u),delete n.onTagObj);let d=u?.createNode?u.createNode(n.schema,e,n):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(n.schema,e,n):new Wn(e);return t?d.tag=t:u.default||(d.tag=u.tag),l&&(l.node=d),d}a(Y1,"createNode");function NO(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){let s=t[i];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=r,r=o}else r=new Map([[s,r]])}return Y1(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:a(()=>{throw new Error("This should not happen, please report a bug.")},"onAnchor"),schema:e,sourceObjects:new Map})}a(NO,"collectionFromPath");var jI=a(e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,"isEmptyPath"),FI=class extends Pb{static{a(this,"Collection")}constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>ns(r)||Gi(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(jI(t))this.add(n);else{let[r,...i]=t,s=this.get(r,!0);if(Cs(s))s.addIn(i,n);else if(s===void 0&&this.schema)this.set(r,NO(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(t){let[n,...r]=t;if(r.length===0)return this.delete(n);let i=this.get(n,!0);if(Cs(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){let[r,...i]=t,s=this.get(r,!0);return i.length===0?!n&&pi(s)?s.value:s:Cs(s)?s.getIn(i,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!Gi(n))return!1;let r=n.value;return r==null||t&&pi(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[n,...r]=t;if(r.length===0)return this.has(n);let i=this.get(n,!0);return Cs(i)?i.hasIn(r):!1}setIn(t,n){let[r,...i]=t;if(i.length===0)this.set(r,n);else{let s=this.get(r,!0);if(Cs(s))s.setIn(i,n);else if(s===void 0&&this.schema)this.set(r,NO(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};var MXe=a(e=>e.replace(/^(?!$)(?: $)?/gm,"#"),"stringifyComment");function fm(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}a(fm,"indentComment");var Y0=a((e,t,n)=>e.endsWith(`
|
|
6703
6703
|
`)?fm(n,t):n.includes(`
|
|
6704
6704
|
`)?`
|
|
@@ -7227,7 +7227,7 @@ The web request used endpoint ${JSON.stringify(e)}. Search endpoint configuratio
|
|
|
7227
7227
|
.error { padding: .75rem; border-radius: .5rem; background: #461d2b; color: #ffd6df; }
|
|
7228
7228
|
.hint { margin: 1.5rem 0 0; font-size: .875rem; }
|
|
7229
7229
|
code { padding: .1rem .3rem; border-radius: .3rem; background: #0c1222; color: #edf2ff; }
|
|
7230
|
-
`}a(RIt,"pageStyles");hO();var s3e="enabled",o3e=Object.freeze({id:"direct",capabilities:Object.freeze(["bash"]),plan:"free",shell:"just-bash-direct",probe:a(e=>e.LOADER===void 0?"available":"needs-binding","probe")}),kD=Object.freeze({id:"dynamic-worker",capabilities:Object.freeze(["bash","coding"]),plan:"paid",shell:"just-bash-isolated",probe:a(e=>e.LOADER===void 0?"needs-binding":"available","probe")}),a3e=Object.freeze({id:"container",capabilities:Object.freeze(["container"]),plan:"paid",shell:"linux-container",probe:a(e=>e.DSH_EDGE_CONTAINER_RUNTIME===s3e?"available":"needs-binding","probe")}),wfr=Object.freeze([a3e,kD,o3e]);function c3e(e,t=wfr){return t.filter(n=>n.probe(e)==="available")}a(c3e,"availableEdgeRuntimeProviders");function l3e(e){let t=a(r=>e.find(i=>i.capabilities.includes(r)),"first"),n=t("bash");if(n===void 0)throw new Error("No available runtime provider serves the bash layer.");return{bash:n.id,container:t("container")?.id??null}}a(l3e,"resolveEdgeRuntimeSelection");function qee(e){let t=c3e(e),{bash:n,container:r}=l3e(t);return t.find(i=>i.id===(r??n)).shell}a(qee,"resolveEdgeRuntimeShell");function kfr(){return"dsh-edge@0.27.0/direct"}a(kfr,"resolveEdgeDeploymentId");function RE(e){return{baseURL:TTe(e.DEEPSEEK_BASE_URL),maxTokens:RTe(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:GS(e.DEEPSEEK_MODEL),reasoningEffort:ATe(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:ML(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:ITe(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:S2(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a(RE,"resolveEdgeDeploymentConfig");function _fr(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}a(_fr,"edgeDeploymentApiKeyConfigured");function Sfr(e){let t=TTe(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}a(Sfr,"projectedEdgeBaseURL");function u3e(e,t){return{shell:qee(e),storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:kfr(),apiKeyConfigured:_fr(e),baseURL:Sfr(e.DEEPSEEK_BASE_URL),maxTokens:RTe(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:GS(e.DEEPSEEK_MODEL),reasoningEffort:ATe(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:ML(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:ITe(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:S2(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a(u3e,"resolveEdgeDeploymentProfile");function Wee(e){RE(e);let t=u3e(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,...e.CF_VERSION_METADATA===void 0?{}:{workerVersionId:e.CF_VERSION_METADATA.id},version:u_,upstreamVersion:bQe,status:"ready"}}a(Wee,"resolveEdgeDeploymentHealth");import{AsyncLocalStorage as N6r}from"node:async_hooks";import{RpcTarget as Efr}from"cloudflare:workers";function Tfr(e){let{intervalMs:t,ping:n,onFailure:r}=e,i=!1,s=setInterval(()=>{i||n().catch(o=>{i||(i=!0,clearInterval(s),r(o instanceof Error?o:new Error(String(o))))})},t);return()=>{i||(i=!0,clearInterval(s))}}a(Tfr,"startHeartbeat");async function Afr(e,t){let n=AbortSignal.timeout(t.timeoutMs),r=await e.fetchPort(t.port,`http://container${t.path}`,{method:"HEAD",signal:n});if(r.body?.cancel(),!r.ok)throw new Error(`computerd health returned ${r.status}`)}a(Afr,"probeComputerdHealth");var Ifr="computer.internal",Rfr="/health",d3e="/api",Cfr=8080,Pfr=3e4,Ofr=2e4,Mfr=1,Nfr=2e3,Lfr=250,Dfr=2e3;function $fr(e,t){if(t===void 0||e===null)return!1;let n=e.indexOf(" ");if(n===-1||e.slice(0,n).toLowerCase()!=="bearer")return!1;let r=e.slice(n+1).trim();if(r.length!==t.length)return!1;let i=0;for(let s=0;s<t.length;s+=1)i|=r.charCodeAt(s)^t.charCodeAt(s);return i===0}a($fr,"bearerMatches");var zee=class{static{a(this,"CloudflareContainerBackend")}type="cloudflare-container";id;#e;#n;#r;#t;#i;#s;#a;#u;constructor(e){this.id=e.id??"container-shell",this.#n=e.egress??{mode:"none"},this.#r=this.#n.mode==="http-gateway"?crypto.randomUUID():void 0,this.#e={container:e.container,workspace:e.workspace,containerEnv:e.containerEnv,egressHost:e.egressHost??Ifr,containerPort:e.containerPort??Cfr,connectTimeoutMs:e.connectTimeoutMs??Pfr,heartbeatIntervalMs:e.heartbeatIntervalMs??Ofr,restartAttempts:e.restartAttempts??Mfr,healthProbeTimeoutMs:e.healthProbeTimeoutMs??Nfr,healthRetryInitialDelayMs:e.healthRetryInitialDelayMs??Lfr,healthRetryMaxDelayMs:e.healthRetryMaxDelayMs??Dfr}}async connect(){if(this.#u)return this.#u;let e=Date.now()+this.#e.connectTimeoutMs,t=await(await this.#e.container()).getWorkspaceContainer(),n=await t.exitInfo().catch(()=>null),r={PORT:String(this.#e.containerPort),MOUNT_POINT:"/workspace",...this.#e.containerEnv},i,s;try{({runtimeId:i,clientSecret:s}=await t.start({env:r,enableInternet:this.#n.mode==="direct"}))}catch(p){throw new nd(this.#h("start",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}try{await t.interceptOutboundHttp(this.#e.egressHost,this.#e.workspace),this.#n.mode==="http-gateway"&&this.#r!==void 0&&await t.interceptAllOutboundHttp(this.#e.workspace,this.#r)}catch(p){throw new nd(this.#h("egress",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}this.#t=s,this.#c(),i=await this.#p(t,r,e,n,i),await this.#l(t,e),await this.#f(t,e,s);let o=await this.#d(e),c=yre(o),l,u=new Promise(p=>{let h=!1,m=a(()=>{h||(h=!0,l?.(),p(),this.#u=void 0)},"onClose");o.addEventListener("close",m,{once:!0}),o.addEventListener("error",m,{once:!0}),c.onRpcBroken(m)});this.#e.heartbeatIntervalMs>0&&(l=Tfr({intervalMs:this.#e.heartbeatIntervalMs,ping:a(()=>c.sync.watermarks(),"ping"),onFailure:a(()=>{try{o.close()}catch{}},"onFailure")}));let d={rpc:c,runtimeId:i,closed:u,close:a(async()=>{l?.();try{c[Symbol.dispose]?.()}catch{}try{o.close()}catch{}this.#u=void 0},"close")};return this.#u=d,d}async handleFetch(e){if(this.#n.mode==="http-gateway"&&this.#r!==void 0&&e.headers.get("x-workspace-egress-token")===this.#r){let i=new Headers(e.headers),s=i.get(u3),o;try{o=new URL(s??"")}catch{return new Response("invalid egress URL",{status:400})}if(o.protocol!=="http:"&&o.protocol!=="https:")return new Response("invalid egress URL",{status:400});i.delete(N$),i.delete(u3);let c=new Request(e,{headers:i});return this.#n.gateway.fetch(new Request(o,c))}if(new URL(e.url).pathname!==d3e)return new Response("not found",{status:404});if(e.headers.get("upgrade")!=="websocket")return new Response(`${d3e} requires a websocket upgrade`,{status:400});if(!$fr(e.headers.get("authorization"),this.#t))return new Response("unauthorized",{status:401,headers:{"www-authenticate":"Bearer"}});let t=new WebSocketPair,[n,r]=[t[0],t[1]];if(r.accept(),this.#s)this.#s(r);else return r.close(1011,"no pending connect"),new Response("no pending connect",{status:409});return new Response(null,{status:101,webSocket:n})}#c(){this.#i=new Promise((e,t)=>{this.#s=e,this.#a=t}),this.#i.catch(()=>{})}#o(){this.#i=void 0,this.#s=void 0,this.#a=void 0}async#p(e,t,n,r,i){let s=this.#e.restartAttempts+1,o=Math.max(0,n-Date.now()),c=Math.max(250,Math.floor(o/s)),l=0,u=0,d,p=i;for(;l<s;){l++;let h=Math.min(n,Date.now()+c);if(await this.#m(e,h).then(()=>!0,m=>(d=m,!1)))return p;if(l<s)try{({runtimeId:p}=await e.restart({env:t,enableInternet:this.#n.mode==="direct"})),u++}catch(m){throw this.#a?.(m),this.#o(),new nd(this.#h("restart",{attempt:l,maxAttempts:s,restarts:u,lastError:m}),{cause:m})}}throw this.#a?.(new Error("computerd never became healthy")),this.#o(),new nd(this.#h("health",{attempt:l,maxAttempts:s,restarts:u,lastError:d,priorExit:r}),d instanceof Error?{cause:d}:void 0)}async#m(e,t){let n=this.#e.healthRetryInitialDelayMs,r;for(;Date.now()<t;)try{await Afr(e,{port:this.#e.containerPort,path:"/health",timeoutMs:Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now()))});return}catch(i){r=i;let s=t-Date.now();if(s<=0)break;await Ufr(Math.min(n,s)),n=Math.min(n*2,this.#e.healthRetryMaxDelayMs)}throw r??new Error("computerd health probe timed out")}#h(e,t){let n=t.priorExit?` priorExit=${JSON.stringify(t.priorExit.reason)}`:"";return`CloudflareContainerBackend(${this.id}): connect failed at stage=${e} port=${this.#e.containerPort} attempt=${t.attempt}/${t.maxAttempts} restarts=${t.restarts} timeoutMs=${this.#e.connectTimeoutMs}${n} lastError=${CIt(t.lastError)}`}async#l(e,t){let n;try{let r=await e.fetchPort(this.#e.containerPort,"http://container/api",{signal:AbortSignal.timeout(Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now())))});n=r.status,await r.text().catch(()=>"")}catch{return}if(n!==401)throw this.#a?.(new Error("container is not enforcing RPC_CLIENT_SECRET")),this.#o(),new nd(`CloudflareContainerBackend(${this.id}) [stage=auth]: container served an unauthenticated request to /api with ${n}, so this workspace would run without authorization. A container or image predating RPC_CLIENT_SECRET has to be recycled.`)}async#f(e,t,n){let r=Math.max(0,t-Date.now()),i;try{i=await e.fetchPort(this.#e.containerPort,"http://container/connect",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},body:JSON.stringify({base:`http://${this.#e.egressHost}`,health:Rfr,api:d3e,healthTimeoutMs:r})})}catch(s){throw this.#a?.(s),this.#o(),new nd(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect failed: ${CIt(s)}`,{cause:s})}if(!i.ok){let s=await i.text().catch(()=>""),o=new Error(`/connect ${i.status}`);throw this.#a?.(o),this.#o(),new nd(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect returned ${i.status}: ${s}`,{cause:o})}}async#d(e){let t=this.#i;if(!t)throw new Error("CloudflareContainerBackend: upgrade promise missing");let n=Math.max(0,e-Date.now()),r;try{return await Promise.race([t,new Promise((i,s)=>{r=setTimeout(()=>s(new nd(`CloudflareContainerBackend(${this.id}) [stage=ws]: /api upgrade did not arrive within ${this.#e.connectTimeoutMs}ms`)),n)})])}finally{r&&clearTimeout(r),this.#o()}}};function Ufr(e){return new Promise(t=>setTimeout(t,e))}a(Ufr,"sleep");function CIt(e){return e instanceof Error?e.message:String(e)}a(CIt,"describeError");var PIt="computer:container-client-secret",Ffr=16;function jfr(){let e=crypto.getRandomValues(new Uint8Array(Ffr));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}a(jfr,"generate");var qfr=class{static{a(this,"ContainerClientSecret")}storage;constructor(e){this.storage=e}async ensure(){let e=await this.storage.get(PIt);if(typeof e=="string"&&e.length>0)return e;let t=jfr();return await this.storage.put(PIt,t),t}},OIt="computer:container-launch-record";async function MIt(e){return{enableInternet:e.enableInternet,envDigest:await Bfr(e.env)}}a(MIt,"launchRecordFor");function Wfr(e,t){return e.enableInternet===t.enableInternet&&e.envDigest===t.envDigest}a(Wfr,"sameLaunch");async function Bfr(e){let t=Object.keys(e).sort().map(r=>`${r.length}:${r}=${e[r]?.length??0}:${e[r]??""}`).join(";"),n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}a(Bfr,"digestEnv");var zfr=class{static{a(this,"CurrentContainerLaunchRecord")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(OIt)??null}async set(e){await this.storage.put(OIt,e)}},NIt=new WeakMap;function m3e(e){let t=NIt.get(e);return t===void 0&&(t={exit:null,currentGeneration:0,expectedExitGeneration:null,currentMonitorSettled:null},NIt.set(e,t)),t}a(m3e,"getContainerLifecycle");function Bee(e){return m3e(e).exit}a(Bee,"containerExitInfo");function LIt(e){return e===void 0?"exited normally":e instanceof Error?e.message:String(e)}a(LIt,"formatExitReason");function DIt(e,t,n){let r=m3e(e);r.currentGeneration+=1;let i=r.currentGeneration;r.exit=null,r.currentMonitorSettled=t.monitor().then(()=>$It(r,i,void 0,n),s=>$It(r,i,s,n))}a(DIt,"installContainerMonitor");async function p3e(e,t){let n=m3e(e);n.expectedExitGeneration=n.currentGeneration;let r=n.currentMonitorSettled;await t.destroy(),r&&await r}a(p3e,"destroyContainerExpectingExit");async function $It(e,t,n,r){if(t!==e.currentGeneration)return;let i=e.expectedExitGeneration===t;i&&(e.expectedExitGeneration=null);let s=LIt(n),o=Date.now();e.exit={reason:s,exitedAt:o},i?console.info({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!0}):console.warn({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!1});try{await r?.()}catch(c){console.error({message:"workspace.container.exit_cleanup_failed",reason:LIt(c),exitedAt:Date.now()})}}a($It,"recordExit");var h3e="computer:container-runtime-identity",Hfr=class{static{a(this,"CurrentContainerRuntimeIdentity")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(h3e)??null}async markStarted(){let e={id:crypto.randomUUID()};return await this.storage.put(h3e,e),e}async clear(e){(await this.get())?.id===e.id&&await this.storage.delete(h3e)}},Gfr=class extends Efr{static{a(this,"WorkspaceContainerAPI")}#e;#n;#r;#t;#i;constructor(e){if(super(),!e.container)throw new Error("WorkspaceContainerAPI: DO is not container-enabled (check wrangler.jsonc)");this.#e=e.container,this.#n=e,this.#r=new Hfr(e.storage),this.#t=new qfr(e.storage),this.#i=new zfr(e.storage)}async start(e){let t=Bee(this.#n),n=await this.#t.ensure(),r=await MIt(e);if(t!==null){try{await p3e(this.#n,this.#e)}catch{}return this.#s(e,n,r,"launched")}if(!this.#e.running)return this.#s(e,n,r,"launched");let i=await this.#i.get();if(i===null||!Wfr(i,r)){console.warn({message:i===null?"container was started outside WorkspaceContainerAPI; relaunching so the requested environment applies":"running container was launched with a different spec; relaunching",component:"workspace-container",requested:r,actual:i});try{await p3e(this.#n,this.#e)}catch{}return this.#s(e,n,r,"relaunched")}let s=await this.#r.get()??await this.#r.markStarted();return DIt(this.#n,this.#e,()=>this.#r.clear(s)),{runtimeId:s.id,clientSecret:n,outcome:"adopted"}}async restart(e){try{await p3e(this.#n,this.#e)}catch{}let t=await this.#t.ensure();return this.#s(e,t,await MIt(e),"launched")}async setInactivityTimeout(e){await this.#e.setInactivityTimeout(e)}async#s(e,t,n,r){let i=await this.#r.markStarted();try{this.#e.start({enableInternet:e.enableInternet,env:{...e.env,RPC_CLIENT_SECRET:t}})}catch(s){throw await this.#r.clear(i),s}return await this.#i.set(n),DIt(this.#n,this.#e,()=>this.#r.clear(i)),{runtimeId:i.id,clientSecret:t,outcome:r}}async status(){return{running:this.#e.running,exit:Bee(this.#n)}}async exitInfo(){return Bee(this.#n)}async interceptAllOutboundHttp(e,t){let n=this.#n.exports.WorkspaceProxy({props:{...e,egressToken:t}});await Promise.all([this.#e.interceptAllOutboundHttp(n),this.#e.interceptOutboundHttps("*",n)])}async interceptOutboundHttp(e,t){let n=this.#n.exports;await this.#e.interceptOutboundHttp(e,n.WorkspaceProxy({props:t}))}fetchPort(e,t,n){let r=Bee(this.#n);if(r!==null)throw new nd(`container exited: ${r.reason}`);return this.#e.getTcpPort(e).fetch(t,n)}port(e){return this.#e.getTcpPort(e)}};function UIt(e){class t extends e{static{a(this,"WithWorkspaceContainer")}getWorkspaceContainer(){return new Gfr(this.ctx)}}return t}a(UIt,"withWorkspaceContainer");var Vfr={session:"sessions",skill:"skills",agentPreset:"agentPresets",subagent:"subagents",goal:"goals",event:"events",download:"downloads"};function jIt(e,t){let n=t.indexOf("."),r=t.indexOf("/"),i=n>=0?n:r;if(i<0)return;let s=t.slice(0,i),o=t.slice(i+1),c=Vfr[s]??s,l=e[c];if(l===void 0)return;let u=l[o];return typeof u=="function"?u:void 0}a(jIt,"resolve");function Kfr(e,t){return Response.json({type:"server-response",rpcId:e,result:{ok:!1,error:t}})}a(Kfr,"errorResponse");async function f3e(e,t,n,r,i){let s=jIt(e,t);if(s!==void 0)return await s({rpcId:n,payload:r},i)}a(f3e,"callEdgeApi");async function qIt(e,t){let r=new URL(t.url).pathname;if(t.method!=="POST"||!r.startsWith("/api/"))return new Response("not found",{status:404});if(r==="/api/respond")return Response.json({accepted:!1,reason:"not-pending"});let i=r.slice(5);if(jIt(e,i)===void 0)return new Response("not found",{status:404});let s;try{s=await t.json()}catch{return new Response("body is not JSON",{status:400})}let o=typeof s.rpcId=="string"?s.rpcId:"invalid-request",c=s.payload??{};try{let l=await f3e(e,i,o,c,t.signal);return l===void 0?new Response("not found",{status:404}):Response.json({type:"server-response",rpcId:l.rpcId,result:l.result})}catch(l){return Kfr(o,{code:"internal",message:String(l),details:{}})}}a(qIt,"dispatchEdgeApi");Fr();Eo();cb();import{DurableObject as L6r}from"cloudflare:workers";var Hee=class{constructor(t,n=Date.now,r=2){this.sleepAfterMs=t;this.now=n;this.maxConcurrent=r}sleepAfterMs;now;maxConcurrent;static{a(this,"ContainerActivity")}inFlight=0;lastActivity;stopping;waiters=[];async admit(t){let n=this.now();for(;this.stopping!==void 0||this.inFlight>=this.maxConcurrent;){if(t?.throwIfAborted(),this.stopping!==void 0){await Qfr(this.stopping,t);continue}await new Promise((r,i)=>{let s=a(()=>{t?.removeEventListener("abort",o),r()},"wake"),o=a(()=>{let c=this.waiters.indexOf(s);c!==-1&&this.waiters.splice(c,1),i(t.reason)},"abort");this.waiters.push(s),t?.addEventListener("abort",o,{once:!0})})}return t?.aborted===!0&&(this.waiters.shift()?.(),t.throwIfAborted()),{release:this.begin(),queuedMs:this.now()-n}}begin(){this.inFlight+=1,this.lastActivity=this.now();let t=!1;return()=>{t||(t=!0,this.inFlight-=1,this.lastActivity=this.now(),this.waiters.shift()?.())}}async stopIfIdle(t){return this.idle()?await this.stop(t):"busy"}async stopNow(t){return this.inFlight===0?await this.stop(t):"busy"}snapshot(){return{runningCommands:this.inFlight,lastActivityAt:this.lastActivity??null}}async stop(t){if(this.stopping!==void 0)return"busy";let n="stopped",r=t().catch(i=>{n="failed",this.lastActivity=this.now(),console.error("dsh-edge container stop failed.",i)});this.stopping=r;try{await r}finally{this.stopping=void 0}return n}deadline(){return this.inFlight>0?this.now()+this.sleepAfterMs():this.lastActivity===void 0?this.now():this.lastActivity+this.sleepAfterMs()}idle(){return this.inFlight===0&&(this.lastActivity===void 0||this.now()>=this.lastActivity+this.sleepAfterMs())}};function Qfr(e,t){return t===void 0?e:new Promise((n,r)=>{let i=a(()=>r(t.reason),"abort");t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",i))})}a(Qfr,"untilAborted");import{WorkerEntrypoint as Hss}from"cloudflare:workers";var oT=ll(WIt(),1);import{gunzipSync as eyr}from"node:zlib";var _D=class{static{a(this,"Diff")}diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);let s=this.castInput(t,r),o=this.castInput(n,r),c=this.removeEmpty(this.tokenize(s,r)),l=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(c,l,r,i)}diffWithOptionsObj(t,n,r,i){var s;let o=a(b=>{if(b=this.postProcess(b,r),i){setTimeout(function(){i(b)},0);return}else return b},"done"),c=n.length,l=t.length,u=1,d=c+l;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(s=r.timeout)!==null&&s!==void 0?s:1/0,h=Date.now()+p,m=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(m[0],n,t,0,r);if(m[0].oldPos+1>=l&&f+1>=c)return o(this.buildValues(m[0].lastComponent,n,t));let g=-1/0,v=1/0,x=a(()=>{for(let b=Math.max(g,-u);b<=Math.min(v,u);b+=2){let w,k=m[b-1],E=m[b+1];k&&(m[b-1]=void 0);let A=!1;if(E){let M=E.oldPos-b;A=E&&0<=M&&M<c}let I=k&&k.oldPos+1<l;if(!A&&!I){m[b]=void 0;continue}if(!I||A&&k.oldPos<E.oldPos?w=this.addToPath(E,!0,!1,0,r):w=this.addToPath(k,!1,!0,1,r),f=this.extractCommon(w,n,t,b,r),w.oldPos+1>=l&&f+1>=c)return o(this.buildValues(w.lastComponent,n,t))||!0;m[b]=w,w.oldPos+1>=l&&(v=Math.min(v,b-1)),f+1>=c&&(g=Math.max(g,b+1))}u++},"execEditLength");if(i)a(function b(){setTimeout(function(){if(u>d||Date.now()>h)return i(void 0);x()||b()},0)},"exec")();else for(;u<=d&&Date.now()<=h;){let b=x();if(b)return b}}addToPath(t,n,r,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:r,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:o}}}extractCommon(t,n,r,i,s){let o=n.length,c=r.length,l=t.oldPos,u=l-i,d=0;for(;u+1<o&&l+1<c&&this.equals(r[l+1],n[u+1],s);)u++,l++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=l,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,c=0,l=0,u=0;for(;c<o;c++){let d=i[c];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(l,l+d.count);p=p.map(function(h,m){let f=r[u+m];return f.length>h.length?f:h}),d.value=this.join(p)}else d.value=this.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}}return i}};var g3e=class extends _D{static{a(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=Yfr}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
7230
|
+
`}a(RIt,"pageStyles");hO();var s3e="enabled",o3e=Object.freeze({id:"direct",capabilities:Object.freeze(["bash"]),plan:"free",shell:"just-bash-direct",probe:a(e=>e.LOADER===void 0?"available":"needs-binding","probe")}),kD=Object.freeze({id:"dynamic-worker",capabilities:Object.freeze(["bash","coding"]),plan:"paid",shell:"just-bash-isolated",probe:a(e=>e.LOADER===void 0?"needs-binding":"available","probe")}),a3e=Object.freeze({id:"container",capabilities:Object.freeze(["container"]),plan:"paid",shell:"linux-container",probe:a(e=>e.DSH_EDGE_CONTAINER_RUNTIME===s3e?"available":"needs-binding","probe")}),wfr=Object.freeze([a3e,kD,o3e]);function c3e(e,t=wfr){return t.filter(n=>n.probe(e)==="available")}a(c3e,"availableEdgeRuntimeProviders");function l3e(e){let t=a(r=>e.find(i=>i.capabilities.includes(r)),"first"),n=t("bash");if(n===void 0)throw new Error("No available runtime provider serves the bash layer.");return{bash:n.id,container:t("container")?.id??null}}a(l3e,"resolveEdgeRuntimeSelection");function qee(e){let t=c3e(e),{bash:n,container:r}=l3e(t);return t.find(i=>i.id===(r??n)).shell}a(qee,"resolveEdgeRuntimeShell");function kfr(){return"dsh-edge@0.27.2/direct"}a(kfr,"resolveEdgeDeploymentId");function RE(e){return{baseURL:TTe(e.DEEPSEEK_BASE_URL),maxTokens:RTe(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:GS(e.DEEPSEEK_MODEL),reasoningEffort:ATe(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:ML(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:ITe(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:S2(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a(RE,"resolveEdgeDeploymentConfig");function _fr(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}a(_fr,"edgeDeploymentApiKeyConfigured");function Sfr(e){let t=TTe(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}a(Sfr,"projectedEdgeBaseURL");function u3e(e,t){return{shell:qee(e),storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:kfr(),apiKeyConfigured:_fr(e),baseURL:Sfr(e.DEEPSEEK_BASE_URL),maxTokens:RTe(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:GS(e.DEEPSEEK_MODEL),reasoningEffort:ATe(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:ML(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:ITe(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:S2(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}a(u3e,"resolveEdgeDeploymentProfile");function Wee(e){RE(e);let t=u3e(e);return{ok:!0,service:"dsh-edge",storage:t.storage,attachmentStorage:t.attachmentStorage,shell:t.shell,agent:"upstream-react-loop-agent",access:"single-owner-cookie",deploymentId:t.deploymentId,...e.CF_VERSION_METADATA===void 0?{}:{workerVersionId:e.CF_VERSION_METADATA.id},version:u_,upstreamVersion:bQe,status:"ready"}}a(Wee,"resolveEdgeDeploymentHealth");import{AsyncLocalStorage as N6r}from"node:async_hooks";import{RpcTarget as Efr}from"cloudflare:workers";function Tfr(e){let{intervalMs:t,ping:n,onFailure:r}=e,i=!1,s=setInterval(()=>{i||n().catch(o=>{i||(i=!0,clearInterval(s),r(o instanceof Error?o:new Error(String(o))))})},t);return()=>{i||(i=!0,clearInterval(s))}}a(Tfr,"startHeartbeat");async function Afr(e,t){let n=AbortSignal.timeout(t.timeoutMs),r=await e.fetchPort(t.port,`http://container${t.path}`,{method:"HEAD",signal:n});if(r.body?.cancel(),!r.ok)throw new Error(`computerd health returned ${r.status}`)}a(Afr,"probeComputerdHealth");var Ifr="computer.internal",Rfr="/health",d3e="/api",Cfr=8080,Pfr=3e4,Ofr=2e4,Mfr=1,Nfr=2e3,Lfr=250,Dfr=2e3;function $fr(e,t){if(t===void 0||e===null)return!1;let n=e.indexOf(" ");if(n===-1||e.slice(0,n).toLowerCase()!=="bearer")return!1;let r=e.slice(n+1).trim();if(r.length!==t.length)return!1;let i=0;for(let s=0;s<t.length;s+=1)i|=r.charCodeAt(s)^t.charCodeAt(s);return i===0}a($fr,"bearerMatches");var zee=class{static{a(this,"CloudflareContainerBackend")}type="cloudflare-container";id;#e;#n;#r;#t;#i;#s;#a;#u;constructor(e){this.id=e.id??"container-shell",this.#n=e.egress??{mode:"none"},this.#r=this.#n.mode==="http-gateway"?crypto.randomUUID():void 0,this.#e={container:e.container,workspace:e.workspace,containerEnv:e.containerEnv,egressHost:e.egressHost??Ifr,containerPort:e.containerPort??Cfr,connectTimeoutMs:e.connectTimeoutMs??Pfr,heartbeatIntervalMs:e.heartbeatIntervalMs??Ofr,restartAttempts:e.restartAttempts??Mfr,healthProbeTimeoutMs:e.healthProbeTimeoutMs??Nfr,healthRetryInitialDelayMs:e.healthRetryInitialDelayMs??Lfr,healthRetryMaxDelayMs:e.healthRetryMaxDelayMs??Dfr}}async connect(){if(this.#u)return this.#u;let e=Date.now()+this.#e.connectTimeoutMs,t=await(await this.#e.container()).getWorkspaceContainer(),n=await t.exitInfo().catch(()=>null),r={PORT:String(this.#e.containerPort),MOUNT_POINT:"/workspace",...this.#e.containerEnv},i,s;try{({runtimeId:i,clientSecret:s}=await t.start({env:r,enableInternet:this.#n.mode==="direct"}))}catch(p){throw new nd(this.#h("start",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}try{await t.interceptOutboundHttp(this.#e.egressHost,this.#e.workspace),this.#n.mode==="http-gateway"&&this.#r!==void 0&&await t.interceptAllOutboundHttp(this.#e.workspace,this.#r)}catch(p){throw new nd(this.#h("egress",{attempt:1,maxAttempts:this.#e.restartAttempts+1,restarts:0,lastError:p,priorExit:n}),{cause:p})}this.#t=s,this.#c(),i=await this.#p(t,r,e,n,i),await this.#l(t,e),await this.#f(t,e,s);let o=await this.#d(e),c=yre(o),l,u=new Promise(p=>{let h=!1,m=a(()=>{h||(h=!0,l?.(),p(),this.#u=void 0)},"onClose");o.addEventListener("close",m,{once:!0}),o.addEventListener("error",m,{once:!0}),c.onRpcBroken(m)});this.#e.heartbeatIntervalMs>0&&(l=Tfr({intervalMs:this.#e.heartbeatIntervalMs,ping:a(()=>c.sync.watermarks(),"ping"),onFailure:a(()=>{try{o.close()}catch{}},"onFailure")}));let d={rpc:c,runtimeId:i,closed:u,close:a(async()=>{l?.();try{c[Symbol.dispose]?.()}catch{}try{o.close()}catch{}this.#u=void 0},"close")};return this.#u=d,d}async handleFetch(e){if(this.#n.mode==="http-gateway"&&this.#r!==void 0&&e.headers.get("x-workspace-egress-token")===this.#r){let i=new Headers(e.headers),s=i.get(u3),o;try{o=new URL(s??"")}catch{return new Response("invalid egress URL",{status:400})}if(o.protocol!=="http:"&&o.protocol!=="https:")return new Response("invalid egress URL",{status:400});i.delete(N$),i.delete(u3);let c=new Request(e,{headers:i});return this.#n.gateway.fetch(new Request(o,c))}if(new URL(e.url).pathname!==d3e)return new Response("not found",{status:404});if(e.headers.get("upgrade")!=="websocket")return new Response(`${d3e} requires a websocket upgrade`,{status:400});if(!$fr(e.headers.get("authorization"),this.#t))return new Response("unauthorized",{status:401,headers:{"www-authenticate":"Bearer"}});let t=new WebSocketPair,[n,r]=[t[0],t[1]];if(r.accept(),this.#s)this.#s(r);else return r.close(1011,"no pending connect"),new Response("no pending connect",{status:409});return new Response(null,{status:101,webSocket:n})}#c(){this.#i=new Promise((e,t)=>{this.#s=e,this.#a=t}),this.#i.catch(()=>{})}#o(){this.#i=void 0,this.#s=void 0,this.#a=void 0}async#p(e,t,n,r,i){let s=this.#e.restartAttempts+1,o=Math.max(0,n-Date.now()),c=Math.max(250,Math.floor(o/s)),l=0,u=0,d,p=i;for(;l<s;){l++;let h=Math.min(n,Date.now()+c);if(await this.#m(e,h).then(()=>!0,m=>(d=m,!1)))return p;if(l<s)try{({runtimeId:p}=await e.restart({env:t,enableInternet:this.#n.mode==="direct"})),u++}catch(m){throw this.#a?.(m),this.#o(),new nd(this.#h("restart",{attempt:l,maxAttempts:s,restarts:u,lastError:m}),{cause:m})}}throw this.#a?.(new Error("computerd never became healthy")),this.#o(),new nd(this.#h("health",{attempt:l,maxAttempts:s,restarts:u,lastError:d,priorExit:r}),d instanceof Error?{cause:d}:void 0)}async#m(e,t){let n=this.#e.healthRetryInitialDelayMs,r;for(;Date.now()<t;)try{await Afr(e,{port:this.#e.containerPort,path:"/health",timeoutMs:Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now()))});return}catch(i){r=i;let s=t-Date.now();if(s<=0)break;await Ufr(Math.min(n,s)),n=Math.min(n*2,this.#e.healthRetryMaxDelayMs)}throw r??new Error("computerd health probe timed out")}#h(e,t){let n=t.priorExit?` priorExit=${JSON.stringify(t.priorExit.reason)}`:"";return`CloudflareContainerBackend(${this.id}): connect failed at stage=${e} port=${this.#e.containerPort} attempt=${t.attempt}/${t.maxAttempts} restarts=${t.restarts} timeoutMs=${this.#e.connectTimeoutMs}${n} lastError=${CIt(t.lastError)}`}async#l(e,t){let n;try{let r=await e.fetchPort(this.#e.containerPort,"http://container/api",{signal:AbortSignal.timeout(Math.min(this.#e.healthProbeTimeoutMs,Math.max(50,t-Date.now())))});n=r.status,await r.text().catch(()=>"")}catch{return}if(n!==401)throw this.#a?.(new Error("container is not enforcing RPC_CLIENT_SECRET")),this.#o(),new nd(`CloudflareContainerBackend(${this.id}) [stage=auth]: container served an unauthenticated request to /api with ${n}, so this workspace would run without authorization. A container or image predating RPC_CLIENT_SECRET has to be recycled.`)}async#f(e,t,n){let r=Math.max(0,t-Date.now()),i;try{i=await e.fetchPort(this.#e.containerPort,"http://container/connect",{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`},body:JSON.stringify({base:`http://${this.#e.egressHost}`,health:Rfr,api:d3e,healthTimeoutMs:r})})}catch(s){throw this.#a?.(s),this.#o(),new nd(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect failed: ${CIt(s)}`,{cause:s})}if(!i.ok){let s=await i.text().catch(()=>""),o=new Error(`/connect ${i.status}`);throw this.#a?.(o),this.#o(),new nd(`CloudflareContainerBackend(${this.id}) [stage=connect]: POST /connect returned ${i.status}: ${s}`,{cause:o})}}async#d(e){let t=this.#i;if(!t)throw new Error("CloudflareContainerBackend: upgrade promise missing");let n=Math.max(0,e-Date.now()),r;try{return await Promise.race([t,new Promise((i,s)=>{r=setTimeout(()=>s(new nd(`CloudflareContainerBackend(${this.id}) [stage=ws]: /api upgrade did not arrive within ${this.#e.connectTimeoutMs}ms`)),n)})])}finally{r&&clearTimeout(r),this.#o()}}};function Ufr(e){return new Promise(t=>setTimeout(t,e))}a(Ufr,"sleep");function CIt(e){return e instanceof Error?e.message:String(e)}a(CIt,"describeError");var PIt="computer:container-client-secret",Ffr=16;function jfr(){let e=crypto.getRandomValues(new Uint8Array(Ffr));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}a(jfr,"generate");var qfr=class{static{a(this,"ContainerClientSecret")}storage;constructor(e){this.storage=e}async ensure(){let e=await this.storage.get(PIt);if(typeof e=="string"&&e.length>0)return e;let t=jfr();return await this.storage.put(PIt,t),t}},OIt="computer:container-launch-record";async function MIt(e){return{enableInternet:e.enableInternet,envDigest:await Bfr(e.env)}}a(MIt,"launchRecordFor");function Wfr(e,t){return e.enableInternet===t.enableInternet&&e.envDigest===t.envDigest}a(Wfr,"sameLaunch");async function Bfr(e){let t=Object.keys(e).sort().map(r=>`${r.length}:${r}=${e[r]?.length??0}:${e[r]??""}`).join(";"),n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}a(Bfr,"digestEnv");var zfr=class{static{a(this,"CurrentContainerLaunchRecord")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(OIt)??null}async set(e){await this.storage.put(OIt,e)}},NIt=new WeakMap;function m3e(e){let t=NIt.get(e);return t===void 0&&(t={exit:null,currentGeneration:0,expectedExitGeneration:null,currentMonitorSettled:null},NIt.set(e,t)),t}a(m3e,"getContainerLifecycle");function Bee(e){return m3e(e).exit}a(Bee,"containerExitInfo");function LIt(e){return e===void 0?"exited normally":e instanceof Error?e.message:String(e)}a(LIt,"formatExitReason");function DIt(e,t,n){let r=m3e(e);r.currentGeneration+=1;let i=r.currentGeneration;r.exit=null,r.currentMonitorSettled=t.monitor().then(()=>$It(r,i,void 0,n),s=>$It(r,i,s,n))}a(DIt,"installContainerMonitor");async function p3e(e,t){let n=m3e(e);n.expectedExitGeneration=n.currentGeneration;let r=n.currentMonitorSettled;await t.destroy(),r&&await r}a(p3e,"destroyContainerExpectingExit");async function $It(e,t,n,r){if(t!==e.currentGeneration)return;let i=e.expectedExitGeneration===t;i&&(e.expectedExitGeneration=null);let s=LIt(n),o=Date.now();e.exit={reason:s,exitedAt:o},i?console.info({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!0}):console.warn({message:"workspace.container.exited",reason:s,exitedAt:o,expected:!1});try{await r?.()}catch(c){console.error({message:"workspace.container.exit_cleanup_failed",reason:LIt(c),exitedAt:Date.now()})}}a($It,"recordExit");var h3e="computer:container-runtime-identity",Hfr=class{static{a(this,"CurrentContainerRuntimeIdentity")}storage;constructor(e){this.storage=e}async get(){return await this.storage.get(h3e)??null}async markStarted(){let e={id:crypto.randomUUID()};return await this.storage.put(h3e,e),e}async clear(e){(await this.get())?.id===e.id&&await this.storage.delete(h3e)}},Gfr=class extends Efr{static{a(this,"WorkspaceContainerAPI")}#e;#n;#r;#t;#i;constructor(e){if(super(),!e.container)throw new Error("WorkspaceContainerAPI: DO is not container-enabled (check wrangler.jsonc)");this.#e=e.container,this.#n=e,this.#r=new Hfr(e.storage),this.#t=new qfr(e.storage),this.#i=new zfr(e.storage)}async start(e){let t=Bee(this.#n),n=await this.#t.ensure(),r=await MIt(e);if(t!==null){try{await p3e(this.#n,this.#e)}catch{}return this.#s(e,n,r,"launched")}if(!this.#e.running)return this.#s(e,n,r,"launched");let i=await this.#i.get();if(i===null||!Wfr(i,r)){console.warn({message:i===null?"container was started outside WorkspaceContainerAPI; relaunching so the requested environment applies":"running container was launched with a different spec; relaunching",component:"workspace-container",requested:r,actual:i});try{await p3e(this.#n,this.#e)}catch{}return this.#s(e,n,r,"relaunched")}let s=await this.#r.get()??await this.#r.markStarted();return DIt(this.#n,this.#e,()=>this.#r.clear(s)),{runtimeId:s.id,clientSecret:n,outcome:"adopted"}}async restart(e){try{await p3e(this.#n,this.#e)}catch{}let t=await this.#t.ensure();return this.#s(e,t,await MIt(e),"launched")}async setInactivityTimeout(e){await this.#e.setInactivityTimeout(e)}async#s(e,t,n,r){let i=await this.#r.markStarted();try{this.#e.start({enableInternet:e.enableInternet,env:{...e.env,RPC_CLIENT_SECRET:t}})}catch(s){throw await this.#r.clear(i),s}return await this.#i.set(n),DIt(this.#n,this.#e,()=>this.#r.clear(i)),{runtimeId:i.id,clientSecret:t,outcome:r}}async status(){return{running:this.#e.running,exit:Bee(this.#n)}}async exitInfo(){return Bee(this.#n)}async interceptAllOutboundHttp(e,t){let n=this.#n.exports.WorkspaceProxy({props:{...e,egressToken:t}});await Promise.all([this.#e.interceptAllOutboundHttp(n),this.#e.interceptOutboundHttps("*",n)])}async interceptOutboundHttp(e,t){let n=this.#n.exports;await this.#e.interceptOutboundHttp(e,n.WorkspaceProxy({props:t}))}fetchPort(e,t,n){let r=Bee(this.#n);if(r!==null)throw new nd(`container exited: ${r.reason}`);return this.#e.getTcpPort(e).fetch(t,n)}port(e){return this.#e.getTcpPort(e)}};function UIt(e){class t extends e{static{a(this,"WithWorkspaceContainer")}getWorkspaceContainer(){return new Gfr(this.ctx)}}return t}a(UIt,"withWorkspaceContainer");var Vfr={session:"sessions",skill:"skills",agentPreset:"agentPresets",subagent:"subagents",goal:"goals",event:"events",download:"downloads"};function jIt(e,t){let n=t.indexOf("."),r=t.indexOf("/"),i=n>=0?n:r;if(i<0)return;let s=t.slice(0,i),o=t.slice(i+1),c=Vfr[s]??s,l=e[c];if(l===void 0)return;let u=l[o];return typeof u=="function"?u:void 0}a(jIt,"resolve");function Kfr(e,t){return Response.json({type:"server-response",rpcId:e,result:{ok:!1,error:t}})}a(Kfr,"errorResponse");async function f3e(e,t,n,r,i){let s=jIt(e,t);if(s!==void 0)return await s({rpcId:n,payload:r},i)}a(f3e,"callEdgeApi");async function qIt(e,t){let r=new URL(t.url).pathname;if(t.method!=="POST"||!r.startsWith("/api/"))return new Response("not found",{status:404});if(r==="/api/respond")return Response.json({accepted:!1,reason:"not-pending"});let i=r.slice(5);if(jIt(e,i)===void 0)return new Response("not found",{status:404});let s;try{s=await t.json()}catch{return new Response("body is not JSON",{status:400})}let o=typeof s.rpcId=="string"?s.rpcId:"invalid-request",c=s.payload??{};try{let l=await f3e(e,i,o,c,t.signal);return l===void 0?new Response("not found",{status:404}):Response.json({type:"server-response",rpcId:l.rpcId,result:l.result})}catch(l){return Kfr(o,{code:"internal",message:String(l),details:{}})}}a(qIt,"dispatchEdgeApi");Fr();Eo();cb();import{DurableObject as L6r}from"cloudflare:workers";var Hee=class{constructor(t,n=Date.now,r=2){this.sleepAfterMs=t;this.now=n;this.maxConcurrent=r}sleepAfterMs;now;maxConcurrent;static{a(this,"ContainerActivity")}inFlight=0;lastActivity;stopping;waiters=[];async admit(t){let n=this.now();for(;this.stopping!==void 0||this.inFlight>=this.maxConcurrent;){if(t?.throwIfAborted(),this.stopping!==void 0){await Qfr(this.stopping,t);continue}await new Promise((r,i)=>{let s=a(()=>{t?.removeEventListener("abort",o),r()},"wake"),o=a(()=>{let c=this.waiters.indexOf(s);c!==-1&&this.waiters.splice(c,1),i(t.reason)},"abort");this.waiters.push(s),t?.addEventListener("abort",o,{once:!0})})}return t?.aborted===!0&&(this.waiters.shift()?.(),t.throwIfAborted()),{release:this.begin(),queuedMs:this.now()-n}}begin(){this.inFlight+=1,this.lastActivity=this.now();let t=!1;return()=>{t||(t=!0,this.inFlight-=1,this.lastActivity=this.now(),this.waiters.shift()?.())}}async stopIfIdle(t){return this.idle()?await this.stop(t):"busy"}async stopNow(t){return this.inFlight===0?await this.stop(t):"busy"}snapshot(){return{runningCommands:this.inFlight,lastActivityAt:this.lastActivity??null}}async stop(t){if(this.stopping!==void 0)return"busy";let n="stopped",r=t().catch(i=>{n="failed",this.lastActivity=this.now(),console.error("dsh-edge container stop failed.",i)});this.stopping=r;try{await r}finally{this.stopping=void 0}return n}deadline(){return this.inFlight>0?this.now()+this.sleepAfterMs():this.lastActivity===void 0?this.now():this.lastActivity+this.sleepAfterMs()}idle(){return this.inFlight===0&&(this.lastActivity===void 0||this.now()>=this.lastActivity+this.sleepAfterMs())}};function Qfr(e,t){return t===void 0?e:new Promise((n,r)=>{let i=a(()=>r(t.reason),"abort");t.addEventListener("abort",i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",i))})}a(Qfr,"untilAborted");import{WorkerEntrypoint as Hss}from"cloudflare:workers";var oT=ll(WIt());import{gunzipSync as eyr}from"node:zlib";var _D=class{static{a(this,"Diff")}diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);let s=this.castInput(t,r),o=this.castInput(n,r),c=this.removeEmpty(this.tokenize(s,r)),l=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(c,l,r,i)}diffWithOptionsObj(t,n,r,i){var s;let o=a(b=>{if(b=this.postProcess(b,r),i){setTimeout(function(){i(b)},0);return}else return b},"done"),c=n.length,l=t.length,u=1,d=c+l;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(s=r.timeout)!==null&&s!==void 0?s:1/0,h=Date.now()+p,m=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(m[0],n,t,0,r);if(m[0].oldPos+1>=l&&f+1>=c)return o(this.buildValues(m[0].lastComponent,n,t));let g=-1/0,v=1/0,x=a(()=>{for(let b=Math.max(g,-u);b<=Math.min(v,u);b+=2){let w,k=m[b-1],E=m[b+1];k&&(m[b-1]=void 0);let A=!1;if(E){let M=E.oldPos-b;A=E&&0<=M&&M<c}let I=k&&k.oldPos+1<l;if(!A&&!I){m[b]=void 0;continue}if(!I||A&&k.oldPos<E.oldPos?w=this.addToPath(E,!0,!1,0,r):w=this.addToPath(k,!1,!0,1,r),f=this.extractCommon(w,n,t,b,r),w.oldPos+1>=l&&f+1>=c)return o(this.buildValues(w.lastComponent,n,t))||!0;m[b]=w,w.oldPos+1>=l&&(v=Math.min(v,b-1)),f+1>=c&&(g=Math.max(g,b+1))}u++},"execEditLength");if(i)a(function b(){setTimeout(function(){if(u>d||Date.now()>h)return i(void 0);x()||b()},0)},"exec")();else for(;u<=d&&Date.now()<=h;){let b=x();if(b)return b}}addToPath(t,n,r,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:r,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:o}}}extractCommon(t,n,r,i,s){let o=n.length,c=r.length,l=t.oldPos,u=l-i,d=0;for(;u+1<o&&l+1<c&&this.equals(r[l+1],n[u+1],s);)u++,l++,d++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!s.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=l,u}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,c=0,l=0,u=0;for(;c<o;c++){let d=i[c];if(d.removed)d.value=this.join(r.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(l,l+d.count);p=p.map(function(h,m){let f=r[u+m];return f.length>h.length?f:h}),d.value=this.join(p)}else d.value=this.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}}return i}};var g3e=class extends _D{static{a(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=Yfr}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
7231
7231
|
`))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
|
|
7232
7232
|
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
|
|
7233
7233
|
`)&&(t=t.slice(0,-1)),n.endsWith(`
|