dsh-edge 0.6.0-alpha.6 → 0.6.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/worker/direct/index.js +11 -9
- package/worker/isolated/index.js +11 -9
package/package.json
CHANGED
package/worker/direct/index.js
CHANGED
|
@@ -515,7 +515,7 @@ ${A}`,f++;break;case"id":A.includes("\0")||(u=A);break;case"retry":/^\d+$/.test(
|
|
|
515
515
|
WHERE session_id = ? AND seq < ?
|
|
516
516
|
AND type IN ('user/message', 'assistant/message')
|
|
517
517
|
AND surface_op = '"append"'
|
|
518
|
-
ORDER BY seq DESC LIMIT ?`,t,a,o).toArray(),u=c.at(-1),d=c.length<o||u===void 0?0:jfe(u);if(d>=a)return{summary:s,events:[],hasMore:d>0};let f=await this.coordinator.readValidatedPage(t,d,bi.maxEvents,(p,h,m,g)=>h!==d?Promise.reject(new Error(`stored session ${t} history contains a legacy event that requires an unbounded prefix`)):this.loadStoredPage(p,h,m,bi.maxStoredBytes,g,a),i);if(f.hasMore)throw new Error(`stored session ${t} history page exceeds the Edge limit of ${bi.maxEvents} events or ${bi.maxStoredBytes} stored bytes`);return{summary:s,events:f.events,hasMore:d>0}}loadStored(t,r){return $s(()=>{r?.throwIfAborted();let n=this.storage.transactionSync(()=>{let o=this.rowFor(t);if(o!==void 0)return{row:o,eventRows:this.eventRows(t,0)}});if(r?.throwIfAborted(),n===void 0)return;let{preserved:i,tornFrom:s}=SP(n.eventRows);return{meta:ao(n.row),events:i,revision:zk(this.storeIdentity,n.row),...s===void 0?{}:{tornMarker:s}}})}readStoredRevision(t,r){return $s(()=>{r?.throwIfAborted();let n=this.rowFor(t);return r?.throwIfAborted(),n===void 0?void 0:zk(this.storeIdentity,n)})}loadStoredFrom(t,r,n){return $s(()=>{n?.throwIfAborted();let i=this.storage.transactionSync(()=>{let s=this.rowFor(t);if(s!==void 0)return{row:s,eventRows:this.eventRows(t,r)}});if(n?.throwIfAborted(),i!==void 0)return{meta:ao(i.row),events:SP(i.eventRows,r).preserved}})}loadStoredPage(t,r,n,i,s,o){return $s(()=>{s?.throwIfAborted();let a=this.storage.transactionSync(()=>{let c=this.rowFor(t);if(c===void 0)return;let u=this.eventRowRangeContaining(t,r,n,o),d=this.lastCommittedSequence(t),f=[],p=0,h=!1,m=r;for(let g of u){let y=new TextEncoder().encode(g.data).byteLength;if(f.length>=n||y>i-p){h=!0;break}let b;try{b=qk(g)}catch{if(g.seq<=d)throw new Error(`corrupt session log: unparsable committed event at seq ${g.seq}`);break}p+=y;for(let w of b)if(!(w.seq<r)&&!(o!==void 0&&w.seq>=o)){if(w.seq!==m){if(w.seq<=d)throw new Error(`corrupt session log: seq gap in committed region (expected ${m}, got ${w.seq})`);h=!1;break}if(f.length>=n){h=!0;break}f.push(w),m=w.seq+1}}return{meta:ao(c),events:f,hasMore:h}});return s?.throwIfAborted(),a})}appendBatch(t,r,n){return $s(()=>{this.storage.transactionSync(()=>{n||this.writeRow(t);let i=u6(r);for(let o of i)this.
|
|
518
|
+
ORDER BY seq DESC LIMIT ?`,t,a,o).toArray(),u=c.at(-1),d=c.length<o||u===void 0?0:jfe(u);if(d>=a)return{summary:s,events:[],hasMore:d>0};let f=await this.coordinator.readValidatedPage(t,d,bi.maxEvents,(p,h,m,g)=>h!==d?Promise.reject(new Error(`stored session ${t} history contains a legacy event that requires an unbounded prefix`)):this.loadStoredPage(p,h,m,bi.maxStoredBytes,g,a),i);if(f.hasMore)throw new Error(`stored session ${t} history page exceeds the Edge limit of ${bi.maxEvents} events or ${bi.maxStoredBytes} stored bytes`);return{summary:s,events:f.events,hasMore:d>0}}loadStored(t,r){return $s(()=>{r?.throwIfAborted();let n=this.storage.transactionSync(()=>{let o=this.rowFor(t);if(o!==void 0)return{row:o,eventRows:this.eventRows(t,0)}});if(r?.throwIfAborted(),n===void 0)return;let{preserved:i,tornFrom:s}=SP(n.eventRows);return{meta:ao(n.row),events:i,revision:zk(this.storeIdentity,n.row),...s===void 0?{}:{tornMarker:s}}})}readStoredRevision(t,r){return $s(()=>{r?.throwIfAborted();let n=this.rowFor(t);return r?.throwIfAborted(),n===void 0?void 0:zk(this.storeIdentity,n)})}loadStoredFrom(t,r,n){return $s(()=>{n?.throwIfAborted();let i=this.storage.transactionSync(()=>{let s=this.rowFor(t);if(s!==void 0)return{row:s,eventRows:this.eventRows(t,r)}});if(n?.throwIfAborted(),i!==void 0)return{meta:ao(i.row),events:SP(i.eventRows,r).preserved}})}loadStoredPage(t,r,n,i,s,o){return $s(()=>{s?.throwIfAborted();let a=this.storage.transactionSync(()=>{let c=this.rowFor(t);if(c===void 0)return;let u=this.eventRowRangeContaining(t,r,n,o),d=this.lastCommittedSequence(t),f=[],p=0,h=!1,m=r;for(let g of u){let y=new TextEncoder().encode(g.data).byteLength;if(f.length>=n||y>i-p){h=!0;break}let b;try{b=qk(g)}catch{if(g.seq<=d)throw new Error(`corrupt session log: unparsable committed event at seq ${g.seq}`);break}p+=y;for(let w of b)if(!(w.seq<r)&&!(o!==void 0&&w.seq>=o)){if(w.seq!==m){if(w.seq<=d)throw new Error(`corrupt session log: seq gap in committed region (expected ${m}, got ${w.seq})`);h=!1;break}if(f.length>=n){h=!0;break}f.push(w),m=w.seq+1}}return{meta:ao(c),events:f,hasMore:h}});return s?.throwIfAborted(),a})}appendBatch(t,r,n){return $s(()=>{this.storage.transactionSync(()=>{n||this.writeRow(t);let i=u6(r);for(let o of i)this.insertStorageRecord(t.id,o);if(this.storage.sql.exec("UPDATE dsh_sessions SET revision = revision + 1 WHERE id = ?",t.id).rowsWritten!==1)throw new Error(`session ${t.id} is not materialized`);this.storage.sql.exec("DELETE FROM dsh_edge_blank_sessions WHERE id = ?",t.id),this.updateSummaryFromBatch(t.id,r)})})}commitRepair(t,r,n){return $s(()=>{this.storage.transactionSync(()=>{r!==void 0&&this.storage.sql.exec("DELETE FROM dsh_session_events WHERE session_id = ? AND seq >= ?",t.id,r);for(let i of n)this.insertEvent(t.id,i);(r!==void 0||n.length>0)&&(this.storage.sql.exec("UPDATE dsh_sessions SET revision = revision + 1 WHERE id = ?",t.id),this.recomputeSummary(t.id))})})}list(t){return $s(()=>{t?.throwIfAborted();let r=this.storage.sql.exec(`SELECT id, version, created_at, cwd, parent_session, seed_length, origin,
|
|
519
519
|
delegation_depth, agent_preset, incarnation, revision
|
|
520
520
|
FROM dsh_sessions`).toArray();t?.throwIfAborted();let n=r.map(ao),i=this.storage.sql.exec(`SELECT id, version, created_at, cwd, parent_session, seed_length, origin,
|
|
521
521
|
delegation_depth, agent_preset
|
|
@@ -535,12 +535,12 @@ ${A}`,f++;break;case"id":A.includes("\0")||(u=A);break;case"retry":/^\d+$/.test(
|
|
|
535
535
|
FROM dsh_edge_blank_sessions ORDER BY created_at DESC, id ASC LIMIT ?`,t).toArray().map(Bk)}materializeBlankSession(t){return $s(()=>this.storage.transactionSync(()=>{let r=this.readBlankSession(t);return r===void 0?!1:(this.rowFor(t)===void 0&&this.writeRow(r),this.storage.sql.exec("DELETE FROM dsh_edge_blank_sessions WHERE id = ?",t),this.insertEmptyLogSummary(t,r.createdAt),!0)}))}readSessionSummary(t){let r=this.storage.sql.exec(`${Kg} WHERE s.id = ?`,t).toArray()[0];return r===void 0?void 0:Yg(r)}readSessionSummaryPage(t,r){return this.storage.transactionSync(()=>{let n=t===void 0?void 0:this.rowFor(t);if(t!==void 0&&n===void 0)return;let i=[],s=n===void 0?"":"WHERE (s.created_at < ? OR (s.created_at = ? AND s.id > ?))";n!==void 0&&i.push(n.created_at,n.created_at,n.id),i.push(r+1);let o=this.storage.sql.exec(`${Kg} ${s}
|
|
536
536
|
ORDER BY s.created_at DESC, s.id ASC LIMIT ?`,...i).toArray();return{sessions:o.slice(0,r).map(Yg),hasMore:o.length>r}})}readAllSessionSummaries(){return this.storage.sql.exec(`${Kg}
|
|
537
537
|
ORDER BY coalesce(sm.last_prompt_at, s.created_at) DESC, s.id ASC`).toArray().map(Yg)}readRecentSessionSummaries(t){return this.storage.sql.exec(`${Kg}
|
|
538
|
-
ORDER BY coalesce(sm.last_prompt_at, s.created_at) DESC, s.id ASC LIMIT ?`,t).toArray().map(Yg)}initialize(){
|
|
538
|
+
ORDER BY coalesce(sm.last_prompt_at, s.created_at) DESC, s.id ASC LIMIT ?`,t).toArray().map(Yg)}initialize(){this.storage.sql.exec("PRAGMA foreign_keys = ON");let t=this.storage.transactionSync(()=>{this.storage.sql.exec(`CREATE TABLE IF NOT EXISTS dsh_session_persistence_state (
|
|
539
539
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
540
540
|
schema_version INTEGER NOT NULL,
|
|
541
541
|
store_id TEXT NOT NULL
|
|
542
|
-
) STRICT`);let
|
|
543
|
-
(singleton, schema_version, store_id) VALUES (1, ?, ?)`,jk,
|
|
542
|
+
) STRICT`);let r=this.storage.sql.exec("SELECT schema_version, store_id FROM dsh_session_persistence_state WHERE singleton = 1").toArray()[0];if(r!==void 0&&r.schema_version!==jk)throw new Error(`dsh-edge session schema ${r.schema_version} is incompatible with ${jk}`);if(r!==void 0&&r.store_id.length===0)throw new Error("dsh-edge session persistence has no valid store identity");r===void 0&&this.removePreCanonicalPrototype();let n=r?.store_id??crypto.randomUUID();return this.storage.sql.exec(`INSERT OR IGNORE INTO dsh_session_persistence_state
|
|
543
|
+
(singleton, schema_version, store_id) VALUES (1, ?, ?)`,jk,n),this.storage.sql.exec(`CREATE TABLE IF NOT EXISTS dsh_sessions (
|
|
544
544
|
id TEXT PRIMARY KEY,
|
|
545
545
|
version INTEGER NOT NULL,
|
|
546
546
|
created_at INTEGER NOT NULL,
|
|
@@ -582,9 +582,9 @@ ${A}`,f++;break;case"id":A.includes("\0")||(u=A);break;case"retry":/^\d+$/.test(
|
|
|
582
582
|
title_seq INTEGER,
|
|
583
583
|
title_time INTEGER,
|
|
584
584
|
title_data TEXT
|
|
585
|
-
) STRICT`),this.syncSummaries()
|
|
586
|
-
WHERE type = 'assistant/chunk' LIMIT 5`).toArray();for(let r of t)try{this.repackOneSession(r.id)}catch(n){console.error(`dsh-edge: repack failed for session ${r.id}
|
|
587
|
-
FROM dsh_session_events WHERE session_id = ? ORDER BY seq`,t).toArray(),n=r.flatMap(s=>qk(s)),i=u6(n);
|
|
585
|
+
) STRICT`),this.syncSummaries(),`durable-object:store:${n}`});return this.repackExistingChunks(),t}repackExistingChunks(){let t=this.storage.sql.exec(`SELECT DISTINCT session_id AS id FROM dsh_session_events
|
|
586
|
+
WHERE type = 'assistant/chunk' LIMIT 5`).toArray();for(let r of t)try{this.repackOneSession(r.id)}catch(n){let i=n instanceof Error?n.message:String(n);console.error(`dsh-edge: repack failed for session ${r.id}: ${i}`)}}repackOneSession(t){let r=this.storage.sql.exec(`SELECT seq, type, time, data, source_event_seqs, surface_op, ignorable
|
|
587
|
+
FROM dsh_session_events WHERE session_id = ? ORDER BY seq`,t).toArray(),n=r.flatMap(s=>qk(s)),i=u6(n);i.length>=r.length||this.storage.transactionSync(()=>{this.storage.sql.exec("DELETE FROM dsh_session_events WHERE session_id = ?",t);for(let s of i)this.insertStorageRecord(t,s)})}syncSummaries(){let t=this.storage.sql.exec(`SELECT s.id FROM dsh_sessions s
|
|
588
588
|
LEFT JOIN dsh_session_summaries sm ON s.id = sm.session_id
|
|
589
589
|
WHERE sm.session_id IS NULL OR sm.revision != s.revision`).toArray();for(let r of t)this.recomputeSummary(r.id)}recomputeSummary(t){let r=this.storage.sql.exec(`${Ufe} WHERE s.id = ?`,t).toArray()[0];r!==void 0&&this.storage.sql.exec(`INSERT INTO dsh_session_summaries
|
|
590
590
|
(session_id, revision, updated_at, last_prompt_at, last_seq, blank,
|
|
@@ -640,7 +640,9 @@ ${A}`,f++;break;case"id":A.includes("\0")||(u=A);break;case"retry":/^\d+$/.test(
|
|
|
640
640
|
delegation_depth = excluded.delegation_depth,
|
|
641
641
|
agent_preset = excluded.agent_preset`,t.id,t.version,t.createdAt,t.cwd??null,t.parentSession??null,t.seedLength??null,t.origin??null,t.delegationDepth??null,t.agentPreset??null,crypto.randomUUID())}insertEvent(t,r){let n=r;this.storage.sql.exec(`INSERT INTO dsh_session_events
|
|
642
642
|
(session_id, seq, type, time, data, source_event_seqs, surface_op, ignorable)
|
|
643
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,t,r.seq,r.type,r.time,JSON.stringify(r.data),n.sourceEventSeqs===void 0?null:JSON.stringify(n.sourceEventSeqs),n.surfaceOp===void 0?null:JSON.stringify(n.surfaceOp),r.ignorable===!0?1:null)}
|
|
643
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,t,r.seq,r.type,r.time,JSON.stringify(r.data),n.sourceEventSeqs===void 0?null:JSON.stringify(n.sourceEventSeqs),n.surfaceOp===void 0?null:JSON.stringify(n.surfaceOp),r.ignorable===!0?1:null)}insertStorageRecord(t,r){let n=r.seq??r.seq0,i=r.time??r.time0,s=r.type;this.storage.sql.exec(`INSERT INTO dsh_session_events
|
|
644
|
+
(session_id, seq, type, time, data, source_event_seqs, surface_op, ignorable)
|
|
645
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,t,n,s,i,JSON.stringify(r.data),r.sourceEventSeqs===void 0?null:JSON.stringify(r.sourceEventSeqs),r.surfaceOp===void 0?null:JSON.stringify(r.surfaceOp),r.ignorable===!0?1:null)}};function zk(e,t){return`${e}:incarnation:${t.incarnation}:revision:${t.revision}`}l(zk,"revisionOf");function $s(e){try{return Promise.resolve(e())}catch(t){let r=Promise.withResolvers();return r.reject(t),r.promise}}l($s,"promiseFromSync");function ao(e){if(!Number.isSafeInteger(e.created_at)||e.created_at<0)throw new Error("stored session createdAt must be a non-negative safe integer");return{id:e.id,version:e.version,createdAt:e.created_at,...e.cwd===null?{}:{cwd:e.cwd},...e.parent_session===null?{}:{parentSession:e.parent_session},...e.seed_length===null?{}:{seedLength:e.seed_length},...e.origin===null?{}:{origin:e.origin},...e.delegation_depth===null?{}:{delegationDepth:e.delegation_depth},...e.agent_preset===null?{}:{agentPreset:e.agent_preset}}}l(ao,"rowToHeader");function Bk(e){let t=ao({...e,incarnation:"",revision:0});if(t.version!==eo)throw new Uc(wf(t.id,t.version));return t}l(Bk,"blankRowToHeader");function qk(e){let t={type:e.type,seq:e.seq,time:e.time,data:JSON.parse(e.data),...e.source_event_seqs===null?{}:{sourceEventSeqs:JSON.parse(e.source_event_seqs)},...e.surface_op===null?{}:{surfaceOp:JSON.parse(e.surface_op)},...e.ignorable===1?{ignorable:!0}:{}};return rO(t)}l(qk,"rowToEvents");function jfe(e){if(e.source_event_seqs===null)return e.seq;let t;try{t=JSON.parse(e.source_event_seqs)}catch{return e.seq}return!Array.isArray(t)||!t.every(r=>Number.isSafeInteger(r))?e.seq:t.reduce((r,n)=>Math.min(r,n),e.seq)}l(jfe,"historyGroupStart");function Yg(e){let t=ao(e);if(t.version!==eo)throw new Uc(wf(t.id,t.version));let r=e.updated_at??t.createdAt;if(!Number.isSafeInteger(r))throw new Error(`stored session ${t.id} has an invalid latest event time`);if(e.last_prompt_at!==null&&!Number.isSafeInteger(e.last_prompt_at))throw new Error(`stored session ${t.id} has an invalid latest prompt time`);let n=e.last_seq??-1;if(!Number.isSafeInteger(n)||n<-1)throw new Error(`stored session ${t.id} has an invalid latest event sequence`);if(e.blank!==0&&e.blank!==1)throw new Error(`stored session ${t.id} has an invalid blank-session marker`);let i={meta:t,updatedAt:r,lastPromptAt:e.last_prompt_at,lastSeq:n,blank:e.blank===1};if([e.title_seq,e.title_time,e.title_data].every(o=>o===null))return i;if(e.title_seq===null||e.title_time===null||e.title_data===null)throw new Error(`stored session ${t.id} has an incomplete title event`);return{...i,titleEvent:zfe(t.id,e.title_seq,e.title_time,e.title_data)}}l(Yg,"rowToStoredSessionSummary");function zfe(e,t,r,n){if(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(r))throw new Error(`stored session ${e} has an invalid session/title envelope`);let i;try{i=JSON.parse(n)}catch{throw new Error(`stored session ${e} has unparsable session/title data`)}let s=Bfe(i);if(s===void 0)throw new Error(`stored session ${e} has invalid session/title data`);return{type:"session/title",seq:t,time:r,data:s}}l(zfe,"storedTitleEvent");function Bfe(e){if(!Hk(e,["title","messageSeqs","source"])||typeof e.title!="string"||e.title.length===0||!qfe(e.messageSeqs))return;let t=Wfe(e.source);if(t!==void 0)return{title:e.title,messageSeqs:[...e.messageSeqs],source:t}}l(Bfe,"sessionTitleEventData");function Wfe(e){if(Hk(e,["kind"],["provider","model"]))switch(e.kind){case"fallback":case"user":return Object.keys(e).length===1?{kind:e.kind}:void 0;case"provider":return typeof e.provider!="string"||e.provider.length===0?void 0:e.model===void 0?{kind:"provider",provider:e.provider}:!Hk(e.model,["provider","model"])||typeof e.model.provider!="string"||e.model.provider.length===0||typeof e.model.model!="string"||e.model.model.length===0?void 0:{kind:"provider",provider:e.provider,model:{provider:e.model.provider,model:e.model.model}};default:return}}l(Wfe,"sessionTitleSource");function qfe(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0)}l(qfe,"isSessionTitleMessageSeqs");function Hfe(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e.header;if(t===null||typeof t!="object"||Array.isArray(t))return;let r=t.config;if(r===null||typeof r!="object"||Array.isArray(r))return;let n=r;if(typeof n.provider!="string"||n.provider.length===0||typeof n.model!="string"||n.model.length===0)return;let i=n.reasoningEffort;if(!(i!==void 0&&(typeof i!="string"||i.length===0)))return{provider:n.provider,model:n.model,...i===void 0?{}:{reasoningEffort:i}}}l(Hfe,"requestHeaderConfig");function Hk(e,t,r=[]){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=Object.keys(e);return t.every(i=>Object.hasOwn(e,i))&&n.every(i=>t.includes(i)||r.includes(i))}l(Hk,"hasOnlyKeys");function SP(e,t=0,r){let n=e.map(c=>{try{return{ok:!0,events:qk(c)}}catch{return{ok:!1}}}),i=r;if(i===void 0){i=-1;for(let c=n.length-1;c>=0;c-=1)if(n[c]?.ok===!0&&e[c]?.type==="turn/end"){i=e[c]?.seq??-1;break}}let s=[],o=t,a=0;for(let c=0;c<e.length;c+=1){let u=n[c];if(u?.ok!==!0){if((e[c]?.seq??o)<=i)throw new Error(`corrupt session log: unparsable committed event at seq ${e[c]?.seq}`);break}let d=u.events.filter(p=>p.seq>=t),f=d[0]?.seq??o;if(f!==o){if(f<=i)throw new Error(`corrupt session log: seq gap in committed region (expected ${o}, got ${f})`);break}s.push(...d),o=(u.events[0]?.seq??o)+u.events.length,a++}return a<e.length?{preserved:s,tornFrom:t+s.length}:{preserved:s}}l(SP,"scanRows");var Jr=Wk;var Gfe="dsh-edge:session-model:",Gk=class{constructor(t){this.storage=t}storage;static{l(this,"EdgeModelSelectionBridge")}cache=new Map;current(t){return this.cache.get(t)}setCurrent(t,r){r===void 0?this.cache.delete(t):this.cache.set(t,r)}async load(t){let r=this.cache.get(t);if(r!==void 0)return r;let n=kP(await this.storage.get(Xg(t)));return n!==void 0&&this.cache.set(t,n),n}async save(t,r){await this.storage.put(Xg(t),r),this.cache.set(t,r)}async clearIfLogged(t,r){let n=await this.storage.transaction(async i=>{let s=await i.get(Xg(t));if(s===void 0)return!0;let o=kP(s);return o!==void 0&&!AP(o,r)?!1:(await i.delete(Xg(t)),!0)});return n&&AP(this.cache.get(t),r)&&this.cache.delete(t),n}};function Xg(e){return`${Gfe}${e}`}l(Xg,"storageKey");function kP(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e;if(typeof t.provider!="string"||t.provider.length===0||typeof t.model!="string"||t.model.length===0)return;let r=t.reasoningEffort;if(!(r!==void 0&&(typeof r!="string"||r.length===0)))return{provider:t.provider,model:t.model,...r===void 0?{}:{reasoningEffort:r}}}l(kP,"parseStoredModelSelection");function AP(e,t){return e?.provider===t.provider&&e.model===t.model&&e.reasoningEffort===t.reasoningEffort}l(AP,"sameModelSelection");var IP=Gk;var Zk={};fn(Zk,{TOOL_TIMEOUT:()=>Vk,apply:()=>Jfe,inject:()=>Yfe,name:()=>Kfe});var Vfe=l(function(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n,i;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(i=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");i&&(n=l(function(){try{i.call(this)}catch(s){return Promise.reject(s)}},"dispose")),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t},"__addDisposableResource"),Zfe=(function(e){return function(t){function r(o){t.error=t.hasError?new e(o,t.error,"An error was suppressed during disposal."):o,t.hasError=!0}l(r,"fail");var n,i=0;function s(){for(;n=t.stack.pop();)try{if(!n.async&&i===1)return i=0,t.stack.push(n),Promise.resolve().then(s);if(n.dispose){var o=n.dispose.call(n.value);if(n.async)return i|=2,Promise.resolve(o).then(s,function(a){return r(a),s()})}else i|=1}catch(a){r(a)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return l(s,"next"),s()}})(typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n}),Vk="TOOL_TIMEOUT",Kfe="timeout-policy",Yfe=["tools"];function Xfe(e){let t=`tool call timed out after ${e}ms`;return{content:[{type:"text",text:`Error: ${t}`}],isError:!0,error:{message:t,info:{name:"ToolTimeoutError",code:Vk}}}}l(Xfe,"toolTimeoutResult");function Jfe(e){e.on("tools/execute",async(t,r)=>{let n={stack:[],error:void 0,hasError:!1};try{let i=e.tools.get(t.name,t.agent)?.timeoutMs;if(i===void 0)return r();let s=Vfe(n,Ul(t.signal,i,Vk),!1),o=t.signal;t.signal=s.signal;try{let a=await r();return uh(s.signal,"TOOL_TIMEOUT")!==void 0?Xfe(i):a}finally{t.signal=o}}catch(i){n.error=i,n.hasError=!0}finally{Zfe(n)}})}l(Jfe,"apply");var c4={};fn(c4,{Config:()=>the,DEFAULT_FETCH_MAX_OUTPUT_CHARS:()=>ED,DEFAULT_WEB_TOOL_TIMEOUT_MS:()=>l4,WEB_SEARCH_MAX_QUERIES:()=>Mpe,WEB_SEARCH_MAX_RESULTS:()=>Lpe,apply:()=>rhe,applyWebFetchTool:()=>xD,applyWebSearchTool:()=>fD,fetchMetaFromResult:()=>wD,fetchMetaFromValue:()=>vD,formatFetchOutput:()=>gD,formatSearchOutput:()=>oD,inject:()=>ehe,name:()=>Qpe,parseFetchArgs:()=>hD,presentFetchCall:()=>yD,presentFetchResult:()=>bD,presentSearchCall:()=>aD,presentSearchResult:()=>dD,searchMetaFromResult:()=>uD,searchMetaFromValue:()=>cD});function Qfe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}l(Qfe,"extend");function Jk(e,t){return Array(t+1).join(e)}l(Jk,"repeat");function TP(e){return e.replace(/^\n*/,"")}l(TP,"trimLeadingNewlines");function CP(e){for(var t=e.length;t>0&&e[t-1]===`
|
|
644
646
|
`;)t--;return e.substring(0,t)}l(CP,"trimTrailingNewlines");function OP(e){return CP(TP(e))}l(OP,"trimNewlines");var epe=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Qk(e){return e4(e,epe)}l(Qk,"isBlock");var RP=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function NP(e){return e4(e,RP)}l(NP,"isVoid");function tpe(e){return DP(e,RP)}l(tpe,"hasVoid");var PP=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function rpe(e){return e4(e,PP)}l(rpe,"isMeaningfulWhenBlank");function npe(e){return DP(e,PP)}l(npe,"hasMeaningfulWhenBlank");function e4(e,t){return t.indexOf(e.nodeName)>=0}l(e4,"is");function DP(e,t){return e.getElementsByTagName&&t.some(function(r){return e.getElementsByTagName(r).length})}l(DP,"has");var ipe=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function LP(e){return ipe.reduce(function(t,r){return t.replace(r[0],r[1])},e)}l(LP,"escapeMarkdown");var vn={};vn.paragraph={filter:"p",replacement:l(function(e){return`
|
|
645
647
|
|
|
646
648
|
`+e+`
|
|
@@ -766,7 +768,7 @@ ${n}`:""}`}});function hD(e){if(e.url.trim().length===0)throw new Error("url mus
|
|
|
766
768
|
button, .button { display: inline-block; box-sizing: border-box; margin-top: 1rem; padding: .75rem 1rem; border: 0; border-radius: .6rem; background: #5a87ff; color: #071022; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
|
|
767
769
|
.secondary { background: #29314b; color: #edf2ff; }
|
|
768
770
|
.error { padding: .75rem; border-radius: .5rem; background: #461d2b; color: #ffd6df; }
|
|
769
|
-
`}l(fL,"pageStyles");var Zhe="https://api.deepseek.com";var Khe="deepseek-v4-flash",Yhe="high";var Xhe=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;function w4(e){let t=e??Zhe,r;try{r=new URL(t)}catch{throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL")}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username.length>0||r.password.length>0)throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL without credentials");return t}l(w4,"resolveEdgeBaseURL");function $f(e){if(e===void 0)return Khe;if(!Xhe.test(e))throw new Error("dsh-edge: DEEPSEEK_MODEL must be a valid model id of at most 128 characters");return e}l($f,"resolveEdgeModel");function b4(e){if(e===void 0)return Yhe;if(e!=="off"&&e!=="low"&&e!=="high"&&e!=="max")throw new Error("dsh-edge: DEEPSEEK_REASONING_EFFORT must be one of off, low, high, or max");return e}l(b4,"resolveEdgeReasoningEffort");function x4(e){if(e===void 0)return 12e4;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t)||t>2147483647)throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be no greater than 2147483647");return t}l(x4,"resolveEdgeStreamIdleTimeoutMs");function E4(e){if(e===void 0)return 256e3;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t))throw new Error(`dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be no greater than ${Number.MAX_SAFE_INTEGER}`);return t}l(E4,"resolveEdgeMaxOutputTokens");var S4={name:"dsh-edge",version:"0.6.0-alpha.6",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.1.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","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","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: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.0","jsonc-parser":"^3.3.1",wrangler:"4.123.0"},devDependencies:{"@cloudflare/computer":"0.2.0","@cloudflare/workers-types":"5.20260812.1","@deepseek-ai/cordis":"4.0.1","@deepseek-ai/dsh-agent":"0.1.1-rc.2","@deepseek-ai/dsh-agent-loop":"0.1.1-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.1.1-rc.2","@deepseek-ai/dsh-attachment":"0.1.1-rc.2","@deepseek-ai/dsh-brand":"0.1.1-rc.2","@deepseek-ai/dsh-compaction":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-basic":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.1.1-rc.2","@deepseek-ai/dsh-credentials":"0.1.1-rc.2","@deepseek-ai/dsh-host-apiproxy":"0.1.1-rc.2","@deepseek-ai/dsh-launch-environment":"0.1.1-rc.2","@deepseek-ai/dsh-llm":"0.1.1-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-session":"0.1.1-rc.2","@deepseek-ai/dsh-session-persistence":"0.1.1-rc.2","@deepseek-ai/dsh-session-projection":"0.1.1-rc.2","@deepseek-ai/dsh-session-query":"0.1.1-rc.2","@deepseek-ai/dsh-session-title":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-llm":"0.1.1-rc.2","@deepseek-ai/dsh-output-retention":"0.1.1-rc.2","@deepseek-ai/dsh-settings":"0.1.1-rc.2","@deepseek-ai/dsh-spill":"0.1.1-rc.2","@deepseek-ai/dsh-spill-policy":"0.1.1-rc.2","@deepseek-ai/dsh-storage":"0.1.1-rc.2","@deepseek-ai/dsh-storage-domain":"0.1.1-rc.2","@deepseek-ai/dsh-timeout":"0.1.1-rc.2","@deepseek-ai/dsh-token-meter":"0.1.1-rc.2","@deepseek-ai/dsh-system-prompt":"0.1.1-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.1-rc.2","@deepseek-ai/dsh-tool-web":"0.1.1-rc.2","@deepseek-ai/dsh-tools":"0.1.1-rc.2","@deepseek-ai/dsh-web":"0.1.1-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-workspace":"0.1.1-rc.2","just-bash":"3.3.0","fast-png":"8.0.0","jpeg-js":"0.4.4",playwright:"^1.49.0",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}};var v1=S4.version,pL=S4.dshEdge.upstreamVersion;function Qhe(){return"dsh-edge@0.6.0-alpha.6/direct"}l(Qhe,"resolveEdgeDeploymentId");function w1(e){return{baseURL:w4(e.DEEPSEEK_BASE_URL),maxTokens:E4(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:$f(e.DEEPSEEK_MODEL),reasoningEffort:b4(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:t1(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:x4(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:kf(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(w1,"resolveEdgeDeploymentConfig");function eme(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}l(eme,"edgeDeploymentApiKeyConfigured");function tme(e){let t=w4(e),r=new URL(t);return r.search.length===0&&r.hash.length===0?t:(r.search="",r.hash="",r.href)}l(tme,"projectedEdgeBaseURL");function k4(e,t){return{shell:e.LOADER===void 0?"just-bash-direct":"just-bash-isolated",storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:Qhe(),apiKeyConfigured:eme(e),baseURL:tme(e.DEEPSEEK_BASE_URL),maxTokens:E4(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:$f(e.DEEPSEEK_MODEL),reasoningEffort:b4(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:t1(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:x4(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:kf(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(k4,"resolveEdgeDeploymentProfile");function hL(e){w1(e);let t=k4(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,version:v1,upstreamVersion:pL,status:"ready"}}l(hL,"resolveEdgeDeploymentHealth");import{WorkerEntrypoint as YBe}from"cloudflare:workers";var Ol=zy(mL(),1);var A4=l((e,t,r)=>{let n=e instanceof RegExp?gL(e,r):e,i=t instanceof RegExp?gL(t,r):t,s=n!==null&&i!=null&&rme(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},"balanced"),gL=l((e,t)=>{let r=t.match(e);return r?r[0]:null},"maybeMatch"),rme=l((e,t,r)=>{let n,i,s,o,a,c=r.indexOf(e),u=r.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],s=r.length;d>=0&&!a;){if(d===c)n.push(d),c=r.indexOf(e,d+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=r.indexOf(t,d+1);d=c<u&&c>=0?c:u}n.length&&o!==void 0&&(a=[s,o])}return a},"range");var yL="\0SLASH"+Math.random()+"\0",vL="\0OPEN"+Math.random()+"\0",$4="\0CLOSE"+Math.random()+"\0",wL="\0COMMA"+Math.random()+"\0",bL="\0PERIOD"+Math.random()+"\0",nme=new RegExp(yL,"g"),ime=new RegExp(vL,"g"),sme=new RegExp($4,"g"),ome=new RegExp(wL,"g"),ame=new RegExp(bL,"g"),lme=/\\\\/g,cme=/\\{/g,ume=/\\}/g,dme=/\\,/g,fme=/\\\./g,pme=1e5,hme=4e6;function I4(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}l(I4,"numeric");function mme(e){return e.replace(lme,yL).replace(cme,vL).replace(ume,$4).replace(dme,wL).replace(fme,bL)}l(mme,"escapeBraces");function gme(e){return e.replace(nme,"\\").replace(ime,"{").replace(sme,"}").replace(ome,",").replace(ame,".")}l(gme,"unescapeBraces");function xL(e){if(!e)return[""];let t=[],r=A4("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:s}=r,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=xL(s);return s.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}l(xL,"parseCommaParts");function EL(e,t={}){if(!e)return[];let{max:r=pme,maxLength:n=hme}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),_4(mme(e),r,n,!0).map(gme)}l(EL,"expand");function yme(e){return"{"+e+"}"}l(yme,"embrace");function vme(e){return/^-?0\d/.test(e)}l(vme,"isPadded");function wme(e,t){return e<=t}l(wme,"lte");function bme(e,t){return e>=t}l(bme,"gte");function Tf(e,t,r,n,i,s){let o=[],a=0;for(let c=0;c<e.length;c++)for(let u=0;u<r.length;u++){if(o.length>=n)return o;let d=e[c]+t+r[u];if(!(s&&!d)){if(a+d.length>i)return o;o.push(d),a+=d.length}}return o}l(Tf,"combine");function xme(e,t,r,n){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=I4(i[0]),a=I4(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(I4(i[2])),1):1,d=wme;a<o&&(u*=-1,d=bme);let p=i.some(vme),h=0;for(let m=o;d(m,a)&&s.length<r;m+=u){let g;if(t)g=String.fromCharCode(m),g==="\\"&&(g="");else if(g=String(m),p){let y=c-g.length;if(y>0){let b=new Array(y+1).join("0");m<0?g="-"+b+g.slice(1):g=b+g}}if(h+g.length>n)break;s.push(g),h+=g.length}return s}l(xme,"expandSequence");function _4(e,t,r,n){let i=[""],s=!1,o=!0;for(;;){let a=A4("{","}",e);if(!a)return Tf(i,e,[""],t,r,s);let c=a.pre;if(/\$$/.test(c)){if(i=Tf(i,c+"{"+a.body+"}",[""],t,r,s&&!a.post.length),o=!1,!a.post.length)break;e=a.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=u||d,p=a.body.indexOf(",")>=0;if(!f&&!p){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+$4+a.post,n=!0;continue}return Tf(i,c+"{"+a.body+"}"+a.post,[""],t,r,s)}o&&(s=n&&!f,o=!1);let h;if(f)h=xme(a.body,d,t,r);else{let m=xL(a.body);if(m.length===1&&m[0]!==void 0&&(m=_4(m[0],t,r,!1).map(yme),m.length===1)){if(i=Tf(i,c+m[0],[""],t,r,s&&!a.post.length),!a.post.length)break;e=a.post;continue}let g=s&&!a.post.length&&!c;for(let b=0;g&&b<i.length;b++)i[b]&&(g=!1);h=[];let y=0;e:for(let b=0;b<m.length;b++){let w=_4(m[b],t,r,!1);for(let x=0;x<w.length;x++){let k=w[x];if(!(g&&!k)){if(h.length>=t||y+k.length>r)break e;h.push(k),y+=k.length}}}}if(i=Tf(i,c,h,t,r,s&&!a.post.length),!a.post.length)break;e=a.post}return i}l(_4,"expand_");var Cf=l(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Eme={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Of=l(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Sme=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),SL=l(e=>e.join(""),"rangesToString"),kL=l((e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,u=!1,d=r,f="";e:for(;s<e.length;){let g=e.charAt(s);if((g==="!"||g==="^")&&s===r+1){u=!0,s++;continue}if(g==="]"&&o&&!c){d=s+1;break}if(o=!0,g==="\\"&&!c){c=!0,s++;continue}if(g==="["&&!c){for(let[y,[b,w,x]]of Object.entries(Eme))if(e.startsWith(y,s)){if(f)return["$.",!1,e.length-r,!0];s+=y.length,x?i.push(b):n.push(b),a=a||w;continue e}}if(c=!1,f){g>f?n.push(Of(f)+"-"+Of(g)):g===f&&n.push(Of(g)),f="",s++;continue}if(e.startsWith("-]",s+1)){n.push(Of(g+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=g,s+=2;continue}n.push(Of(g)),s++}if(d<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[Sme(g),!1,d-r,!1]}let p="["+(u?"^":"")+SL(n)+"]",h="["+(u?"":"^")+SL(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,a,d-r,!0]},"parseClass");var Jo=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var Gn,kme=new Set(["!","?","+","*","@"]),T4=l(e=>kme.has(e),"isExtglobType"),AL=l(e=>T4(e.type),"isExtglobAST"),Ame=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Ime=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),_me=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),IL=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),$me="(?!(?:^|/)\\.\\.?(?:$|/))",x1="(?!\\.)",Tme=new Set(["[","."]),Cme=new Set(["..","."]),Ome=new Set("().*{}+?[]^$\\!"),Rme=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),C4="[^/]",_L=C4+"*?",$L=C4+"+?",Nme=0,el=class{static{l(this,"AST")}type;#e;#r;#n=!1;#t=[];#i;#s;#a;#u=!1;#l;#o;#c=!1;id=++Nme;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#e=this.#i?this.#i.#e:this,this.#l=this.#e===this?n:this.#e.#l,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#u&&this.#a.push(this),this.#s=this.#i?this.#i.#t.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#x(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let i=r.#s+1;!n.type&&i<n.#t.length;i++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[i])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Gn&&r.#i===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let t=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let r=0;r<this.#s;r++){let n=t.#t[r];if(!(n instanceof Gn&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#t.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Gn(this.type,t);for(let n of this.#t)r.copyIn(n);return r}static#h(t,r,n,i,s){let o=i.maxExtglobRecursion??2,a=!1,c=!1,u=-1,d=!1;if(r.type===null){let g=n,y="";for(;g<t.length;){let b=t.charAt(g++);if(a||b==="\\"){a=!a,y+=b;continue}if(c){g===u+1?(b==="^"||b==="!")&&(d=!0):b==="]"&&!(g===u+2&&d)&&(c=!1),y+=b;continue}else if(b==="["){c=!0,u=g,d=!1,y+=b;continue}if(!i.noext&&T4(b)&&t.charAt(g)==="("&&s<=o){r.push(y),y="";let x=new Gn(b,r);g=Gn.#h(t,x,g,i,s+1),r.push(x);continue}y+=b}return r.push(y),g}let f=n+1,p=new Gn(null,r),h=[],m="";for(;f<t.length;){let g=t.charAt(f++);if(a||g==="\\"){a=!a,m+=g;continue}if(c){f===u+1?(g==="^"||g==="!")&&(d=!0):g==="]"&&!(f===u+2&&d)&&(c=!1),m+=g;continue}else if(g==="["){c=!0,u=f,d=!1,m+=g;continue}if(!i.noext&&T4(g)&&t.charAt(f)==="("&&(s<=o||r&&r.#g(g))){let b=r&&r.#g(g)?0:1;p.push(m),m="";let w=new Gn(g,p);p.push(w),f=Gn.#h(t,w,f,i,s+b);continue}if(g==="|"){p.push(m),m="",h.push(p),p=new Gn(null,r);continue}if(g===")")return m===""&&r.#t.length===0&&(r.#c=!0),p.push(m),m="",r.push(...h,p),f;m+=g}return r.type=null,r.#r=void 0,r.#t=[t.substring(n-1)],f}#C(t){return this.#m(t,Ime)}#m(t,r=Ame){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#g(n.type,r)}#g(t,r=_me){return!!r.get(this.type)?.includes(t)}#f(t,r){let n=t.#t[0],i=new Gn(null,n,this.options);i.#t.push(""),n.push(i),this.#E(t,r)}#E(t,r){let n=t.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#i=this);this.#o=void 0}#S(t){return!!IL.get(this.type)?.has(t)}#O(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=t.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#y(t){let r=IL.get(this.type),n=t.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let s of this.#t)typeof s=="object"&&(s.#i=this);this.type=i,this.#o=void 0,this.#c=!1}static fromGlob(t,r={}){let n=new Gn(null,void 0,r);return Gn.#h(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#l.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#l}toRegExpSource(t){let r=t??!!this.#l.dot;if(this.#e===this&&(this.#p(),this.#x()),!AL(this)){let c=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),u=this.#t.map(h=>{let[m,g,y,b]=typeof h=="string"?Gn.#k(h,this.#r,c):h.toRegExpSource(t);return this.#r=this.#r||y,this.#n=this.#n||b,m}).join(""),d="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Cme.has(this.#t[0]))){let m=Tme,g=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),y=!r&&!t&&m.has(u.charAt(0));d=g?$me:y?x1:""}let f="";return this.isEnd()&&this.#e.#u&&this.#i?.type==="!"&&(f="(?:$|\\/)"),[d+u+f,Jo(u),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#v(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#r=void 0,[c,Jo(this.toString()),!1,!1]}let o=!n||t||r||!x1?"":this.#v(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!r?x1:"")+$L;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?x1:"")+_L+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,Jo(s),this.#r=!!this.#r,this.#n]}#p(){if(AL(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#p(),this.#m(i)?(r=!1,this.#E(i,n)):this.#C(i)?(r=!1,this.#f(i,n)):this.#O(i)&&(r=!1,this.#y(i)))}}while(!r&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#o=void 0}#v(t){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(t);return this.#n=this.#n||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#k(t,r,n=!1){let i=!1,s="",o=!1,a=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(Ome.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=!0,s+=n&&/^[*]+$/.test(t)?$L:_L,r=!0;continue}else a=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,f,p,h]=kL(t,c);if(p){s+=d,o=o||f,c+=p-1,r=r||h;continue}}if(u==="?"){s+=C4,r=!0;continue}s+=Rme(u)}return[s,Jo(t),!!r,o]}};Gn=el;var O4=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Qr=l((e,t,r={})=>(Cf(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Wc(t,r).match(e)),"minimatch"),Pme=/^\*+([^+@!?*[(]*)$/,Dme=l(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),Lme=l(e=>t=>t.endsWith(e),"starDotExtTestDot"),Mme=l(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),Fme=l(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),Ume=/^\*+\.\*+$/,jme=l(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),zme=l(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),Bme=/^\.\*+$/,Wme=l(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),qme=/^\*+$/,Hme=l(e=>e.length!==0&&!e.startsWith("."),"starTest"),Gme=l(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),Vme=/^\?+([^+@!?*[(]*)?$/,Zme=l(([e,t=""])=>{let r=OL([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocase"),Kme=l(([e,t=""])=>{let r=RL([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocaseDot"),Yme=l(([e,t=""])=>{let r=RL([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTestDot"),Xme=l(([e,t=""])=>{let r=OL([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTest"),OL=l(([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},"qmarksTestNoExt"),RL=l(([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},"qmarksTestNoExtDot"),NL=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",TL={win32:{sep:"\\"},posix:{sep:"/"}},Jme=NL==="win32"?TL.win32.sep:TL.posix.sep;Qr.sep=Jme;var bn=Symbol("globstar **");Qr.GLOBSTAR=bn;var Qme="[^/]",ege=Qme+"*?",tge="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",rge="(?:(?!(?:\\/|^)\\.).)*?",nge=l((e,t={})=>r=>Qr(r,e,t),"filter");Qr.filter=nge;var xi=l((e,t={})=>Object.assign({},e,t),"ext"),ige=l(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Qr;let t=Qr;return Object.assign(l((n,i,s={})=>t(n,i,xi(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{l(this,"Minimatch")}constructor(i,s={}){super(i,xi(e,s))}static defaults(i){return t.defaults(xi(e,i)).Minimatch}},AST:class extends t.AST{static{l(this,"AST")}constructor(i,s,o={}){super(i,s,xi(e,o))}static fromGlob(i,s={}){return t.AST.fromGlob(i,xi(e,s))}},unescape:l((n,i={})=>t.unescape(n,xi(e,i)),"unescape"),escape:l((n,i={})=>t.escape(n,xi(e,i)),"escape"),filter:l((n,i={})=>t.filter(n,xi(e,i)),"filter"),defaults:l(n=>t.defaults(xi(e,n)),"defaults"),makeRe:l((n,i={})=>t.makeRe(n,xi(e,i)),"makeRe"),braceExpand:l((n,i={})=>t.braceExpand(n,xi(e,i)),"braceExpand"),match:l((n,i,s={})=>t.match(n,i,xi(e,s)),"match"),sep:t.sep,GLOBSTAR:bn})},"defaults");Qr.defaults=ige;var PL=l((e,t={})=>(Cf(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:EL(e,{max:t.braceExpandMax})),"braceExpand");Qr.braceExpand=PL;var sge=l((e,t={})=>new Wc(e,t).makeRe(),"makeRe");Qr.makeRe=sge;var oge=l((e,t,r={})=>{let n=new Wc(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e},"match");Qr.match=oge;var CL=/[?*]|[+@!]\(.*?\)|\[|\]/,age=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Wc=class{static{l(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){Cf(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||NL,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!CL.test(s[2]))&&!CL.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],u=n[i+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let d=n.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,s=0,o=[],a="";for(;i<t.length&&s<r.length;)if(t[i]===r[s])o.push(a==="b"?r[s]:t[i]),i++,s++;else if(n&&t[i]==="**"&&r[s]===t[i+1])o.push(t[i]),i++;else if(n&&r[s]==="**"&&t[i]===r[s+1])o.push(r[s]),s++;else if(t[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(t[i]),i++,s++}else if(r[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return t.length===r.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,s=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),d=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=c?3:a?0:void 0,p=d?3:u?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[h,m]=[t[f],r[p]];h.toLowerCase()===m.toLowerCase()&&(r[p]=h,s=p,i=f)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(bn)?this.#e(t,r,n,i,s):this.#n(t,r,n,i,s)}#e(t,r,n,i,s){let o=r.indexOf(bn,s),a=r.lastIndexOf(bn),[c,u,d]=n?[r.slice(s,o),r.slice(o+1),[]]:[r.slice(s,o),r.slice(o+1,a),r.slice(a+1)];if(c.length){let w=t.slice(i,i+c.length);if(!this.#n(w,c,n,0,0))return!1;i+=c.length,s+=c.length}let f=0;if(d.length){if(d.length+i>t.length)return!1;let w=t.length-d.length;if(this.#n(t,d,n,w,0))f=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(w--,!this.#n(t,d,n,w,0)))return!1;f=d.length+1}}if(!u.length){let w=!!f;for(let x=i;x<t.length-f;x++){let k=String(t[x]);if(w=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return n||w}let p=[[[],0]],h=p[0],m=0,g=[0];for(let w of u)w===bn?(g.push(m),h=[[],0],p.push(h)):(h[0].push(w),m++);let y=p.length-1,b=t.length-f;for(let w of p)w[1]=b-(g[y--]+w[0].length);return!!this.#r(t,p,i,0,n,0,!!f)}#r(t,r,n,i,s,o,a){let c=r[i];if(!c){for(let f=n;f<t.length;f++){a=!0;let p=t[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[u,d]=c;for(;n<=d;){if(this.#n(t.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let h=this.#r(t,r,n+u.length,i+1,s,o+1,a);if(h!==!1)return h}let p=t[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(t,r,n,i,s){let o,a,c,u;for(o=i,a=s,u=t.length,c=r.length;o<u&&a<c;o++,a++){this.debug("matchOne loop");let d=r[a],f=t[o];if(this.debug(r,d,f),d===!1||d===bn)return!1;let p;if(typeof d=="string"?(p=f===d,this.debug("string match",d,f,p)):(p=d.test(f),this.debug("pattern match",d,f,p)),!p)return!1}if(o===u&&a===c)return!0;if(o===u)return n;if(a===c)return o===u-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return PL(this.pattern,this.options)}parse(t){Cf(t);let r=this.options;if(t==="**")return bn;if(t==="")return"";let n,i=null;(n=t.match(qme))?i=r.dot?Gme:Hme:(n=t.match(Pme))?i=(r.nocase?r.dot?Fme:Mme:r.dot?Lme:Dme)(n[1]):(n=t.match(Vme))?i=(r.nocase?r.dot?Kme:Zme:r.dot?Yme:Xme)(n):(n=t.match(Ume))?i=r.dot?zme:jme:(n=t.match(Bme))&&(i=Wme);let s=el.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?ege:r.dot?tge:rge,i=new Set(r.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?age(f):f===bn?bn:f._src});u.forEach((f,p)=>{let h=u[p+1],m=u[p-1];f!==bn||m===bn||(m===void 0?h!==void 0&&h!==bn?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=m+"(?:\\/|\\/"+n+")?":h!==bn&&(u[p-1]=m+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=bn))});let d=u.filter(f=>f!==bn);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of s){let c=i;if(n.matchBase&&a.length===1&&(c=[o]),this.matchOne(c,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Qr.defaults(t).Minimatch}};Qr.AST=el;Qr.Minimatch=Wc;Qr.escape=O4;Qr.unescape=Jo;import{gunzipSync as a0e}from"node:zlib";var Rf=class{static{l(this,"Diff")}diff(t,r,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let s=this.castInput(t,n),o=this.castInput(r,n),a=this.removeEmpty(this.tokenize(s,n)),c=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(a,c,n,i)}diffWithOptionsObj(t,r,n,i){var s;let o=l(w=>{if(w=this.postProcess(w,n),i){setTimeout(function(){i(w)},0);return}else return w},"done"),a=r.length,c=t.length,u=1,d=a+c;n.maxEditLength!=null&&(d=Math.min(d,n.maxEditLength));let f=(s=n.timeout)!==null&&s!==void 0?s:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(h[0],r,t,0,n);if(h[0].oldPos+1>=c&&m+1>=a)return o(this.buildValues(h[0].lastComponent,r,t));let g=-1/0,y=1/0,b=l(()=>{for(let w=Math.max(g,-u);w<=Math.min(y,u);w+=2){let x,k=h[w-1],S=h[w+1];k&&(h[w-1]=void 0);let A=!1;if(S){let C=S.oldPos-w;A=S&&0<=C&&C<a}let I=k&&k.oldPos+1<c;if(!A&&!I){h[w]=void 0;continue}if(!I||A&&k.oldPos<S.oldPos?x=this.addToPath(S,!0,!1,0,n):x=this.addToPath(k,!1,!0,1,n),m=this.extractCommon(x,r,t,w,n),x.oldPos+1>=c&&m+1>=a)return o(this.buildValues(x.lastComponent,r,t))||!0;h[w]=x,x.oldPos+1>=c&&(y=Math.min(y,w-1)),m+1>=a&&(g=Math.max(g,w+1))}u++},"execEditLength");if(i)l(function w(){setTimeout(function(){if(u>d||Date.now()>p)return i(void 0);b()||w()},0)},"exec")();else for(;u<=d&&Date.now()<=p;){let w=b();if(w)return w}}addToPath(t,r,n,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===r&&o.removed===n?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:r,removed:n,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:r,removed:n,previousComponent:o}}}extractCommon(t,r,n,i,s){let o=r.length,a=n.length,c=t.oldPos,u=c-i,d=0;for(;u+1<o&&c+1<a&&this.equals(n[c+1],r[u+1],s);)u++,c++,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=c,u}equals(t,r,n){return n.comparator?n.comparator(t,r):t===r||!!n.ignoreCase&&t.toLowerCase()===r.toLowerCase()}removeEmpty(t){let r=[];for(let n=0;n<t.length;n++)t[n]&&r.push(t[n]);return r}castInput(t,r){return t}tokenize(t,r){return Array.from(t)}join(t){return t.join("")}postProcess(t,r){return t}get useLongestToken(){return!1}buildValues(t,r,n){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,a=0,c=0,u=0;for(;a<o;a++){let d=i[a];if(d.removed)d.value=this.join(n.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=r.slice(c,c+d.count);f=f.map(function(p,h){let m=n[u+h];return m.length>p.length?m:p}),d.value=this.join(f)}else d.value=this.join(r.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var R4=class extends Rf{static{l(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=cge}equals(t,r,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
|
|
771
|
+
`}l(fL,"pageStyles");var Zhe="https://api.deepseek.com";var Khe="deepseek-v4-flash",Yhe="high";var Xhe=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;function w4(e){let t=e??Zhe,r;try{r=new URL(t)}catch{throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL")}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username.length>0||r.password.length>0)throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL without credentials");return t}l(w4,"resolveEdgeBaseURL");function $f(e){if(e===void 0)return Khe;if(!Xhe.test(e))throw new Error("dsh-edge: DEEPSEEK_MODEL must be a valid model id of at most 128 characters");return e}l($f,"resolveEdgeModel");function b4(e){if(e===void 0)return Yhe;if(e!=="off"&&e!=="low"&&e!=="high"&&e!=="max")throw new Error("dsh-edge: DEEPSEEK_REASONING_EFFORT must be one of off, low, high, or max");return e}l(b4,"resolveEdgeReasoningEffort");function x4(e){if(e===void 0)return 12e4;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t)||t>2147483647)throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be no greater than 2147483647");return t}l(x4,"resolveEdgeStreamIdleTimeoutMs");function E4(e){if(e===void 0)return 256e3;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t))throw new Error(`dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be no greater than ${Number.MAX_SAFE_INTEGER}`);return t}l(E4,"resolveEdgeMaxOutputTokens");var S4={name:"dsh-edge",version:"0.6.0-alpha.7",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.1.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","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","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: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.0","jsonc-parser":"^3.3.1",wrangler:"4.123.0"},devDependencies:{"@cloudflare/computer":"0.2.0","@cloudflare/workers-types":"5.20260812.1","@deepseek-ai/cordis":"4.0.1","@deepseek-ai/dsh-agent":"0.1.1-rc.2","@deepseek-ai/dsh-agent-loop":"0.1.1-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.1.1-rc.2","@deepseek-ai/dsh-attachment":"0.1.1-rc.2","@deepseek-ai/dsh-brand":"0.1.1-rc.2","@deepseek-ai/dsh-compaction":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-basic":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.1.1-rc.2","@deepseek-ai/dsh-credentials":"0.1.1-rc.2","@deepseek-ai/dsh-host-apiproxy":"0.1.1-rc.2","@deepseek-ai/dsh-launch-environment":"0.1.1-rc.2","@deepseek-ai/dsh-llm":"0.1.1-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-session":"0.1.1-rc.2","@deepseek-ai/dsh-session-persistence":"0.1.1-rc.2","@deepseek-ai/dsh-session-projection":"0.1.1-rc.2","@deepseek-ai/dsh-session-query":"0.1.1-rc.2","@deepseek-ai/dsh-session-title":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-llm":"0.1.1-rc.2","@deepseek-ai/dsh-output-retention":"0.1.1-rc.2","@deepseek-ai/dsh-settings":"0.1.1-rc.2","@deepseek-ai/dsh-spill":"0.1.1-rc.2","@deepseek-ai/dsh-spill-policy":"0.1.1-rc.2","@deepseek-ai/dsh-storage":"0.1.1-rc.2","@deepseek-ai/dsh-storage-domain":"0.1.1-rc.2","@deepseek-ai/dsh-timeout":"0.1.1-rc.2","@deepseek-ai/dsh-token-meter":"0.1.1-rc.2","@deepseek-ai/dsh-system-prompt":"0.1.1-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.1-rc.2","@deepseek-ai/dsh-tool-web":"0.1.1-rc.2","@deepseek-ai/dsh-tools":"0.1.1-rc.2","@deepseek-ai/dsh-web":"0.1.1-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-workspace":"0.1.1-rc.2","just-bash":"3.3.0","fast-png":"8.0.0","jpeg-js":"0.4.4",playwright:"^1.49.0",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}};var v1=S4.version,pL=S4.dshEdge.upstreamVersion;function Qhe(){return"dsh-edge@0.6.0-alpha.7/direct"}l(Qhe,"resolveEdgeDeploymentId");function w1(e){return{baseURL:w4(e.DEEPSEEK_BASE_URL),maxTokens:E4(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:$f(e.DEEPSEEK_MODEL),reasoningEffort:b4(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:t1(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:x4(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:kf(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(w1,"resolveEdgeDeploymentConfig");function eme(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}l(eme,"edgeDeploymentApiKeyConfigured");function tme(e){let t=w4(e),r=new URL(t);return r.search.length===0&&r.hash.length===0?t:(r.search="",r.hash="",r.href)}l(tme,"projectedEdgeBaseURL");function k4(e,t){return{shell:e.LOADER===void 0?"just-bash-direct":"just-bash-isolated",storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:Qhe(),apiKeyConfigured:eme(e),baseURL:tme(e.DEEPSEEK_BASE_URL),maxTokens:E4(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:$f(e.DEEPSEEK_MODEL),reasoningEffort:b4(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:t1(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:x4(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:kf(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(k4,"resolveEdgeDeploymentProfile");function hL(e){w1(e);let t=k4(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,version:v1,upstreamVersion:pL,status:"ready"}}l(hL,"resolveEdgeDeploymentHealth");import{WorkerEntrypoint as YBe}from"cloudflare:workers";var Ol=zy(mL(),1);var A4=l((e,t,r)=>{let n=e instanceof RegExp?gL(e,r):e,i=t instanceof RegExp?gL(t,r):t,s=n!==null&&i!=null&&rme(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},"balanced"),gL=l((e,t)=>{let r=t.match(e);return r?r[0]:null},"maybeMatch"),rme=l((e,t,r)=>{let n,i,s,o,a,c=r.indexOf(e),u=r.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],s=r.length;d>=0&&!a;){if(d===c)n.push(d),c=r.indexOf(e,d+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=r.indexOf(t,d+1);d=c<u&&c>=0?c:u}n.length&&o!==void 0&&(a=[s,o])}return a},"range");var yL="\0SLASH"+Math.random()+"\0",vL="\0OPEN"+Math.random()+"\0",$4="\0CLOSE"+Math.random()+"\0",wL="\0COMMA"+Math.random()+"\0",bL="\0PERIOD"+Math.random()+"\0",nme=new RegExp(yL,"g"),ime=new RegExp(vL,"g"),sme=new RegExp($4,"g"),ome=new RegExp(wL,"g"),ame=new RegExp(bL,"g"),lme=/\\\\/g,cme=/\\{/g,ume=/\\}/g,dme=/\\,/g,fme=/\\\./g,pme=1e5,hme=4e6;function I4(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}l(I4,"numeric");function mme(e){return e.replace(lme,yL).replace(cme,vL).replace(ume,$4).replace(dme,wL).replace(fme,bL)}l(mme,"escapeBraces");function gme(e){return e.replace(nme,"\\").replace(ime,"{").replace(sme,"}").replace(ome,",").replace(ame,".")}l(gme,"unescapeBraces");function xL(e){if(!e)return[""];let t=[],r=A4("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:s}=r,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=xL(s);return s.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}l(xL,"parseCommaParts");function EL(e,t={}){if(!e)return[];let{max:r=pme,maxLength:n=hme}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),_4(mme(e),r,n,!0).map(gme)}l(EL,"expand");function yme(e){return"{"+e+"}"}l(yme,"embrace");function vme(e){return/^-?0\d/.test(e)}l(vme,"isPadded");function wme(e,t){return e<=t}l(wme,"lte");function bme(e,t){return e>=t}l(bme,"gte");function Tf(e,t,r,n,i,s){let o=[],a=0;for(let c=0;c<e.length;c++)for(let u=0;u<r.length;u++){if(o.length>=n)return o;let d=e[c]+t+r[u];if(!(s&&!d)){if(a+d.length>i)return o;o.push(d),a+=d.length}}return o}l(Tf,"combine");function xme(e,t,r,n){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=I4(i[0]),a=I4(i[1]),c=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(I4(i[2])),1):1,d=wme;a<o&&(u*=-1,d=bme);let p=i.some(vme),h=0;for(let m=o;d(m,a)&&s.length<r;m+=u){let g;if(t)g=String.fromCharCode(m),g==="\\"&&(g="");else if(g=String(m),p){let y=c-g.length;if(y>0){let b=new Array(y+1).join("0");m<0?g="-"+b+g.slice(1):g=b+g}}if(h+g.length>n)break;s.push(g),h+=g.length}return s}l(xme,"expandSequence");function _4(e,t,r,n){let i=[""],s=!1,o=!0;for(;;){let a=A4("{","}",e);if(!a)return Tf(i,e,[""],t,r,s);let c=a.pre;if(/\$$/.test(c)){if(i=Tf(i,c+"{"+a.body+"}",[""],t,r,s&&!a.post.length),o=!1,!a.post.length)break;e=a.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=u||d,p=a.body.indexOf(",")>=0;if(!f&&!p){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+$4+a.post,n=!0;continue}return Tf(i,c+"{"+a.body+"}"+a.post,[""],t,r,s)}o&&(s=n&&!f,o=!1);let h;if(f)h=xme(a.body,d,t,r);else{let m=xL(a.body);if(m.length===1&&m[0]!==void 0&&(m=_4(m[0],t,r,!1).map(yme),m.length===1)){if(i=Tf(i,c+m[0],[""],t,r,s&&!a.post.length),!a.post.length)break;e=a.post;continue}let g=s&&!a.post.length&&!c;for(let b=0;g&&b<i.length;b++)i[b]&&(g=!1);h=[];let y=0;e:for(let b=0;b<m.length;b++){let w=_4(m[b],t,r,!1);for(let x=0;x<w.length;x++){let k=w[x];if(!(g&&!k)){if(h.length>=t||y+k.length>r)break e;h.push(k),y+=k.length}}}}if(i=Tf(i,c,h,t,r,s&&!a.post.length),!a.post.length)break;e=a.post}return i}l(_4,"expand_");var Cf=l(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Eme={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Of=l(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Sme=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),SL=l(e=>e.join(""),"rangesToString"),kL=l((e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,u=!1,d=r,f="";e:for(;s<e.length;){let g=e.charAt(s);if((g==="!"||g==="^")&&s===r+1){u=!0,s++;continue}if(g==="]"&&o&&!c){d=s+1;break}if(o=!0,g==="\\"&&!c){c=!0,s++;continue}if(g==="["&&!c){for(let[y,[b,w,x]]of Object.entries(Eme))if(e.startsWith(y,s)){if(f)return["$.",!1,e.length-r,!0];s+=y.length,x?i.push(b):n.push(b),a=a||w;continue e}}if(c=!1,f){g>f?n.push(Of(f)+"-"+Of(g)):g===f&&n.push(Of(g)),f="",s++;continue}if(e.startsWith("-]",s+1)){n.push(Of(g+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=g,s+=2;continue}n.push(Of(g)),s++}if(d<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[Sme(g),!1,d-r,!1]}let p="["+(u?"^":"")+SL(n)+"]",h="["+(u?"":"^")+SL(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,a,d-r,!0]},"parseClass");var Jo=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var Gn,kme=new Set(["!","?","+","*","@"]),T4=l(e=>kme.has(e),"isExtglobType"),AL=l(e=>T4(e.type),"isExtglobAST"),Ame=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Ime=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),_me=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),IL=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),$me="(?!(?:^|/)\\.\\.?(?:$|/))",x1="(?!\\.)",Tme=new Set(["[","."]),Cme=new Set(["..","."]),Ome=new Set("().*{}+?[]^$\\!"),Rme=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),C4="[^/]",_L=C4+"*?",$L=C4+"+?",Nme=0,el=class{static{l(this,"AST")}type;#e;#r;#n=!1;#t=[];#i;#s;#a;#u=!1;#l;#o;#c=!1;id=++Nme;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#e=this.#i?this.#i.#e:this,this.#l=this.#e===this?n:this.#e.#l,this.#a=this.#e===this?[]:this.#e.#a,t==="!"&&!this.#e.#u&&this.#a.push(this),this.#s=this.#i?this.#i.#t.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#x(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let i=r.#s+1;!n.type&&i<n.#t.length;i++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#t[i])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Gn&&r.#i===this))throw new Error("invalid part: "+r);this.#t.push(r)}}toJSON(){let t=this.type===null?this.#t.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#t.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let r=0;r<this.#s;r++){let n=t.#t[r];if(!(n instanceof Gn&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#t.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Gn(this.type,t);for(let n of this.#t)r.copyIn(n);return r}static#h(t,r,n,i,s){let o=i.maxExtglobRecursion??2,a=!1,c=!1,u=-1,d=!1;if(r.type===null){let g=n,y="";for(;g<t.length;){let b=t.charAt(g++);if(a||b==="\\"){a=!a,y+=b;continue}if(c){g===u+1?(b==="^"||b==="!")&&(d=!0):b==="]"&&!(g===u+2&&d)&&(c=!1),y+=b;continue}else if(b==="["){c=!0,u=g,d=!1,y+=b;continue}if(!i.noext&&T4(b)&&t.charAt(g)==="("&&s<=o){r.push(y),y="";let x=new Gn(b,r);g=Gn.#h(t,x,g,i,s+1),r.push(x);continue}y+=b}return r.push(y),g}let f=n+1,p=new Gn(null,r),h=[],m="";for(;f<t.length;){let g=t.charAt(f++);if(a||g==="\\"){a=!a,m+=g;continue}if(c){f===u+1?(g==="^"||g==="!")&&(d=!0):g==="]"&&!(f===u+2&&d)&&(c=!1),m+=g;continue}else if(g==="["){c=!0,u=f,d=!1,m+=g;continue}if(!i.noext&&T4(g)&&t.charAt(f)==="("&&(s<=o||r&&r.#g(g))){let b=r&&r.#g(g)?0:1;p.push(m),m="";let w=new Gn(g,p);p.push(w),f=Gn.#h(t,w,f,i,s+b);continue}if(g==="|"){p.push(m),m="",h.push(p),p=new Gn(null,r);continue}if(g===")")return m===""&&r.#t.length===0&&(r.#c=!0),p.push(m),m="",r.push(...h,p),f;m+=g}return r.type=null,r.#r=void 0,r.#t=[t.substring(n-1)],f}#C(t){return this.#m(t,Ime)}#m(t,r=Ame){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#g(n.type,r)}#g(t,r=_me){return!!r.get(this.type)?.includes(t)}#f(t,r){let n=t.#t[0],i=new Gn(null,n,this.options);i.#t.push(""),n.push(i),this.#E(t,r)}#E(t,r){let n=t.#t[0];this.#t.splice(r,1,...n.#t);for(let i of n.#t)typeof i=="object"&&(i.#i=this);this.#o=void 0}#S(t){return!!IL.get(this.type)?.has(t)}#O(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let r=t.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#y(t){let r=IL.get(this.type),n=t.#t[0],i=r?.get(n.type);if(!i)return!1;this.#t=n.#t;for(let s of this.#t)typeof s=="object"&&(s.#i=this);this.type=i,this.#o=void 0,this.#c=!1}static fromGlob(t,r={}){let n=new Gn(null,void 0,r);return Gn.#h(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#l.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#l}toRegExpSource(t){let r=t??!!this.#l.dot;if(this.#e===this&&(this.#p(),this.#x()),!AL(this)){let c=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),u=this.#t.map(h=>{let[m,g,y,b]=typeof h=="string"?Gn.#k(h,this.#r,c):h.toRegExpSource(t);return this.#r=this.#r||y,this.#n=this.#n||b,m}).join(""),d="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Cme.has(this.#t[0]))){let m=Tme,g=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),y=!r&&!t&&m.has(u.charAt(0));d=g?$me:y?x1:""}let f="";return this.isEnd()&&this.#e.#u&&this.#i?.type==="!"&&(f="(?:$|\\/)"),[d+u+f,Jo(u),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#v(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#r=void 0,[c,Jo(this.toString()),!1,!1]}let o=!n||t||r||!x1?"":this.#v(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!r?x1:"")+$L;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?x1:"")+_L+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,Jo(s),this.#r=!!this.#r,this.#n]}#p(){if(AL(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];typeof i=="object"&&(i.#p(),this.#m(i)?(r=!1,this.#E(i,n)):this.#C(i)?(r=!1,this.#f(i,n)):this.#O(i)&&(r=!1,this.#y(i)))}}while(!r&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#o=void 0}#v(t){return this.#t.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(t);return this.#n=this.#n||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#k(t,r,n=!1){let i=!1,s="",o=!1,a=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(i){i=!1,s+=(Ome.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=!0,s+=n&&/^[*]+$/.test(t)?$L:_L,r=!0;continue}else a=!1;if(u==="\\"){c===t.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[d,f,p,h]=kL(t,c);if(p){s+=d,o=o||f,c+=p-1,r=r||h;continue}}if(u==="?"){s+=C4,r=!0;continue}s+=Rme(u)}return[s,Jo(t),!!r,o]}};Gn=el;var O4=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Qr=l((e,t,r={})=>(Cf(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Wc(t,r).match(e)),"minimatch"),Pme=/^\*+([^+@!?*[(]*)$/,Dme=l(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),Lme=l(e=>t=>t.endsWith(e),"starDotExtTestDot"),Mme=l(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),Fme=l(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),Ume=/^\*+\.\*+$/,jme=l(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),zme=l(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),Bme=/^\.\*+$/,Wme=l(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),qme=/^\*+$/,Hme=l(e=>e.length!==0&&!e.startsWith("."),"starTest"),Gme=l(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),Vme=/^\?+([^+@!?*[(]*)?$/,Zme=l(([e,t=""])=>{let r=OL([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocase"),Kme=l(([e,t=""])=>{let r=RL([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},"qmarksTestNocaseDot"),Yme=l(([e,t=""])=>{let r=RL([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTestDot"),Xme=l(([e,t=""])=>{let r=OL([e]);return t?n=>r(n)&&n.endsWith(t):r},"qmarksTest"),OL=l(([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},"qmarksTestNoExt"),RL=l(([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},"qmarksTestNoExtDot"),NL=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",TL={win32:{sep:"\\"},posix:{sep:"/"}},Jme=NL==="win32"?TL.win32.sep:TL.posix.sep;Qr.sep=Jme;var bn=Symbol("globstar **");Qr.GLOBSTAR=bn;var Qme="[^/]",ege=Qme+"*?",tge="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",rge="(?:(?!(?:\\/|^)\\.).)*?",nge=l((e,t={})=>r=>Qr(r,e,t),"filter");Qr.filter=nge;var xi=l((e,t={})=>Object.assign({},e,t),"ext"),ige=l(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Qr;let t=Qr;return Object.assign(l((n,i,s={})=>t(n,i,xi(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{l(this,"Minimatch")}constructor(i,s={}){super(i,xi(e,s))}static defaults(i){return t.defaults(xi(e,i)).Minimatch}},AST:class extends t.AST{static{l(this,"AST")}constructor(i,s,o={}){super(i,s,xi(e,o))}static fromGlob(i,s={}){return t.AST.fromGlob(i,xi(e,s))}},unescape:l((n,i={})=>t.unescape(n,xi(e,i)),"unescape"),escape:l((n,i={})=>t.escape(n,xi(e,i)),"escape"),filter:l((n,i={})=>t.filter(n,xi(e,i)),"filter"),defaults:l(n=>t.defaults(xi(e,n)),"defaults"),makeRe:l((n,i={})=>t.makeRe(n,xi(e,i)),"makeRe"),braceExpand:l((n,i={})=>t.braceExpand(n,xi(e,i)),"braceExpand"),match:l((n,i,s={})=>t.match(n,i,xi(e,s)),"match"),sep:t.sep,GLOBSTAR:bn})},"defaults");Qr.defaults=ige;var PL=l((e,t={})=>(Cf(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:EL(e,{max:t.braceExpandMax})),"braceExpand");Qr.braceExpand=PL;var sge=l((e,t={})=>new Wc(e,t).makeRe(),"makeRe");Qr.makeRe=sge;var oge=l((e,t,r={})=>{let n=new Wc(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e},"match");Qr.match=oge;var CL=/[?*]|[+@!]\(.*?\)|\[|\]/,age=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Wc=class{static{l(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){Cf(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||NL,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!CL.test(s[2]))&&!CL.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let s=t[i];i===1&&s===""&&t[0]===""||(s==="."||s==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],u=n[i+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(i,1);let d=n.slice(0);d[i]="**",t.push(d),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,s=0,o=[],a="";for(;i<t.length&&s<r.length;)if(t[i]===r[s])o.push(a==="b"?r[s]:t[i]),i++,s++;else if(n&&t[i]==="**"&&r[s]===t[i+1])o.push(t[i]),i++;else if(n&&r[s]==="**"&&t[i]===r[s+1])o.push(r[s]),s++;else if(t[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(t[i]),i++,s++}else if(r[s]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return t.length===r.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,s=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),d=!u&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=c?3:a?0:void 0,p=d?3:u?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[h,m]=[t[f],r[p]];h.toLowerCase()===m.toLowerCase()&&(r[p]=h,s=p,i=f)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(bn)?this.#e(t,r,n,i,s):this.#n(t,r,n,i,s)}#e(t,r,n,i,s){let o=r.indexOf(bn,s),a=r.lastIndexOf(bn),[c,u,d]=n?[r.slice(s,o),r.slice(o+1),[]]:[r.slice(s,o),r.slice(o+1,a),r.slice(a+1)];if(c.length){let w=t.slice(i,i+c.length);if(!this.#n(w,c,n,0,0))return!1;i+=c.length,s+=c.length}let f=0;if(d.length){if(d.length+i>t.length)return!1;let w=t.length-d.length;if(this.#n(t,d,n,w,0))f=d.length;else{if(t[t.length-1]!==""||i+d.length===t.length||(w--,!this.#n(t,d,n,w,0)))return!1;f=d.length+1}}if(!u.length){let w=!!f;for(let x=i;x<t.length-f;x++){let k=String(t[x]);if(w=!0,k==="."||k===".."||!this.options.dot&&k.startsWith("."))return!1}return n||w}let p=[[[],0]],h=p[0],m=0,g=[0];for(let w of u)w===bn?(g.push(m),h=[[],0],p.push(h)):(h[0].push(w),m++);let y=p.length-1,b=t.length-f;for(let w of p)w[1]=b-(g[y--]+w[0].length);return!!this.#r(t,p,i,0,n,0,!!f)}#r(t,r,n,i,s,o,a){let c=r[i];if(!c){for(let f=n;f<t.length;f++){a=!0;let p=t[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[u,d]=c;for(;n<=d;){if(this.#n(t.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let h=this.#r(t,r,n+u.length,i+1,s,o+1,a);if(h!==!1)return h}let p=t[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(t,r,n,i,s){let o,a,c,u;for(o=i,a=s,u=t.length,c=r.length;o<u&&a<c;o++,a++){this.debug("matchOne loop");let d=r[a],f=t[o];if(this.debug(r,d,f),d===!1||d===bn)return!1;let p;if(typeof d=="string"?(p=f===d,this.debug("string match",d,f,p)):(p=d.test(f),this.debug("pattern match",d,f,p)),!p)return!1}if(o===u&&a===c)return!0;if(o===u)return n;if(a===c)return o===u-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return PL(this.pattern,this.options)}parse(t){Cf(t);let r=this.options;if(t==="**")return bn;if(t==="")return"";let n,i=null;(n=t.match(qme))?i=r.dot?Gme:Hme:(n=t.match(Pme))?i=(r.nocase?r.dot?Fme:Mme:r.dot?Lme:Dme)(n[1]):(n=t.match(Vme))?i=(r.nocase?r.dot?Kme:Zme:r.dot?Yme:Xme)(n):(n=t.match(Ume))?i=r.dot?zme:jme:(n=t.match(Bme))&&(i=Wme);let s=el.fromGlob(t,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?ege:r.dot?tge:rge,i=new Set(r.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))i.add(p);return typeof f=="string"?age(f):f===bn?bn:f._src});u.forEach((f,p)=>{let h=u[p+1],m=u[p-1];f!==bn||m===bn||(m===void 0?h!==void 0&&h!==bn?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=m+"(?:\\/|\\/"+n+")?":h!==bn&&(u[p-1]=m+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=bn))});let d=u.filter(f=>f!==bn);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a of s){let c=i;if(n.matchBase&&a.length===1&&(c=[o]),this.matchOne(c,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Qr.defaults(t).Minimatch}};Qr.AST=el;Qr.Minimatch=Wc;Qr.escape=O4;Qr.unescape=Jo;import{gunzipSync as a0e}from"node:zlib";var Rf=class{static{l(this,"Diff")}diff(t,r,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let s=this.castInput(t,n),o=this.castInput(r,n),a=this.removeEmpty(this.tokenize(s,n)),c=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(a,c,n,i)}diffWithOptionsObj(t,r,n,i){var s;let o=l(w=>{if(w=this.postProcess(w,n),i){setTimeout(function(){i(w)},0);return}else return w},"done"),a=r.length,c=t.length,u=1,d=a+c;n.maxEditLength!=null&&(d=Math.min(d,n.maxEditLength));let f=(s=n.timeout)!==null&&s!==void 0?s:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(h[0],r,t,0,n);if(h[0].oldPos+1>=c&&m+1>=a)return o(this.buildValues(h[0].lastComponent,r,t));let g=-1/0,y=1/0,b=l(()=>{for(let w=Math.max(g,-u);w<=Math.min(y,u);w+=2){let x,k=h[w-1],S=h[w+1];k&&(h[w-1]=void 0);let A=!1;if(S){let C=S.oldPos-w;A=S&&0<=C&&C<a}let I=k&&k.oldPos+1<c;if(!A&&!I){h[w]=void 0;continue}if(!I||A&&k.oldPos<S.oldPos?x=this.addToPath(S,!0,!1,0,n):x=this.addToPath(k,!1,!0,1,n),m=this.extractCommon(x,r,t,w,n),x.oldPos+1>=c&&m+1>=a)return o(this.buildValues(x.lastComponent,r,t))||!0;h[w]=x,x.oldPos+1>=c&&(y=Math.min(y,w-1)),m+1>=a&&(g=Math.max(g,w+1))}u++},"execEditLength");if(i)l(function w(){setTimeout(function(){if(u>d||Date.now()>p)return i(void 0);b()||w()},0)},"exec")();else for(;u<=d&&Date.now()<=p;){let w=b();if(w)return w}}addToPath(t,r,n,i,s){let o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===r&&o.removed===n?{oldPos:t.oldPos+i,lastComponent:{count:o.count+1,added:r,removed:n,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:r,removed:n,previousComponent:o}}}extractCommon(t,r,n,i,s){let o=r.length,a=n.length,c=t.oldPos,u=c-i,d=0;for(;u+1<o&&c+1<a&&this.equals(n[c+1],r[u+1],s);)u++,c++,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=c,u}equals(t,r,n){return n.comparator?n.comparator(t,r):t===r||!!n.ignoreCase&&t.toLowerCase()===r.toLowerCase()}removeEmpty(t){let r=[];for(let n=0;n<t.length;n++)t[n]&&r.push(t[n]);return r}castInput(t,r){return t}tokenize(t,r){return Array.from(t)}join(t){return t.join("")}postProcess(t,r){return t}get useLongestToken(){return!1}buildValues(t,r,n){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let o=i.length,a=0,c=0,u=0;for(;a<o;a++){let d=i[a];if(d.removed)d.value=this.join(n.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=r.slice(c,c+d.count);f=f.map(function(p,h){let m=n[u+h];return m.length>p.length?m:p}),d.value=this.join(f)}else d.value=this.join(r.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return i}};var R4=class extends Rf{static{l(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=cge}equals(t,r,n){return n.ignoreWhitespace?((!n.newlineIsToken||!t.includes(`
|
|
770
772
|
`))&&(t=t.trim()),(!n.newlineIsToken||!r.includes(`
|
|
771
773
|
`))&&(r=r.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(t.endsWith(`
|
|
772
774
|
`)&&(t=t.slice(0,-1)),r.endsWith(`
|
package/worker/isolated/index.js
CHANGED
|
@@ -515,7 +515,7 @@ ${_}`,f++;break;case"id":_.includes("\0")||(u=_);break;case"retry":/^\d+$/.test(
|
|
|
515
515
|
WHERE session_id = ? AND seq < ?
|
|
516
516
|
AND type IN ('user/message', 'assistant/message')
|
|
517
517
|
AND surface_op = '"append"'
|
|
518
|
-
ORDER BY seq DESC LIMIT ?`,t,o,a).toArray(),u=c.at(-1),d=c.length<a||u===void 0?0:mre(u);if(d>=o)return{summary:s,events:[],hasMore:d>0};let f=await this.coordinator.readValidatedPage(t,d,Tr.maxEvents,(p,h,g,y)=>h!==d?Promise.reject(new Error(`stored session ${t} history contains a legacy event that requires an unbounded prefix`)):this.loadStoredPage(p,h,g,Tr.maxStoredBytes,y,o),r);if(f.hasMore)throw new Error(`stored session ${t} history page exceeds the Edge limit of ${Tr.maxEvents} events or ${Tr.maxStoredBytes} stored bytes`);return{summary:s,events:f.events,hasMore:d>0}}loadStored(t,n){return _i(()=>{n?.throwIfAborted();let i=this.storage.transactionSync(()=>{let a=this.rowFor(t);if(a!==void 0)return{row:a,eventRows:this.eventRows(t,0)}});if(n?.throwIfAborted(),i===void 0)return;let{preserved:r,tornFrom:s}=x$(i.eventRows);return{meta:Ji(i.row),events:r,revision:Sx(this.storeIdentity,i.row),...s===void 0?{}:{tornMarker:s}}})}readStoredRevision(t,n){return _i(()=>{n?.throwIfAborted();let i=this.rowFor(t);return n?.throwIfAborted(),i===void 0?void 0:Sx(this.storeIdentity,i)})}loadStoredFrom(t,n,i){return _i(()=>{i?.throwIfAborted();let r=this.storage.transactionSync(()=>{let s=this.rowFor(t);if(s!==void 0)return{row:s,eventRows:this.eventRows(t,n)}});if(i?.throwIfAborted(),r!==void 0)return{meta:Ji(r.row),events:x$(r.eventRows,n).preserved}})}loadStoredPage(t,n,i,r,s,a){return _i(()=>{s?.throwIfAborted();let o=this.storage.transactionSync(()=>{let c=this.rowFor(t);if(c===void 0)return;let u=this.eventRowRangeContaining(t,n,i,a),d=this.lastCommittedSequence(t),f=[],p=0,h=!1,g=n;for(let y of u){let w=new TextEncoder().encode(y.data).byteLength;if(f.length>=i||w>r-p){h=!0;break}let x;try{x=_x(y)}catch{if(y.seq<=d)throw new Error(`corrupt session log: unparsable committed event at seq ${y.seq}`);break}p+=w;for(let k of x)if(!(k.seq<n)&&!(a!==void 0&&k.seq>=a)){if(k.seq!==g){if(k.seq<=d)throw new Error(`corrupt session log: seq gap in committed region (expected ${g}, got ${k.seq})`);h=!1;break}if(f.length>=i){h=!0;break}f.push(k),g=k.seq+1}}return{meta:Ji(c),events:f,hasMore:h}});return s?.throwIfAborted(),o})}appendBatch(t,n,i){return _i(()=>{this.storage.transactionSync(()=>{i||this.writeRow(t);let r=Hw(n);for(let a of r)this.
|
|
518
|
+
ORDER BY seq DESC LIMIT ?`,t,o,a).toArray(),u=c.at(-1),d=c.length<a||u===void 0?0:mre(u);if(d>=o)return{summary:s,events:[],hasMore:d>0};let f=await this.coordinator.readValidatedPage(t,d,Tr.maxEvents,(p,h,g,y)=>h!==d?Promise.reject(new Error(`stored session ${t} history contains a legacy event that requires an unbounded prefix`)):this.loadStoredPage(p,h,g,Tr.maxStoredBytes,y,o),r);if(f.hasMore)throw new Error(`stored session ${t} history page exceeds the Edge limit of ${Tr.maxEvents} events or ${Tr.maxStoredBytes} stored bytes`);return{summary:s,events:f.events,hasMore:d>0}}loadStored(t,n){return _i(()=>{n?.throwIfAborted();let i=this.storage.transactionSync(()=>{let a=this.rowFor(t);if(a!==void 0)return{row:a,eventRows:this.eventRows(t,0)}});if(n?.throwIfAborted(),i===void 0)return;let{preserved:r,tornFrom:s}=x$(i.eventRows);return{meta:Ji(i.row),events:r,revision:Sx(this.storeIdentity,i.row),...s===void 0?{}:{tornMarker:s}}})}readStoredRevision(t,n){return _i(()=>{n?.throwIfAborted();let i=this.rowFor(t);return n?.throwIfAborted(),i===void 0?void 0:Sx(this.storeIdentity,i)})}loadStoredFrom(t,n,i){return _i(()=>{i?.throwIfAborted();let r=this.storage.transactionSync(()=>{let s=this.rowFor(t);if(s!==void 0)return{row:s,eventRows:this.eventRows(t,n)}});if(i?.throwIfAborted(),r!==void 0)return{meta:Ji(r.row),events:x$(r.eventRows,n).preserved}})}loadStoredPage(t,n,i,r,s,a){return _i(()=>{s?.throwIfAborted();let o=this.storage.transactionSync(()=>{let c=this.rowFor(t);if(c===void 0)return;let u=this.eventRowRangeContaining(t,n,i,a),d=this.lastCommittedSequence(t),f=[],p=0,h=!1,g=n;for(let y of u){let w=new TextEncoder().encode(y.data).byteLength;if(f.length>=i||w>r-p){h=!0;break}let x;try{x=_x(y)}catch{if(y.seq<=d)throw new Error(`corrupt session log: unparsable committed event at seq ${y.seq}`);break}p+=w;for(let k of x)if(!(k.seq<n)&&!(a!==void 0&&k.seq>=a)){if(k.seq!==g){if(k.seq<=d)throw new Error(`corrupt session log: seq gap in committed region (expected ${g}, got ${k.seq})`);h=!1;break}if(f.length>=i){h=!0;break}f.push(k),g=k.seq+1}}return{meta:Ji(c),events:f,hasMore:h}});return s?.throwIfAborted(),o})}appendBatch(t,n,i){return _i(()=>{this.storage.transactionSync(()=>{i||this.writeRow(t);let r=Hw(n);for(let a of r)this.insertStorageRecord(t.id,a);if(this.storage.sql.exec("UPDATE dsh_sessions SET revision = revision + 1 WHERE id = ?",t.id).rowsWritten!==1)throw new Error(`session ${t.id} is not materialized`);this.storage.sql.exec("DELETE FROM dsh_edge_blank_sessions WHERE id = ?",t.id),this.updateSummaryFromBatch(t.id,n)})})}commitRepair(t,n,i){return _i(()=>{this.storage.transactionSync(()=>{n!==void 0&&this.storage.sql.exec("DELETE FROM dsh_session_events WHERE session_id = ? AND seq >= ?",t.id,n);for(let r of i)this.insertEvent(t.id,r);(n!==void 0||i.length>0)&&(this.storage.sql.exec("UPDATE dsh_sessions SET revision = revision + 1 WHERE id = ?",t.id),this.recomputeSummary(t.id))})})}list(t){return _i(()=>{t?.throwIfAborted();let n=this.storage.sql.exec(`SELECT id, version, created_at, cwd, parent_session, seed_length, origin,
|
|
519
519
|
delegation_depth, agent_preset, incarnation, revision
|
|
520
520
|
FROM dsh_sessions`).toArray();t?.throwIfAborted();let i=n.map(Ji),r=this.storage.sql.exec(`SELECT id, version, created_at, cwd, parent_session, seed_length, origin,
|
|
521
521
|
delegation_depth, agent_preset
|
|
@@ -535,12 +535,12 @@ ${_}`,f++;break;case"id":_.includes("\0")||(u=_);break;case"retry":/^\d+$/.test(
|
|
|
535
535
|
FROM dsh_edge_blank_sessions ORDER BY created_at DESC, id ASC LIMIT ?`,t).toArray().map(kx)}materializeBlankSession(t){return _i(()=>this.storage.transactionSync(()=>{let n=this.readBlankSession(t);return n===void 0?!1:(this.rowFor(t)===void 0&&this.writeRow(n),this.storage.sql.exec("DELETE FROM dsh_edge_blank_sessions WHERE id = ?",t),this.insertEmptyLogSummary(t,n.createdAt),!0)}))}readSessionSummary(t){let n=this.storage.sql.exec(`${bh} WHERE s.id = ?`,t).toArray()[0];return n===void 0?void 0:xh(n)}readSessionSummaryPage(t,n){return this.storage.transactionSync(()=>{let i=t===void 0?void 0:this.rowFor(t);if(t!==void 0&&i===void 0)return;let r=[],s=i===void 0?"":"WHERE (s.created_at < ? OR (s.created_at = ? AND s.id > ?))";i!==void 0&&r.push(i.created_at,i.created_at,i.id),r.push(n+1);let a=this.storage.sql.exec(`${bh} ${s}
|
|
536
536
|
ORDER BY s.created_at DESC, s.id ASC LIMIT ?`,...r).toArray();return{sessions:a.slice(0,n).map(xh),hasMore:a.length>n}})}readAllSessionSummaries(){return this.storage.sql.exec(`${bh}
|
|
537
537
|
ORDER BY coalesce(sm.last_prompt_at, s.created_at) DESC, s.id ASC`).toArray().map(xh)}readRecentSessionSummaries(t){return this.storage.sql.exec(`${bh}
|
|
538
|
-
ORDER BY coalesce(sm.last_prompt_at, s.created_at) DESC, s.id ASC LIMIT ?`,t).toArray().map(xh)}initialize(){
|
|
538
|
+
ORDER BY coalesce(sm.last_prompt_at, s.created_at) DESC, s.id ASC LIMIT ?`,t).toArray().map(xh)}initialize(){this.storage.sql.exec("PRAGMA foreign_keys = ON");let t=this.storage.transactionSync(()=>{this.storage.sql.exec(`CREATE TABLE IF NOT EXISTS dsh_session_persistence_state (
|
|
539
539
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
540
540
|
schema_version INTEGER NOT NULL,
|
|
541
541
|
store_id TEXT NOT NULL
|
|
542
|
-
) STRICT`);let
|
|
543
|
-
(singleton, schema_version, store_id) VALUES (1, ?, ?)`,Ex,
|
|
542
|
+
) STRICT`);let n=this.storage.sql.exec("SELECT schema_version, store_id FROM dsh_session_persistence_state WHERE singleton = 1").toArray()[0];if(n!==void 0&&n.schema_version!==Ex)throw new Error(`dsh-edge session schema ${n.schema_version} is incompatible with ${Ex}`);if(n!==void 0&&n.store_id.length===0)throw new Error("dsh-edge session persistence has no valid store identity");n===void 0&&this.removePreCanonicalPrototype();let i=n?.store_id??crypto.randomUUID();return this.storage.sql.exec(`INSERT OR IGNORE INTO dsh_session_persistence_state
|
|
543
|
+
(singleton, schema_version, store_id) VALUES (1, ?, ?)`,Ex,i),this.storage.sql.exec(`CREATE TABLE IF NOT EXISTS dsh_sessions (
|
|
544
544
|
id TEXT PRIMARY KEY,
|
|
545
545
|
version INTEGER NOT NULL,
|
|
546
546
|
created_at INTEGER NOT NULL,
|
|
@@ -582,9 +582,9 @@ ${_}`,f++;break;case"id":_.includes("\0")||(u=_);break;case"retry":/^\d+$/.test(
|
|
|
582
582
|
title_seq INTEGER,
|
|
583
583
|
title_time INTEGER,
|
|
584
584
|
title_data TEXT
|
|
585
|
-
) STRICT`),this.syncSummaries()
|
|
586
|
-
WHERE type = 'assistant/chunk' LIMIT 5`).toArray();for(let n of t)try{this.repackOneSession(n.id)}catch(i){console.error(`dsh-edge: repack failed for session ${n.id}
|
|
587
|
-
FROM dsh_session_events WHERE session_id = ? ORDER BY seq`,t).toArray(),i=n.flatMap(s=>_x(s)),r=Hw(i);
|
|
585
|
+
) STRICT`),this.syncSummaries(),`durable-object:store:${i}`});return this.repackExistingChunks(),t}repackExistingChunks(){let t=this.storage.sql.exec(`SELECT DISTINCT session_id AS id FROM dsh_session_events
|
|
586
|
+
WHERE type = 'assistant/chunk' LIMIT 5`).toArray();for(let n of t)try{this.repackOneSession(n.id)}catch(i){let r=i instanceof Error?i.message:String(i);console.error(`dsh-edge: repack failed for session ${n.id}: ${r}`)}}repackOneSession(t){let n=this.storage.sql.exec(`SELECT seq, type, time, data, source_event_seqs, surface_op, ignorable
|
|
587
|
+
FROM dsh_session_events WHERE session_id = ? ORDER BY seq`,t).toArray(),i=n.flatMap(s=>_x(s)),r=Hw(i);r.length>=n.length||this.storage.transactionSync(()=>{this.storage.sql.exec("DELETE FROM dsh_session_events WHERE session_id = ?",t);for(let s of r)this.insertStorageRecord(t,s)})}syncSummaries(){let t=this.storage.sql.exec(`SELECT s.id FROM dsh_sessions s
|
|
588
588
|
LEFT JOIN dsh_session_summaries sm ON s.id = sm.session_id
|
|
589
589
|
WHERE sm.session_id IS NULL OR sm.revision != s.revision`).toArray();for(let n of t)this.recomputeSummary(n.id)}recomputeSummary(t){let n=this.storage.sql.exec(`${hre} WHERE s.id = ?`,t).toArray()[0];n!==void 0&&this.storage.sql.exec(`INSERT INTO dsh_session_summaries
|
|
590
590
|
(session_id, revision, updated_at, last_prompt_at, last_seq, blank,
|
|
@@ -640,7 +640,9 @@ ${_}`,f++;break;case"id":_.includes("\0")||(u=_);break;case"retry":/^\d+$/.test(
|
|
|
640
640
|
delegation_depth = excluded.delegation_depth,
|
|
641
641
|
agent_preset = excluded.agent_preset`,t.id,t.version,t.createdAt,t.cwd??null,t.parentSession??null,t.seedLength??null,t.origin??null,t.delegationDepth??null,t.agentPreset??null,crypto.randomUUID())}insertEvent(t,n){let i=n;this.storage.sql.exec(`INSERT INTO dsh_session_events
|
|
642
642
|
(session_id, seq, type, time, data, source_event_seqs, surface_op, ignorable)
|
|
643
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,t,n.seq,n.type,n.time,JSON.stringify(n.data),i.sourceEventSeqs===void 0?null:JSON.stringify(i.sourceEventSeqs),i.surfaceOp===void 0?null:JSON.stringify(i.surfaceOp),n.ignorable===!0?1:null)}
|
|
643
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,t,n.seq,n.type,n.time,JSON.stringify(n.data),i.sourceEventSeqs===void 0?null:JSON.stringify(i.sourceEventSeqs),i.surfaceOp===void 0?null:JSON.stringify(i.surfaceOp),n.ignorable===!0?1:null)}insertStorageRecord(t,n){let i=n.seq??n.seq0,r=n.time??n.time0,s=n.type;this.storage.sql.exec(`INSERT INTO dsh_session_events
|
|
644
|
+
(session_id, seq, type, time, data, source_event_seqs, surface_op, ignorable)
|
|
645
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,t,i,s,r,JSON.stringify(n.data),n.sourceEventSeqs===void 0?null:JSON.stringify(n.sourceEventSeqs),n.surfaceOp===void 0?null:JSON.stringify(n.surfaceOp),n.ignorable===!0?1:null)}};function Sx(e,t){return`${e}:incarnation:${t.incarnation}:revision:${t.revision}`}l(Sx,"revisionOf");function _i(e){try{return Promise.resolve(e())}catch(t){let n=Promise.withResolvers();return n.reject(t),n.promise}}l(_i,"promiseFromSync");function Ji(e){if(!Number.isSafeInteger(e.created_at)||e.created_at<0)throw new Error("stored session createdAt must be a non-negative safe integer");return{id:e.id,version:e.version,createdAt:e.created_at,...e.cwd===null?{}:{cwd:e.cwd},...e.parent_session===null?{}:{parentSession:e.parent_session},...e.seed_length===null?{}:{seedLength:e.seed_length},...e.origin===null?{}:{origin:e.origin},...e.delegation_depth===null?{}:{delegationDepth:e.delegation_depth},...e.agent_preset===null?{}:{agentPreset:e.agent_preset}}}l(Ji,"rowToHeader");function kx(e){let t=Ji({...e,incarnation:"",revision:0});if(t.version!==Hi)throw new tl(cu(t.id,t.version));return t}l(kx,"blankRowToHeader");function _x(e){let t={type:e.type,seq:e.seq,time:e.time,data:JSON.parse(e.data),...e.source_event_seqs===null?{}:{sourceEventSeqs:JSON.parse(e.source_event_seqs)},...e.surface_op===null?{}:{surfaceOp:JSON.parse(e.surface_op)},...e.ignorable===1?{ignorable:!0}:{}};return YA(t)}l(_x,"rowToEvents");function mre(e){if(e.source_event_seqs===null)return e.seq;let t;try{t=JSON.parse(e.source_event_seqs)}catch{return e.seq}return!Array.isArray(t)||!t.every(n=>Number.isSafeInteger(n))?e.seq:t.reduce((n,i)=>Math.min(n,i),e.seq)}l(mre,"historyGroupStart");function xh(e){let t=Ji(e);if(t.version!==Hi)throw new tl(cu(t.id,t.version));let n=e.updated_at??t.createdAt;if(!Number.isSafeInteger(n))throw new Error(`stored session ${t.id} has an invalid latest event time`);if(e.last_prompt_at!==null&&!Number.isSafeInteger(e.last_prompt_at))throw new Error(`stored session ${t.id} has an invalid latest prompt time`);let i=e.last_seq??-1;if(!Number.isSafeInteger(i)||i<-1)throw new Error(`stored session ${t.id} has an invalid latest event sequence`);if(e.blank!==0&&e.blank!==1)throw new Error(`stored session ${t.id} has an invalid blank-session marker`);let r={meta:t,updatedAt:n,lastPromptAt:e.last_prompt_at,lastSeq:i,blank:e.blank===1};if([e.title_seq,e.title_time,e.title_data].every(a=>a===null))return r;if(e.title_seq===null||e.title_time===null||e.title_data===null)throw new Error(`stored session ${t.id} has an incomplete title event`);return{...r,titleEvent:gre(t.id,e.title_seq,e.title_time,e.title_data)}}l(xh,"rowToStoredSessionSummary");function gre(e,t,n,i){if(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n))throw new Error(`stored session ${e} has an invalid session/title envelope`);let r;try{r=JSON.parse(i)}catch{throw new Error(`stored session ${e} has unparsable session/title data`)}let s=yre(r);if(s===void 0)throw new Error(`stored session ${e} has invalid session/title data`);return{type:"session/title",seq:t,time:n,data:s}}l(gre,"storedTitleEvent");function yre(e){if(!Ix(e,["title","messageSeqs","source"])||typeof e.title!="string"||e.title.length===0||!wre(e.messageSeqs))return;let t=vre(e.source);if(t!==void 0)return{title:e.title,messageSeqs:[...e.messageSeqs],source:t}}l(yre,"sessionTitleEventData");function vre(e){if(Ix(e,["kind"],["provider","model"]))switch(e.kind){case"fallback":case"user":return Object.keys(e).length===1?{kind:e.kind}:void 0;case"provider":return typeof e.provider!="string"||e.provider.length===0?void 0:e.model===void 0?{kind:"provider",provider:e.provider}:!Ix(e.model,["provider","model"])||typeof e.model.provider!="string"||e.model.provider.length===0||typeof e.model.model!="string"||e.model.model.length===0?void 0:{kind:"provider",provider:e.provider,model:{provider:e.model.provider,model:e.model.model}};default:return}}l(vre,"sessionTitleSource");function wre(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0)}l(wre,"isSessionTitleMessageSeqs");function bre(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e.header;if(t===null||typeof t!="object"||Array.isArray(t))return;let n=t.config;if(n===null||typeof n!="object"||Array.isArray(n))return;let i=n;if(typeof i.provider!="string"||i.provider.length===0||typeof i.model!="string"||i.model.length===0)return;let r=i.reasoningEffort;if(!(r!==void 0&&(typeof r!="string"||r.length===0)))return{provider:i.provider,model:i.model,...r===void 0?{}:{reasoningEffort:r}}}l(bre,"requestHeaderConfig");function Ix(e,t,n=[]){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let i=Object.keys(e);return t.every(r=>Object.hasOwn(e,r))&&i.every(r=>t.includes(r)||n.includes(r))}l(Ix,"hasOnlyKeys");function x$(e,t=0,n){let i=e.map(c=>{try{return{ok:!0,events:_x(c)}}catch{return{ok:!1}}}),r=n;if(r===void 0){r=-1;for(let c=i.length-1;c>=0;c-=1)if(i[c]?.ok===!0&&e[c]?.type==="turn/end"){r=e[c]?.seq??-1;break}}let s=[],a=t,o=0;for(let c=0;c<e.length;c+=1){let u=i[c];if(u?.ok!==!0){if((e[c]?.seq??a)<=r)throw new Error(`corrupt session log: unparsable committed event at seq ${e[c]?.seq}`);break}let d=u.events.filter(p=>p.seq>=t),f=d[0]?.seq??a;if(f!==a){if(f<=r)throw new Error(`corrupt session log: seq gap in committed region (expected ${a}, got ${f})`);break}s.push(...d),a=(u.events[0]?.seq??a)+u.events.length,o++}return o<e.length?{preserved:s,tornFrom:t+s.length}:{preserved:s}}l(x$,"scanRows");var Sn=Ax;var xre="dsh-edge:session-model:",Cx=class{constructor(t){this.storage=t}storage;static{l(this,"EdgeModelSelectionBridge")}cache=new Map;current(t){return this.cache.get(t)}setCurrent(t,n){n===void 0?this.cache.delete(t):this.cache.set(t,n)}async load(t){let n=this.cache.get(t);if(n!==void 0)return n;let i=E$(await this.storage.get(Eh(t)));return i!==void 0&&this.cache.set(t,i),i}async save(t,n){await this.storage.put(Eh(t),n),this.cache.set(t,n)}async clearIfLogged(t,n){let i=await this.storage.transaction(async r=>{let s=await r.get(Eh(t));if(s===void 0)return!0;let a=E$(s);return a!==void 0&&!S$(a,n)?!1:(await r.delete(Eh(t)),!0)});return i&&S$(this.cache.get(t),n)&&this.cache.delete(t),i}};function Eh(e){return`${xre}${e}`}l(Eh,"storageKey");function E$(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e;if(typeof t.provider!="string"||t.provider.length===0||typeof t.model!="string"||t.model.length===0)return;let n=t.reasoningEffort;if(!(n!==void 0&&(typeof n!="string"||n.length===0)))return{provider:t.provider,model:t.model,...n===void 0?{}:{reasoningEffort:n}}}l(E$,"parseStoredModelSelection");function S$(e,t){return e?.provider===t.provider&&e.model===t.model&&e.reasoningEffort===t.reasoningEffort}l(S$,"sameModelSelection");var k$=Cx;var Tx={};On(Tx,{TOOL_TIMEOUT:()=>$x,apply:()=>Ire,inject:()=>Are,name:()=>kre});var Ere=l(function(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var i,r;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=t[Symbol.asyncDispose]}if(i===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=t[Symbol.dispose],n&&(r=i)}if(typeof i!="function")throw new TypeError("Object not disposable.");r&&(i=l(function(){try{r.call(this)}catch(s){return Promise.reject(s)}},"dispose")),e.stack.push({value:t,dispose:i,async:n})}else n&&e.stack.push({async:!0});return t},"__addDisposableResource"),Sre=(function(e){return function(t){function n(a){t.error=t.hasError?new e(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}l(n,"fail");var i,r=0;function s(){for(;i=t.stack.pop();)try{if(!i.async&&r===1)return r=0,t.stack.push(i),Promise.resolve().then(s);if(i.dispose){var a=i.dispose.call(i.value);if(i.async)return r|=2,Promise.resolve(a).then(s,function(o){return n(o),s()})}else r|=1}catch(o){n(o)}if(r===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return l(s,"next"),s()}})(typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var i=new Error(n);return i.name="SuppressedError",i.error=e,i.suppressed=t,i}),$x="TOOL_TIMEOUT",kre="timeout-policy",Are=["tools"];function _re(e){let t=`tool call timed out after ${e}ms`;return{content:[{type:"text",text:`Error: ${t}`}],isError:!0,error:{message:t,info:{name:"ToolTimeoutError",code:$x}}}}l(_re,"toolTimeoutResult");function Ire(e){e.on("tools/execute",async(t,n)=>{let i={stack:[],error:void 0,hasError:!1};try{let r=e.tools.get(t.name,t.agent)?.timeoutMs;if(r===void 0)return n();let s=Ere(i,eo(t.signal,r,$x),!1),a=t.signal;t.signal=s.signal;try{let o=await n();return Dd(s.signal,"TOOL_TIMEOUT")!==void 0?_re(r):o}finally{t.signal=a}}catch(r){i.error=r,i.hasError=!0}finally{Sre(i)}})}l(Ire,"apply");var Hx={};On(Hx,{Config:()=>Tie,DEFAULT_FETCH_MAX_OUTPUT_CHARS:()=>bT,DEFAULT_WEB_TOOL_TIMEOUT_MS:()=>qx,WEB_SEARCH_MAX_QUERIES:()=>fie,WEB_SEARCH_MAX_RESULTS:()=>die,apply:()=>Nie,applyWebFetchTool:()=>wT,applyWebSearchTool:()=>uT,fetchMetaFromResult:()=>yT,fetchMetaFromValue:()=>gT,formatFetchOutput:()=>hT,formatSearchOutput:()=>iT,inject:()=>$ie,name:()=>Cie,parseFetchArgs:()=>fT,presentFetchCall:()=>mT,presentFetchResult:()=>vT,presentSearchCall:()=>sT,presentSearchResult:()=>cT,searchMetaFromResult:()=>lT,searchMetaFromValue:()=>oT});function Cre(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}l(Cre,"extend");function Px(e,t){return Array(t+1).join(e)}l(Px,"repeat");function I$(e){return e.replace(/^\n*/,"")}l(I$,"trimLeadingNewlines");function C$(e){for(var t=e.length;t>0&&e[t-1]===`
|
|
644
646
|
`;)t--;return e.substring(0,t)}l(C$,"trimTrailingNewlines");function $$(e){return C$(I$(e))}l($$,"trimNewlines");var $re=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Dx(e){return Lx(e,$re)}l(Dx,"isBlock");var T$=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function N$(e){return Lx(e,T$)}l(N$,"isVoid");function Tre(e){return O$(e,T$)}l(Tre,"hasVoid");var R$=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function Nre(e){return Lx(e,R$)}l(Nre,"isMeaningfulWhenBlank");function Rre(e){return O$(e,R$)}l(Rre,"hasMeaningfulWhenBlank");function Lx(e,t){return t.indexOf(e.nodeName)>=0}l(Lx,"is");function O$(e,t){return e.getElementsByTagName&&t.some(function(n){return e.getElementsByTagName(n).length})}l(O$,"has");var Ore=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function P$(e){return Ore.reduce(function(t,n){return t.replace(n[0],n[1])},e)}l(P$,"escapeMarkdown");var Fn={};Fn.paragraph={filter:"p",replacement:l(function(e){return`
|
|
645
647
|
|
|
646
648
|
`+e+`
|
|
@@ -766,7 +768,7 @@ ${i}`:""}`}});function fT(e){if(e.url.trim().length===0)throw new Error("url mus
|
|
|
766
768
|
button, .button { display: inline-block; box-sizing: border-box; margin-top: 1rem; padding: .75rem 1rem; border: 0; border-radius: .6rem; background: #5a87ff; color: #071022; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
|
|
767
769
|
.secondary { background: #29314b; color: #edf2ff; }
|
|
768
770
|
.error { padding: .75rem; border-radius: .5rem; background: #461d2b; color: #ffd6df; }
|
|
769
|
-
`}l(uN,"pageStyles");var Sse="https://api.deepseek.com";var kse="deepseek-v4-flash",Ase="high";var _se=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;function t6(e){let t=e??Sse,n;try{n=new URL(t)}catch{throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL")}if(n.protocol!=="http:"&&n.protocol!=="https:"||n.username.length>0||n.password.length>0)throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL without credentials");return t}l(t6,"resolveEdgeBaseURL");function vu(e){if(e===void 0)return kse;if(!_se.test(e))throw new Error("dsh-edge: DEEPSEEK_MODEL must be a valid model id of at most 128 characters");return e}l(vu,"resolveEdgeModel");function n6(e){if(e===void 0)return Ase;if(e!=="off"&&e!=="low"&&e!=="high"&&e!=="max")throw new Error("dsh-edge: DEEPSEEK_REASONING_EFFORT must be one of off, low, high, or max");return e}l(n6,"resolveEdgeReasoningEffort");function r6(e){if(e===void 0)return 12e4;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t)||t>2147483647)throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be no greater than 2147483647");return t}l(r6,"resolveEdgeStreamIdleTimeoutMs");function i6(e){if(e===void 0)return 256e3;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t))throw new Error(`dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be no greater than ${Number.MAX_SAFE_INTEGER}`);return t}l(i6,"resolveEdgeMaxOutputTokens");var s6={name:"dsh-edge",version:"0.6.0-alpha.6",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.1.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","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","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: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.0","jsonc-parser":"^3.3.1",wrangler:"4.123.0"},devDependencies:{"@cloudflare/computer":"0.2.0","@cloudflare/workers-types":"5.20260812.1","@deepseek-ai/cordis":"4.0.1","@deepseek-ai/dsh-agent":"0.1.1-rc.2","@deepseek-ai/dsh-agent-loop":"0.1.1-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.1.1-rc.2","@deepseek-ai/dsh-attachment":"0.1.1-rc.2","@deepseek-ai/dsh-brand":"0.1.1-rc.2","@deepseek-ai/dsh-compaction":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-basic":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.1.1-rc.2","@deepseek-ai/dsh-credentials":"0.1.1-rc.2","@deepseek-ai/dsh-host-apiproxy":"0.1.1-rc.2","@deepseek-ai/dsh-launch-environment":"0.1.1-rc.2","@deepseek-ai/dsh-llm":"0.1.1-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-session":"0.1.1-rc.2","@deepseek-ai/dsh-session-persistence":"0.1.1-rc.2","@deepseek-ai/dsh-session-projection":"0.1.1-rc.2","@deepseek-ai/dsh-session-query":"0.1.1-rc.2","@deepseek-ai/dsh-session-title":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-llm":"0.1.1-rc.2","@deepseek-ai/dsh-output-retention":"0.1.1-rc.2","@deepseek-ai/dsh-settings":"0.1.1-rc.2","@deepseek-ai/dsh-spill":"0.1.1-rc.2","@deepseek-ai/dsh-spill-policy":"0.1.1-rc.2","@deepseek-ai/dsh-storage":"0.1.1-rc.2","@deepseek-ai/dsh-storage-domain":"0.1.1-rc.2","@deepseek-ai/dsh-timeout":"0.1.1-rc.2","@deepseek-ai/dsh-token-meter":"0.1.1-rc.2","@deepseek-ai/dsh-system-prompt":"0.1.1-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.1-rc.2","@deepseek-ai/dsh-tool-web":"0.1.1-rc.2","@deepseek-ai/dsh-tools":"0.1.1-rc.2","@deepseek-ai/dsh-web":"0.1.1-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-workspace":"0.1.1-rc.2","just-bash":"3.3.0","fast-png":"8.0.0","jpeg-js":"0.4.4",playwright:"^1.49.0",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}};var Wh=s6.version,dN=s6.dshEdge.upstreamVersion;function Cse(){return"dsh-edge@0.6.0-alpha.6/isolated"}l(Cse,"resolveEdgeDeploymentId");function qh(e){return{baseURL:t6(e.DEEPSEEK_BASE_URL),maxTokens:i6(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:vu(e.DEEPSEEK_MODEL),reasoningEffort:n6(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:_h(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:r6(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:hu(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(qh,"resolveEdgeDeploymentConfig");function $se(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}l($se,"edgeDeploymentApiKeyConfigured");function Tse(e){let t=t6(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}l(Tse,"projectedEdgeBaseURL");function a6(e,t){return{shell:e.LOADER===void 0?"just-bash-direct":"just-bash-isolated",storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:Cse(),apiKeyConfigured:$se(e),baseURL:Tse(e.DEEPSEEK_BASE_URL),maxTokens:i6(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:vu(e.DEEPSEEK_MODEL),reasoningEffort:n6(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:_h(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:r6(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:hu(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(a6,"resolveEdgeDeploymentProfile");function fN(e){qh(e);let t=a6(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,version:Wh,upstreamVersion:dN,status:"ready"}}l(fN,"resolveEdgeDeploymentHealth");import{WorkerEntrypoint as QIe}from"cloudflare:workers";var Ha=E1(pN(),1);var o6=l((e,t,n)=>{let i=e instanceof RegExp?hN(e,n):e,r=t instanceof RegExp?hN(t,n):t,s=i!==null&&r!=null&&Nse(i,r,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+i.length,s[1]),post:n.slice(s[1]+r.length)}},"balanced"),hN=l((e,t)=>{let n=t.match(e);return n?n[0]:null},"maybeMatch"),Nse=l((e,t,n)=>{let i,r,s,a,o,c=n.indexOf(e),u=n.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(i=[],s=n.length;d>=0&&!o;){if(d===c)i.push(d),c=n.indexOf(e,d+1);else if(i.length===1){let f=i.pop();f!==void 0&&(o=[f,u])}else r=i.pop(),r!==void 0&&r<s&&(s=r,a=u),u=n.indexOf(t,d+1);d=c<u&&c>=0?c:u}i.length&&a!==void 0&&(o=[s,a])}return o},"range");var mN="\0SLASH"+Math.random()+"\0",gN="\0OPEN"+Math.random()+"\0",u6="\0CLOSE"+Math.random()+"\0",yN="\0COMMA"+Math.random()+"\0",vN="\0PERIOD"+Math.random()+"\0",Rse=new RegExp(mN,"g"),Ose=new RegExp(gN,"g"),Pse=new RegExp(u6,"g"),Dse=new RegExp(yN,"g"),Lse=new RegExp(vN,"g"),Mse=/\\\\/g,jse=/\\{/g,Fse=/\\}/g,Use=/\\,/g,zse=/\\\./g,Bse=1e5,Wse=4e6;function l6(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}l(l6,"numeric");function qse(e){return e.replace(Mse,mN).replace(jse,gN).replace(Fse,u6).replace(Use,yN).replace(zse,vN)}l(qse,"escapeBraces");function Hse(e){return e.replace(Rse,"\\").replace(Ose,"{").replace(Pse,"}").replace(Dse,",").replace(Lse,".")}l(Hse,"unescapeBraces");function wN(e){if(!e)return[""];let t=[],n=o6("{","}",e);if(!n)return e.split(",");let{pre:i,body:r,post:s}=n,a=i.split(",");a[a.length-1]+="{"+r+"}";let o=wN(s);return s.length&&(a[a.length-1]+=o.shift(),a.push.apply(a,o)),t.push.apply(t,a),t}l(wN,"parseCommaParts");function bN(e,t={}){if(!e)return[];let{max:n=Bse,maxLength:i=Wse}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),c6(qse(e),n,i,!0).map(Hse)}l(bN,"expand");function Gse(e){return"{"+e+"}"}l(Gse,"embrace");function Vse(e){return/^-?0\d/.test(e)}l(Vse,"isPadded");function Zse(e,t){return e<=t}l(Zse,"lte");function Kse(e,t){return e>=t}l(Kse,"gte");function wu(e,t,n,i,r,s){let a=[],o=0;for(let c=0;c<e.length;c++)for(let u=0;u<n.length;u++){if(a.length>=i)return a;let d=e[c]+t+n[u];if(!(s&&!d)){if(o+d.length>r)return a;a.push(d),o+=d.length}}return a}l(wu,"combine");function Xse(e,t,n,i){let r=e.split(/\.\./),s=[];if(r[0]===void 0||r[1]===void 0)return s;let a=l6(r[0]),o=l6(r[1]),c=Math.max(r[0].length,r[1].length),u=r.length===3&&r[2]!==void 0?Math.max(Math.abs(l6(r[2])),1):1,d=Zse;o<a&&(u*=-1,d=Kse);let p=r.some(Vse),h=0;for(let g=a;d(g,o)&&s.length<n;g+=u){let y;if(t)y=String.fromCharCode(g),y==="\\"&&(y="");else if(y=String(g),p){let w=c-y.length;if(w>0){let x=new Array(w+1).join("0");g<0?y="-"+x+y.slice(1):y=x+y}}if(h+y.length>i)break;s.push(y),h+=y.length}return s}l(Xse,"expandSequence");function c6(e,t,n,i){let r=[""],s=!1,a=!0;for(;;){let o=o6("{","}",e);if(!o)return wu(r,e,[""],t,n,s);let c=o.pre;if(/\$$/.test(c)){if(r=wu(r,c+"{"+o.body+"}",[""],t,n,s&&!o.post.length),a=!1,!o.post.length)break;e=o.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),f=u||d,p=o.body.indexOf(",")>=0;if(!f&&!p){if(o.post.match(/,(?!,).*\}/)){e=o.pre+"{"+o.body+u6+o.post,i=!0;continue}return wu(r,c+"{"+o.body+"}"+o.post,[""],t,n,s)}a&&(s=i&&!f,a=!1);let h;if(f)h=Xse(o.body,d,t,n);else{let g=wN(o.body);if(g.length===1&&g[0]!==void 0&&(g=c6(g[0],t,n,!1).map(Gse),g.length===1)){if(r=wu(r,c+g[0],[""],t,n,s&&!o.post.length),!o.post.length)break;e=o.post;continue}let y=s&&!o.post.length&&!c;for(let x=0;y&&x<r.length;x++)r[x]&&(y=!1);h=[];let w=0;e:for(let x=0;x<g.length;x++){let k=c6(g[x],t,n,!1);for(let E=0;E<k.length;E++){let A=k[E];if(!(y&&!A)){if(h.length>=t||w+A.length>n)break e;h.push(A),w+=A.length}}}}if(r=wu(r,c,h,t,n,s&&!o.post.length),!o.post.length)break;e=o.post}return r}l(c6,"expand_");var bu=l(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Qse={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},xu=l(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Jse=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),xN=l(e=>e.join(""),"rangesToString"),EN=l((e,t)=>{let n=t;if(e.charAt(n)!=="[")throw new Error("not in a brace expression");let i=[],r=[],s=n+1,a=!1,o=!1,c=!1,u=!1,d=n,f="";e:for(;s<e.length;){let y=e.charAt(s);if((y==="!"||y==="^")&&s===n+1){u=!0,s++;continue}if(y==="]"&&a&&!c){d=s+1;break}if(a=!0,y==="\\"&&!c){c=!0,s++;continue}if(y==="["&&!c){for(let[w,[x,k,E]]of Object.entries(Qse))if(e.startsWith(w,s)){if(f)return["$.",!1,e.length-n,!0];s+=w.length,E?r.push(x):i.push(x),o=o||k;continue e}}if(c=!1,f){y>f?i.push(xu(f)+"-"+xu(y)):y===f&&i.push(xu(y)),f="",s++;continue}if(e.startsWith("-]",s+1)){i.push(xu(y+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=y,s+=2;continue}i.push(xu(y)),s++}if(d<s)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,e.length-n,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!u){let y=i[0].length===2?i[0].slice(-1):i[0];return[Jse(y),!1,d-n,!1]}let p="["+(u?"^":"")+xN(i)+"]",h="["+(u?"":"^")+xN(r)+"]";return[i.length&&r.length?"("+p+"|"+h+")":i.length?p:h,o,d-n,!0]},"parseClass");var Rs=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var dr,Yse=new Set(["!","?","+","*","@"]),d6=l(e=>Yse.has(e),"isExtglobType"),SN=l(e=>d6(e.type),"isExtglobAST"),eae=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),tae=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),nae=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),kN=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),rae="(?!(?:^|/)\\.\\.?(?:$|/))",Gh="(?!\\.)",iae=new Set(["[","."]),sae=new Set(["..","."]),aae=new Set("().*{}+?[]^$\\!"),oae=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),f6="[^/]",AN=f6+"*?",_N=f6+"+?",lae=0,Ca=class{static{l(this,"AST")}type;#e;#n;#r=!1;#t=[];#i;#s;#o;#u=!1;#l;#a;#c=!1;id=++lae;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,n,i={}){this.type=t,t&&(this.#n=!0),this.#i=n,this.#e=this.#i?this.#i.#e:this,this.#l=this.#e===this?i:this.#e.#l,this.#o=this.#e===this?[]:this.#e.#o,t==="!"&&!this.#e.#u&&this.#o.push(this),this.#s=this.#i?this.#i.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#a=this.#t.map(t=>String(t)).join("")}#x(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#o.pop();){if(t.type!=="!")continue;let n=t,i=n.#i;for(;i;){for(let r=n.#s+1;!i.type&&r<i.#t.length;r++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(i.#t[r])}n=i,i=n.#i}}return this}push(...t){for(let n of t)if(n!==""){if(typeof n!="string"&&!(n instanceof dr&&n.#i===this))throw new Error("invalid part: "+n);this.#t.push(n)}}toJSON(){let t=this.type===null?this.#t.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#t.map(n=>n.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let n=0;n<this.#s;n++){let i=t.#t[n];if(!(i instanceof dr&&i.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#t.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let n=new dr(this.type,t);for(let i of this.#t)n.copyIn(i);return n}static#h(t,n,i,r,s){let a=r.maxExtglobRecursion??2,o=!1,c=!1,u=-1,d=!1;if(n.type===null){let y=i,w="";for(;y<t.length;){let x=t.charAt(y++);if(o||x==="\\"){o=!o,w+=x;continue}if(c){y===u+1?(x==="^"||x==="!")&&(d=!0):x==="]"&&!(y===u+2&&d)&&(c=!1),w+=x;continue}else if(x==="["){c=!0,u=y,d=!1,w+=x;continue}if(!r.noext&&d6(x)&&t.charAt(y)==="("&&s<=a){n.push(w),w="";let E=new dr(x,n);y=dr.#h(t,E,y,r,s+1),n.push(E);continue}w+=x}return n.push(w),y}let f=i+1,p=new dr(null,n),h=[],g="";for(;f<t.length;){let y=t.charAt(f++);if(o||y==="\\"){o=!o,g+=y;continue}if(c){f===u+1?(y==="^"||y==="!")&&(d=!0):y==="]"&&!(f===u+2&&d)&&(c=!1),g+=y;continue}else if(y==="["){c=!0,u=f,d=!1,g+=y;continue}if(!r.noext&&d6(y)&&t.charAt(f)==="("&&(s<=a||n&&n.#g(y))){let x=n&&n.#g(y)?0:1;p.push(g),g="";let k=new dr(y,p);p.push(k),f=dr.#h(t,k,f,r,s+x);continue}if(y==="|"){p.push(g),g="",h.push(p),p=new dr(null,n);continue}if(y===")")return g===""&&n.#t.length===0&&(n.#c=!0),p.push(g),g="",n.push(...h,p),f;g+=y}return n.type=null,n.#n=void 0,n.#t=[t.substring(i-1)],f}#T(t){return this.#m(t,tae)}#m(t,n=eae){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let i=t.#t[0];return!i||typeof i!="object"||i.type===null?!1:this.#g(i.type,n)}#g(t,n=nae){return!!n.get(this.type)?.includes(t)}#f(t,n){let i=t.#t[0],r=new dr(null,i,this.options);r.#t.push(""),i.push(r),this.#E(t,n)}#E(t,n){let i=t.#t[0];this.#t.splice(n,1,...i.#t);for(let r of i.#t)typeof r=="object"&&(r.#i=this);this.#a=void 0}#S(t){return!!kN.get(this.type)?.has(t)}#N(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#S(n.type)}#y(t){let n=kN.get(this.type),i=t.#t[0],r=n?.get(i.type);if(!r)return!1;this.#t=i.#t;for(let s of this.#t)typeof s=="object"&&(s.#i=this);this.type=r,this.#a=void 0,this.#c=!1}static fromGlob(t,n={}){let i=new dr(null,void 0,n);return dr.#h(t,i,0,n,0),i}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[n,i,r,s]=this.toRegExpSource();if(!(r||this.#n||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let o=(this.#l.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${n}$`,o),{_src:n,_glob:t})}get options(){return this.#l}toRegExpSource(t){let n=t??!!this.#l.dot;if(this.#e===this&&(this.#p(),this.#x()),!SN(this)){let c=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),u=this.#t.map(h=>{let[g,y,w,x]=typeof h=="string"?dr.#k(h,this.#n,c):h.toRegExpSource(t);return this.#n=this.#n||w,this.#r=this.#r||x,g}).join(""),d="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&sae.has(this.#t[0]))){let g=iae,y=n&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),w=!n&&!t&&g.has(u.charAt(0));d=y?rae:w?Gh:""}let f="";return this.isEnd()&&this.#e.#u&&this.#i?.type==="!"&&(f="(?:$|\\/)"),[d+u+f,Rs(u),this.#n=!!this.#n,this.#r]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#v(n);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#n=void 0,[c,Rs(this.toString()),!1,!1]}let a=!i||t||n||!Gh?"":this.#v(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let o="";if(this.type==="!"&&this.#c)o=(this.isStart()&&!n?Gh:"")+_N;else{let c=this.type==="!"?"))"+(this.isStart()&&!n&&!t?Gh:"")+AN+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;o=r+s+c}return[o,Rs(s),this.#n=!!this.#n,this.#r]}#p(){if(SN(this)){let t=0,n=!1;do{n=!0;for(let i=0;i<this.#t.length;i++){let r=this.#t[i];typeof r=="object"&&(r.#p(),this.#m(r)?(n=!1,this.#E(r,i)):this.#T(r)?(n=!1,this.#f(r,i)):this.#N(r)&&(n=!1,this.#y(r)))}}while(!n&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#a=void 0}#v(t){return this.#t.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[i,r,s,a]=n.toRegExpSource(t);return this.#r=this.#r||a,i}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#k(t,n,i=!1){let r=!1,s="",a=!1,o=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(r){r=!1,s+=(aae.has(u)?"\\":"")+u;continue}if(u==="*"){if(o)continue;o=!0,s+=i&&/^[*]+$/.test(t)?_N:AN,n=!0;continue}else o=!1;if(u==="\\"){c===t.length-1?s+="\\\\":r=!0;continue}if(u==="["){let[d,f,p,h]=EN(t,c);if(p){s+=d,a=a||f,c+=p-1,n=n||h;continue}}if(u==="?"){s+=f6,n=!0;continue}s+=oae(u)}return[s,Rs(t),!!n,a]}};dr=Ca;var p6=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var kn=l((e,t,n={})=>(bu(t),!n.nocomment&&t.charAt(0)==="#"?!1:new sl(t,n).match(e)),"minimatch"),cae=/^\*+([^+@!?*[(]*)$/,uae=l(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),dae=l(e=>t=>t.endsWith(e),"starDotExtTestDot"),fae=l(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),pae=l(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),hae=/^\*+\.\*+$/,mae=l(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),gae=l(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),yae=/^\.\*+$/,vae=l(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),wae=/^\*+$/,bae=l(e=>e.length!==0&&!e.startsWith("."),"starTest"),xae=l(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),Eae=/^\?+([^+@!?*[(]*)?$/,Sae=l(([e,t=""])=>{let n=$N([e]);return t?(t=t.toLowerCase(),i=>n(i)&&i.toLowerCase().endsWith(t)):n},"qmarksTestNocase"),kae=l(([e,t=""])=>{let n=TN([e]);return t?(t=t.toLowerCase(),i=>n(i)&&i.toLowerCase().endsWith(t)):n},"qmarksTestNocaseDot"),Aae=l(([e,t=""])=>{let n=TN([e]);return t?i=>n(i)&&i.endsWith(t):n},"qmarksTestDot"),_ae=l(([e,t=""])=>{let n=$N([e]);return t?i=>n(i)&&i.endsWith(t):n},"qmarksTest"),$N=l(([e])=>{let t=e.length;return n=>n.length===t&&!n.startsWith(".")},"qmarksTestNoExt"),TN=l(([e])=>{let t=e.length;return n=>n.length===t&&n!=="."&&n!==".."},"qmarksTestNoExtDot"),NN=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",IN={win32:{sep:"\\"},posix:{sep:"/"}},Iae=NN==="win32"?IN.win32.sep:IN.posix.sep;kn.sep=Iae;var zn=Symbol("globstar **");kn.GLOBSTAR=zn;var Cae="[^/]",$ae=Cae+"*?",Tae="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Nae="(?:(?!(?:\\/|^)\\.).)*?",Rae=l((e,t={})=>n=>kn(n,e,t),"filter");kn.filter=Rae;var Nr=l((e,t={})=>Object.assign({},e,t),"ext"),Oae=l(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return kn;let t=kn;return Object.assign(l((i,r,s={})=>t(i,r,Nr(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{l(this,"Minimatch")}constructor(r,s={}){super(r,Nr(e,s))}static defaults(r){return t.defaults(Nr(e,r)).Minimatch}},AST:class extends t.AST{static{l(this,"AST")}constructor(r,s,a={}){super(r,s,Nr(e,a))}static fromGlob(r,s={}){return t.AST.fromGlob(r,Nr(e,s))}},unescape:l((i,r={})=>t.unescape(i,Nr(e,r)),"unescape"),escape:l((i,r={})=>t.escape(i,Nr(e,r)),"escape"),filter:l((i,r={})=>t.filter(i,Nr(e,r)),"filter"),defaults:l(i=>t.defaults(Nr(e,i)),"defaults"),makeRe:l((i,r={})=>t.makeRe(i,Nr(e,r)),"makeRe"),braceExpand:l((i,r={})=>t.braceExpand(i,Nr(e,r)),"braceExpand"),match:l((i,r,s={})=>t.match(i,r,Nr(e,s)),"match"),sep:t.sep,GLOBSTAR:zn})},"defaults");kn.defaults=Oae;var RN=l((e,t={})=>(bu(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:bN(e,{max:t.braceExpandMax})),"braceExpand");kn.braceExpand=RN;var Pae=l((e,t={})=>new sl(e,t).makeRe(),"makeRe");kn.makeRe=Pae;var Dae=l((e,t,n={})=>{let i=new sl(t,n);return e=e.filter(r=>i.match(r)),i.options.nonull&&!e.length&&e.push(t),e},"match");kn.match=Dae;var CN=/[?*]|[+@!]\(.*?\)|\[|\]/,Lae=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),sl=class{static{l(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,n={}){bu(t),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=t,this.platform=n.platform||NN,this.isWindows=this.platform==="win32";let i="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[i]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let n of t)if(typeof n!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,n=this.options;if(!n.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let r=this.globParts.map((s,a,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!CN.test(s[2]))&&!CN.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,r),this.set=r.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i of t)for(let r=0;r<i.length;r++)i[r]==="**"&&(i[r]="*");let{optimizationLevel:n=1}=this.options;return n>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):n>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(n=>{let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let r=i;for(;n[r+1]==="**";)r++;r!==i&&n.splice(i,r-i)}return n})}levelOneOptimize(t){return t.map(n=>(n=n.reduce((i,r)=>{let s=i[i.length-1];return r==="**"&&s==="**"?i:r===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(i.pop(),i):(i.push(r),i)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let s=t[r];r===1&&s===""&&t[0]===""||(s==="."||s==="")&&(n=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(n=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let r=t[i-1];r&&r!=="."&&r!==".."&&r!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(n=!0,t.splice(i-1,2),i-=2)}}while(n);return t.length===0?[""]:t}firstPhasePreProcess(t){let n=!1;do{n=!1;for(let i of t){let r=-1;for(;(r=i.indexOf("**",r+1))!==-1;){let a=r;for(;i[a+1]==="**";)a++;a>r&&i.splice(r+1,a-r);let o=i[r+1],c=i[r+2],u=i[r+3];if(o!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;n=!0,i.splice(r,1);let d=i.slice(0);d[r]="**",t.push(d),r--}if(!this.preserveMultipleSlashes){for(let a=1;a<i.length-1;a++){let o=i[a];a===1&&o===""&&i[0]===""||(o==="."||o==="")&&(n=!0,i.splice(a,1),a--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(n=!0,i.pop())}let s=0;for(;(s=i.indexOf("..",s+1))!==-1;){let a=i[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){n=!0;let c=s===1&&i[s+1]==="**"?["."]:[];i.splice(s-1,2,...c),i.length===0&&i.push(""),s-=2}}}}while(n);return t}secondPhasePreProcess(t){for(let n=0;n<t.length-1;n++)for(let i=n+1;i<t.length;i++){let r=this.partsMatch(t[n],t[i],!this.preserveMultipleSlashes);if(r){t[n]=[],t[i]=r;break}}return t.filter(n=>n.length)}partsMatch(t,n,i=!1){let r=0,s=0,a=[],o="";for(;r<t.length&&s<n.length;)if(t[r]===n[s])a.push(o==="b"?n[s]:t[r]),r++,s++;else if(i&&t[r]==="**"&&n[s]===t[r+1])a.push(t[r]),r++;else if(i&&n[s]==="**"&&t[r]===n[s+1])a.push(n[s]),s++;else if(t[r]==="*"&&n[s]&&(this.options.dot||!n[s].startsWith("."))&&n[s]!=="**"){if(o==="b")return!1;o="a",a.push(t[r]),r++,s++}else if(n[s]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(o==="a")return!1;o="b",a.push(n[s]),r++,s++}else return!1;return t.length===n.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,n=!1,i=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)n=!n,i++;i&&(this.pattern=t.slice(i)),this.negate=n}matchOne(t,n,i=!1){let r=0,s=0;if(this.isWindows){let o=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!o&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),d=!u&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),f=c?3:o?0:void 0,p=d?3:u?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[h,g]=[t[f],n[p]];h.toLowerCase()===g.toLowerCase()&&(n[p]=h,s=p,r=f)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(t=this.levelTwoFileOptimize(t)),n.includes(zn)?this.#e(t,n,i,r,s):this.#r(t,n,i,r,s)}#e(t,n,i,r,s){let a=n.indexOf(zn,s),o=n.lastIndexOf(zn),[c,u,d]=i?[n.slice(s,a),n.slice(a+1),[]]:[n.slice(s,a),n.slice(a+1,o),n.slice(o+1)];if(c.length){let k=t.slice(r,r+c.length);if(!this.#r(k,c,i,0,0))return!1;r+=c.length,s+=c.length}let f=0;if(d.length){if(d.length+r>t.length)return!1;let k=t.length-d.length;if(this.#r(t,d,i,k,0))f=d.length;else{if(t[t.length-1]!==""||r+d.length===t.length||(k--,!this.#r(t,d,i,k,0)))return!1;f=d.length+1}}if(!u.length){let k=!!f;for(let E=r;E<t.length-f;E++){let A=String(t[E]);if(k=!0,A==="."||A===".."||!this.options.dot&&A.startsWith("."))return!1}return i||k}let p=[[[],0]],h=p[0],g=0,y=[0];for(let k of u)k===zn?(y.push(g),h=[[],0],p.push(h)):(h[0].push(k),g++);let w=p.length-1,x=t.length-f;for(let k of p)k[1]=x-(y[w--]+k[0].length);return!!this.#n(t,p,r,0,i,0,!!f)}#n(t,n,i,r,s,a,o){let c=n[r];if(!c){for(let f=i;f<t.length;f++){o=!0;let p=t[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return o}let[u,d]=c;for(;i<=d;){if(this.#r(t.slice(0,i+u.length),u,s,i,0)&&a<this.maxGlobstarRecursion){let h=this.#n(t,n,i+u.length,r+1,s,a+1,o);if(h!==!1)return h}let p=t[i];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;i++}return s||null}#r(t,n,i,r,s){let a,o,c,u;for(a=r,o=s,u=t.length,c=n.length;a<u&&o<c;a++,o++){this.debug("matchOne loop");let d=n[o],f=t[a];if(this.debug(n,d,f),d===!1||d===zn)return!1;let p;if(typeof d=="string"?(p=f===d,this.debug("string match",d,f,p)):(p=d.test(f),this.debug("pattern match",d,f,p)),!p)return!1}if(a===u&&o===c)return!0;if(a===u)return i;if(o===c)return a===u-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return RN(this.pattern,this.options)}parse(t){bu(t);let n=this.options;if(t==="**")return zn;if(t==="")return"";let i,r=null;(i=t.match(wae))?r=n.dot?xae:bae:(i=t.match(cae))?r=(n.nocase?n.dot?pae:fae:n.dot?dae:uae)(i[1]):(i=t.match(Eae))?r=(n.nocase?n.dot?kae:Sae:n.dot?Aae:_ae)(i):(i=t.match(hae))?r=n.dot?gae:mae:(i=t.match(yae))&&(r=vae);let s=Ca.fromGlob(t,this.options).toMMPattern();return r&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:r}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let n=this.options,i=n.noglobstar?$ae:n.dot?Tae:Nae,r=new Set(n.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))r.add(p);return typeof f=="string"?Lae(f):f===zn?zn:f._src});u.forEach((f,p)=>{let h=u[p+1],g=u[p-1];f!==zn||g===zn||(g===void 0?h!==void 0&&h!==zn?u[p+1]="(?:\\/|"+i+"\\/)?"+h:u[p]=i:h===void 0?u[p-1]=g+"(?:\\/|\\/"+i+")?":h!==zn&&(u[p-1]=g+"(?:\\/|\\/"+i+"\\/)"+h,u[p+1]=zn))});let d=u.filter(f=>f!==zn);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[a,o]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+o+"$",this.partial&&(s="^(?:\\/|"+a+s.slice(1,-1)+o+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,n=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&n)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let s=this.set;this.debug(this.pattern,"set",s);let a=r[r.length-1];if(!a)for(let o=r.length-2;!a&&o>=0;o--)a=r[o];for(let o of s){let c=r;if(i.matchBase&&o.length===1&&(c=[a]),this.matchOne(c,o,n))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return kn.defaults(t).Minimatch}};kn.AST=Ca;kn.Minimatch=sl;kn.escape=p6;kn.unescape=Rs;import{gunzipSync as tce}from"node:zlib";var Eu=class{static{l(this,"Diff")}diff(t,n,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);let s=this.castInput(t,i),a=this.castInput(n,i),o=this.removeEmpty(this.tokenize(s,i)),c=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(o,c,i,r)}diffWithOptionsObj(t,n,i,r){var s;let a=l(k=>{if(k=this.postProcess(k,i),r){setTimeout(function(){r(k)},0);return}else return k},"done"),o=n.length,c=t.length,u=1,d=o+c;i.maxEditLength!=null&&(d=Math.min(d,i.maxEditLength));let f=(s=i.timeout)!==null&&s!==void 0?s:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(h[0],n,t,0,i);if(h[0].oldPos+1>=c&&g+1>=o)return a(this.buildValues(h[0].lastComponent,n,t));let y=-1/0,w=1/0,x=l(()=>{for(let k=Math.max(y,-u);k<=Math.min(w,u);k+=2){let E,A=h[k-1],S=h[k+1];A&&(h[k-1]=void 0);let _=!1;if(S){let M=S.oldPos-k;_=S&&0<=M&&M<o}let T=A&&A.oldPos+1<c;if(!_&&!T){h[k]=void 0;continue}if(!T||_&&A.oldPos<S.oldPos?E=this.addToPath(S,!0,!1,0,i):E=this.addToPath(A,!1,!0,1,i),g=this.extractCommon(E,n,t,k,i),E.oldPos+1>=c&&g+1>=o)return a(this.buildValues(E.lastComponent,n,t))||!0;h[k]=E,E.oldPos+1>=c&&(w=Math.min(w,k-1)),g+1>=o&&(y=Math.max(y,k+1))}u++},"execEditLength");if(r)l(function k(){setTimeout(function(){if(u>d||Date.now()>p)return r(void 0);x()||k()},0)},"exec")();else for(;u<=d&&Date.now()<=p;){let k=x();if(k)return k}}addToPath(t,n,i,r,s){let a=t.lastComponent;return a&&!s.oneChangePerToken&&a.added===n&&a.removed===i?{oldPos:t.oldPos+r,lastComponent:{count:a.count+1,added:n,removed:i,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:n,removed:i,previousComponent:a}}}extractCommon(t,n,i,r,s){let a=n.length,o=i.length,c=t.oldPos,u=c-r,d=0;for(;u+1<a&&c+1<o&&this.equals(i[c+1],n[u+1],s);)u++,c++,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=c,u}equals(t,n,i){return i.comparator?i.comparator(t,n):t===n||!!i.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let i=0;i<t.length;i++)t[i]&&n.push(t[i]);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,i){let r=[],s;for(;t;)r.push(t),s=t.previousComponent,delete t.previousComponent,t=s;r.reverse();let a=r.length,o=0,c=0,u=0;for(;o<a;o++){let d=r[o];if(d.removed)d.value=this.join(i.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=n.slice(c,c+d.count);f=f.map(function(p,h){let g=i[u+h];return g.length>p.length?g:p}),d.value=this.join(f)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return r}};var h6=class extends Eu{static{l(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=jae}equals(t,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!t.includes(`
|
|
771
|
+
`}l(uN,"pageStyles");var Sse="https://api.deepseek.com";var kse="deepseek-v4-flash",Ase="high";var _se=/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;function t6(e){let t=e??Sse,n;try{n=new URL(t)}catch{throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL")}if(n.protocol!=="http:"&&n.protocol!=="https:"||n.username.length>0||n.password.length>0)throw new Error("dsh-edge: DEEPSEEK_BASE_URL must be a valid HTTP(S) URL without credentials");return t}l(t6,"resolveEdgeBaseURL");function vu(e){if(e===void 0)return kse;if(!_se.test(e))throw new Error("dsh-edge: DEEPSEEK_MODEL must be a valid model id of at most 128 characters");return e}l(vu,"resolveEdgeModel");function n6(e){if(e===void 0)return Ase;if(e!=="off"&&e!=="low"&&e!=="high"&&e!=="max")throw new Error("dsh-edge: DEEPSEEK_REASONING_EFFORT must be one of off, low, high, or max");return e}l(n6,"resolveEdgeReasoningEffort");function r6(e){if(e===void 0)return 12e4;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t)||t>2147483647)throw new Error("dsh-edge: DEEPSEEK_STREAM_IDLE_TIMEOUT_MS must be no greater than 2147483647");return t}l(r6,"resolveEdgeStreamIdleTimeoutMs");function i6(e){if(e===void 0)return 256e3;if(!/^[1-9]\d*$/.test(e))throw new Error("dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be a positive integer");let t=Number(e);if(!Number.isSafeInteger(t))throw new Error(`dsh-edge: DEEPSEEK_MAX_OUTPUT_TOKENS must be no greater than ${Number.MAX_SAFE_INTEGER}`);return t}l(i6,"resolveEdgeMaxOutputTokens");var s6={name:"dsh-edge",version:"0.6.0-alpha.7",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.1.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","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","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: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.0","jsonc-parser":"^3.3.1",wrangler:"4.123.0"},devDependencies:{"@cloudflare/computer":"0.2.0","@cloudflare/workers-types":"5.20260812.1","@deepseek-ai/cordis":"4.0.1","@deepseek-ai/dsh-agent":"0.1.1-rc.2","@deepseek-ai/dsh-agent-loop":"0.1.1-rc.2","@deepseek-ai/dsh-anonymous-user-id":"0.1.1-rc.2","@deepseek-ai/dsh-attachment":"0.1.1-rc.2","@deepseek-ai/dsh-brand":"0.1.1-rc.2","@deepseek-ai/dsh-compaction":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-basic":"0.1.1-rc.2","@deepseek-ai/dsh-compaction-tool-result-pruner":"0.1.1-rc.2","@deepseek-ai/dsh-credentials":"0.1.1-rc.2","@deepseek-ai/dsh-host-apiproxy":"0.1.1-rc.2","@deepseek-ai/dsh-launch-environment":"0.1.1-rc.2","@deepseek-ai/dsh-llm":"0.1.1-rc.2","@deepseek-ai/dsh-llm-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-session":"0.1.1-rc.2","@deepseek-ai/dsh-session-persistence":"0.1.1-rc.2","@deepseek-ai/dsh-session-projection":"0.1.1-rc.2","@deepseek-ai/dsh-session-query":"0.1.1-rc.2","@deepseek-ai/dsh-session-title":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-first-prompt-llm":"0.1.1-rc.2","@deepseek-ai/dsh-session-title-llm":"0.1.1-rc.2","@deepseek-ai/dsh-output-retention":"0.1.1-rc.2","@deepseek-ai/dsh-settings":"0.1.1-rc.2","@deepseek-ai/dsh-spill":"0.1.1-rc.2","@deepseek-ai/dsh-spill-policy":"0.1.1-rc.2","@deepseek-ai/dsh-storage":"0.1.1-rc.2","@deepseek-ai/dsh-storage-domain":"0.1.1-rc.2","@deepseek-ai/dsh-timeout":"0.1.1-rc.2","@deepseek-ai/dsh-token-meter":"0.1.1-rc.2","@deepseek-ai/dsh-system-prompt":"0.1.1-rc.2","@deepseek-ai/dsh-tool-call-timeout-policy":"0.1.1-rc.2","@deepseek-ai/dsh-tool-web":"0.1.1-rc.2","@deepseek-ai/dsh-tools":"0.1.1-rc.2","@deepseek-ai/dsh-web":"0.1.1-rc.2","@deepseek-ai/dsh-web-search-deepseek":"0.1.1-rc.2","@deepseek-ai/dsh-workspace":"0.1.1-rc.2","just-bash":"3.3.0","fast-png":"8.0.0","jpeg-js":"0.4.4",playwright:"^1.49.0",typescript:"^6.0.3",vitest:"^4.1.8",ws:"^8.21.0"}};var Wh=s6.version,dN=s6.dshEdge.upstreamVersion;function Cse(){return"dsh-edge@0.6.0-alpha.7/isolated"}l(Cse,"resolveEdgeDeploymentId");function qh(e){return{baseURL:t6(e.DEEPSEEK_BASE_URL),maxTokens:i6(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:vu(e.DEEPSEEK_MODEL),reasoningEffort:n6(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:_h(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:r6(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:hu(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(qh,"resolveEdgeDeploymentConfig");function $se(e){return typeof e.DEEPSEEK_API_KEY=="string"&&e.DEEPSEEK_API_KEY.trim().length>0}l($se,"edgeDeploymentApiKeyConfigured");function Tse(e){let t=t6(e),n=new URL(t);return n.search.length===0&&n.hash.length===0?t:(n.search="",n.hash="",n.href)}l(Tse,"projectedEdgeBaseURL");function a6(e,t){return{shell:e.LOADER===void 0?"just-bash-direct":"just-bash-isolated",storage:"durable-object-sqlite-vfs",attachmentStorage:t??(e.DSH_EDGE_ATTACHMENTS===void 0?"temporary-do":"private-r2"),deploymentId:Cse(),apiKeyConfigured:$se(e),baseURL:Tse(e.DEEPSEEK_BASE_URL),maxTokens:i6(e.DEEPSEEK_MAX_OUTPUT_TOKENS),model:vu(e.DEEPSEEK_MODEL),reasoningEffort:n6(e.DEEPSEEK_REASONING_EFFORT),searchBaseURL:_h(e.DEEPSEEK_SEARCH_BASE_URL),streamIdleTimeoutMs:r6(e.DEEPSEEK_STREAM_IDLE_TIMEOUT_MS),commandTimeoutPolicy:hu(e.DSH_EDGE_DEFAULT_COMMAND_TIMEOUT_MS,e.DSH_EDGE_MAX_COMMAND_TIMEOUT_MS)}}l(a6,"resolveEdgeDeploymentProfile");function fN(e){qh(e);let t=a6(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,version:Wh,upstreamVersion:dN,status:"ready"}}l(fN,"resolveEdgeDeploymentHealth");import{WorkerEntrypoint as QIe}from"cloudflare:workers";var Ha=E1(pN(),1);var o6=l((e,t,n)=>{let i=e instanceof RegExp?hN(e,n):e,r=t instanceof RegExp?hN(t,n):t,s=i!==null&&r!=null&&Nse(i,r,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+i.length,s[1]),post:n.slice(s[1]+r.length)}},"balanced"),hN=l((e,t)=>{let n=t.match(e);return n?n[0]:null},"maybeMatch"),Nse=l((e,t,n)=>{let i,r,s,a,o,c=n.indexOf(e),u=n.indexOf(t,c+1),d=c;if(c>=0&&u>0){if(e===t)return[c,u];for(i=[],s=n.length;d>=0&&!o;){if(d===c)i.push(d),c=n.indexOf(e,d+1);else if(i.length===1){let f=i.pop();f!==void 0&&(o=[f,u])}else r=i.pop(),r!==void 0&&r<s&&(s=r,a=u),u=n.indexOf(t,d+1);d=c<u&&c>=0?c:u}i.length&&a!==void 0&&(o=[s,a])}return o},"range");var mN="\0SLASH"+Math.random()+"\0",gN="\0OPEN"+Math.random()+"\0",u6="\0CLOSE"+Math.random()+"\0",yN="\0COMMA"+Math.random()+"\0",vN="\0PERIOD"+Math.random()+"\0",Rse=new RegExp(mN,"g"),Ose=new RegExp(gN,"g"),Pse=new RegExp(u6,"g"),Dse=new RegExp(yN,"g"),Lse=new RegExp(vN,"g"),Mse=/\\\\/g,jse=/\\{/g,Fse=/\\}/g,Use=/\\,/g,zse=/\\\./g,Bse=1e5,Wse=4e6;function l6(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}l(l6,"numeric");function qse(e){return e.replace(Mse,mN).replace(jse,gN).replace(Fse,u6).replace(Use,yN).replace(zse,vN)}l(qse,"escapeBraces");function Hse(e){return e.replace(Rse,"\\").replace(Ose,"{").replace(Pse,"}").replace(Dse,",").replace(Lse,".")}l(Hse,"unescapeBraces");function wN(e){if(!e)return[""];let t=[],n=o6("{","}",e);if(!n)return e.split(",");let{pre:i,body:r,post:s}=n,a=i.split(",");a[a.length-1]+="{"+r+"}";let o=wN(s);return s.length&&(a[a.length-1]+=o.shift(),a.push.apply(a,o)),t.push.apply(t,a),t}l(wN,"parseCommaParts");function bN(e,t={}){if(!e)return[];let{max:n=Bse,maxLength:i=Wse}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),c6(qse(e),n,i,!0).map(Hse)}l(bN,"expand");function Gse(e){return"{"+e+"}"}l(Gse,"embrace");function Vse(e){return/^-?0\d/.test(e)}l(Vse,"isPadded");function Zse(e,t){return e<=t}l(Zse,"lte");function Kse(e,t){return e>=t}l(Kse,"gte");function wu(e,t,n,i,r,s){let a=[],o=0;for(let c=0;c<e.length;c++)for(let u=0;u<n.length;u++){if(a.length>=i)return a;let d=e[c]+t+n[u];if(!(s&&!d)){if(o+d.length>r)return a;a.push(d),o+=d.length}}return a}l(wu,"combine");function Xse(e,t,n,i){let r=e.split(/\.\./),s=[];if(r[0]===void 0||r[1]===void 0)return s;let a=l6(r[0]),o=l6(r[1]),c=Math.max(r[0].length,r[1].length),u=r.length===3&&r[2]!==void 0?Math.max(Math.abs(l6(r[2])),1):1,d=Zse;o<a&&(u*=-1,d=Kse);let p=r.some(Vse),h=0;for(let g=a;d(g,o)&&s.length<n;g+=u){let y;if(t)y=String.fromCharCode(g),y==="\\"&&(y="");else if(y=String(g),p){let w=c-y.length;if(w>0){let x=new Array(w+1).join("0");g<0?y="-"+x+y.slice(1):y=x+y}}if(h+y.length>i)break;s.push(y),h+=y.length}return s}l(Xse,"expandSequence");function c6(e,t,n,i){let r=[""],s=!1,a=!0;for(;;){let o=o6("{","}",e);if(!o)return wu(r,e,[""],t,n,s);let c=o.pre;if(/\$$/.test(c)){if(r=wu(r,c+"{"+o.body+"}",[""],t,n,s&&!o.post.length),a=!1,!o.post.length)break;e=o.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),f=u||d,p=o.body.indexOf(",")>=0;if(!f&&!p){if(o.post.match(/,(?!,).*\}/)){e=o.pre+"{"+o.body+u6+o.post,i=!0;continue}return wu(r,c+"{"+o.body+"}"+o.post,[""],t,n,s)}a&&(s=i&&!f,a=!1);let h;if(f)h=Xse(o.body,d,t,n);else{let g=wN(o.body);if(g.length===1&&g[0]!==void 0&&(g=c6(g[0],t,n,!1).map(Gse),g.length===1)){if(r=wu(r,c+g[0],[""],t,n,s&&!o.post.length),!o.post.length)break;e=o.post;continue}let y=s&&!o.post.length&&!c;for(let x=0;y&&x<r.length;x++)r[x]&&(y=!1);h=[];let w=0;e:for(let x=0;x<g.length;x++){let k=c6(g[x],t,n,!1);for(let E=0;E<k.length;E++){let A=k[E];if(!(y&&!A)){if(h.length>=t||w+A.length>n)break e;h.push(A),w+=A.length}}}}if(r=wu(r,c,h,t,n,s&&!o.post.length),!o.post.length)break;e=o.post}return r}l(c6,"expand_");var bu=l(e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Qse={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},xu=l(e=>e.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Jse=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),xN=l(e=>e.join(""),"rangesToString"),EN=l((e,t)=>{let n=t;if(e.charAt(n)!=="[")throw new Error("not in a brace expression");let i=[],r=[],s=n+1,a=!1,o=!1,c=!1,u=!1,d=n,f="";e:for(;s<e.length;){let y=e.charAt(s);if((y==="!"||y==="^")&&s===n+1){u=!0,s++;continue}if(y==="]"&&a&&!c){d=s+1;break}if(a=!0,y==="\\"&&!c){c=!0,s++;continue}if(y==="["&&!c){for(let[w,[x,k,E]]of Object.entries(Qse))if(e.startsWith(w,s)){if(f)return["$.",!1,e.length-n,!0];s+=w.length,E?r.push(x):i.push(x),o=o||k;continue e}}if(c=!1,f){y>f?i.push(xu(f)+"-"+xu(y)):y===f&&i.push(xu(y)),f="",s++;continue}if(e.startsWith("-]",s+1)){i.push(xu(y+"-")),s+=2;continue}if(e.startsWith("-",s+1)){f=y,s+=2;continue}i.push(xu(y)),s++}if(d<s)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,e.length-n,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!u){let y=i[0].length===2?i[0].slice(-1):i[0];return[Jse(y),!1,d-n,!1]}let p="["+(u?"^":"")+xN(i)+"]",h="["+(u?"":"^")+xN(r)+"]";return[i.length&&r.length?"("+p+"|"+h+")":i.length?p:h,o,d-n,!0]},"parseClass");var Rs=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape");var dr,Yse=new Set(["!","?","+","*","@"]),d6=l(e=>Yse.has(e),"isExtglobType"),SN=l(e=>d6(e.type),"isExtglobAST"),eae=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),tae=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),nae=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),kN=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),rae="(?!(?:^|/)\\.\\.?(?:$|/))",Gh="(?!\\.)",iae=new Set(["[","."]),sae=new Set(["..","."]),aae=new Set("().*{}+?[]^$\\!"),oae=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),f6="[^/]",AN=f6+"*?",_N=f6+"+?",lae=0,Ca=class{static{l(this,"AST")}type;#e;#n;#r=!1;#t=[];#i;#s;#o;#u=!1;#l;#a;#c=!1;id=++lae;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,n,i={}){this.type=t,t&&(this.#n=!0),this.#i=n,this.#e=this.#i?this.#i.#e:this,this.#l=this.#e===this?i:this.#e.#l,this.#o=this.#e===this?[]:this.#e.#o,t==="!"&&!this.#e.#u&&this.#o.push(this),this.#s=this.#i?this.#i.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#a=this.#t.map(t=>String(t)).join("")}#x(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#o.pop();){if(t.type!=="!")continue;let n=t,i=n.#i;for(;i;){for(let r=n.#s+1;!i.type&&r<i.#t.length;r++)for(let s of t.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(i.#t[r])}n=i,i=n.#i}}return this}push(...t){for(let n of t)if(n!==""){if(typeof n!="string"&&!(n instanceof dr&&n.#i===this))throw new Error("invalid part: "+n);this.#t.push(n)}}toJSON(){let t=this.type===null?this.#t.slice().map(n=>typeof n=="string"?n:n.toJSON()):[this.type,...this.#t.map(n=>n.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#s===0)return!0;let t=this.#i;for(let n=0;n<this.#s;n++){let i=t.#t[n];if(!(i instanceof dr&&i.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#t.length:0;return this.#s===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let n=new dr(this.type,t);for(let i of this.#t)n.copyIn(i);return n}static#h(t,n,i,r,s){let a=r.maxExtglobRecursion??2,o=!1,c=!1,u=-1,d=!1;if(n.type===null){let y=i,w="";for(;y<t.length;){let x=t.charAt(y++);if(o||x==="\\"){o=!o,w+=x;continue}if(c){y===u+1?(x==="^"||x==="!")&&(d=!0):x==="]"&&!(y===u+2&&d)&&(c=!1),w+=x;continue}else if(x==="["){c=!0,u=y,d=!1,w+=x;continue}if(!r.noext&&d6(x)&&t.charAt(y)==="("&&s<=a){n.push(w),w="";let E=new dr(x,n);y=dr.#h(t,E,y,r,s+1),n.push(E);continue}w+=x}return n.push(w),y}let f=i+1,p=new dr(null,n),h=[],g="";for(;f<t.length;){let y=t.charAt(f++);if(o||y==="\\"){o=!o,g+=y;continue}if(c){f===u+1?(y==="^"||y==="!")&&(d=!0):y==="]"&&!(f===u+2&&d)&&(c=!1),g+=y;continue}else if(y==="["){c=!0,u=f,d=!1,g+=y;continue}if(!r.noext&&d6(y)&&t.charAt(f)==="("&&(s<=a||n&&n.#g(y))){let x=n&&n.#g(y)?0:1;p.push(g),g="";let k=new dr(y,p);p.push(k),f=dr.#h(t,k,f,r,s+x);continue}if(y==="|"){p.push(g),g="",h.push(p),p=new dr(null,n);continue}if(y===")")return g===""&&n.#t.length===0&&(n.#c=!0),p.push(g),g="",n.push(...h,p),f;g+=y}return n.type=null,n.#n=void 0,n.#t=[t.substring(i-1)],f}#T(t){return this.#m(t,tae)}#m(t,n=eae){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let i=t.#t[0];return!i||typeof i!="object"||i.type===null?!1:this.#g(i.type,n)}#g(t,n=nae){return!!n.get(this.type)?.includes(t)}#f(t,n){let i=t.#t[0],r=new dr(null,i,this.options);r.#t.push(""),i.push(r),this.#E(t,n)}#E(t,n){let i=t.#t[0];this.#t.splice(n,1,...i.#t);for(let r of i.#t)typeof r=="object"&&(r.#i=this);this.#a=void 0}#S(t){return!!kN.get(this.type)?.has(t)}#N(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#S(n.type)}#y(t){let n=kN.get(this.type),i=t.#t[0],r=n?.get(i.type);if(!r)return!1;this.#t=i.#t;for(let s of this.#t)typeof s=="object"&&(s.#i=this);this.type=r,this.#a=void 0,this.#c=!1}static fromGlob(t,n={}){let i=new dr(null,void 0,n);return dr.#h(t,i,0,n,0),i}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[n,i,r,s]=this.toRegExpSource();if(!(r||this.#n||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return i;let o=(this.#l.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${n}$`,o),{_src:n,_glob:t})}get options(){return this.#l}toRegExpSource(t){let n=t??!!this.#l.dot;if(this.#e===this&&(this.#p(),this.#x()),!SN(this)){let c=this.isStart()&&this.isEnd()&&!this.#t.some(h=>typeof h!="string"),u=this.#t.map(h=>{let[g,y,w,x]=typeof h=="string"?dr.#k(h,this.#n,c):h.toRegExpSource(t);return this.#n=this.#n||w,this.#r=this.#r||x,g}).join(""),d="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&sae.has(this.#t[0]))){let g=iae,y=n&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),w=!n&&!t&&g.has(u.charAt(0));d=y?rae:w?Gh:""}let f="";return this.isEnd()&&this.#e.#u&&this.#i?.type==="!"&&(f="(?:$|\\/)"),[d+u+f,Rs(u),this.#n=!!this.#n,this.#r]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#v(n);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#n=void 0,[c,Rs(this.toString()),!1,!1]}let a=!i||t||n||!Gh?"":this.#v(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let o="";if(this.type==="!"&&this.#c)o=(this.isStart()&&!n?Gh:"")+_N;else{let c=this.type==="!"?"))"+(this.isStart()&&!n&&!t?Gh:"")+AN+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;o=r+s+c}return[o,Rs(s),this.#n=!!this.#n,this.#r]}#p(){if(SN(this)){let t=0,n=!1;do{n=!0;for(let i=0;i<this.#t.length;i++){let r=this.#t[i];typeof r=="object"&&(r.#p(),this.#m(r)?(n=!1,this.#E(r,i)):this.#T(r)?(n=!1,this.#f(r,i)):this.#N(r)&&(n=!1,this.#y(r)))}}while(!n&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#a=void 0}#v(t){return this.#t.map(n=>{if(typeof n=="string")throw new Error("string type in extglob ast??");let[i,r,s,a]=n.toRegExpSource(t);return this.#r=this.#r||a,i}).filter(n=>!(this.isStart()&&this.isEnd())||!!n).join("|")}static#k(t,n,i=!1){let r=!1,s="",a=!1,o=!1;for(let c=0;c<t.length;c++){let u=t.charAt(c);if(r){r=!1,s+=(aae.has(u)?"\\":"")+u;continue}if(u==="*"){if(o)continue;o=!0,s+=i&&/^[*]+$/.test(t)?_N:AN,n=!0;continue}else o=!1;if(u==="\\"){c===t.length-1?s+="\\\\":r=!0;continue}if(u==="["){let[d,f,p,h]=EN(t,c);if(p){s+=d,a=a||f,c+=p-1,n=n||h;continue}}if(u==="?"){s+=f6,n=!0;continue}s+=oae(u)}return[s,Rs(t),!!n,a]}};dr=Ca;var p6=l((e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var kn=l((e,t,n={})=>(bu(t),!n.nocomment&&t.charAt(0)==="#"?!1:new sl(t,n).match(e)),"minimatch"),cae=/^\*+([^+@!?*[(]*)$/,uae=l(e=>t=>!t.startsWith(".")&&t.endsWith(e),"starDotExtTest"),dae=l(e=>t=>t.endsWith(e),"starDotExtTestDot"),fae=l(e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),"starDotExtTestNocase"),pae=l(e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),"starDotExtTestNocaseDot"),hae=/^\*+\.\*+$/,mae=l(e=>!e.startsWith(".")&&e.includes("."),"starDotStarTest"),gae=l(e=>e!=="."&&e!==".."&&e.includes("."),"starDotStarTestDot"),yae=/^\.\*+$/,vae=l(e=>e!=="."&&e!==".."&&e.startsWith("."),"dotStarTest"),wae=/^\*+$/,bae=l(e=>e.length!==0&&!e.startsWith("."),"starTest"),xae=l(e=>e.length!==0&&e!=="."&&e!=="..","starTestDot"),Eae=/^\?+([^+@!?*[(]*)?$/,Sae=l(([e,t=""])=>{let n=$N([e]);return t?(t=t.toLowerCase(),i=>n(i)&&i.toLowerCase().endsWith(t)):n},"qmarksTestNocase"),kae=l(([e,t=""])=>{let n=TN([e]);return t?(t=t.toLowerCase(),i=>n(i)&&i.toLowerCase().endsWith(t)):n},"qmarksTestNocaseDot"),Aae=l(([e,t=""])=>{let n=TN([e]);return t?i=>n(i)&&i.endsWith(t):n},"qmarksTestDot"),_ae=l(([e,t=""])=>{let n=$N([e]);return t?i=>n(i)&&i.endsWith(t):n},"qmarksTest"),$N=l(([e])=>{let t=e.length;return n=>n.length===t&&!n.startsWith(".")},"qmarksTestNoExt"),TN=l(([e])=>{let t=e.length;return n=>n.length===t&&n!=="."&&n!==".."},"qmarksTestNoExtDot"),NN=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",IN={win32:{sep:"\\"},posix:{sep:"/"}},Iae=NN==="win32"?IN.win32.sep:IN.posix.sep;kn.sep=Iae;var zn=Symbol("globstar **");kn.GLOBSTAR=zn;var Cae="[^/]",$ae=Cae+"*?",Tae="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Nae="(?:(?!(?:\\/|^)\\.).)*?",Rae=l((e,t={})=>n=>kn(n,e,t),"filter");kn.filter=Rae;var Nr=l((e,t={})=>Object.assign({},e,t),"ext"),Oae=l(e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return kn;let t=kn;return Object.assign(l((i,r,s={})=>t(i,r,Nr(e,s)),"m"),{Minimatch:class extends t.Minimatch{static{l(this,"Minimatch")}constructor(r,s={}){super(r,Nr(e,s))}static defaults(r){return t.defaults(Nr(e,r)).Minimatch}},AST:class extends t.AST{static{l(this,"AST")}constructor(r,s,a={}){super(r,s,Nr(e,a))}static fromGlob(r,s={}){return t.AST.fromGlob(r,Nr(e,s))}},unescape:l((i,r={})=>t.unescape(i,Nr(e,r)),"unescape"),escape:l((i,r={})=>t.escape(i,Nr(e,r)),"escape"),filter:l((i,r={})=>t.filter(i,Nr(e,r)),"filter"),defaults:l(i=>t.defaults(Nr(e,i)),"defaults"),makeRe:l((i,r={})=>t.makeRe(i,Nr(e,r)),"makeRe"),braceExpand:l((i,r={})=>t.braceExpand(i,Nr(e,r)),"braceExpand"),match:l((i,r,s={})=>t.match(i,r,Nr(e,s)),"match"),sep:t.sep,GLOBSTAR:zn})},"defaults");kn.defaults=Oae;var RN=l((e,t={})=>(bu(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:bN(e,{max:t.braceExpandMax})),"braceExpand");kn.braceExpand=RN;var Pae=l((e,t={})=>new sl(e,t).makeRe(),"makeRe");kn.makeRe=Pae;var Dae=l((e,t,n={})=>{let i=new sl(t,n);return e=e.filter(r=>i.match(r)),i.options.nonull&&!e.length&&e.push(t),e},"match");kn.match=Dae;var CN=/[?*]|[+@!]\(.*?\)|\[|\]/,Lae=l(e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),sl=class{static{l(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,n={}){bu(t),n=n||{},this.options=n,this.maxGlobstarRecursion=n.maxGlobstarRecursion??200,this.pattern=t,this.platform=n.platform||NN,this.isWindows=this.platform==="win32";let i="allowWindowsEscape";this.windowsPathsNoEscape=!!n.windowsPathsNoEscape||n[i]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!n.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!n.nonegate,this.comment=!1,this.empty=!1,this.partial=!!n.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=n.windowsNoMagicRoot!==void 0?n.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let n of t)if(typeof n!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,n=this.options;if(!n.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],n.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let r=this.globParts.map((s,a,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!CN.test(s[2]))&&!CN.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(d=>this.parse(d))];if(u)return[s[0],...s.slice(1).map(d=>this.parse(d))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,r),this.set=r.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i of t)for(let r=0;r<i.length;r++)i[r]==="**"&&(i[r]="*");let{optimizationLevel:n=1}=this.options;return n>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):n>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(n=>{let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let r=i;for(;n[r+1]==="**";)r++;r!==i&&n.splice(i,r-i)}return n})}levelOneOptimize(t){return t.map(n=>(n=n.reduce((i,r)=>{let s=i[i.length-1];return r==="**"&&s==="**"?i:r===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(i.pop(),i):(i.push(r),i)},[]),n.length===0?[""]:n))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){let s=t[r];r===1&&s===""&&t[0]===""||(s==="."||s==="")&&(n=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(n=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let r=t[i-1];r&&r!=="."&&r!==".."&&r!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(n=!0,t.splice(i-1,2),i-=2)}}while(n);return t.length===0?[""]:t}firstPhasePreProcess(t){let n=!1;do{n=!1;for(let i of t){let r=-1;for(;(r=i.indexOf("**",r+1))!==-1;){let a=r;for(;i[a+1]==="**";)a++;a>r&&i.splice(r+1,a-r);let o=i[r+1],c=i[r+2],u=i[r+3];if(o!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;n=!0,i.splice(r,1);let d=i.slice(0);d[r]="**",t.push(d),r--}if(!this.preserveMultipleSlashes){for(let a=1;a<i.length-1;a++){let o=i[a];a===1&&o===""&&i[0]===""||(o==="."||o==="")&&(n=!0,i.splice(a,1),a--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(n=!0,i.pop())}let s=0;for(;(s=i.indexOf("..",s+1))!==-1;){let a=i[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){n=!0;let c=s===1&&i[s+1]==="**"?["."]:[];i.splice(s-1,2,...c),i.length===0&&i.push(""),s-=2}}}}while(n);return t}secondPhasePreProcess(t){for(let n=0;n<t.length-1;n++)for(let i=n+1;i<t.length;i++){let r=this.partsMatch(t[n],t[i],!this.preserveMultipleSlashes);if(r){t[n]=[],t[i]=r;break}}return t.filter(n=>n.length)}partsMatch(t,n,i=!1){let r=0,s=0,a=[],o="";for(;r<t.length&&s<n.length;)if(t[r]===n[s])a.push(o==="b"?n[s]:t[r]),r++,s++;else if(i&&t[r]==="**"&&n[s]===t[r+1])a.push(t[r]),r++;else if(i&&n[s]==="**"&&t[r]===n[s+1])a.push(n[s]),s++;else if(t[r]==="*"&&n[s]&&(this.options.dot||!n[s].startsWith("."))&&n[s]!=="**"){if(o==="b")return!1;o="a",a.push(t[r]),r++,s++}else if(n[s]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(o==="a")return!1;o="b",a.push(n[s]),r++,s++}else return!1;return t.length===n.length&&a}parseNegate(){if(this.nonegate)return;let t=this.pattern,n=!1,i=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)n=!n,i++;i&&(this.pattern=t.slice(i)),this.negate=n}matchOne(t,n,i=!1){let r=0,s=0;if(this.isWindows){let o=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!o&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),u=typeof n[0]=="string"&&/^[a-z]:$/i.test(n[0]),d=!u&&n[0]===""&&n[1]===""&&n[2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3]),f=c?3:o?0:void 0,p=d?3:u?0:void 0;if(typeof f=="number"&&typeof p=="number"){let[h,g]=[t[f],n[p]];h.toLowerCase()===g.toLowerCase()&&(n[p]=h,s=p,r=f)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(t=this.levelTwoFileOptimize(t)),n.includes(zn)?this.#e(t,n,i,r,s):this.#r(t,n,i,r,s)}#e(t,n,i,r,s){let a=n.indexOf(zn,s),o=n.lastIndexOf(zn),[c,u,d]=i?[n.slice(s,a),n.slice(a+1),[]]:[n.slice(s,a),n.slice(a+1,o),n.slice(o+1)];if(c.length){let k=t.slice(r,r+c.length);if(!this.#r(k,c,i,0,0))return!1;r+=c.length,s+=c.length}let f=0;if(d.length){if(d.length+r>t.length)return!1;let k=t.length-d.length;if(this.#r(t,d,i,k,0))f=d.length;else{if(t[t.length-1]!==""||r+d.length===t.length||(k--,!this.#r(t,d,i,k,0)))return!1;f=d.length+1}}if(!u.length){let k=!!f;for(let E=r;E<t.length-f;E++){let A=String(t[E]);if(k=!0,A==="."||A===".."||!this.options.dot&&A.startsWith("."))return!1}return i||k}let p=[[[],0]],h=p[0],g=0,y=[0];for(let k of u)k===zn?(y.push(g),h=[[],0],p.push(h)):(h[0].push(k),g++);let w=p.length-1,x=t.length-f;for(let k of p)k[1]=x-(y[w--]+k[0].length);return!!this.#n(t,p,r,0,i,0,!!f)}#n(t,n,i,r,s,a,o){let c=n[r];if(!c){for(let f=i;f<t.length;f++){o=!0;let p=t[f];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return o}let[u,d]=c;for(;i<=d;){if(this.#r(t.slice(0,i+u.length),u,s,i,0)&&a<this.maxGlobstarRecursion){let h=this.#n(t,n,i+u.length,r+1,s,a+1,o);if(h!==!1)return h}let p=t[i];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;i++}return s||null}#r(t,n,i,r,s){let a,o,c,u;for(a=r,o=s,u=t.length,c=n.length;a<u&&o<c;a++,o++){this.debug("matchOne loop");let d=n[o],f=t[a];if(this.debug(n,d,f),d===!1||d===zn)return!1;let p;if(typeof d=="string"?(p=f===d,this.debug("string match",d,f,p)):(p=d.test(f),this.debug("pattern match",d,f,p)),!p)return!1}if(a===u&&o===c)return!0;if(a===u)return i;if(o===c)return a===u-1&&t[a]==="";throw new Error("wtf?")}braceExpand(){return RN(this.pattern,this.options)}parse(t){bu(t);let n=this.options;if(t==="**")return zn;if(t==="")return"";let i,r=null;(i=t.match(wae))?r=n.dot?xae:bae:(i=t.match(cae))?r=(n.nocase?n.dot?pae:fae:n.dot?dae:uae)(i[1]):(i=t.match(Eae))?r=(n.nocase?n.dot?kae:Sae:n.dot?Aae:_ae)(i):(i=t.match(hae))?r=n.dot?gae:mae:(i=t.match(yae))&&(r=vae);let s=Ca.fromGlob(t,this.options).toMMPattern();return r&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:r}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let n=this.options,i=n.noglobstar?$ae:n.dot?Tae:Nae,r=new Set(n.nocase?["i"]:[]),s=t.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))r.add(p);return typeof f=="string"?Lae(f):f===zn?zn:f._src});u.forEach((f,p)=>{let h=u[p+1],g=u[p-1];f!==zn||g===zn||(g===void 0?h!==void 0&&h!==zn?u[p+1]="(?:\\/|"+i+"\\/)?"+h:u[p]=i:h===void 0?u[p-1]=g+"(?:\\/|\\/"+i+")?":h!==zn&&(u[p-1]=g+"(?:\\/|\\/"+i+"\\/)"+h,u[p+1]=zn))});let d=u.filter(f=>f!==zn);if(this.partial&&d.length>=1){let f=[];for(let p=1;p<=d.length;p++)f.push(d.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return d.join("/")}).join("|"),[a,o]=t.length>1?["(?:",")"]:["",""];s="^"+a+s+o+"$",this.partial&&(s="^(?:\\/|"+a+s.slice(1,-1)+o+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,n=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&n)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let s=this.set;this.debug(this.pattern,"set",s);let a=r[r.length-1];if(!a)for(let o=r.length-2;!a&&o>=0;o--)a=r[o];for(let o of s){let c=r;if(i.matchBase&&o.length===1&&(c=[a]),this.matchOne(c,o,n))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return kn.defaults(t).Minimatch}};kn.AST=Ca;kn.Minimatch=sl;kn.escape=p6;kn.unescape=Rs;import{gunzipSync as tce}from"node:zlib";var Eu=class{static{l(this,"Diff")}diff(t,n,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);let s=this.castInput(t,i),a=this.castInput(n,i),o=this.removeEmpty(this.tokenize(s,i)),c=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(o,c,i,r)}diffWithOptionsObj(t,n,i,r){var s;let a=l(k=>{if(k=this.postProcess(k,i),r){setTimeout(function(){r(k)},0);return}else return k},"done"),o=n.length,c=t.length,u=1,d=o+c;i.maxEditLength!=null&&(d=Math.min(d,i.maxEditLength));let f=(s=i.timeout)!==null&&s!==void 0?s:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(h[0],n,t,0,i);if(h[0].oldPos+1>=c&&g+1>=o)return a(this.buildValues(h[0].lastComponent,n,t));let y=-1/0,w=1/0,x=l(()=>{for(let k=Math.max(y,-u);k<=Math.min(w,u);k+=2){let E,A=h[k-1],S=h[k+1];A&&(h[k-1]=void 0);let _=!1;if(S){let M=S.oldPos-k;_=S&&0<=M&&M<o}let T=A&&A.oldPos+1<c;if(!_&&!T){h[k]=void 0;continue}if(!T||_&&A.oldPos<S.oldPos?E=this.addToPath(S,!0,!1,0,i):E=this.addToPath(A,!1,!0,1,i),g=this.extractCommon(E,n,t,k,i),E.oldPos+1>=c&&g+1>=o)return a(this.buildValues(E.lastComponent,n,t))||!0;h[k]=E,E.oldPos+1>=c&&(w=Math.min(w,k-1)),g+1>=o&&(y=Math.max(y,k+1))}u++},"execEditLength");if(r)l(function k(){setTimeout(function(){if(u>d||Date.now()>p)return r(void 0);x()||k()},0)},"exec")();else for(;u<=d&&Date.now()<=p;){let k=x();if(k)return k}}addToPath(t,n,i,r,s){let a=t.lastComponent;return a&&!s.oneChangePerToken&&a.added===n&&a.removed===i?{oldPos:t.oldPos+r,lastComponent:{count:a.count+1,added:n,removed:i,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:n,removed:i,previousComponent:a}}}extractCommon(t,n,i,r,s){let a=n.length,o=i.length,c=t.oldPos,u=c-r,d=0;for(;u+1<a&&c+1<o&&this.equals(i[c+1],n[u+1],s);)u++,c++,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=c,u}equals(t,n,i){return i.comparator?i.comparator(t,n):t===n||!!i.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let i=0;i<t.length;i++)t[i]&&n.push(t[i]);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,i){let r=[],s;for(;t;)r.push(t),s=t.previousComponent,delete t.previousComponent,t=s;r.reverse();let a=r.length,o=0,c=0,u=0;for(;o<a;o++){let d=r[o];if(d.removed)d.value=this.join(i.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=n.slice(c,c+d.count);f=f.map(function(p,h){let g=i[u+h];return g.length>p.length?g:p}),d.value=this.join(f)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return r}};var h6=class extends Eu{static{l(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=jae}equals(t,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!t.includes(`
|
|
770
772
|
`))&&(t=t.trim()),(!i.newlineIsToken||!n.includes(`
|
|
771
773
|
`))&&(n=n.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(t.endsWith(`
|
|
772
774
|
`)&&(t=t.slice(0,-1)),n.endsWith(`
|