@yuandc/aica 0.1.62 → 0.1.64
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 +1 @@
|
|
|
1
|
-
import{CodexSubtaskExecutions as A}from"./subtask-executions.js";class O{routes=new Map;executions=new A;idleWaiters=new Set;reset(){this.routes.clear(),this.executions.reset(),this.resolveIdleWaiters(!1)}routeFor(t){return t?this.routes.get(t)??null:null}routesForSubscription(){return[...this.routes.values()]}activeThreadIds(){return this.executions.activeThreadIds()}hasActiveSubtasks(){return this.activeThreadIds().length>0}waitForIdle(t){return this.activeThreadIds().length===0?Promise.resolve({timedOut:!1,activeThreadIds:[]}):new Promise(s=>{const i={resolve:s,timer:setTimeout(()=>{this.idleWaiters.delete(i),s({timedOut:!0,activeThreadIds:this.activeThreadIds()})},t)};i.timer.unref(),this.idleWaiters.add(i)})}stopWaiting(){this.resolveIdleWaiters(!1)}acceptNotification(t,e,s){const i=this.executions.accept(t,e,
|
|
1
|
+
import{CodexSubtaskExecutions as A}from"./subtask-executions.js";class O{routes=new Map;executions=new A;idleWaiters=new Set;reset(){this.routes.clear(),this.executions.reset(),this.resolveIdleWaiters(!1)}routeFor(t){return t?this.routes.get(t)??null:null}routesForSubscription(){return[...this.routes.values()]}activeThreadIds(){return this.executions.activeThreadIds()}hasActiveSubtasks(){return this.activeThreadIds().length>0}waitForIdle(t){return this.activeThreadIds().length===0?Promise.resolve({timedOut:!1,activeThreadIds:[]}):new Promise(s=>{const i={resolve:s,timer:setTimeout(()=>{this.idleWaiters.delete(i),s({timedOut:!0,activeThreadIds:this.activeThreadIds()})},t)};i.timer.unref(),this.idleWaiters.add(i)})}stopWaiting(){this.resolveIdleWaiters(!1)}acceptNotification(t,e,s){const i=this.executions.accept(t,e,c(s));return this.hasActiveSubtasks()||this.resolveIdleWaiters(!1),i}restoreFromSessionSnapshot(t,e){const s=c(t),i=c(s.thread),n=a(i,"id")||e,o=c(s.initialTurnsPage),h=[...I(i,"turns"),...I(o,"data")];let u=0;for(const f of h){const l=c(f);for(const p of I(l,"items"))u+=this.observe({threadId:n,item:p},e,!0)}return u}observe(t,e,s=!1){const i=c(t),n=c(i.item);if(a(n,"type")==="subAgentActivity")return this.observeSubAgentActivity(n,a(i,"threadId"),e,s);if(!k(n))return 0;const o=a(n,"id");if(!o)return 0;const h=a(n,"senderThreadId")||a(i,"threadId"),u=this.routeFor(h||null),f=u?.parentToolCallId||o,l=Math.min(8,(u?.depth??0)+1),p=x(n),b=w(n.agentsStates);let T=0;for(const d of p){if(!d||d===e||d===h)continue;this.routes.has(d)||(this.routes.set(d,{parentToolCallId:f,sourceThreadId:d,depth:l}),T+=1);const m=b.get(d);if(!s){if(a(n,"tool")==="spawnAgent"){const S=this.executions.get(d);!this.executions.hasStart(d,o)&&(!S||!["pending","running"].includes(S.state))&&this.routes.set(d,{parentToolCallId:f,sourceThreadId:d,depth:l}),this.executions.start(this.routes.get(d),o,"pending",{description:a(n,"prompt")||void 0})}m?this.updateStatus(d,m):a(n,"tool")==="spawnAgent"&&this.updateStatus(d,"pending")}}return T}observeSubAgentActivity(t,e,s,i){const n=a(t,"kind"),o=a(t,"agentThreadId");if(!o||o===s||!i&&n==="started"&&this.executions.hasStart(o,a(t,"id")))return 0;if(n==="completed"||n==="interrupted")return i||this.updateStatus(o,n==="completed"?"completed":"interrupted"),0;if(n!=="started"&&n!=="interacted")return 0;const h=this.routeFor(e||null),u=h?.parentToolCallId||a(t,"id"),f=Math.min(8,(h?.depth??0)+1);if(!u)return 0;const l=this.routes.has(o)?0:1;if(l&&this.routes.set(o,{parentToolCallId:u,sourceThreadId:o,depth:f}),i)return l;if(n==="started"){const p=this.executions.get(o);(!p||!["pending","running"].includes(p.state))&&this.routes.set(o,{parentToolCallId:u,sourceThreadId:o,depth:f}),this.executions.start(this.routes.get(o),a(t,"id"),"running",{name:a(t,"agentPath").split("/").filter(Boolean).at(-1)}),this.updateStatus(o,"running")}return l}updateStatus(t,e){const s=this.routes.get(t);s&&this.executions.observeState(s,e),this.hasActiveSubtasks()||this.resolveIdleWaiters(!1)}resolveIdleWaiters(t){const e=this.activeThreadIds();for(const s of this.idleWaiters)clearTimeout(s.timer),s.resolve({timedOut:t,activeThreadIds:e});this.idleWaiters.clear()}}function w(r){const t=new Map,e=c(r);for(const[s,i]of Object.entries(e)){const n=y(a(c(i),"status"));s.trim()&&n!=="unknown"&&t.set(s.trim(),n)}return t}function y(r){switch(r.toLowerCase()){case"pending":case"pendinginit":return"pending";case"running":case"inprogress":case"in_progress":return"running";case"completed":case"shutdown":return"completed";case"failed":case"errored":case"notfound":return"failed";case"cancelled":case"canceled":case"interrupted":return"interrupted";default:return"unknown"}}function x(r){const t=c(r),e=new Set;g(e,t.newThreadId),g(e,t.receiverThreadId),C(e,t.receiverThreadIds);const s=t.agentsStates;if(Array.isArray(s))for(const i of s)v(e,i);else{const i=c(s);for(const[n,o]of Object.entries(i))v(e,o),W(n)&&e.add(n)}return[...e]}function k(r){const t=a(c(r),"type");return t==="collabAgentToolCall"||t==="collabToolCall"}function v(r,t){const e=c(t);for(const s of["threadId","thread_id","receiverThreadId","newThreadId"])g(r,e[s])}function g(r,t){typeof t=="string"&&t.trim()&&r.add(t.trim())}function C(r,t){if(Array.isArray(t))for(const e of t)g(r,e)}function I(r,t){const e=r[t];return Array.isArray(e)?e:[]}function W(r){return r.length<8?!1:!["pending","running","completed","failed","cancelled","canceled"].includes(r.toLowerCase())}function c(r){return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}function a(r,t){const e=r[t];return typeof e=="string"?e:""}export{O as CodexSubtaskRouter,x as collaborationChildThreadIds,k as isCollaborationItem};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{activeTerminalService as Q}from"./terminal/service.js";import{execFileSync as y}from"node:child_process";import{randomUUID as $}from"node:crypto";import l from"node:fs";import T from"node:os";import u from"node:path";import{acaServerDownloadToFile as Z,acaServerRequest as P}from"./aca-server-client.js";import{loadAcaConfig as q,upsertLocalProject as tt}from"./aca-config.js";import{startLongPollWorker as et}from"./long-poll-worker.js";import{expandWorkerRuntimePath as rt}from"./worker-runtime-paths.js";import{syncCodexProviderRuntimeConfig as ot}from"./codex-provider-runtime-config.js";import{defaultAcpRuntimePool as nt}from"../acp/client/acp-runtime-pool.js";const F=25e3,it=F+1e4,E=300,st=3e4;let b=null;function te(t){return et({run:async()=>{const e=q();if(!e.token)throw new Error("Worker 尚未配置认证令牌");const r=await P("GET",`/api/client/machine-operations/claim?machineId=${encodeURIComponent(e.machineId)}&waitMs=${F}`,void 0,{timeoutMs:it});if(r.item)try{const o=await at(r.item);await P("POST",`/api/client/machine-operations/${encodeURIComponent(r.item.requestId)}/complete`,{result:o})}catch(o){const n=o instanceof Error?o.message:String(o);t.warn(`machine filesystem request failed request=${r.item.requestId}: ${n}`),await P("POST",`/api/client/machine-operations/${encodeURIComponent(r.item.requestId)}/fail`,{message:n}).catch(()=>{})}},onError:(e,r)=>t.warn(`machine filesystem worker failed, retry in ${r}ms: ${e instanceof Error?e.message:String(e)}`)})}async function at(t){if(t.operation==="sync_codex_provider_config"){const e=await ot(),r=await nt.retireProviderRuntimes("codex-acp");return{configured:!!e,revision:e?.revision??null,retiredRuntimes:r}}if(t.operation==="filesystem_roots")return Dt();if(t.operation==="list_directory")return Rt({directoryPath:String(t.payload.path||""),includeHidden:t.payload.includeHidden===!0});if(t.operation==="register_project")return It(t.payload);if(t.operation==="list_project_directory")return ut(t.payload);if(t.operation==="upload_project_file")return ft(t.payload);if(t.operation==="mutate_project_files")return dt(t.payload);if(t.operation==="get_project_git_status")return O(t.payload);if(t.operation==="get_project_git_diff")return gt(t.payload);if(t.operation==="get_project_git_log")return St(t.payload);if(t.operation==="get_project_git_commit")return _t(t.payload);if(t.operation==="get_worktree_status")return k(t.payload);if(t.operation==="commit_worktree")return ct(t.payload);if(t.operation==="cleanup_worktree")return lt(t.payload);throw new Error("不支持的 Machine 文件系统操作。 ")}function k(t){const e=C(String(t.worktreePath||""));if(!l.existsSync(e))return{exists:!1,isRepository:!1,dirty:!1,changedFiles:0,ahead:0};const r=m(e);if(!w(r))return{exists:!0,isRepository:!1,dirty:xt(r),changedFiles:null,ahead:0};const o=O({rootPath:r}),n=String(t.baseCommit||"").trim(),s=n&&/^[0-9a-f]{7,64}$/i.test(n)?bt(r,n):0;return{exists:!0,isRepository:!0,dirty:Array.isArray(o.files)&&o.files.length>0,changedFiles:Array.isArray(o.files)?o.files.length:0,branch:o.branch,ahead:s,files:Array.isArray(o.files)?o.files.slice(0,50):[],truncated:o.truncated===!0}}function ct(t){const e=m(String(t.worktreePath||"")),r=String(t.message||"").trim();if(!r)throw new Error("提交说明不能为空。");if(!w(e))throw new Error("当前 Worktree 不是 Git 仓库,无法提交。");y("git",["-C",e,"add","-A"],{stdio:"pipe",timeout:3e4});try{return y("git",["-C",e,"diff","--cached","--quiet"],{stdio:"pipe",timeout:1e4}),{committed:!1,reason:"no_changes",...k(t)}}catch(o){if(Number(o.status)!==1)throw o}return y("git",["-C",e,"commit","-m",r],{stdio:"pipe",timeout:6e4}),{committed:!0,commit:d(e,["rev-parse","HEAD"],8*1024).trim(),...k(t)}}function lt(t){const e=C(String(t.worktreePath||"")),r=m(String(t.projectRoot||""));if(h(e)===h(r))throw new Error("不能清理项目主目录。");if(!l.existsSync(e))return{removed:!1,reason:"not_found"};const o=m(e);if(Q?.hasRunningInDirectory(o,String(t.sessionId||"")))throw new Error("请先结束此目录中的会话终端,再清理 Worktree。");const n=String(t.branchName||"").trim(),s=w(o)&&w(r);if(s){if(y("git",["-C",r,"worktree","remove","--force",o],{stdio:"pipe",timeout:6e4}),t.deleteBranch===!0&&n)try{y("git",["-C",r,"branch","-D",n],{stdio:"pipe",timeout:3e4})}catch(i){const a=String(i.stderr||i);if(!/not found|not exist/i.test(a))throw i}}else l.rmSync(o,{recursive:!0,force:!0,maxRetries:2,retryDelay:200});return{removed:!0,branchDeleted:!!(s&&t.deleteBranch===!0&&n)}}function ut(t){const e=m(String(t.rootPath||"")),r=S(String(t.relativePath||"")),o=j(e,r,!0),n=Math.max(0,Number(t.offset||0)),s=Math.min(300,Math.max(20,Number(t.limit||200))),i=l.readdirSync(o,{withFileTypes:!0}).filter(c=>!c.isSymbolicLink()).map(c=>({name:c.name,path:K(e,u.join(o,c.name)),type:c.isDirectory()?"directory":c.isFile()?"file":"other",hidden:c.name.startsWith("."),extension:c.isFile()?u.extname(c.name).slice(1).toLowerCase():""})).filter(c=>c.type!=="other").sort((c,f)=>c.type!==f.type?c.type==="directory"?-1:1:c.name.localeCompare(f.name,void 0,{numeric:!0,sensitivity:"base"})),a=i.slice(n,n+s);return{path:r,rootKind:t.rootKind==="worktree"?"worktree":"project",items:a,total:i.length,nextOffset:n+a.length<i.length?n+a.length:null}}async function ft(t){const e=String(t.uploadId||"").trim();if(!e)throw new Error("项目上传任务缺少 uploadId。");const r=m(String(t.rootPath||"")),o=S(String(t.relativeDirectory||"")),n=j(r,o,!0),s=I(String(t.fileName||"")),i=Number(t.sizeBytes),a=String(t.sha256||"").trim().toLowerCase();if(!Number.isSafeInteger(i)||i<0)throw new Error("项目上传文件大小无效。");if(!/^[0-9a-f]{64}$/.test(a))throw new Error("项目上传文件摘要无效。");const c=u.join(n,`.aca-upload-${$()}.tmp`);try{const f=await Z(`/api/client/project-uploads/${encodeURIComponent(e)}`,c,{maxBytes:i,timeoutMs:3e5});if(f.sizeBytes!==i)throw new Error("项目上传文件大小校验失败。");if(f.sha256.toLowerCase()!==a)throw new Error("项目上传文件完整性校验失败。");const p=ht(r,o,s,c);return{name:u.basename(p),path:K(r,p),directory:o,size:f.sizeBytes,sha256:f.sha256,renamed:u.basename(p)!==s,rootKind:t.rootKind==="worktree"?"worktree":"project"}}finally{l.rmSync(c,{force:!0})}}function dt(t){const e=m(String(t.rootPath||"")),r=t.action&&typeof t.action=="object"?t.action:{};if(r.type==="delete")return mt(e,String(r.path||""),r.recursive===!0,t.rootKind);throw new Error("project_file_operation_unsupported")}function mt(t,e,r,o){const n=S(e);if(!n)throw new Error("project_file_root_protected");pt(n);const s=n.split("/"),i=s.slice(0,-1).join("/"),a=j(t,i,!0),c=u.join(a,s.at(-1)||"");let f;try{f=l.lstatSync(c)}catch(p){throw p.code==="ENOENT"?new Error("project_file_not_found"):p}if(f.isSymbolicLink())throw new Error("project_file_symbolic_link");if(!f.isFile()&&!f.isDirectory())throw new Error("project_file_type_unsupported");if(f.isDirectory()&&!r&&l.readdirSync(c).length>0)throw new Error("project_directory_not_empty");return f.isDirectory()&&r?l.rmSync(c,{recursive:!0,force:!1,maxRetries:2,retryDelay:150}):f.isDirectory()?l.rmdirSync(c):l.unlinkSync(c),{operation:"delete",path:n,entryType:f.isDirectory()?"directory":"file",parentPath:i,affectedDirectories:[i],rootKind:o==="worktree"?"worktree":"project"}}function pt(t){const e=t.split("/")[0].toLocaleLowerCase("en-US");if([".git",".aca",".aica"].includes(e))throw new Error("project_file_protected")}function ht(t,e,r,o){const n=m(t),s=S(e),i=j(n,s,!0),a=I(r);if(l.realpathSync.native(u.dirname(o))!==i)throw new Error("项目上传临时文件不在目标目录中。");const f=l.lstatSync(o);if(!f.isFile()||f.isSymbolicLink())throw new Error("项目上传临时文件无效。");for(let p=1;p<=1e4;p+=1){const J=p===1?a:wt(a,p),_=u.join(i,J);try{return l.linkSync(o,_),l.chmodSync(_,420),l.rmSync(o,{force:!0}),_}catch(v){if(L(v))continue;if(!yt(v))throw v;try{return l.copyFileSync(o,_,l.constants.COPYFILE_EXCL),l.chmodSync(_,420),l.rmSync(o,{force:!0}),_}catch(N){if(L(N))continue;throw N}}}throw new Error("同名文件过多,无法生成可用文件名。")}function I(t){const e=t.trim();if(!e||e==="."||e===".."||/[\\/\x00-\x1F]/.test(e))throw new Error("项目上传文件名无效。");if(process.platform==="win32"&&(/[<>:"|?*]/.test(e)||/[. ]$/.test(e)))throw new Error("项目上传文件名在 Windows 上无效。");return e.slice(0,180)}function wt(t,e){const r=u.extname(t);return`${r?t.slice(0,-r.length):t} (${e})${r}`}function L(t){return!!(t&&typeof t=="object"&&t.code==="EEXIST")}function yt(t){const e=t&&typeof t=="object"?t.code:"";return["EPERM","EACCES","EXDEV","ENOTSUP","EOPNOTSUPP"].includes(String(e||""))}const M=500,x=2*1024*1024,g=2*1024*1024;function O(t){const e=m(String(t.rootPath||""));if(!w(e))return{isRepository:!1,branch:null,files:[],ahead:0,behind:0};const o=d(e,["status","--porcelain=v1","-z","--untracked-files=all","--no-renames"],x).split("\0").filter(Boolean).slice(0,M),n=o.map(a=>Et(a)).filter(a=>!!a),s=A(d(e,["diff","--no-ext-diff","--numstat","-z","--no-renames","HEAD","--","."],x));for(const a of n){const c=s.get(a.path);if(c)a.additions=c.additions,a.deletions=c.deletions;else if(a.status==="untracked"){const f=G(e,a.path);a.additions=f.additions,a.deletions=f.deletions}}const i=At(e);return{isRepository:!0,branch:kt(e),files:n,ahead:i.ahead,behind:i.behind,truncated:o.length>=M}}function gt(t){const e=m(String(t.rootPath||"")),r=S(String(t.relativePath||""));if(!r)throw new Error("Diff 文件路径不能为空。");if(!w(e))return{isRepository:!1,path:r,diff:"",additions:0,deletions:0};const o=W(e,r),n=jt(e,r),s=n?d(e,["diff","--no-ext-diff","--unified=80","HEAD","--",r],g):B(e,["diff","--no-ext-diff","--no-index","--unified=80",process.platform==="win32"?"NUL":"/dev/null",o],g),i=n?A(d(e,["diff","--no-ext-diff","--numstat","-z","--no-renames","HEAD","--",r],32*1024)).get(r):G(e,r);return{isRepository:!0,path:r,diff:U(s),additions:i?.additions??0,deletions:i?.deletions??0,truncated:s.length>g}}function St(t){const e=m(String(t.rootPath||""));if(!w(e))return{isRepository:!1,items:[]};if(!vt(e))return{isRepository:!0,items:[]};const r=Math.min(200,Math.max(20,Number(t.limit||100)));return{isRepository:!0,items:d(e,["log",`--max-count=${r}`,"--date=iso-strict","--pretty=format:%H%x1f%h%x1f%an%x1f%ae%x1f%aI%x1f%D%x1f%s%x1f%b%x1e"],x).split("").map(i=>Pt(i)).filter(i=>!!i),limit:r}}function _t(t){const e=m(String(t.rootPath||"")),r=String(t.commit||"").trim();if(!/^[0-9a-f]{7,64}$/i.test(r))throw new Error("Git 提交标识无效。");if(!w(e))return{isRepository:!1,commit:r,diff:"",additions:0,deletions:0};d(e,["cat-file","-e",`${r}^{commit}`],8*1024);const o=d(e,["show","--no-ext-diff","--no-color","--format=","--stat","--patch","--unified=40",r],g),n=[...A(d(e,["show","--no-ext-diff","--numstat","-z","--no-renames","--format=",r],x)).values()];return{isRepository:!0,commit:r,diff:U(o),additions:n.reduce((s,i)=>s+(i.additions||0),0),deletions:n.reduce((s,i)=>s+(i.deletions||0),0),changedFiles:n.length,truncated:o.length>g}}function Pt(t){const e=t.replace(/^\s+|\s+$/g,"");if(!e)return null;const r=e.split(""),o=String(r[0]||"").trim();return o?{hash:o,shortHash:String(r[1]||o.slice(0,8)).trim(),authorName:String(r[2]||"").trim(),authorEmail:String(r[3]||"").trim(),authoredAt:String(r[4]||"").trim(),refs:String(r[5]||"").trim(),subject:String(r[6]||"").trim(),body:r.slice(7).join("").trim()}:null}function Et(t){if(t.length<4)return null;const e=t[0]||" ",r=t[1]||" ",o=S(t.slice(3));return o?{path:o,status:e==="?"&&r==="?"?"untracked":e==="U"||r==="U"?"conflicted":e==="D"||r==="D"?"deleted":e==="A"||r==="A"?"added":e==="R"||r==="R"?"renamed":"modified",indexStatus:e,worktreeStatus:r,staged:e!==" "&&e!=="?",additions:null,deletions:null}:null}function A(t){const e=new Map;for(const r of t.split("\0")){if(!r)continue;const o=H(r);if(!o||!o.path)continue;const n=S(o.path);n&&e.set(n,{additions:o.additions,deletions:o.deletions})}return e}function G(t,e){const r=W(t,e),n=B(t,["diff","--no-ext-diff","--no-index","--numstat","-z","--",process.platform==="win32"?"NUL":"/dev/null",r],32*1024).split("\0",1)[0]||"",s=H(n);return s?{additions:s.additions,deletions:s.deletions}:{additions:null,deletions:null}}function H(t){const e=t.indexOf(" "),r=e<0?-1:t.indexOf(" ",e+1);if(e<0||r<0)return null;const o=t.slice(0,e),n=t.slice(e+1,r);return{additions:/^\d+$/.test(o)?Number(o):null,deletions:/^\d+$/.test(n)?Number(n):null,path:t.slice(r+1)}}function w(t){try{return d(t,["rev-parse","--is-inside-work-tree"],8*1024).trim()==="true"}catch(e){if(String(e.code||"")==="ENOENT")throw new Error("设备未安装 Git。");return!1}}function bt(t,e){try{const r=d(t,["rev-list","--count",`${e}..HEAD`],8192).trim(),o=Number(r);return Number.isSafeInteger(o)&&o>0?o:0}catch{return 0}}function xt(t){try{return l.readdirSync(t).length>0}catch{return!1}}function jt(t,e){try{return d(t,["ls-files","--error-unmatch","--",e],8*1024),!0}catch{return!1}}function vt(t){try{return d(t,["rev-parse","--verify","HEAD"],8*1024),!0}catch{return!1}}function kt(t){try{return d(t,["symbolic-ref","--quiet","--short","HEAD"],8*1024).trim()||null}catch{try{return`HEAD (${d(t,["rev-parse","--short","HEAD"],8*1024).trim()})`}catch{return null}}}function At(t){try{const e=d(t,["rev-list","--left-right","--count","HEAD...@{upstream}"],8192).trim().split(/\s+/).map(Number);return{ahead:Number.isFinite(e[0])?e[0]:0,behind:Number.isFinite(e[1])?e[1]:0}}catch{return{ahead:0,behind:0}}}function W(t,e){const r=u.resolve(t,...e.split("/")),o=u.relative(t,r);if(o.startsWith("..")||u.isAbsolute(o))throw new Error("Diff 路径超出项目范围。");return r}function d(t,e,r){return y("git",["-C",t,...e],{encoding:"utf8",timeout:2e4,maxBuffer:r,stdio:["ignore","pipe","pipe"]})}function B(t,e,r){try{return d(t,e,r)}catch(o){const n=String(o.stdout||"");if(n)return n;if(Number(o.status)===1)return"";throw o}}function U(t){return t.length<=g?t:`${t.slice(0,g)}
|
|
1
|
+
import{activeTerminalService as Q}from"./terminal/service.js";import{execFileSync as y}from"node:child_process";import{randomUUID as T}from"node:crypto";import l from"node:fs";import F from"node:os";import u from"node:path";import{acaServerDownloadToFile as Z,acaServerRequest as E}from"./aca-server-client.js";import{loadAcaConfig as q,upsertLocalProject as tt}from"./aca-config.js";import{startLongPollWorker as et}from"./long-poll-worker.js";import{expandWorkerRuntimePath as rt}from"./worker-runtime-paths.js";import{syncCodexProviderRuntimeConfig as ot}from"./codex-provider-runtime-config.js";import{defaultAcpRuntimePool as nt}from"../acp/client/acp-runtime-pool.js";const I=25e3,it=I+1e4,b=300,st=3e4;let x=null;function ee(t){return et({run:async()=>{const e=q();if(!e.token)throw new Error("Worker 尚未配置认证令牌");const r=await E("GET",`/api/client/machine-operations/claim?machineId=${encodeURIComponent(e.machineId)}&waitMs=${I}`,void 0,{timeoutMs:it});if(r.item)try{const o=await ct(r.item);await E("POST",`/api/client/machine-operations/${encodeURIComponent(r.item.requestId)}/complete`,{result:o})}catch(o){const n=o instanceof Error?o.message:String(o);t.warn(`machine filesystem request failed request=${r.item.requestId}: ${n}`),await E("POST",`/api/client/machine-operations/${encodeURIComponent(r.item.requestId)}/fail`,{message:n}).catch(()=>{})}},onError:(e,r)=>t.warn(`machine filesystem worker failed, retry in ${r}ms: ${e instanceof Error?e.message:String(e)}`)})}async function ct(t){if(t.operation==="sync_codex_provider_config"){const e=await ot(),r=await nt.retireProviderRuntimes("codex-acp");return{configured:!!e,revision:e?.revision??null,retiredRuntimes:r}}if(t.operation==="filesystem_roots")return Rt();if(t.operation==="list_directory")return Ct({directoryPath:String(t.payload.path||""),includeHidden:t.payload.includeHidden===!0});if(t.operation==="register_project")return Lt(t.payload);if(t.operation==="list_project_directory")return ut(t.payload);if(t.operation==="upload_project_file")return dt(t.payload);if(t.operation==="mutate_project_files")return mt(t.payload);if(t.operation==="get_project_git_status")return G(t.payload);if(t.operation==="get_project_git_diff")return St(t.payload);if(t.operation==="get_project_git_log")return _t(t.payload);if(t.operation==="get_project_git_commit")return Pt(t.payload);if(t.operation==="get_worktree_status")return k(t.payload);if(t.operation==="commit_worktree")return at(t.payload);if(t.operation==="cleanup_worktree")return lt(t.payload);throw new Error("不支持的 Machine 文件系统操作。 ")}function k(t){const e=N(String(t.worktreePath||""));if(!l.existsSync(e))return{exists:!1,isRepository:!1,dirty:!1,changedFiles:0,ahead:0};const r=p(e);if(!w(r))return{exists:!0,isRepository:!1,dirty:jt(r),changedFiles:null,ahead:0};const o=G({rootPath:r}),n=String(t.baseCommit||"").trim(),s=n&&/^[0-9a-f]{7,64}$/i.test(n)?xt(r,n):0;return{exists:!0,isRepository:!0,dirty:Array.isArray(o.files)&&o.files.length>0,changedFiles:Array.isArray(o.files)?o.files.length:0,branch:o.branch,ahead:s,files:Array.isArray(o.files)?o.files.slice(0,50):[],truncated:o.truncated===!0}}function at(t){const e=p(String(t.worktreePath||"")),r=String(t.message||"").trim();if(!r)throw new Error("提交说明不能为空。");if(!w(e))throw new Error("当前 Worktree 不是 Git 仓库,无法提交。");y("git",["-C",e,"add","-A"],{stdio:"pipe",timeout:3e4});try{return y("git",["-C",e,"diff","--cached","--quiet"],{stdio:"pipe",timeout:1e4}),{committed:!1,reason:"no_changes",...k(t)}}catch(o){if(Number(o.status)!==1)throw o}return y("git",["-C",e,"commit","-m",r],{stdio:"pipe",timeout:6e4}),{committed:!0,commit:m(e,["rev-parse","HEAD"],8*1024).trim(),...k(t)}}function lt(t){const e=N(String(t.worktreePath||"")),r=p(String(t.projectRoot||""));if(h(e)===h(r))throw new Error("不能清理项目主目录。");if(!l.existsSync(e))return{removed:!1,reason:"not_found"};const o=p(e);if(Q?.hasRunningInDirectory(o,String(t.sessionId||"")))throw new Error("请先结束此目录中的会话终端,再清理 Worktree。");const n=String(t.branchName||"").trim(),s=w(o)&&w(r);if(s){if(y("git",["-C",r,"worktree","remove","--force",o],{stdio:"pipe",timeout:6e4}),t.deleteBranch===!0&&n)try{y("git",["-C",r,"branch","-D",n],{stdio:"pipe",timeout:3e4})}catch(i){const c=String(i.stderr||i);if(!/not found|not exist/i.test(c))throw i}}else l.rmSync(o,{recursive:!0,force:!0,maxRetries:2,retryDelay:200});return{removed:!0,branchDeleted:!!(s&&t.deleteBranch===!0&&n)}}function ut(t){const e=p(String(t.rootPath||"")),r=S(String(t.relativePath||"")),o=v(e,r,!0),n=Math.max(0,Number(t.offset||0)),s=Math.min(300,Math.max(20,Number(t.limit||200))),i=t.sort==="modified-desc"||t.sort==="modified-asc"?t.sort:"name",c=l.readdirSync(o,{withFileTypes:!0}).filter(a=>!a.isSymbolicLink()).map(a=>({name:a.name,path:X(e,u.join(o,a.name)),type:a.isDirectory()?"directory":a.isFile()?"file":"other",hidden:a.name.startsWith("."),extension:a.isFile()?u.extname(a.name).slice(1).toLowerCase():"",modifiedAt:i==="name"?void 0:ft(u.join(o,a.name))})).filter(a=>a.type!=="other").sort((a,d)=>{if(a.type!==d.type)return a.type==="directory"?-1:1;if(i!=="name"){if(a.modifiedAt==null&&d.modifiedAt!=null)return 1;if(d.modifiedAt==null&&a.modifiedAt!=null)return-1;const P=(a.modifiedAt??0)-(d.modifiedAt??0);if(P)return i==="modified-desc"?-P:P}return a.name.localeCompare(d.name,void 0,{numeric:!0,sensitivity:"base"})}),f=c.slice(n,n+s);return{path:r,rootKind:t.rootKind==="worktree"?"worktree":"project",items:f,total:c.length,nextOffset:n+f.length<c.length?n+f.length:null}}function ft(t){try{const e=l.lstatSync(t);return e.isSymbolicLink()?null:e.mtimeMs}catch{return null}}async function dt(t){const e=String(t.uploadId||"").trim();if(!e)throw new Error("项目上传任务缺少 uploadId。");const r=p(String(t.rootPath||"")),o=S(String(t.relativeDirectory||"")),n=v(r,o,!0),s=L(String(t.fileName||"")),i=Number(t.sizeBytes),c=String(t.sha256||"").trim().toLowerCase();if(!Number.isSafeInteger(i)||i<0)throw new Error("项目上传文件大小无效。");if(!/^[0-9a-f]{64}$/.test(c))throw new Error("项目上传文件摘要无效。");const f=u.join(n,`.aca-upload-${T()}.tmp`);try{const a=await Z(`/api/client/project-uploads/${encodeURIComponent(e)}`,f,{maxBytes:i,timeoutMs:3e5});if(a.sizeBytes!==i)throw new Error("项目上传文件大小校验失败。");if(a.sha256.toLowerCase()!==c)throw new Error("项目上传文件完整性校验失败。");const d=wt(r,o,s,f);return{name:u.basename(d),path:X(r,d),directory:o,size:a.sizeBytes,sha256:a.sha256,renamed:u.basename(d)!==s,rootKind:t.rootKind==="worktree"?"worktree":"project"}}finally{l.rmSync(f,{force:!0})}}function mt(t){const e=p(String(t.rootPath||"")),r=t.action&&typeof t.action=="object"?t.action:{};if(r.type==="delete")return pt(e,String(r.path||""),r.recursive===!0,t.rootKind);throw new Error("project_file_operation_unsupported")}function pt(t,e,r,o){const n=S(e);if(!n)throw new Error("project_file_root_protected");ht(n);const s=n.split("/"),i=s.slice(0,-1).join("/"),c=v(t,i,!0),f=u.join(c,s.at(-1)||"");let a;try{a=l.lstatSync(f)}catch(d){throw d.code==="ENOENT"?new Error("project_file_not_found"):d}if(a.isSymbolicLink())throw new Error("project_file_symbolic_link");if(!a.isFile()&&!a.isDirectory())throw new Error("project_file_type_unsupported");if(a.isDirectory()&&!r&&l.readdirSync(f).length>0)throw new Error("project_directory_not_empty");return a.isDirectory()&&r?l.rmSync(f,{recursive:!0,force:!1,maxRetries:2,retryDelay:150}):a.isDirectory()?l.rmdirSync(f):l.unlinkSync(f),{operation:"delete",path:n,entryType:a.isDirectory()?"directory":"file",parentPath:i,affectedDirectories:[i],rootKind:o==="worktree"?"worktree":"project"}}function ht(t){const e=t.split("/")[0].toLocaleLowerCase("en-US");if([".git",".aca",".aica"].includes(e))throw new Error("project_file_protected")}function wt(t,e,r,o){const n=p(t),s=S(e),i=v(n,s,!0),c=L(r);if(l.realpathSync.native(u.dirname(o))!==i)throw new Error("项目上传临时文件不在目标目录中。");const a=l.lstatSync(o);if(!a.isFile()||a.isSymbolicLink())throw new Error("项目上传临时文件无效。");for(let d=1;d<=1e4;d+=1){const P=d===1?c:yt(c,d),_=u.join(i,P);try{return l.linkSync(o,_),l.chmodSync(_,420),l.rmSync(o,{force:!0}),_}catch(A){if(M(A))continue;if(!gt(A))throw A;try{return l.copyFileSync(o,_,l.constants.COPYFILE_EXCL),l.chmodSync(_,420),l.rmSync(o,{force:!0}),_}catch($){if(M($))continue;throw $}}}throw new Error("同名文件过多,无法生成可用文件名。")}function L(t){const e=t.trim();if(!e||e==="."||e===".."||/[\\/\x00-\x1F]/.test(e))throw new Error("项目上传文件名无效。");if(process.platform==="win32"&&(/[<>:"|?*]/.test(e)||/[. ]$/.test(e)))throw new Error("项目上传文件名在 Windows 上无效。");return e.slice(0,180)}function yt(t,e){const r=u.extname(t);return`${r?t.slice(0,-r.length):t} (${e})${r}`}function M(t){return!!(t&&typeof t=="object"&&t.code==="EEXIST")}function gt(t){const e=t&&typeof t=="object"?t.code:"";return["EPERM","EACCES","EXDEV","ENOTSUP","EOPNOTSUPP"].includes(String(e||""))}const O=500,j=2*1024*1024,g=2*1024*1024;function G(t){const e=p(String(t.rootPath||""));if(!w(e))return{isRepository:!1,branch:null,files:[],ahead:0,behind:0};const o=m(e,["status","--porcelain=v1","-z","--untracked-files=all","--no-renames"],j).split("\0").filter(Boolean).slice(0,O),n=o.map(c=>bt(c)).filter(c=>!!c),s=D(m(e,["diff","--no-ext-diff","--numstat","-z","--no-renames","HEAD","--","."],j));for(const c of n){const f=s.get(c.path);if(f)c.additions=f.additions,c.deletions=f.deletions;else if(c.status==="untracked"){const a=H(e,c.path);c.additions=a.additions,c.deletions=a.deletions}}const i=Dt(e);return{isRepository:!0,branch:kt(e),files:n,ahead:i.ahead,behind:i.behind,truncated:o.length>=O}}function St(t){const e=p(String(t.rootPath||"")),r=S(String(t.relativePath||""));if(!r)throw new Error("Diff 文件路径不能为空。");if(!w(e))return{isRepository:!1,path:r,diff:"",additions:0,deletions:0};const o=B(e,r),n=vt(e,r),s=n?m(e,["diff","--no-ext-diff","--unified=80","HEAD","--",r],g):U(e,["diff","--no-ext-diff","--no-index","--unified=80",process.platform==="win32"?"NUL":"/dev/null",o],g),i=n?D(m(e,["diff","--no-ext-diff","--numstat","-z","--no-renames","HEAD","--",r],32*1024)).get(r):H(e,r);return{isRepository:!0,path:r,diff:z(s),additions:i?.additions??0,deletions:i?.deletions??0,truncated:s.length>g}}function _t(t){const e=p(String(t.rootPath||""));if(!w(e))return{isRepository:!1,items:[]};if(!At(e))return{isRepository:!0,items:[]};const r=Math.min(200,Math.max(20,Number(t.limit||100)));return{isRepository:!0,items:m(e,["log",`--max-count=${r}`,"--date=iso-strict","--pretty=format:%H%x1f%h%x1f%an%x1f%ae%x1f%aI%x1f%D%x1f%s%x1f%b%x1e"],j).split("").map(i=>Et(i)).filter(i=>!!i),limit:r}}function Pt(t){const e=p(String(t.rootPath||"")),r=String(t.commit||"").trim();if(!/^[0-9a-f]{7,64}$/i.test(r))throw new Error("Git 提交标识无效。");if(!w(e))return{isRepository:!1,commit:r,diff:"",additions:0,deletions:0};m(e,["cat-file","-e",`${r}^{commit}`],8*1024);const o=m(e,["show","--no-ext-diff","--no-color","--format=","--stat","--patch","--unified=40",r],g),n=[...D(m(e,["show","--no-ext-diff","--numstat","-z","--no-renames","--format=",r],j)).values()];return{isRepository:!0,commit:r,diff:z(o),additions:n.reduce((s,i)=>s+(i.additions||0),0),deletions:n.reduce((s,i)=>s+(i.deletions||0),0),changedFiles:n.length,truncated:o.length>g}}function Et(t){const e=t.replace(/^\s+|\s+$/g,"");if(!e)return null;const r=e.split(""),o=String(r[0]||"").trim();return o?{hash:o,shortHash:String(r[1]||o.slice(0,8)).trim(),authorName:String(r[2]||"").trim(),authorEmail:String(r[3]||"").trim(),authoredAt:String(r[4]||"").trim(),refs:String(r[5]||"").trim(),subject:String(r[6]||"").trim(),body:r.slice(7).join("").trim()}:null}function bt(t){if(t.length<4)return null;const e=t[0]||" ",r=t[1]||" ",o=S(t.slice(3));return o?{path:o,status:e==="?"&&r==="?"?"untracked":e==="U"||r==="U"?"conflicted":e==="D"||r==="D"?"deleted":e==="A"||r==="A"?"added":e==="R"||r==="R"?"renamed":"modified",indexStatus:e,worktreeStatus:r,staged:e!==" "&&e!=="?",additions:null,deletions:null}:null}function D(t){const e=new Map;for(const r of t.split("\0")){if(!r)continue;const o=W(r);if(!o||!o.path)continue;const n=S(o.path);n&&e.set(n,{additions:o.additions,deletions:o.deletions})}return e}function H(t,e){const r=B(t,e),n=U(t,["diff","--no-ext-diff","--no-index","--numstat","-z","--",process.platform==="win32"?"NUL":"/dev/null",r],32*1024).split("\0",1)[0]||"",s=W(n);return s?{additions:s.additions,deletions:s.deletions}:{additions:null,deletions:null}}function W(t){const e=t.indexOf(" "),r=e<0?-1:t.indexOf(" ",e+1);if(e<0||r<0)return null;const o=t.slice(0,e),n=t.slice(e+1,r);return{additions:/^\d+$/.test(o)?Number(o):null,deletions:/^\d+$/.test(n)?Number(n):null,path:t.slice(r+1)}}function w(t){try{return m(t,["rev-parse","--is-inside-work-tree"],8*1024).trim()==="true"}catch(e){if(String(e.code||"")==="ENOENT")throw new Error("设备未安装 Git。");return!1}}function xt(t,e){try{const r=m(t,["rev-list","--count",`${e}..HEAD`],8192).trim(),o=Number(r);return Number.isSafeInteger(o)&&o>0?o:0}catch{return 0}}function jt(t){try{return l.readdirSync(t).length>0}catch{return!1}}function vt(t,e){try{return m(t,["ls-files","--error-unmatch","--",e],8*1024),!0}catch{return!1}}function At(t){try{return m(t,["rev-parse","--verify","HEAD"],8*1024),!0}catch{return!1}}function kt(t){try{return m(t,["symbolic-ref","--quiet","--short","HEAD"],8*1024).trim()||null}catch{try{return`HEAD (${m(t,["rev-parse","--short","HEAD"],8*1024).trim()})`}catch{return null}}}function Dt(t){try{const e=m(t,["rev-list","--left-right","--count","HEAD...@{upstream}"],8192).trim().split(/\s+/).map(Number);return{ahead:Number.isFinite(e[0])?e[0]:0,behind:Number.isFinite(e[1])?e[1]:0}}catch{return{ahead:0,behind:0}}}function B(t,e){const r=u.resolve(t,...e.split("/")),o=u.relative(t,r);if(o.startsWith("..")||u.isAbsolute(o))throw new Error("Diff 路径超出项目范围。");return r}function m(t,e,r){return y("git",["-C",t,...e],{encoding:"utf8",timeout:2e4,maxBuffer:r,stdio:["ignore","pipe","pipe"]})}function U(t,e,r){try{return m(t,e,r)}catch(o){const n=String(o.stdout||"");if(n)return n;if(Number(o.status)===1)return"";throw o}}function z(t){return t.length<=g?t:`${t.slice(0,g)}
|
|
2
2
|
|
|
3
|
-
[Diff 内容过大,已截断]`}function
|
|
4
|
-
`),o=Y(
|
|
5
|
-
`),n=Y(
|
|
3
|
+
[Diff 内容过大,已截断]`}function Rt(){const t=process.platform,e=R(t);return{platform:t,roots:e}}function Ct(t){if(!t.directoryPath.trim())throw new Error("目录路径不能为空。");return process.platform==="win32"?Ft(t.directoryPath,!!t.includeHidden):Tt(t.directoryPath,!!t.includeHidden)}function h(t,e=process.platform){const r=e==="win32"?u.win32:u.posix,o=r.normalize(t),n=r.parse(o).root,s=o.length>n.length?o.replace(/[\\/]+$/,""):o;return e==="win32"?s.toLocaleLowerCase("en-US"):s}function Nt(){const t=l.realpathSync(F.homedir()),e=[{id:"home",label:"用户目录",path:t,kind:"home",available:!0}];return t!==u.parse(t).root&&e.push({id:"root",label:"文件系统",path:"/",kind:"root",available:!0}),e}function R(t){if(x?.platform===t&&x.expiresAtMs>Date.now())return x.roots;const e=t==="win32"?$t():Nt();return x={platform:t,roots:e,expiresAtMs:Date.now()+st},e}function $t(){const t=l.realpathSync.native(F.homedir()),e=new Map;e.set(h(t,"win32"),{id:"home",label:"用户目录",path:t,kind:"home",available:!0});try{const r=["$items = Get-CimInstance Win32_LogicalDisk | ForEach-Object {"," [PSCustomObject]@{ Name = $_.DeviceID; Root = ($_.DeviceID + '\\\\'); DriveType = $_.DriveType; VolumeName = $_.VolumeName }","}","@($items) | ConvertTo-Json -Compress"].join(`
|
|
4
|
+
`),o=J(Y(r));for(const n of o){const s=String(n.Root||"");if(!s)continue;const i=Number(n.DriveType||0),c=String(n.Name||s.replace(/[\\/]+$/,"")),f=String(n.VolumeName||"").trim();e.set(h(s,"win32"),{id:`drive-${c.replace(/[^a-z0-9]+/gi,"").toLowerCase()}`,label:f?`${f} (${c})`:Wt(c,i),path:s,kind:Ht(i),available:!0})}}catch{const r=u.win32.parse(t).root;e.set(h(r,"win32"),{id:"drive-system",label:`系统盘 (${r.replace(/\\$/,"")})`,path:r,kind:"fixed",available:!0})}return[...e.values()]}function Tt(t,e){const r=C(t),n=l.readdirSync(r,{withFileTypes:!0}).filter(i=>i.isDirectory()&&!i.isSymbolicLink()&&(e||!i.name.startsWith("."))),s=n.slice(0,b).map(i=>({name:i.name,path:u.join(r,i.name),kind:"directory",hidden:i.name.startsWith("."),hasChildren:!0}));return s.sort((i,c)=>i.name.localeCompare(c.name,void 0,{numeric:!0,sensitivity:"base"})),K(r,s,n.length>b,"linux")}function Ft(t,e){const r=C(t),o=["$items = Get-ChildItem -LiteralPath $env:ACA_MACHINE_FS_PATH -Directory -Force -ErrorAction Stop | ForEach-Object {"," [PSCustomObject]@{ Name = $_.Name; FullName = $_.FullName; Attributes = $_.Attributes.ToString() }","}","@($items) | ConvertTo-Json -Compress"].join(`
|
|
5
|
+
`),n=J(Y(o,{ACA_MACHINE_FS_PATH:r})),s=n.map(i=>{const c=String(i.Attributes||"");return{name:String(i.Name||""),path:String(i.FullName||""),kind:"directory",hidden:/Hidden|System/i.test(c),hasChildren:!0,reparsePoint:/ReparsePoint/i.test(c)}}).filter(i=>i.name&&i.path&&!i.reparsePoint&&(e||!i.hidden)).slice(0,b).sort((i,c)=>i.name.localeCompare(c.name,void 0,{numeric:!0,sensitivity:"base"}));return K(r,s,n.length>b,"win32")}function K(t,e,r,o){const n=o==="win32"?u.win32:u.posix,s=n.parse(t).root,i=h(t,o)===h(s,o)?null:n.dirname(t);return{platform:o,path:t,parentPath:i,breadcrumbs:It(t,o),readable:V(t,l.constants.R_OK),writable:V(t,l.constants.W_OK),items:e,truncated:r}}function It(t,e){const r=e==="win32"?u.win32:u.posix,o=r.parse(t),n=t.slice(o.root.length).split(/[\\/]+/).filter(Boolean),s=[{label:o.root.replace(/[\\/]+$/,"")||o.root,path:o.root}];let i=o.root;for(const c of n)i=r.join(i,c),s.push({label:c,path:i});return s}async function Lt(t){const e=String(t.workspaceId||"").trim(),r=String(t.name||"").trim(),o=t.projectType==="chat_room"?"chat_room":"project";if(!e||!r)throw new Error("项目名称和工作区不能为空。");const n=C(String(t.path||""));l.accessSync(n,l.constants.R_OK|l.constants.W_OK);const i=(await E("GET",`/api/projects?workspaceId=${encodeURIComponent(e)}`)).items.find(f=>h(f.root_path)===h(n)),c=i||(await E("POST","/api/projects",{projectId:T(),workspaceId:e,name:r,rootPath:n,source:"aica",projectType:o})).item;return tt(Mt(c)),{project:c,duplicate:!!i}}function Mt(t){return{projectId:t.project_id,workspaceId:t.workspace_id,name:t.name,rootPath:t.root_path}}function C(t){if(!t.trim()||!u.isAbsolute(t))throw new Error("必须选择绝对目录路径。");if(Ot(t),!l.statSync(t).isDirectory())throw new Error("选择的路径不是目录。");const r=l.realpathSync.native(t);return Gt(r),r}function p(t){const e=N(t),r=l.realpathSync.native(e);if(!l.statSync(r).isDirectory())throw new Error("项目根目录不存在。");return r}function N(t){const e=rt(t);if(!e||!u.isAbsolute(e))throw new Error("项目根目录无效。");return u.resolve(e)}function S(t){const e=t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");if(!e)return"";if(e.includes("\0")||e.split("/").some(r=>!r||r==="."||r===".."))throw new Error("项目相对路径无效。");return e}function v(t,e,r){const o=e?u.join(t,...e.split("/")):t,n=l.realpathSync.native(o),s=u.relative(t,n);if(s.startsWith("..")||u.isAbsolute(s))throw new Error("目录超出项目范围。");const i=l.statSync(n);if(r&&!i.isDirectory())throw new Error("请求路径不是目录。");return n}function X(t,e){return u.relative(t,e).split(u.sep).join("/")}function Ot(t){const e=process.platform==="win32"?u.win32:u.posix;if(!R(process.platform).some(o=>{const n=String(o.path||"");if(!n)return!1;const s=e.relative(n,t);return s===""||!s.startsWith("..")&&!e.isAbsolute(s)}))throw new Error("目录不在允许浏览的位置内。")}function Gt(t){const e=process.platform==="win32"?u.win32:u.posix;if(!R(process.platform).some(o=>{const n=String(o.path||"");if(!n)return!1;const s=e.relative(n,t);return s===""||!s.startsWith("..")&&!e.isAbsolute(s)}))throw new Error("目录不在允许浏览的位置内。")}function V(t,e){try{return l.accessSync(t,e),!0}catch{return!1}}function Y(t,e={}){return y("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command",t],{encoding:"utf8",windowsHide:!0,timeout:8e3,maxBuffer:4*1024*1024,env:{...process.env,...e}}).replace(/^\uFEFF/,"").trim()}function J(t){if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(r=>!!(r&&typeof r=="object")):e&&typeof e=="object"?[e]:[]}function Ht(t){return t===2?"removable":t===3?"fixed":t===4?"network":t===5?"optical":"drive"}function Wt(t,e){return e===2?`移动磁盘 (${t})`:e===4?`网络驱动器 (${t})`:e===5?`光驱 (${t})`:`本地磁盘 (${t})`}export{lt as cleanupWorktree,wt as commitProjectUploadTempFile,at as commitWorktree,h as comparableMachinePath,Pt as getProjectGitCommit,St as getProjectGitDiff,_t as getProjectGitLog,G as getProjectGitStatus,k as getWorktreeStatus,Ct as listMachineDirectory,Rt as listMachineFilesystemRoots,ut as listProjectDirectory,mt as mutateProjectFiles,ee as startMachineFilesystemWorkerLoop,dt as uploadProjectFile};
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.1.
|
|
1
|
+
const o="0.1.64";export{o as AICA_VERSION};
|