@yuandc/aica 0.1.82 → 0.1.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{execFileSync as l}from"node:child_process";import d from"node:fs";import c from"node:path";import h from"node:crypto";const m=50*1024*1024,g=["path","file","filePath","file_path","filename","targetPath","target_path","move_path"];function T(t){if(!y(t))return null;const e=b(t);if(!e)return null;const n=new Map;for(const r of e)n.set(r.path,{status:r.status,objectHash:r.status.includes("D")?null:v(t,r.path)});return n}function R(t){const e=new Map;for(const n of t.evidencePaths)x(e,t.cwd,n,"unknown","acp_tool");return[...e.values()].filter(n=>n.relativePath&&!n.relativePath.startsWith(".git/")).sort((n,r)=>n.relativePath.localeCompare(r.relativePath))}function E(t){const e=new Set;return u(t,(n,r)=>{if(typeof n=="string"&&(S(r)&&p(e,n),r==="command"))for(const s of F(n))p(e,s)}),A(t,e),j(t,e),[...e]}function x(t,e,n,r,s){const a=w(e,n);if(!a)return;const i=t.get(a.relativePath),o=C(a.absolutePath),f={path:a.absolutePath,absolutePath:a.absolutePath,relativePath:a.relativePath,changeType:P(i?.changeType,r),source:i?.source==="acp_tool"||i?.source==="acp_diff"?i.source:s,exists:!!o?.isFile(),downloadable:!!o?.isFile(),...o?.isFile()?{size:o.size,mime:_(a.absolutePath),sha256:o.size<=m?H(a.absolutePath):void 0}:{}};t.set(a.relativePath,f)}function P(t,e){return!t||t==="unknown"?e:e==="unknown"||t===e?t:t==="created"&&e==="modified"?"created":e}function w(t,e){if(!e||e.includes("\0"))return null;const n=c.resolve(t),r=c.isAbsolute(e)?c.resolve(e):c.resolve(n,e),s=c.relative(n,r).replace(/\\/g,"/");return!s||s.startsWith("..")||c.isAbsolute(s)?null:{absolutePath:r,relativePath:s}}function y(t){try{return l("git",["-C",t,"rev-parse","--is-inside-work-tree"],{windowsHide:!0,encoding:"utf8",stdio:["ignore","pipe","ignore"]}),!0}catch{return!1}}function b(t){try{const n=l("git",["-C",t,"status","--porcelain=v1","-z","--untracked-files=all"],{windowsHide:!0,encoding:"buffer",maxBuffer:20971520}).toString("utf8").split("\0").filter(Boolean),r=[];for(let s=0;s<n.length;s+=1){const a=n[s],i=a.slice(0,2),o=a.slice(3);if(o)if(i.startsWith("R")||i.startsWith("C")){const f=n[s+1];f&&(r.push({status:i,path:f}),s+=1)}else r.push({status:i,path:o})}return r}catch{return null}}function v(t,e){try{const n=l("git",["-C",t,"hash-object","--",e],{windowsHide:!0,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:1048576}).trim();return/^[0-9a-f]{40,64}$/i.test(n)?n:null}catch{return null}}function u(t,e,n,r=0){if(!(r>8)&&(e(t,n),!(!t||typeof t!="object"))){if(Array.isArray(t)){for(const s of t)u(s,e,void 0,r+1);return}for(const[s,a]of Object.entries(t))u(a,e,s,r+1)}}function A(t,e){u(t,n=>{if(!n||typeof n!="object"||Array.isArray(n))return;const r=n;r.type==="diff"&&p(e,r.path)})}function j(t,e){u(t,(n,r)=>{if(!(r!=="changes"||!n||typeof n!="object"||Array.isArray(n)))for(const s of Object.keys(n))p(e,s)})}function S(t){return t?g.includes(t):!1}function p(t,e){if(typeof e!="string")return;const n=k(e);!n||n.length>500||n.includes(`
2
- `)||n==="."||n===".."||t.add(n)}function k(t){let e=t.trim();e=e.replace(/\s+\+\d+\s*\/\s*-\d+(?:\s+.*)?$/,""),e=e.replace(/\s+\(\s*\+\d+\s*[,/ ]\s*-\d+\s*\)(?:\s+.*)?$/,""),e=e.replace(/\s+(?:source|event|workspace|session|last)=\S+.*$/,"");const n=e.split(/\s+/)[0]||"";return n&&/\.[A-Za-z][A-Za-z0-9+-]{0,12}$/.test(n)&&(e=n),e.replace(/^["']|["']$/g,"").trim()}function F(t){const e=[],n=/(?:^|\s)(?:\d?>|>>)\s*(?:"([^"]+)"|'([^']+)'|([^\s;&|<>]+))/g;let r;for(;r=n.exec(t);){const a=r[1]||r[2]||r[3];a&&e.push(a)}const s=/(?:^|\s)touch\s+(?:"([^"]+)"|'([^']+)'|([^\s;&|<>]+))/g;for(;r=s.exec(t);){const a=r[1]||r[2]||r[3];a&&!a.startsWith("-")&&e.push(a)}return e}function C(t){try{return d.statSync(t)}catch{return null}}function H(t){try{return h.createHash("sha256").update(d.readFileSync(t)).digest("hex")}catch{return}}function _(t){switch(c.extname(t).toLowerCase()){case".doc":return"application/msword";case".xls":return"application/vnd.ms-excel";case".xlsm":return"application/vnd.ms-excel.sheet.macroEnabled.12";case".ppt":return"application/vnd.ms-powerpoint";case".pptx":return"application/vnd.openxmlformats-officedocument.presentationml.presentation";case".odt":return"application/vnd.oasis.opendocument.text";case".ods":return"application/vnd.oasis.opendocument.spreadsheet";case".odp":return"application/vnd.oasis.opendocument.presentation";case".rtf":return"application/rtf";case".svg":return"image/svg+xml";case".bmp":return"image/bmp";case".tif":case".tiff":return"image/tiff";case".avif":return"image/avif";case".pdf":return"application/pdf";case".md":case".markdown":return"text/markdown; charset=utf-8";case".txt":case".log":return"text/plain; charset=utf-8";case".json":return"application/json; charset=utf-8";case".csv":return"text/csv; charset=utf-8";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".zip":return"application/zip";case".docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";default:return"application/octet-stream"}}export{T as captureGitSnapshot,R as collectAffectedFiles,E as extractAffectedFilePathsFromAcpRaw,_ as mimeForPath};
1
+ import{execFileSync as l}from"node:child_process";import d from"node:fs";import o from"node:path";import h from"node:crypto";import{mediaMimeForExtension as m}from"./media-file-types.js";import{packageMimeForExtension as g}from"./package-file-types.js";const x=50*1024*1024,w=["path","file","filePath","file_path","filename","targetPath","target_path","move_path"];function G(t){if(!P(t))return null;const e=A(t);if(!e)return null;const n=new Map;for(const r of e)n.set(r.path,{status:r.status,objectHash:r.status.includes("D")?null:k(t,r.path)});return n}function K(t){const e=new Map;for(const n of t.evidencePaths)y(e,t.cwd,n,"unknown","acp_tool");return[...e.values()].filter(n=>n.relativePath&&!n.relativePath.startsWith(".git/")).sort((n,r)=>n.relativePath.localeCompare(r.relativePath))}function O(t){const e=new Set;return u(t,(n,r)=>{if(typeof n=="string"&&(S(r)&&p(e,n),r==="command"))for(const s of H(n))p(e,s)}),F(t,e),j(t,e),[...e]}function y(t,e,n,r,s){const a=v(e,n);if(!a)return;const i=t.get(a.relativePath),c=_(a.absolutePath),f={path:a.absolutePath,absolutePath:a.absolutePath,relativePath:a.relativePath,changeType:b(i?.changeType,r),source:i?.source==="acp_tool"||i?.source==="acp_diff"?i.source:s,exists:!!c?.isFile(),downloadable:!!c?.isFile(),...c?.isFile()?{size:c.size,mime:M(a.absolutePath),sha256:c.size<=x?B(a.absolutePath):void 0}:{}};t.set(a.relativePath,f)}function b(t,e){return!t||t==="unknown"?e:e==="unknown"||t===e?t:t==="created"&&e==="modified"?"created":e}function v(t,e){if(!e||e.includes("\0"))return null;const n=o.resolve(t),r=o.isAbsolute(e)?o.resolve(e):o.resolve(n,e),s=o.relative(n,r).replace(/\\/g,"/");return!s||s.startsWith("..")||o.isAbsolute(s)?null:{absolutePath:r,relativePath:s}}function P(t){try{return l("git",["-C",t,"rev-parse","--is-inside-work-tree"],{windowsHide:!0,encoding:"utf8",stdio:["ignore","pipe","ignore"]}),!0}catch{return!1}}function A(t){try{const n=l("git",["-C",t,"status","--porcelain=v1","-z","--untracked-files=all"],{windowsHide:!0,encoding:"buffer",maxBuffer:20971520}).toString("utf8").split("\0").filter(Boolean),r=[];for(let s=0;s<n.length;s+=1){const a=n[s],i=a.slice(0,2),c=a.slice(3);if(c)if(i.startsWith("R")||i.startsWith("C")){const f=n[s+1];f&&(r.push({status:i,path:f}),s+=1)}else r.push({status:i,path:c})}return r}catch{return null}}function k(t,e){try{const n=l("git",["-C",t,"hash-object","--",e],{windowsHide:!0,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:1048576}).trim();return/^[0-9a-f]{40,64}$/i.test(n)?n:null}catch{return null}}function u(t,e,n,r=0){if(!(r>8)&&(e(t,n),!(!t||typeof t!="object"))){if(Array.isArray(t)){for(const s of t)u(s,e,void 0,r+1);return}for(const[s,a]of Object.entries(t))u(a,e,s,r+1)}}function F(t,e){u(t,n=>{if(!n||typeof n!="object"||Array.isArray(n))return;const r=n;r.type==="diff"&&p(e,r.path)})}function j(t,e){u(t,(n,r)=>{if(!(r!=="changes"||!n||typeof n!="object"||Array.isArray(n)))for(const s of Object.keys(n))p(e,s)})}function S(t){return t?w.includes(t):!1}function p(t,e){if(typeof e!="string")return;const n=C(e);!n||n.length>500||n.includes(`
2
+ `)||n==="."||n===".."||t.add(n)}function C(t){let e=t.trim();e=e.replace(/\s+\+\d+\s*\/\s*-\d+(?:\s+.*)?$/,""),e=e.replace(/\s+\(\s*\+\d+\s*[,/ ]\s*-\d+\s*\)(?:\s+.*)?$/,""),e=e.replace(/\s+(?:source|event|workspace|session|last)=\S+.*$/,"");const n=e.split(/\s+/)[0]||"";return n&&/\.[A-Za-z][A-Za-z0-9+-]{0,12}$/.test(n)&&(e=n),e.replace(/^["']|["']$/g,"").trim()}function H(t){const e=[],n=/(?:^|\s)(?:\d?>|>>)\s*(?:"([^"]+)"|'([^']+)'|([^\s;&|<>]+))/g;let r;for(;r=n.exec(t);){const a=r[1]||r[2]||r[3];a&&e.push(a)}const s=/(?:^|\s)touch\s+(?:"([^"]+)"|'([^']+)'|([^\s;&|<>]+))/g;for(;r=s.exec(t);){const a=r[1]||r[2]||r[3];a&&!a.startsWith("-")&&e.push(a)}return e}function _(t){try{return d.statSync(t)}catch{return null}}function B(t){try{return h.createHash("sha256").update(d.readFileSync(t)).digest("hex")}catch{return}}function M(t){const e=g(o.extname(t));if(e)return e;const n=m(o.extname(t));if(n)return n;switch(o.extname(t).toLowerCase()){case".doc":return"application/msword";case".xls":return"application/vnd.ms-excel";case".xlsm":return"application/vnd.ms-excel.sheet.macroEnabled.12";case".ppt":return"application/vnd.ms-powerpoint";case".pptx":return"application/vnd.openxmlformats-officedocument.presentationml.presentation";case".odt":return"application/vnd.oasis.opendocument.text";case".ods":return"application/vnd.oasis.opendocument.spreadsheet";case".odp":return"application/vnd.oasis.opendocument.presentation";case".rtf":return"application/rtf";case".svg":return"image/svg+xml";case".bmp":return"image/bmp";case".tif":case".tiff":return"image/tiff";case".avif":return"image/avif";case".pdf":return"application/pdf";case".md":case".markdown":return"text/markdown; charset=utf-8";case".txt":case".log":return"text/plain; charset=utf-8";case".json":return"application/json; charset=utf-8";case".csv":return"text/csv; charset=utf-8";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";default:return"application/octet-stream"}}export{G as captureGitSnapshot,K as collectAffectedFiles,O as extractAffectedFilePathsFromAcpRaw,M as mimeForPath};
@@ -1 +1 @@
1
- import l from"node:fs";import n from"node:path";import{mimeForPath as S}from"../affected-files.js";const _=new Set([".pdf",".doc",".docx",".odt",".rtf",".xls",".xlsx",".xlsm",".ods",".csv",".ppt",".pptx",".odp",".png",".jpg",".jpeg",".gif",".webp",".bmp",".tif",".tiff",".svg",".avif"]),N=new Set([".git","node_modules",".venv","venv","__pycache__"]),T=[["target","classes"],["target","test-classes"],[".next","cache"],[".angular","cache"],[".gradle","caches"]],x=[["build","resources","main"],["build","resources","test"],["build","intermediates","merged_res"],["build","intermediates","packaged_res"],["build","intermediates","merged_assets"]],A=[".aca/attachments",".aica/attachments",".aca/artifacts",".aica/artifacts",".aca/logs",".aica/logs",".aca/server-data",".aica/server-data"],j=8192,b=1e4,w=new Map;function g(c,e){const t=n.basename(c);return!f(c,e)&&!t.startsWith("~$")&&_.has(n.extname(t).toLowerCase())}function f(c,e){const t=c.split(n.sep).join("/"),i=t.split("/"),s=(r,a)=>a.some(o=>o.every((d,p)=>i[r+p]===d));return i.some((r,a)=>N.has(r)||s(a,T)||r==="build"&&e?.has(i.slice(0,a+1).join("/"))&&s(a,x))||A.some(r=>t===r||t.startsWith(`${r}/`))}class z{root;warn;watches=new Map;gradleBuildPaths=new Set;subscribers=new Set;pending=new Set;timer;closed=!1;warned=!1;draining=!1;constructor(e,t){this.root=e,this.warn=t}degraded(e){this.warned||this.closed||(this.warned=!0,this.warn(`文档监听部分不可用,将以结束扫描补偿(仍可能遗漏瞬时变化):${String(e)}`))}watchDirectory(e){if(!(this.closed||this.watches.has(e))){if(this.watches.size>=j){this.degraded("目录监听数量达到上限");return}try{const t=l.watch(e,{persistent:!1},(i,s)=>{if(this.closed||!s)return;const r=n.join(e,s.toString()),a=n.relative(this.root,r);if(!f(a,this.gradleBuildPaths)){if(g(a,this.gradleBuildPaths))for(const o of this.subscribers)o.size<b?o.add(a):this.degraded("文件事件候选数量达到上限");i==="rename"&&this.schedule(r)}});t.on("error",i=>{t.close(),this.watches.get(e)===t&&this.watches.delete(e),this.degraded(i)}),this.watches.set(e,t)}catch(t){this.degraded(t)}}}schedule(e){if(this.pending.size>=b){this.degraded("目录事件积压");return}this.pending.add(e),!(this.timer||this.draining)&&(this.timer=setTimeout(()=>{this.timer=void 0,this.drain()},50),this.timer.unref())}async drain(){this.draining=!0;try{for(;!this.closed&&this.pending.size>0;){const e=this.pending.values().next().value;if(this.pending.delete(e),this.watches.has(e))for(const[t,i]of this.watches)(t===e||t.startsWith(`${e}${n.sep}`))&&(i.close(),this.watches.delete(t));await this.walk(e,new Map)}}finally{this.draining=!1}}async snapshot(){const e=new Map;return await this.walk(this.root,e),e}async updateGradleContext(e,t){if(!t||n.basename(e)!=="build")return;const i=await Promise.all(["build.gradle","build.gradle.kts"].map(async r=>{try{return(await l.promises.lstat(n.join(n.dirname(e),r))).isFile()}catch(a){const o=a.code;return o!=="ENOENT"&&o!=="ENOTDIR"&&this.degraded(a),!1}})),s=t.split(n.sep).join("/");i.some(Boolean)?this.gradleBuildPaths.add(s):this.gradleBuildPaths.delete(s)}async walk(e,t){if(this.closed)return;const i=n.relative(this.root,e);if(!f(i,this.gradleBuildPaths))try{const s=await l.promises.lstat(e);if(s.isSymbolicLink())return;if(s.isDirectory()){await this.updateGradleContext(e,i),this.watchDirectory(e);const r=await l.promises.opendir(e);for await(const a of r){if(this.closed)break;if(a.isSymbolicLink())continue;const o=n.join(e,a.name),d=n.relative(this.root,o);f(d,this.gradleBuildPaths)||(a.isDirectory()||g(d,this.gradleBuildPaths))&&await this.walk(o,t)}}else if(s.isFile()&&g(i,this.gradleBuildPaths)){const r=await l.promises.realpath(e),a=n.relative(this.root,r);if(a.startsWith(`..${n.sep}`)||n.isAbsolute(a)||f(a,this.gradleBuildPaths))return;t.set(i,{size:s.size,signature:`${s.dev}:${s.ino}:${s.size}:${s.mtimeMs}:${s.ctimeMs}`})}}catch(s){const r=s.code;r!=="ENOENT"&&r!=="ENOTDIR"&&this.degraded(s)}}close(){this.closed=!0,this.timer&&clearTimeout(this.timer);for(const e of this.watches.values())e.close();this.watches.clear(),this.pending.clear()}}async function M(c,e){const t=await l.promises.realpath(c);let i=w.get(t);i||(i=new z(t,e),w.set(t,i));const s=i,r=new Set;s.subscribers.add(r);let a=!1;const o=()=>{a||(a=!0,s.subscribers.delete(r),s.subscribers.size===0&&(s.close(),w.delete(t)))};let d;try{d=await s.snapshot(),r.clear()}catch(m){throw o(),m}let p;return{dispose:o,finish(){return p??=(async()=>{if(a)return[];try{const m=await s.snapshot(),v=[];for(const[h,u]of m){const y=d.get(h);if(!r.has(h)&&y?.signature===u.signature)continue;const E=n.join(t,h);v.push({path:E,absolutePath:E,relativePath:h.split(n.sep).join("/"),changeType:y?"modified":"created",source:"job_time_window",exists:!0,downloadable:!0,size:u.size,mime:S(h)})}return v.sort((h,u)=>h.relativePath.localeCompare(u.relativePath))}finally{o()}})()}}}function P(c,e){const t=new Map(c.map(i=>[i.relativePath,i]));for(const i of e)t.set(i.relativePath,i);return[...t.values()]}export{g as isArtifactPath,f as isIgnoredArtifactPath,P as mergeArtifactFiles,M as startJobArtifactMonitor};
1
+ import l from"node:fs";import n from"node:path";import{mimeForPath as _}from"../affected-files.js";import{MEDIA_FILE_EXTENSIONS as b}from"../media-file-types.js";import{PACKAGE_FILE_EXTENSIONS as N}from"../package-file-types.js";const A=new Set([".pdf",".doc",".docx",".odt",".rtf",".xls",".xlsx",".xlsm",".ods",".csv",".ppt",".pptx",".odp",".png",".jpg",".jpeg",".gif",".webp",".bmp",".tif",".tiff",".svg",".avif",...b,...N]),T=new Set([".git","node_modules",".venv","venv","__pycache__"]),I=[["target","classes"],["target","test-classes"],[".next","cache"],[".angular","cache"],[".gradle","caches"]],x=[["build","resources","main"],["build","resources","test"],["build","intermediates","merged_res"],["build","intermediates","packaged_res"],["build","intermediates","merged_assets"]],D=[".aca/attachments",".aica/attachments",".aca/artifacts",".aica/artifacts",".aca/logs",".aica/logs",".aca/server-data",".aica/server-data"],j=8192,S=1e4,w=new Map;function g(c,t){const e=n.basename(c);return!f(c,t)&&!e.startsWith("~$")&&A.has(n.extname(e).toLowerCase())}function f(c,t){const e=c.split(n.sep).join("/"),i=e.split("/"),s=(r,a)=>a.some(o=>o.every((d,p)=>i[r+p]===d));return i.some((r,a)=>T.has(r)||s(a,I)||r==="build"&&t?.has(i.slice(0,a+1).join("/"))&&s(a,x))||D.some(r=>e===r||e.startsWith(`${r}/`))}class z{root;warn;watches=new Map;gradleBuildPaths=new Set;subscribers=new Set;pending=new Set;timer;closed=!1;warned=!1;draining=!1;constructor(t,e){this.root=t,this.warn=e}degraded(t){this.warned||this.closed||(this.warned=!0,this.warn(`产物监听部分不可用,将以结束扫描补偿(仍可能遗漏瞬时变化):${String(t)}`))}watchDirectory(t){if(!(this.closed||this.watches.has(t))){if(this.watches.size>=j){this.degraded("目录监听数量达到上限");return}try{const e=l.watch(t,{persistent:!1},(i,s)=>{if(this.closed||!s)return;const r=n.join(t,s.toString()),a=n.relative(this.root,r);if(!f(a,this.gradleBuildPaths)){if(g(a,this.gradleBuildPaths))for(const o of this.subscribers)o.size<S?o.add(a):this.degraded("文件事件候选数量达到上限");i==="rename"&&this.schedule(r)}});e.on("error",i=>{e.close(),this.watches.get(t)===e&&this.watches.delete(t),this.degraded(i)}),this.watches.set(t,e)}catch(e){this.degraded(e)}}}schedule(t){if(this.pending.size>=S){this.degraded("目录事件积压");return}this.pending.add(t),!(this.timer||this.draining)&&(this.timer=setTimeout(()=>{this.timer=void 0,this.drain()},50),this.timer.unref())}async drain(){this.draining=!0;try{for(;!this.closed&&this.pending.size>0;){const t=this.pending.values().next().value;if(this.pending.delete(t),this.watches.has(t))for(const[e,i]of this.watches)(e===t||e.startsWith(`${t}${n.sep}`))&&(i.close(),this.watches.delete(e));await this.walk(t,new Map)}}finally{this.draining=!1}}async snapshot(){const t=new Map;return await this.walk(this.root,t),t}async updateGradleContext(t,e){if(!e||n.basename(t)!=="build")return;const i=await Promise.all(["build.gradle","build.gradle.kts"].map(async r=>{try{return(await l.promises.lstat(n.join(n.dirname(t),r))).isFile()}catch(a){const o=a.code;return o!=="ENOENT"&&o!=="ENOTDIR"&&this.degraded(a),!1}})),s=e.split(n.sep).join("/");i.some(Boolean)?this.gradleBuildPaths.add(s):this.gradleBuildPaths.delete(s)}async walk(t,e){if(this.closed)return;const i=n.relative(this.root,t);if(!f(i,this.gradleBuildPaths))try{const s=await l.promises.lstat(t);if(s.isSymbolicLink())return;if(s.isDirectory()){await this.updateGradleContext(t,i),this.watchDirectory(t);const r=await l.promises.opendir(t);for await(const a of r){if(this.closed)break;if(a.isSymbolicLink())continue;const o=n.join(t,a.name),d=n.relative(this.root,o);f(d,this.gradleBuildPaths)||(a.isDirectory()||g(d,this.gradleBuildPaths))&&await this.walk(o,e)}}else if(s.isFile()&&g(i,this.gradleBuildPaths)){const r=await l.promises.realpath(t),a=n.relative(this.root,r);if(a.startsWith(`..${n.sep}`)||n.isAbsolute(a)||f(a,this.gradleBuildPaths))return;e.set(i,{size:s.size,signature:`${s.dev}:${s.ino}:${s.size}:${s.mtimeMs}:${s.ctimeMs}`})}}catch(s){const r=s.code;r!=="ENOENT"&&r!=="ENOTDIR"&&this.degraded(s)}}close(){this.closed=!0,this.timer&&clearTimeout(this.timer);for(const t of this.watches.values())t.close();this.watches.clear(),this.pending.clear()}}async function $(c,t){const e=await l.promises.realpath(c);let i=w.get(e);i||(i=new z(e,t),w.set(e,i));const s=i,r=new Set;s.subscribers.add(r);let a=!1;const o=()=>{a||(a=!0,s.subscribers.delete(r),s.subscribers.size===0&&(s.close(),w.delete(e)))};let d;try{d=await s.snapshot(),r.clear()}catch(m){throw o(),m}let p;return{dispose:o,finish(){return p??=(async()=>{if(a)return[];try{const m=await s.snapshot(),E=[];for(const[h,u]of m){const v=d.get(h);if(!r.has(h)&&v?.signature===u.signature)continue;const y=n.join(e,h);E.push({path:y,absolutePath:y,relativePath:h.split(n.sep).join("/"),changeType:v?"modified":"created",source:"job_time_window",exists:!0,downloadable:!0,size:u.size,mime:_(h)})}return E.sort((h,u)=>h.relativePath.localeCompare(u.relativePath))}finally{o()}})()}}}function C(c,t){const e=new Map(c.map(i=>[i.relativePath,i]));for(const i of t)e.set(i.relativePath,i);return[...e.values()]}export{g as isArtifactPath,f as isIgnoredArtifactPath,C as mergeArtifactFiles,$ as startJobArtifactMonitor};
@@ -1 +1 @@
1
- import{managementActivity as f}from"./management/activity.js";import{managedClaim as y}from"./management/claims.js";import c from"node:fs";import x from"node:os";import o from"node:path";import{Readable as l}from"node:stream";import{acaServerRequest as u,acaServerStreamRequest as g}from"./aca-server-client.js";import{loadAcaConfig as b}from"./aca-config.js";import{expandWorkerRuntimePath as S}from"./worker-runtime-paths.js";import{startLongPollWorker as I}from"./long-poll-worker.js";import{openImageFile as j}from"./image-file-access.js";const d=25e3,v=d+1e4;function G(e){return I({run:async()=>{const t=b();if(!t.token)throw new Error("Worker 尚未配置认证令牌");const a=await y("file",()=>u("GET",`/api/client/file-requests/claim?machineId=${encodeURIComponent(t.machineId)}&waitMs=${d}`,void 0,{timeoutMs:v}));if(!a.item)return;const n=f.track("file");try{await E(a.item,t,e)}catch(i){const r=i instanceof Error?i.message:String(i);e.warn(`file request failed request=${a.item.requestId}: ${r}`);try{await R(a.item.requestId,r)}catch(s){f.uncertain.add("file-finalize"),e.warn(`file request fail callback failed request=${a.item.requestId}: ${s instanceof Error?s.message:String(s)}`)}}finally{n()}},onError:(t,a)=>e.warn(`file transfer worker failed, retry in ${a}ms: ${t instanceof Error?t.message:String(t)}`)})}async function R(e,t){await u("POST",`/api/client/file-requests/${encodeURIComponent(e)}/fail`,{message:t})}async function E(e,t,a){const n=t.projects.find(m=>m.projectId===e.projectId),i=h(e.projectRoot||n?.rootPath||"");if(e.purpose==="image-file"){const m=j(i,e.path,e.maxBytes);try{a.info(`streaming image request=${e.requestId} path=${m.path}`),await g("POST",`/api/client/file-requests/${encodeURIComponent(e.requestId)}/stream`,l.toWeb(m.stream),{"content-type":"application/octet-stream","x-aca-file-name":encodeURIComponent(o.basename(m.path)),"x-aca-file-size":String(m.sizeBytes),"x-aca-file-mime":m.mimeType})}finally{m.stream.destroy()}return}if(!i)throw new Error(`file request ${e.requestId} project root is unknown`);const r=e.purpose==="temp-image"?"temp-image":e.purpose==="project-preview"?"project-preview":"project-file",s=r==="temp-image"?F(e.path):$(i,e.path),p=c.statSync(s);if(!p.isFile())throw new Error(`file request ${e.requestId} target is not a file`);if(p.size>e.maxBytes)throw new Error(`file request ${e.requestId} target is too large (${p.size} bytes)`);const w=r==="temp-image"?k(s):L(s);a.info(`streaming file request=${e.requestId} path=${s}`),await g("POST",`/api/client/file-requests/${encodeURIComponent(e.requestId)}/stream`,l.toWeb(c.createReadStream(s)),{"content-type":"application/octet-stream","x-aca-file-name":encodeURIComponent(o.basename(s)),"x-aca-file-size":String(p.size),"x-aca-file-mime":w})}function $(e,t){const a=c.realpathSync(h(e)),n=o.isAbsolute(t)?t:o.join(a,t),i=c.realpathSync(n),r=o.relative(a,i);if(r===""||r.startsWith("..")||o.isAbsolute(r))throw new Error("requested file is outside project root");return i}function F(e){const t=T(e);if(!o.isAbsolute(t))throw new Error("temporary image path must be absolute");const a=c.lstatSync(t);if(a.isSymbolicLink())throw new Error("temporary image cannot be a symbolic link");if(!a.isFile())throw new Error("temporary image target is not a regular file");const n=c.realpathSync(x.tmpdir()),i=c.realpathSync(t),r=o.relative(n,i);if(r===""||r.startsWith("..")||o.isAbsolute(r))throw new Error("temporary image is outside the system temp directory");return i}function k(e){const t=o.extname(e).toLowerCase(),a=Buffer.alloc(16),n=c.openSync(e,"r");let i=0;try{i=c.readSync(n,a,0,a.length,0)}finally{c.closeSync(n)}const r=a.subarray(0,i);if(t===".png"&&r.length>=8&&r.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])))return"image/png";if([".jpg",".jpeg"].includes(t)&&r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"image/jpeg";if(t===".gif"&&r.length>=6&&["GIF87a","GIF89a"].includes(r.subarray(0,6).toString("ascii")))return"image/gif";if(t===".webp"&&r.length>=12&&r.subarray(0,4).toString("ascii")==="RIFF"&&r.subarray(8,12).toString("ascii")==="WEBP")return"image/webp";throw new Error("temporary file is not a supported raster image")}function T(e){const t=String(e||"").trim();if(!t.startsWith("file://"))return t;try{return decodeURIComponent(new URL(t).pathname)}catch{throw new Error("temporary image path is invalid")}}function h(e){return S(e)}function L(e){switch(o.extname(e).toLowerCase()){case".pdf":return"application/pdf";case".md":case".markdown":return"text/markdown; charset=utf-8";case".txt":case".log":return"text/plain; charset=utf-8";case".html":case".htm":return"text/html; charset=utf-8";case".css":return"text/css; charset=utf-8";case".js":case".mjs":return"text/javascript; charset=utf-8";case".json":case".map":return"application/json; charset=utf-8";case".xml":return"application/xml; charset=utf-8";case".svg":return"image/svg+xml; charset=utf-8";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".ppm":return"image/x-portable-pixmap";case".bmp":return"image/bmp";case".woff":return"font/woff";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".otf":return"font/otf";case".eot":return"application/vnd.ms-fontobject";case".mp4":return"video/mp4";case".webm":return"video/webm";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return"audio/ogg";case".webmanifest":return"application/manifest+json; charset=utf-8";case".zip":return"application/zip";case".docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";default:return"application/octet-stream"}}export{k as detectSafeTempImageMime,L as mimeForPath,$ as resolveProjectFile,F as resolveTempImageFile,G as startFileTransferWorkerLoop};
1
+ import{managementActivity as f}from"./management/activity.js";import{managedClaim as x}from"./management/claims.js";import c from"node:fs";import y from"node:os";import i from"node:path";import{Readable as l}from"node:stream";import{acaServerRequest as u,acaServerStreamRequest as g}from"./aca-server-client.js";import{loadAcaConfig as b}from"./aca-config.js";import{expandWorkerRuntimePath as S}from"./worker-runtime-paths.js";import{startLongPollWorker as I}from"./long-poll-worker.js";import{openImageFile as j}from"./image-file-access.js";import{mediaMimeForExtension as E}from"./media-file-types.js";import{packageMimeForExtension as v}from"./package-file-types.js";const d=25e3,R=d+1e4;function H(e){return I({run:async()=>{const t=b();if(!t.token)throw new Error("Worker 尚未配置认证令牌");const a=await x("file",()=>u("GET",`/api/client/file-requests/claim?machineId=${encodeURIComponent(t.machineId)}&waitMs=${d}`,void 0,{timeoutMs:R}));if(!a.item)return;const n=f.track("file");try{await F(a.item,t,e)}catch(o){const r=o instanceof Error?o.message:String(o);e.warn(`file request failed request=${a.item.requestId}: ${r}`);try{await $(a.item.requestId,r)}catch(s){f.uncertain.add("file-finalize"),e.warn(`file request fail callback failed request=${a.item.requestId}: ${s instanceof Error?s.message:String(s)}`)}}finally{n()}},onError:(t,a)=>e.warn(`file transfer worker failed, retry in ${a}ms: ${t instanceof Error?t.message:String(t)}`)})}async function $(e,t){await u("POST",`/api/client/file-requests/${encodeURIComponent(e)}/fail`,{message:t})}async function F(e,t,a){const n=t.projects.find(m=>m.projectId===e.projectId),o=h(e.projectRoot||n?.rootPath||"");if(e.purpose==="image-file"){const m=j(o,e.path,e.maxBytes);try{a.info(`streaming image request=${e.requestId} path=${m.path}`),await g("POST",`/api/client/file-requests/${encodeURIComponent(e.requestId)}/stream`,l.toWeb(m.stream),{"content-type":"application/octet-stream","x-aca-file-name":encodeURIComponent(i.basename(m.path)),"x-aca-file-size":String(m.sizeBytes),"x-aca-file-mime":m.mimeType})}finally{m.stream.destroy()}return}if(!o)throw new Error(`file request ${e.requestId} project root is unknown`);const r=e.purpose==="temp-image"?"temp-image":e.purpose==="project-preview"?"project-preview":"project-file",s=r==="temp-image"?T(e.path):k(o,e.path),p=c.statSync(s);if(!p.isFile())throw new Error(`file request ${e.requestId} target is not a file`);if(p.size>e.maxBytes)throw new Error(`file request ${e.requestId} target is too large (${p.size} bytes)`);const w=r==="temp-image"?L(s):C(s);a.info(`streaming file request=${e.requestId} path=${s}`),await g("POST",`/api/client/file-requests/${encodeURIComponent(e.requestId)}/stream`,l.toWeb(c.createReadStream(s)),{"content-type":"application/octet-stream","x-aca-file-name":encodeURIComponent(i.basename(s)),"x-aca-file-size":String(p.size),"x-aca-file-mime":w})}function k(e,t){const a=c.realpathSync(h(e)),n=i.isAbsolute(t)?t:i.join(a,t),o=c.realpathSync(n),r=i.relative(a,o);if(r===""||r.startsWith("..")||i.isAbsolute(r))throw new Error("requested file is outside project root");return o}function T(e){const t=q(e);if(!i.isAbsolute(t))throw new Error("temporary image path must be absolute");const a=c.lstatSync(t);if(a.isSymbolicLink())throw new Error("temporary image cannot be a symbolic link");if(!a.isFile())throw new Error("temporary image target is not a regular file");const n=c.realpathSync(y.tmpdir()),o=c.realpathSync(t),r=i.relative(n,o);if(r===""||r.startsWith("..")||i.isAbsolute(r))throw new Error("temporary image is outside the system temp directory");return o}function L(e){const t=i.extname(e).toLowerCase(),a=Buffer.alloc(16),n=c.openSync(e,"r");let o=0;try{o=c.readSync(n,a,0,a.length,0)}finally{c.closeSync(n)}const r=a.subarray(0,o);if(t===".png"&&r.length>=8&&r.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])))return"image/png";if([".jpg",".jpeg"].includes(t)&&r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"image/jpeg";if(t===".gif"&&r.length>=6&&["GIF87a","GIF89a"].includes(r.subarray(0,6).toString("ascii")))return"image/gif";if(t===".webp"&&r.length>=12&&r.subarray(0,4).toString("ascii")==="RIFF"&&r.subarray(8,12).toString("ascii")==="WEBP")return"image/webp";throw new Error("temporary file is not a supported raster image")}function q(e){const t=String(e||"").trim();if(!t.startsWith("file://"))return t;try{return decodeURIComponent(new URL(t).pathname)}catch{throw new Error("temporary image path is invalid")}}function h(e){return S(e)}function C(e){const t=v(i.extname(e));if(t)return t;const a=E(i.extname(e));if(a)return a;switch(i.extname(e).toLowerCase()){case".pdf":return"application/pdf";case".md":case".markdown":return"text/markdown; charset=utf-8";case".txt":case".log":return"text/plain; charset=utf-8";case".html":case".htm":return"text/html; charset=utf-8";case".css":return"text/css; charset=utf-8";case".js":case".mjs":return"text/javascript; charset=utf-8";case".json":case".map":return"application/json; charset=utf-8";case".xml":return"application/xml; charset=utf-8";case".svg":return"image/svg+xml; charset=utf-8";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".ppm":return"image/x-portable-pixmap";case".bmp":return"image/bmp";case".woff":return"font/woff";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".otf":return"font/otf";case".eot":return"application/vnd.ms-fontobject";case".webmanifest":return"application/manifest+json; charset=utf-8";case".docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";default:return"application/octet-stream"}}export{L as detectSafeTempImageMime,C as mimeForPath,k as resolveProjectFile,T as resolveTempImageFile,H as startFileTransferWorkerLoop};
@@ -0,0 +1 @@
1
+ const o={".mp4":"video/mp4",".webm":"video/webm",".mov":"video/quicktime",".mkv":"video/x-matroska",".avi":"video/x-msvideo",".m4v":"video/x-m4v",".mp3":"audio/mpeg",".wav":"audio/wav",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".ogg":"audio/ogg",".opus":"audio/ogg"},e=Object.keys(o);function i(a){return o[a.toLowerCase()]}export{e as MEDIA_FILE_EXTENSIONS,i as mediaMimeForExtension};
@@ -0,0 +1 @@
1
+ const a={".apk":"application/vnd.android.package-archive",".aab":"application/octet-stream",".exe":"application/vnd.microsoft.portable-executable",".msi":"application/x-msi",".msix":"application/msix",".dmg":"application/x-apple-diskimage",".pkg":"application/octet-stream",".deb":"application/vnd.debian.binary-package",".rpm":"application/x-rpm",".appimage":"application/vnd.appimage",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".bz2":"application/x-bzip2",".tbz2":"application/x-bzip2",".xz":"application/x-xz",".txz":"application/x-xz",".zst":"application/zstd",".tzst":"application/zstd",".rar":"application/vnd.rar",".7z":"application/x-7z-compressed"},i=Object.keys(a);function t(p){return a[p.toLowerCase()]}export{i as PACKAGE_FILE_EXTENSIONS,t as packageMimeForExtension};
@@ -1 +1 @@
1
- import a from"node:fs";import i from"node:path";import w from"node:os";import A from"node:net";import{createHash as x}from"node:crypto";import{getAcaHome as m}from"./paths.js";import{readPidFile as h,isProcessAlive as k}from"./process.js";import{readProcessStartTicks as O}from"./process-identity.js";function l(e){const r=i.resolve(e);try{return a.realpathSync(r)}catch{return i.dirname(r)===r?r:i.join(l(i.dirname(r)),i.basename(r))}}function y(e,r){const o=e.find(t=>t.startsWith(`${r}=`));if(o)return o.slice(r.length+1);const n=e.indexOf(r);return n>=0?e[n+1]:void 0}function $(e,r,o){const n=r.ACA_SINGLE_FILE_WORKER==="1"&&e[1]==="start",t=e.indexOf("start");if(t<(n?1:2)||t>8||e.slice(t+1).some(s=>s==="-b"||s==="--background"))return!1;if(n)return!0;const f=e[t-1];if(!/^(?:aca|aica|(?:worker-cli|cli)\.(?:js|mjs|cjs|ts))$/.test(i.basename(f)))return!1;if(r.ACA_WORKER_INSTANCE_ID)return!0;let c=i.dirname(l(i.resolve(o,f)));for(let s=0;s<4;s++){try{const u=JSON.parse(a.readFileSync(i.join(c,"package.json"),"utf8"));if(["aca","@yuandc/aica"].includes(u.name))return!0}catch{}c=i.dirname(c)}return!1}function I(e=m()){if(process.platform!=="linux"){const n=h();return n&&n!==process.pid&&k(n)?[{pid:n,startTicks:null}]:[]}const r=l(e),o=[];for(const n of a.readdirSync("/proc")){if(!/^\d+$/.test(n)||Number(n)===process.pid)continue;const t=Number(n);try{const f=a.readFileSync(`/proc/${t}/stat`,"utf8").split(") ").at(-1).split(" ");if(f[0]==="Z")continue;const c=a.readFileSync(`/proc/${t}/cmdline`,"utf8").split("\0").filter(Boolean);if(!c.includes("start"))continue;const s=Object.fromEntries(a.readFileSync(`/proc/${t}/environ`,"utf8").split("\0").filter(d=>d.includes("=")).map(d=>[d.slice(0,d.indexOf("=")),d.slice(d.indexOf("=")+1)])),u=a.readlinkSync(`/proc/${t}/cwd`);if(!$(c,s,u))continue;const S=y(c,"--aica-home")||y(c,"--aca-home")||s.AICA_HOME||s.ACA_HOME||i.join(s.HOME||w.homedir(),".aica");if(l(i.resolve(u,S))!==r)continue;const p=O(t);p===f[19]&&o.push({pid:t,startTicks:p})}catch(f){if(f.code==="EACCES"&&h()===t)throw new Error(`无法核对 Worker PID ${t} 的身份,请检查进程权限`)}}return o.sort((n,t)=>n.pid-t.pid)}function E(){const e=I();if(e.length)throw new Error(`当前运行目录已有 Worker:${e.map(r=>r.pid).join(", ")}。请使用 daemon restart 或 daemon stop 处理现有实例。`)}async function T(){if(process.platform!=="linux")return E(),()=>{};const e=x("sha256").update(l(m())).digest("hex"),r=A.createServer(o=>o.destroy());await new Promise((o,n)=>{r.once("error",t=>n(t.code==="EADDRINUSE"?new Error("当前运行目录已有 Worker 正在启动或运行,请勿重复启动"):t)),r.listen(`\0aica-worker-${e}`,o)}),r.unref();try{E()}catch(o){throw r.close(),o}return()=>{r.close()}}function g(e){if(e.startTicks!==null)try{const r=a.readFileSync(`/proc/${e.pid}/stat`,"utf8").split(") ").at(-1).split(" ");return r[0]!=="Z"&&r[19]===e.startTicks}catch{return!1}return k(e.pid)}export{T as acquireWorkerLease,E as assertNoWorkerInstances,I as findWorkerInstances,g as sameWorkerInstance};
1
+ import f from"node:fs";import i from"node:path";import W from"node:os";import O from"node:net";import{createHash as $}from"node:crypto";import{getAcaHome as k}from"./paths.js";import{readPidFile as y,isProcessAlive as S}from"./process.js";import{readProcessStartTicks as I}from"./process-identity.js";import{readWorkerProcessScope as u,sameWorkerProcessScope as E}from"./worker-process-scope.js";function l(e){const r=i.resolve(e);try{return f.realpathSync(r)}catch{return i.dirname(r)===r?r:i.join(l(i.dirname(r)),i.basename(r))}}function w(e,r){const n=e.find(t=>t.startsWith(`${r}=`));if(n)return n.slice(r.length+1);const s=e.indexOf(r);return s>=0?e[s+1]:void 0}function j(e,r,n){const s=r.ACA_SINGLE_FILE_WORKER==="1"&&e[1]==="start",t=e.indexOf("start");if(t<(s?1:2)||t>8||e.slice(t+1).some(c=>c==="-b"||c==="--background"))return!1;if(s)return!0;const o=e[t-1];if(!/^(?:aca|aica|(?:worker-cli|cli)\.(?:js|mjs|cjs|ts))$/.test(i.basename(o)))return!1;if(r.ACA_WORKER_INSTANCE_ID)return!0;let a=i.dirname(l(i.resolve(n,o)));for(let c=0;c<4;c++){try{const p=JSON.parse(f.readFileSync(i.join(a,"package.json"),"utf8"));if(["aca","@yuandc/aica"].includes(p.name))return!0}catch{}a=i.dirname(a)}return!1}function C(e=k()){if(process.platform!=="linux"){const t=y();return t&&t!==process.pid&&S(t)?[{pid:t,startTicks:null}]:[]}const r=u(),n=l(e),s=[];for(const t of f.readdirSync("/proc")){if(!/^\d+$/.test(t)||Number(t)===process.pid)continue;const o=Number(t);try{const a=f.readFileSync(`/proc/${o}/stat`,"utf8").split(") ").at(-1).split(" ");if(a[0]==="Z")continue;const c=f.readFileSync(`/proc/${o}/cmdline`,"utf8").split("\0").filter(Boolean);if(!c.includes("start")||!E(r,u(o)))continue;const p=Object.fromEntries(f.readFileSync(`/proc/${o}/environ`,"utf8").split("\0").filter(d=>d.includes("=")).map(d=>[d.slice(0,d.indexOf("=")),d.slice(d.indexOf("=")+1)])),m=f.readlinkSync(`/proc/${o}/cwd`);if(!j(c,p,m))continue;const A=w(c,"--aica-home")||w(c,"--aca-home")||p.AICA_HOME||p.ACA_HOME||i.join(p.HOME||W.homedir(),".aica");if(l(i.resolve(m,A))!==n)continue;const h=I(o);h===a[19]&&s.push({pid:o,startTicks:h})}catch(a){if(a.code==="EACCES"&&y()===o)throw new Error(`无法核对 Worker PID ${o} 的身份,请检查进程权限`)}}return s.sort((t,o)=>t.pid-o.pid)}function x(){const e=C();if(e.length)throw new Error(`当前运行目录已有 Worker:${e.map(r=>r.pid).join(", ")}。请使用 daemon restart 或 daemon stop 处理现有实例。`)}async function v(){if(process.platform!=="linux")return x(),()=>{};const e=$("sha256").update(l(k())).digest("hex"),r=O.createServer(n=>n.destroy());await new Promise((n,s)=>{r.once("error",t=>s(t.code==="EADDRINUSE"?new Error("当前运行目录已有 Worker 正在启动或运行,请勿重复启动"):t)),r.listen(`\0aica-worker-${e}`,n)}),r.unref();try{x()}catch(n){throw r.close(),n}return()=>{r.close()}}function D(e){if(process.platform==="linux")try{if(!E(u(),u(e.pid)))return!1}catch{return!1}if(e.startTicks!==null)try{const r=f.readFileSync(`/proc/${e.pid}/stat`,"utf8").split(") ").at(-1).split(" ");return r[0]!=="Z"&&r[19]===e.startTicks}catch{return!1}return S(e.pid)}export{v as acquireWorkerLease,x as assertNoWorkerInstances,C as findWorkerInstances,D as sameWorkerInstance};
@@ -0,0 +1 @@
1
+ import r from"node:fs";function t(e="self"){const o=`/proc/${e}`,n=r.statSync(`${o}/root`,{bigint:!0});return{pidNamespace:r.readlinkSync(`${o}/ns/pid`),mountNamespace:r.readlinkSync(`${o}/ns/mnt`),rootDevice:n.dev,rootInode:n.ino}}function s(e,o){return e.pidNamespace===o.pidNamespace&&e.mountNamespace===o.mountNamespace&&e.rootDevice===o.rootDevice&&e.rootInode===o.rootInode}export{t as readWorkerProcessScope,s as sameWorkerProcessScope};
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- const o="0.1.82";export{o as AICA_VERSION};
1
+ const o="0.1.85";export{o as AICA_VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuandc/aica",
3
- "version": "0.1.82",
3
+ "version": "0.1.85",
4
4
  "description": "AICA remote Agent worker",
5
5
  "author": "yuandc",
6
6
  "type": "module",