diff --git a/dist/mcp/server.js b/dist/mcp/server.js index 7989f58..80a53f0 100644 --- a/dist/mcp/server.js +++ b/dist/mcp/server.js @@ -1530,7 +1530,7 @@ seal-use corps hose-staffs --json '{ \`\`\` * 直接使用指定 ID 完成接入并进行连通性验证。 `;var uy={"SKILL.md":zL,"agents/openai.yaml":CL,"references/rule-lightweight.md":RL,"references/approval-bad-cases.md":hL,"references/cli.md":mL,"references/approval-run-lightweight.md":xL,"references/approval-attachment-trace.md":aL,"references/customer-feedback-rule-remediation.md":sL,"references/enterprise-onboarding.md":ny,"references/hose-enterprise-auth.md":iy,"references/hose-enterprise-init.md":ty};function ey(){return uy["SKILL.md"]||""}function zu(){return z4(oy(),".agents","skills","seal-use")}function ly(){return z4(oy(),".agents","skills","seal-home")}function vy(){let n=ly();if(M4(n))try{return WK(n,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function C4(n=zu()){vy(),ry(n,{recursive:!0});let i=[];for(let[r,o]of Object.entries(uy)){let t=z4(n,r);ry(XK(t),{recursive:!0}),JK(t,o,"utf8"),i.push(r)}return{targetDir:n,files:i}}function R4(){let n=ly(),i=zu(),r=M4(n),o=M4(i);if(r||o)return vy(),C4(i),{synced:!0,targetDir:i};return{synced:!1}}function Iy(n,i,r){if(n==="dump"||n==="cat"||n==="show"){process.stdout.write(`${ey()} -`);return}if(n==="install"||n==="init"||n==="sync"){let o=_(r.options.local)||_(r.options.workspace),t=D(r.options.dir)??D(r.options.target)??i,u=t?t:o?w$(process.cwd(),".agents","skills","seal-use"):zu(),e=C4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=zu(),t=w$(process.cwd(),".agents","skills","seal-use");B({global:{dir:o,installed:$y(w$(o,"SKILL.md"))},local:{dir:t,installed:$y(w$(t,"SKILL.md"))}});return}throw Error(`Unknown skill command: ${n}. Run 'seal-use help' for available commands.`)}async function gy(n,i){if(n==="config"){B(await xr(i));return}throw Error(`Unknown source command: ${n??""}. Run 'seal-use help' for available commands.`)}async function by(n,i,r,o){if(!n)throw Error("Usage: seal-use tool [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function wy(){B(Vu.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as HK,mkdirSync as YK,renameSync as h4,rmSync as PK,unlinkSync as Sy,writeFileSync as fy}from"node:fs";import{dirname as pK,join as cy}from"node:path";import{spawnSync as Zt}from"node:child_process";function f$(n=process.execPath,i=import.meta.url){if(i.includes("/$bunfs/")||i.includes("\\$bunfs\\"))return!0;let r=n.toLowerCase().replace(/\\/g,"/");return!r.endsWith("/bun")&&!r.endsWith("/bun.exe")&&!r.endsWith("/node")&&!r.endsWith("/node.exe")}var Ay="yunyingk/seal-home",sr="yunyingk/seal-home";var QK="SEAL_USE_GITHUB_REPO",FK="SEAL_HOME_GITHUB_REPO";async function Oy(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:Z4,version:m,launcher:n.launcher},o=i.repo||process.env[QK]?.trim()||process.env[FK]?.trim()||Ay,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let G=u.replace(/^v/,""),N=ky(G,m);if(N<0){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`Cannot downgrade seal-use from v${m} to older version v${G}. Updates must be forward-only.`});return}if(N===0&&!i.force){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`seal-use is already at version v${m}. Use --force to reinstall.`});return}}if(i.changelogOnly){let G=await m4(o,i.limit??10);B({currentVersion:m,totalQueried:G.length,releases:G.map((N)=>({version:N.version,tagName:N.tagName,publishedAt:N.publishedAt,author:N.author,releaseNotes:N.notes,releaseUrl:N.htmlUrl,isCurrent:N.version===m,isNewer:Cu(N.version,m)}))});return}if(!f$()){if(i.checkOnly){let N=await m4(o,30),E=N[0],x=E?.version??m,yn=N.find((un)=>un.version===m),Wn=Cu(x,m),On=N.filter((un)=>Cu(un.version,m));B({updated:!1,updateAvailable:Wn,currentVersion:m,currentVersionPublishedAt:yn?.publishedAt,latestVersion:x,latestVersionPublishedAt:E?.publishedAt,behindCount:On.length,pendingReleases:On.map((un)=>({version:un.version,tagName:un.tagName,publishedAt:un.publishedAt,author:un.author,releaseNotes:un.notes,releaseUrl:un.htmlUrl})),releaseNotes:E?.notes??"",releaseUrl:E?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let G=ar(r).running;if(G)await _t("stop",r);try{Dy("git",["-C",n.appRoot,"pull","--ff-only"])}catch(N){console.error(`git pull skipped: ${N instanceof Error?N.message:String(N)}`)}if(Dy("bun",["install"],{cwd:n.appRoot}),G)await _t("start",r);B({updated:!0,serviceRestarted:G,version:m,mode:"source"});return}let e=KK(),l=BK(),$=await m4(o,30),I=u?$.find((G)=>G.version===u||G.tagName===u||G.tagName===`v${u}`)??await Uy(o,u):$[0]??await Uy(o);if(!I){B({updated:!1,currentVersion:m,mode:"binary",message:`Failed to query releases from repository '${o}'`});return}let g=I.version,b=$.find((G)=>G.version===m),w=Cu(g,m),f=w||Boolean(i.force),c=$.filter((G)=>Cu(G.version,m));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((G)=>({version:G.version,tagName:G.tagName,publishedAt:G.publishedAt,author:G.author,releaseNotes:G.notes,releaseUrl:G.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-use is already up to date (v${m})`});return}let S=TK(I.assets,e,l);if(!S)throw Error(`No compatible binary found for ${e}-${l} in release v${g}. Available assets: ${I.assets.map((G)=>G.name).join(", ")}`);let k=ar(r).running;if(k)await _t("stop",r);let d=process.execPath,Q=pK(d),Y=cy(Q,`.tmp-update-${Date.now()}`);YK(Y,{recursive:!0});try{let G=cy(Y,S.name);await VK(S.downloadUrl,G,I.tagName,S.name);let N=G;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))N=qK(G,Y,e);else if(S.name.endsWith(".zip"))N=EK(G,Y,e);if(HK(N,493),process.platform==="darwin")try{Zt("/usr/bin/codesign",["--remove-signature",N],{stdio:"ignore"}),Zt("/usr/bin/codesign",["--force","--sign","-",N],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let x=`${d}.old.${Date.now()}`;try{h4(d,x)}catch{}h4(N,d)}else h4(N,d);if(k)await _t("start",r);let E=R4();B({updated:!0,fromVersion:m,toVersion:g,serviceRestarted:k,skillSynced:E.synced?E.targetDir:!1,mode:"binary"})}finally{try{PK(Y,{recursive:!0,force:!0})}catch{}}}function KK(){if(process.platform==="darwin")return"darwin";if(process.platform==="win32")return"windows";return"linux"}function BK(){return process.arch==="arm64"?"arm64":"x64"}async function m4(n,i=20){let r=process.env.GITHUB_TOKEN||process.env.GH_TOKEN,o={"User-Agent":`seal-use/${m}`,Accept:"application/vnd.github.v3+json",...r?{Authorization:`Bearer ${r}`}:{}},t=[`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${i}`,`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${i}`,`https://api.github.com/repos/${n}/releases?per_page=${i}`];if(n!==sr)t.push(`https://api.github.com/repos/${sr}/releases?per_page=${i}`);for(let u of t)try{let e=await fetch(u,{headers:o,signal:AbortSignal.timeout(5000)});if(!e.ok)continue;let l=await e.json();if(!Array.isArray(l)||l.length===0)continue;let $=[];for(let I of l){let g=I.tag_name??"",b=g.replace(/^v/,"");if(!b)continue;let w=(I.assets??[]).map((f)=>({name:f.name,downloadUrl:f.browser_download_url,size:f.size??0}));$.push({version:b,tagName:g,name:I.name??g,publishedAt:I.published_at,author:I.author?.login,notes:I.body??"",htmlUrl:I.html_url??"",assets:w})}if($.length>0)return $}catch{}return[]}async function Uy(n,i){let r=i?i.startsWith("v")?i:`v${i}`:void 0,o=process.env.GITHUB_TOKEN||process.env.GH_TOKEN,t={"User-Agent":`seal-use/${m}`,Accept:"application/vnd.github.v3+json",...o?{Authorization:`Bearer ${o}`}:{}},u=r?[`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${r}`,`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${r}`,`https://api.github.com/repos/${n}/releases/tags/${r}`,...n!==sr?[`https://api.github.com/repos/${sr}/releases/tags/${r}`]:[]]:["https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest","https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest",`https://api.github.com/repos/${n}/releases/latest`,...n!==sr?[`https://api.github.com/repos/${sr}/releases/latest`]:[]],e;for(let l of u)try{let $=await fetch(l,{headers:t,signal:AbortSignal.timeout(5000)});if(!$.ok)continue;let I=await $.json(),g=I.tag_name??"",b=g.replace(/^v/,"");if(!b)continue;let w=(I.assets??[]).map((c)=>({name:c.name,downloadUrl:c.browser_download_url,size:c.size??0})),f={version:b,tagName:g,name:I.name??g,publishedAt:I.published_at,author:I.author?.login,notes:I.body??"",htmlUrl:I.html_url??"",assets:w};if(w.length>0)return f;if(!e)e=f}catch{}return e}function TK(n,i,r){let o={darwin:["darwin","macos","osx","apple"],linux:["linux"],windows:["windows","win32","win"]},t={arm64:["arm64","aarch64"],x64:["x64","x86_64","amd64"]},u=o[i]||[],e=t[r]||[],l=n.filter((g)=>{let b=g.name.toLowerCase(),w=u.some((c)=>b.includes(c)),f=e.some((c)=>b.includes(c));return w&&f}),$=l.find((g)=>!g.name.endsWith(".tar.gz")&&!g.name.endsWith(".tgz")&&!g.name.endsWith(".zip")&&!g.name.endsWith(".sha256"));if($)return $;return l.find((g)=>g.name.endsWith(".tar.gz")||g.name.endsWith(".tgz")||g.name.endsWith(".zip"))||l[0]}function c$(n){try{process.stderr.write(`${n} +`);return}if(n==="install"||n==="init"||n==="sync"){let o=_(r.options.local)||_(r.options.workspace),t=D(r.options.dir)??D(r.options.target)??i,u=t?t:o?w$(process.cwd(),".agents","skills","seal-use"):zu(),e=C4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=zu(),t=w$(process.cwd(),".agents","skills","seal-use");B({global:{dir:o,installed:$y(w$(o,"SKILL.md"))},local:{dir:t,installed:$y(w$(t,"SKILL.md"))}});return}throw Error(`Unknown skill command: ${n}. Run 'seal-use help' for available commands.`)}async function gy(n,i){if(n==="config"){B(await xr(i));return}throw Error(`Unknown source command: ${n??""}. Run 'seal-use help' for available commands.`)}async function by(n,i,r,o){if(!n)throw Error("Usage: seal-use tool [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function wy(){B(Vu.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as HK,mkdirSync as YK,renameSync as h4,rmSync as PK,unlinkSync as Sy,writeFileSync as fy}from"node:fs";import{dirname as pK,join as cy}from"node:path";import{spawnSync as Zt}from"node:child_process";function f$(n=process.execPath,i=import.meta.url){if(i.includes("/$bunfs/")||i.includes("\\$bunfs\\"))return!0;let r=n.toLowerCase().replace(/\\/g,"/");return!r.endsWith("/bun")&&!r.endsWith("/bun.exe")&&!r.endsWith("/node")&&!r.endsWith("/node.exe")}var Ay="yunyingk/seal-home",sr="yunyingk/seal-home";var QK="SEAL_USE_GITHUB_REPO",FK="SEAL_HOME_GITHUB_REPO";async function Oy(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:Z4,version:m,launcher:n.launcher},o=i.repo||process.env[QK]?.trim()||process.env[FK]?.trim()||Ay,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let G=u.replace(/^v/,""),N=ky(G,m);if(N<0){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`Cannot downgrade seal-use from v${m} to older version v${G}. Updates must be forward-only.`});return}if(N===0&&!i.force){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`seal-use is already at version v${m}. Use --force to reinstall.`});return}}if(i.changelogOnly){let G=await m4(o,i.limit??10);B({currentVersion:m,totalQueried:G.length,releases:G.map((N)=>({version:N.version,tagName:N.tagName,publishedAt:N.publishedAt,author:N.author,releaseNotes:N.notes,releaseUrl:N.htmlUrl,isCurrent:N.version===m,isNewer:Cu(N.version,m)}))});return}if(!f$()){if(i.checkOnly){let N=await m4(o,30),E=N[0],x=E?.version??m,yn=N.find((un)=>un.version===m),Wn=Cu(x,m),On=N.filter((un)=>Cu(un.version,m));B({updated:!1,updateAvailable:Wn,currentVersion:m,currentVersionPublishedAt:yn?.publishedAt,latestVersion:x,latestVersionPublishedAt:E?.publishedAt,behindCount:On.length,pendingReleases:On.map((un)=>({version:un.version,tagName:un.tagName,publishedAt:un.publishedAt,author:un.author,releaseNotes:un.notes,releaseUrl:un.htmlUrl})),releaseNotes:E?.notes??"",releaseUrl:E?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let G=ar(r).running;if(G)await _t("stop",r);try{Dy("git",["-C",n.appRoot,"pull","--ff-only"])}catch(N){console.error(`git pull skipped: ${N instanceof Error?N.message:String(N)}`)}if(Dy("bun",["install"],{cwd:n.appRoot}),G)await _t("start",r);B({updated:!0,serviceRestarted:G,version:m,mode:"source"});return}let e=KK(),l=BK(),$=await m4(o,30),I=u?$.find((G)=>G.version===u||G.tagName===u||G.tagName===`v${u}`)??await Uy(o,u):$[0]??await Uy(o);if(!I){B({updated:!1,currentVersion:m,mode:"binary",message:`Failed to query releases from repository '${o}'`});return}let g=I.version,b=$.find((G)=>G.version===m),w=Cu(g,m),f=w||Boolean(i.force),c=$.filter((G)=>Cu(G.version,m));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((G)=>({version:G.version,tagName:G.tagName,publishedAt:G.publishedAt,author:G.author,releaseNotes:G.notes,releaseUrl:G.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-use is already up to date (v${m})`});return}let S=TK(I.assets,e,l);if(!S)throw Error(`No compatible binary found for ${e}-${l} in release v${g}. Available assets: ${I.assets.map((G)=>G.name).join(", ")}`);let k=ar(r).running;if(k)await _t("stop",r);let d=process.execPath,Q=pK(d),Y=cy(Q,`.tmp-update-${Date.now()}`);YK(Y,{recursive:!0});try{let G=cy(Y,S.name);await VK(S.downloadUrl,G,I.tagName,S.name);let N=G;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))N=qK(G,Y,e);else if(S.name.endsWith(".zip"))N=EK(G,Y,e);if(HK(N,493),process.platform==="darwin")try{Zt("/usr/bin/codesign",["--remove-signature",N],{stdio:"ignore"}),Zt("/usr/bin/codesign",["--force","--sign","-",N],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let x=`${d}.old.${Date.now()}`;try{h4(d,x)}catch{}h4(N,d)}else h4(N,d);if(k)await _t("start",r);let E=R4();B({updated:!0,fromVersion:m,toVersion:g,serviceRestarted:k,skillSynced:E.synced?E.targetDir:!1,mode:"binary"})}finally{try{PK(Y,{recursive:!0,force:!0})}catch{}}}function KK(){if(process.platform==="darwin")return"darwin";if(process.platform==="win32")return"windows";return"linux"}function BK(){return process.arch==="arm64"?"arm64":"x64"}async function m4(n,i=20){let r=process.env.GITHUB_TOKEN||process.env.GH_TOKEN,o={"User-Agent":`seal-use/${m}`,Accept:"application/vnd.github.v3+json",...r?{Authorization:`Bearer ${r}`}:{}},t=[`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${i}`,`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${i}`,`https://api.github.com/repos/${n}/releases?per_page=${i}`];if(n!==sr)t.push(`https://api.github.com/repos/${sr}/releases?per_page=${i}`);for(let u of t)try{let e=await fetch(u,{headers:o,signal:AbortSignal.timeout(3000)});if(!e.ok)continue;let l=await e.json();if(!Array.isArray(l)||l.length===0)continue;let $=[];for(let I of l){let g=I.tag_name??"",b=g.replace(/^v/,"");if(!b)continue;let w=(I.assets??[]).map((f)=>({name:f.name,downloadUrl:f.browser_download_url,size:f.size??0}));$.push({version:b,tagName:g,name:I.name??g,publishedAt:I.published_at,author:I.author?.login,notes:I.body??"",htmlUrl:I.html_url??"",assets:w})}if($.length>0)return $}catch{}return[]}async function Uy(n,i){let r=i?i.startsWith("v")?i:`v${i}`:void 0,o=process.env.GITHUB_TOKEN||process.env.GH_TOKEN,t={"User-Agent":`seal-use/${m}`,Accept:"application/vnd.github.v3+json",...o?{Authorization:`Bearer ${o}`}:{}},u=r?[`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${r}`,`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${r}`,`https://api.github.com/repos/${n}/releases/tags/${r}`,...n!==sr?[`https://api.github.com/repos/${sr}/releases/tags/${r}`]:[]]:["https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest","https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest",`https://api.github.com/repos/${n}/releases/latest`,...n!==sr?[`https://api.github.com/repos/${sr}/releases/latest`]:[]],e;for(let l of u)try{let $=await fetch(l,{headers:t,signal:AbortSignal.timeout(3000)});if(!$.ok)continue;let I=await $.json(),g=I.tag_name??"",b=g.replace(/^v/,"");if(!b)continue;let w=(I.assets??[]).map((c)=>({name:c.name,downloadUrl:c.browser_download_url,size:c.size??0})),f={version:b,tagName:g,name:I.name??g,publishedAt:I.published_at,author:I.author?.login,notes:I.body??"",htmlUrl:I.html_url??"",assets:w};if(w.length>0)return f;if(!e)e=f}catch{}return e}function TK(n,i,r){let o={darwin:["darwin","macos","osx","apple"],linux:["linux"],windows:["windows","win32","win"]},t={arm64:["arm64","aarch64"],x64:["x64","x86_64","amd64"]},u=o[i]||[],e=t[r]||[],l=n.filter((g)=>{let b=g.name.toLowerCase(),w=u.some((c)=>b.includes(c)),f=e.some((c)=>b.includes(c));return w&&f}),$=l.find((g)=>!g.name.endsWith(".tar.gz")&&!g.name.endsWith(".tgz")&&!g.name.endsWith(".zip")&&!g.name.endsWith(".sha256"));if($)return $;return l.find((g)=>g.name.endsWith(".tar.gz")||g.name.endsWith(".tgz")||g.name.endsWith(".zip"))||l[0]}function c$(n){try{process.stderr.write(`${n} `)}catch{}}async function VK(n,i,r,o){let t=[],u=r?r.startsWith("v")?r:`v${r}`:void 0,e=o||n.split("/").pop()||"";if(u&&e)t.push(`https://git.ying-qing.cn/gitea/seal-home/releases/download/${u}/${e}`);if(n.startsWith("https://git.ying-qing.cn"))t.push(n);if(u&&e){let c=`https://github.com/${Ay}/releases/download/${u}/${e}`;t.push(`https://ghfast.top/${c}`),t.push(`https://gh.ddlc.top/${c}`),t.push(c)}else if(n.includes("github.com"))t.push(`https://ghfast.top/${n}`),t.push(`https://gh.ddlc.top/${n}`),t.push(n);else t.push(n);let l=Array.from(new Set(t)),$,I=6000,g=6000,b=307200,w=1e4,f=180000;for(let c=0;c{d=E;try{k.abort()}catch{}},Y=setTimeout(()=>{Q("Connection timed out (no response headers within 6s)")},I),G,N;try{c$(`==> [${c+1}/${l.length}] Downloading via: ${S}`);let E=await fetch(S,{signal:k.signal});if(Y)clearTimeout(Y),Y=void 0;if(!E.ok)throw Error(`HTTP ${E.status} ${E.statusText}`);G=setTimeout(()=>{Q("Overall download time exceeded 3 minutes")},f);let x=Number(E.headers.get("content-length"))||0,yn=E.body?.getReader();if(!yn){let wi=Buffer.from(await E.arrayBuffer());if(wi.length<1000)throw Error(`Downloaded content is suspiciously small (${wi.length} bytes)`);fy(i,wi),c$(`✓ Download succeeded (${(wi.length/1024/1024).toFixed(1)} MB)`);return}let Wn=[],On=0,un=0;N=setTimeout(()=>{if(On{no=setTimeout(()=>{S$(Error("Data transfer stalled (no chunk received for 10s)"))},w)}),s4;try{s4=await Promise.race([wi,Wy])}finally{if(no)clearTimeout(no)}let{done:Jy,value:U$}=s4;if(Jy)break;if(U$){if(Wn.push(U$),On+=U$.length,N&&On>=b)clearTimeout(N),N=void 0;let D$=Date.now();if(D$-un>200){un=D$;let S$=x?Math.round(On/x*100):0,Xy=(On/1048576).toFixed(1),Hy=x?(x/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${S$}% (${Xy} / ${Hy} MB)...`)}catch{}}}}try{process.stderr.write(` `)}catch{}let Ot=Buffer.concat(Wn);if(Ot.length<1000)throw Error(`Downloaded content is suspiciously small (${Ot.length} bytes)`);fy(i,Ot),c$(`✓ Download completed successfully (${(Ot.length/1024/1024).toFixed(1)} MB)`);return}catch(E){if(Y)clearTimeout(Y);if(N)clearTimeout(N);if(G)clearTimeout(G);let x=d||(E instanceof Error?E.message:String(E));$=Error(x),c$(` ↳ Mirror failed: ${$.message}`)}finally{if(Y)clearTimeout(Y);if(N)clearTimeout(N);if(G)clearTimeout(G)}}throw Error(`Failed to download asset from all mirrors: ${$?.message}`)}function qK(n,i,r){let o=Zt("tar",["-xzf",n,"-C",i],{stdio:"pipe"});if(o.status!==0)throw Error(`Failed to extract tar archive: ${o.stderr.toString()}`);Sy(n);let t=r==="windows"?"seal-use.exe":"seal-use",u=Zt("find",[i,"-type","f"],{encoding:"utf8"}).stdout.trim().split(` diff --git a/src/cli.test.ts b/src/cli.test.ts index 726b89d..d88a581 100644 --- a/src/cli.test.ts +++ b/src/cli.test.ts @@ -178,7 +178,7 @@ describe("CLI version & help handling", () => { expect(parsed).toHaveProperty("behindCount"); expect(parsed).toHaveProperty("pendingReleases"); expect(Array.isArray(parsed.pendingReleases)).toBe(true); - }); + }, 20000); test("changelog command outputs release history list", () => { const result = runCli(["changelog", "--limit", "5"]); @@ -186,7 +186,7 @@ describe("CLI version & help handling", () => { const parsed = JSON.parse(result.stdout.trim()); expect(parsed.currentVersion).toBe(VERSION); expect(Array.isArray(parsed.releases)).toBe(true); - }); + }, 20000); test("rejects downgrade to older version when target version is lower", () => { const result = runCli(["update", "0.3.3"]); @@ -204,7 +204,7 @@ describe("CLI version & help handling", () => { const parsed = JSON.parse(result.stdout.trim()); expect(parsed).toHaveProperty("latestVersion"); expect(parsed.updated).toBe(false); - }); + }, 20000); }); function makeConfigEnv(): Record { diff --git a/src/cli/commands/update.ts b/src/cli/commands/update.ts index 5c36594..92acf9e 100644 --- a/src/cli/commands/update.ts +++ b/src/cli/commands/update.ts @@ -326,7 +326,7 @@ async function fetchGitHubReleases(repo: string, limit = 20): Promise