@xenosystem/agent-sdk 0.10.18 → 0.10.19

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.
@@ -48,7 +48,7 @@ ${this.stringify(e.data)}
48
48
  `)+`
49
49
  `;await k(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await k(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await k(c,u)}catch(u){this.workspaceMirrorDisabled=!0,B("Transcript workspace mirror disabled",u)}}}async truncateAfterMessageCount(e){let t=await x(this.transcriptPath);if(!t)return;let r=Z(t),s=Math.max(0,e),i=0,o=[];for(let c of r){if(c.type==="user_message"||c.type==="assistant_message"){if(i>=s)break;i+=1}o.push(c)}let a=o.length>0?o.map(c=>JSON.stringify(c)).join(`
50
50
  `)+`
51
- `:"";await k(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await k(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await k(c,u)}catch(u){this.workspaceMirrorDisabled=!0,B("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let e=await x(this.transcriptPath);if(!e){this.sequence=0;return}let t=Z(e);if(t.length===0){this.sequence=0;return}let r=t[t.length-1];this.sequence=r.sequence+1}catch(e){let t=e instanceof Error?e.message:String(e);B(`Transcript initialization warning: ${t}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};var ee=_(require("path"),1),lt=require("crypto"),ut=require("fs/promises");var qt={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function me(n){return qt[n]??n}var I=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(e,t){this.sessionDir=e,this.checkpointsDir=ee.join(e,"checkpoints"),this.autoInterval=t?.autoInterval??10}async initialize(){let e=await this.list();e.length>0&&(this.lastCheckpointMessageCount=e[0].messageCount)}async create(e){await N(this.checkpointsDir);let t=(0,lt.randomUUID)(),r={id:t,name:e.description,trigger:e.trigger,createdAt:new Date().toISOString(),messageCount:e.messages.length,tokenCount:this.estimateTokens(e.messages)},s={info:r,messages:e.messages},i=ee.join(this.checkpointsDir,`${t}.json`);return await k(i,JSON.stringify(s,null,2)),this.lastCheckpointMessageCount=e.messages.length,r}async list(){let e=await Ze(this.checkpointsDir,/\.json$/),t=[];for(let r of e){let s=await x(r);if(s){let i=E(s,null);if(i){let o=await(0,ut.stat)(r);t.push({info:i.info,modifiedAtMs:o.mtimeMs})}}}return t.sort((r,s)=>new Date(s.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||s.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(e){let t=ee.join(this.checkpointsDir,`${e}.json`),r;try{r=await x(t)}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to read checkpoint ${e}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${e} (path: ${t})`);let s=E(r,null);if(!s)throw new Error(`Invalid checkpoint data for ${e}: JSON parse failed`);if(!s.messages||!Array.isArray(s.messages))throw new Error(`Invalid checkpoint data for ${e}: missing or invalid messages array`);if(!s.info)throw new Error(`Invalid checkpoint data for ${e}: missing info object`);return{messages:s.messages,info:s.info}}shouldAutoCheckpoint(e){return e-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(e,t){if(e=me(e),e==="Write")return!0;if(e==="Bash"){let s=t.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>s.includes(o))}return!1}async delete(e){let t=ee.join(this.checkpointsDir,`${e}.json`);await $(t)}estimateTokens(e){let t=0;for(let r of e)if(typeof r.content=="string")t+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let s of r.content)"text"in s&&(t+=Math.ceil(s.text.length/4));return t}};var j=_(require("path"),1),$e=_(require("os"),1),F=_(require("fs"),1);var Jt=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),Vt=globalThis,Oe=Vt[Jt]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},Ne=Oe.cleanups;function zt(){for(let n of Ne)try{n()}catch{}}function dt(n){return Ne.add(n),!Oe.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(Oe.exitHandlerRegistered=!0,process.on("exit",zt)),()=>{Ne.delete(n)}}var pt="0.10.18";var Xt=1e4,Kt=6e4,Yt="session.lock",Qt="lock.json",Q=new Map;function Le(n,e){return n!=null&&n.pid===e.pid&&n.hostname===e.hostname&&n.processStartedAt===e.processStartedAt&&n.acquiredAt===e.acquiredAt}function Zt(){for(let[n,e]of Q)try{let t=E(F.readFileSync(n,"utf8"),null);Le(t,e)&&F.unlinkSync(n)}catch{}Q.clear()}dt(Zt);var U=class n{sessionDir;lockPath;legacyLockPath;sessionId;heartbeatTimer;acquiredOwner;constructor(e){this.sessionDir=e,this.lockPath=j.join(e,Yt),this.legacyLockPath=j.join(e,Qt),this.sessionId=j.basename(e)}async acquire(){let e=new Date().toISOString(),t={schemaVersion:1,name:`session:${this.sessionId}`,sessionId:this.sessionId,pid:process.pid,hostname:$e.hostname(),processStartedAt:new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString(),version:pt,acquiredAt:e,updatedAt:e,heartbeat:e},r=j.dirname(this.lockPath);await F.promises.mkdir(r,{recursive:!0});let s=await this.findExistingLockPath();if(s){if(!await this.isStalePath(s)){let o=await this.readLockAt(s);throw new Error(`Session ${this.sessionId} is already locked by PID ${o?.pid} on ${o?.hostname}`)}await $(s)}try{await F.promises.writeFile(this.lockPath,JSON.stringify(t,null,2),{flag:"wx",encoding:"utf-8"}),this.acquiredOwner=t,Q.set(this.lockPath,t)}catch(i){if(i.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 $(this.lockPath);try{await F.promises.writeFile(this.lockPath,JSON.stringify(t,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}this.acquiredOwner=t,Q.set(this.lockPath,t)}else throw i}}async release(){this.stopHeartbeat();let e=this.acquiredOwner;if(this.acquiredOwner=void 0,!e)return;Q.delete(this.lockPath);let t=await this.readLockAt(this.lockPath);Le(t,e)&&await $(this.lockPath)}async isLocked(){let e=await this.findExistingLockPath();return e?!await this.isStalePath(e):!1}async isStale(){let e=await this.findExistingLockPath();return e?this.isStalePath(e):!1}async isStalePath(e){let t=await this.readLockAt(e);if(!t)return!1;if(t.hostname===$e.hostname())try{return process.kill(t.pid,0),!1}catch(i){return i.code!=="EPERM"}let r=new Date(t.heartbeat).getTime();return Date.now()-r>Kt}startHeartbeat(e=Xt){this.heartbeatTimer&&this.stopHeartbeat(),this.heartbeatTimer=setInterval(async()=>{try{await this.updateHeartbeat()}catch(t){let r=t instanceof Error?t.message:String(t);if(t?.code==="ENOENT"){W("SessionLock: Session directory removed, stopping heartbeat"),this.stopHeartbeat();return}W(`SessionLock: Failed to update heartbeat: ${r}`)}},e),this.heartbeatTimer.unref()}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}async updateHeartbeat(){let e=await this.readLockAt(this.lockPath),t=this.acquiredOwner;if(!(!e||!t)){if(!Le(e,t)){this.acquiredOwner=void 0,Q.delete(this.lockPath),this.stopHeartbeat();return}e.heartbeat=new Date().toISOString(),e.updatedAt=e.heartbeat,await k(this.lockPath,JSON.stringify(e,null,2))}}async readLock(){let e=await this.findExistingLockPath();return e?this.readLockAt(e):null}async readLockAt(e){let t=await x(e);return t?E(t,null):null}async findExistingLockPath(){return await x(this.lockPath)?this.lockPath:await x(this.legacyLockPath)?this.legacyLockPath:null}static async cleanStale(e){let t=await ue(e),r=[];for(let s of t){let i=new n(s);if(await i.isStale()){let a=await i.findExistingLockPath();a&&await $(a),r.push(j.basename(s))}}return r}};var A=_(require("path"),1);var te=1;var C=_(require("path"),1);function er(n,e){let t=C.resolve(n),r=C.resolve(n,e);return r===t?!0:t===C.parse(t).root?r.startsWith(t):r.startsWith(t+C.sep)}function q(n,e){if(C.isAbsolute(e))return C.resolve(e);if(!er(n,e))throw new Error(`PathSecurity: Path traversal attempt detected: ${e}`);return C.resolve(n,e)}function J(n){if(n!==void 0&&n!=="agent"&&n!=="chatOnly")throw new Error("Invalid session execution mode; expected agent or chatOnly.")}var b=_(require("path"),1),we=_(require("os"),1),R=_(require("node:fs/promises"),1),Se=require("node:crypto");var V=require("node:os");var Be=require("node:path"),Kr=(0,V.platform)();var Yr=(0,V.release)(),Qr=(0,V.homedir)();function he(){let n=process.env.XENO_AGENT_HOME?.trim();return n?(0,Be.resolve)(n):(0,Be.resolve)((0,V.homedir)(),".xeno-agent")}var gt=1,ft="recent.json",tr=".lock",ht=".entries",rr=3e4,Fe=6e4,yt=new Set(["EACCES","EBUSY","EPERM"]),nr=[5,10,20,40,80,160,320],ye=new Map;function sr(n,e){let t=(0,Se.createHash)("sha256").update(e).digest("hex");return b.join(`${n}${ht}`,`${t}.json`)}async function je(n,e,t){let r={schemaVersion:1,key:e,entry:t};await k(sr(n,e),JSON.stringify(r)+`
51
+ `:"";await k(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await k(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await k(c,u)}catch(u){this.workspaceMirrorDisabled=!0,B("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let e=await x(this.transcriptPath);if(!e){this.sequence=0;return}let t=Z(e);if(t.length===0){this.sequence=0;return}let r=t[t.length-1];this.sequence=r.sequence+1}catch(e){let t=e instanceof Error?e.message:String(e);B(`Transcript initialization warning: ${t}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};var ee=_(require("path"),1),lt=require("crypto"),ut=require("fs/promises");var qt={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function me(n){return qt[n]??n}var I=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(e,t){this.sessionDir=e,this.checkpointsDir=ee.join(e,"checkpoints"),this.autoInterval=t?.autoInterval??10}async initialize(){let e=await this.list();e.length>0&&(this.lastCheckpointMessageCount=e[0].messageCount)}async create(e){await N(this.checkpointsDir);let t=(0,lt.randomUUID)(),r={id:t,name:e.description,trigger:e.trigger,createdAt:new Date().toISOString(),messageCount:e.messages.length,tokenCount:this.estimateTokens(e.messages)},s={info:r,messages:e.messages},i=ee.join(this.checkpointsDir,`${t}.json`);return await k(i,JSON.stringify(s,null,2)),this.lastCheckpointMessageCount=e.messages.length,r}async list(){let e=await Ze(this.checkpointsDir,/\.json$/),t=[];for(let r of e){let s=await x(r);if(s){let i=E(s,null);if(i){let o=await(0,ut.stat)(r);t.push({info:i.info,modifiedAtMs:o.mtimeMs})}}}return t.sort((r,s)=>new Date(s.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||s.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(e){let t=ee.join(this.checkpointsDir,`${e}.json`),r;try{r=await x(t)}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to read checkpoint ${e}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${e} (path: ${t})`);let s=E(r,null);if(!s)throw new Error(`Invalid checkpoint data for ${e}: JSON parse failed`);if(!s.messages||!Array.isArray(s.messages))throw new Error(`Invalid checkpoint data for ${e}: missing or invalid messages array`);if(!s.info)throw new Error(`Invalid checkpoint data for ${e}: missing info object`);return{messages:s.messages,info:s.info}}shouldAutoCheckpoint(e){return e-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(e,t){if(e=me(e),e==="Write")return!0;if(e==="Bash"){let s=t.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>s.includes(o))}return!1}async delete(e){let t=ee.join(this.checkpointsDir,`${e}.json`);await $(t)}estimateTokens(e){let t=0;for(let r of e)if(typeof r.content=="string")t+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let s of r.content)"text"in s&&(t+=Math.ceil(s.text.length/4));return t}};var j=_(require("path"),1),$e=_(require("os"),1),F=_(require("fs"),1);var Jt=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),Vt=globalThis,Oe=Vt[Jt]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},Ne=Oe.cleanups;function zt(){for(let n of Ne)try{n()}catch{}}function dt(n){return Ne.add(n),!Oe.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(Oe.exitHandlerRegistered=!0,process.on("exit",zt)),()=>{Ne.delete(n)}}var pt="0.10.19";var Xt=1e4,Kt=6e4,Yt="session.lock",Qt="lock.json",Q=new Map;function Le(n,e){return n!=null&&n.pid===e.pid&&n.hostname===e.hostname&&n.processStartedAt===e.processStartedAt&&n.acquiredAt===e.acquiredAt}function Zt(){for(let[n,e]of Q)try{let t=E(F.readFileSync(n,"utf8"),null);Le(t,e)&&F.unlinkSync(n)}catch{}Q.clear()}dt(Zt);var U=class n{sessionDir;lockPath;legacyLockPath;sessionId;heartbeatTimer;acquiredOwner;constructor(e){this.sessionDir=e,this.lockPath=j.join(e,Yt),this.legacyLockPath=j.join(e,Qt),this.sessionId=j.basename(e)}async acquire(){let e=new Date().toISOString(),t={schemaVersion:1,name:`session:${this.sessionId}`,sessionId:this.sessionId,pid:process.pid,hostname:$e.hostname(),processStartedAt:new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString(),version:pt,acquiredAt:e,updatedAt:e,heartbeat:e},r=j.dirname(this.lockPath);await F.promises.mkdir(r,{recursive:!0});let s=await this.findExistingLockPath();if(s){if(!await this.isStalePath(s)){let o=await this.readLockAt(s);throw new Error(`Session ${this.sessionId} is already locked by PID ${o?.pid} on ${o?.hostname}`)}await $(s)}try{await F.promises.writeFile(this.lockPath,JSON.stringify(t,null,2),{flag:"wx",encoding:"utf-8"}),this.acquiredOwner=t,Q.set(this.lockPath,t)}catch(i){if(i.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 $(this.lockPath);try{await F.promises.writeFile(this.lockPath,JSON.stringify(t,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}this.acquiredOwner=t,Q.set(this.lockPath,t)}else throw i}}async release(){this.stopHeartbeat();let e=this.acquiredOwner;if(this.acquiredOwner=void 0,!e)return;Q.delete(this.lockPath);let t=await this.readLockAt(this.lockPath);Le(t,e)&&await $(this.lockPath)}async isLocked(){let e=await this.findExistingLockPath();return e?!await this.isStalePath(e):!1}async isStale(){let e=await this.findExistingLockPath();return e?this.isStalePath(e):!1}async isStalePath(e){let t=await this.readLockAt(e);if(!t)return!1;if(t.hostname===$e.hostname())try{return process.kill(t.pid,0),!1}catch(i){return i.code!=="EPERM"}let r=new Date(t.heartbeat).getTime();return Date.now()-r>Kt}startHeartbeat(e=Xt){this.heartbeatTimer&&this.stopHeartbeat(),this.heartbeatTimer=setInterval(async()=>{try{await this.updateHeartbeat()}catch(t){let r=t instanceof Error?t.message:String(t);if(t?.code==="ENOENT"){W("SessionLock: Session directory removed, stopping heartbeat"),this.stopHeartbeat();return}W(`SessionLock: Failed to update heartbeat: ${r}`)}},e),this.heartbeatTimer.unref()}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}async updateHeartbeat(){let e=await this.readLockAt(this.lockPath),t=this.acquiredOwner;if(!(!e||!t)){if(!Le(e,t)){this.acquiredOwner=void 0,Q.delete(this.lockPath),this.stopHeartbeat();return}e.heartbeat=new Date().toISOString(),e.updatedAt=e.heartbeat,await k(this.lockPath,JSON.stringify(e,null,2))}}async readLock(){let e=await this.findExistingLockPath();return e?this.readLockAt(e):null}async readLockAt(e){let t=await x(e);return t?E(t,null):null}async findExistingLockPath(){return await x(this.lockPath)?this.lockPath:await x(this.legacyLockPath)?this.legacyLockPath:null}static async cleanStale(e){let t=await ue(e),r=[];for(let s of t){let i=new n(s);if(await i.isStale()){let a=await i.findExistingLockPath();a&&await $(a),r.push(j.basename(s))}}return r}};var A=_(require("path"),1);var te=1;var C=_(require("path"),1);function er(n,e){let t=C.resolve(n),r=C.resolve(n,e);return r===t?!0:t===C.parse(t).root?r.startsWith(t):r.startsWith(t+C.sep)}function q(n,e){if(C.isAbsolute(e))return C.resolve(e);if(!er(n,e))throw new Error(`PathSecurity: Path traversal attempt detected: ${e}`);return C.resolve(n,e)}function J(n){if(n!==void 0&&n!=="agent"&&n!=="chatOnly")throw new Error("Invalid session execution mode; expected agent or chatOnly.")}var b=_(require("path"),1),we=_(require("os"),1),R=_(require("node:fs/promises"),1),Se=require("node:crypto");var V=require("node:os");var Be=require("node:path"),Kr=(0,V.platform)();var Yr=(0,V.release)(),Qr=(0,V.homedir)();function he(){let n=process.env.XENO_AGENT_HOME?.trim();return n?(0,Be.resolve)(n):(0,Be.resolve)((0,V.homedir)(),".xeno-agent")}var gt=1,ft="recent.json",tr=".lock",ht=".entries",rr=3e4,Fe=6e4,yt=new Set(["EACCES","EBUSY","EPERM"]),nr=[5,10,20,40,80,160,320],ye=new Map;function sr(n,e){let t=(0,Se.createHash)("sha256").update(e).digest("hex");return b.join(`${n}${ht}`,`${t}.json`)}async function je(n,e,t){let r={schemaVersion:1,key:e,entry:t};await k(sr(n,e),JSON.stringify(r)+`
52
52
  `)}async function ir(n,e){let t=`${n}${ht}`,r;try{r=await R.readdir(t)}catch(s){if(s.code==="ENOENT")return;throw s}await Promise.all(r.filter(s=>s.endsWith(".json")).map(async s=>{let i=await R.readFile(b.join(t,s),"utf8").catch(()=>""),o=E(i,null);if(!(!o||o.schemaVersion!==1||typeof o.key!="string")){if(o.entry===null){delete e[o.key];return}typeof o.entry.sessionId!="string"||typeof o.entry.endedAt!="string"||(e[o.key]=o.entry)}}))}function mt(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function or(n){try{let[e,t]=await Promise.all([R.readFile(b.join(n,"owner.json"),"utf8").catch(()=>""),R.stat(n)]),r=E(e,null);return r?.hostname===we.hostname()&&mt(r.pid)?!1:r?.hostname&&r.hostname!==we.hostname()||!r?Date.now()-t.mtimeMs>Fe:Date.now()-t.mtimeMs>Fe||!mt(r.pid)}catch{return!1}}async function wt(n){for(let e=0;;e+=1)try{await R.rm(n,{recursive:!0});return}catch(t){let r=t.code;if(r==="ENOENT")return;let s=nr[e];if(process.platform!=="win32"||!r||!yt.has(r)||s===void 0)throw t;await new Promise(i=>setTimeout(i,s))}}async function ar(n,e){try{let t=await R.readFile(b.join(n,"owner.json"),"utf8");E(t,null)?.token===e&&await wt(n)}catch(t){if(t.code!=="ENOENT")throw t}}async function He(n,e){let t=z(n),r=ye.get(t)??Promise.resolve(),s,i=new Promise(o=>{s=o});ye.set(t,i),await r;try{return await cr(t,e)}finally{s(),ye.get(t)===i&&ye.delete(t)}}async function cr(n,e){let t=`${n}${tr}`,r=(0,Se.randomUUID)(),s=Date.now();await R.mkdir(b.dirname(n),{recursive:!0});for(let i=0;;i+=1){let o={schemaVersion:1,token:r,pid:process.pid,hostname:we.hostname(),acquiredAt:new Date().toISOString()};try{await R.mkdir(t),await R.writeFile(b.join(t,"owner.json"),JSON.stringify(o),"utf8");break}catch(a){let l=a.code,c=process.platform==="win32"&&!!l&&yt.has(l);if(l!=="EEXIST"&&!c)throw a;if(await or(t)){await wt(t);continue}if(Date.now()-s>=rr)throw new Error(`Timed out waiting for recent-sessions index lock: ${t}`);let u=Math.min(100,5+i*5)+Math.floor(Math.random()*10);await new Promise(p=>setTimeout(p,u))}}try{return await e()}finally{await ar(t,r)}}function z(n){return n===void 0?b.join(he(),ft):b.join(n,".xeno-agent",ft)}function re(n){let e=b.normalize(n).replace(/[\\/]+$/,""),t=e.length>0?e:b.parse(b.normalize(n)).root;return process.platform==="win32"?t.toLowerCase():t}async function H(n){let e=z(n),t=le(e)?await x(e):null,r=t?E(t,null):null,s=r&&typeof r=="object"?r:null,i={},o=s?.version===gt&&s.entries&&typeof s.entries=="object"?s.entries:{};for(let[a,l]of Object.entries(o)){if(!l||typeof l!="object")continue;let c=l;typeof c.sessionId!="string"||c.sessionId.length===0||typeof c.endedAt=="string"&&(i[a]={sessionId:c.sessionId,endedAt:c.endedAt,role:typeof c.role=="string"?c.role:void 0})}return await ir(e,i),{version:gt,entries:i}}async function ke(n,e={}){let t=await H(e.homeDir),r=re(n),s=t.entries[r];if(s&&!(e.role&&s.role&&s.role!==e.role))return s}async function xe(n,e={}){let t=re(n.cwd),r={sessionId:n.sessionId,role:n.role,endedAt:n.endedAt??new Date().toISOString()},s=z(e.homeDir);await je(s,t,r),await He(e.homeDir,async()=>{let i=await H(e.homeDir);i.entries[t]=r,await k(s,JSON.stringify(i,null,2)+`
53
53
  `)})}async function St(n,e={}){let t=re(n),r=z(e.homeDir);(await H(e.homeDir)).entries[t]&&(await je(r,t,null),await He(e.homeDir,async()=>{let i=await H(e.homeDir);delete i.entries[t],await k(r,JSON.stringify(i,null,2)+`
54
54
  `)}))}async function ne(n,e={}){let t=await H(e.homeDir),r=Object.entries(t.entries).filter(([,i])=>i.sessionId===n).map(([i])=>i);if(r.length===0)return;let s=z(e.homeDir);await Promise.all(r.map(i=>je(s,i,null))),await He(e.homeDir,async()=>{let i=await H(e.homeDir);for(let[o,a]of Object.entries(i.entries))a.sessionId===n&&delete i.entries[o];await k(s,JSON.stringify(i,null,2)+`
@@ -48,7 +48,7 @@ ${this.stringify(e.data)}
48
48
  `)+`
49
49
  `;await S(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await S(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await S(c,u)}catch(u){this.workspaceMirrorDisabled=!0,$("Transcript workspace mirror disabled",u)}}}async truncateAfterMessageCount(e){let t=await k(this.transcriptPath);if(!t)return;let r=K(t),s=Math.max(0,e),i=0,o=[];for(let c of r){if(c.type==="user_message"||c.type==="assistant_message"){if(i>=s)break;i+=1}o.push(c)}let a=o.length>0?o.map(c=>JSON.stringify(c)).join(`
50
50
  `)+`
51
- `:"";await S(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await S(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await S(c,u)}catch(u){this.workspaceMirrorDisabled=!0,$("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let e=await k(this.transcriptPath);if(!e){this.sequence=0;return}let t=K(e);if(t.length===0){this.sequence=0;return}let r=t[t.length-1];this.sequence=r.sequence+1}catch(e){let t=e instanceof Error?e.message:String(e);$(`Transcript initialization warning: ${t}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};import*as Y from"path";import{randomUUID as Lt}from"crypto";import{stat as Bt}from"fs/promises";var $t={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function oe(n){return $t[n]??n}var I=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(e,t){this.sessionDir=e,this.checkpointsDir=Y.join(e,"checkpoints"),this.autoInterval=t?.autoInterval??10}async initialize(){let e=await this.list();e.length>0&&(this.lastCheckpointMessageCount=e[0].messageCount)}async create(e){await A(this.checkpointsDir);let t=Lt(),r={id:t,name:e.description,trigger:e.trigger,createdAt:new Date().toISOString(),messageCount:e.messages.length,tokenCount:this.estimateTokens(e.messages)},s={info:r,messages:e.messages},i=Y.join(this.checkpointsDir,`${t}.json`);return await S(i,JSON.stringify(s,null,2)),this.lastCheckpointMessageCount=e.messages.length,r}async list(){let e=await We(this.checkpointsDir,/\.json$/),t=[];for(let r of e){let s=await k(r);if(s){let i=P(s,null);if(i){let o=await Bt(r);t.push({info:i.info,modifiedAtMs:o.mtimeMs})}}}return t.sort((r,s)=>new Date(s.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||s.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(e){let t=Y.join(this.checkpointsDir,`${e}.json`),r;try{r=await k(t)}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to read checkpoint ${e}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${e} (path: ${t})`);let s=P(r,null);if(!s)throw new Error(`Invalid checkpoint data for ${e}: JSON parse failed`);if(!s.messages||!Array.isArray(s.messages))throw new Error(`Invalid checkpoint data for ${e}: missing or invalid messages array`);if(!s.info)throw new Error(`Invalid checkpoint data for ${e}: missing info object`);return{messages:s.messages,info:s.info}}shouldAutoCheckpoint(e){return e-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(e,t){if(e=oe(e),e==="Write")return!0;if(e==="Bash"){let s=t.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>s.includes(o))}return!1}async delete(e){let t=Y.join(this.checkpointsDir,`${e}.json`);await O(t)}estimateTokens(e){let t=0;for(let r of e)if(typeof r.content=="string")t+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let s of r.content)"text"in s&&(t+=Math.ceil(s.text.length/4));return t}};import*as B from"path";import*as Pe from"os";import*as L from"fs";var Ft=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),jt=globalThis,xe=jt[Ft]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},ve=xe.cleanups;function Ht(){for(let n of ve)try{n()}catch{}}function Qe(n){return ve.add(n),!xe.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(xe.exitHandlerRegistered=!0,process.on("exit",Ht)),()=>{ve.delete(n)}}var Ze="0.10.18";var Wt=1e4,Gt=6e4,Ut="session.lock",qt="lock.json",q=new Map;function Ee(n,e){return n!=null&&n.pid===e.pid&&n.hostname===e.hostname&&n.processStartedAt===e.processStartedAt&&n.acquiredAt===e.acquiredAt}function Jt(){for(let[n,e]of q)try{let t=P(L.readFileSync(n,"utf8"),null);Ee(t,e)&&L.unlinkSync(n)}catch{}q.clear()}Qe(Jt);var J=class n{sessionDir;lockPath;legacyLockPath;sessionId;heartbeatTimer;acquiredOwner;constructor(e){this.sessionDir=e,this.lockPath=B.join(e,Ut),this.legacyLockPath=B.join(e,qt),this.sessionId=B.basename(e)}async acquire(){let e=new Date().toISOString(),t={schemaVersion:1,name:`session:${this.sessionId}`,sessionId:this.sessionId,pid:process.pid,hostname:Pe.hostname(),processStartedAt:new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString(),version:Ze,acquiredAt:e,updatedAt:e,heartbeat:e},r=B.dirname(this.lockPath);await L.promises.mkdir(r,{recursive:!0});let s=await this.findExistingLockPath();if(s){if(!await this.isStalePath(s)){let o=await this.readLockAt(s);throw new Error(`Session ${this.sessionId} is already locked by PID ${o?.pid} on ${o?.hostname}`)}await O(s)}try{await L.promises.writeFile(this.lockPath,JSON.stringify(t,null,2),{flag:"wx",encoding:"utf-8"}),this.acquiredOwner=t,q.set(this.lockPath,t)}catch(i){if(i.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 O(this.lockPath);try{await L.promises.writeFile(this.lockPath,JSON.stringify(t,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}this.acquiredOwner=t,q.set(this.lockPath,t)}else throw i}}async release(){this.stopHeartbeat();let e=this.acquiredOwner;if(this.acquiredOwner=void 0,!e)return;q.delete(this.lockPath);let t=await this.readLockAt(this.lockPath);Ee(t,e)&&await O(this.lockPath)}async isLocked(){let e=await this.findExistingLockPath();return e?!await this.isStalePath(e):!1}async isStale(){let e=await this.findExistingLockPath();return e?this.isStalePath(e):!1}async isStalePath(e){let t=await this.readLockAt(e);if(!t)return!1;if(t.hostname===Pe.hostname())try{return process.kill(t.pid,0),!1}catch(i){return i.code!=="EPERM"}let r=new Date(t.heartbeat).getTime();return Date.now()-r>Gt}startHeartbeat(e=Wt){this.heartbeatTimer&&this.stopHeartbeat(),this.heartbeatTimer=setInterval(async()=>{try{await this.updateHeartbeat()}catch(t){let r=t instanceof Error?t.message:String(t);if(t?.code==="ENOENT"){F("SessionLock: Session directory removed, stopping heartbeat"),this.stopHeartbeat();return}F(`SessionLock: Failed to update heartbeat: ${r}`)}},e),this.heartbeatTimer.unref()}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}async updateHeartbeat(){let e=await this.readLockAt(this.lockPath),t=this.acquiredOwner;if(!(!e||!t)){if(!Ee(e,t)){this.acquiredOwner=void 0,q.delete(this.lockPath),this.stopHeartbeat();return}e.heartbeat=new Date().toISOString(),e.updatedAt=e.heartbeat,await S(this.lockPath,JSON.stringify(e,null,2))}}async readLock(){let e=await this.findExistingLockPath();return e?this.readLockAt(e):null}async readLockAt(e){let t=await k(e);return t?P(t,null):null}async findExistingLockPath(){return await k(this.lockPath)?this.lockPath:await k(this.legacyLockPath)?this.legacyLockPath:null}static async cleanStale(e){let t=await se(e),r=[];for(let s of t){let i=new n(s);if(await i.isStale()){let a=await i.findExistingLockPath();a&&await O(a),r.push(B.basename(s))}}return r}};import*as D from"path";var Q=1;import*as M from"path";function Vt(n,e){let t=M.resolve(n),r=M.resolve(n,e);return r===t?!0:t===M.parse(t).root?r.startsWith(t):r.startsWith(t+M.sep)}function H(n,e){if(M.isAbsolute(e))return M.resolve(e);if(!Vt(n,e))throw new Error(`PathSecurity: Path traversal attempt detected: ${e}`);return M.resolve(n,e)}function W(n){if(n!==void 0&&n!=="agent"&&n!=="chatOnly")throw new Error("Invalid session execution mode; expected agent or chatOnly.")}import*as T from"path";import*as le from"os";import*as b from"node:fs/promises";import{createHash as Kt,randomUUID as Yt}from"node:crypto";import{homedir as tt,platform as zt,release as Xt}from"node:os";import{resolve as et}from"node:path";var cn=zt();var ln=Xt(),un=tt();function ae(){let n=process.env.XENO_AGENT_HOME?.trim();return n?et(n):et(tt(),".xeno-agent")}var rt=1,nt="recent.json",Qt=".lock",it=".entries",Zt=3e4,Te=6e4,ot=new Set(["EACCES","EBUSY","EPERM"]),er=[5,10,20,40,80,160,320],ce=new Map;function tr(n,e){let t=Kt("sha256").update(e).digest("hex");return T.join(`${n}${it}`,`${t}.json`)}async function be(n,e,t){let r={schemaVersion:1,key:e,entry:t};await S(tr(n,e),JSON.stringify(r)+`
51
+ `:"";await S(this.transcriptPath,a);let l=this.buildMarkdownDocument(o,"session store");if(await S(this.markdownPath,l),!this.workspaceMirrorDisabled){let c=await this.resolveWorkspaceMarkdownPath();if(c)try{let u=this.buildMarkdownDocument(o,"workspace mirror");await S(c,u)}catch(u){this.workspaceMirrorDisabled=!0,$("Transcript workspace mirror disabled",u)}}}getSequence(){return this.sequence}async initialize(){try{let e=await k(this.transcriptPath);if(!e){this.sequence=0;return}let t=K(e);if(t.length===0){this.sequence=0;return}let r=t[t.length-1];this.sequence=r.sequence+1}catch(e){let t=e instanceof Error?e.message:String(e);$(`Transcript initialization warning: ${t}. Starting with empty transcript.`),this.sequence=0}}async flush(){await this.writeQueue}};import*as Y from"path";import{randomUUID as Lt}from"crypto";import{stat as Bt}from"fs/promises";var $t={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function oe(n){return $t[n]??n}var I=class{sessionDir;checkpointsDir;autoInterval;lastCheckpointMessageCount=0;constructor(e,t){this.sessionDir=e,this.checkpointsDir=Y.join(e,"checkpoints"),this.autoInterval=t?.autoInterval??10}async initialize(){let e=await this.list();e.length>0&&(this.lastCheckpointMessageCount=e[0].messageCount)}async create(e){await A(this.checkpointsDir);let t=Lt(),r={id:t,name:e.description,trigger:e.trigger,createdAt:new Date().toISOString(),messageCount:e.messages.length,tokenCount:this.estimateTokens(e.messages)},s={info:r,messages:e.messages},i=Y.join(this.checkpointsDir,`${t}.json`);return await S(i,JSON.stringify(s,null,2)),this.lastCheckpointMessageCount=e.messages.length,r}async list(){let e=await We(this.checkpointsDir,/\.json$/),t=[];for(let r of e){let s=await k(r);if(s){let i=P(s,null);if(i){let o=await Bt(r);t.push({info:i.info,modifiedAtMs:o.mtimeMs})}}}return t.sort((r,s)=>new Date(s.info.createdAt).getTime()-new Date(r.info.createdAt).getTime()||s.modifiedAtMs-r.modifiedAtMs).map(({info:r})=>r)}async restore(e){let t=Y.join(this.checkpointsDir,`${e}.json`),r;try{r=await k(t)}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to read checkpoint ${e}: ${o}`)}if(!r)throw new Error(`Checkpoint not found: ${e} (path: ${t})`);let s=P(r,null);if(!s)throw new Error(`Invalid checkpoint data for ${e}: JSON parse failed`);if(!s.messages||!Array.isArray(s.messages))throw new Error(`Invalid checkpoint data for ${e}: missing or invalid messages array`);if(!s.info)throw new Error(`Invalid checkpoint data for ${e}: missing info object`);return{messages:s.messages,info:s.info}}shouldAutoCheckpoint(e){return e-this.lastCheckpointMessageCount>=this.autoInterval}static isDangerousOperation(e,t){if(e=oe(e),e==="Write")return!0;if(e==="Bash"){let s=t.command?.toLowerCase()||"";return["rm ","del ","git push","git reset","drop ","truncate"].some(o=>s.includes(o))}return!1}async delete(e){let t=Y.join(this.checkpointsDir,`${e}.json`);await O(t)}estimateTokens(e){let t=0;for(let r of e)if(typeof r.content=="string")t+=Math.ceil(r.content.length/4);else if(Array.isArray(r.content))for(let s of r.content)"text"in s&&(t+=Math.ceil(s.text.length/4));return t}};import*as B from"path";import*as Pe from"os";import*as L from"fs";var Ft=Symbol.for("@xenosystem/agent-sdk/shutdown-registry"),jt=globalThis,xe=jt[Ft]??={cleanups:new Set,exitHandlerRegistered:!1,signalHandlersInstalled:!1},ve=xe.cleanups;function Ht(){for(let n of ve)try{n()}catch{}}function Qe(n){return ve.add(n),!xe.exitHandlerRegistered&&typeof process<"u"&&typeof process.on=="function"&&(xe.exitHandlerRegistered=!0,process.on("exit",Ht)),()=>{ve.delete(n)}}var Ze="0.10.19";var Wt=1e4,Gt=6e4,Ut="session.lock",qt="lock.json",q=new Map;function Ee(n,e){return n!=null&&n.pid===e.pid&&n.hostname===e.hostname&&n.processStartedAt===e.processStartedAt&&n.acquiredAt===e.acquiredAt}function Jt(){for(let[n,e]of q)try{let t=P(L.readFileSync(n,"utf8"),null);Ee(t,e)&&L.unlinkSync(n)}catch{}q.clear()}Qe(Jt);var J=class n{sessionDir;lockPath;legacyLockPath;sessionId;heartbeatTimer;acquiredOwner;constructor(e){this.sessionDir=e,this.lockPath=B.join(e,Ut),this.legacyLockPath=B.join(e,qt),this.sessionId=B.basename(e)}async acquire(){let e=new Date().toISOString(),t={schemaVersion:1,name:`session:${this.sessionId}`,sessionId:this.sessionId,pid:process.pid,hostname:Pe.hostname(),processStartedAt:new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString(),version:Ze,acquiredAt:e,updatedAt:e,heartbeat:e},r=B.dirname(this.lockPath);await L.promises.mkdir(r,{recursive:!0});let s=await this.findExistingLockPath();if(s){if(!await this.isStalePath(s)){let o=await this.readLockAt(s);throw new Error(`Session ${this.sessionId} is already locked by PID ${o?.pid} on ${o?.hostname}`)}await O(s)}try{await L.promises.writeFile(this.lockPath,JSON.stringify(t,null,2),{flag:"wx",encoding:"utf-8"}),this.acquiredOwner=t,q.set(this.lockPath,t)}catch(i){if(i.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 O(this.lockPath);try{await L.promises.writeFile(this.lockPath,JSON.stringify(t,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}this.acquiredOwner=t,q.set(this.lockPath,t)}else throw i}}async release(){this.stopHeartbeat();let e=this.acquiredOwner;if(this.acquiredOwner=void 0,!e)return;q.delete(this.lockPath);let t=await this.readLockAt(this.lockPath);Ee(t,e)&&await O(this.lockPath)}async isLocked(){let e=await this.findExistingLockPath();return e?!await this.isStalePath(e):!1}async isStale(){let e=await this.findExistingLockPath();return e?this.isStalePath(e):!1}async isStalePath(e){let t=await this.readLockAt(e);if(!t)return!1;if(t.hostname===Pe.hostname())try{return process.kill(t.pid,0),!1}catch(i){return i.code!=="EPERM"}let r=new Date(t.heartbeat).getTime();return Date.now()-r>Gt}startHeartbeat(e=Wt){this.heartbeatTimer&&this.stopHeartbeat(),this.heartbeatTimer=setInterval(async()=>{try{await this.updateHeartbeat()}catch(t){let r=t instanceof Error?t.message:String(t);if(t?.code==="ENOENT"){F("SessionLock: Session directory removed, stopping heartbeat"),this.stopHeartbeat();return}F(`SessionLock: Failed to update heartbeat: ${r}`)}},e),this.heartbeatTimer.unref()}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}async updateHeartbeat(){let e=await this.readLockAt(this.lockPath),t=this.acquiredOwner;if(!(!e||!t)){if(!Ee(e,t)){this.acquiredOwner=void 0,q.delete(this.lockPath),this.stopHeartbeat();return}e.heartbeat=new Date().toISOString(),e.updatedAt=e.heartbeat,await S(this.lockPath,JSON.stringify(e,null,2))}}async readLock(){let e=await this.findExistingLockPath();return e?this.readLockAt(e):null}async readLockAt(e){let t=await k(e);return t?P(t,null):null}async findExistingLockPath(){return await k(this.lockPath)?this.lockPath:await k(this.legacyLockPath)?this.legacyLockPath:null}static async cleanStale(e){let t=await se(e),r=[];for(let s of t){let i=new n(s);if(await i.isStale()){let a=await i.findExistingLockPath();a&&await O(a),r.push(B.basename(s))}}return r}};import*as D from"path";var Q=1;import*as M from"path";function Vt(n,e){let t=M.resolve(n),r=M.resolve(n,e);return r===t?!0:t===M.parse(t).root?r.startsWith(t):r.startsWith(t+M.sep)}function H(n,e){if(M.isAbsolute(e))return M.resolve(e);if(!Vt(n,e))throw new Error(`PathSecurity: Path traversal attempt detected: ${e}`);return M.resolve(n,e)}function W(n){if(n!==void 0&&n!=="agent"&&n!=="chatOnly")throw new Error("Invalid session execution mode; expected agent or chatOnly.")}import*as T from"path";import*as le from"os";import*as b from"node:fs/promises";import{createHash as Kt,randomUUID as Yt}from"node:crypto";import{homedir as tt,platform as zt,release as Xt}from"node:os";import{resolve as et}from"node:path";var cn=zt();var ln=Xt(),un=tt();function ae(){let n=process.env.XENO_AGENT_HOME?.trim();return n?et(n):et(tt(),".xeno-agent")}var rt=1,nt="recent.json",Qt=".lock",it=".entries",Zt=3e4,Te=6e4,ot=new Set(["EACCES","EBUSY","EPERM"]),er=[5,10,20,40,80,160,320],ce=new Map;function tr(n,e){let t=Kt("sha256").update(e).digest("hex");return T.join(`${n}${it}`,`${t}.json`)}async function be(n,e,t){let r={schemaVersion:1,key:e,entry:t};await S(tr(n,e),JSON.stringify(r)+`
52
52
  `)}async function rr(n,e){let t=`${n}${it}`,r;try{r=await b.readdir(t)}catch(s){if(s.code==="ENOENT")return;throw s}await Promise.all(r.filter(s=>s.endsWith(".json")).map(async s=>{let i=await b.readFile(T.join(t,s),"utf8").catch(()=>""),o=P(i,null);if(!(!o||o.schemaVersion!==1||typeof o.key!="string")){if(o.entry===null){delete e[o.key];return}typeof o.entry.sessionId!="string"||typeof o.entry.endedAt!="string"||(e[o.key]=o.entry)}}))}function st(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function nr(n){try{let[e,t]=await Promise.all([b.readFile(T.join(n,"owner.json"),"utf8").catch(()=>""),b.stat(n)]),r=P(e,null);return r?.hostname===le.hostname()&&st(r.pid)?!1:r?.hostname&&r.hostname!==le.hostname()||!r?Date.now()-t.mtimeMs>Te:Date.now()-t.mtimeMs>Te||!st(r.pid)}catch{return!1}}async function at(n){for(let e=0;;e+=1)try{await b.rm(n,{recursive:!0});return}catch(t){let r=t.code;if(r==="ENOENT")return;let s=er[e];if(process.platform!=="win32"||!r||!ot.has(r)||s===void 0)throw t;await new Promise(i=>setTimeout(i,s))}}async function sr(n,e){try{let t=await b.readFile(T.join(n,"owner.json"),"utf8");P(t,null)?.token===e&&await at(n)}catch(t){if(t.code!=="ENOENT")throw t}}async function Re(n,e){let t=V(n),r=ce.get(t)??Promise.resolve(),s,i=new Promise(o=>{s=o});ce.set(t,i),await r;try{return await ir(t,e)}finally{s(),ce.get(t)===i&&ce.delete(t)}}async function ir(n,e){let t=`${n}${Qt}`,r=Yt(),s=Date.now();await b.mkdir(T.dirname(n),{recursive:!0});for(let i=0;;i+=1){let o={schemaVersion:1,token:r,pid:process.pid,hostname:le.hostname(),acquiredAt:new Date().toISOString()};try{await b.mkdir(t),await b.writeFile(T.join(t,"owner.json"),JSON.stringify(o),"utf8");break}catch(a){let l=a.code,c=process.platform==="win32"&&!!l&&ot.has(l);if(l!=="EEXIST"&&!c)throw a;if(await nr(t)){await at(t);continue}if(Date.now()-s>=Zt)throw new Error(`Timed out waiting for recent-sessions index lock: ${t}`);let u=Math.min(100,5+i*5)+Math.floor(Math.random()*10);await new Promise(p=>setTimeout(p,u))}}try{return await e()}finally{await sr(t,r)}}function V(n){return n===void 0?T.join(ae(),nt):T.join(n,".xeno-agent",nt)}function ue(n){let e=T.normalize(n).replace(/[\\/]+$/,""),t=e.length>0?e:T.parse(T.normalize(n)).root;return process.platform==="win32"?t.toLowerCase():t}async function G(n){let e=V(n),t=ne(e)?await k(e):null,r=t?P(t,null):null,s=r&&typeof r=="object"?r:null,i={},o=s?.version===rt&&s.entries&&typeof s.entries=="object"?s.entries:{};for(let[a,l]of Object.entries(o)){if(!l||typeof l!="object")continue;let c=l;typeof c.sessionId!="string"||c.sessionId.length===0||typeof c.endedAt=="string"&&(i[a]={sessionId:c.sessionId,endedAt:c.endedAt,role:typeof c.role=="string"?c.role:void 0})}return await rr(e,i),{version:rt,entries:i}}async function _e(n,e={}){let t=await G(e.homeDir),r=ue(n),s=t.entries[r];if(s&&!(e.role&&s.role&&s.role!==e.role))return s}async function Me(n,e={}){let t=ue(n.cwd),r={sessionId:n.sessionId,role:n.role,endedAt:n.endedAt??new Date().toISOString()},s=V(e.homeDir);await be(s,t,r),await Re(e.homeDir,async()=>{let i=await G(e.homeDir);i.entries[t]=r,await S(s,JSON.stringify(i,null,2)+`
53
53
  `)})}async function or(n,e={}){let t=ue(n),r=V(e.homeDir);(await G(e.homeDir)).entries[t]&&(await be(r,t,null),await Re(e.homeDir,async()=>{let i=await G(e.homeDir);delete i.entries[t],await S(r,JSON.stringify(i,null,2)+`
54
54
  `)}))}async function de(n,e={}){let t=await G(e.homeDir),r=Object.entries(t.entries).filter(([,i])=>i.sessionId===n).map(([i])=>i);if(r.length===0)return;let s=V(e.homeDir);await Promise.all(r.map(i=>be(s,i,null))),await Re(e.homeDir,async()=>{let i=await G(e.homeDir);for(let[o,a]of Object.entries(i.entries))a.sessionId===n&&delete i.entries[o];await S(s,JSON.stringify(i,null,2)+`
@@ -1 +1 @@
1
- {"inputs":{"src/session/id-generator.ts":{"bytes":870,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/fs.ts":{"bytes":11685,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/json.ts":{"bytes":804,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3719,"imports":[],"format":"esm"},"src/session/direct-shell.ts":{"bytes":2317,"imports":[],"format":"esm"},"src/session/transcript-pages.ts":{"bytes":9566,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/transcript.ts":{"bytes":18791,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/transcript-pages.ts","kind":"import-statement","original":"./transcript-pages.js"}],"format":"esm"},"src/tools/tool-names.ts":{"bytes":3747,"imports":[],"format":"esm"},"src/session/checkpoint.ts":{"bytes":5786,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"fs/promises","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"}],"format":"esm"},"src/runtime/shutdown.ts":{"bytes":7260,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/session/lock.ts":{"bytes":10975,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/runtime/shutdown.ts","kind":"import-statement","original":"../runtime/shutdown.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"}],"format":"esm"},"src/types.ts":{"bytes":30376,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":993,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/session/execution-mode.ts":{"bytes":313,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/recent-sessions.ts":{"bytes":15374,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/session/registry.ts":{"bytes":15052,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"}],"format":"esm"},"src/session/recovery.ts":{"bytes":11638,"imports":[{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"}],"format":"esm"},"src/session/manager.ts":{"bytes":16015,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"}],"format":"esm"},"src/session/turn-restore.ts":{"bytes":30751,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"}],"format":"esm"},"src/session/index.ts":{"bytes":1570,"imports":[{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/manager.ts","kind":"import-statement","original":"./manager.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/session/turn-restore.ts","kind":"import-statement","original":"./turn-restore.js"}],"format":"esm"}},"outputs":{"dist/session/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"crypto","kind":"require-call","external":true},{"path":"fs/promises","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"os","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"os","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/session/index.ts","inputs":{"src/session/index.ts":{"bytesInOutput":755},"src/session/id-generator.ts":{"bytesInOutput":340},"src/session/transcript.ts":{"bytesInOutput":7906},"src/utils/fs.ts":{"bytesInOutput":1604},"src/utils/json.ts":{"bytesInOutput":170},"src/utils/logger.ts":{"bytesInOutput":489},"src/session/direct-shell.ts":{"bytesInOutput":1071},"src/session/transcript-pages.ts":{"bytesInOutput":3825},"src/session/checkpoint.ts":{"bytesInOutput":2307},"src/tools/tool-names.ts":{"bytesInOutput":242},"src/session/lock.ts":{"bytesInOutput":3733},"src/runtime/shutdown.ts":{"bytesInOutput":400},"src/version.ts":{"bytesInOutput":17},"src/session/registry.ts":{"bytesInOutput":4614},"src/types.ts":{"bytesInOutput":9},"src/utils/path-security.ts":{"bytesInOutput":314},"src/session/execution-mode.ts":{"bytesInOutput":136},"src/session/recent-sessions.ts":{"bytesInOutput":4302},"src/utils/platform.ts":{"bytesInOutput":244},"src/session/manager.ts":{"bytesInOutput":6024},"src/session/recovery.ts":{"bytesInOutput":4149},"src/session/turn-restore.ts":{"bytesInOutput":13682}},"bytes":57492}}}
1
+ {"inputs":{"src/session/id-generator.ts":{"bytes":870,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/fs.ts":{"bytes":11685,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/json.ts":{"bytes":804,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3719,"imports":[],"format":"esm"},"src/session/direct-shell.ts":{"bytes":2317,"imports":[],"format":"esm"},"src/session/transcript-pages.ts":{"bytes":9566,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/transcript.ts":{"bytes":18791,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/transcript-pages.ts","kind":"import-statement","original":"./transcript-pages.js"}],"format":"esm"},"src/tools/tool-names.ts":{"bytes":3779,"imports":[],"format":"esm"},"src/session/checkpoint.ts":{"bytes":5786,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"fs/promises","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"}],"format":"esm"},"src/runtime/shutdown.ts":{"bytes":7260,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/session/lock.ts":{"bytes":10975,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/runtime/shutdown.ts","kind":"import-statement","original":"../runtime/shutdown.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"}],"format":"esm"},"src/types.ts":{"bytes":30376,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":993,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/session/execution-mode.ts":{"bytes":313,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/recent-sessions.ts":{"bytes":15374,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/session/registry.ts":{"bytes":15052,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"}],"format":"esm"},"src/session/recovery.ts":{"bytes":11638,"imports":[{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"}],"format":"esm"},"src/session/manager.ts":{"bytes":16015,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"}],"format":"esm"},"src/session/turn-restore.ts":{"bytes":30751,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"}],"format":"esm"},"src/session/index.ts":{"bytes":1570,"imports":[{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/manager.ts","kind":"import-statement","original":"./manager.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/session/turn-restore.ts","kind":"import-statement","original":"./turn-restore.js"}],"format":"esm"}},"outputs":{"dist/session/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"crypto","kind":"require-call","external":true},{"path":"fs/promises","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"os","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"os","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/session/index.ts","inputs":{"src/session/index.ts":{"bytesInOutput":755},"src/session/id-generator.ts":{"bytesInOutput":340},"src/session/transcript.ts":{"bytesInOutput":7906},"src/utils/fs.ts":{"bytesInOutput":1604},"src/utils/json.ts":{"bytesInOutput":170},"src/utils/logger.ts":{"bytesInOutput":489},"src/session/direct-shell.ts":{"bytesInOutput":1071},"src/session/transcript-pages.ts":{"bytesInOutput":3825},"src/session/checkpoint.ts":{"bytesInOutput":2307},"src/tools/tool-names.ts":{"bytesInOutput":242},"src/session/lock.ts":{"bytesInOutput":3733},"src/runtime/shutdown.ts":{"bytesInOutput":400},"src/version.ts":{"bytesInOutput":17},"src/session/registry.ts":{"bytesInOutput":4614},"src/types.ts":{"bytesInOutput":9},"src/utils/path-security.ts":{"bytesInOutput":314},"src/session/execution-mode.ts":{"bytesInOutput":136},"src/session/recent-sessions.ts":{"bytesInOutput":4302},"src/utils/platform.ts":{"bytesInOutput":244},"src/session/manager.ts":{"bytesInOutput":6024},"src/session/recovery.ts":{"bytesInOutput":4149},"src/session/turn-restore.ts":{"bytesInOutput":13682}},"bytes":57492}}}
@@ -1 +1 @@
1
- {"inputs":{"src/session/id-generator.ts":{"bytes":870,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/fs.ts":{"bytes":11685,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/json.ts":{"bytes":804,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3719,"imports":[],"format":"esm"},"src/session/direct-shell.ts":{"bytes":2317,"imports":[],"format":"esm"},"src/session/transcript-pages.ts":{"bytes":9566,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/transcript.ts":{"bytes":18791,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/transcript-pages.ts","kind":"import-statement","original":"./transcript-pages.js"}],"format":"esm"},"src/tools/tool-names.ts":{"bytes":3747,"imports":[],"format":"esm"},"src/session/checkpoint.ts":{"bytes":5786,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"fs/promises","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"}],"format":"esm"},"src/runtime/shutdown.ts":{"bytes":7260,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/session/lock.ts":{"bytes":10975,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/runtime/shutdown.ts","kind":"import-statement","original":"../runtime/shutdown.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"}],"format":"esm"},"src/types.ts":{"bytes":30376,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":993,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/session/execution-mode.ts":{"bytes":313,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/recent-sessions.ts":{"bytes":15374,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/session/registry.ts":{"bytes":15052,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"}],"format":"esm"},"src/session/recovery.ts":{"bytes":11638,"imports":[{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"}],"format":"esm"},"src/session/manager.ts":{"bytes":16015,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"}],"format":"esm"},"src/session/turn-restore.ts":{"bytes":30751,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"}],"format":"esm"},"src/session/index.ts":{"bytes":1570,"imports":[{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/manager.ts","kind":"import-statement","original":"./manager.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/session/turn-restore.ts","kind":"import-statement","original":"./turn-restore.js"}],"format":"esm"}},"outputs":{"dist/session/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"fs/promises","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["CheckpointManager","DIRECT_SHELL_CONTEXT_WARNING","MAX_DIRECT_SHELL_OUTPUT_CHARS","SessionLock","SessionManager","SessionRegistry","TranscriptWriter","TurnRestoreManager","createDirectShellMessage","forgetRecentSession","forgetRecentSessionById","formatDirectShellContext","generateSessionId","getRecentSessionsIndexPath","isDirectShellMessage","isValidSessionId","loadRecentSessionsIndex","lookupRecentSession","normalizeDirectShellResultRecord","normalizeWorkingDirectory","parseSessionId","readSessionFormatVersion","recordRecentSession","recoverSessionMessages","repairInterruptedToolCalls"],"entryPoint":"src/session/index.ts","inputs":{"src/session/id-generator.ts":{"bytesInOutput":337},"src/session/index.ts":{"bytesInOutput":0},"src/session/transcript.ts":{"bytesInOutput":7903},"src/utils/fs.ts":{"bytesInOutput":1617},"src/utils/json.ts":{"bytesInOutput":170},"src/utils/logger.ts":{"bytesInOutput":489},"src/session/direct-shell.ts":{"bytesInOutput":1071},"src/session/transcript-pages.ts":{"bytesInOutput":3828},"src/session/checkpoint.ts":{"bytesInOutput":2301},"src/tools/tool-names.ts":{"bytesInOutput":242},"src/session/lock.ts":{"bytesInOutput":3729},"src/runtime/shutdown.ts":{"bytesInOutput":400},"src/version.ts":{"bytesInOutput":17},"src/session/registry.ts":{"bytesInOutput":4609},"src/types.ts":{"bytesInOutput":8},"src/utils/path-security.ts":{"bytesInOutput":310},"src/session/execution-mode.ts":{"bytesInOutput":136},"src/session/recent-sessions.ts":{"bytesInOutput":4301},"src/utils/platform.ts":{"bytesInOutput":227},"src/session/manager.ts":{"bytesInOutput":6018},"src/session/recovery.ts":{"bytesInOutput":4149},"src/session/turn-restore.ts":{"bytesInOutput":13274}},"bytes":55834}}}
1
+ {"inputs":{"src/session/id-generator.ts":{"bytes":870,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/fs.ts":{"bytes":11685,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/utils/json.ts":{"bytes":804,"imports":[],"format":"esm"},"src/utils/logger.ts":{"bytes":3719,"imports":[],"format":"esm"},"src/session/direct-shell.ts":{"bytes":2317,"imports":[],"format":"esm"},"src/session/transcript-pages.ts":{"bytes":9566,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/transcript.ts":{"bytes":18791,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/transcript-pages.ts","kind":"import-statement","original":"./transcript-pages.js"}],"format":"esm"},"src/tools/tool-names.ts":{"bytes":3779,"imports":[],"format":"esm"},"src/session/checkpoint.ts":{"bytes":5786,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"fs/promises","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"}],"format":"esm"},"src/runtime/shutdown.ts":{"bytes":7260,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/session/lock.ts":{"bytes":10975,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/runtime/shutdown.ts","kind":"import-statement","original":"../runtime/shutdown.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"}],"format":"esm"},"src/types.ts":{"bytes":30376,"imports":[],"format":"esm"},"src/utils/path-security.ts":{"bytes":993,"imports":[{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"src/session/execution-mode.ts":{"bytes":313,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/session/recent-sessions.ts":{"bytes":15374,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/session/registry.ts":{"bytes":15052,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"}],"format":"esm"},"src/session/recovery.ts":{"bytes":11638,"imports":[{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"}],"format":"esm"},"src/session/manager.ts":{"bytes":16015,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"src/utils/fs.ts","kind":"import-statement","original":"../utils/fs.js"},{"path":"src/utils/json.ts","kind":"import-statement","original":"../utils/json.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/types.ts","kind":"import-statement","original":"../types.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/utils/logger.ts","kind":"import-statement","original":"../utils/logger.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/execution-mode.ts","kind":"import-statement","original":"./execution-mode.js"}],"format":"esm"},"src/session/turn-restore.ts":{"bytes":30751,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/utils/path-security.ts","kind":"import-statement","original":"../utils/path-security.js"}],"format":"esm"},"src/session/index.ts":{"bytes":1570,"imports":[{"path":"src/session/id-generator.ts","kind":"import-statement","original":"./id-generator.js"},{"path":"src/session/transcript.ts","kind":"import-statement","original":"./transcript.js"},{"path":"src/session/checkpoint.ts","kind":"import-statement","original":"./checkpoint.js"},{"path":"src/session/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/session/registry.ts","kind":"import-statement","original":"./registry.js"},{"path":"src/session/manager.ts","kind":"import-statement","original":"./manager.js"},{"path":"src/session/recovery.ts","kind":"import-statement","original":"./recovery.js"},{"path":"src/session/direct-shell.ts","kind":"import-statement","original":"./direct-shell.js"},{"path":"src/session/recent-sessions.ts","kind":"import-statement","original":"./recent-sessions.js"},{"path":"src/session/turn-restore.ts","kind":"import-statement","original":"./turn-restore.js"}],"format":"esm"}},"outputs":{"dist/session/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"crypto","kind":"import-statement","external":true},{"path":"fs/promises","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["CheckpointManager","DIRECT_SHELL_CONTEXT_WARNING","MAX_DIRECT_SHELL_OUTPUT_CHARS","SessionLock","SessionManager","SessionRegistry","TranscriptWriter","TurnRestoreManager","createDirectShellMessage","forgetRecentSession","forgetRecentSessionById","formatDirectShellContext","generateSessionId","getRecentSessionsIndexPath","isDirectShellMessage","isValidSessionId","loadRecentSessionsIndex","lookupRecentSession","normalizeDirectShellResultRecord","normalizeWorkingDirectory","parseSessionId","readSessionFormatVersion","recordRecentSession","recoverSessionMessages","repairInterruptedToolCalls"],"entryPoint":"src/session/index.ts","inputs":{"src/session/id-generator.ts":{"bytesInOutput":337},"src/session/index.ts":{"bytesInOutput":0},"src/session/transcript.ts":{"bytesInOutput":7903},"src/utils/fs.ts":{"bytesInOutput":1617},"src/utils/json.ts":{"bytesInOutput":170},"src/utils/logger.ts":{"bytesInOutput":489},"src/session/direct-shell.ts":{"bytesInOutput":1071},"src/session/transcript-pages.ts":{"bytesInOutput":3828},"src/session/checkpoint.ts":{"bytesInOutput":2301},"src/tools/tool-names.ts":{"bytesInOutput":242},"src/session/lock.ts":{"bytesInOutput":3729},"src/runtime/shutdown.ts":{"bytesInOutput":400},"src/version.ts":{"bytesInOutput":17},"src/session/registry.ts":{"bytesInOutput":4609},"src/types.ts":{"bytesInOutput":8},"src/utils/path-security.ts":{"bytesInOutput":310},"src/session/execution-mode.ts":{"bytesInOutput":136},"src/session/recent-sessions.ts":{"bytesInOutput":4301},"src/utils/platform.ts":{"bytesInOutput":227},"src/session/manager.ts":{"bytesInOutput":6018},"src/session/recovery.ts":{"bytesInOutput":4149},"src/session/turn-restore.ts":{"bytesInOutput":13274}},"bytes":55834}}}
package/dist/ui/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var G=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(n,t)=>{for(var i in t)G(n,i,{get:t[i],enumerable:!0})},oe=(n,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!te.call(n,r)&&r!==i&&G(n,r,{get:()=>t[r],enumerable:!(e=Z(t,r))||e.enumerable});return n};var ie=n=>oe(G({},"__esModule",{value:!0}),n);var ve={};ne(ve,{XENO_UI_RENDERER_API_VERSION:()=>L,createAgentUiController:()=>B,createAgentUiView:()=>z,dispatchAgentUiAction:()=>S,isSafeMarkdownHref:()=>q,mountAgentUi:()=>Y,parseMarkdown:()=>V,xenoUiCss:()=>H,xenoUiTokens:()=>K});module.exports=ie(ve);var re={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function se(n){return re[n]??n}var ae=new Set(["Read","Glob","Grep","LS","MemoryRead","Think","dispatch_agent","ElfAnalyze","Receive","ListAgents","ListSessions","CoordinationQuery"]),le=new Set(["Write","Edit","Patch","MemoryWrite","Send","CoordinationSend"]),ce=new Set(["Bash"]);function F(n){let t=se(n);return ce.has(t)?"high":ae.has(t)?"low":(le.has(t),"medium")}var L=1;function de(n){let t=n.config;return t&&typeof t=="object"?t:null}function X(n){let t=n.tokenUsage;return{input:Number(t.input)||0,output:Number(t.output)||0,total:Number(t.total)||0}}function ue(n){let t=n.toLowerCase();return["rate limit","429","network","timeout","econnrefused","api error","unreachable"].some(i=>t.includes(i))}function B(n){let t=n.agent,i=n.now??Date.now,e=0,r=n.createId??(()=>`xeno-ui-${i()}-${++e}`),m=new Set,g=[],A="idle",R=X(t),_=null,u=null,k=null,h=null,d="",w=null,N=0,E=!1,b=!1,O=0,p=de(t),U=p?.permissionEngine,$=U?.promptFn;function C(){return Object.freeze({apiVersion:1,revision:O,items:Object.freeze([...g]),isProcessing:E,status:A,tokenUsage:Object.freeze({...R}),permissionRequest:_?Object.freeze({..._}):null,lastUserMessage:k})}function y(){O+=1;let s=C();for(let l of[...m])l(s)}function P(s){g=[...g,s],y()}function D(s){let l=[...g];for(let x=l.length-1;x>=0;x-=1){let a=l[x];if(a?.type==="message"&&a.data.role==="assistant"){l[x]={type:"message",data:s(a.data)},g=l,y();return}}}function j(s,l){let x=[...g];for(let a=x.length-1;a>=0;a-=1){let c=x[a];if(c?.type==="tool_call"&&c.data.id===s){x[a]={type:"tool_call",data:l(c.data)},g=x,y();return}}}function o(){h&&(D(s=>({...s,isStreaming:!1})),h=null,d="")}function T(s){let l={id:r(),message:s,retryable:ue(s),timestamp:i()};P({type:"error",data:l})}function f(s){p&&(p.onText=s.onText,p.onToolStart=s.onToolStart,p.onToolEnd=s.onToolEnd,p.onError=s.onError)}async function I(s){let l=s.trim();if(b||E||!l)return!1;E=!0,k=l,A="thinking",h=null,d="";let x={id:r(),role:"user",content:l,timestamp:i()};g=[...g,{type:"message",data:x}],y();let a={onText:p?.onText,onToolStart:p?.onToolStart,onToolEnd:p?.onToolEnd,onError:p?.onError};p&&(p.onText=c=>{a.onText?.(c),!b&&(d+=c,h?D(v=>({...v,content:d,isStreaming:!0})):(h=r(),P({type:"message",data:{id:h,role:"assistant",content:d,timestamp:i(),isStreaming:!0}})))},p.onToolStart=(c,v)=>{a.onToolStart?.(c,v),!b&&(o(),A="executing",w=r(),N=i(),P({type:"tool_call",data:{id:w,toolName:c,input:v,status:"running",timestamp:i()}}))},p.onToolEnd=(c,v)=>{a.onToolEnd?.(c,v),!b&&(w&&(j(w,J=>({...J,status:v.success?"success":"error",result:v,durationMs:Math.max(0,i()-N)})),w=null),A="thinking",y())},p.onError=(c,v)=>a.onError?.(c,v));try{await t.run(l),b||(o(),A="idle",R=X(t),y())}catch(c){if(!b){o();let v=c instanceof Error?c:new Error(String(c));A=v.name==="AgentInterruptedError"?"idle":"error",v.name!=="AgentInterruptedError"&&T(v.message),R=X(t),y()}}finally{E=!1,f(a),b||y()}return!0}return n.enablePermissionRequests&&U&&(U.promptFn=s=>(u&&u("deny"),new Promise(l=>{u=l,_={id:r(),toolName:s.toolName,detail:s.detail,description:s.description,operation:s.operation,preview:s.preview,riskLevel:F(s.toolName),timestamp:i(),...s.oneTime?{oneTime:!0}:{},...s.elevation?{elevation:{network:s.elevation.network,directories:[...s.elevation.directories],justification:s.elevation.justification}}:{}},y()}))),{apiVersion:1,getSnapshot:C,subscribe(s){if(b)throw new Error("Agent UI controller is disposed");return m.add(s),s(C()),()=>m.delete(s)},sendMessage:I,cancelExecution(){!b&&E&&t.cancelCurrentTurn()},clearMessages(){b||(g=[],h=null,d="",y())},retryLastMessage(){return b||E||!k?Promise.resolve(!1):(g=g.filter((s,l,x)=>s.type!=="error"?!0:x.slice(l+1).some(a=>a.type!=="error")),A="idle",y(),I(k))},resolvePermission(s,l){if(b||!_||_.id!==s||!u)return!1;_.oneTime&&l==="always"&&(l="allow");let x=u;return u=null,_=null,y(),x(l),!0},dispose(){b||(b=!0,u&&u("deny"),u=null,_=null,U&&(U.promptFn=$),m.clear())}}}function me(n){let t=[],i=[[/```([\w-]*)\n([\s\S]*?)```/,e=>({kind:"code-block",language:e[1]??"",code:e[2]??""})],[/`([^`\n]+)`/,e=>({kind:"inline-code",code:e[1]??""})],[/\*\*(.+?)\*\*/,e=>({kind:"strong",text:e[1]??""})],[/\*([^*\n]+)\*/,e=>({kind:"emphasis",text:e[1]??""})],[/\[([^\]]+)\]\(([^)\s]+)\)/,e=>({kind:"link",text:e[1]??"",href:e[2]??""})]];for(let[e,r]of i){let m=n.match(e);m?.index!==void 0&&t.push({index:m.index,value:r(m),length:m[0].length})}return t.sort((e,r)=>e.index-r.index),t[0]??null}function V(n){let t=[],i=n;for(;i;){let e=me(i);if(!e){t.push({kind:"text",text:i});break}e.index>0&&t.push({kind:"text",text:i.slice(0,e.index)}),t.push(e.value),i=i.slice(e.index+e.length)}return t}function q(n){try{let t=new URL(n,"https://xeno.invalid/");return t.protocol==="https:"||t.protocol==="http:"||t.protocol==="mailto:"}catch{return!1}}var K=Object.freeze({background:"#101214",surface:"#181b1f",surfaceRaised:"#20242a",border:"#343a42",text:"#f2f4f7",textMuted:"#aab2bd",accent:"#5da9e9",success:"#56b881",warning:"#e7b65a",danger:"#e57373",focus:"#8bc5f4"}),H=`
1
+ "use strict";var G=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(n,t)=>{for(var i in t)G(n,i,{get:t[i],enumerable:!0})},oe=(n,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!te.call(n,r)&&r!==i&&G(n,r,{get:()=>t[r],enumerable:!(e=Z(t,r))||e.enumerable});return n};var ie=n=>oe(G({},"__esModule",{value:!0}),n);var ve={};ne(ve,{XENO_UI_RENDERER_API_VERSION:()=>L,createAgentUiController:()=>B,createAgentUiView:()=>z,dispatchAgentUiAction:()=>S,isSafeMarkdownHref:()=>q,mountAgentUi:()=>Y,parseMarkdown:()=>V,xenoUiCss:()=>H,xenoUiTokens:()=>K});module.exports=ie(ve);var re={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function se(n){return re[n]??n}var ae=new Set(["Read","ToolOutput","Glob","Grep","LS","MemoryRead","Think","dispatch_agent","ElfAnalyze","Receive","ListAgents","ListSessions","CoordinationQuery"]),le=new Set(["Write","Edit","Patch","MemoryWrite","Send","CoordinationSend"]),ce=new Set(["Bash"]);function F(n){let t=se(n);return ce.has(t)?"high":ae.has(t)?"low":(le.has(t),"medium")}var L=1;function de(n){let t=n.config;return t&&typeof t=="object"?t:null}function X(n){let t=n.tokenUsage;return{input:Number(t.input)||0,output:Number(t.output)||0,total:Number(t.total)||0}}function ue(n){let t=n.toLowerCase();return["rate limit","429","network","timeout","econnrefused","api error","unreachable"].some(i=>t.includes(i))}function B(n){let t=n.agent,i=n.now??Date.now,e=0,r=n.createId??(()=>`xeno-ui-${i()}-${++e}`),m=new Set,g=[],A="idle",R=X(t),_=null,u=null,k=null,h=null,d="",w=null,N=0,E=!1,b=!1,O=0,p=de(t),U=p?.permissionEngine,$=U?.promptFn;function C(){return Object.freeze({apiVersion:1,revision:O,items:Object.freeze([...g]),isProcessing:E,status:A,tokenUsage:Object.freeze({...R}),permissionRequest:_?Object.freeze({..._}):null,lastUserMessage:k})}function y(){O+=1;let s=C();for(let l of[...m])l(s)}function P(s){g=[...g,s],y()}function D(s){let l=[...g];for(let x=l.length-1;x>=0;x-=1){let a=l[x];if(a?.type==="message"&&a.data.role==="assistant"){l[x]={type:"message",data:s(a.data)},g=l,y();return}}}function j(s,l){let x=[...g];for(let a=x.length-1;a>=0;a-=1){let c=x[a];if(c?.type==="tool_call"&&c.data.id===s){x[a]={type:"tool_call",data:l(c.data)},g=x,y();return}}}function o(){h&&(D(s=>({...s,isStreaming:!1})),h=null,d="")}function T(s){let l={id:r(),message:s,retryable:ue(s),timestamp:i()};P({type:"error",data:l})}function f(s){p&&(p.onText=s.onText,p.onToolStart=s.onToolStart,p.onToolEnd=s.onToolEnd,p.onError=s.onError)}async function I(s){let l=s.trim();if(b||E||!l)return!1;E=!0,k=l,A="thinking",h=null,d="";let x={id:r(),role:"user",content:l,timestamp:i()};g=[...g,{type:"message",data:x}],y();let a={onText:p?.onText,onToolStart:p?.onToolStart,onToolEnd:p?.onToolEnd,onError:p?.onError};p&&(p.onText=c=>{a.onText?.(c),!b&&(d+=c,h?D(v=>({...v,content:d,isStreaming:!0})):(h=r(),P({type:"message",data:{id:h,role:"assistant",content:d,timestamp:i(),isStreaming:!0}})))},p.onToolStart=(c,v)=>{a.onToolStart?.(c,v),!b&&(o(),A="executing",w=r(),N=i(),P({type:"tool_call",data:{id:w,toolName:c,input:v,status:"running",timestamp:i()}}))},p.onToolEnd=(c,v)=>{a.onToolEnd?.(c,v),!b&&(w&&(j(w,J=>({...J,status:v.success?"success":"error",result:v,durationMs:Math.max(0,i()-N)})),w=null),A="thinking",y())},p.onError=(c,v)=>a.onError?.(c,v));try{await t.run(l),b||(o(),A="idle",R=X(t),y())}catch(c){if(!b){o();let v=c instanceof Error?c:new Error(String(c));A=v.name==="AgentInterruptedError"?"idle":"error",v.name!=="AgentInterruptedError"&&T(v.message),R=X(t),y()}}finally{E=!1,f(a),b||y()}return!0}return n.enablePermissionRequests&&U&&(U.promptFn=s=>(u&&u("deny"),new Promise(l=>{u=l,_={id:r(),toolName:s.toolName,detail:s.detail,description:s.description,operation:s.operation,preview:s.preview,riskLevel:F(s.toolName),timestamp:i(),...s.oneTime?{oneTime:!0}:{},...s.elevation?{elevation:{network:s.elevation.network,directories:[...s.elevation.directories],justification:s.elevation.justification}}:{}},y()}))),{apiVersion:1,getSnapshot:C,subscribe(s){if(b)throw new Error("Agent UI controller is disposed");return m.add(s),s(C()),()=>m.delete(s)},sendMessage:I,cancelExecution(){!b&&E&&t.cancelCurrentTurn()},clearMessages(){b||(g=[],h=null,d="",y())},retryLastMessage(){return b||E||!k?Promise.resolve(!1):(g=g.filter((s,l,x)=>s.type!=="error"?!0:x.slice(l+1).some(a=>a.type!=="error")),A="idle",y(),I(k))},resolvePermission(s,l){if(b||!_||_.id!==s||!u)return!1;_.oneTime&&l==="always"&&(l="allow");let x=u;return u=null,_=null,y(),x(l),!0},dispose(){b||(b=!0,u&&u("deny"),u=null,_=null,U&&(U.promptFn=$),m.clear())}}}function me(n){let t=[],i=[[/```([\w-]*)\n([\s\S]*?)```/,e=>({kind:"code-block",language:e[1]??"",code:e[2]??""})],[/`([^`\n]+)`/,e=>({kind:"inline-code",code:e[1]??""})],[/\*\*(.+?)\*\*/,e=>({kind:"strong",text:e[1]??""})],[/\*([^*\n]+)\*/,e=>({kind:"emphasis",text:e[1]??""})],[/\[([^\]]+)\]\(([^)\s]+)\)/,e=>({kind:"link",text:e[1]??"",href:e[2]??""})]];for(let[e,r]of i){let m=n.match(e);m?.index!==void 0&&t.push({index:m.index,value:r(m),length:m[0].length})}return t.sort((e,r)=>e.index-r.index),t[0]??null}function V(n){let t=[],i=n;for(;i;){let e=me(i);if(!e){t.push({kind:"text",text:i});break}e.index>0&&t.push({kind:"text",text:i.slice(0,e.index)}),t.push(e.value),i=i.slice(e.index+e.length)}return t}function q(n){try{let t=new URL(n,"https://xeno.invalid/");return t.protocol==="https:"||t.protocol==="http:"||t.protocol==="mailto:"}catch{return!1}}var K=Object.freeze({background:"#101214",surface:"#181b1f",surfaceRaised:"#20242a",border:"#343a42",text:"#f2f4f7",textMuted:"#aab2bd",accent:"#5da9e9",success:"#56b881",warning:"#e7b65a",danger:"#e57373",focus:"#8bc5f4"}),H=`
2
2
  .xeno-ui{box-sizing:border-box;display:grid;grid-template-rows:auto minmax(12rem,1fr) auto;width:min(32rem,100%);height:min(44rem,100%);min-height:24rem;border:1px solid var(--xeno-border,#343a42);background:var(--xeno-bg,#101214);color:var(--xeno-text,#f2f4f7);font:14px/1.45 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:0}
3
3
  .xeno-ui *{box-sizing:border-box;letter-spacing:0}
4
4
  .xeno-ui__header{display:flex;align-items:center;gap:.75rem;padding:.75rem 1rem;border-bottom:1px solid var(--xeno-border,#343a42);background:var(--xeno-surface,#181b1f)}
package/dist/ui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var W={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function Q(n){return W[n]??n}var Y=new Set(["Read","Glob","Grep","LS","MemoryRead","Think","dispatch_agent","ElfAnalyze","Receive","ListAgents","ListSessions","CoordinationQuery"]),J=new Set(["Write","Edit","Patch","MemoryWrite","Send","CoordinationSend"]),Z=new Set(["Bash"]);function X(n){let t=Q(n);return Z.has(t)?"high":Y.has(t)?"low":(J.has(t),"medium")}var I=1;function ee(n){let t=n.config;return t&&typeof t=="object"?t:null}function H(n){let t=n.tokenUsage;return{input:Number(t.input)||0,output:Number(t.output)||0,total:Number(t.total)||0}}function te(n){let t=n.toLowerCase();return["rate limit","429","network","timeout","econnrefused","api error","unreachable"].some(r=>t.includes(r))}function ne(n){let t=n.agent,r=n.now??Date.now,e=0,s=n.createId??(()=>`xeno-ui-${r()}-${++e}`),m=new Set,g=[],A="idle",S=H(t),_=null,u=null,k=null,h=null,d="",w=null,R=0,E=!1,b=!1,O=0,p=ee(t),U=p?.permissionEngine,V=U?.promptFn;function C(){return Object.freeze({apiVersion:1,revision:O,items:Object.freeze([...g]),isProcessing:E,status:A,tokenUsage:Object.freeze({...S}),permissionRequest:_?Object.freeze({..._}):null,lastUserMessage:k})}function y(){O+=1;let i=C();for(let l of[...m])l(i)}function N(i){g=[...g,i],y()}function D(i){let l=[...g];for(let x=l.length-1;x>=0;x-=1){let a=l[x];if(a?.type==="message"&&a.data.role==="assistant"){l[x]={type:"message",data:i(a.data)},g=l,y();return}}}function q(i,l){let x=[...g];for(let a=x.length-1;a>=0;a-=1){let c=x[a];if(c?.type==="tool_call"&&c.data.id===i){x[a]={type:"tool_call",data:l(c.data)},g=x,y();return}}}function o(){h&&(D(i=>({...i,isStreaming:!1})),h=null,d="")}function T(i){let l={id:s(),message:i,retryable:te(i),timestamp:r()};N({type:"error",data:l})}function f(i){p&&(p.onText=i.onText,p.onToolStart=i.onToolStart,p.onToolEnd=i.onToolEnd,p.onError=i.onError)}async function L(i){let l=i.trim();if(b||E||!l)return!1;E=!0,k=l,A="thinking",h=null,d="";let x={id:s(),role:"user",content:l,timestamp:r()};g=[...g,{type:"message",data:x}],y();let a={onText:p?.onText,onToolStart:p?.onToolStart,onToolEnd:p?.onToolEnd,onError:p?.onError};p&&(p.onText=c=>{a.onText?.(c),!b&&(d+=c,h?D(v=>({...v,content:d,isStreaming:!0})):(h=s(),N({type:"message",data:{id:h,role:"assistant",content:d,timestamp:r(),isStreaming:!0}})))},p.onToolStart=(c,v)=>{a.onToolStart?.(c,v),!b&&(o(),A="executing",w=s(),R=r(),N({type:"tool_call",data:{id:w,toolName:c,input:v,status:"running",timestamp:r()}}))},p.onToolEnd=(c,v)=>{a.onToolEnd?.(c,v),!b&&(w&&(q(w,K=>({...K,status:v.success?"success":"error",result:v,durationMs:Math.max(0,r()-R)})),w=null),A="thinking",y())},p.onError=(c,v)=>a.onError?.(c,v));try{await t.run(l),b||(o(),A="idle",S=H(t),y())}catch(c){if(!b){o();let v=c instanceof Error?c:new Error(String(c));A=v.name==="AgentInterruptedError"?"idle":"error",v.name!=="AgentInterruptedError"&&T(v.message),S=H(t),y()}}finally{E=!1,f(a),b||y()}return!0}return n.enablePermissionRequests&&U&&(U.promptFn=i=>(u&&u("deny"),new Promise(l=>{u=l,_={id:s(),toolName:i.toolName,detail:i.detail,description:i.description,operation:i.operation,preview:i.preview,riskLevel:X(i.toolName),timestamp:r(),...i.oneTime?{oneTime:!0}:{},...i.elevation?{elevation:{network:i.elevation.network,directories:[...i.elevation.directories],justification:i.elevation.justification}}:{}},y()}))),{apiVersion:1,getSnapshot:C,subscribe(i){if(b)throw new Error("Agent UI controller is disposed");return m.add(i),i(C()),()=>m.delete(i)},sendMessage:L,cancelExecution(){!b&&E&&t.cancelCurrentTurn()},clearMessages(){b||(g=[],h=null,d="",y())},retryLastMessage(){return b||E||!k?Promise.resolve(!1):(g=g.filter((i,l,x)=>i.type!=="error"?!0:x.slice(l+1).some(a=>a.type!=="error")),A="idle",y(),L(k))},resolvePermission(i,l){if(b||!_||_.id!==i||!u)return!1;_.oneTime&&l==="always"&&(l="allow");let x=u;return u=null,_=null,y(),x(l),!0},dispose(){b||(b=!0,u&&u("deny"),u=null,_=null,U&&(U.promptFn=V),m.clear())}}}function oe(n){let t=[],r=[[/```([\w-]*)\n([\s\S]*?)```/,e=>({kind:"code-block",language:e[1]??"",code:e[2]??""})],[/`([^`\n]+)`/,e=>({kind:"inline-code",code:e[1]??""})],[/\*\*(.+?)\*\*/,e=>({kind:"strong",text:e[1]??""})],[/\*([^*\n]+)\*/,e=>({kind:"emphasis",text:e[1]??""})],[/\[([^\]]+)\]\(([^)\s]+)\)/,e=>({kind:"link",text:e[1]??"",href:e[2]??""})]];for(let[e,s]of r){let m=n.match(e);m?.index!==void 0&&t.push({index:m.index,value:s(m),length:m[0].length})}return t.sort((e,s)=>e.index-s.index),t[0]??null}function z(n){let t=[],r=n;for(;r;){let e=oe(r);if(!e){t.push({kind:"text",text:r});break}e.index>0&&t.push({kind:"text",text:r.slice(0,e.index)}),t.push(e.value),r=r.slice(e.index+e.length)}return t}function $(n){try{let t=new URL(n,"https://xeno.invalid/");return t.protocol==="https:"||t.protocol==="http:"||t.protocol==="mailto:"}catch{return!1}}var ie=Object.freeze({background:"#101214",surface:"#181b1f",surfaceRaised:"#20242a",border:"#343a42",text:"#f2f4f7",textMuted:"#aab2bd",accent:"#5da9e9",success:"#56b881",warning:"#e7b65a",danger:"#e57373",focus:"#8bc5f4"}),j=`
1
+ var W={View:"Read",Replace:"Write",GlobTool:"Glob",GrepTool:"Grep",SQLiteAnalyze:"SqliteAnalyze",ReadNotebook:"NotebookRead",NotebookEditCell:"NotebookEdit",CoordinationSend:"Send",CoordinationQuery:"Receive"};function Q(n){return W[n]??n}var Y=new Set(["Read","ToolOutput","Glob","Grep","LS","MemoryRead","Think","dispatch_agent","ElfAnalyze","Receive","ListAgents","ListSessions","CoordinationQuery"]),J=new Set(["Write","Edit","Patch","MemoryWrite","Send","CoordinationSend"]),Z=new Set(["Bash"]);function X(n){let t=Q(n);return Z.has(t)?"high":Y.has(t)?"low":(J.has(t),"medium")}var I=1;function ee(n){let t=n.config;return t&&typeof t=="object"?t:null}function H(n){let t=n.tokenUsage;return{input:Number(t.input)||0,output:Number(t.output)||0,total:Number(t.total)||0}}function te(n){let t=n.toLowerCase();return["rate limit","429","network","timeout","econnrefused","api error","unreachable"].some(r=>t.includes(r))}function ne(n){let t=n.agent,r=n.now??Date.now,e=0,s=n.createId??(()=>`xeno-ui-${r()}-${++e}`),m=new Set,g=[],A="idle",S=H(t),_=null,u=null,k=null,h=null,d="",w=null,R=0,E=!1,b=!1,O=0,p=ee(t),U=p?.permissionEngine,V=U?.promptFn;function C(){return Object.freeze({apiVersion:1,revision:O,items:Object.freeze([...g]),isProcessing:E,status:A,tokenUsage:Object.freeze({...S}),permissionRequest:_?Object.freeze({..._}):null,lastUserMessage:k})}function y(){O+=1;let i=C();for(let l of[...m])l(i)}function N(i){g=[...g,i],y()}function D(i){let l=[...g];for(let x=l.length-1;x>=0;x-=1){let a=l[x];if(a?.type==="message"&&a.data.role==="assistant"){l[x]={type:"message",data:i(a.data)},g=l,y();return}}}function q(i,l){let x=[...g];for(let a=x.length-1;a>=0;a-=1){let c=x[a];if(c?.type==="tool_call"&&c.data.id===i){x[a]={type:"tool_call",data:l(c.data)},g=x,y();return}}}function o(){h&&(D(i=>({...i,isStreaming:!1})),h=null,d="")}function T(i){let l={id:s(),message:i,retryable:te(i),timestamp:r()};N({type:"error",data:l})}function f(i){p&&(p.onText=i.onText,p.onToolStart=i.onToolStart,p.onToolEnd=i.onToolEnd,p.onError=i.onError)}async function L(i){let l=i.trim();if(b||E||!l)return!1;E=!0,k=l,A="thinking",h=null,d="";let x={id:s(),role:"user",content:l,timestamp:r()};g=[...g,{type:"message",data:x}],y();let a={onText:p?.onText,onToolStart:p?.onToolStart,onToolEnd:p?.onToolEnd,onError:p?.onError};p&&(p.onText=c=>{a.onText?.(c),!b&&(d+=c,h?D(v=>({...v,content:d,isStreaming:!0})):(h=s(),N({type:"message",data:{id:h,role:"assistant",content:d,timestamp:r(),isStreaming:!0}})))},p.onToolStart=(c,v)=>{a.onToolStart?.(c,v),!b&&(o(),A="executing",w=s(),R=r(),N({type:"tool_call",data:{id:w,toolName:c,input:v,status:"running",timestamp:r()}}))},p.onToolEnd=(c,v)=>{a.onToolEnd?.(c,v),!b&&(w&&(q(w,K=>({...K,status:v.success?"success":"error",result:v,durationMs:Math.max(0,r()-R)})),w=null),A="thinking",y())},p.onError=(c,v)=>a.onError?.(c,v));try{await t.run(l),b||(o(),A="idle",S=H(t),y())}catch(c){if(!b){o();let v=c instanceof Error?c:new Error(String(c));A=v.name==="AgentInterruptedError"?"idle":"error",v.name!=="AgentInterruptedError"&&T(v.message),S=H(t),y()}}finally{E=!1,f(a),b||y()}return!0}return n.enablePermissionRequests&&U&&(U.promptFn=i=>(u&&u("deny"),new Promise(l=>{u=l,_={id:s(),toolName:i.toolName,detail:i.detail,description:i.description,operation:i.operation,preview:i.preview,riskLevel:X(i.toolName),timestamp:r(),...i.oneTime?{oneTime:!0}:{},...i.elevation?{elevation:{network:i.elevation.network,directories:[...i.elevation.directories],justification:i.elevation.justification}}:{}},y()}))),{apiVersion:1,getSnapshot:C,subscribe(i){if(b)throw new Error("Agent UI controller is disposed");return m.add(i),i(C()),()=>m.delete(i)},sendMessage:L,cancelExecution(){!b&&E&&t.cancelCurrentTurn()},clearMessages(){b||(g=[],h=null,d="",y())},retryLastMessage(){return b||E||!k?Promise.resolve(!1):(g=g.filter((i,l,x)=>i.type!=="error"?!0:x.slice(l+1).some(a=>a.type!=="error")),A="idle",y(),L(k))},resolvePermission(i,l){if(b||!_||_.id!==i||!u)return!1;_.oneTime&&l==="always"&&(l="allow");let x=u;return u=null,_=null,y(),x(l),!0},dispose(){b||(b=!0,u&&u("deny"),u=null,_=null,U&&(U.promptFn=V),m.clear())}}}function oe(n){let t=[],r=[[/```([\w-]*)\n([\s\S]*?)```/,e=>({kind:"code-block",language:e[1]??"",code:e[2]??""})],[/`([^`\n]+)`/,e=>({kind:"inline-code",code:e[1]??""})],[/\*\*(.+?)\*\*/,e=>({kind:"strong",text:e[1]??""})],[/\*([^*\n]+)\*/,e=>({kind:"emphasis",text:e[1]??""})],[/\[([^\]]+)\]\(([^)\s]+)\)/,e=>({kind:"link",text:e[1]??"",href:e[2]??""})]];for(let[e,s]of r){let m=n.match(e);m?.index!==void 0&&t.push({index:m.index,value:s(m),length:m[0].length})}return t.sort((e,s)=>e.index-s.index),t[0]??null}function z(n){let t=[],r=n;for(;r;){let e=oe(r);if(!e){t.push({kind:"text",text:r});break}e.index>0&&t.push({kind:"text",text:r.slice(0,e.index)}),t.push(e.value),r=r.slice(e.index+e.length)}return t}function $(n){try{let t=new URL(n,"https://xeno.invalid/");return t.protocol==="https:"||t.protocol==="http:"||t.protocol==="mailto:"}catch{return!1}}var ie=Object.freeze({background:"#101214",surface:"#181b1f",surfaceRaised:"#20242a",border:"#343a42",text:"#f2f4f7",textMuted:"#aab2bd",accent:"#5da9e9",success:"#56b881",warning:"#e7b65a",danger:"#e57373",focus:"#8bc5f4"}),j=`
2
2
  .xeno-ui{box-sizing:border-box;display:grid;grid-template-rows:auto minmax(12rem,1fr) auto;width:min(32rem,100%);height:min(44rem,100%);min-height:24rem;border:1px solid var(--xeno-border,#343a42);background:var(--xeno-bg,#101214);color:var(--xeno-text,#f2f4f7);font:14px/1.45 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:0}
3
3
  .xeno-ui *{box-sizing:border-box;letter-spacing:0}
4
4
  .xeno-ui__header{display:flex;align-items:center;gap:.75rem;padding:.75rem 1rem;border-bottom:1px solid var(--xeno-border,#343a42);background:var(--xeno-surface,#181b1f)}
@@ -1 +1 @@
1
- {"inputs":{"src/tools/tool-names.ts":{"bytes":3747,"imports":[],"format":"esm"},"src/ui/types.ts":{"bytes":4678,"imports":[],"format":"esm"},"src/ui/controller.ts":{"bytes":10914,"imports":[{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/markdown.ts":{"bytes":2181,"imports":[],"format":"esm"},"src/ui/styles.ts":{"bytes":4255,"imports":[],"format":"esm"},"src/ui/view-model.ts":{"bytes":4490,"imports":[{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/dom-renderer.ts":{"bytes":12031,"imports":[{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"}],"format":"esm"},"src/ui/index.ts":{"bytes":1059,"imports":[{"path":"src/ui/controller.ts","kind":"import-statement","original":"./controller.js"},{"path":"src/ui/dom-renderer.ts","kind":"import-statement","original":"./dom-renderer.js"},{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"}},"outputs":{"dist/ui/index.cjs":{"imports":[],"exports":[],"entryPoint":"src/ui/index.ts","inputs":{"src/ui/index.ts":{"bytesInOutput":257},"src/tools/tool-names.ts":{"bytesInOutput":580},"src/ui/types.ts":{"bytesInOutput":8},"src/ui/controller.ts":{"bytesInOutput":3559},"src/ui/markdown.ts":{"bytesInOutput":864},"src/ui/styles.ts":{"bytesInOutput":4161},"src/ui/view-model.ts":{"bytesInOutput":2338},"src/ui/dom-renderer.ts":{"bytesInOutput":6248}},"bytes":18633}}}
1
+ {"inputs":{"src/tools/tool-names.ts":{"bytes":3779,"imports":[],"format":"esm"},"src/ui/types.ts":{"bytes":4678,"imports":[],"format":"esm"},"src/ui/controller.ts":{"bytes":10914,"imports":[{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/markdown.ts":{"bytes":2181,"imports":[],"format":"esm"},"src/ui/styles.ts":{"bytes":4255,"imports":[],"format":"esm"},"src/ui/view-model.ts":{"bytes":4490,"imports":[{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/dom-renderer.ts":{"bytes":12031,"imports":[{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"}],"format":"esm"},"src/ui/index.ts":{"bytes":1059,"imports":[{"path":"src/ui/controller.ts","kind":"import-statement","original":"./controller.js"},{"path":"src/ui/dom-renderer.ts","kind":"import-statement","original":"./dom-renderer.js"},{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"}},"outputs":{"dist/ui/index.cjs":{"imports":[],"exports":[],"entryPoint":"src/ui/index.ts","inputs":{"src/ui/index.ts":{"bytesInOutput":257},"src/tools/tool-names.ts":{"bytesInOutput":593},"src/ui/types.ts":{"bytesInOutput":8},"src/ui/controller.ts":{"bytesInOutput":3559},"src/ui/markdown.ts":{"bytesInOutput":864},"src/ui/styles.ts":{"bytesInOutput":4161},"src/ui/view-model.ts":{"bytesInOutput":2338},"src/ui/dom-renderer.ts":{"bytesInOutput":6248}},"bytes":18646}}}
@@ -1 +1 @@
1
- {"inputs":{"src/tools/tool-names.ts":{"bytes":3747,"imports":[],"format":"esm"},"src/ui/types.ts":{"bytes":4678,"imports":[],"format":"esm"},"src/ui/controller.ts":{"bytes":10914,"imports":[{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/markdown.ts":{"bytes":2181,"imports":[],"format":"esm"},"src/ui/styles.ts":{"bytes":4255,"imports":[],"format":"esm"},"src/ui/view-model.ts":{"bytes":4490,"imports":[{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/dom-renderer.ts":{"bytes":12031,"imports":[{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"}],"format":"esm"},"src/ui/index.ts":{"bytes":1059,"imports":[{"path":"src/ui/controller.ts","kind":"import-statement","original":"./controller.js"},{"path":"src/ui/dom-renderer.ts","kind":"import-statement","original":"./dom-renderer.js"},{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"}},"outputs":{"dist/ui/index.js":{"imports":[],"exports":["XENO_UI_RENDERER_API_VERSION","createAgentUiController","createAgentUiView","dispatchAgentUiAction","isSafeMarkdownHref","mountAgentUi","parseMarkdown","xenoUiCss","xenoUiTokens"],"entryPoint":"src/ui/index.ts","inputs":{"src/tools/tool-names.ts":{"bytesInOutput":570},"src/ui/types.ts":{"bytesInOutput":8},"src/ui/controller.ts":{"bytesInOutput":3560},"src/ui/index.ts":{"bytesInOutput":0},"src/ui/markdown.ts":{"bytesInOutput":864},"src/ui/styles.ts":{"bytesInOutput":4162},"src/ui/view-model.ts":{"bytesInOutput":2338},"src/ui/dom-renderer.ts":{"bytesInOutput":6249}},"bytes":17970}}}
1
+ {"inputs":{"src/tools/tool-names.ts":{"bytes":3779,"imports":[],"format":"esm"},"src/ui/types.ts":{"bytes":4678,"imports":[],"format":"esm"},"src/ui/controller.ts":{"bytes":10914,"imports":[{"path":"src/tools/tool-names.ts","kind":"import-statement","original":"../tools/tool-names.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/markdown.ts":{"bytes":2181,"imports":[],"format":"esm"},"src/ui/styles.ts":{"bytes":4255,"imports":[],"format":"esm"},"src/ui/view-model.ts":{"bytes":4490,"imports":[{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/ui/dom-renderer.ts":{"bytes":12031,"imports":[{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"}],"format":"esm"},"src/ui/index.ts":{"bytes":1059,"imports":[{"path":"src/ui/controller.ts","kind":"import-statement","original":"./controller.js"},{"path":"src/ui/dom-renderer.ts","kind":"import-statement","original":"./dom-renderer.js"},{"path":"src/ui/markdown.ts","kind":"import-statement","original":"./markdown.js"},{"path":"src/ui/styles.ts","kind":"import-statement","original":"./styles.js"},{"path":"src/ui/view-model.ts","kind":"import-statement","original":"./view-model.js"},{"path":"src/ui/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"}},"outputs":{"dist/ui/index.js":{"imports":[],"exports":["XENO_UI_RENDERER_API_VERSION","createAgentUiController","createAgentUiView","dispatchAgentUiAction","isSafeMarkdownHref","mountAgentUi","parseMarkdown","xenoUiCss","xenoUiTokens"],"entryPoint":"src/ui/index.ts","inputs":{"src/tools/tool-names.ts":{"bytesInOutput":583},"src/ui/types.ts":{"bytesInOutput":8},"src/ui/controller.ts":{"bytesInOutput":3560},"src/ui/index.ts":{"bytesInOutput":0},"src/ui/markdown.ts":{"bytesInOutput":864},"src/ui/styles.ts":{"bytesInOutput":4162},"src/ui/view-model.ts":{"bytesInOutput":2338},"src/ui/dom-renderer.ts":{"bytesInOutput":6249}},"bytes":17983}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenosystem/agent-sdk",
3
- "version": "0.10.18",
3
+ "version": "0.10.19",
4
4
  "description": "XENO Agent SDK built from the same engine as XENO CODE",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",