@xenosystem/agent-sdk 0.10.35 → 0.10.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/index.cjs +9 -9
- package/dist/agents/index.d.cts +4 -1
- package/dist/agents/index.d.ts +4 -1
- package/dist/agents/index.js +16 -16
- package/dist/agents/metafile-cjs.json +1 -1
- package/dist/agents/metafile-esm.json +1 -1
- package/dist/artifacts/index.cjs +1 -1
- package/dist/artifacts/index.js +1 -1
- package/dist/artifacts/metafile-cjs.json +1 -1
- package/dist/artifacts/metafile-esm.json +1 -1
- package/dist/automation/index.cjs +35 -24
- package/dist/automation/index.d.cts +194 -12
- package/dist/automation/index.d.ts +194 -12
- package/dist/automation/index.js +35 -24
- package/dist/automation/metafile-cjs.json +1 -1
- package/dist/automation/metafile-esm.json +1 -1
- package/dist/control-plane/index.cjs +8 -8
- package/dist/control-plane/index.js +8 -8
- package/dist/control-plane/metafile-cjs.json +1 -1
- package/dist/control-plane/metafile-esm.json +1 -1
- package/dist/coordination/index.cjs +2 -2
- package/dist/coordination/index.js +2 -2
- package/dist/coordination/metafile-cjs.json +1 -1
- package/dist/coordination/metafile-esm.json +1 -1
- package/dist/electron/index.cjs +243 -223
- package/dist/electron/index.d.cts +198 -1
- package/dist/electron/index.d.ts +198 -1
- package/dist/electron/index.js +243 -223
- package/dist/electron/metafile-cjs.json +1 -1
- package/dist/electron/metafile-esm.json +1 -1
- package/dist/hosted/metafile-cjs.json +1 -1
- package/dist/hosted/metafile-esm.json +1 -1
- package/dist/index.cjs +406 -395
- package/dist/index.d.cts +325 -172
- package/dist/index.d.ts +325 -172
- package/dist/index.js +406 -395
- package/dist/intelligence/index.cjs +4 -4
- package/dist/intelligence/index.js +4 -4
- package/dist/intelligence/metafile-cjs.json +1 -1
- package/dist/intelligence/metafile-esm.json +1 -1
- package/dist/mcp/index.cjs +20 -20
- package/dist/mcp/index.d.cts +146 -0
- package/dist/mcp/index.d.ts +146 -0
- package/dist/mcp/index.js +17 -17
- package/dist/mcp/metafile-cjs.json +1 -1
- package/dist/mcp/metafile-esm.json +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/index.cjs +10 -10
- package/dist/providers/index.d.cts +49 -5
- package/dist/providers/index.d.ts +49 -5
- package/dist/providers/index.js +10 -10
- package/dist/providers/metafile-cjs.json +1 -1
- package/dist/providers/metafile-esm.json +1 -1
- package/dist/recipes/metafile-cjs.json +1 -1
- package/dist/recipes/metafile-esm.json +1 -1
- package/dist/research/metafile-cjs.json +1 -1
- package/dist/research/metafile-esm.json +1 -1
- package/dist/session/index.cjs +24 -24
- package/dist/session/index.js +16 -16
- package/dist/session/metafile-cjs.json +1 -1
- package/dist/session/metafile-esm.json +1 -1
- package/dist/sharing/index.cjs +1 -1
- package/dist/sharing/index.js +3 -3
- package/dist/sharing/metafile-cjs.json +1 -1
- package/dist/sharing/metafile-esm.json +1 -1
- package/dist/skills/index.d.cts +6 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/utils/index.cjs +24 -24
- package/dist/utils/index.d.cts +14 -2
- package/dist/utils/index.d.ts +14 -2
- package/dist/utils/index.js +24 -24
- package/dist/utils/metafile-cjs.json +1 -1
- package/dist/utils/metafile-esm.json +1 -1
- package/ownership/evidence/PROPRIETARY-PTY-1/implementation-record.md +1 -1
- package/ownership/ownership-policy.json +14 -3
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{randomUUID as
|
|
2
|
-
`,{encoding:"utf8",flag:"wx"})}function
|
|
3
|
-
`,"utf8"),u}finally{i.release()}}read(e){return
|
|
4
|
-
`,"utf8"),
|
|
5
|
-
`,"utf8"),
|
|
6
|
-
`,"utf8"),o}readEvents(e){let t=this.eventsPath(e);return
|
|
7
|
-
`,"utf8"),t}query(e={}){return Et(this.path)?Dt(this.path,"utf8").split(/\r?\n/).filter(Boolean).flatMap(t=>{try{let r=JSON.parse(t);return _t(r,e)?[r]:[]}catch{return[]}}):[]}summarize(e={}){let t=new
|
|
8
|
-
`,"utf8");try{Ot(t,s)}catch(r){throw z(t,{force:!0}),r}}function I(s){let e=s.replace(/[^A-Za-z0-9._-]/gu,"_");if(!e||e==="."||e==="..")throw new Error(`Invalid identifier: ${s}`);return e}function J(s){return C(s)?K(s).filter(e=>e.endsWith(".json")).map(e=>p(s,e)):[]}var Jt=new Int32Array(new SharedArrayBuffer(4));function _(s,e,t){let r=Date.now()+5e3;for(;;){let n;try{n=x(s,e,String(k))}catch(o){if(!/already locked/u.test(o instanceof Error?o.message:String(o))||Date.now()>r)throw o;Atomics.wait(Jt,0,0,10);continue}try{return t()}finally{n.release()}}}function Kt(){return p(v(),"control-plane","peers")}var De=class{directory;now;options;constructor(e=Kt(),t={}){this.directory=e,this.now=t.now??(()=>Date.now()),this.options={maxPerSenderPerWindow:t.maxPerSenderPerWindow??M.maxPerSenderPerWindow,windowMs:t.windowMs??M.windowMs,maxQueuedPerRecipient:t.maxQueuedPerRecipient??M.maxQueuedPerRecipient,maxHeldPerRecipient:t.maxHeldPerRecipient??M.maxHeldPerRecipient,maxChainDepth:t.maxChainDepth??M.maxChainDepth,presenceTtlMs:t.presenceTtlMs??Wt,defaultTtlMs:t.defaultTtlMs??Lt},q(p(this.directory,"presence"),{recursive:!0}),q(p(this.directory,"mailbox"),{recursive:!0}),q(p(this.directory,"locks"),{recursive:!0})}presencePath(e){return p(this.directory,"presence",`${I(e)}.json`)}presenceLock(e){return p(this.directory,"locks",`presence-${I(e)}.lock`)}registerSession(e){let t=A(this.now()),r={schemaVersion:k,sessionId:e.sessionId,incarnationId:e.incarnationId??`inc_${re().replaceAll("-","").slice(0,16)}`,...e.name?{name:e.name}:{},host:Ut(),owner:zt(),pid:process.pid,workspace:e.workspace,surface:e.surface??"cli",state:e.state??"idle",inboundPolicy:e.inboundPolicy??"accept",posture:e.posture??"unknown",capabilities:[...e.capabilities??[]],startedAt:t,heartbeatAt:t,...e.parentSessionId?{parentSessionId:e.parentSessionId}:{},...e.dockedAgents?{dockedAgents:e.dockedAgents}:{}};return _(this.presenceLock(e.sessionId),"peer-presence",()=>(H(this.presencePath(e.sessionId),r),r))}heartbeat(e,t,r={}){return _(this.presenceLock(e),"peer-presence",()=>{let n=S(this.presencePath(e));if(!n||n.schemaVersion!==k||n.incarnationId!==t)return null;let o={...n,...Bt(r),heartbeatAt:A(this.now())};return r.name===void 0&&"name"in r&&delete o.name,H(this.presencePath(e),o),o})}unregisterSession(e,t){return _(this.presenceLock(e),"peer-presence",()=>{let r=S(this.presencePath(e));return!r||r.incarnationId!==t?!1:(z(this.presencePath(e),{force:!0}),!0)})}getPresence(e){let t=S(this.presencePath(e));return t&&t.schemaVersion===k?this.withLiveness(t):null}listSessions(e={}){let t=[];for(let r of J(p(this.directory,"presence"))){let n=S(r);if(!n||n.schemaVersion!==k)continue;let o=this.withLiveness(n);o.state==="offline"&&e.includeOffline===!1||t.push(o)}return t.sort((r,n)=>(r.name??"").localeCompare(n.name??"")||r.sessionId.localeCompare(n.sessionId))}withLiveness(e){return Date.parse(e.heartbeatAt)+this.options.presenceTtlMs<this.now()?{...e,state:"offline"}:e}mailboxDir(e){return p(this.directory,"mailbox",I(e))}messagePath(e,t){return p(this.mailboxDir(e),`${I(t)}.json`)}messageLock(e){return p(this.directory,"locks",`message-${I(e)}.lock`)}send(e){let t=e.text.trim();if(!t)return{status:"refused",reason:"A message needs text."};if(!e.from.sessionId||!e.to.sessionId)return{status:"refused",reason:"A message needs a sender and a recipient session."};if(e.from.sessionId===e.to.sessionId)return{status:"refused",reason:"A session cannot message itself."};let r=this.getPresence(e.to.sessionId);if(!r)return{status:"refused",reason:`Unknown peer session ${e.to.sessionId}; it has never registered here.`};let n=this.getPresence(e.from.sessionId),o=this.now();if(this.listSent(e.from.sessionId).filter(l=>Date.parse(l.createdAt)>o-this.options.windowMs).length>=this.options.maxPerSenderPerWindow)return{status:"refused",reason:`Rate limit: ${this.options.maxPerSenderPerWindow} messages per ${Math.round(this.options.windowMs/1e3)}s.`};let a=0;if(e.causedBy){let l=this.find(e.causedBy);if(a=l?l.chainDepth+1:1,a>this.options.maxChainDepth)return{status:"refused",reason:`Causal chain depth ${a} exceeds ${this.options.maxChainDepth}; this exchange is looping.`}}if(e.idempotencyKey){let l=this.inbox(e.to.sessionId).find(E=>E.from.sessionId===e.from.sessionId&&E.idempotencyKey===e.idempotencyKey);if(l)return l.delivery.status==="held"?{status:"held",message:l,reason:l.delivery.reason??"held"}:{status:"queued",message:l}}let u=this.inbox(e.to.sessionId),R=u.filter(l=>l.delivery.status==="queued").length,g=u.filter(l=>l.delivery.status==="held").length,c=e.kind??"message",f=r.inboundPolicy==="hold"?`${te(r)} holds incoming messages for its human.`:r.inboundPolicy==="refuse"?void 0:n&&Ht(n.posture,r.posture)?`Sender runs with ${n.posture} and the receiver with ${r.posture}; a message never moves trust upward.`:void 0;if(r.inboundPolicy==="refuse")return{status:"refused",reason:`${te(r)} is not accepting messages.`};if(f?g>=this.options.maxHeldPerRecipient:R>=this.options.maxQueuedPerRecipient)return{status:"refused",reason:`${te(r)} has ${f?"too many held":"too many queued"} messages; try again after it drains.`};let h=A(o),d={schemaVersion:k,messageId:`msg_${re().replaceAll("-","").slice(0,20)}`,...e.idempotencyKey?{idempotencyKey:e.idempotencyKey}:{},kind:c,from:{sessionId:e.from.sessionId,...e.from.incarnationId?{incarnationId:e.from.incarnationId}:{},...e.from.name??n?.name?{name:e.from.name??n?.name}:{},...e.from.host??n?.host?{host:e.from.host??n?.host}:{},...e.from.workspace??n?.workspace?{workspace:e.from.workspace??n?.workspace}:{}},to:{sessionId:r.sessionId,...r.name?{name:r.name}:{},host:r.host,workspace:r.workspace},text:t,...e.correlationId?{correlationId:e.correlationId}:{},...e.causedBy?{causedBy:e.causedBy}:{},chainDepth:a,createdAt:h,updatedAt:h,expiresAt:A(o+(e.ttlMs??this.options.defaultTtlMs)),delivery:f?{status:"held",at:h,reason:f}:{status:"queued",at:h},...c==="task"?{task:{status:"offered",at:h}}:{}};return q(this.mailboxDir(r.sessionId),{recursive:!0}),_(this.messageLock(d.messageId),"peer-message",()=>{H(this.messagePath(r.sessionId,d.messageId),d)}),f?{status:"held",message:d,reason:f}:{status:"queued",message:d}}inbox(e){return J(this.mailboxDir(e)).map(t=>S(t)).filter(t=>!!t&&t.schemaVersion===k).sort((t,r)=>t.createdAt.localeCompare(r.createdAt)||t.messageId.localeCompare(r.messageId))}listSent(e){let t=[],r=p(this.directory,"mailbox");if(!C(r))return t;for(let n of K(r)){let o=p(r,n);if($t(o).isDirectory())for(let i of J(o)){let a=S(i);a&&a.schemaVersion===k&&a.from.sessionId===e&&t.push(a)}}return t.sort((n,o)=>n.createdAt.localeCompare(o.createdAt)||n.messageId.localeCompare(o.messageId))}find(e){let t=p(this.directory,"mailbox");if(!C(t))return null;let r=`${I(e)}.json`;for(let n of K(t)){let o=p(t,n,r);if(C(o)){let i=S(o);return i&&i.schemaVersion===k?i:null}}return null}mutate(e,t){return _(this.messageLock(e),"peer-message",()=>{let r=this.find(e);if(!r)throw new Error(`Unknown peer message ${e}.`);let n=t(r);return n.updatedAt=A(this.now()),H(this.messagePath(n.to.sessionId,n.messageId),n),n})}setDelivery(e,t,r={}){return this.mutate(e,n=>{if(!qt[n.delivery.status].includes(t))throw new Error(`Invalid peer delivery transition ${n.delivery.status} -> ${t} for ${e}.`);let o={status:t,at:A(this.now()),...r.reason?{reason:r.reason}:{},...r.incarnationId?{incarnationId:r.incarnationId}:{}},i={...n,delivery:o};return i.task&&!F(i.task.status)&&(t==="refused"||t==="expired"||t==="cancelled")&&(i.task={...i.task,status:"cancelled",at:o.at,endedAt:o.at,error:r.reason??`Delivery ${t}.`}),i})}release(e){return this.setDelivery(e,"queued",{reason:"Released by the receiving session."})}receive(e,t){return this.setDelivery(e,"received",{incarnationId:t})}setTask(e,t,r={}){return this.mutate(e,n=>{if(!n.task)throw new Error(`Peer message ${e} is a ${n.kind}, not a task.`);if(!Ft[n.task.status].includes(t))throw new Error(`Invalid peer task transition ${n.task.status} -> ${t} for ${e}.`);let o=A(this.now()),i={...n.task,status:t,at:o};return t==="running"&&(i.startedAt=o,r.executorIncarnationId&&(i.executorIncarnationId=r.executorIncarnationId)),(F(t)||t==="recovery-required")&&(i.endedAt=o),r.result!==void 0&&(i.result=r.result),r.error!==void 0&&(i.error=r.error),r.reportMessageId&&(i.reportMessageId=r.reportMessageId),{...n,task:i}})}requestCancel(e,t="Cancelled by sender."){let r=this.find(e);if(!r)throw new Error(`Unknown peer message ${e}.`);return r.delivery.status==="queued"||r.delivery.status==="held"?this.setDelivery(e,"cancelled",{reason:t}):r.task&&!F(r.task.status)?r.task.status==="offered"||r.task.status==="accepted"||r.task.status==="blocked"||r.task.status==="recovery-required"?this.setTask(e,"cancelled",{error:t}):this.mutate(e,n=>({...n,task:{...n.task,cancelRequestedAt:A(this.now())}})):r}expireStale(e){let t=this.now(),r=[];for(let n of this.inbox(e))(n.delivery.status==="queued"||n.delivery.status==="held")&&Date.parse(n.expiresAt)<=t&&r.push(this.setDelivery(n.messageId,"expired",{reason:"Not received before it expired."}));return r}reconcileAbandonedTasks(e,t){let r=[];for(let n of this.inbox(e)){let o=n.task;!o||o.status!=="running"||o.executorIncarnationId!==t&&r.push(this.setTask(n.messageId,"recovery-required",{error:`The executing process (incarnation ${o.executorIncarnationId??"unknown"}) exited before the task finished; inspect its side effects before re-delegating.`}))}return r}compact(e=10080*60*1e3){let t=this.now()-e,r=0,n=0,o=p(this.directory,"mailbox");if(C(o))for(let i of K(o))for(let a of J(p(o,i))){let u=S(a);if(!u)continue;u.delivery.status!=="queued"&&u.delivery.status!=="held"&&(!u.task||F(u.task.status)||u.task.status==="recovery-required")&&Date.parse(u.updatedAt)<t&&(z(a,{force:!0}),r+=1)}for(let i of this.listSessions())i.state==="offline"&&Date.parse(i.heartbeatAt)<t&&(z(this.presencePath(i.sessionId),{force:!0}),n+=1);return{messages:r,presence:n}}};function zt(){try{return Vt().username}catch{return process.env.USERNAME??process.env.USER??"unknown"}}function Bt(s){let e={};for(let[t,r]of Object.entries(s))r!==void 0&&(e[t]=r);return e}export{D as AGENT_DAEMON_PROTOCOL_VERSION,we as AgentDaemonClient,he as AgentDaemonServer,O as AgentEventStore,fe as AgentRunController,V as AgentRunStore,Ae as MonitorManager,xe as MonitorStopTool,Se as MonitorTool,Ee as OtelExporter,Lt as PEER_MESSAGE_DEFAULT_TTL_MS,Wt as PEER_PRESENCE_TTL_MS,k as PEER_SCHEMA_VERSION,jt as PEER_TASK_TERMINAL_STATUSES,De as PeerMessagingStore,ee as UsageAccumulator,Ie as UsageLedger,T as WorkflowPlanner,ve as WorkflowRuntime,Y as WorkflowStore,x as acquireControlPlaneLock,mt as createAgentRunId,Kt as defaultPeerDirectory,vr as getAgentRunDir,Rr as getAgentRunStoreDir,F as isPeerTaskTerminal,Ht as movesTrustUpward,Te as peerShortId,te as renderPeerLabel,Jr as resolvePeerTarget,Hr as toPeerPosture};
|
|
1
|
+
import{createHash as ze,randomUUID as Ge}from"node:crypto";import{existsSync as Qe,mkdirSync as J,readFileSync as Ze,readdirSync as Ye,renameSync as et,rmSync as tt,writeFileSync as $}from"node:fs";import{basename as le,dirname as rt,join as w,resolve as nt}from"node:path";var E="0.10.37";import{mkdirSync as Oe,readFileSync as Me,rmSync as ne,writeFileSync as _e}from"node:fs";import{hostname as se}from"node:os";import{dirname as Ce}from"node:path";function Ne(){return new Date().toISOString()}function $e(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function oe(s){try{return JSON.parse(Me(s,"utf8"))}catch{return null}}function Ve(s){if(!s||s<=0)return!1;try{return process.kill(s,0),!0}catch{return!1}}function Ue(s){return s.hostname!==se()?!0:Ve(s.pid)}function re(s,e){Oe(Ce(s),{recursive:!0}),_e(s,JSON.stringify(e,null,2)+`
|
|
2
|
+
`,{encoding:"utf8",flag:"wx"})}function Le(s,e){let t=oe(s);t?.pid!==e.pid||t.hostname!==e.hostname||ne(s,{force:!0})}function x(s,e,t){let r=Ne(),n={schemaVersion:1,name:e,pid:process.pid,hostname:se(),processStartedAt:$e(),version:t,acquiredAt:r,updatedAt:r};try{re(s,n)}catch(o){if(o.code!=="EEXIST")throw o;let a=oe(s);if(a&&Ue(a))throw new Error(`${e} is already locked by PID ${a.pid} on ${a.hostname}.`);ne(s,{force:!0}),re(s,n)}return{record:n,release:()=>{Le(s,n)}}}import{randomUUID as We}from"node:crypto";import{appendFileSync as Ke,existsSync as Be,mkdirSync as ie,readFileSync as Xe}from"node:fs";import{basename as qe,dirname as Fe,join as He}from"node:path";function ae(s){return qe(s).replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,96)}function ue(s){return Be(s)?Xe(s,"utf8").split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(e=>e!==null):[]}var C=class{constructor(e){this.runsDir=e;ie(this.runsDir,{recursive:!0})}runsDir;pathFor(e){return He(this.runsDir,ae(e),"events.jsonl")}append(e,t,r={},n=new Date().toISOString()){let o=this.pathFor(e);ie(Fe(o),{recursive:!0});let i=x(`${o}.lock`,`events:${ae(e)}`,E);try{let a=ue(o).reduce((P,p,c)=>Math.max(P,p.sequence??c),-1)+1,u={schemaVersion:1,eventId:`event_${We()}`,sequence:a,runId:e,type:t,timestamp:n,payload:r};return Ke(o,`${JSON.stringify(u)}
|
|
3
|
+
`,"utf8"),u}finally{i.release()}}read(e){return ue(this.pathFor(e))}tail(e,t=100){let r=Math.max(0,Math.min(1e4,Math.trunc(t)));return r===0?[]:this.read(e).slice(-r)}};import{homedir as de,platform as je,release as Je}from"node:os";import{delimiter as lr,join as pr,resolve as ce}from"node:path";var gr=je();var fr=Je(),hr=de();function y(){let s=process.env.XENO_AGENT_HOME?.trim();return s?ce(s):ce(de(),".xeno-agent")}var st=1,ot=w(y(),"daemon"),z=w(ot,"runs");function g(){return new Date().toISOString()}function it(s=new Date){return s.toISOString().replace(/[^0-9]/g,"").slice(0,14)}function pe(s){return s.replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,80)}function G(s){return nt(s)}function V(s){return G(s).toLowerCase()}function me(s,e){let t=V(s),r=V(e);return t===r||t.startsWith(`${r}\\`)||t.startsWith(`${r}/`)}function at(s,e){return!!(V(s.cwd)===V(e)||s.git?.root&&me(e,s.git.root)||s.git?.worktree&&me(e,s.git.worktree))}function ut(s){let e=G(s);return`workspace_${ze("sha256").update(process.platform==="win32"?e.toLowerCase():e).digest("hex")}`}function ct(){return{input:0,output:0,total:0}}function N(s){try{return JSON.parse(Ze(s,"utf8"))}catch{return null}}function dt(s){return s instanceof Error&&/\balready locked by PID\b/.test(s.message)}function lt(s,e){J(rt(s),{recursive:!0});let t=`${s}.${process.pid}.${Date.now()}.tmp`;$(t,JSON.stringify(e,null,2)+`
|
|
4
|
+
`,"utf8"),et(t,s)}function pt(s){if(!s||s<=0)return!1;try{return process.kill(s,0),!0}catch{return!1}}function mt(s){return s==="completed"||s==="failed"||s==="cancelled"||s==="interrupted"}function gt(s,e){return s.pinned!==e.pinned?s.pinned?-1:1:Date.parse(e.updatedAt)-Date.parse(s.updatedAt)}function xr(){return z}function Ir(s){return w(z,s)}function ft(s=new Date){return`run_${it(s)}_${Ge().slice(0,8)}`}var U=class{constructor(e=z){this.runsDir=e;J(this.runsDir,{recursive:!0}),this.eventStore=new C(this.runsDir)}runsDir;eventStore;create(e){let t=ft(),r=w(this.runsDir,t);J(r,{recursive:!0});let n=g(),o=w(r,"events.jsonl"),i={schemaVersion:st,runId:t,sessionId:t,rootRunId:t,cwd:G(e.cwd),workspaceId:ut(e.cwd),prompt:e.prompt,...e.title?{title:e.title}:{},status:"starting",model:e.model,...e.effort?{effort:e.effort}:{},...e.agent?{agent:e.agent}:{},...e.git?{git:e.git}:{},permissionMode:e.permissionMode,...e.cliVersion?{createdByCliVersion:e.cliVersion}:{},createdBySdkVersion:e.sdkVersion??E,createdAt:n,updatedAt:n,lastActivityAt:n,pinned:!!e.pinned,attachedClients:0,...e.cliVersion?{cliVersion:e.cliVersion}:{},...e.sdkVersion?{sdkVersion:e.sdkVersion}:{},stdoutPath:w(r,"stdout.log"),stderrPath:w(r,"stderr.log"),eventsPath:o,usage:ct(),children:[],tags:[]};return $(i.stdoutPath,"","utf8"),$(i.stderrPath,"","utf8"),$(i.eventsPath,"","utf8"),this.write(i),this.appendEvent(t,"run_created",{cwd:i.cwd,model:i.model,...i.agent?{agent:i.agent}:{},...i.git?{git:i.git}:{},permissionMode:i.permissionMode,pinned:i.pinned}),i}get(e){let t=N(this.recordPath(e));return t?this.refreshRecordStatus(t):null}list(e={}){if(!Qe(this.runsDir))return[];let t=Ye(this.runsDir,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>{try{return this.get(r.name)}catch(n){if(dt(n))return N(this.recordPath(r.name));throw n}}).filter(r=>r!==null).filter(r=>e.all||!e.cwd||at(r,e.cwd)).filter(r=>!e.status||e.status.includes(r.status)).sort(gt);return typeof e.limit=="number"&&e.limit>0?t.slice(0,e.limit):t}markSpawned(e,t,r){return this.update(e,n=>({...n,status:"running",workerPid:t,...r?{workerVersion:r}:{},startedAt:n.startedAt??g(),lastActivityAt:g()}))}markStarted(e,t){return this.update(e,r=>({...r,status:"running",workerPid:t.pid,...t.workerVersion?{workerVersion:t.workerVersion}:{},...t.model?{model:t.model}:{},...t.effort?{effort:t.effort}:{},startedAt:r.startedAt??g(),lastActivityAt:g()}))}markCompleted(e,t){return this.update(e,r=>({...r,status:t.status,...t.statusReason?{statusReason:t.statusReason}:{},exitCode:t.exitCode??null,usage:t.usage??r.usage,endedAt:g(),lastActivityAt:g()}))}markCancelled(e,t){return this.update(e,r=>({...r,status:"cancelled",statusReason:t,endedAt:g(),lastActivityAt:g()}))}markPaused(e,t="Paused by user."){let r=this.update(e,n=>({...n,status:"paused",statusReason:t,lastActivityAt:g()}));return r&&this.appendEvent(e,"run_paused",{reason:t}),r}markResumed(e,t="Resumed by user."){let r=this.update(e,n=>{let o={...n,status:"running",statusReason:t,lastActivityAt:g()};return delete o.endedAt,delete o.exitCode,o});return r&&this.appendEvent(e,"run_resumed",{reason:t}),r}setPinned(e,t){let r=this.update(e,n=>({...n,pinned:t,lastActivityAt:g()}));return r&&this.appendEvent(e,t?"run_pinned":"run_unpinned",{pinned:t}),r}appendEvent(e,t,r={}){let n=N(this.recordPath(e)),o=this.eventStore.append(e,t,r);n&&this.update(e,i=>({...i,lastActivityAt:o.timestamp}))}readEvents(e){return this.get(e)?this.eventStore.read(e):[]}delete(e){tt(w(this.runsDir,e),{recursive:!0,force:!0})}refreshRecordStatus(e){if(mt(e.status))return e;if(e.workerPid&&!pt(e.workerPid)){let t={...e,status:"failed",statusReason:"Worker process is no longer running and did not record a terminal status.",endedAt:e.endedAt??g(),updatedAt:g()};return this.write(t),t}return e}update(e,t){let r=N(this.recordPath(e));if(!r)return null;let n=t(r);return n.updatedAt=g(),this.write(n),n}write(e){let t=x(w(this.runDir(e.runId),"run.lock"),`run:${e.runId}`,E);try{lt(this.recordPath(e.runId),e)}finally{t.release()}}recordPath(e){return w(this.runsDir,pe(le(e)),"run.json")}runDir(e){return w(this.runsDir,pe(le(e)))}};function ge(s){return s==="completed"||s==="failed"||s==="cancelled"||s==="interrupted"}var fe=class{constructor(e={}){this.options=e;this.store=e.store??new U}options;store;create(e){return this.store.create(e)}async start(e){let t=this.create(e);if(!this.options.spawn)return t;try{let r=await this.options.spawn(t),n=this.store.markSpawned(t.runId,r.pid,r.workerVersion);if(!n)throw new Error(`Run disappeared during spawn: ${t.runId}`);return this.store.appendEvent(t.runId,"run_started",{pid:r.pid}),n}catch(r){let n=r instanceof Error?r.message:String(r);throw this.store.markCompleted(t.runId,{status:"failed",statusReason:n,exitCode:null}),this.store.appendEvent(t.runId,"run_start_failed",{reason:n}),r}}get(e){return this.store.get(e)}list(e={}){return this.store.list(e)}events(e,t){let r=this.store.readEvents(e);return t===void 0?r:r.slice(-Math.max(0,Math.trunc(t)))}async stop(e,t="Stopped by user."){let r=this.store.get(e);if(!r||ge(r.status))return r;await this.options.stop?.(r,t);let n=this.store.markCancelled(e,t);return n&&this.store.appendEvent(e,"run_cancelled",{reason:t}),n}async pause(e,t="Paused by user."){let r=this.store.get(e);return!r||ge(r.status)||r.status==="paused"?r:(await this.options.pause?.(r,t),this.store.markPaused(e,t))}async resume(e,t="Resumed by user."){let r=this.store.get(e);return!r||r.status!=="paused"?r:(await this.options.resume?.(r,t),this.store.markResumed(e,t))}complete(e,t,r={}){let n=this.store.markCompleted(e,{status:t,...r.reason?{statusReason:r.reason}:{},...r.exitCode!==void 0?{exitCode:r.exitCode}:{},...r.usage?{usage:r.usage}:{}});return n&&this.store.appendEvent(e,`run_${t}`,{...r.reason?{reason:r.reason}:{}}),n}};import{randomUUID as ht,timingSafeEqual as wt}from"node:crypto";var T=1;function kt(s,e){if(!s)return!1;let t=Buffer.from(s),r=Buffer.from(e);return t.length===r.length&&wt(t,r)}var he=class{constructor(e={}){this.options=e}options;handlers=new Map;register(e,t){let r=e.trim();if(!r)throw new Error("Daemon method name cannot be empty.");if(this.handlers.has(r))throw new Error(`Daemon method already registered: ${r}`);return this.handlers.set(r,t),this}registerController(e){return this.register("runs.start",t=>e.start(t)).register("runs.get",t=>e.get(t.runId)).register("runs.list",t=>e.list(t??{})).register("runs.events",t=>{let r=t;return e.events(r.runId,r.limit)}).register("runs.stop",t=>{let r=t;return e.stop(r.runId,r.reason)}).register("runs.pause",t=>{let r=t;return e.pause(r.runId,r.reason)}).register("runs.resume",t=>{let r=t;return e.resume(r.runId,r.reason)})}async handle(e){if(e.protocolVersion!==T)return this.error(e.id,"PROTOCOL_MISMATCH",`Unsupported protocol version: ${e.protocolVersion}`);if(this.options.authToken&&!kt(e.authToken,this.options.authToken))return this.error(e.id,"UNAUTHORIZED","Daemon authentication failed.");let t=this.handlers.get(e.method);if(!t)return this.error(e.id,"METHOD_NOT_FOUND",`Unknown daemon method: ${e.method}`);try{return{protocolVersion:T,id:e.id,result:await t(e.params,e)}}catch(r){return this.error(e.id,"INTERNAL_ERROR",r instanceof Error?r.message:String(r))}}error(e,t,r){return{protocolVersion:T,id:e,error:{code:t,message:r}}}},we=class{constructor(e,t={}){this.transport=e;this.options=t}transport;options;async request(e,t){let r={protocolVersion:T,id:`request_${ht()}`,method:e,params:t,...this.options.authToken?{authToken:this.options.authToken}:{}},n=await this.transport(r);if(n.protocolVersion!==T||n.id!==r.id)throw new Error("Invalid daemon response identity.");if("error"in n){let o=new Error(n.error.message);throw o.code=n.error.code,o}return n.result}};import{randomUUID as ke}from"node:crypto";import{appendFileSync as Pt,existsSync as yt,mkdirSync as W,readFileSync as Re,readdirSync as Rt,renameSync as vt,writeFileSync as At}from"node:fs";import{basename as St,dirname as ve,join as R}from"node:path";function L(s){return St(s).replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,96)}function Q(s){try{return JSON.parse(Re(s,"utf8"))}catch{return null}}function Pe(s,e){W(ve(s),{recursive:!0});let t=`${s}.${process.pid}.${Date.now()}.tmp`;At(t,`${JSON.stringify(e,null,2)}
|
|
5
|
+
`,"utf8"),vt(t,s)}var D=class{plan(e){if(e.schemaVersion!==1)throw new Error("Unsupported workflow schema version.");if(!e.id.trim()||!e.name.trim())throw new Error("Workflow id and name are required.");let t=new Map;for(let i of e.nodes){if(!i.id.trim())throw new Error("Workflow node id cannot be empty.");if(t.has(i.id))throw new Error(`Duplicate workflow node: ${i.id}`);t.set(i.id,i)}for(let i of e.nodes)for(let a of i.dependsOn??[]){if(!t.has(a))throw new Error(`Workflow node ${i.id} depends on unknown node ${a}.`);if(a===i.id)throw new Error(`Workflow node ${i.id} cannot depend on itself.`)}let r=new Set(t.keys()),n=new Set,o=[];for(;r.size>0;){let i=[...r].filter(a=>(t.get(a)?.dependsOn??[]).every(u=>n.has(u))).sort();if(i.length===0)throw new Error("Workflow dependency graph contains a cycle.");o.push(i);for(let a of i)r.delete(a),n.add(a)}return{workflowId:e.id,waves:o}}},Z=class{constructor(e=R(y(),"workflows")){this.rootDir=e;W(this.definitionsDir(),{recursive:!0}),W(this.runsDir(),{recursive:!0})}rootDir;saveDefinition(e){return new D().plan(e),Pe(R(this.definitionsDir(),`${L(e.id)}.json`),e),e}getDefinition(e){return Q(R(this.definitionsDir(),`${L(e)}.json`))}listDefinitions(){return Rt(this.definitionsDir(),{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(".json")).map(e=>Q(R(this.definitionsDir(),e.name))).filter(e=>e!==null)}createRun(e){new D().plan(e);let t=new Date().toISOString(),r={schemaVersion:1,runId:`workflow_run_${ke()}`,workflowId:e.id,status:"queued",createdAt:t,updatedAt:t,nodes:Object.fromEntries(e.nodes.map(n=>[n.id,{status:"pending"}]))};return this.writeRun(r),this.appendEvent(r.runId,"workflow_created",{}),r}getRun(e){return Q(this.runPath(e))}updateRun(e,t){let r=this.getRun(e);if(!r)throw new Error(`Workflow run not found: ${e}`);let n=t(r);return n.updatedAt=new Date().toISOString(),this.writeRun(n),n}appendEvent(e,t,r,n){let o={schemaVersion:1,eventId:`workflow_event_${ke()}`,runId:e,type:t,timestamp:new Date().toISOString(),...n?{nodeId:n}:{},payload:r},i=this.eventsPath(e);return W(ve(i),{recursive:!0}),Pt(i,`${JSON.stringify(o)}
|
|
6
|
+
`,"utf8"),o}readEvents(e){let t=this.eventsPath(e);return yt(t)?Re(t,"utf8").split(/\r?\n/).filter(Boolean).flatMap(r=>{try{return[JSON.parse(r)]}catch{return[]}}):[]}writeRun(e){Pe(this.runPath(e.runId),e)}definitionsDir(){return R(this.rootDir,"definitions")}runsDir(){return R(this.rootDir,"runs")}runPath(e){return R(this.runsDir(),L(e),"run.json")}eventsPath(e){return R(this.runsDir(),L(e),"events.jsonl")}},ye=class{constructor(e=new Z,t=new D){this.store=e;this.planner=t}store;planner;async run(e,t){let r=this.planner.plan(e),n=this.store.createRun(e);n=this.store.updateRun(n.runId,a=>({...a,status:"running"})),this.store.appendEvent(n.runId,"workflow_started",{waves:r.waves.length});let o=Math.max(1,Math.trunc(e.maxConcurrency??4)),i=!1;for(let a of r.waves)for(let u=0;u<a.length;u+=o){let P=a.slice(u,u+o);await Promise.all(P.map(async p=>{let c=e.nodes.find(d=>d.id===p);if((c.dependsOn??[]).some(d=>this.store.getRun(n.runId)?.nodes[d]?.status!=="completed")||i&&e.failFast!==!1){this.store.updateRun(n.runId,d=>({...d,nodes:{...d.nodes,[p]:{status:"skipped",completedAt:new Date().toISOString()}}})),this.store.appendEvent(n.runId,"node_skipped",{},p);return}let h=new Date().toISOString();n=this.store.updateRun(n.runId,d=>({...d,nodes:{...d.nodes,[p]:{status:"running",startedAt:h}}})),this.store.appendEvent(n.runId,"node_started",{},p);try{let d=await t(c,{run:n,definition:e});this.store.updateRun(n.runId,l=>({...l,nodes:{...l.nodes,[p]:{status:"completed",startedAt:h,completedAt:new Date().toISOString(),output:d}}})),this.store.appendEvent(n.runId,"node_completed",{},p)}catch(d){i=!0;let l=d instanceof Error?d.message:String(d);this.store.updateRun(n.runId,b=>({...b,nodes:{...b.nodes,[p]:{status:"failed",startedAt:h,completedAt:new Date().toISOString(),error:l}}})),this.store.appendEvent(n.runId,"node_failed",{error:l},p)}}))}return n=this.store.updateRun(n.runId,a=>({...a,status:i?"failed":"completed",completedAt:new Date().toISOString()})),this.store.appendEvent(n.runId,i?"workflow_failed":"workflow_completed",{}),n}};import{randomUUID as xt}from"node:crypto";var Ae=class{constructor(e=1e4){this.maxEvents=e;if(!Number.isInteger(e)||e<1)throw new Error("maxEvents must be a positive integer.")}maxEvents;sources=new Map;events=[];register(e){if(!e.id.trim())throw new Error("Monitor source id cannot be empty.");if(this.sources.has(e.id))throw new Error(`Monitor source already registered: ${e.id}`);return this.sources.set(e.id,{source:e,running:!1}),this}async start(e,t=1e3){let r=this.require(e);if(r.running)return this.snapshot(e);await r.source.start?.(),r.running=!0,await this.poll(e);let n=Math.max(25,Math.trunc(t));return r.timer=setInterval(()=>{this.poll(e).catch(()=>{})},n),r.timer.unref?.(),this.snapshot(e)}async poll(e){let n=(await this.require(e).source.poll()).map(o=>({schemaVersion:1,eventId:`monitor_event_${xt()}`,sourceId:e,type:o.type,timestamp:o.timestamp??new Date().toISOString(),payload:o.payload}));return this.events.push(...n),this.events.length>this.maxEvents&&this.events.splice(0,this.events.length-this.maxEvents),n}async stop(e){let t=this.require(e);return t.timer&&clearInterval(t.timer),t.timer=void 0,t.running&&await t.source.stop?.(),t.running=!1,this.snapshot(e)}async stopAll(){await Promise.all([...this.sources.keys()].map(e=>this.stop(e)))}snapshot(e,t=100){let r=this.require(e);return{sourceId:e,running:r.running,events:this.events.filter(n=>n.sourceId===e).slice(-Math.max(0,Math.trunc(t)))}}list(){return[...this.sources].map(([e,t])=>({sourceId:e,running:t.running}))}require(e){let t=this.sources.get(e);if(!t)throw new Error(`Monitor source not found: ${e}`);return t}},Se=class{constructor(e){this.manager=e}manager;execute(e){return this.manager.start(e.sourceId,e.intervalMs)}},xe=class{constructor(e){this.manager=e}manager;execute(e){return this.manager.stop(e.sourceId)}};import{randomUUID as It}from"node:crypto";import{appendFileSync as bt,existsSync as Et,mkdirSync as Tt,readFileSync as Dt}from"node:fs";import{dirname as Ot,join as Mt}from"node:path";function v(s){return Number.isFinite(s)?Math.max(0,s??0):0}var Y=class{totalsValue={inputTokens:0,outputTokens:0,totalTokens:0,cachedInputTokens:0,estimatedCostUsd:0,events:0};add(e){let t=v(e.inputTokens),r=v(e.outputTokens);return this.totalsValue.inputTokens+=t,this.totalsValue.outputTokens+=r,this.totalsValue.totalTokens+=t+r,this.totalsValue.cachedInputTokens+=v(e.cachedInputTokens),this.totalsValue.estimatedCostUsd+=v(e.estimatedCostUsd),this.totalsValue.events+=1,this}snapshot(){return{...this.totalsValue}}};function _t(s,e){if(["runId","sessionId","workflowRunId","agentId","provider","model"].some(n=>e[n]!==void 0&&s[n]!==e[n]))return!1;let r=Date.parse(s.timestamp);return!(e.from&&r<Date.parse(e.from)||e.to&&r>Date.parse(e.to))}var Ie=class{path;constructor(e=Mt(y(),"usage","events.jsonl")){this.path=e,Tt(Ot(e),{recursive:!0})}append(e){let t={...e,schemaVersion:1,eventId:`usage_${It()}`,timestamp:e.timestamp??new Date().toISOString(),inputTokens:v(e.inputTokens),outputTokens:v(e.outputTokens),...e.cachedInputTokens!==void 0?{cachedInputTokens:v(e.cachedInputTokens)}:{},...e.estimatedCostUsd!==void 0?{estimatedCostUsd:v(e.estimatedCostUsd)}:{}};return bt(this.path,`${JSON.stringify(t)}
|
|
7
|
+
`,"utf8"),t}query(e={}){return Et(this.path)?Dt(this.path,"utf8").split(/\r?\n/).filter(Boolean).flatMap(t=>{try{let r=JSON.parse(t);return _t(r,e)?[r]:[]}catch{return[]}}):[]}summarize(e={}){let t=new Y;for(let r of this.query(e))t.add(r);return t.snapshot()}},be=class{constructor(e){this.adapter=e}adapter;export(e){for(let t of e){let r={...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{}};this.adapter.addCounter("xeno.usage.input_tokens",t.inputTokens,r),this.adapter.addCounter("xeno.usage.output_tokens",t.outputTokens,r),t.cachedInputTokens&&this.adapter.addCounter("xeno.usage.cached_input_tokens",t.cachedInputTokens,r),t.estimatedCostUsd&&this.adapter.addCounter("xeno.usage.estimated_cost_usd",t.estimatedCostUsd,r),this.adapter.recordEvent?.("xeno.usage.recorded",r)}}};import{randomUUID as te}from"node:crypto";import{existsSync as _,mkdirSync as K,readFileSync as Ct,readdirSync as H,renameSync as Nt,rmSync as j,statSync as $t,writeFileSync as Vt}from"node:fs";import{hostname as Ut,userInfo as Lt}from"node:os";import{join as m}from"node:path";var k=2,Wt=3e4,Kt=1440*60*1e3,Ee={unknown:0,plan:0,default:1,acceptEdits:2,bypassPermissions:3},O={maxPerSenderPerWindow:20,windowMs:6e4,maxQueuedPerRecipient:50,maxHeldPerRecipient:20,maxChainDepth:8},Bt={queued:["held","received","refused","expired","cancelled"],held:["queued","received","refused","expired","cancelled"],received:[],refused:[],expired:[],cancelled:[]},Xt={offered:["accepted","cancelled","blocked"],accepted:["running","cancelled","blocked"],running:["completed","failed","cancelled","recovery-required"],blocked:["accepted","cancelled"],"recovery-required":["cancelled"],completed:[],failed:[],cancelled:[]},qt=["completed","failed","cancelled"];function B(s){return qt.includes(s)}function Ft(s,e){return Ee[s]>Ee[e]}function Gr(s){switch((s??"").trim()){case"plan":case"default":case"acceptEdits":case"bypassPermissions":return s;case"full-access":return"bypassPermissions";default:return"unknown"}}function De(s){return s.replace(/[^a-z0-9]/giu,"").slice(-6).toLowerCase()||s}function ee(s){let e=`[${De(s.sessionId)}]`;return s.name?`${s.name} \u2442 ${e}`:`unnamed \u2442 ${e}`}function X(s){return s.normalize("NFC").replace(/\s+/gu," ").trim().toLowerCase()}function Qr(s,e,t){let r=e.trim();if(!r)return{kind:"unknown"};let n=s.filter(c=>c.sessionId!==t),o=n.find(c=>c.sessionId===r);if(o)return{kind:"resolved",peer:o};let i=/^(.*?)\s*(?:⑂\s*)?\[([a-z0-9]{4,})\]\s*$/iu.exec(r),a=(i?i[2]:r).toLowerCase(),u=n.filter(c=>De(c.sessionId)===a||!i&&/^[a-z0-9]{6,}$/iu.test(r)&&c.sessionId.toLowerCase().startsWith(r.toLowerCase()));if(i){let c=i[1]?X(i[1]):"",f=u.filter(h=>!c||X(h.name??"")===c);return f.length===1?{kind:"resolved",peer:f[0]}:f.length>1?{kind:"ambiguous",candidates:f}:{kind:"unknown"}}if(u.length===1)return{kind:"resolved",peer:u[0]};if(u.length>1)return{kind:"ambiguous",candidates:u};let P=X(r),p=n.filter(c=>c.name&&X(c.name)===P);if(p.length===1)return{kind:"resolved",peer:p[0]};if(p.length>1){let c=p.filter(f=>f.state!=="offline");return c.length===1?{kind:"resolved",peer:c[0]}:{kind:"ambiguous",candidates:p}}return{kind:"unknown"}}function A(s){return new Date(s).toISOString()}function S(s){try{return JSON.parse(Ct(s,"utf8"))}catch{return null}}function q(s,e){let t=`${s}.${process.pid}.${te().slice(0,8)}.tmp`;Vt(t,`${JSON.stringify(e,null,2)}
|
|
8
|
+
`,"utf8");try{Nt(t,s)}catch(r){throw j(t,{force:!0}),r}}function I(s){let e=s.replace(/[^A-Za-z0-9._-]/gu,"_");if(!e||e==="."||e==="..")throw new Error(`Invalid identifier: ${s}`);return e}function F(s){return _(s)?H(s).filter(e=>e.endsWith(".json")).map(e=>m(s,e)):[]}var Ht=new Int32Array(new SharedArrayBuffer(4));function M(s,e,t){let r=Date.now()+5e3;for(;;){let n;try{n=x(s,e,String(k))}catch(o){if(!/already locked/u.test(o instanceof Error?o.message:String(o))||Date.now()>r)throw o;Atomics.wait(Ht,0,0,10);continue}try{return t()}finally{n.release()}}}function jt(){return m(y(),"control-plane","peers")}var Te=class{directory;now;options;constructor(e=jt(),t={}){this.directory=e,this.now=t.now??(()=>Date.now()),this.options={maxPerSenderPerWindow:t.maxPerSenderPerWindow??O.maxPerSenderPerWindow,windowMs:t.windowMs??O.windowMs,maxQueuedPerRecipient:t.maxQueuedPerRecipient??O.maxQueuedPerRecipient,maxHeldPerRecipient:t.maxHeldPerRecipient??O.maxHeldPerRecipient,maxChainDepth:t.maxChainDepth??O.maxChainDepth,presenceTtlMs:t.presenceTtlMs??Wt,defaultTtlMs:t.defaultTtlMs??Kt},K(m(this.directory,"presence"),{recursive:!0}),K(m(this.directory,"mailbox"),{recursive:!0}),K(m(this.directory,"locks"),{recursive:!0})}presencePath(e){return m(this.directory,"presence",`${I(e)}.json`)}presenceLock(e){return m(this.directory,"locks",`presence-${I(e)}.lock`)}registerSession(e){let t=A(this.now()),r={schemaVersion:k,sessionId:e.sessionId,incarnationId:e.incarnationId??`inc_${te().replaceAll("-","").slice(0,16)}`,...e.name?{name:e.name}:{},host:Ut(),owner:Jt(),pid:process.pid,workspace:e.workspace,surface:e.surface??"cli",state:e.state??"idle",inboundPolicy:e.inboundPolicy??"accept",posture:e.posture??"unknown",capabilities:[...e.capabilities??[]],startedAt:t,heartbeatAt:t,...e.parentSessionId?{parentSessionId:e.parentSessionId}:{},...e.dockedAgents?{dockedAgents:e.dockedAgents}:{}};return M(this.presenceLock(e.sessionId),"peer-presence",()=>(q(this.presencePath(e.sessionId),r),r))}heartbeat(e,t,r={}){return M(this.presenceLock(e),"peer-presence",()=>{let n=S(this.presencePath(e));if(!n||n.schemaVersion!==k||n.incarnationId!==t)return null;let o={...n,...zt(r),heartbeatAt:A(this.now())};return r.name===void 0&&"name"in r&&delete o.name,q(this.presencePath(e),o),o})}unregisterSession(e,t){return M(this.presenceLock(e),"peer-presence",()=>{let r=S(this.presencePath(e));return!r||r.incarnationId!==t?!1:(j(this.presencePath(e),{force:!0}),!0)})}getPresence(e){let t=S(this.presencePath(e));return t&&t.schemaVersion===k?this.withLiveness(t):null}listSessions(e={}){let t=[];for(let r of F(m(this.directory,"presence"))){let n=S(r);if(!n||n.schemaVersion!==k)continue;let o=this.withLiveness(n);o.state==="offline"&&e.includeOffline===!1||t.push(o)}return t.sort((r,n)=>(r.name??"").localeCompare(n.name??"")||r.sessionId.localeCompare(n.sessionId))}withLiveness(e){return Date.parse(e.heartbeatAt)+this.options.presenceTtlMs<this.now()?{...e,state:"offline"}:e}mailboxDir(e){return m(this.directory,"mailbox",I(e))}messagePath(e,t){return m(this.mailboxDir(e),`${I(t)}.json`)}messageLock(e){return m(this.directory,"locks",`message-${I(e)}.lock`)}send(e){let t=e.text.trim();if(!t)return{status:"refused",reason:"A message needs text."};if(!e.from.sessionId||!e.to.sessionId)return{status:"refused",reason:"A message needs a sender and a recipient session."};if(e.from.sessionId===e.to.sessionId)return{status:"refused",reason:"A session cannot message itself."};let r=this.getPresence(e.to.sessionId);if(!r)return{status:"refused",reason:`Unknown peer session ${e.to.sessionId}; it has never registered here.`};let n=this.getPresence(e.from.sessionId),o=this.now();if(this.listSent(e.from.sessionId).filter(l=>Date.parse(l.createdAt)>o-this.options.windowMs).length>=this.options.maxPerSenderPerWindow)return{status:"refused",reason:`Rate limit: ${this.options.maxPerSenderPerWindow} messages per ${Math.round(this.options.windowMs/1e3)}s.`};let a=0;if(e.causedBy){let l=this.find(e.causedBy);if(a=l?l.chainDepth+1:1,a>this.options.maxChainDepth)return{status:"refused",reason:`Causal chain depth ${a} exceeds ${this.options.maxChainDepth}; this exchange is looping.`}}if(e.idempotencyKey){let l=this.inbox(e.to.sessionId).find(b=>b.from.sessionId===e.from.sessionId&&b.idempotencyKey===e.idempotencyKey);if(l)return l.delivery.status==="held"?{status:"held",message:l,reason:l.delivery.reason??"held"}:{status:"queued",message:l}}let u=this.inbox(e.to.sessionId),P=u.filter(l=>l.delivery.status==="queued").length,p=u.filter(l=>l.delivery.status==="held").length,c=e.kind??"message",f=r.inboundPolicy==="hold"?`${ee(r)} holds incoming messages for its human.`:r.inboundPolicy==="refuse"?void 0:n&&Ft(n.posture,r.posture)?`Sender runs with ${n.posture} and the receiver with ${r.posture}; a message never moves trust upward.`:void 0;if(r.inboundPolicy==="refuse")return{status:"refused",reason:`${ee(r)} is not accepting messages.`};if(f?p>=this.options.maxHeldPerRecipient:P>=this.options.maxQueuedPerRecipient)return{status:"refused",reason:`${ee(r)} has ${f?"too many held":"too many queued"} messages; try again after it drains.`};let h=A(o),d={schemaVersion:k,messageId:`msg_${te().replaceAll("-","").slice(0,20)}`,...e.idempotencyKey?{idempotencyKey:e.idempotencyKey}:{},kind:c,from:{sessionId:e.from.sessionId,...e.from.incarnationId?{incarnationId:e.from.incarnationId}:{},...e.from.name??n?.name?{name:e.from.name??n?.name}:{},...e.from.host??n?.host?{host:e.from.host??n?.host}:{},...e.from.workspace??n?.workspace?{workspace:e.from.workspace??n?.workspace}:{}},to:{sessionId:r.sessionId,...r.name?{name:r.name}:{},host:r.host,workspace:r.workspace},text:t,...e.correlationId?{correlationId:e.correlationId}:{},...e.causedBy?{causedBy:e.causedBy}:{},chainDepth:a,createdAt:h,updatedAt:h,expiresAt:A(o+(e.ttlMs??this.options.defaultTtlMs)),delivery:f?{status:"held",at:h,reason:f}:{status:"queued",at:h},...c==="task"?{task:{status:"offered",at:h}}:{}};return K(this.mailboxDir(r.sessionId),{recursive:!0}),M(this.messageLock(d.messageId),"peer-message",()=>{q(this.messagePath(r.sessionId,d.messageId),d)}),f?{status:"held",message:d,reason:f}:{status:"queued",message:d}}inbox(e){return F(this.mailboxDir(e)).map(t=>S(t)).filter(t=>!!t&&t.schemaVersion===k).sort((t,r)=>t.createdAt.localeCompare(r.createdAt)||t.messageId.localeCompare(r.messageId))}listSent(e){let t=[],r=m(this.directory,"mailbox");if(!_(r))return t;for(let n of H(r)){let o=m(r,n);if($t(o).isDirectory())for(let i of F(o)){let a=S(i);a&&a.schemaVersion===k&&a.from.sessionId===e&&t.push(a)}}return t.sort((n,o)=>n.createdAt.localeCompare(o.createdAt)||n.messageId.localeCompare(o.messageId))}find(e){let t=m(this.directory,"mailbox");if(!_(t))return null;let r=`${I(e)}.json`;for(let n of H(t)){let o=m(t,n,r);if(_(o)){let i=S(o);return i&&i.schemaVersion===k?i:null}}return null}mutate(e,t){return M(this.messageLock(e),"peer-message",()=>{let r=this.find(e);if(!r)throw new Error(`Unknown peer message ${e}.`);let n=t(r);return n.updatedAt=A(this.now()),q(this.messagePath(n.to.sessionId,n.messageId),n),n})}setDelivery(e,t,r={}){return this.mutate(e,n=>{if(!Bt[n.delivery.status].includes(t))throw new Error(`Invalid peer delivery transition ${n.delivery.status} -> ${t} for ${e}.`);let o={status:t,at:A(this.now()),...r.reason?{reason:r.reason}:{},...r.incarnationId?{incarnationId:r.incarnationId}:{}},i={...n,delivery:o};return i.task&&!B(i.task.status)&&(t==="refused"||t==="expired"||t==="cancelled")&&(i.task={...i.task,status:"cancelled",at:o.at,endedAt:o.at,error:r.reason??`Delivery ${t}.`}),i})}release(e){return this.setDelivery(e,"queued",{reason:"Released by the receiving session."})}receive(e,t){return this.setDelivery(e,"received",{incarnationId:t})}setTask(e,t,r={}){return this.mutate(e,n=>{if(!n.task)throw new Error(`Peer message ${e} is a ${n.kind}, not a task.`);if(!Xt[n.task.status].includes(t))throw new Error(`Invalid peer task transition ${n.task.status} -> ${t} for ${e}.`);let o=A(this.now()),i={...n.task,status:t,at:o};return t==="running"&&(i.startedAt=o,r.executorIncarnationId&&(i.executorIncarnationId=r.executorIncarnationId)),(B(t)||t==="recovery-required")&&(i.endedAt=o),r.result!==void 0&&(i.result=r.result),r.error!==void 0&&(i.error=r.error),r.reportMessageId&&(i.reportMessageId=r.reportMessageId),{...n,task:i}})}requestCancel(e,t="Cancelled by sender."){let r=this.find(e);if(!r)throw new Error(`Unknown peer message ${e}.`);return r.delivery.status==="queued"||r.delivery.status==="held"?this.setDelivery(e,"cancelled",{reason:t}):r.task&&!B(r.task.status)?r.task.status==="offered"||r.task.status==="accepted"||r.task.status==="blocked"||r.task.status==="recovery-required"?this.setTask(e,"cancelled",{error:t}):this.mutate(e,n=>({...n,task:{...n.task,cancelRequestedAt:A(this.now())}})):r}expireStale(e){let t=this.now(),r=[];for(let n of this.inbox(e))(n.delivery.status==="queued"||n.delivery.status==="held")&&Date.parse(n.expiresAt)<=t&&r.push(this.setDelivery(n.messageId,"expired",{reason:"Not received before it expired."}));return r}reconcileAbandonedTasks(e,t){let r=[];for(let n of this.inbox(e)){let o=n.task;!o||o.status!=="running"||o.executorIncarnationId!==t&&r.push(this.setTask(n.messageId,"recovery-required",{error:`The executing process (incarnation ${o.executorIncarnationId??"unknown"}) exited before the task finished; inspect its side effects before re-delegating.`}))}return r}compact(e=10080*60*1e3){let t=this.now()-e,r=0,n=0,o=m(this.directory,"mailbox");if(_(o))for(let i of H(o))for(let a of F(m(o,i))){let u=S(a);if(!u)continue;u.delivery.status!=="queued"&&u.delivery.status!=="held"&&(!u.task||B(u.task.status)||u.task.status==="recovery-required")&&Date.parse(u.updatedAt)<t&&(j(a,{force:!0}),r+=1)}for(let i of this.listSessions())i.state==="offline"&&Date.parse(i.heartbeatAt)<t&&(j(this.presencePath(i.sessionId),{force:!0}),n+=1);return{messages:r,presence:n}}};function Jt(){try{return Lt().username}catch{return process.env.USERNAME??process.env.USER??"unknown"}}function zt(s){let e={};for(let[t,r]of Object.entries(s))r!==void 0&&(e[t]=r);return e}export{T as AGENT_DAEMON_PROTOCOL_VERSION,we as AgentDaemonClient,he as AgentDaemonServer,C as AgentEventStore,fe as AgentRunController,U as AgentRunStore,Ae as MonitorManager,xe as MonitorStopTool,Se as MonitorTool,be as OtelExporter,Kt as PEER_MESSAGE_DEFAULT_TTL_MS,Wt as PEER_PRESENCE_TTL_MS,k as PEER_SCHEMA_VERSION,qt as PEER_TASK_TERMINAL_STATUSES,Te as PeerMessagingStore,Y as UsageAccumulator,Ie as UsageLedger,D as WorkflowPlanner,ye as WorkflowRuntime,Z as WorkflowStore,x as acquireControlPlaneLock,ft as createAgentRunId,jt as defaultPeerDirectory,Ir as getAgentRunDir,xr as getAgentRunStoreDir,B as isPeerTaskTerminal,Ft as movesTrustUpward,De as peerShortId,ee as renderPeerLabel,Qr as resolvePeerTarget,Gr as toPeerPosture};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/control-plane/types.ts":{"bytes":2465,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2496,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/event-store.ts":{"bytes":2302,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"}],"format":"esm"},"src/utils/platform.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/control-plane/types.ts":{"bytes":2465,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2496,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/event-store.ts":{"bytes":2302,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"}],"format":"esm"},"src/runtime/process-tree-kill.ts":{"bytes":9124,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/platform.ts":{"bytes":9633,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/runtime/process-tree-kill.ts","kind":"import-statement","original":"../runtime/process-tree-kill.js"}],"format":"esm"},"src/control-plane/run-store.ts":{"bytes":11686,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/control-plane/event-store.ts","kind":"import-statement","original":"./event-store.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/control-plane/controller.ts":{"bytes":4113,"imports":[{"path":"src/control-plane/run-store.ts","kind":"import-statement","original":"./run-store.js"}],"format":"esm"},"src/control-plane/daemon.ts":{"bytes":4922,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/workflow.ts":{"bytes":10111,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/control-plane/monitor.ts":{"bytes":4008,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/usage.ts":{"bytes":5009,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/control-plane/peer-messaging.ts":{"bytes":35643,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"}],"format":"esm"},"src/control-plane/index.ts":{"bytes":309,"imports":[{"path":"src/control-plane/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/control-plane/run-store.ts","kind":"import-statement","original":"./run-store.js"},{"path":"src/control-plane/event-store.ts","kind":"import-statement","original":"./event-store.js"},{"path":"src/control-plane/controller.ts","kind":"import-statement","original":"./controller.js"},{"path":"src/control-plane/daemon.ts","kind":"import-statement","original":"./daemon.js"},{"path":"src/control-plane/workflow.ts","kind":"import-statement","original":"./workflow.js"},{"path":"src/control-plane/monitor.ts","kind":"import-statement","original":"./monitor.js"},{"path":"src/control-plane/usage.ts","kind":"import-statement","original":"./usage.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/control-plane/peer-messaging.ts","kind":"import-statement","original":"./peer-messaging.js"}],"format":"esm"}},"outputs":{"dist/control-plane/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:os","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:path","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","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:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/control-plane/index.ts","inputs":{"src/control-plane/index.ts":{"bytesInOutput":804},"src/control-plane/run-store.ts":{"bytesInOutput":5531},"src/version.ts":{"bytesInOutput":16},"src/control-plane/lock.ts":{"bytesInOutput":1066},"src/control-plane/event-store.ts":{"bytesInOutput":1057},"src/utils/platform.ts":{"bytesInOutput":244},"src/control-plane/controller.ts":{"bytesInOutput":1690},"src/control-plane/daemon.ts":{"bytesInOutput":1937},"src/control-plane/workflow.ts":{"bytesInOutput":4805},"src/control-plane/monitor.ts":{"bytesInOutput":1819},"src/control-plane/usage.ts":{"bytesInOutput":2183},"src/control-plane/peer-messaging.ts":{"bytesInOutput":13070}},"bytes":35239}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/control-plane/types.ts":{"bytes":2465,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2496,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/event-store.ts":{"bytes":2302,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"}],"format":"esm"},"src/utils/platform.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/control-plane/types.ts":{"bytes":2465,"imports":[],"format":"esm"},"src/version.ts":{"bytes":195,"imports":[],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2496,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/event-store.ts":{"bytes":2302,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"}],"format":"esm"},"src/runtime/process-tree-kill.ts":{"bytes":9124,"imports":[{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/utils/platform.ts":{"bytes":9633,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/runtime/process-tree-kill.ts","kind":"import-statement","original":"../runtime/process-tree-kill.js"}],"format":"esm"},"src/control-plane/run-store.ts":{"bytes":11686,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/control-plane/event-store.ts","kind":"import-statement","original":"./event-store.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/control-plane/controller.ts":{"bytes":4113,"imports":[{"path":"src/control-plane/run-store.ts","kind":"import-statement","original":"./run-store.js"}],"format":"esm"},"src/control-plane/daemon.ts":{"bytes":4922,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/workflow.ts":{"bytes":10111,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/control-plane/monitor.ts":{"bytes":4008,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/usage.ts":{"bytes":5009,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/control-plane/peer-messaging.ts":{"bytes":35643,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"}],"format":"esm"},"src/control-plane/index.ts":{"bytes":309,"imports":[{"path":"src/control-plane/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/control-plane/run-store.ts","kind":"import-statement","original":"./run-store.js"},{"path":"src/control-plane/event-store.ts","kind":"import-statement","original":"./event-store.js"},{"path":"src/control-plane/controller.ts","kind":"import-statement","original":"./controller.js"},{"path":"src/control-plane/daemon.ts","kind":"import-statement","original":"./daemon.js"},{"path":"src/control-plane/workflow.ts","kind":"import-statement","original":"./workflow.js"},{"path":"src/control-plane/monitor.ts","kind":"import-statement","original":"./monitor.js"},{"path":"src/control-plane/usage.ts","kind":"import-statement","original":"./usage.js"},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"./lock.js"},{"path":"src/control-plane/peer-messaging.ts","kind":"import-statement","original":"./peer-messaging.js"}],"format":"esm"}},"outputs":{"dist/control-plane/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","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:path","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","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:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["AGENT_DAEMON_PROTOCOL_VERSION","AgentDaemonClient","AgentDaemonServer","AgentEventStore","AgentRunController","AgentRunStore","MonitorManager","MonitorStopTool","MonitorTool","OtelExporter","PEER_MESSAGE_DEFAULT_TTL_MS","PEER_PRESENCE_TTL_MS","PEER_SCHEMA_VERSION","PEER_TASK_TERMINAL_STATUSES","PeerMessagingStore","UsageAccumulator","UsageLedger","WorkflowPlanner","WorkflowRuntime","WorkflowStore","acquireControlPlaneLock","createAgentRunId","defaultPeerDirectory","getAgentRunDir","getAgentRunStoreDir","isPeerTaskTerminal","movesTrustUpward","peerShortId","renderPeerLabel","resolvePeerTarget","toPeerPosture"],"entryPoint":"src/control-plane/index.ts","inputs":{"src/control-plane/index.ts":{"bytesInOutput":0},"src/control-plane/run-store.ts":{"bytesInOutput":5373},"src/version.ts":{"bytesInOutput":16},"src/control-plane/lock.ts":{"bytesInOutput":1053},"src/control-plane/event-store.ts":{"bytesInOutput":1066},"src/utils/platform.ts":{"bytesInOutput":253},"src/control-plane/controller.ts":{"bytesInOutput":1690},"src/control-plane/daemon.ts":{"bytesInOutput":1943},"src/control-plane/workflow.ts":{"bytesInOutput":4685},"src/control-plane/monitor.ts":{"bytesInOutput":1820},"src/control-plane/usage.ts":{"bytesInOutput":2200},"src/control-plane/peer-messaging.ts":{"bytesInOutput":12733}},"bytes":33573}}}
|