@xenosystem/agent-sdk 0.8.12 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts/index.cjs +1 -1
- package/dist/artifacts/index.js +1 -1
- package/dist/control-plane/index.cjs +1 -1
- package/dist/control-plane/index.js +1 -1
- package/dist/electron/index.cjs +140 -138
- package/dist/electron/index.d.cts +2 -0
- package/dist/electron/index.d.ts +2 -0
- package/dist/electron/index.js +139 -137
- package/dist/electron/metafile-cjs.json +1 -1
- package/dist/electron/metafile-esm.json +1 -1
- package/dist/index.cjs +322 -320
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +322 -320
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/session/index.cjs +1 -1
- package/dist/session/index.js +1 -1
- package/ownership/ownership-policy.json +59 -18
- package/package.json +209 -209
package/dist/session/index.cjs
CHANGED
|
@@ -46,7 +46,7 @@ ${this.stringify(t.data)}
|
|
|
46
46
|
`)+`
|
|
47
47
|
`;await f(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await f(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await f(c,u)}catch(u){this.workspaceMirrorDisabled=!0,E("Transcript workspace mirror disabled",u)}}}async truncateAfterMessageCount(t){let e=await m(this.transcriptPath);if(!e)return;let r=H(e),i=Math.max(0,t),s=0,o=[];for(let c of r){if(c.type==="user_message"||c.type==="assistant_message"){if(s>=i)break;s+=1}o.push(c)}let a=o.length>0?o.map(c=>JSON.stringify(c)).join(`
|
|
48
48
|
`)+`
|
|
49
|
-
`:"";await f(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await f(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await f(c,u)}catch(u){this.workspaceMirrorDisabled=!0,E("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let t=await m(this.transcriptPath);if(!t){this.sequence=0;return}let e=H(t);if(e.length===0){this.sequence=0;return}let r=e[e.length-1];this.sequence=r.sequence+1}catch(t){let e=t instanceof Error?t.message:String(t);E(`Transcript initialization warning: ${e}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};var W=y(require("path"),1),Nt=require("crypto"),Bt=require("fs/promises");var le={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit"};function nt(n){return le[n]??n}var A=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(t,e){this.sessionDir=t,this.checkpointsDir=W.join(t,"checkpoints"),this.autoInterval=e?.autoInterval??10}async initialize(){let t=await this.list();t.length>0&&(this.lastCheckpointMessageCount=t[0].messageCount)}async create(t){await B(this.checkpointsDir);let e=(0,Nt.randomUUID)(),r={id:e,name:t.description,trigger:t.trigger,createdAt:new Date().toISOString(),messageCount:t.messages.length,tokenCount:this.estimateTokens(t.messages)},i={info:r,messages:t.messages},s=W.join(this.checkpointsDir,`${e}.json`);return await f(s,JSON.stringify(i,null,2)),this.lastCheckpointMessageCount=t.messages.length,r}async list(){let t=await Ct(this.checkpointsDir,/\.json$/),e=[];for(let r of t){let i=await m(r);if(i){let s=k(i,null);if(s){let o=await(0,Bt.stat)(r);e.push({info:s.info,modifiedAtMs:o.mtimeMs})}}}return e.sort((r,i)=>new Date(i.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||i.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(t){let e=W.join(this.checkpointsDir,`${t}.json`),r;try{r=await m(e)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`Failed to read checkpoint ${t}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${t} (path: ${e})`);let i=k(r,null);if(!i)throw new Error(`Invalid checkpoint data for ${t}: JSON parse failed`);if(!i.messages||!Array.isArray(i.messages))throw new Error(`Invalid checkpoint data for ${t}: missing or invalid messages array`);if(!i.info)throw new Error(`Invalid checkpoint data for ${t}: missing info object`);return{messages:i.messages,info:i.info}}shouldAutoCheckpoint(t){return t-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(t,e){if(t=nt(t),t==="Write")return!0;if(t==="Bash"){let i=e.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>i.includes(o))}return!1}async delete(t){let e=W.join(this.checkpointsDir,`${t}.json`);await b(e)}estimateTokens(t){let e=0;for(let r of t)if(typeof r.content=="string")e+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let i of r.content)"text"in i&&(e+=Math.ceil(i.text.length/4));return e}};var R=y(require("path"),1),wt=y(require("os"),1),L=y(require("fs"),1);var ue=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),pe=globalThis,ft=pe[ue]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},ht=ft.cleanups;function de(){for(let n of ht)try{n()}catch{}}function Lt(n){return ht.add(n),!ft.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(ft.exitHandlerRegistered=!0,process.on("exit",de)),()=>{ht.delete(n)}}var jt="0.8.
|
|
49
|
+
`:"";await f(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await f(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await f(c,u)}catch(u){this.workspaceMirrorDisabled=!0,E("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let t=await m(this.transcriptPath);if(!t){this.sequence=0;return}let e=H(t);if(e.length===0){this.sequence=0;return}let r=e[e.length-1];this.sequence=r.sequence+1}catch(t){let e=t instanceof Error?t.message:String(t);E(`Transcript initialization warning: ${e}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};var W=y(require("path"),1),Nt=require("crypto"),Bt=require("fs/promises");var le={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit"};function nt(n){return le[n]??n}var A=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(t,e){this.sessionDir=t,this.checkpointsDir=W.join(t,"checkpoints"),this.autoInterval=e?.autoInterval??10}async initialize(){let t=await this.list();t.length>0&&(this.lastCheckpointMessageCount=t[0].messageCount)}async create(t){await B(this.checkpointsDir);let e=(0,Nt.randomUUID)(),r={id:e,name:t.description,trigger:t.trigger,createdAt:new Date().toISOString(),messageCount:t.messages.length,tokenCount:this.estimateTokens(t.messages)},i={info:r,messages:t.messages},s=W.join(this.checkpointsDir,`${e}.json`);return await f(s,JSON.stringify(i,null,2)),this.lastCheckpointMessageCount=t.messages.length,r}async list(){let t=await Ct(this.checkpointsDir,/\.json$/),e=[];for(let r of t){let i=await m(r);if(i){let s=k(i,null);if(s){let o=await(0,Bt.stat)(r);e.push({info:s.info,modifiedAtMs:o.mtimeMs})}}}return e.sort((r,i)=>new Date(i.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||i.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(t){let e=W.join(this.checkpointsDir,`${t}.json`),r;try{r=await m(e)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`Failed to read checkpoint ${t}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${t} (path: ${e})`);let i=k(r,null);if(!i)throw new Error(`Invalid checkpoint data for ${t}: JSON parse failed`);if(!i.messages||!Array.isArray(i.messages))throw new Error(`Invalid checkpoint data for ${t}: missing or invalid messages array`);if(!i.info)throw new Error(`Invalid checkpoint data for ${t}: missing info object`);return{messages:i.messages,info:i.info}}shouldAutoCheckpoint(t){return t-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(t,e){if(t=nt(t),t==="Write")return!0;if(t==="Bash"){let i=e.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>i.includes(o))}return!1}async delete(t){let e=W.join(this.checkpointsDir,`${t}.json`);await b(e)}estimateTokens(t){let e=0;for(let r of t)if(typeof r.content=="string")e+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let i of r.content)"text"in i&&(e+=Math.ceil(i.text.length/4));return e}};var R=y(require("path"),1),wt=y(require("os"),1),L=y(require("fs"),1);var ue=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),pe=globalThis,ft=pe[ue]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},ht=ft.cleanups;function de(){for(let n of ht)try{n()}catch{}}function Lt(n){return ht.add(n),!ft.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(ft.exitHandlerRegistered=!0,process.on("exit",de)),()=>{ht.delete(n)}}var jt="0.8.13";var ge=1e4,me=6e4,fe="session.lock",he="lock.json",U=new Set;function we(){for(let n of U)try{L.unlinkSync(n)}catch{}U.clear()}Lt(we);var _=class n{sessionDir;lockPath;legacyLockPath;sessionId;heartbeatTimer;constructor(t){this.sessionDir=t,this.lockPath=R.join(t,fe),this.legacyLockPath=R.join(t,he),this.sessionId=R.basename(t)}async acquire(){let t=new Date().toISOString(),e={schemaVersion:1,name:`session:${this.sessionId}`,sessionId:this.sessionId,pid:process.pid,hostname:wt.hostname(),processStartedAt:new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString(),version:jt,acquiredAt:t,updatedAt:t,heartbeat:t},r=R.dirname(this.lockPath);await L.promises.mkdir(r,{recursive:!0});let i=await this.findExistingLockPath();if(i){if(!await this.isStalePath(i)){let o=await this.readLockAt(i);throw new Error(`Session ${this.sessionId} is already locked by PID ${o?.pid} on ${o?.hostname}`)}await b(i)}try{await L.promises.writeFile(this.lockPath,JSON.stringify(e,null,2),{flag:"wx",encoding:"utf-8"}),U.add(this.lockPath)}catch(s){if(s.code==="EEXIST"){if(!await this.isStalePath(this.lockPath)){let l=await this.readLockAt(this.lockPath);throw new Error(`Session ${this.sessionId} is already locked by PID ${l?.pid} on ${l?.hostname}`)}await b(this.lockPath);try{await L.promises.writeFile(this.lockPath,JSON.stringify(e,null,2),{flag:"wx",encoding:"utf-8"})}catch(l){throw l.code==="EEXIST"?new Error(`Session ${this.sessionId} lock was acquired by another process during stale recovery`):l}U.add(this.lockPath)}else throw s}}async release(){this.stopHeartbeat(),U.delete(this.lockPath),await b(this.lockPath)}async isLocked(){let t=await this.findExistingLockPath();return t?!await this.isStalePath(t):!1}async isStale(){let t=await this.findExistingLockPath();return t?this.isStalePath(t):!1}async isStalePath(t){let e=await this.readLockAt(t);if(!e)return!1;let r=new Date(e.heartbeat).getTime();return Date.now()-r>me}startHeartbeat(t=ge){this.heartbeatTimer&&this.stopHeartbeat(),this.heartbeatTimer=setInterval(async()=>{try{await this.updateHeartbeat()}catch(e){let r=e instanceof Error?e.message:String(e);if(e?.code==="ENOENT"){I("SessionLock: Session directory removed, stopping heartbeat"),this.stopHeartbeat();return}I(`SessionLock: Failed to update heartbeat: ${r}`)}},t),this.heartbeatTimer.unref()}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}async updateHeartbeat(){let t=await this.readLockAt(this.lockPath);t&&(t.pid!==process.pid||t.hostname!==wt.hostname()||(t.heartbeat=new Date().toISOString(),t.updatedAt=t.heartbeat,await f(this.lockPath,JSON.stringify(t,null,2))))}async readLock(){let t=await this.findExistingLockPath();return t?this.readLockAt(t):null}async readLockAt(t){let e=await m(t);return e?k(e,null):null}async findExistingLockPath(){return await m(this.lockPath)?this.lockPath:await m(this.legacyLockPath)?this.legacyLockPath:null}static async cleanStale(t){let e=await Z(t),r=[];for(let i of e){let s=new n(i);if(await s.isStale()){let a=await s.findExistingLockPath();a&&await b(a),r.push(R.basename(i))}}return r}};var v=y(require("path"),1),Gt=y(require("os"),1);var P=y(require("path"),1);function ye(n,t){let e=P.resolve(n),r=P.resolve(n,t);return r===e?!0:e===P.parse(e).root?r.startsWith(e):r.startsWith(e+P.sep)}function O(n,t){if(P.isAbsolute(t))return P.resolve(t);if(!ye(n,t))throw new Error(`PathSecurity: Path traversal attempt detected: ${t}`);return P.resolve(n,t)}var $=y(require("path"),1),kt=y(require("os"),1);var yt=1,ke="recent.json";function j(n=kt.homedir()){return $.join(n,".xeno-agent",ke)}function J(n){let t=$.normalize(n).replace(/[\\/]+$/,""),e=t.length>0?t:$.parse($.normalize(n)).root;return process.platform==="win32"?e.toLowerCase():e}async function F(n=kt.homedir()){let t={version:yt,entries:{}},e=j(n);if(!Y(e))return t;let r=await m(e);if(!r)return t;let i=k(r,null);if(!i||typeof i!="object")return t;let s=i;if(s.version!==yt||!s.entries||typeof s.entries!="object")return t;let o={};for(let[a,l]of Object.entries(s.entries)){if(!l||typeof l!="object")continue;let c=l;typeof c.sessionId!="string"||c.sessionId.length===0||typeof c.endedAt=="string"&&(o[a]={sessionId:c.sessionId,endedAt:c.endedAt,role:typeof c.role=="string"?c.role:void 0})}return{version:yt,entries:o}}async function it(n,t={}){let e=await F(t.homeDir),r=J(n),i=e.entries[r];if(i&&!(t.role&&i.role&&i.role!==t.role))return i}async function st(n,t={}){let e=await F(t.homeDir),r=J(n.cwd);e.entries[r]={sessionId:n.sessionId,role:n.role,endedAt:n.endedAt??new Date().toISOString()};let i=j(t.homeDir);await f(i,JSON.stringify(e,null,2)+`
|
|
50
50
|
`)}async function Ft(n,t={}){let e=await F(t.homeDir),r=J(n);if(!(r in e.entries))return;delete e.entries[r];let i=j(t.homeDir);await f(i,JSON.stringify(e,null,2)+`
|
|
51
51
|
`)}async function q(n,t={}){let e=await F(t.homeDir),r=!1;for(let[s,o]of Object.entries(e.entries))o.sessionId===n&&(delete e.entries[s],r=!0);if(!r)return;let i=j(t.homeDir);await f(i,JSON.stringify(e,null,2)+`
|
|
52
52
|
`)}var N=class{static getSessionsDir(){let t=process.env.XENO_AGENT_HOME?.trim()||v.join(Gt.homedir(),".xeno-agent");return v.join(t,"sessions")}static async list(t){let e=this.getSessionsDir(),r=typeof t?.limit=="number"&&Number.isFinite(t.limit)?Math.max(0,Math.floor(t.limit)):void 0;if(r===0)return[];let i=t?.workingDirectory?this.normalizeWorkingDirectory(t.workingDirectory):void 0;if(!Y(e))return[];let s=await Z(e),o=[];for(let a of s){let l=await this.loadMeta(a);l&&(t?.status&&!t.status.includes(l.status)||t?.role&&l.role!==t.role||i&&this.normalizeWorkingDirectory(l.workingDirectory)!==i||o.push(l))}return o.sort((a,l)=>new Date(l.lastActivity).getTime()-new Date(a.lastActivity).getTime()),r!==void 0?o.slice(0,r):o}static async find(t){let e=this.getSessionsDir(),r=O(e,t);return await this.loadMeta(r)}static async findMostRecent(t){let e=typeof t=="string"?{role:t}:t??{};if(e.workingDirectory){let s=await it(e.workingDirectory,{...e.role!==void 0?{role:e.role}:{}});if(s){let o=await this.find(s.sessionId);if(o){if(!(e.role&&o.role!==e.role)){if(this.normalizeWorkingDirectory(o.workingDirectory)===this.normalizeWorkingDirectory(e.workingDirectory))return o}}else await q(s.sessionId)}}let i=(await this.list({...e.role!==void 0?{role:e.role}:{},...e.workingDirectory!==void 0?{workingDirectory:e.workingDirectory}:{},limit:1}))[0]??null;if(i&&e.workingDirectory)try{await st({cwd:i.workingDirectory,sessionId:i.id,role:i.role,endedAt:i.lastActivity})}catch{}return i}static async delete(t){let e=this.getSessionsDir(),r=O(e,t);await Mt(r),await q(t)}static async purgeWorkingDirectory(t,e){let r=new Set(e?.excludeSessionIds??[]),i=await this.list({workingDirectory:t}),s=[],o=[];for(let a of i){if(r.has(a.id)){o.push(a.id);continue}await this.delete(a.id),await this.deleteWorkspaceMirror(t,a.id),s.push(a.id)}return{deletedIds:s,skippedIds:o}}static async updateMeta(t,e){let r=this.getSessionsDir(),i=O(r,t),s=v.join(i,"meta.json"),o=await m(s);if(!o)throw new Error(`Session not found: ${t}`);let a=k(o,null);if(!a)throw new Error(`Invalid session metadata: ${t}`);let l={...a,...e,updatedAt:new Date().toISOString()};return await f(s,JSON.stringify(l,null,2)),l}static async loadMeta(t){let e=v.join(t,"meta.json"),r=await m(e);if(!r)return null;let i=k(r,null);if(!i)return null;let s=i.formatVersion;return{...i,formatVersion:typeof s=="number"&&Number.isFinite(s)&&s>0?s:1}}static getSessionDir(t){return O(this.getSessionsDir(),t)}static normalizeWorkingDirectory(t){let e=v.normalize(t).replace(/[\\/]+$/,""),r=e.length>0?e:v.parse(v.normalize(t)).root;return process.platform==="win32"?r.toLowerCase():r}static async deleteWorkspaceMirror(t,e){let r=v.join(t,".xeno","sessions",`${e}.md`);await b(r)}};var at=y(require("path"),1);var ct=class n{sessionDir;_meta;_transcript;_checkpoints;_lock;constructor(t,e,r,i,s){this.sessionDir=t,this._meta=e,this._transcript=r,this._checkpoints=i,this._lock=s}static async create(t){let e=t.role??"default",r=Q(e),i=N.getSessionDir(r),s=null,o=null;try{await B(i);let a={id:r,role:e,status:"creating",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),lastActivity:new Date().toISOString(),workingDirectory:t.workingDirectory,model:t.model,parentSession:t.parentSession,checkpoints:[],messageCount:0,tokenUsage:{input:0,output:0,total:0},formatVersion:1},l=at.join(i,"meta.json");await f(l,JSON.stringify(a,null,2)),o=new M(i);let c=new A(i);s=new _(i),await s.acquire(),s.startHeartbeat(),await o.append({type:"session_start",data:{sessionId:r,role:e,workingDirectory:t.workingDirectory,model:t.model,formatVersion:1}});let u=new n(i,a,o,c,s);return await u.updateMeta({status:"active"}),u}catch(a){if(s)try{s.stopHeartbeat(),await s.release()}catch(l){I("Error releasing lock during cleanup",l)}throw a}}static async resume(t){let e=N.getSessionDir(t.sessionId),r=null,i=null;try{let s=at.join(e,"meta.json"),o=await m(s);if(!o)throw new Error(`SessionManager: Session not found: ${t.sessionId}`);let a=k(o,null);if(!a)throw new Error(`SessionManager: Invalid session metadata: ${t.sessionId}`);a.formatVersion=St(a),i=new M(e),await i.initialize();let l=new A(e);if(r=new _(e),await r.acquire(),r.startHeartbeat(),t.fromCheckpoint){let{info:u}=await l.restore(t.fromCheckpoint);a.messageCount=u.messageCount,await i.append({type:"checkpoint",data:{id:t.fromCheckpoint,trigger:"manual",messageCount:u.messageCount}})}let c=new n(e,a,i,l,r);return await c.updateMeta({status:"active",lastActivity:new Date().toISOString()}),c}catch(s){if(r)try{r.stopHeartbeat(),await r.release()}catch(o){I("Error releasing lock during cleanup",o)}throw s}}get meta(){return{...this._meta}}get transcript(){return this._transcript}get checkpoints(){return this._checkpoints}async updateMeta(t){this._meta={...this._meta,...t,updatedAt:new Date().toISOString()};let e=at.join(this.sessionDir,"meta.json"),r=3,i=null;for(let s=0;s<r;s++)try{await f(e,JSON.stringify(this._meta,null,2));return}catch(o){i=o instanceof Error?o:new Error(String(o)),E(`Failed to write session metadata (attempt ${s+1}/${r}): ${i.message}`),s<r-1&&await new Promise(a=>setTimeout(a,Math.pow(2,s)*100))}I(`Failed to write session metadata after ${r} attempts. Session will continue but metadata may be stale.`)}async end(t="completed"){await this._transcript.append({type:"session_end",data:{reason:t==="completed"?"completed":"user_exit",messageCount:this._meta.messageCount,totalTokens:this._meta.tokenUsage.total}}),await this._transcript.flush(),await this.updateMeta({status:t}),this._lock.stopHeartbeat(),await this._lock.release()}async recordUserMessage(t){await this._transcript.append({type:"user_message",data:{role:"user",content:t}}),await this.updateMeta({messageCount:this._meta.messageCount+1,lastActivity:new Date().toISOString()})}async recordDirectShellResult(t){let e=et(t);return await this._transcript.append({type:"user_message",data:e}),await this.updateMeta({messageCount:this._meta.messageCount+1,lastActivity:new Date().toISOString()}),e}async recordAssistantMessage(t,e){await this._transcript.append({type:"assistant_message",data:{role:"assistant",content:t},tokenCount:e}),await this.updateMeta({messageCount:this._meta.messageCount+1,lastActivity:new Date().toISOString()})}async recordTokenUsage(t,e){let r={input:this._meta.tokenUsage.input+t,output:this._meta.tokenUsage.output+e,total:this._meta.tokenUsage.total+t+e};await this.updateMeta({tokenUsage:r})}async recordDelegationSummary(t){await this._transcript.append({type:"delegation_summary",data:t}),await this.updateMeta({lastActivity:new Date().toISOString()})}async updateMessageCount(t){t!==this._meta.messageCount&&await this.updateMeta({messageCount:t,lastActivity:new Date().toISOString()})}};function St(n){let t=n?.formatVersion;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}var z=require("node:crypto"),Qt=require("node:child_process"),p=require("node:fs/promises"),Yt=require("node:os"),d=y(require("node:path"),1);var xt=2,Ht=400,Pt=80,Tt=12,Wt=3e4,vt=64*1024*1024;function Ut(n){let t=n.replace(/\r\n/g,`
|
package/dist/session/index.js
CHANGED
|
@@ -46,7 +46,7 @@ ${this.stringify(t.data)}
|
|
|
46
46
|
`)+`
|
|
47
47
|
`;await m(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await m(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await m(c,u)}catch(u){this.workspaceMirrorDisabled=!0,T("Transcript workspace mirror disabled",u)}}}async truncateAfterMessageCount(t){let e=await g(this.transcriptPath);if(!e)return;let r=L(e),n=Math.max(0,t),s=0,o=[];for(let c of r){if(c.type==="user_message"||c.type==="assistant_message"){if(s>=n)break;s+=1}o.push(c)}let a=o.length>0?o.map(c=>JSON.stringify(c)).join(`
|
|
48
48
|
`)+`
|
|
49
|
-
`:"";await m(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await m(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await m(c,u)}catch(u){this.workspaceMirrorDisabled=!0,T("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let t=await g(this.transcriptPath);if(!t){this.sequence=0;return}let e=L(t);if(e.length===0){this.sequence=0;return}let r=e[e.length-1];this.sequence=r.sequence+1}catch(t){let e=t instanceof Error?t.message:String(t);T(`Transcript initialization warning: ${e}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};import*as j from"path";import{randomUUID as ee}from"crypto";import{stat as re}from"fs/promises";var te={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit"};function K(i){return te[i]??i}var _=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(t,e){this.sessionDir=t,this.checkpointsDir=j.join(t,"checkpoints"),this.autoInterval=e?.autoInterval??10}async initialize(){let t=await this.list();t.length>0&&(this.lastCheckpointMessageCount=t[0].messageCount)}async create(t){await M(this.checkpointsDir);let e=ee(),r={id:e,name:t.description,trigger:t.trigger,createdAt:new Date().toISOString(),messageCount:t.messages.length,tokenCount:this.estimateTokens(t.messages)},n={info:r,messages:t.messages},s=j.join(this.checkpointsDir,`${e}.json`);return await m(s,JSON.stringify(n,null,2)),this.lastCheckpointMessageCount=t.messages.length,r}async list(){let t=await Tt(this.checkpointsDir,/\.json$/),e=[];for(let r of t){let n=await g(r);if(n){let s=w(n,null);if(s){let o=await re(r);e.push({info:s.info,modifiedAtMs:o.mtimeMs})}}}return e.sort((r,n)=>new Date(n.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||n.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(t){let e=j.join(this.checkpointsDir,`${t}.json`),r;try{r=await g(e)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`Failed to read checkpoint ${t}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${t} (path: ${e})`);let n=w(r,null);if(!n)throw new Error(`Invalid checkpoint data for ${t}: JSON parse failed`);if(!n.messages||!Array.isArray(n.messages))throw new Error(`Invalid checkpoint data for ${t}: missing or invalid messages array`);if(!n.info)throw new Error(`Invalid checkpoint data for ${t}: missing info object`);return{messages:n.messages,info:n.info}}shouldAutoCheckpoint(t){return t-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(t,e){if(t=K(t),t==="Write")return!0;if(t==="Bash"){let n=e.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>n.includes(o))}return!1}async delete(t){let e=j.join(this.checkpointsDir,`${t}.json`);await v(e)}estimateTokens(t){let e=0;for(let r of t)if(typeof r.content=="string")e+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let n of r.content)"text"in n&&(e+=Math.ceil(n.text.length/4));return e}};import*as b from"path";import*as lt from"os";import*as O from"fs";var ne=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),ie=globalThis,at=ie[ne]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},ct=at.cleanups;function se(){for(let i of ct)try{i()}catch{}}function Mt(i){return ct.add(i),!at.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(at.exitHandlerRegistered=!0,process.on("exit",se)),()=>{ct.delete(i)}}var At="0.8.
|
|
49
|
+
`:"";await m(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await m(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await m(c,u)}catch(u){this.workspaceMirrorDisabled=!0,T("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let t=await g(this.transcriptPath);if(!t){this.sequence=0;return}let e=L(t);if(e.length===0){this.sequence=0;return}let r=e[e.length-1];this.sequence=r.sequence+1}catch(t){let e=t instanceof Error?t.message:String(t);T(`Transcript initialization warning: ${e}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};import*as j from"path";import{randomUUID as ee}from"crypto";import{stat as re}from"fs/promises";var te={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit"};function K(i){return te[i]??i}var _=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(t,e){this.sessionDir=t,this.checkpointsDir=j.join(t,"checkpoints"),this.autoInterval=e?.autoInterval??10}async initialize(){let t=await this.list();t.length>0&&(this.lastCheckpointMessageCount=t[0].messageCount)}async create(t){await M(this.checkpointsDir);let e=ee(),r={id:e,name:t.description,trigger:t.trigger,createdAt:new Date().toISOString(),messageCount:t.messages.length,tokenCount:this.estimateTokens(t.messages)},n={info:r,messages:t.messages},s=j.join(this.checkpointsDir,`${e}.json`);return await m(s,JSON.stringify(n,null,2)),this.lastCheckpointMessageCount=t.messages.length,r}async list(){let t=await Tt(this.checkpointsDir,/\.json$/),e=[];for(let r of t){let n=await g(r);if(n){let s=w(n,null);if(s){let o=await re(r);e.push({info:s.info,modifiedAtMs:o.mtimeMs})}}}return e.sort((r,n)=>new Date(n.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||n.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(t){let e=j.join(this.checkpointsDir,`${t}.json`),r;try{r=await g(e)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`Failed to read checkpoint ${t}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${t} (path: ${e})`);let n=w(r,null);if(!n)throw new Error(`Invalid checkpoint data for ${t}: JSON parse failed`);if(!n.messages||!Array.isArray(n.messages))throw new Error(`Invalid checkpoint data for ${t}: missing or invalid messages array`);if(!n.info)throw new Error(`Invalid checkpoint data for ${t}: missing info object`);return{messages:n.messages,info:n.info}}shouldAutoCheckpoint(t){return t-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(t,e){if(t=K(t),t==="Write")return!0;if(t==="Bash"){let n=e.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>n.includes(o))}return!1}async delete(t){let e=j.join(this.checkpointsDir,`${t}.json`);await v(e)}estimateTokens(t){let e=0;for(let r of t)if(typeof r.content=="string")e+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let n of r.content)"text"in n&&(e+=Math.ceil(n.text.length/4));return e}};import*as b from"path";import*as lt from"os";import*as O from"fs";var ne=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),ie=globalThis,at=ie[ne]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},ct=at.cleanups;function se(){for(let i of ct)try{i()}catch{}}function Mt(i){return ct.add(i),!at.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(at.exitHandlerRegistered=!0,process.on("exit",se)),()=>{ct.delete(i)}}var At="0.8.13";var oe=1e4,ae=6e4,ce="session.lock",le="lock.json",F=new Set;function ue(){for(let i of F)try{O.unlinkSync(i)}catch{}F.clear()}Mt(ue);var $=class i{sessionDir;lockPath;legacyLockPath;sessionId;heartbeatTimer;constructor(t){this.sessionDir=t,this.lockPath=b.join(t,ce),this.legacyLockPath=b.join(t,le),this.sessionId=b.basename(t)}async acquire(){let t=new Date().toISOString(),e={schemaVersion:1,name:`session:${this.sessionId}`,sessionId:this.sessionId,pid:process.pid,hostname:lt.hostname(),processStartedAt:new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString(),version:At,acquiredAt:t,updatedAt:t,heartbeat:t},r=b.dirname(this.lockPath);await O.promises.mkdir(r,{recursive:!0});let n=await this.findExistingLockPath();if(n){if(!await this.isStalePath(n)){let o=await this.readLockAt(n);throw new Error(`Session ${this.sessionId} is already locked by PID ${o?.pid} on ${o?.hostname}`)}await v(n)}try{await O.promises.writeFile(this.lockPath,JSON.stringify(e,null,2),{flag:"wx",encoding:"utf-8"}),F.add(this.lockPath)}catch(s){if(s.code==="EEXIST"){if(!await this.isStalePath(this.lockPath)){let l=await this.readLockAt(this.lockPath);throw new Error(`Session ${this.sessionId} is already locked by PID ${l?.pid} on ${l?.hostname}`)}await v(this.lockPath);try{await O.promises.writeFile(this.lockPath,JSON.stringify(e,null,2),{flag:"wx",encoding:"utf-8"})}catch(l){throw l.code==="EEXIST"?new Error(`Session ${this.sessionId} lock was acquired by another process during stale recovery`):l}F.add(this.lockPath)}else throw s}}async release(){this.stopHeartbeat(),F.delete(this.lockPath),await v(this.lockPath)}async isLocked(){let t=await this.findExistingLockPath();return t?!await this.isStalePath(t):!1}async isStale(){let t=await this.findExistingLockPath();return t?this.isStalePath(t):!1}async isStalePath(t){let e=await this.readLockAt(t);if(!e)return!1;let r=new Date(e.heartbeat).getTime();return Date.now()-r>ae}startHeartbeat(t=oe){this.heartbeatTimer&&this.stopHeartbeat(),this.heartbeatTimer=setInterval(async()=>{try{await this.updateHeartbeat()}catch(e){let r=e instanceof Error?e.message:String(e);if(e?.code==="ENOENT"){R("SessionLock: Session directory removed, stopping heartbeat"),this.stopHeartbeat();return}R(`SessionLock: Failed to update heartbeat: ${r}`)}},t),this.heartbeatTimer.unref()}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}async updateHeartbeat(){let t=await this.readLockAt(this.lockPath);t&&(t.pid!==process.pid||t.hostname!==lt.hostname()||(t.heartbeat=new Date().toISOString(),t.updatedAt=t.heartbeat,await m(this.lockPath,JSON.stringify(t,null,2))))}async readLock(){let t=await this.findExistingLockPath();return t?this.readLockAt(t):null}async readLockAt(t){let e=await g(t);return e?w(e,null):null}async findExistingLockPath(){return await g(this.lockPath)?this.lockPath:await g(this.legacyLockPath)?this.legacyLockPath:null}static async cleanStale(t){let e=await V(t),r=[];for(let n of e){let s=new i(n);if(await s.isStale()){let a=await s.findExistingLockPath();a&&await v(a),r.push(b.basename(n))}}return r}};import*as x from"path";import*as _t from"os";import*as S from"path";function pe(i,t){let e=S.resolve(i),r=S.resolve(i,t);return r===e?!0:e===S.parse(e).root?r.startsWith(e):r.startsWith(e+S.sep)}function I(i,t){if(S.isAbsolute(t))return S.resolve(t);if(!pe(i,t))throw new Error(`PathSecurity: Path traversal attempt detected: ${t}`);return S.resolve(i,t)}import*as C from"path";import*as pt from"os";var ut=1,de="recent.json";function G(i=pt.homedir()){return C.join(i,".xeno-agent",de)}function Q(i){let t=C.normalize(i).replace(/[\\/]+$/,""),e=t.length>0?t:C.parse(C.normalize(i)).root;return process.platform==="win32"?e.toLowerCase():e}async function H(i=pt.homedir()){let t={version:ut,entries:{}},e=G(i);if(!z(e))return t;let r=await g(e);if(!r)return t;let n=w(r,null);if(!n||typeof n!="object")return t;let s=n;if(s.version!==ut||!s.entries||typeof s.entries!="object")return t;let o={};for(let[a,l]of Object.entries(s.entries)){if(!l||typeof l!="object")continue;let c=l;typeof c.sessionId!="string"||c.sessionId.length===0||typeof c.endedAt=="string"&&(o[a]={sessionId:c.sessionId,endedAt:c.endedAt,role:typeof c.role=="string"?c.role:void 0})}return{version:ut,entries:o}}async function dt(i,t={}){let e=await H(t.homeDir),r=Q(i),n=e.entries[r];if(n&&!(t.role&&n.role&&n.role!==t.role))return n}async function gt(i,t={}){let e=await H(t.homeDir),r=Q(i.cwd);e.entries[r]={sessionId:i.sessionId,role:i.role,endedAt:i.endedAt??new Date().toISOString()};let n=G(t.homeDir);await m(n,JSON.stringify(e,null,2)+`
|
|
50
50
|
`)}async function ge(i,t={}){let e=await H(t.homeDir),r=Q(i);if(!(r in e.entries))return;delete e.entries[r];let n=G(t.homeDir);await m(n,JSON.stringify(e,null,2)+`
|
|
51
51
|
`)}async function Y(i,t={}){let e=await H(t.homeDir),r=!1;for(let[s,o]of Object.entries(e.entries))o.sessionId===i&&(delete e.entries[s],r=!0);if(!r)return;let n=G(t.homeDir);await m(n,JSON.stringify(e,null,2)+`
|
|
52
52
|
`)}var N=class{static getSessionsDir(){let t=process.env.XENO_AGENT_HOME?.trim()||x.join(_t.homedir(),".xeno-agent");return x.join(t,"sessions")}static async list(t){let e=this.getSessionsDir(),r=typeof t?.limit=="number"&&Number.isFinite(t.limit)?Math.max(0,Math.floor(t.limit)):void 0;if(r===0)return[];let n=t?.workingDirectory?this.normalizeWorkingDirectory(t.workingDirectory):void 0;if(!z(e))return[];let s=await V(e),o=[];for(let a of s){let l=await this.loadMeta(a);l&&(t?.status&&!t.status.includes(l.status)||t?.role&&l.role!==t.role||n&&this.normalizeWorkingDirectory(l.workingDirectory)!==n||o.push(l))}return o.sort((a,l)=>new Date(l.lastActivity).getTime()-new Date(a.lastActivity).getTime()),r!==void 0?o.slice(0,r):o}static async find(t){let e=this.getSessionsDir(),r=I(e,t);return await this.loadMeta(r)}static async findMostRecent(t){let e=typeof t=="string"?{role:t}:t??{};if(e.workingDirectory){let s=await dt(e.workingDirectory,{...e.role!==void 0?{role:e.role}:{}});if(s){let o=await this.find(s.sessionId);if(o){if(!(e.role&&o.role!==e.role)){if(this.normalizeWorkingDirectory(o.workingDirectory)===this.normalizeWorkingDirectory(e.workingDirectory))return o}}else await Y(s.sessionId)}}let n=(await this.list({...e.role!==void 0?{role:e.role}:{},...e.workingDirectory!==void 0?{workingDirectory:e.workingDirectory}:{},limit:1}))[0]??null;if(n&&e.workingDirectory)try{await gt({cwd:n.workingDirectory,sessionId:n.id,role:n.role,endedAt:n.lastActivity})}catch{}return n}static async delete(t){let e=this.getSessionsDir(),r=I(e,t);await bt(r),await Y(t)}static async purgeWorkingDirectory(t,e){let r=new Set(e?.excludeSessionIds??[]),n=await this.list({workingDirectory:t}),s=[],o=[];for(let a of n){if(r.has(a.id)){o.push(a.id);continue}await this.delete(a.id),await this.deleteWorkspaceMirror(t,a.id),s.push(a.id)}return{deletedIds:s,skippedIds:o}}static async updateMeta(t,e){let r=this.getSessionsDir(),n=I(r,t),s=x.join(n,"meta.json"),o=await g(s);if(!o)throw new Error(`Session not found: ${t}`);let a=w(o,null);if(!a)throw new Error(`Invalid session metadata: ${t}`);let l={...a,...e,updatedAt:new Date().toISOString()};return await m(s,JSON.stringify(l,null,2)),l}static async loadMeta(t){let e=x.join(t,"meta.json"),r=await g(e);if(!r)return null;let n=w(r,null);if(!n)return null;let s=n.formatVersion;return{...n,formatVersion:typeof s=="number"&&Number.isFinite(s)&&s>0?s:1}}static getSessionDir(t){return I(this.getSessionsDir(),t)}static normalizeWorkingDirectory(t){let e=x.normalize(t).replace(/[\\/]+$/,""),r=e.length>0?e:x.parse(x.normalize(t)).root;return process.platform==="win32"?r.toLowerCase():r}static async deleteWorkspaceMirror(t,e){let r=x.join(t,".xeno","sessions",`${e}.md`);await v(r)}};import*as tt from"path";var mt=class i{sessionDir;_meta;_transcript;_checkpoints;_lock;constructor(t,e,r,n,s){this.sessionDir=t,this._meta=e,this._transcript=r,this._checkpoints=n,this._lock=s}static async create(t){let e=t.role??"default",r=it(e),n=N.getSessionDir(r),s=null,o=null;try{await M(n);let a={id:r,role:e,status:"creating",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),lastActivity:new Date().toISOString(),workingDirectory:t.workingDirectory,model:t.model,parentSession:t.parentSession,checkpoints:[],messageCount:0,tokenUsage:{input:0,output:0,total:0},formatVersion:1},l=tt.join(n,"meta.json");await m(l,JSON.stringify(a,null,2)),o=new A(n);let c=new _(n);s=new $(n),await s.acquire(),s.startHeartbeat(),await o.append({type:"session_start",data:{sessionId:r,role:e,workingDirectory:t.workingDirectory,model:t.model,formatVersion:1}});let u=new i(n,a,o,c,s);return await u.updateMeta({status:"active"}),u}catch(a){if(s)try{s.stopHeartbeat(),await s.release()}catch(l){R("Error releasing lock during cleanup",l)}throw a}}static async resume(t){let e=N.getSessionDir(t.sessionId),r=null,n=null;try{let s=tt.join(e,"meta.json"),o=await g(s);if(!o)throw new Error(`SessionManager: Session not found: ${t.sessionId}`);let a=w(o,null);if(!a)throw new Error(`SessionManager: Invalid session metadata: ${t.sessionId}`);a.formatVersion=Ot(a),n=new A(e),await n.initialize();let l=new _(e);if(r=new $(e),await r.acquire(),r.startHeartbeat(),t.fromCheckpoint){let{info:u}=await l.restore(t.fromCheckpoint);a.messageCount=u.messageCount,await n.append({type:"checkpoint",data:{id:t.fromCheckpoint,trigger:"manual",messageCount:u.messageCount}})}let c=new i(e,a,n,l,r);return await c.updateMeta({status:"active",lastActivity:new Date().toISOString()}),c}catch(s){if(r)try{r.stopHeartbeat(),await r.release()}catch(o){R("Error releasing lock during cleanup",o)}throw s}}get meta(){return{...this._meta}}get transcript(){return this._transcript}get checkpoints(){return this._checkpoints}async updateMeta(t){this._meta={...this._meta,...t,updatedAt:new Date().toISOString()};let e=tt.join(this.sessionDir,"meta.json"),r=3,n=null;for(let s=0;s<r;s++)try{await m(e,JSON.stringify(this._meta,null,2));return}catch(o){n=o instanceof Error?o:new Error(String(o)),T(`Failed to write session metadata (attempt ${s+1}/${r}): ${n.message}`),s<r-1&&await new Promise(a=>setTimeout(a,Math.pow(2,s)*100))}R(`Failed to write session metadata after ${r} attempts. Session will continue but metadata may be stale.`)}async end(t="completed"){await this._transcript.append({type:"session_end",data:{reason:t==="completed"?"completed":"user_exit",messageCount:this._meta.messageCount,totalTokens:this._meta.tokenUsage.total}}),await this._transcript.flush(),await this.updateMeta({status:t}),this._lock.stopHeartbeat(),await this._lock.release()}async recordUserMessage(t){await this._transcript.append({type:"user_message",data:{role:"user",content:t}}),await this.updateMeta({messageCount:this._meta.messageCount+1,lastActivity:new Date().toISOString()})}async recordDirectShellResult(t){let e=st(t);return await this._transcript.append({type:"user_message",data:e}),await this.updateMeta({messageCount:this._meta.messageCount+1,lastActivity:new Date().toISOString()}),e}async recordAssistantMessage(t,e){await this._transcript.append({type:"assistant_message",data:{role:"assistant",content:t},tokenCount:e}),await this.updateMeta({messageCount:this._meta.messageCount+1,lastActivity:new Date().toISOString()})}async recordTokenUsage(t,e){let r={input:this._meta.tokenUsage.input+t,output:this._meta.tokenUsage.output+e,total:this._meta.tokenUsage.total+t+e};await this.updateMeta({tokenUsage:r})}async recordDelegationSummary(t){await this._transcript.append({type:"delegation_summary",data:t}),await this.updateMeta({lastActivity:new Date().toISOString()})}async updateMessageCount(t){t!==this._meta.messageCount&&await this.updateMeta({messageCount:t,lastActivity:new Date().toISOString()})}};function Ot(i){let t=i?.formatVersion;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}import{randomUUID as rt}from"node:crypto";import{spawn as me}from"node:child_process";import{mkdir as U,readFile as W,readdir as $t,realpath as nt,rm as et,stat as fe,unlink as Nt,writeFile as ft}from"node:fs/promises";import{tmpdir as he}from"node:os";import p from"node:path";var ht=2,Bt=400,wt=80,kt=12,Lt=3e4,yt=64*1024*1024;function jt(i){let t=i.replace(/\r\n/g,`
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"targetLevel": "P2",
|
|
11
11
|
"enforcedLevel": "pre-P1",
|
|
12
12
|
"xenoPackagePrefixes": [
|
|
13
|
-
"@xeno-corporation/"
|
|
13
|
+
"@xeno-corporation/",
|
|
14
|
+
"@xenosystem/"
|
|
14
15
|
],
|
|
15
16
|
"repositories": {
|
|
16
17
|
"sdk": {
|
|
@@ -44,7 +45,10 @@
|
|
|
44
45
|
"name": "chalk",
|
|
45
46
|
"classification": "temporary-runtime",
|
|
46
47
|
"license": "MIT",
|
|
47
|
-
"usedBy": [
|
|
48
|
+
"usedBy": [
|
|
49
|
+
"sdk",
|
|
50
|
+
"cli"
|
|
51
|
+
],
|
|
48
52
|
"replacement": "xeno-ansi",
|
|
49
53
|
"expiresAtMilestone": "PROPRIETARY-ANSI-1",
|
|
50
54
|
"allowedThrough": "pre-P1"
|
|
@@ -53,16 +57,23 @@
|
|
|
53
57
|
"name": "microsoft-mxc-native-assets",
|
|
54
58
|
"classification": "external-runtime",
|
|
55
59
|
"license": "MIT",
|
|
56
|
-
"usedBy": [
|
|
60
|
+
"usedBy": [
|
|
61
|
+
"sdk",
|
|
62
|
+
"cli"
|
|
63
|
+
],
|
|
57
64
|
"replacement": "release-certified-platform-containment-adapter",
|
|
58
65
|
"expiresAtMilestone": "never",
|
|
59
|
-
"artifactPathPrefixes": [
|
|
66
|
+
"artifactPathPrefixes": [
|
|
67
|
+
"native/mxc/"
|
|
68
|
+
]
|
|
60
69
|
},
|
|
61
70
|
{
|
|
62
71
|
"name": "undici",
|
|
63
72
|
"classification": "external-runtime",
|
|
64
73
|
"license": "MIT",
|
|
65
|
-
"usedBy": [
|
|
74
|
+
"usedBy": [
|
|
75
|
+
"cli"
|
|
76
|
+
],
|
|
66
77
|
"replacement": "standalone-runtime-network-boundary",
|
|
67
78
|
"expiresAtMilestone": "PROPRIETARY-RUNTIME-1",
|
|
68
79
|
"allowedThrough": "P2"
|
|
@@ -72,7 +83,10 @@
|
|
|
72
83
|
{
|
|
73
84
|
"name": "node:sqlite",
|
|
74
85
|
"classification": "external-runtime",
|
|
75
|
-
"usedBy": [
|
|
86
|
+
"usedBy": [
|
|
87
|
+
"sdk",
|
|
88
|
+
"cli"
|
|
89
|
+
],
|
|
76
90
|
"replacement": "standalone-runtime-decision",
|
|
77
91
|
"expiresAtMilestone": "PROPRIETARY-RUNTIME-1",
|
|
78
92
|
"allowedThrough": "P2"
|
|
@@ -82,7 +96,10 @@
|
|
|
82
96
|
{
|
|
83
97
|
"name": "node>=20",
|
|
84
98
|
"classification": "external-runtime",
|
|
85
|
-
"usedBy": [
|
|
99
|
+
"usedBy": [
|
|
100
|
+
"sdk",
|
|
101
|
+
"cli"
|
|
102
|
+
],
|
|
86
103
|
"replacement": "standalone-runtime-decision",
|
|
87
104
|
"expiresAtMilestone": "PROPRIETARY-RUNTIME-1",
|
|
88
105
|
"allowedThrough": "P2"
|
|
@@ -90,14 +107,20 @@
|
|
|
90
107
|
{
|
|
91
108
|
"name": "windows-kernel32",
|
|
92
109
|
"classification": "platform-api",
|
|
93
|
-
"usedBy": [
|
|
110
|
+
"usedBy": [
|
|
111
|
+
"sdk",
|
|
112
|
+
"cli"
|
|
113
|
+
],
|
|
94
114
|
"replacement": "operating-system-boundary",
|
|
95
115
|
"expiresAtMilestone": "never"
|
|
96
116
|
},
|
|
97
117
|
{
|
|
98
118
|
"name": "posix-libc",
|
|
99
119
|
"classification": "platform-api",
|
|
100
|
-
"usedBy": [
|
|
120
|
+
"usedBy": [
|
|
121
|
+
"sdk",
|
|
122
|
+
"cli"
|
|
123
|
+
],
|
|
101
124
|
"replacement": "operating-system-boundary",
|
|
102
125
|
"expiresAtMilestone": "never"
|
|
103
126
|
}
|
|
@@ -116,63 +139,81 @@
|
|
|
116
139
|
{
|
|
117
140
|
"name": "node:zlib",
|
|
118
141
|
"classification": "test-oracle",
|
|
119
|
-
"usedBy": [
|
|
142
|
+
"usedBy": [
|
|
143
|
+
"sdk"
|
|
144
|
+
],
|
|
120
145
|
"replacement": "xeno-deflate",
|
|
121
146
|
"expiresAtMilestone": "never"
|
|
122
147
|
},
|
|
123
148
|
{
|
|
124
149
|
"name": "libwebp",
|
|
125
150
|
"classification": "test-oracle",
|
|
126
|
-
"usedBy": [
|
|
151
|
+
"usedBy": [
|
|
152
|
+
"sdk"
|
|
153
|
+
],
|
|
127
154
|
"replacement": "xeno-vp8-webp",
|
|
128
155
|
"expiresAtMilestone": "never"
|
|
129
156
|
},
|
|
130
157
|
{
|
|
131
158
|
"name": "libvpx",
|
|
132
159
|
"classification": "test-oracle",
|
|
133
|
-
"usedBy": [
|
|
160
|
+
"usedBy": [
|
|
161
|
+
"sdk"
|
|
162
|
+
],
|
|
134
163
|
"replacement": "xeno-vp8-webp",
|
|
135
164
|
"expiresAtMilestone": "never"
|
|
136
165
|
},
|
|
137
166
|
{
|
|
138
167
|
"name": "Pillow",
|
|
139
168
|
"classification": "test-oracle",
|
|
140
|
-
"usedBy": [
|
|
169
|
+
"usedBy": [
|
|
170
|
+
"sdk"
|
|
171
|
+
],
|
|
141
172
|
"replacement": "xeno-owned-media",
|
|
142
173
|
"expiresAtMilestone": "never"
|
|
143
174
|
},
|
|
144
175
|
{
|
|
145
176
|
"name": "ImageMagick",
|
|
146
177
|
"classification": "test-oracle",
|
|
147
|
-
"usedBy": [
|
|
178
|
+
"usedBy": [
|
|
179
|
+
"sdk"
|
|
180
|
+
],
|
|
148
181
|
"replacement": "xeno-owned-media",
|
|
149
182
|
"expiresAtMilestone": "never"
|
|
150
183
|
},
|
|
151
184
|
{
|
|
152
185
|
"name": "libpng-PNGSuite",
|
|
153
186
|
"classification": "test-oracle",
|
|
154
|
-
"usedBy": [
|
|
187
|
+
"usedBy": [
|
|
188
|
+
"sdk"
|
|
189
|
+
],
|
|
155
190
|
"replacement": "xeno-owned-media",
|
|
156
191
|
"expiresAtMilestone": "never"
|
|
157
192
|
},
|
|
158
193
|
{
|
|
159
194
|
"name": "libjpeg-turbo-testimages",
|
|
160
195
|
"classification": "test-oracle",
|
|
161
|
-
"usedBy": [
|
|
196
|
+
"usedBy": [
|
|
197
|
+
"sdk"
|
|
198
|
+
],
|
|
162
199
|
"replacement": "xeno-owned-media",
|
|
163
200
|
"expiresAtMilestone": "never"
|
|
164
201
|
},
|
|
165
202
|
{
|
|
166
203
|
"name": "libwebp-test-data",
|
|
167
204
|
"classification": "test-oracle",
|
|
168
|
-
"usedBy": [
|
|
205
|
+
"usedBy": [
|
|
206
|
+
"sdk"
|
|
207
|
+
],
|
|
169
208
|
"replacement": "xeno-owned-media",
|
|
170
209
|
"expiresAtMilestone": "never"
|
|
171
210
|
},
|
|
172
211
|
{
|
|
173
212
|
"name": "W3C-SVG-test-suite",
|
|
174
213
|
"classification": "test-oracle",
|
|
175
|
-
"usedBy": [
|
|
214
|
+
"usedBy": [
|
|
215
|
+
"sdk"
|
|
216
|
+
],
|
|
176
217
|
"replacement": "xeno-owned-media",
|
|
177
218
|
"expiresAtMilestone": "never"
|
|
178
219
|
}
|