workspai 0.66.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +24 -22
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  3. package/contracts/extension-cli-compatibility.v1.json +4 -0
  4. package/contracts/published-contract-catalog.v1.json +20 -0
  5. package/contracts/runtime-command-surface.v1.json +55 -2
  6. package/contracts/workspace-activity-board.v1.json +114 -0
  7. package/contracts/workspace-activity-monitor-fleet.v1.json +18 -0
  8. package/contracts/workspace-activity-monitor-snapshot.v1.json +161 -0
  9. package/contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json +196 -0
  10. package/contracts/workspace-intelligence-architecture.v1.json +17 -0
  11. package/contracts/workspace-intelligence-chain.v1.json +17 -0
  12. package/dist/analyze-IC2KRVCG.js +1 -0
  13. package/dist/{artifact-remediation-plan-M2XBS2IU.js → artifact-remediation-plan-GFFHC2ZU.js} +1 -1
  14. package/dist/autopilot-release-RECEZAZI.js +1 -0
  15. package/dist/capabilities-command-X4WZIJNR.js +1 -0
  16. package/dist/{chunk-TTHO4MFC.js → chunk-2M62CU3O.js} +1 -1
  17. package/dist/{chunk-JZJBA2V2.js → chunk-2MTJWPQ4.js} +1 -1
  18. package/dist/chunk-2MVIRJJR.js +1 -0
  19. package/dist/chunk-2RPFCBS4.js +1 -0
  20. package/dist/{chunk-O37UBRMX.js → chunk-3O7LZPKA.js} +1 -1
  21. package/dist/chunk-3OGPTLI2.js +1 -0
  22. package/dist/{chunk-3H5ACWWZ.js → chunk-4RV4JVGR.js} +1 -1
  23. package/dist/{chunk-XQFWUM2P.js → chunk-4WVOAX2V.js} +1 -1
  24. package/dist/{chunk-L5CCIIF2.js → chunk-5EVDW7JM.js} +1 -1
  25. package/dist/{chunk-727IQFGN.js → chunk-5ME4W4LN.js} +1 -1
  26. package/dist/{chunk-DUBOKZMA.js → chunk-6254CWUY.js} +12 -12
  27. package/dist/{chunk-AP4PV6WJ.js → chunk-6E2Y3XGT.js} +1 -1
  28. package/dist/{chunk-ZQH2I5RQ.js → chunk-ARUFY5W3.js} +1 -1
  29. package/dist/{chunk-IIFFEEMX.js → chunk-BHFRP7TV.js} +1 -1
  30. package/dist/{chunk-6JX56VAL.js → chunk-BHM6RHTA.js} +1 -1
  31. package/dist/{chunk-VA5VSOBL.js → chunk-BRYJTW6S.js} +1 -1
  32. package/dist/{chunk-3NM3JAZW.js → chunk-BUYLM6QV.js} +1 -1
  33. package/dist/chunk-CPR2CMOY.js +1 -0
  34. package/dist/{chunk-2PACEMNE.js → chunk-CZVT7T2X.js} +1 -1
  35. package/dist/{chunk-7FF5EOIO.js → chunk-EHCKITR4.js} +1 -1
  36. package/dist/{chunk-UPIPSSXY.js → chunk-ENZPM52J.js} +1 -1
  37. package/dist/{chunk-334J2KIP.js → chunk-FPDH3N3A.js} +1 -1
  38. package/dist/{chunk-D4UHRJAP.js → chunk-FX5J6JCK.js} +1 -1
  39. package/dist/{chunk-HJLGXFMK.js → chunk-GIQ4SDRJ.js} +1 -1
  40. package/dist/{chunk-WTWRSEOW.js → chunk-H77ZNH5O.js} +1 -1
  41. package/dist/{chunk-EHH4SKVH.js → chunk-HQLBO23O.js} +3 -3
  42. package/dist/{chunk-AXUA7PFV.js → chunk-HYE5UHPV.js} +1 -1
  43. package/dist/{chunk-XESFJN52.js → chunk-IKUFNK46.js} +1 -1
  44. package/dist/{chunk-YX5VWPR5.js → chunk-IQQMFRWM.js} +1 -1
  45. package/dist/{chunk-PD7Y6HIM.js → chunk-JCGSIDMC.js} +1 -1
  46. package/dist/{chunk-4XEH3WNV.js → chunk-KENOAC2Q.js} +1 -1
  47. package/dist/{chunk-QGAPGZPL.js → chunk-KQ2TMI26.js} +1 -1
  48. package/dist/{chunk-OI2VOU6S.js → chunk-N4QFNOAI.js} +1 -1
  49. package/dist/{chunk-5XGR3LRI.js → chunk-OCNPOYMA.js} +1 -1
  50. package/dist/{chunk-VQOWB26M.js → chunk-PSYQ6IJA.js} +1 -1
  51. package/dist/{chunk-HLWDIIWL.js → chunk-QMQBX3RV.js} +1 -1
  52. package/dist/{chunk-H5RJCS5E.js → chunk-SLFOUSRW.js} +1 -1
  53. package/dist/chunk-SRLWHOLF.js +1 -0
  54. package/dist/chunk-SVYY55IS.js +157 -0
  55. package/dist/{chunk-JRP6WP5C.js → chunk-THIG2YQP.js} +1 -1
  56. package/dist/{chunk-PJPS7CNH.js → chunk-TP7VKEUF.js} +1 -1
  57. package/dist/{chunk-IVF6NEHS.js → chunk-VI4ZRAY6.js} +1 -1
  58. package/dist/{chunk-EP4CUWOO.js → chunk-VWBMDGPY.js} +1 -1
  59. package/dist/{chunk-GAYK3WGV.js → chunk-XDPTAV2T.js} +1 -1
  60. package/dist/{chunk-R2M5OJOK.js → chunk-Y35VLVF6.js} +1 -1
  61. package/dist/{chunk-ECLMYTWT.js → chunk-Y4Z6CEII.js} +1 -1
  62. package/dist/{chunk-UOCERSAN.js → chunk-YYY2WXOH.js} +1 -1
  63. package/dist/{chunk-6UNATTB7.js → chunk-ZGHJIQXL.js} +1 -1
  64. package/dist/chunk-ZI2E7P6O.js +4 -0
  65. package/dist/{create-SOLLXXAB.js → create-72ITVZXV.js} +1 -1
  66. package/dist/{doctor-NQ5PUCUP.js → doctor-CVYUESRQ.js} +1 -1
  67. package/dist/{goal-lifecycle-IPNY7KNR.js → goal-lifecycle-H55AGFCB.js} +1 -1
  68. package/dist/{goal-pack-2WV3EA4Y.js → goal-pack-6OBZOPCD.js} +1 -1
  69. package/dist/index.d.ts +14 -2
  70. package/dist/index.js +129 -129
  71. package/dist/live-command-5VXPR43F.js +15 -0
  72. package/dist/{pipeline-MIMENSI7.js → pipeline-SKYOXWHW.js} +1 -1
  73. package/dist/{project-agent-entry-OWLJ3IHQ.js → project-agent-entry-5IUBEREI.js} +1 -1
  74. package/dist/{project-intelligence-lens-I67EO6AE.js → project-intelligence-lens-LQCN65P2.js} +1 -1
  75. package/dist/{project-test-coverage-OPDVSFPH.js → project-test-coverage-KD4LLFGV.js} +1 -1
  76. package/dist/{verified-goal-46JWNCDY.js → verified-goal-HN7G532B.js} +1 -1
  77. package/dist/{workspace-KO37XHF6.js → workspace-5W7FYGDQ.js} +1 -1
  78. package/dist/{workspace-agent-sync-32FIJQBH.js → workspace-agent-sync-OZCDQORK.js} +1 -1
  79. package/dist/{workspace-archive-6R5DRNZW.js → workspace-archive-NOSGRKRZ.js} +1 -1
  80. package/dist/{workspace-context-JKRPX775.js → workspace-context-L65BR5L6.js} +1 -1
  81. package/dist/{workspace-contract-4T3NYNK5.js → workspace-contract-JYHNEJPV.js} +1 -1
  82. package/dist/workspace-explain-SUBK6FLO.js +1 -0
  83. package/dist/workspace-explain-contract-WMREJWHF.js +1 -0
  84. package/dist/{workspace-feedback-6VQ7T4CR.js → workspace-feedback-MWGCT5R2.js} +1 -1
  85. package/dist/{workspace-foundation-GHWO3BZU.js → workspace-foundation-VIB3PXNH.js} +1 -1
  86. package/dist/{workspace-graph-stream-PTVS47NJ.js → workspace-graph-stream-45JHE4MG.js} +1 -1
  87. package/dist/workspace-graph-token-efficiency-NPECU6Y5.js +1 -0
  88. package/dist/{workspace-history-M2K4M2JY.js → workspace-history-JKW3VJO3.js} +1 -1
  89. package/dist/{workspace-intelligence-PJIPTXL3.js → workspace-intelligence-3C47PK4L.js} +1 -1
  90. package/dist/workspace-intelligence-benchmark-SRDIHX3X.js +1 -0
  91. package/dist/workspace-intelligence-evaluation-OJIQS5SN.js +1 -0
  92. package/dist/{workspace-intelligence-runner-M47QR3JM.js → workspace-intelligence-runner-OWN5ZI6W.js} +1 -1
  93. package/dist/{workspace-intelligence-runtime-registry-FFGQF4A7.js → workspace-intelligence-runtime-registry-UKFB3BI7.js} +1 -1
  94. package/dist/{workspace-knowledge-graph-V2EAYDCL.js → workspace-knowledge-graph-AKG5NUU6.js} +1 -1
  95. package/dist/{workspace-knowledge-graph-contract-VANN7RCA.js → workspace-knowledge-graph-contract-X52KXBXJ.js} +1 -1
  96. package/dist/{workspace-knowledge-graph-query-RASPF7FS.js → workspace-knowledge-graph-query-DXA4CROE.js} +1 -1
  97. package/dist/workspace-knowledge-graph-snapshot-SNI5K2RL.js +1 -0
  98. package/dist/{workspace-mcp-serve-YRORNE4P.js → workspace-mcp-serve-PK226GMV.js} +1 -1
  99. package/dist/{workspace-model-VSVKLX7M.js → workspace-model-R4ISKDB2.js} +1 -1
  100. package/dist/{workspace-onboarding-2VMJZVLZ.js → workspace-onboarding-Y5RPEFUD.js} +1 -1
  101. package/dist/{workspace-readme-6X3GLTBM.js → workspace-readme-PL5V3UDH.js} +1 -1
  102. package/dist/{workspace-registry-summary-QVSJKKTX.js → workspace-registry-summary-STGUGROG.js} +1 -1
  103. package/dist/{workspace-repair-engine-WSKV3Q4V.js → workspace-repair-engine-FNLL5ZDK.js} +1 -1
  104. package/dist/workspace-run-GFBFGUFM.js +1 -0
  105. package/dist/{workspace-verify-EJCSOBIK.js → workspace-verify-AXVX3PF3.js} +1 -1
  106. package/dist/{workspace-watch-JTIFBF4Z.js → workspace-watch-RLBEJKXE.js} +1 -1
  107. package/docs/DEVELOPMENT.md +19 -0
  108. package/docs/README.md +19 -16
  109. package/docs/ci-workflows.md +1 -1
  110. package/docs/commands-reference.md +17 -1
  111. package/docs/contracts/ARTIFACT_CATALOG.md +1 -0
  112. package/docs/contracts/README.md +3 -0
  113. package/docs/workspace-intelligence-benchmark.md +82 -0
  114. package/docs/workspace-live-activity.md +11 -1
  115. package/package.json +4 -2
  116. package/dist/analyze-UJQWGNM2.js +0 -1
  117. package/dist/autopilot-release-U6F4M2BQ.js +0 -1
  118. package/dist/capabilities-command-XUKPO25Z.js +0 -1
  119. package/dist/chunk-5U4L6VF2.js +0 -1
  120. package/dist/chunk-C4S22E6S.js +0 -1
  121. package/dist/chunk-H7MRINGP.js +0 -1
  122. package/dist/chunk-JC4XSU7G.js +0 -1
  123. package/dist/chunk-MZ7U4BIQ.js +0 -157
  124. package/dist/live-command-Q6E45N7S.js +0 -18
  125. package/dist/workspace-explain-MOGL4GEA.js +0 -1
  126. package/dist/workspace-explain-contract-W2E6LF4Q.js +0 -1
  127. package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +0 -1
  128. package/dist/workspace-intelligence-evaluation-GONCRE6O.js +0 -1
  129. package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +0 -1
  130. package/dist/workspace-run-3BXKTLVL.js +0 -1
@@ -1,18 +0,0 @@
1
- import {e,i,d,a,b,c}from'./chunk-UTV4DTNM.js';import _ from'path';import B from'fs';var kt=64*1024,Et=1024*1024;function Jt(t){if(!t||typeof t!="object")return false;let e=t;return e.schemaVersion===a&&typeof e.eventId=="string"&&typeof e.runId=="string"&&Number.isInteger(e.sequence)&&Number(e.sequence)>0&&typeof e.timestamp=="string"&&!!e.scope&&typeof e.scope?.id=="string"&&typeof e.scope?.label=="string"&&["ephemeral-project","project","workspace"].includes(String(e.scope?.kind))&&typeof e.scope?.portable=="boolean"&&b.includes(e.kind)&&c.includes(e.status)&&(e.attempt===void 0||Number.isInteger(e.attempt)&&e.attempt>0)&&(e.origin===void 0||typeof e.origin.id=="string"&&typeof e.origin.label=="string"&&["project","workspace-root"].includes(e.origin.kind))&&typeof e.message=="string"}function Ct(t,e){try{let r=B.statSync(t).size,o;if(r<=kt+Et)o=B.readFileSync(t,"utf8");else {let n=B.openSync(t,"r");try{let s=Buffer.allocUnsafe(kt),a=Buffer.allocUnsafe(Et),i=B.readSync(n,s,0,s.length,0),c=Math.max(0,r-a.length),d=B.readSync(n,a,0,a.length,c),u=s.subarray(0,i).toString("utf8"),l=a.subarray(0,d).toString("utf8"),p=l.indexOf(`
2
- `),f=p>=0?l.slice(p+1):"";o=`${u.endsWith(`
3
- `)?u:`${u}
4
- `}${f}`,e.push(`Bounded replay window applied to ${_.basename(t)}.`);}finally{B.closeSync(n);}}return o.split(/\r?\n/).filter(Boolean).flatMap(n=>{try{let s=JSON.parse(n);return Jt(s)?[s]:[]}catch{return e.push(`Ignored an incomplete activity record in ${_.basename(t)}.`),[]}})}catch(r){return e.push(`Unable to read ${_.basename(t)}: ${r instanceof Error?r.message:String(r)}`),[]}}function Kt(t,e,r){let o=e.get(t.fromBlockId),n=e.get(t.toBlockId);return !o||!n?"planned":n.status!=="planned"?n.status:r!=="running"&&r!=="planned"?"skipped":o.status==="succeeded"||o.status==="warned"?"running":o.status==="failed"?"failed":o.status==="blocked"?"blocked":o.status==="cancelled"?"cancelled":"planned"}function gt(t){let e$1=e(t.targetPath??process.cwd(),{env:t.env}),r=[],o=_.join(e$1.statePath,"runs"),n=[];try{n=B.readdirSync(o,{withFileTypes:true}).filter(i=>i.isFile()&&i.name.endsWith(".ndjson")).map(i=>{let c=_.join(o,i.name);return {name:i.name,mtimeMs:B.statSync(c).mtimeMs}}).sort((i,c)=>c.mtimeMs-i.mtimeMs);}catch(i){i.code!=="ENOENT"&&r.push(i instanceof Error?i.message:String(i));}t.runId&&(n=n.filter(i=>i.name===`${t.runId}.ndjson`)),n=n.slice(0,Math.max(1,t.maxRuns??25));let s=n.flatMap(i=>Ct(_.join(o,i.name),r)).sort((i,c)=>i.timestamp.localeCompare(c.timestamp)||i.sequence-c.sequence),a=Math.max(100,t.maxEvents??2e4);return {resolvedScope:e$1,events:s.slice(-a),diagnostics:r}}function yt(t){let e=new Map,r=new Map,o=new Map;for(let n of t.events){let s=e.get(n.runId);if(!s){let a=Array.isArray(n.attributes?.command)?n.attributes.command.filter(i=>typeof i=="string"):[];s={runId:n.runId,...n.parentRunId?{parentRunId:n.parentRunId}:{},...Number.isInteger(Number(n.attributes?.pid))&&Number(n.attributes?.pid)>0?{pid:Number(n.attributes?.pid)}:{},...n.origin?{origin:n.origin}:{},command:a,status:n.status,startedAt:n.timestamp,updatedAt:n.timestamp,blocks:[],edges:[],touches:[],artifacts:[],warnings:[]},e.set(n.runId,s),r.set(n.runId,new Map),o.set(n.runId,new Map);}if(s.updatedAt=n.timestamp,n.kind.startsWith("run.")){if(s.status=n.status,n.kind==="run.started"&&Array.isArray(n.attributes?.command)){let i=n.attributes?.command;s.command=i.filter(c=>typeof c=="string");}let a=Number(n.attributes?.pid);n.kind==="run.started"&&Number.isInteger(a)&&a>0&&(s.pid=a),n.origin&&(s.origin=n.origin),n.durationMs!==void 0&&(s.durationMs=n.durationMs);}if(n.blockId&&n.kind.startsWith("block.")){let a=r.get(n.runId),i=a.get(n.blockId),c=Number(n.attributes?.order),d=i?.attempt??0,u=n.kind==="block.planned"||n.kind==="block.skipped"&&d===0?void 0:n.kind==="block.started"&&i?.status!=="running"?d+1:Math.max(1,d),l=n.attempt??u,p=[...i?.attempts??[]];if(l!==void 0){let f=p.findIndex(h=>h.attempt===l),m=f>=0?p[f]:void 0,v={attempt:l,status:n.status,startedAt:m?.startedAt??n.timestamp,updatedAt:n.timestamp,...n.progress?{progress:n.progress}:m?.progress?{progress:m.progress}:{},...n.durationMs!==void 0?{durationMs:n.durationMs}:m?.durationMs!==void 0?{durationMs:m.durationMs}:{}};f>=0?p[f]=v:p.push(v);}a.set(n.blockId,{id:n.blockId,label:n.kind==="block.planned"||!i?n.message||n.blockId:i.label,status:n.status,order:Number.isFinite(c)?c:i?.order??a.size+1,...n.parentSpanId?{parentId:n.parentSpanId}:i?.parentId?{parentId:i.parentId}:{},...n.progress?{progress:n.progress}:i?.progress?{progress:i.progress}:{},...n.durationMs!==void 0?{durationMs:n.durationMs}:i?.durationMs!==void 0?{durationMs:i.durationMs}:{},...typeof n.attributes?.layoutHint=="string"?{layoutHint:n.attributes.layoutHint}:i?.layoutHint?{layoutHint:i.layoutHint}:{},...typeof n.attributes?.group=="string"?{group:n.attributes.group}:i?.group?{group:i.group}:{},updatedAt:n.timestamp,...l!==void 0?{attempt:l}:i?.attempt?{attempt:i.attempt}:{},attempts:p});}if(n.kind==="edge.declared"&&n.edge){let a=o.get(n.runId),i=Number(n.attributes?.order);a.set(n.edge.id,{id:n.edge.id,fromBlockId:n.edge.fromBlockId,toBlockId:n.edge.toBlockId,kind:n.edge.kind,status:"planned",order:Number.isFinite(i)?i:a.size+1,updatedAt:n.timestamp});}(n.kind==="touch.observed"||n.kind==="touch.planned")&&(s.touches.push({locator:n.target?.locator??n.message,...n.target?.operation?{operation:n.target.operation}:{},at:n.timestamp}),s.touches=s.touches.slice(-20)),n.kind==="artifact.published"&&(s.artifacts.push({locator:n.target?.locator??n.message,at:n.timestamp}),s.artifacts=s.artifacts.slice(-20)),n.kind==="warning.detected"&&(s.warnings.push(n.message),s.warnings=s.warnings.slice(-20));}for(let[n,s]of e){s.blocks=[...r.get(n)?.values()??[]].sort((i,c)=>i.order-c.order||i.id.localeCompare(c.id));let a=r.get(n)??new Map;s.edges=[...o.get(n)?.values()??[]].map(i=>({...i,status:Kt(i,a,s.status),updatedAt:a.get(i.toBlockId)?.updatedAt??a.get(i.fromBlockId)?.updatedAt??i.updatedAt})).sort((i,c)=>i.order-c.order||i.id.localeCompare(c.id));}return {schemaVersion:"workspace-activity-monitor-snapshot.v1",generatedAt:new Date().toISOString(),scope:t.resolvedScope.scope,runs:[...e.values()].sort((n,s)=>s.updatedAt.localeCompare(n.updatedAt)),diagnostics:[...t.diagnostics??[]]}}function Tt(t){let e=Math.max(0,Math.min(t.events.length,Math.floor(t.eventCount)));return yt({resolvedScope:t.resolvedScope,events:t.events.slice(0,e),diagnostics:t.diagnostics})}function Xt(t){try{return process.kill(t,0),true}catch(e){return e.code==="EPERM"}}function Bt(t,e=Xt){return {...t,runs:t.runs.map(r=>{if(r.status!=="running"||!r.pid||e(r.pid))return r;let o=Date.parse(r.updatedAt),n=Date.parse(r.startedAt);return {...r,status:"cancelled",orphaned:true,durationMs:Number.isFinite(o)&&Number.isFinite(n)?Math.max(0,o-n):r.durationMs,blocks:r.blocks.map(s=>({...s,status:s.status==="running"?"cancelled":s.status==="planned"?"skipped":s.status,attempts:s.attempts.map((a,i,c)=>i===c.length-1&&a.status==="running"?{...a,status:"cancelled"}:a)})),edges:r.edges.map(s=>({...s,status:s.status==="running"?"cancelled":s.status==="planned"?"skipped":s.status}))}})}}function Qt(t){let e=[];try{e=B.readdirSync(t.stateHome,{withFileTypes:true}).filter(i=>i.isDirectory()).flatMap(i=>{let c=_.join(t.stateHome,i.name,"runs");try{return [{path:c,mtimeMs:B.statSync(c).mtimeMs}]}catch{return []}}).sort((i,c)=>c.mtimeMs-i.mtimeMs).slice(0,Math.min(200,Math.max(16,t.maxScopes*4)));}catch(i){i.code!=="ENOENT"&&t.diagnostics.push(i instanceof Error?i.message:String(i));}let r=e.flatMap(i=>{try{return B.readdirSync(i.path,{withFileTypes:true}).filter(c=>c.isFile()&&c.name.endsWith(".ndjson")&&(!t.runId||c.name===`${t.runId}.ndjson`)).map(c=>{let d=_.join(i.path,c.name);return {filePath:d,mtimeMs:B.statSync(d).mtimeMs}})}catch{return []}}).sort((i,c)=>c.mtimeMs-i.mtimeMs).slice(0,Math.max(t.maxRuns*4,t.maxScopes*2)),o=new Map;for(let i of r)for(let c of Ct(i.filePath,t.diagnostics))o.has(c.eventId)||o.set(c.eventId,c);let n=[...o.values()].sort((i,c)=>i.timestamp.localeCompare(c.timestamp)||i.sequence-c.sequence),s=[...new Set([...n].reverse().map(i=>i.runId))].slice(0,t.maxRuns),a=new Set(s);return n.filter(i=>a.has(i.runId))}function Lt(t={}){let e=[],r=Math.max(1,Math.min(100,t.maxRuns??12)),o=Math.max(1,Math.min(50,t.maxScopes??12)),n=Qt({stateHome:d(t.env),runId:t.runId,maxRuns:r,maxScopes:o,diagnostics:e}),s=Math.max(100,Math.min(5e5,t.maxEvents??5e4));n=n.slice(-s);let a=new Map;for(let c of n){let d=a.get(c.scope.id)??{scope:c.scope,events:[]};d.events.push(c),a.set(c.scope.id,d);}let i=[...a.values()].map(c=>Bt(yt({resolvedScope:{scope:c.scope},events:c.events}))).sort((c,d)=>(d.runs[0]?.updatedAt??"").localeCompare(c.runs[0]?.updatedAt??"")||c.scope.label.localeCompare(d.scope.label)).slice(0,o);return {schemaVersion:"workspace-activity-monitor-fleet.v1",generatedAt:new Date().toISOString(),scopes:i,diagnostics:e}}function Pt(t={}){let e=gt(t);return Bt(yt({resolvedScope:e.resolvedScope,events:e.events,diagnostics:e.diagnostics}))}function Ot(t={}){let e$1=e(t.targetPath??process.cwd(),{env:t.env}),r=_.join(e$1.statePath,"runs");return i(r,{maxRuns:t.maxRuns,maxAgeDays:t.maxAgeDays})}var Zt=new Set(["planned","running"]);function te(t){return Zt.has(t)}function ee(t){return t.command.length>0?`workspai ${t.command.join(" ")}`:`run ${t.runId.slice(0,8)}`}function ne(t){return t.slice(1).map((e,r)=>{let o=t[r];return {id:`inferred:${o.id}->${e.id}`,fromBlockId:o.id,toBlockId:e.id,kind:e.layoutHint==="gate"?"gate":e.layoutHint==="sink"?"handoff":"sequence",status:re(o.status,e.status),order:r+1,updatedAt:e.updatedAt,inferred:true}})}function re(t,e){return e!=="planned"?e:t==="succeeded"||t==="warned"?"running":t==="failed"||t==="blocked"||t==="cancelled"?t:"planned"}function ie(t,e,r){let o=[...t.blocks].sort((i,c)=>i.order-c.order||i.id.localeCompare(c.id)),n=o.some(i=>i.parentId),s=o.filter(i=>!n||!!i.parentId).map(i=>({...i,root:!i.parentId})),a=t.edges.length>0?t.edges.map(i=>({...i,inferred:false})):ne(s);return {run:t,commandLabel:ee(t),active:t.status==="running",nodes:s,edges:a,activeBlockCount:s.filter(i=>i.status==="running").length,warningCount:t.warnings.length+s.filter(i=>i.status==="warned").length,scope:e,locationLabel:t.origin&&(t.origin.label!==e.label||r.originLabel!==t.origin.label)?`${r.scopeLabel}/${r.originLabel}`:r.scopeLabel}}function D(t,e={}){let r=Math.max(1,e.maxRuns??6),o=t.schemaVersion==="workspace-activity-monitor-fleet.v1",n=o?t.scopes:[t],s=new Map,a=new Map;for(let u of n){let l=s.get(u.scope.label)??new Set;l.add(u.scope.id),s.set(u.scope.label,l);for(let p of u.runs){if(!p.origin)continue;let f=`${u.scope.id}\0${p.origin.label}`,m=a.get(f)??new Set;m.add(p.origin.id),a.set(f,m);}}let i=n.flatMap(u=>u.runs.map(l=>{let p=(s.get(u.scope.label)?.size??0)>1?`${u.scope.label}#${u.scope.id.slice(-4)}`:u.scope.label,f=l.origin?`${u.scope.id}\0${l.origin.label}`:void 0,m=l.origin?(a.get(f??"")?.size??0)>1?`${l.origin.label}#${l.origin.id.slice(-4)}`:l.origin.label:void 0;return ie(l,u.scope,{scopeLabel:p,originLabel:m})})).sort((u,l)=>u.active!==l.active?u.active?-1:1:l.run.updatedAt.localeCompare(u.run.updatedAt)),c=(e.activeOnly?i.filter(u=>u.active):i).slice(0,r),d=c.find(u=>u.run.runId===e.selectedRunId)?.run.runId??c.find(u=>u.active)?.run.runId??c[0]?.run.runId;return {scopeLabel:o?"Global activity":n[0]?.scope.label??"activity",generatedAt:t.generatedAt,activeRunCount:i.filter(u=>u.active).length,healthyRunCount:i.filter(u=>u.run.status==="succeeded").length,warningRunCount:i.filter(u=>u.run.status==="warned"||u.warningCount>0).length,failedRunCount:i.filter(u=>u.run.status==="failed").length,...d?{selectedRunId:d}:{},runs:c,diagnostics:o?[...t.diagnostics,...n.flatMap(u=>u.diagnostics)]:t.diagnostics,global:o,scopeCount:n.length}}function F(t,e,r){return t.edges.find(o=>o.fromBlockId===e&&o.toBlockId===r)}function Nt(t){return t.runs.map(e=>e.run.runId)}function Wt(t){return t.runs.some(e=>e.active||e.nodes.some(r=>te(r.status))||e.edges.some(r=>r.status==="running"))}var P={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",magenta:"\x1B[35m"},oe={planned:"\u25CB",running:"\u25C9",succeeded:"\u2713",warned:"!",blocked:"\u2298",failed:"\xD7",cancelled:"\xD7",skipped:"\u2013","rolled-back":"\u21B6"},se={planned:"o",running:"*",succeeded:"+",warned:"!",blocked:"#",failed:"x",cancelled:"x",skipped:"-","rolled-back":"~"};function ht(t){return t.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"")}function L(t){return ht(t).replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}function N(t){return [...ht(t)].length}function W(t,e){let r=L(t),o=[...r];return o.length<=e?r:e<=0?"":e===1?"\u2026":`${o.slice(0,e-1).join("")}\u2026`}function x(t,e){return N(t)<=e?t:W(ht(t),e)}function ae(t,e){return t==="running"?e%2===0?P.brightCyan:P.cyan:t==="succeeded"?P.green:t==="warned"||t==="blocked"?P.yellow:t==="failed"||t==="cancelled"?P.red:t==="rolled-back"?P.magenta:P.dim}function O(t,e,r,o){return r?`${ae(e,o)}${t}${P.reset}`:t}function X(t,e){return e?`${P.bold}${P.brightCyan}${t}${P.reset}`:t}function U(t,e){return (e?se:oe)[t]}function ot(t,e){let r=t.durationMs??Math.max(0,e-Date.parse(t.startedAt));if(r<1e3)return `${r}ms`;let o=Math.floor(r/1e3);if(o<60)return `${o}s`;let n=Math.floor(o/60);return n<60?`${n}m ${o%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function H(t){let e=t.progress;return e?e.percent!==void 0?`${Math.round(e.percent)}%`:e.completed!==void 0&&e.total!==void 0?`${e.completed}/${e.total}`:e.iteration!==void 0&&e.iterations!==void 0?`${e.iteration}/${e.iterations}`:"":""}function Q(t,e){return t.attempt&&t.attempt>1?`${e?"R":"\u21BB"}${t.attempt}`:""}function jt(t,e,r){let o=N(t),n=N(e);return o+n+1>r?x(`${t} ${e}`,r):`${t}${" ".repeat(r-o-n)}${e}`}var st={planned:"QUEUE",running:"RUN",succeeded:"DONE",warned:"WARN",blocked:"BLOCK",failed:"FAIL",cancelled:"STOP",skipped:"SKIP","rolled-back":"ROLL"};function it(t,e,r,o){return o?"+":r?{left:"\u252B",right:"\u2523",top:"\u253B",bottom:"\u2533"}[t]:e==="planned"||e==="skipped"?{left:"\u2524",right:"\u251C",top:"\u2534",bottom:"\u252C"}[t]:{left:"\u2525",right:"\u251D",top:"\u2537",bottom:"\u252F"}[t]}function ce(t,e,r){let o=W(e,Math.max(3,Math.floor(r*.6))),n=Math.max(0,r-N(o)-(o?1:0)),s=W(t,n);return `${s}${" ".repeat(Math.max(0,r-N(s)-N(o)))}${o}`}function Vt(t,e,r,o,n){let s=Array.from({length:Math.max(0,o-2)},()=>r);return n&&s.length>0&&(s[Math.floor(s.length/2)]=n),`${t}${s.join("")}${e}`}function de(t,e,r,o){let n=t.status==="running",s=r.ascii?{topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|"}:n?{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503"}:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"},a=H(t),i=Q(t,r.ascii),c=[st[t.status],i,a].filter(Boolean).join(" "),d=Vt(s.topLeft,s.topRight,s.horizontal,e,o.top?it("top",o.top,n,r.ascii):void 0),u=`${o.left?it("left",o.left,n,r.ascii):s.vertical}${ce(L(t.label),c,e-2)}${o.right?it("right",o.right,n,r.ascii):s.vertical}`,l=Vt(s.bottomLeft,s.bottomRight,s.horizontal,e,o.bottom?it("bottom",o.bottom,n,r.ascii):void 0);return [d,u,l].map(p=>O(p,t.status,r.color,r.frame))}function ue(t,e,r,o,n,s){let a=Math.max(2,s),i=n?"-":"\u2501",c=n?".":"\u2504";if(t==="running"&&o){let d=n?"=":"\u254D",u=Array.from({length:a},()=>i),l=r%a;return u[e==="right"?l:a-l-1]=d,u.join("")}return t==="planned"||t==="skipped"?c.repeat(a):t==="blocked"||t==="warned"?(n?"~":"\u2505").repeat(a):t==="failed"||t==="cancelled"?(n?"=":"\u254D").repeat(a):i.repeat(a)}function _t(t,e,r,o=7){return t?O(ue(t.status,e,r.frame,r.motion,r.ascii,o),t.status,r.color,r.frame):" ".repeat(o)}function le(t,e,r,o){let n=t?.status??"planned",s=n==="running"&&o.motion,a=n==="planned"||n==="skipped"?o.ascii?":":"\u250A":n==="blocked"||n==="warned"?o.ascii?"~":"\u250B":o.ascii?"|":"\u2503",i=o.ascii?":":"\u254F";return [s&&o.frame%2===0?i:a,s&&o.frame%2===1?i:a].map(d=>O(`${" ".repeat(Math.max(0,e))}${d}`.padEnd(r),n,o.color,o.frame))}function pe(t,e,r){let o=e>=132?9:7,n=t.nodes.length<=2?Math.min(32,e):e>=132?19:e>=100?17:15,s=Math.max(1,Math.floor((e+o)/(n+o))),a=[];for(let c=0;c<t.nodes.length;c+=s)a.push(t.nodes.slice(c,c+s));let i=[];return a.forEach((c,d)=>{let u=d%2===0?"right":"left",l=u==="right"?c:[...c].reverse(),p=a[d+1],f=a[d-1],m=f?F(t,f.at(-1)?.id??"",c[0]?.id??""):void 0,v=p?F(t,c.at(-1)?.id??"",p[0]?.id??""):void 0,h=(y,S)=>u==="right"?F(t,y.id,S.id):F(t,S.id,y.id),E=l.map((y,S)=>{let b=S>0?h(l[S-1],y):void 0,M=S<l.length-1?h(y,l[S+1]):void 0;return de(y,n,r,{...b?{left:b.status}:{},...M?{right:M.status}:{},...m&&y.id===c[0]?.id?{top:m.status}:{},...v&&y.id===c.at(-1)?.id?{bottom:v.status}:{}})});for(let y=0;y<3;y+=1){let S="";l.forEach((b,M)=>{if(S+=E[M][y],M>=l.length-1)return;if(y!==1){S+=" ".repeat(o);return}let k=l[M+1],$=u==="right"?F(t,b.id,k.id):F(t,k.id,b.id);S+=_t($,u,r,o);}),i.push(x(S,e));}if(!p)return;let I=v,w=l.length*n+(l.length-1)*o,T=u==="right"?Math.max(0,w-Math.ceil(n/2)):Math.floor(n/2);i.push(...le(I,T,e,r));}),i}function me(t,e){let r=H(t),o=Q(t,e.ascii),n=`${U(t.status,e.ascii)} ${L(t.label)}${o?` ${o}`:""}${r?` ${r}`:""}`;return O(`[${n}]`,t.status,e.color,e.frame)}function fe(t,e,r,o){if(t.nodes.length===0)return [];let n=[],s="",a=0;for(let[i,c]of t.nodes.entries()){let d=me(c,o),u=t.nodes[i-1],l=u?F(t,u.id,c.id):void 0,p=u?_t(l,"right",o,7):"",f=`${s?p:""}${d}`;if(s&&N(s)+N(f)>e){if(n.push(x(s,e)),n.length>=r)break;s=`${o.ascii?"> ":"\u21B3 "}${d}`;}else s+=f;a=i+1;}if(n.length<r&&s&&n.push(x(s,e)),a<t.nodes.length&&n.length>0){let i=` \u2026 +${t.nodes.length-a}`;n[n.length-1]=x(`${n.at(-1)}${i}`,e);}return n.slice(0,r)}function ge(t,e,r,o){if(t.length===0)return;let n=e>=130?3:e>=92?2:1,s=t.slice(0,n),a="ALSO ACTIVE ",i=s.map(d=>{let u=W(d.commandLabel.replace(/^workspai\s+/,""),24),l=o?`${W(d.locationLabel,20)} \xB7 `:"";return O(`[${U("running",r.ascii)} ${l}${u} \xB7 ${d.run.runId.slice(0,8)}]`,"running",r.color,r.frame)}),c=t.length-s.length;return x(`${a}${i.join(" ")}${c>0?` +${c}`:""}`,e)}function ye(t){let e=t.map(r=>r.status);for(let r of ["failed","cancelled","blocked","warned","running"])if(e.includes(r))return r;return e.length>0&&e.every(r=>r==="succeeded")?"succeeded":e.some(r=>r==="succeeded")?"running":e[0]??"planned"}function he(t,e,r){let o=[...new Set(t.nodes.map(a=>a.group).filter(Boolean))];if(o.length<2)return;let n=r.ascii?" > ":" \u2501 ",s=o.map((a,i)=>{let c=ye(t.nodes.filter(d=>d.group===a));return O(`${String(i+1).padStart(2,"0")} ${W(a,14)}`,c,r.color,r.frame)});return x(`PHASES ${s.join(n)}`,e)}function Dt(t){return [...t.nodes].reverse().find(e=>e.status==="running")??[...t.nodes].reverse().find(e=>["failed","blocked","warned","cancelled"].includes(e.status))??[...t.nodes].sort((e,r)=>r.updatedAt.localeCompare(e.updatedAt))[0]}function ve(t){if(t<1e3)return `${t}ms`;let e=Math.floor(t/1e3);if(e<60)return `${e}s`;let r=Math.floor(e/60);return r<60?`${r}m ${e%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function be(t,e,r,o){let n=Dt(t);if(!n||e<24)return [];let s=o.ascii?"-":"\u2500",a=o.ascii?"|":"\u2502",i=e-2,c=n.attempt??0,d=n.attempts.at(-1)?.startedAt??n.updatedAt,u=n.durationMs??(n.status==="running"?Math.max(0,r-Date.parse(d)):void 0),l=[X("INSPECT",o.color),L(n.label),"",`STATE ${st[n.status]}`,`PHASE ${n.group??"GENERAL"}`,`ATTEMPT ${c>0?`${c}/${Math.max(c,n.attempts.length)}`:"\u2014"}`,`PROGRESS ${H(n)||"\u2014"}`,`ELAPSED ${u===void 0?"\u2014":ve(u)}`,"",`TOUCHES ${t.run.touches.length}`,`ARTIFACTS ${t.run.artifacts.length}`,`WARNINGS ${t.warningCount}`],p=o.ascii?{tl:"+",tr:"+",bl:"+",br:"+"}:{tl:"\u250C",tr:"\u2510",bl:"\u2514",br:"\u2518"};return [`${p.tl}${s.repeat(i)}${p.tr}`,...l.map(f=>{let m=x(f,i);return `${a}${m}${" ".repeat(Math.max(0,i-N(m)))}${a}`}),`${p.bl}${s.repeat(i)}${p.br}`]}function Ae(t,e,r,o=3){return Array.from({length:Math.max(t.length,e.length)},(n,s)=>{let a=x(t[s]??"",r);return `${a}${" ".repeat(Math.max(0,r-N(a))+o)}${e[s]??""}`})}function $e(t,e,r,o,n){let s=[...t.runs.filter(p=>p.active),...t.runs.filter(p=>!p.active&&p.run.runId===e)].filter((p,f,m)=>m.findIndex(v=>v.run.runId===p.run.runId)===f);if(s.length===0)return [];let a=s.slice(0,r>=110?4:2),i=Math.max(12,Math.min(28,Math.floor(r*.24))),c=Math.max(14,Math.min(30,Math.floor(r*.27))),d=Math.max(10,Math.min(20,Math.floor(r*.18))),u=`FLEET ${"LOCATION".padEnd(i)} ${"COMMAND".padEnd(c)} ${"ACTIVE BLOCK".padEnd(d)} STATE`,l=[X(x(u,r),n.color)];for(let p of a){let f=Dt(p),m=p.run.runId===e?n.ascii?">":"\u25C6":" ",v=p.commandLabel.replace(/^workspai\s+/,""),h=`${m} ${W(p.locationLabel,i).padEnd(i)} ${W(v,c).padEnd(c)} ${W(f?.label??"\u2014",d).padEnd(d)} ${st[p.run.status]} \xB7 ${ot(p.run,o)}`;l.push(O(x(h,r),p.run.status,n.color,n.frame));}return s.length>a.length&&l.push(x(` +${s.length-a.length} more runs`,r)),l}function xe(t,e,r,o,n,s){let a=n.ascii?">":"\u25C6",i=s?`${W(t.locationLabel,28)} `:"",c=`RUN ${t.run.runId.slice(0,8).toUpperCase()} ${i}${L(t.commandLabel)}`,d=t.warningCount>0?` \xB7 !${t.warningCount}`:"",u=`${st[t.run.status]} \xB7 ${ot(t.run,o)}${d}`,l=O(jt(c,u,Math.max(0,r-2)),t.run.status,n.color,n.frame);return `${X(a,n.color)} ${l}`}function Se(t,e,r){let o=[x(`Workspai Live | ${L(t.scopeLabel)} | ${t.activeRunCount} active | ${t.failedRunCount} failed`,e)];t.runs.length===0&&o.push("WAITING");for(let n of t.runs){o.push(x(`RUN ${n.run.status.toUpperCase()} | ${L(n.commandLabel)} | ${n.run.runId.slice(0,8)} | ${ot(n.run,r)}`,e));for(let s of n.nodes)o.push(x(` BLOCK ${s.status.toUpperCase()} | ${L(s.label)}${Q(s,true)?` | ATTEMPT ${s.attempt}`:""}${H(s)?` | ${H(s)}`:""}`,e));}return o.join(`
5
- `)}function Y(t,e={}){if(e.classic)return Me(t,e);let r=Math.max(20,e.width??process.stdout.columns??100),o=Math.max(1,e.height??process.stdout.rows??28),n=e.now??Date.now(),s=e.frame??0,a=e.ascii??(process.env.WORKSPAI_LIVE_ASCII==="1"||process.env.TERM==="dumb"),i=e.color??(process.stdout.isTTY&&process.env.NO_COLOR===void 0&&process.env.TERM!=="dumb"),c=e.motion??(process.env.WORKSPAI_LIVE_REDUCED_MOTION!=="1"&&process.env.CI!=="true"),d=D(t,{selectedRunId:e.selectedRunId,activeOnly:e.activeOnly,maxRuns:e.maxRuns});if(e.accessible)return Se(d,r,n);let u={ascii:a,color:i,frame:s,motion:c},l=X("WORKSPAI LIVE",i),p=x(L(d.scopeLabel),Math.max(8,Math.floor(r/3))),m=`${d.global?`${d.scopeCount} SCOPES `:""}${U("running",a)} ${d.activeRunCount} ACTIVE ${U("succeeded",a)} ${d.healthyRunCount} ${U("warned",a)} ${d.warningRunCount} ${U("failed",a)} ${d.failedRunCount}`,v=a?"-".repeat(r):"\u2501".repeat(r),h=[jt(`${l} ${p}`,m,r),O(v,"planned",i,s)],E=x(e.replay?`${e.replay.paused?"PAUSED":"PLAY"} ${e.replay.index}/${e.replay.total} \xB7 ${e.replay.speed}x SPACE PLAY/PAUSE ${a?"<>":"\u2190\u2192"} STEP Q CLOSE`:`${a?"^v":"\u2191\u2193"} SELECT ENTER FOCUS I INSPECT F ACTIVE Q CLOSE`,r),I=e.interactive?o>=8?[O(v,"planned",i,s),E]:o>=3?[E]:[]:[];if(d.runs.length===0)h.push("",X(`${a?"*":"\u25C7"} WAITING FOR WORKSPAI ACTIVITY`,i));else {let w=d.runs.find(J=>J.run.runId===d.selectedRunId)??d.runs[0],T=e.focused?[]:d.runs.filter(J=>J.run.runId!==w.run.runId&&J.active);d.global&&!e.focused&&h.push(...$e(d,w.run.runId,r,n,u)),h.push(xe(w,true,r,n,u,d.global));let y=e.inspector!==false&&r>=132,S=y?Math.min(34,Math.floor(r*.25)):0,b=y?r-S-3:r,M=he(w,b,u),k=[...M?[M]:[],...pe(w,b,u)],$=y?be(w,S,n,u):[],tt=y?Ae(k,$,b):k,G=ge(T,r,u,d.global),et=G&&!d.global?1:0,q=Math.max(0,o-I.length-h.length-et),j=r>=72&&o>=14&&tt.length<=q;G&&!d.global&&h.length+I.length<o&&h.push(G),h.push(...j?tt:q>0?fe(w,r,Math.min(3,q),u):[]);}return d.diagnostics.length>0&&h.length+I.length<o&&h.push(O(`! ${d.diagnostics.length} DIAGNOSTIC`,"warned",i,s)),h.push(...I),h.slice(0,o).map(w=>x(w,r)).join(`
6
- `)}function Me(t,e={}){let r=Math.max(20,e.width??process.stdout.columns??100),o=e.now??Date.now(),n=e.ascii??false,s=D(t,{maxRuns:e.maxRuns}),a=s.runs.map(d=>d.run),i=s.activeRunCount,c=[x(`Workspai Live \xB7 ${L(s.scopeLabel)} \xB7 ${i} active run${i===1?"":"s"}`,r),(n?"-":"\u2500").repeat(Math.min(r,100))];a.length===0&&c.push("Waiting for Workspai commands in this project or workspace\u2026");for(let[d,u]of a.entries()){d>0&&c.push("");let l=L(u.command.length>0?`workspai ${u.command.join(" ")}`:u.runId);c.push(x(`${U(u.status,n)} ${l} \xB7 ${u.runId.slice(0,8)} \xB7 ${ot(u,o)}`,r));for(let p of u.blocks.slice(0,18))c.push(x(` ${U(p.status,n)} ${L(p.label)}${Q(p,n)?` ${Q(p,n)}`:""}${H(p)?` ${H(p)}`:""}`,r));}return c.join(`
7
- `)}var Ut={github:{width:1280,height:720},linkedin:{width:1200,height:627},x:{width:1600,height:900},square:{width:1080,height:1080},wide:{width:1600,height:900}},we={obsidian:{background:"#070b12",surface:"#0d1420",surfaceRaised:"#121c2b",grid:"#1d2a3b",text:"#edf6ff",muted:"#8090a5",cyan:"#20d9ff",green:"#27e0a3",yellow:"#f4d35e",red:"#ff667d",violet:"#b89cff"},light:{background:"#f4f7fb",surface:"#ffffff",surfaceRaised:"#eef3f9",grid:"#d9e2ee",text:"#102033",muted:"#617187",cyan:"#007fa3",green:"#087f5b",yellow:"#a16a00",red:"#c92a42",violet:"#6741d9"},mono:{background:"#080808",surface:"#111111",surfaceRaised:"#181818",grid:"#303030",text:"#f4f4f4",muted:"#9a9a9a",cyan:"#f4f4f4",green:"#d8d8d8",yellow:"#bdbdbd",red:"#ffffff",violet:"#c9c9c9"}};function V(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g," ")}function ct(t,e){let r=[...t];return r.length<=e?t:`${r.slice(0,e-1).join("")}\u2026`}function Z(t,e){return t==="running"?e.cyan:t==="succeeded"?e.green:t==="warned"||t==="blocked"?e.yellow:t==="failed"||t==="cancelled"?e.red:t==="rolled-back"?e.violet:e.muted}function bt(t){return {planned:"QUEUE",running:"RUNNING",succeeded:"COMPLETE",warned:"WARNING",blocked:"BLOCKED",failed:"FAILED",cancelled:"CANCELLED",skipped:"SKIPPED","rolled-back":"ROLLED BACK"}[t]}function Re(t){if(t<1e3)return `${t}ms`;let e=Math.floor(t/1e3);if(e<60)return `${e}s`;let r=Math.floor(e/60);return r<60?`${r}m ${e%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function Ft(t){return t.progress?.percent!==void 0?`${Math.round(t.progress.percent)}%`:t.progress?.completed!==void 0&&t.progress.total!==void 0?`${t.progress.completed}/${t.progress.total}`:""}function Ie(t){return [...t].reverse().find(e=>e.status==="running")??[...t].reverse().find(e=>["failed","blocked","warned"].includes(e.status))??[...t].sort((e,r)=>r.updatedAt.localeCompare(e.updatedAt))[0]}function ke(t,e){if(!e)return `workspai ${t.join(" ")}`.trim();let r=t[0]?.match(/^[a-z][a-z0-9-]*$/i)?.[0]??"command",n=new Set(["workspace","doctor","goal","graph","model","context"]).has(r)?t[1]?.match(/^[a-z][a-z0-9-]*$/i)?.[0]:void 0;return `workspai ${[r,n].filter(Boolean).join(" ")}`}function Ee(t,e={}){let r=e.preset??"github",o=e.theme??"obsidian",{width:n,height:s}=Ut[r],a=we[o],i=D(t,{selectedRunId:e.runId,maxRuns:50}),c=i.runs.find(g=>g.run.runId===i.selectedRunId)??i.runs[0],d=e.now??Date.parse(t.generatedAt),u=Math.round(n*.045),l=28,p=Math.max(250,Math.round(n*.24)),f=n-u*2-p-l,m=u,v=m+f+l,h=184,E=s-54,I=30,w=34,T=Math.max(2,Math.min(5,Math.floor((f+I)/180))),y=Math.floor((f-I*(T-1))/T),S=Math.max(1,Math.ceil((c?.nodes.length??0)/T)),b=Math.max(48,Math.min(64,Math.floor((E-h-w*(S-1))/S))),M=[...new Set(c?.nodes.map(g=>g.group).filter(Boolean)??[])],k=new Map;c?.nodes.forEach((g,A)=>{let R=Math.floor(A/T),C=A%T,z=R%2===0?C:T-C-1;k.set(g.id,{x:m+z*(y+I),y:h+R*(b+w)});});let $=c?Ie(c.nodes):void 0,tt=e.redact?"workspace / project":i.scopeLabel,G=e.redact?"workspace / project":c?.locationLabel,et=c?ke(c.run.command,e.redact===true):"Waiting for activity",q=c?c.run.durationMs??Math.max(0,d-Date.parse(c.run.startedAt)):0,j=[`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${s}" viewBox="0 0 ${n} ${s}" role="img" aria-labelledby="title description">`,'<title id="title">Workspai Live execution board</title>',`<desc id="description">${V(et)} execution graph with ${c?.nodes.length??0} blocks.</desc>`,"<defs>",`<pattern id="grid" width="28" height="28" patternUnits="userSpaceOnUse"><path d="M 28 0 L 0 0 0 28" fill="none" stroke="${a.grid}" stroke-width="1" opacity="0.28"/></pattern>`,...["planned","running","succeeded","warned","blocked","failed","cancelled","skipped","rolled-back"].map(g=>`<marker id="arrow-${g}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="${Z(g,a)}"/></marker>`),'<filter id="glow"><feGaussianBlur stdDeviation="3" result="blur"/><feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge></filter>',"</defs>",`<rect width="${n}" height="${s}" fill="${a.background}"/>`,`<rect width="${n}" height="${s}" fill="url(#grid)"/>`,`<text x="${u}" y="58" fill="${a.cyan}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="17" font-weight="700" letter-spacing="2">WORKSPAI LIVE</text>`,`<text x="${u}" y="91" fill="${a.text}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="27" font-weight="650">${V(ct(et,62))}</text>`,`<text x="${u}" y="118" fill="${a.muted}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="14">${V(ct(G??tt,72))}</text>`,`<text x="${n-u}" y="61" text-anchor="end" fill="${c?Z(c.run.status,a):a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="14" font-weight="700">${c?bt(c.run.status):"STANDBY"} \xB7 ${Re(q)}</text>`,`<line x1="${u}" y1="143" x2="${n-u}" y2="143" stroke="${a.grid}" stroke-width="2"/>`];if(M.length>1){let g=Math.min(132,Math.floor((f-12*(M.length-1))/M.length));M.forEach((A,R)=>{let C=m+R*(g+12);j.push(`<rect x="${C}" y="156" width="${g}" height="20" rx="10" fill="${a.surfaceRaised}" stroke="${a.grid}"/>`,`<text x="${C+g/2}" y="170" text-anchor="middle" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" font-weight="700" letter-spacing="1">${V(A)}</text>`);});}for(let g of c?.edges??[]){let A=k.get(g.fromBlockId),R=k.get(g.toBlockId);if(!A||!R)continue;let C=A.x+y/2,z=A.y+b/2,dt=R.x+y/2,$t=R.y+b/2,K=Math.abs($t-z)<2,ut=K?dt>C?A.x+y:A.x:C,lt=K?z:A.y+b,pt=K?dt>C?R.x:R.x+y:dt,mt=K?$t:R.y,xt=(lt+mt)/2,Gt=K?`M ${ut} ${lt} L ${pt} ${mt}`:`M ${ut} ${lt} L ${ut} ${xt} L ${pt} ${xt} L ${pt} ${mt}`,qt=Z(g.status,a);j.push(`<path d="${Gt}" fill="none" stroke="${qt}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" ${g.status==="planned"?'stroke-dasharray="5 7"':""} marker-end="url(#arrow-${g.status})" opacity="${g.status==="planned"?"0.55":"0.9"}"/>`);}for(let g of c?.nodes??[]){let A=k.get(g.id);if(!A)continue;let R=Z(g.status,a),C=g.attempt&&g.attempt>1?` \xB7 R${g.attempt}`:"",z=Ft(g);j.push(`<g${g.status==="running"?' filter="url(#glow)"':""}>`,`<rect x="${A.x}" y="${A.y}" width="${y}" height="${b}" rx="8" fill="${a.surface}" stroke="${R}" stroke-width="${g.status==="running"?3:1.5}"/>`,`<rect x="${A.x}" y="${A.y}" width="4" height="${b}" rx="2" fill="${R}"/>`,`<text x="${A.x+15}" y="${A.y+25}" fill="${a.text}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="13" font-weight="650">${V(ct(g.label,Math.max(10,Math.floor(y/8))))}</text>`,`<text x="${A.x+15}" y="${A.y+45}" fill="${R}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" font-weight="700">${bt(g.status)}${V(C)}${z?` \xB7 ${V(z)}`:""}</text>`,"</g>");}return j.push(`<rect x="${v}" y="156" width="${p}" height="${Math.max(250,s-210)}" rx="12" fill="${a.surface}" stroke="${a.grid}" stroke-width="1.5"/>`,`<text x="${v+24}" y="191" fill="${a.cyan}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="12" font-weight="700" letter-spacing="1.5">INSPECT</text>`,`<text x="${v+24}" y="224" fill="${a.text}" font-family="Inter,ui-sans-serif,system-ui,sans-serif" font-size="19" font-weight="650">${V(ct($?.label??"No active block",24))}</text>`),[["STATE",$?bt($.status):"STANDBY"],["PHASE",$?.group??"GENERAL"],["ATTEMPT",$?.attempt?String($.attempt):"\u2014"],["PROGRESS",$&&Ft($)||"\u2014"],["TOUCHES",String(c?.run.touches.length??0)],["ARTIFACTS",String(c?.run.artifacts.length??0)],["WARNINGS",String(c?.warningCount??0)]].forEach(([g,A],R)=>{let C=273+R*45;j.push(`<text x="${v+24}" y="${C}" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" font-weight="700" letter-spacing="1">${g}</text>`,`<text x="${v+p-24}" y="${C}" text-anchor="end" fill="${g==="STATE"&&$?Z($.status,a):a.text}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="12" font-weight="700">${V(A)}</text>`);}),j.push(`<text x="${u}" y="${s-24}" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10" letter-spacing="1">EVENT-DRIVEN \xB7 DETERMINISTIC \xB7 LOCAL-FIRST</text>`,`<text x="${n-u}" y="${s-24}" text-anchor="end" fill="${a.muted}" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="10">${e.redact?"PRODUCT-SAFE CAPTURE":V(c?.run.runId.slice(0,8).toUpperCase()??"NO RUN")}</text>`,"</svg>"),`${j.join(`
8
- `)}
9
- `}function zt(t,e){let r=e.preset??"github",o=_.resolve(e.outputPath);if(_.extname(o).toLowerCase()!==".svg")throw new Error("Activity capture output must use the .svg extension.");B.mkdirSync(_.dirname(o),{recursive:true,mode:448});let n=Ee(t,e),s=`${o}.${process.pid}.tmp`;try{B.writeFileSync(s,n,{encoding:"utf8",mode:384}),B.renameSync(s,o);}finally{try{B.unlinkSync(s);}catch(a){if(a.code!=="ENOENT")throw a}}return {outputPath:o,...Ut[r],bytes:Buffer.byteLength(n)}}function Te(t){return JSON.stringify(t.schemaVersion==="workspace-activity-monitor-fleet.v1"?{...t,generatedAt:"",scopes:t.scopes.map(e=>({...e,generatedAt:""}))}:{...t,generatedAt:""})}function Yt(t,e,r={}){let o=Math.max(1,r.height??process.stdout.rows??28),n=e.split(`
10
- `).slice(0,o),s=Math.min(o,Math.max(t.length,n.length)),a=r.force?"\x1B[2J":"",i=r.force===true;for(let c=0;c<s;c+=1){let d=n[c]??"";!r.force&&t[c]===d||(i=true,a+=`\x1B[${c+1};1H\x1B[2K${d}`);}return i&&(a+=`\x1B[${Math.min(o,n.length+1)};1H`),{output:a,lines:n}}function Be(t,e,r){return Nt(D(t,{selectedRunId:e.selectedRunId,activeOnly:e.activeOnly,maxRuns:r}))}function At(t,e,r){let o=D(t,{selectedRunId:e.selectionPinned?e.selectedRunId:void 0,activeOnly:e.activeOnly,maxRuns:r});e.selectedRunId=o.selectedRunId;}function Ht(t,e,r,o){let n=Be(e,r,o);if(n.length===0)return;let s=Math.max(0,n.indexOf(r.selectedRunId??""));r.selectedRunId=n[(s+t+n.length)%n.length],r.selectionPinned=true,r.dirty=true;}function Le(t){let e=process.stdin;if(!e.isTTY||typeof e.setRawMode!="function")return null;let r=e.isRaw,o=e.isPaused(),n=s=>{let a=s.toString();if(a===""||a.toLowerCase()==="q"){t.stop();return}if(a==="\x1B[A"||a==="\x1B[D"||a.toLowerCase()==="k"){Ht(-1,t.snapshot(),t.state,t.maxRuns);return}if(a==="\x1B[B"||a==="\x1B[C"||a.toLowerCase()==="j"){Ht(1,t.snapshot(),t.state,t.maxRuns);return}if(a==="\r"||a===`
11
- `){t.state.focused=!t.state.focused,t.state.focused&&(t.state.selectionPinned=true),t.state.dirty=true;return}if(a.toLowerCase()==="f"){t.state.activeOnly=!t.state.activeOnly,At(t.snapshot(),t.state,t.maxRuns),t.state.dirty=true;return}(a===" "||a.toLowerCase()==="i")&&(t.state.inspector=!t.state.inspector,t.state.dirty=true);};return e.setRawMode(true),e.resume(),e.on("data",n),()=>{e.removeListener("data",n),e.setRawMode(r===true),o&&e.pause();}}async function Pe(t){let e=gt({targetPath:t.targetPath,runId:t.runId,maxRuns:t.maxRuns});if(e.events.length===0)throw new Error(`No activity journal found for run ${t.runId}.`);let r=f=>Tt({resolvedScope:e.resolvedScope,events:e.events,eventCount:f+1,diagnostics:e.diagnostics}),o=r(e.events.length-1);if(t.options.once||t.options.json||t.options.accessible||t.options.classic||!process.stdout.isTTY||!process.stdin.isTTY)return process.stdout.write(t.options.json?`${JSON.stringify(o,null,2)}
12
- `:`${Y(o,{width:process.stdout.columns,height:process.stdout.rows,maxRuns:t.maxRuns,selectedRunId:t.runId,color:t.options.color,motion:false,ascii:t.options.ascii,accessible:t.options.accessible,classic:t.options.classic})}
13
- `),o;let n=0,s=false,a=false,i=true,c=[],d=process.stdin,u=d.isRaw,l=d.isPaused(),p=f=>{let m=f.toString();m===""||m.toLowerCase()==="q"?a=true:m===" "?s=!s:m==="\x1B[C"||m==="."?(n=Math.min(e.events.length-1,n+1),s=true):(m==="\x1B[D"||m===",")&&(n=Math.max(0,n-1),s=true),i=true;};d.setRawMode(true),d.resume(),d.on("data",p),process.stdout.write("\x1B[?1049h\x1B[?25l");try{for(;!a;){n>=e.events.length-1&&!s&&(s=true,i=true);let f=r(n);if(i){let E=Y(f,{width:process.stdout.columns,height:process.stdout.rows,maxRuns:t.maxRuns,selectedRunId:t.runId,focused:true,frame:n,color:t.options.color,motion:t.options.motion,ascii:t.options.ascii,accessible:t.options.accessible,classic:t.options.classic,inspector:true,interactive:true,replay:{index:n+1,total:e.events.length,paused:s,speed:t.speed}}),I=Yt(c,E,{force:c.length===0,height:process.stdout.rows});I.output&&process.stdout.write(I.output),c=I.lines,i=false;}if(s||n>=e.events.length-1){s=n>=e.events.length-1?true:s,await new Promise(E=>setTimeout(E,50));continue}let m=Date.parse(e.events[n]?.timestamp??""),v=Date.parse(e.events[n+1]?.timestamp??""),h=Math.max(30,Math.min(1e3,(v-m)/t.speed||30));await new Promise(E=>setTimeout(E,h)),n+=1,i=true;}}finally{d.removeListener("data",p),d.setRawMode(u===true),l&&d.pause(),process.stdout.write("\x1B[0m\x1B[?25h\x1B[?1049l");}return r(n)}async function rn(t){let e=_.resolve(t.targetPath??process.cwd()),r=Math.max(1,Math.min(50,t.maxRuns??6)),o=Math.max(1,Math.min(50,t.maxScopes??12)),n=Math.max(100,Math.min(5e3,t.refreshMs??250)),s=Math.max(.25,Math.min(64,t.replaySpeed??4));if(t.replayRunId){if(t.global)throw new Error("--replay cannot be combined with --global.");return Pe({targetPath:e,runId:t.replayRunId,speed:s,maxRuns:r,options:t})}t.global||Ot({targetPath:e});let a=()=>t.global?Lt({runId:t.runId,maxRuns:r,maxScopes:o}):Pt({targetPath:e,runId:t.runId,maxRuns:r}),i=a(),c=!!(process.stdout.isTTY&&process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&!t.json&&!t.accessible),d={selectedRunId:t.runId,selectionPinned:!!t.runId,focused:!!t.runId,activeOnly:false,inspector:true,dirty:true},u=0,l=()=>({width:process.stdout.columns,height:process.stdout.rows,maxRuns:r,selectedRunId:d.selectedRunId,focused:d.focused,activeOnly:d.activeOnly,frame:u,color:t.color,motion:t.motion,ascii:t.ascii,accessible:t.accessible,classic:t.classic,interactive:c,inspector:d.inspector});if(At(i,d,r),t.capturePath){let b=zt(i,{outputPath:t.capturePath,runId:d.selectedRunId,preset:t.capturePreset,theme:t.captureTheme,redact:t.captureRedact});return process.stdout.write(`${JSON.stringify({kind:"workspai.live.capture",...b},null,t.json?2:0)}
14
- `),i}if(t.once)return t.json?process.stdout.write(`${JSON.stringify(i,null,2)}
15
- `):process.stdout.write(`${Y(i,l())}
16
- `),i;let p=false,f,m=()=>{p=true,f?.();},v=b=>new Promise(M=>{let k=setTimeout(()=>{f=void 0,M();},b);f=()=>{clearTimeout(k),f=void 0,M();};});process.once("SIGINT",m),process.once("SIGTERM",m);let h=true,E=()=>{h=true,d.dirty=true;};process.stdout.on("resize",E);let I=c?Le({snapshot:()=>i,state:d,maxRuns:r,stop:m}):null;c&&process.stdout.write("\x1B[?1049h\x1B[?25l");let w="",T=[],y=0,S=c&&t.motion!==false&&process.env.WORKSPAI_LIVE_REDUCED_MOTION!=="1"&&process.env.CI!=="true";try{for(;!p;){let b=Date.now();if((y===0||b-y>=n)&&(i=a(),At(i,d,r),y=b,d.dirty=true),c){let k=Y(i,l()),$=Yt(T,k,{force:h,height:process.stdout.rows});$.output&&process.stdout.write($.output),T=$.lines,h=false,d.dirty=false,u+=1;}else {let k=JSON.stringify(i),$=Te(i);$!==w&&(process.stdout.write(t.json?`${k}
17
- `:`${Y(i,l())}
18
- `),w=$);}let M=S&&Wt(D(i,{selectedRunId:d.selectedRunId,activeOnly:d.activeOnly,maxRuns:r}));p||await v(M?Math.min(n,125):n);}}finally{I?.(),process.removeListener("SIGINT",m),process.removeListener("SIGTERM",m),process.stdout.removeListener("resize",E),c&&process.stdout.write("\x1B[0m\x1B[?25h\x1B[?1049l");}return i}export{Te as activitySnapshotComparisonKey,Yt as renderActivityScreenDiff,rn as runLiveCommand};
@@ -1 +0,0 @@
1
- export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-4XEH3WNV.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-H5RJCS5E.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-VA5VSOBL.js';
@@ -1 +0,0 @@
1
- export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-D4UHRJAP.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-H5RJCS5E.js';
@@ -1 +0,0 @@
1
- export{a as WORKSPACE_GRAPH_TOKEN_EFFICIENCY_SCHEMA_VERSION,b as buildWorkspaceGraphTokenEfficiencyReport}from'./chunk-H7MRINGP.js';
@@ -1 +0,0 @@
1
- import {a as a$1,b as b$1,c,d as d$1}from'./chunk-5U4L6VF2.js';import {a}from'./chunk-AFIFZTOY.js';import {e}from'./chunk-6UNATTB7.js';import d from'crypto';import s from'path';import {open,unlink,stat}from'fs/promises';import u from'fs-extra';var k=e.evaluationLive,O=e.evaluationLastRun,W="contracts/workspace-intelligence/model-usage-event.v1.json",E="contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",P="contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json",_=3e4,N=100,b=25;function C(){return {modelCalls:0,toolCalls:0,tokenSources:{providerReported:0,tokenizerCounted:0,estimated:0,unavailable:0},tokens:{input:0,output:0,cachedInput:0,reasoning:0,observedTotal:0},latencyMs:0,costs:[],outcome:{status:"unknown",verified:false,blockersResolved:0},efficiency:{tokensPerVerifiedOutcome:null,noProgressDecisions:0,repeatedArtifactReads:0}}}function m(t){return t??0}function S(t){let e=C(),a=new Map,n=new Map;for(let o of t){if(o.kind==="model-call"){e.modelCalls+=1;let r={"provider-reported":"providerReported","tokenizer-counted":"tokenizerCounted",estimated:"estimated",unavailable:"unavailable"}[o.modelCall.source];if(e.tokenSources[r]+=1,e.tokens.input+=m(o.modelCall.inputTokens),e.tokens.output+=m(o.modelCall.outputTokens),e.tokens.cachedInput+=m(o.modelCall.cachedInputTokens),e.tokens.reasoning+=m(o.modelCall.reasoningTokens),e.latencyMs+=o.modelCall.latencyMs??0,o.modelCall.cost){let i=o.modelCall.cost.currency.toUpperCase(),l=n.get(i)??{currency:i,amount:0,providerReported:0,estimated:0};l.amount+=o.modelCall.cost.amount,o.modelCall.cost.source==="provider-reported"?l.providerReported+=o.modelCall.cost.amount:l.estimated+=o.modelCall.cost.amount,n.set(i,l);}continue}if(o.kind==="tool-call"){e.toolCalls+=1,e.latencyMs+=o.toolCall.durationMs??0,!o.toolCall.changedSource&&o.toolCall.result==="passed"&&(e.efficiency.noProgressDecisions+=1),o.toolCall.artifact&&a.set(o.toolCall.artifact,(a.get(o.toolCall.artifact)??0)+1);continue}o.kind==="outcome"&&(e.outcome={status:o.outcome.status,verified:o.outcome.verified,blockersResolved:o.outcome.blockersResolved});}return e.tokens.observedTotal=e.tokens.input+e.tokens.output,e.costs=[...n.values()].map(o=>({...o,amount:Number(o.amount.toFixed(8)),providerReported:Number(o.providerReported.toFixed(8)),estimated:Number(o.estimated.toFixed(8))})).sort((o,r)=>o.currency.localeCompare(r.currency)),e.efficiency.repeatedArtifactReads=[...a.values()].reduce((o,r)=>o+Math.max(0,r-1),0),e.efficiency.tokensPerVerifiedOutcome=e.outcome.verified&&e.outcome.status==="passed"?e.tokens.observedTotal:null,e}function x(t,e=new Date){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Evaluation event must be a JSON object.");let a$2=t,n={...a$2,schemaVersion:a$1,eventId:typeof a$2.eventId=="string"&&a$2.eventId.trim()?a$2.eventId.trim():d.randomUUID(),recordedAt:typeof a$2.recordedAt=="string"&&a$2.recordedAt.trim()?a$2.recordedAt:e.toISOString()};a(n,W,"workspace evaluation event");let o={"model-call":"modelCall","tool-call":"toolCall",outcome:"outcome",milestone:"milestone"}[n.kind],r=["modelCall","toolCall","outcome","milestone"].filter(i=>a$2[i]!==void 0);if(r.length!==1||r[0]!==o)throw new Error(`Evaluation event kind ${n.kind} requires only ${o}.`);if(n.kind==="model-call"&&n.modelCall.source!=="unavailable"&&n.modelCall.inputTokens===null&&n.modelCall.outputTokens===null)throw new Error("Measured model calls require at least one input or output token count.");return n}function J(t){let e=t.now??new Date,a$1=s.resolve(t.workspacePath),n={schemaVersion:b$1,runId:t.runId??d.randomUUID(),sessionId:t.sessionId??d.randomUUID(),status:"live",startedAt:e.toISOString(),updatedAt:e.toISOString(),workspace:{name:t.workspaceName?.trim()||s.basename(a$1),path:a$1},configuration:{taskId:t.taskId.trim(),strategy:t.strategy??"workspace-intelligence",...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.temperature!==void 0?{temperature:t.temperature}:{},...t.baselineRunId?{baselineRunId:t.baselineRunId}:{}},methodology:{id:"provider-usage-and-verified-outcome.v1",claimBoundary:"Provider-reported and tokenizer-counted values are measured; estimated values remain explicitly labelled. Verified task success is required before reporting tokens per successful outcome."},events:[],summary:C()};return a(n,E,"workspace evaluation"),n}async function L(t,e){await u.ensureDir(s.dirname(t));let a=`${t}.${process.pid}.${d.randomUUID()}.tmp`;try{await u.writeJson(a,e,{spaces:2}),await u.rename(a,t);}finally{await u.remove(a).catch(()=>{});}}async function A(t,e){let a=s.join(s.resolve(t),`${k}.lock`);await u.ensureDir(s.dirname(a));for(let n=0;n<N;n+=1)try{let o=await open(a,"wx");try{return await o.writeFile(JSON.stringify({pid:process.pid,acquiredAt:new Date().toISOString()})),await e()}finally{await o.close(),await unlink(a).catch(()=>{});}}catch(o){if(o.code!=="EEXIST")throw o;let i=await stat(a).catch(()=>null);if(i&&Date.now()-i.mtimeMs>_){await unlink(a).catch(()=>{});continue}await new Promise(l=>setTimeout(l,b));}throw new Error("Timed out waiting for the workspace evaluation writer lock.")}async function v(t,e,a$1=k){let n=s.join(s.resolve(t),a$1);return a(e,E,a$1),await L(n,e),n}async function T(t,e=k){let a$1=s.isAbsolute(e)?e:s.join(s.resolve(t),e),n=await u.readJson(a$1);return a(n,E,a$1),n}async function G(t){return A(t.workspacePath,async()=>{let e=await T(t.workspacePath);if(e.status!=="live")throw new Error(`Evaluation ${e.runId} is ${e.status}; initialize a new run.`);let a=x(t.payload,t.now);if(e.events.some(o=>o.eventId===a.eventId))return e;let n={...e,updatedAt:(t.now??new Date).toISOString(),events:[...e.events,a],summary:S([...e.events,a])};return await v(t.workspacePath,n),n})}async function H(t){return A(t.workspacePath,async()=>{let e=await T(t.workspacePath),a=(t.now??new Date).toISOString(),n={...e,status:t.status??"completed",updatedAt:a,completedAt:a,summary:S(e.events)},o=await v(t.workspacePath,n,O);return await v(t.workspacePath,n),{report:n,outputPath:o}})}function q(t,e){let a$1=t.summary.tokens.observedTotal,n=e.summary.tokens.observedTotal,o=a$1-n,r={schemaVersion:c,generatedAt:new Date().toISOString(),taskAligned:t.configuration.taskId===e.configuration.taskId,current:{runId:t.runId,strategy:t.configuration.strategy,tokens:a$1,verified:t.summary.outcome.verified,status:t.summary.outcome.status},baseline:{runId:e.runId,strategy:e.configuration.strategy,tokens:n,verified:e.summary.outcome.verified,status:e.summary.outcome.status},delta:{tokens:o,reductionPercent:n===0?null:Number((-o/n*100).toFixed(2)),modelCalls:t.summary.modelCalls-e.summary.modelCalls,toolCalls:t.summary.toolCalls-e.summary.toolCalls,latencyMs:Number((t.summary.latencyMs-e.summary.latencyMs).toFixed(2))},comparableOutcome:t.summary.outcome.verified&&e.summary.outcome.verified&&t.summary.outcome.status===e.summary.outcome.status};return a(r,P,"workspace evaluation comparison"),r}function B(){if(d$1.length!==4)throw new Error("Model usage source taxonomy is incomplete.")}export{O as WORKSPACE_EVALUATION_LAST_RUN_PATH,k as WORKSPACE_EVALUATION_LIVE_PATH,G as appendWorkspaceEvaluationEvent,B as assertWorkspaceEvaluationSourceTaxonomy,q as compareWorkspaceEvaluations,J as createWorkspaceEvaluation,H as finalizeWorkspaceEvaluation,x as normalizeWorkspaceEvaluationEvent,T as readWorkspaceEvaluation,S as summarizeWorkspaceEvaluation,v as writeWorkspaceEvaluation};
@@ -1 +0,0 @@
1
- export{a as readWorkspaceKnowledgeGraphSnapshot}from'./chunk-UPIPSSXY.js';
@@ -1 +0,0 @@
1
- export{a as runWorkspaceStage}from'./chunk-R2M5OJOK.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-5XGR3LRI.js';