@testmuai/kane-cli 0.6.6 → 0.6.8

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 (187) hide show
  1. package/dist/ChatSurface-QLRMFZJG.js +8 -0
  2. package/dist/{ChromeProfilePicker-6PLUQ5TW.js → ChromeProfilePicker-FJOUNY2B.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-I4F56IVK.js → CliFeedbackPrompt-HC4NNBTK.js} +1 -1
  4. package/dist/{CliUploadProgress-ULRSPKY3.js → CliUploadProgress-VIEZQNZ5.js} +1 -1
  5. package/dist/{ConfigView-7NMYALEA.js → ConfigView-LK5F4F7W.js} +1 -1
  6. package/dist/EvidenceViewOffer-HZ4WZKGM.js +2 -0
  7. package/dist/{FolderPicker-4IOVDO2P.js → FolderPicker-3S57MSC6.js} +1 -1
  8. package/dist/{HelpView-SHMVMHNU.js → HelpView-BQ3TS7WE.js} +1 -1
  9. package/dist/{InfoBox-W2LZVGQS.js → InfoBox-4HVXV3TD.js} +1 -1
  10. package/dist/{LinksBox-ZS25VTBY.js → LinksBox-3B2KO5S4.js} +1 -1
  11. package/dist/{ProfilesView-XBBRIQ3U.js → ProfilesView-FLRMROUR.js} +1 -1
  12. package/dist/{ProjectPicker-AUN47FXS.js → ProjectPicker-R3KLRGHH.js} +1 -1
  13. package/dist/{SaveSessionPrompt-Z2K225VN.js → SaveSessionPrompt-P7HSG7R7.js} +1 -1
  14. package/dist/SingleShotApp-ZBZY7KGR.js +2 -0
  15. package/dist/{SummaryBox-4T545XRB.js → SummaryBox-HCDIWKPS.js} +1 -1
  16. package/dist/TestMdRunView-GQP2QGFU.js +2 -0
  17. package/dist/{WhoamiView-GCVD35EX.js → WhoamiView-ZD6FIBMK.js} +1 -1
  18. package/dist/{bind-JLMT57Q3.js → bind-RSVQXQJT.js} +2 -2
  19. package/dist/{bridge-PDJEOSAJ.js → bridge-D2HETW5M.js} +1 -1
  20. package/dist/{changelog-D65HWZDM.js → changelog-QB7S4VV4.js} +1 -1
  21. package/dist/chat-committer-MWZ4JQMM.js +2 -0
  22. package/dist/chat-controller-YX5A7R52.js +2 -0
  23. package/dist/{chunk-BLSZ4H5W.js → chunk-27GF2OQ7.js} +3 -3
  24. package/dist/chunk-35RV2AAV.js +12 -0
  25. package/dist/{chunk-MSPZOEFB.js → chunk-3BIEIXJK.js} +1 -1
  26. package/dist/chunk-4GXOBABK.js +4 -0
  27. package/dist/chunk-5VC7MBHR.js +2 -0
  28. package/dist/{chunk-MY32TBBR.js → chunk-66LXV7NN.js} +1 -1
  29. package/dist/chunk-6WHKJSMJ.js +6 -0
  30. package/dist/{chunk-GYW7LVVL.js → chunk-7Z64BL5D.js} +1 -1
  31. package/dist/{chunk-BV5QKFMJ.js → chunk-A6TFZQV6.js} +1 -1
  32. package/dist/{chunk-JU5KRCKD.js → chunk-ATO6NM45.js} +1 -1
  33. package/dist/{chunk-S2C62SDY.js → chunk-AXJIXRYF.js} +1 -1
  34. package/dist/{chunk-L26LU6TU.js → chunk-B22NUHB2.js} +2 -2
  35. package/dist/chunk-BLHCGRSK.js +11 -0
  36. package/dist/chunk-BSFONZ2E.js +2 -0
  37. package/dist/{chunk-P4HW2NTZ.js → chunk-BUVRZXO3.js} +1 -1
  38. package/dist/chunk-CVOGP253.js +2 -0
  39. package/dist/{chunk-JTEY32TL.js → chunk-D4WLVWJQ.js} +1 -1
  40. package/dist/{chunk-HA5GE57Z.js → chunk-D5IZ77YG.js} +2 -2
  41. package/dist/chunk-DNNZ353O.js +4 -0
  42. package/dist/chunk-E4EHWO3J.js +4 -0
  43. package/dist/{chunk-LLS47HUA.js → chunk-ELN3EN4K.js} +1 -1
  44. package/dist/{chunk-RV2NXHIC.js → chunk-EQORZ6RT.js} +1 -1
  45. package/dist/chunk-EYZWG32F.js +13 -0
  46. package/dist/{chunk-6NIV7AVZ.js → chunk-F4FXE466.js} +1 -1
  47. package/dist/chunk-FCMLIK7P.js +2 -0
  48. package/dist/{chunk-EWTX7HSU.js → chunk-FCZ2YFD3.js} +2 -2
  49. package/dist/{chunk-EOLQUB4Q.js → chunk-GFKIE3AL.js} +1 -1
  50. package/dist/chunk-GG43HSU2.js +3 -0
  51. package/dist/{chunk-3Z3UIW5H.js → chunk-GO4CBUB6.js} +1 -1
  52. package/dist/{chunk-UZJ7MRBV.js → chunk-HCWEZCKP.js} +1 -1
  53. package/dist/chunk-IAHKTEET.js +2 -0
  54. package/dist/{chunk-6XHAXAL2.js → chunk-IQFUBT6Z.js} +1 -1
  55. package/dist/{chunk-WJGBXJT4.js → chunk-JKHQBGFY.js} +2 -2
  56. package/dist/{chunk-AKHUNBQS.js → chunk-K4ERF7GT.js} +1 -1
  57. package/dist/chunk-K4LCN5X4.js +6 -0
  58. package/dist/{chunk-D7L6UW5Z.js → chunk-K7P6VNLI.js} +1 -1
  59. package/dist/chunk-L3HG5ONB.js +4 -0
  60. package/dist/{chunk-ZZLR3O5A.js → chunk-L4JIMNKW.js} +1 -1
  61. package/dist/chunk-LEA6IHXC.js +2 -0
  62. package/dist/chunk-MBXWXBDM.js +4 -0
  63. package/dist/{chunk-4SXD6XWV.js → chunk-MEHEGW3V.js} +1 -1
  64. package/dist/{chunk-2WO7G2HO.js → chunk-N5YIMTGV.js} +1 -1
  65. package/dist/{chunk-VBCE4U4B.js → chunk-NKCXCCPM.js} +1 -1
  66. package/dist/{chunk-C42WWO7Y.js → chunk-NKUA3TSO.js} +1 -1
  67. package/dist/{chunk-2PQXEEVY.js → chunk-NVGBE2DR.js} +1 -1
  68. package/dist/chunk-NVGTSXCJ.js +9 -0
  69. package/dist/{chunk-6GTOYTCQ.js → chunk-OSALXGD4.js} +1 -1
  70. package/dist/{chunk-LEQ2B3PR.js → chunk-OYOTWI53.js} +1 -1
  71. package/dist/{chunk-N6DO2LBH.js → chunk-PV4EDQY4.js} +1 -1
  72. package/dist/{chunk-6SGPN76K.js → chunk-PXPXK4Q7.js} +1 -1
  73. package/dist/{chunk-24OFJ7SE.js → chunk-Q3WHZ26R.js} +1 -1
  74. package/dist/{chunk-LABIRPOT.js → chunk-QFD6CB4P.js} +1 -1
  75. package/dist/chunk-QM4S2APK.js +2 -0
  76. package/dist/{chunk-JV356AYH.js → chunk-QOGQBVTP.js} +2 -2
  77. package/dist/chunk-QZ7DZXLQ.js +14 -0
  78. package/dist/chunk-RGDQMKNJ.js +4 -0
  79. package/dist/chunk-SHAA6FOD.js +11 -0
  80. package/dist/{chunk-5JJ245FW.js → chunk-TAUSKB3O.js} +1 -1
  81. package/dist/{chunk-XQL53VB7.js → chunk-TBXIOT6M.js} +1 -1
  82. package/dist/chunk-TFVMSEIA.js +2 -0
  83. package/dist/{chunk-KI2DVQSA.js → chunk-TRXNJZSL.js} +1 -1
  84. package/dist/{chunk-HWA7WD44.js → chunk-VRVSOGXH.js} +1 -1
  85. package/dist/{chunk-24VYAMMK.js → chunk-VZHXNQDO.js} +1 -1
  86. package/dist/chunk-XSAZDIQV.js +347 -0
  87. package/dist/chunk-XWIN3S7O.js +4 -0
  88. package/dist/{chunk-32GP7KTM.js → chunk-YEMR62WY.js} +1 -1
  89. package/dist/chunk-YKZIACYJ.js +2 -0
  90. package/dist/{chunk-2BWRAY3Y.js → chunk-YTK3IQUB.js} +1 -1
  91. package/dist/{chunk-FJTWJ243.js → chunk-ZPDM6FO7.js} +1 -1
  92. package/dist/{config-6PAZZ7CR.js → config-JV7HNJ3I.js} +1 -1
  93. package/dist/cover-cmd-L2HSVDLH.js +2 -0
  94. package/dist/{credentials-BJCIWQWA.js → credentials-TQW3TT2I.js} +1 -1
  95. package/dist/{descriptor-EHK3DRCZ.js → descriptor-KXDJ4XYD.js} +1 -1
  96. package/dist/dossier-ZHSHATVU.js +3 -0
  97. package/dist/evidence-ZFYDHO73.js +2 -0
  98. package/dist/evolve-cmd-YGJECGND.js +2 -0
  99. package/dist/explain-VTRHEVUQ.js +2 -0
  100. package/dist/{explain-cmd-U367SD4N.js → explain-cmd-327F6ESA.js} +1 -1
  101. package/dist/{explain-cmd-KV5YUXKB.js → explain-cmd-E366QTAD.js} +1 -1
  102. package/dist/extract-bind-7UZXDON6.js +5 -0
  103. package/dist/{extract-cmd-Z4PMDIMZ.js → extract-cmd-TQ2MYXOG.js} +1 -1
  104. package/dist/gaps-cmd-IAEXXESW.js +2 -0
  105. package/dist/{generate-headless-IWY32HC4.js → generate-headless-XXECVP6L.js} +2 -2
  106. package/dist/index.js +12 -12
  107. package/dist/ingest-CBQAXVH6.js +2 -0
  108. package/dist/ingest-cmd-JN6PLDE3.js +3 -0
  109. package/dist/interactive-bind-WA2YVAUW.js +7 -0
  110. package/dist/lifecycle-cmd-KZOC4WDW.js +2 -0
  111. package/dist/list-cmd-6X5U46RD.js +3 -0
  112. package/dist/{list-commands-SSXJQGE7.js → list-commands-I577A5LK.js} +1 -1
  113. package/dist/{logical-ids-3Y6RX5C2.js → logical-ids-RFGWBVML.js} +1 -1
  114. package/dist/login-flow-OVEZXSMW.js +2 -0
  115. package/dist/maintenance-cmd-UJG4LPWD.js +2 -0
  116. package/dist/pdf-convert-KYXI4FU4.js +2 -0
  117. package/dist/{persist-recorded-session-3AOYZJT2.js → persist-recorded-session-DT3K6ZYQ.js} +1 -1
  118. package/dist/pipeline-5N7HWGAL.js +2 -0
  119. package/dist/readmodel-V3DVL6NP.js +2 -0
  120. package/dist/reconcile-cmd-HYYH3SZS.js +2 -0
  121. package/dist/{recording-banner-KKEUWS3N.js → recording-banner-QI77ERTZ.js} +1 -1
  122. package/dist/{require-project-folder-NPTKR2AW.js → require-project-folder-2UAXXZA4.js} +1 -1
  123. package/dist/revert-FRXNIP5R.js +2 -0
  124. package/dist/{review-cmd-4WZUUOE4.js → review-cmd-XVWPSWU2.js} +1 -1
  125. package/dist/run-RYIYWV63.js +2 -0
  126. package/dist/run-VMKZDO7J.js +2 -0
  127. package/dist/{run-test-md-QNC6KDMN.js → run-test-md-DKRJOUFA.js} +2 -2
  128. package/dist/{skill-installer-ULFNSE6X.js → skill-installer-TK5REDD6.js} +1 -1
  129. package/dist/{spawner-DWONVIPI.js → spawner-K7LWPNIC.js} +1 -1
  130. package/dist/tcg-generate-6EJLU5KX.js +2 -0
  131. package/dist/{testmd-actions-S3ZNOZEK.js → testmd-actions-Q2XWL7P5.js} +1 -1
  132. package/dist/token-refresh-NQZJEUQE.js +2 -0
  133. package/dist/{validate-basic-4OLDKIA2.js → validate-basic-XEJGB4GN.js} +1 -1
  134. package/dist/{version-check-UL4S6R4N.js → version-check-IT7T5YKJ.js} +1 -1
  135. package/dist/{view-cmd-FRMQF76B.js → view-cmd-G4PGJRQH.js} +3 -3
  136. package/dist/walk-session-HCTG4LN2.js +2 -0
  137. package/package.json +7 -6
  138. package/dist/ChatSurface-LV3KW6WN.js +0 -8
  139. package/dist/EvidenceViewOffer-KQKPTMXA.js +0 -2
  140. package/dist/SingleShotApp-M7R5PW4X.js +0 -2
  141. package/dist/TestMdRunView-JXRXMACE.js +0 -2
  142. package/dist/chat-committer-ADJJTDUT.js +0 -2
  143. package/dist/chat-controller-VAC57IEV.js +0 -3
  144. package/dist/chunk-262ES67I.js +0 -14
  145. package/dist/chunk-4A6BLXQN.js +0 -13
  146. package/dist/chunk-4R2HOA7J.js +0 -14
  147. package/dist/chunk-64LC36AF.js +0 -2
  148. package/dist/chunk-6AYUSR7X.js +0 -2
  149. package/dist/chunk-6CZIEK6B.js +0 -11
  150. package/dist/chunk-6PS65QFF.js +0 -2
  151. package/dist/chunk-74RUSHIB.js +0 -4
  152. package/dist/chunk-GBBVP2JW.js +0 -2
  153. package/dist/chunk-JF7Q2I45.js +0 -2
  154. package/dist/chunk-KNCHEM6A.js +0 -9
  155. package/dist/chunk-KYHXDJN4.js +0 -2
  156. package/dist/chunk-LURGFJEE.js +0 -6
  157. package/dist/chunk-MCQXRJGH.js +0 -2
  158. package/dist/chunk-OFEOWKM3.js +0 -6
  159. package/dist/chunk-QPZRHAYK.js +0 -4
  160. package/dist/chunk-RE3BZVGE.js +0 -3
  161. package/dist/chunk-RIMJDJWY.js +0 -2
  162. package/dist/chunk-SJ2KQKOV.js +0 -3
  163. package/dist/chunk-WIA7TPK3.js +0 -2
  164. package/dist/chunk-WWH7CW5R.js +0 -356
  165. package/dist/chunk-ZG2V2ODK.js +0 -4
  166. package/dist/cover-cmd-K3LCXHAQ.js +0 -2
  167. package/dist/evidence-7VE5EGEF.js +0 -2
  168. package/dist/evolve-cmd-RUGUWKAG.js +0 -2
  169. package/dist/explain-VFIZTHFN.js +0 -2
  170. package/dist/extract-bind-YS7C4KZ3.js +0 -5
  171. package/dist/gaps-cmd-DTVDIOED.js +0 -2
  172. package/dist/ingest-C5ANIN7S.js +0 -2
  173. package/dist/ingest-cmd-LLC5CDQ5.js +0 -3
  174. package/dist/interactive-bind-ZIIJDRBU.js +0 -7
  175. package/dist/lifecycle-cmd-BXE5IMFN.js +0 -2
  176. package/dist/list-cmd-KBWPYJMV.js +0 -3
  177. package/dist/login-flow-HRS6YACY.js +0 -2
  178. package/dist/maintenance-cmd-VS3APIUN.js +0 -2
  179. package/dist/pipeline-IZSODNCC.js +0 -2
  180. package/dist/readmodel-XOGOELUP.js +0 -2
  181. package/dist/reconcile-cmd-6HVZJFG3.js +0 -2
  182. package/dist/revert-AQQ2VHRM.js +0 -2
  183. package/dist/run-2A7M7EJK.js +0 -2
  184. package/dist/run-6AFY35QW.js +0 -2
  185. package/dist/tcg-generate-IHHPRVNG.js +0 -2
  186. package/dist/token-refresh-CFVOA62N.js +0 -2
  187. package/dist/walk-session-N3BP57HK.js +0 -2
@@ -0,0 +1,12 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{f as je}from"./chunk-K5JGCJ2K.js";import{a as pe,e as Te,g as Ne,h as qe}from"./chunk-NVGTSXCJ.js";import{b as Fe,f as Ue,g as He,h as Ge}from"./chunk-FXPPQL4D.js";import{a as Pe}from"./chunk-GG43HSU2.js";import{a as Ae,b as Ie}from"./chunk-JFAFKHDX.js";import{c as Oe}from"./chunk-OSALXGD4.js";import{a as se,b as Ee}from"./chunk-DNNZ353O.js";import{b as Me}from"./chunk-YKTYVJBN.js";import{a as Be}from"./chunk-CVOGP253.js";import{a as V}from"./chunk-NVGBE2DR.js";import{a as R}from"./chunk-LEA6IHXC.js";import{e as z,f as re}from"./chunk-L3HG5ONB.js";import{b as Re}from"./chunk-IAHKTEET.js";import{d as H}from"./chunk-5YPBPZUR.js";import{appendFileSync as st,mkdirSync as he,writeFileSync as _e}from"fs";import{extname as ot,join as M}from"path";var E=class extends Error{code;constructor(e,c){super(`${e}: ${c}`),this.name="ProposalAdapterError",this.code=e}};function Le(s){return s.version===2}function We(s,e){if(s.read_basis.length!==1)throw new E("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${s.read_basis.length}`);let c=s.read_basis[0],x=s.use_cases.map(o=>{if(o.cite.length!==1)throw new E("CITE_COUNT",`${o.temp_ref}: cite must have exactly 1 element, got ${o.cite.length}`);let g=o.cite[0];if(g.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}: cite source ${g.source_id} != read_basis source ${c.source_id} (single-source)`);return{temp_ref:o.temp_ref,title:o.title,...o.description!==void 0?{description:o.description}:{},...o.summary!==void 0?{summary:o.summary}:{},...o.actors!==void 0?{actors:o.actors}:{},...o.value!==void 0?{value:o.value}:{},risk:o.risk,cite:{anchor:g.anchor,quote:g.quote},...o.criteria!=null&&o.criteria.length>0?{criteria:o.criteria.map((d,h)=>{if(d.cite.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}.criteria[${h}]: cite source ${d.cite.source_id} != read_basis source ${c.source_id} (single-source)`);return{text:d.text,cite:{anchor:d.cite.anchor,quote:d.cite.quote}}})}:{},depends_on_hint:o.depends_on_hint,matches_existing:o.matches_existing,...o.conflicts_with!=null?{conflicts_with:o.conflicts_with}:{},...o.changed?{changed:!0}:{},...o.updated!=null?{updated:{...o.updated.title!=null?{title:o.updated.title}:{},...o.updated.description!=null?{description:o.updated.description}:{},...o.updated.summary!=null?{summary:o.updated.summary}:{},...o.updated.actors!=null?{actors:o.updated.actors}:{},...o.updated.value!=null?{value:o.updated.value}:{},...o.updated.risk!=null?{risk:o.updated.risk}:{},...o.updated.criteria!=null?{criteria:o.updated.criteria.map((d,h)=>{if(d.cite.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}.updated.criteria[${h}]: cite source ${d.cite.source_id} != read_basis source ${c.source_id} (single-source)`);return{text:d.text,cite:{anchor:d.cite.anchor,quote:d.cite.quote}}})}:{}}}:{},...o.change_note!=null?{change_note:o.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:c.source_id,source_cid:c.source_cid},use_cases:x}}function ze(s){let{contextDir:e,graph:c}=s,x=s.maxDigestBytes??4096,o={},g=[];for(let[u,l]of c.heads){if(o[u]=l,typeof l!="string")continue;let _=c.mediaOf(l),k=c.getNode(l)?.content?.blob;if(typeof k=="string")if(_.format==="image")g.push({source_id:u,cid:l,format:"image",blobRef:{path:V(e,k),cid:k}});else{let n=se(e,c,l)?.toString("utf8")??"";g.push({source_id:u,cid:l,format:_.format,text:n})}}g.sort((u,l)=>u.source_id<l.source_id?-1:1);let d=[];for(let u of c.byLabel(H.STYLENOTE).sort((l,_)=>l.cid<_.cid?-1:1))c.superseded.has(u.cid)||d.push(`\u2022 ${String(u.content.statement)} [${String(u.content.learned_from_kind)}]`);let h="";for(let u of d){if(Buffer.byteLength(h+u+`
3
+ `,"utf8")>x)break;h+=u+`
4
+ `}return{read_basis:o,sources:g,styleNoteDigest:h}}function Ve(s,e){let c=ze({contextDir:s,graph:e}).styleNoteDigest;return c.length>0?c:void 0}function it(s){return s.length>8&&s[0]===137&&s[1]===80&&s[2]===78&&s[3]===71?"image/png":s.length>3&&s[0]===255&&s[1]===216&&s[2]===255?"image/jpeg":s.length>12&&s.toString("ascii",0,4)==="RIFF"&&s.toString("ascii",8,12)==="WEBP"?"image/webp":null}function Je(s){return s.toISOString().replace(/[-:]/g,"").slice(0,15)}function nt(s){return s.startsWith("su-conv-")?`conv-${Re(Buffer.from(s,"utf8")).slice(0,8)}`:s}function Qe(s){return s.source_id.startsWith("su-conv-")?"the conversation":s.source_id}function at(s,e,c){return`reading ${Qe(s)}${c>1?` (source ${e} of ${c})`:""}`}function J(s){return s.toLowerCase().trim().replace(/\s+/g," ")}function Xe(s,e){let c=new Map,x=new Map,o=new Map;for(let{cid:d,content:h}of e.byLabel(H.USECASE)){if(e.superseded.has(d))continue;(e.trust.get(d)==="archived"?o:x).set(J(String(h.title??"")),d)}let g=d=>e.trust.get(d)==="archived"?{cid:d,archived:!0,reason:e.archivedReason.get(d)}:{cid:d};for(let d of s.use_cases){if(d.matches_existing){let l=d.matches_existing.cid;if(e.superseded.has(l)){let _=e.tipOf(l);l=e.superseded.has(_)?null:_}if(l!==null){c.set(d.temp_ref,g(l));continue}}let h=x.get(J(d.title));if(h){c.set(d.temp_ref,{cid:h});continue}let u=o.get(J(d.title));u&&c.set(d.temp_ref,g(u))}return c}var Ye=/^(\S+)\.criteria\[(\d+)\]/;function ct(s,e,c){if(e.length===0||!e.every(o=>Ye.test(o.detail)))return!1;let x=new Map;for(let o of e){let g=Ye.exec(o.detail),d=x.get(g[1])??new Set;d.add(Number(g[2])),x.set(g[1],d)}for(let o of s.use_cases){let g=x.get(o.temp_ref);g?.size&&(o.criteria=(o.criteria??[]).filter((d,h)=>!g.has(h)),c(`${o.temp_ref}: dropped ${g.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function Ke(s,e,c,x,o=()=>{},g){let d=(h,u)=>o(h,u,s.session_id);return Ne(s,e,c,x,o,{async onProposalEvent(h){let u=h,l=null,_=null;if(Le(u))try{l=We(u,s.read_basis),d("adapter",{ok:!0,use_cases:l.use_cases.length})}catch(k){_=k instanceof E?k.message:String(k),d("adapter",{ok:!1,error:_})}else l=u;return l&&l.use_cases.length===0&&e.out("warning: the agent proposed ZERO use-cases for this source"),l&&g&&await g(l),{proposal:l,error:_}}})}var dt=new Set(["agent","ci","override"]);async function Gt(s,e){let c=s.mode??"interactive";if(c==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!dt.has(c))return e.out(`extract: unknown mode "${c}" \u2014 interactive | agent | ci | override`),2;let x=Je(e.now?.()??new Date),o=M(e.contextDir,"logs");he(o,{recursive:!0});let g=M(o,`extract-${x}.log`),d=`run-${x}-${Math.random().toString(36).slice(2,8)}`,h=t=>t==="error"||t==="failed_proposal"?"error":t==="repair_respawn"?"warn":"info",u=(t,a,m)=>{try{st(g,JSON.stringify({ts:new Date().toISOString(),level:h(t),run_id:d,...m?{session_id:m}:{},kind:t,data:a})+`
5
+ `)}catch{}};e.out(`trace: ${pe(g)}`),e.emit?.({type:"run_start",mode:c,trace:g});let l=Me();if(l&&e.out(l),e.preflightTurn){let t=await e.preflightTurn();if(u("preflight",t),!t.ok)return e.out(t.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:t.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let _=R(e.contextDir),k=Ve(e.contextDir,_);if(s.source){if(s.resume){let a="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_WITH_RESUME"}),2}let t=_.heads.get(s.source);if(typeof t!="string"){let a=t===null?`error: --source ${s.source} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${s.source} is not an ingested source (kane-cli context list shows them)`;return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_UNKNOWN"}),2}}let n=null;if(s.resume){try{n=Ge(e.contextDir,s.resume,_)}catch(m){return e.out(`error: ${m instanceof Error?m.message:String(m)}`),e.emit?.({type:"error",message:`error: ${m instanceof Error?m.message:String(m)}`}),1}let t=n.handle.state.change_basis;if(t&&(_.heads.get(t.source_id)??null)!==t.new_head){let m=`error: ${t.source_id} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${s.resume} is defunct and can be ignored)`;return e.out(m),e.emit?.({type:"error",message:m,code:"CHANGE_BASIS_MOVED"}),n.handle.release(),2}n.staleBasis.length>0&&e.out(`note: changed since the pause: ${n.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let a=n.handle.state.held_receipts??[];if(a.length>0)if(e.chat?.holdReceipt)for(let m of a)e.chat.holdReceipt(m);else e={...e,initialMessage:[a.join(`
6
+
7
+ `),e.initialMessage].filter(Boolean).join(`
8
+
9
+ `)};n.handle.state.assumed.length>0&&e.out(`note: ${n.handle.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${s.resume} lists them`)}let xe=_.extractedSourceCids,X=!!(s.force||n?.handle.state.force),y=[],P=[];for(let[t,a]of _.heads.entries())if(a!=null&&!(s.source&&t!==s.source)){if(!s.source&&!n&&t.startsWith("su-conv-")){e.out(`skipped: ${t} \u2014 conversation source (extract it explicitly with --source ${t})`),P.push({source_id:t,reason:"conversation"});continue}if(n){let m=t in n.handle.state.read_basis,I=n.handle.state.corpus_cursor.remaining.includes(t);if(!m&&!I)continue;if(I&&!X&&xe.has(a)){e.out(`cached: ${t} @ ${a.slice(0,19)} already extracted \u2014 skipping`),P.push({source_id:t,reason:"cached"});continue}}else if(!X&&xe.has(a)){e.out(`cached: ${t} @ ${a.slice(0,19)} already extracted \u2014 skipping`),P.push({source_id:t,reason:"cached"});continue}y.push({source_id:t,cid:a})}let Ze=t=>{let a=je(e.contextDir,t);a&&e.out(`note: a reconcile plan for ${t} is pending (${a.pending} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${a.path}\``)};for(let t of P)t.reason==="cached"&&Ze(t.source_id);if(e.emit?.({type:"corpus",sources:y,skipped:P}),y.length===0){if(n){let m=`error: resumed session's paused source (${Object.keys(n.handle.state.read_basis).join(", ")||"unknown"}) is no longer in the corpus \u2014 restore/re-ingest it and re-run --resume ${s.resume}, or discard with: kane-cli context sessions clean ${s.resume}`;return e.out(m),e.emit?.({type:"error",message:m,code:"SOURCE_MISSING"}),n.handle.release(),2}let t=P.length>0&&P.every(a=>a.reason==="conversation");return e.out(s.source?`extract: nothing to do \u2014 ${s.source} is already extracted at its current snapshot (--force to re-run)`:t?"extract: nothing to do \u2014 only conversation sources here (extract one explicitly with --source <id>)":"extract: nothing to do \u2014 every ingested source is already extracted"),0}let Y=new Map;if(n&&n.questions.length>0&&!s.message){e.out(`re-presenting ${n.questions.length} unanswered question(s) from the paused session`);let t=await e.ask(n.questions.map(Ue));for(let a of t)Y.set(a.id,a)}let G=e.by??{kind:"human",id:"owner"},A=c==="interactive"&&!s.plan&&!!e.chat,oe=0,ye=0;try{for(let t of y){let a=R(e.contextDir),m={current:a};e.chat?.attachOnCommitted?.(r=>{m.current=r});let I=a.getNode(t.cid),K=String(I?.content.blob??""),ie=se(e.contextDir,a,t.cid);if(!ie)return e.out(`error: ${t.source_id}: blob ${K} missing from .context/blobs`),e.emit?.({type:"error",source_id:t.source_id,message:`error: ${t.source_id}: blob ${K} missing from .context/blobs`,code:"BLOB_MISSING"}),1;let T=a.mediaOf(t.cid),ne=T.media_type.startsWith("image/");if(!ne){let r=it(ie);if(r){e.out(`skipping ${t.source_id}: binary ${r} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`),e.emit?.({type:"source_skipped",source_id:t.source_id,reason:"binary_pre_media"});continue}}let q=ne?`0001| (image source ${t.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:Ee(ie),ve=Je(e.now?.()??new Date),N=`${ve}-${t.source_id}`,$e=!!(n&&t.source_id in n.handle.state.read_basis)?s.resume:`ext-${ve}-${nt(t.source_id)}`,F="";if(A){let r=Oe({contextDir:e.contextDir,graph:R(e.contextDir),sessionStamp:$e,by:G});r.errors===null||r.errors[0]?.code==="CONV_SOURCE_EXISTS"?(F=r.sourceId,e.chat.attachConversationSource?.(F),m.current=R(e.contextDir)):e.out(`warning: conversation source unavailable (${r.errors[0]?.detail}) \u2014 chat adds will not land this session`)}let b={type:"run_config",version:1,session_id:$e,mode:c,source:{source_id:t.source_id,source_cid:t.cid,kind:T.format==="pdf"?"pdf":ot(t.source_id)||"md",numbered_text:q,...T.format==="pdf"&&(T.images??[]).some(r=>r.delivery==="selected")?{images:(T.images??[]).filter(r=>r.delivery==="selected").map(r=>({ref:r.ref,page:r.page,media_type:r.media_type,blob_ref:{path:V(e.contextDir,r.blob),cid:r.blob}}))}:{}},existing_use_cases:a.byLabel(H.USECASE).filter(({cid:r})=>a.trust.get(r)!=="archived"&&!a.superseded.has(r)).map(({cid:r,content:i})=>({id:r,title:String(i.title??""),summary:String(i.summary??"")})),read_basis:m.current.latestHash,max_free_text_rounds:Te,graph_reads:!0,verb:"extract",...k!==void 0?{style_note_digest:k}:{},...s.changeContext&&s.changeContext.source_id===t.source_id?{change_context:s.changeContext}:{},topology:Be(),...A?{chat:!0}:{},...ne?{image_sources:[{source_id:t.source_id,source_cid:t.cid,media_type:T.media_type,blob_ref:{path:V(e.contextDir,K),cid:K}}]}:{},...n&&t.source_id in n.handle.state.read_basis?{resume:{agent_state:n.handle.state.agent_state}}:{}};A||e.out(n&&t.source_id in n.handle.state.read_basis?`resuming: ${t.source_id} (session ${s.resume})`:`extracting: ${t.source_id} @ ${t.cid.slice(0,19)}`),e.emit?.({type:"source_start",source_id:t.source_id,cid:t.cid,index:y.indexOf(t)+1,total:y.length,resumed:!!(n&&t.source_id in n.handle.state.read_basis)}),e.chat?.ledger?.({kind:"banner",text:at(t,y.indexOf(t)+1,y.length)}),e.chat?.setWorking?.(`Reading ${Qe(t)}\u2026`);let be=new Map;u("spawn",{source_id:t.source_id,source_cid:t.cid,resume:!!n,chat:A},b.session_id);let we=!1,et=async r=>{let i=z(r,q,R(e.contextDir));if(u("kane_validate",{errors:i.map(p=>p.code)},b.session_id),i.length>0){e.chat.submit("[auto-repair] the proposal failed validation: "+i.map(p=>`${p.code}: ${p.detail}`).join("; ")+" \u2014 please re-finalize with these fixed.");return}let v=R(e.contextDir),C=Xe(r,v),ee=M(e.contextDir,"proposals",N);he(ee,{recursive:!0}),_e(M(ee,"proposal.json"),JSON.stringify(r,null,2)+`
10
+ `);let rt=new Map(r.use_cases.map(p=>[p.temp_ref,{resolution:"skipped"}])),te=re({contextDir:e.contextDir,graph:v,proposal:r,proposalId:N,verdicts:rt,by:{kind:"ai",id:"extract-agent"},autoName:!0});if(te.errors){e.chat.ledger?.({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:te.errors.map(p=>`${p.code}: ${p.detail}`)});return}we=!0;let j=te.record.nodes.length;oe+=j;let U=r.use_cases.length-j;{let p=R(e.contextDir),De=new Map;for(let{cid:$,content:D}of p.byLabel(H.USECASE))p.superseded.has($)||De.set(J(String(D.title??"")),$);let fe=[];for(let $ of r.use_cases){let D=null;if($.matches_existing?.cid&&p.hasNode($.matches_existing.cid)){let W=p.tipOf($.matches_existing.cid);D=p.superseded.has(W)?null:W}D=D??De.get(J($.title))??null,D&&fe.push({ref:$.temp_ref,cid:D,...p.displayNameOf(D)?{id:p.displayNameOf(D)}:{}})}fe.length>0&&e.chat.registerAliases?.(fe),m.current=p;let ke=$=>{for(let[D,W]of p.names)if(W===$&&!p.superseded.has(W))return D},Ce=Pe({verb:"extract",commitN:1,phase:"proposal",committed:te.record.nodes.map($=>({cid:$.cid,...ke($.cid)?{logical_id:ke($.cid)}:{}})),reused:U},p);e.emit?.(Ce.event),e.chat.holdReceipt?.(Ce.text)}u("commit",{derived:j,evidence_matched:U,chat:!0},b.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:j===0&&U>0?`all ${U} matched existing \u2014 nothing new to save`:`saved ${j} use-case${j===1?"":"s"} as drafts`+(U>0?` \xB7 ${U} matched existing`:"")})},Se=!!(n&&t.source_id in n.handle.state.read_basis),Q=Se&&Y.size>0?{...e,ask:async r=>r.every(i=>Y.has(i.id))?(n.handle.markApplied(r.map(i=>`resolveq:${s.resume}:${i.id}`)),e.out(`answered ${r.length} re-asked question(s) from the held resume answers`),r.map(i=>Y.get(i.id))):e.ask(r)}:e;Se&&s.message&&(Q={...Q,initialMessage:s.message});let f=await Ke(b,{...Q,graphSlot:m},be,a,u,A?et:void 0);if(e.chat?.setWorking?.(null),f.error)return e.out(`error: agent failed for ${t.source_id}: ${f.error}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: agent failed for ${t.source_id}: ${f.error}`}),1;if(f.highRisk)return e.out(`error: ${f.highRisk.length} high-risk decision${f.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",source_id:t.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${f.highRisk.map(r=>r.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(f.paused){let r=y.slice(y.indexOf(t)+1).map(ee=>ee.source_id),i=n?.handle??Fe(e.contextDir,{sid:b.session_id,mode:"agent",created_at:(e.now?.()??new Date).toISOString(),expires_at:new Date((e.now?.()??new Date).getTime()+1440*60*1e3).toISOString(),agent_state:f.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[t.source_id]:t.cid},corpus_cursor:{remaining:r},conv_source:F,verb:"extract",...X?{force:!0}:{},...s.changeContext?{change_basis:{source_id:s.changeContext.source_id,new_head:s.changeContext.new_head}}:{}});F&&i.state.conv_source!==F&&i.save({conv_source:F});let v=e.chat?.drainHeldReceipts?.()??[];(v.length>0||(i.state.held_receipts?.length??0)>0)&&i.save({held_receipts:v}),n?.handle&&i.save({read_basis:{[t.source_id]:t.cid},corpus_cursor:{remaining:r},...X&&!i.state.force?{force:!0}:{}}),He(i,f.paused),u("session_paused",{sid:i.state.sid},b.session_id);let C=`kane-cli context extract --resume ${i.state.sid} --mode ${c}`;return e.out(`paused: session ${i.state.sid} saved \u2014 resume with: ${C}`),e.emit?.({type:"session_paused",sid:i.state.sid,source_id:t.source_id,mode:c,resume:C,expires_at:i.state.expires_at,pending_questions:f.paused.pending.questions}),e.chat?.ledger?.({kind:"pause",sid:i.state.sid,expires_at:i.state.expires_at,resume:C,messageForm:`${C} --message "<your words>"`}),3}if(A){if(ye+=f.assumedDefaults??0,f.error)return 1;if(!we){let r=y.length-y.indexOf(t)-1;return e.out(`done \u2014 nothing committed for ${t.source_id} (no finalize before the session ended)`+(r>0?`; stopping here \u2014 ${r} remaining source(s) not extracted (re-run kane-cli context extract to continue)`:"")),n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null),0}n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null);continue}if(!f.proposal)return e.out(`error: agent ended without a proposal for ${t.source_id}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: agent ended without a proposal for ${t.source_id}`}),1;let S=z(f.proposal,q,a);if(u("kane_validate",{errors:S.map(r=>r.code)},b.session_id),S.length>0&&ct(f.proposal,S,r=>e.out(r))&&(u("criteria_dropped",{source_id:t.source_id},b.session_id),S=z(f.proposal,q,a)),S.length>0){if(e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:t.source_id,codes:S.map(r=>r.code),repairing:!0}),u("repair_respawn",{source_id:t.source_id},b.session_id),f=await Ke(b,{...Q,graphSlot:m},be,a,u),f.error||!f.proposal)return e.out(`error: repair run failed for ${t.source_id}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: repair run failed for ${t.source_id}`}),1;if(S=z(f.proposal,q,a),S.length>0){for(let r of S)e.out(` ${r.detail}`);return e.emit?.({type:"validate_failed",source_id:t.source_id,codes:S.map(r=>r.code),repairing:!1}),e.emit?.({type:"error",source_id:t.source_id,message:`error: proposal failed validation after repair (${S.map(r=>r.code).join(", ")})`}),1}}let w=f.proposal,Z=Xe(w,a),ae=M(e.contextDir,"proposals",N);if(he(ae,{recursive:!0}),_e(M(ae,"proposal.json"),JSON.stringify(w,null,2)+`
11
+ `),s.plan){e.out(`plan: ${w.use_cases.length} use-case(s) proposed from ${t.source_id} (nothing committed)`);for(let r of w.use_cases){let i=Z.get(r.temp_ref),v=i?i.archived?` \u2248 matches ARCHIVED ${i.cid.slice(0,19)}${i.reason?` \u2014 previously rejected: "${i.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${i.cid.slice(0,19)}`:"";e.out(` [${r.risk}] ${r.title} \u2014 cite ${r.cite.anchor}${v}`)}e.emit?.({type:"plan",source_id:t.source_id,use_cases:w.use_cases.map(r=>{let i=Z.get(r.temp_ref);return{risk:r.risk,title:r.title,anchor:r.cite.anchor,...i?{match:i.cid,match_archived:!!i.archived}:{}}})}),f.assumedDefaults&&e.out(`assumed: ${f.assumedDefaults} default(s) auto-taken (flagged)`);continue}for(let r of w.use_cases){if(!r.conflicts_with?.length)continue;let i=r.conflicts_with.filter(C=>a.resolve(C)!==null),v=r.conflicts_with.filter(C=>a.resolve(C)===null);v.length>0&&(e.out(`note: ${r.temp_ref}: dropped unresolvable conflict hint(s): ${v.join(", ")}`),r.conflicts_with=i.length>0?i:void 0)}u("review_start",{use_cases:w.use_cases.length,flags:Z.size},b.session_id);let L=await e.review(w.use_cases,Z);u("review_verdicts",[...L.entries()].map(([r,i])=>({ref:r,resolution:i.resolution})),b.session_id),_e(M(ae,"review.json"),JSON.stringify(w.use_cases.map(r=>{let i=L.get(r.temp_ref)??{resolution:"skipped"};return{id:r.temp_ref,kind:"review-item",resolution:i.resolution,edit:i.edit??null,reason:i.reason??null,...i.supersedeTarget?{supersede_target:i.supersedeTarget}:{},by:G}}),null,2)+`
12
+ `);let ce=a,O=re({contextDir:e.contextDir,graph:ce,proposal:w,proposalId:N,verdicts:L,by:G,autoName:!0});if(O.errors&&O.errors[0]?.code==="STALE_BASIS"){if(!await e.confirmStale(`the context changed while you reviewed (${O.errors[0].detail}) \u2014 commit against the new head anyway?`))return e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:t.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),e.emit?.({type:"done",status:"aborted",exit_code:1}),1;ce=R(e.contextDir),O=re({contextDir:e.contextDir,graph:ce,proposal:w,proposalId:N,verdicts:L,by:G,allowStaleBasis:!0,autoName:!0})}if(O.errors){for(let r of O.errors)e.out(` ${r.detail}`);return e.emit?.({type:"error",source_id:t.source_id,message:`error: commit failed: ${O.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}`}),1}let tt=new Date().toISOString();for(let r of w.use_cases){let i=L.get(r.temp_ref)??{resolution:"skipped"};for(let v of Ie({ts:tt,command:"context extract",id:r.temp_ref,by:G},i.resolution))Ae(e.contextDir,v)}let B=O.record,de=new Map(B.review.map(r=>[r.id,r.resolution])),ue=[...de.values()].filter(r=>r==="approved"||r==="edited").length,le=[...de.values()].filter(r=>r==="rejected").length,me=B.nodes.filter(r=>!de.has(r.cid)).length,ge=B.supersessions.filter(r=>r.kind==="node"&&r.new!==r.old).length;u("commit",{trusted:ue,derived:me,archived:le},b.session_id),e.out(`committed: ${ue} trusted, ${me} derived (queued), ${le} archived`+(ge>0?`, ${ge} superseded`:"")),f.assumedDefaults&&e.out(`assumed: ${f.assumedDefaults} default(s) auto-taken (flagged)`),e.emit?.({type:"commit",source_id:t.source_id,proposal_id:N,trusted:ue,derived:me,archived:le,superseded:ge,assumed:f.assumedDefaults??0,evidence_matched:Math.max(0,w.use_cases.length-B.nodes.length),minted:B.nodes.map(r=>{let i=B.names?.find(v=>v.cid===r.cid)?.slug;return{cid:r.cid,...i?{logical_id:i}:{}}})}),n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),e.out(`session ${s.resume} complete`),e.emit?.({type:"session_complete",sid:s.resume,source_id:t.source_id}),n=null)}}finally{n?.handle.release()}if(A){let t=e.chat?.state.ledger.filter(I=>I.kind==="answer"&&I.receipt.form==="assumed").length??0,a=ye+t,m=e.chat?.state.credits?.total;e.chat?.ledger?.({kind:"summary",lines:[`saved ${oe} use-case${oe===1?"":"s"} across ${y.length} source${y.length===1?"":"s"}`,...a>0?[`${a} assumed default(s)`]:[],...m!==void 0?[`credits used: ${m.toFixed(1)}`]:[],`trace: ${pe(g)}`]})}return s.plan||qe(e.contextDir),0}export{nt as a,Qe as b,at as c,Xe as d,Gt as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b}from"./chunk-C42WWO7Y.js";import{c as k}from"./chunk-RFHMDQXZ.js";import{a as C}from"./chunk-P4HW2NTZ.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-6SGPN76K.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
2
+ import{a as b}from"./chunk-NKUA3TSO.js";import{c as k}from"./chunk-RFHMDQXZ.js";import{a as C}from"./chunk-BUVRZXO3.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-PXPXK4Q7.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
3
3
  Please open this URL manually: ${e}
4
4
  `)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
5
5
  <html lang="en">
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as C}from"./chunk-DNNZ353O.js";import{b as h,c as f}from"./chunk-NVGBE2DR.js";import{a as L}from"./chunk-LEA6IHXC.js";import{a as B,c as A}from"./chunk-L4JIMNKW.js";import{e as N}from"./chunk-MBXWXBDM.js";import{a as k,d as O,f as I}from"./chunk-5YPBPZUR.js";import{existsSync as G,mkdirSync as X,readFileSync as H,writeFileSync as V}from"fs";import{basename as Z,extname as T,join as Y}from"path";var $=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function U(e){return typeof e=="string"&&e!=="."&&e!==".."&&$.test(e)}function w(e){if(!U(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String($)} (no path separators)`)}import{extname as J}from"path";var D=[{kind:"text",media_type:"text/plain",extensions:[".txt"],cite:"verbatim",maxBytes:2e6},{kind:"markdown",media_type:"text/markdown",extensions:[".md",".markdown"],cite:"verbatim",maxBytes:2e6},{kind:"image",media_type:"image/png",extensions:[".png"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/jpeg",extensions:[".jpg",".jpeg"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/webp",extensions:[".webp"],cite:"anchor-only",maxBytes:5e6},{kind:"text",media_type:"application/json",extensions:[".json"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/yaml",extensions:[".yaml",".yml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/toml",extensions:[".toml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/xml",extensions:[".xml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"text/plain",extensions:[".log"],cite:"verbatim",maxBytes:2e6},{kind:"pdf",media_type:"application/pdf",extensions:[".pdf"],cite:"verbatim",maxBytes:25e6,sniff:e=>e.subarray(0,5).toString("latin1")==="%PDF-"}];function M(e){let n=J(e).toLowerCase(),t=D.find(s=>s.extensions.includes(n));return t?{ok:!0,media:t}:{ok:!1,code:"UNSUPPORTED_MEDIA",allowlist:D.flatMap(s=>s.extensions)}}function P(e){let n=Object.entries(e).map(([t,s])=>`${JSON.stringify(t)}: ${JSON.stringify(s)}`).join(", ");return Buffer.byteLength(`{${n}}`,"utf8")}var F=2e3;function q(e){let t=Z(e,T(e)).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"");return w(t),t}function fe(e){let n=/^(.*?)[-_.]?v?\d+$/.exec(e);if(!n)return null;let t=(n[1]??"").replace(/[-_.]+$/,"");return t.length>0&&t!==e?t:null}function W(e){let n=Y(e,"meta.json");G(n)||(X(e,{recursive:!0}),V(n,JSON.stringify({schema:k,canonicalizer:"v1"},null,2)+`
3
+ `))}async function ue(e){let{contextDir:n,filePath:t,asId:s,confirmSameSource:v,pdfConverter:E}=e;W(n);let a=H(t),r=M(t);if(!r.ok)throw new Error(`UNSUPPORTED_MEDIA: ${T(t)} \u2014 supported: ${r.allowlist.join(" ")}`);if(a.byteLength>r.media.maxBytes)throw new Error(`FILE_TOO_LARGE: ${a.byteLength} bytes > ${r.media.maxBytes} cap for ${r.media.media_type}`);if(r.media.sniff&&!r.media.sniff(a))throw new Error(`MEDIA_SNIFF_MISMATCH: ${t} does not look like ${r.media.media_type}`);let u=[];if(r.media.cite==="verbatim"&&r.media.kind!=="pdf"){try{new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch{throw new Error(`ENCODING_UNSUPPORTED: ${t} is not valid UTF-8 \u2014 re-save it as UTF-8 and re-ingest`)}a.toString("utf8").split(`
4
+ `).some(i=>i.length>F)&&u.push(`long line detected (> ${F} chars) \u2014 anchors lose granularity; consider pretty-printing before ingest`)}let d=h(a),o;s!==void 0?(w(s),o=s):o=q(t);let p=L(n),m=p.heads.get(o),j=m!=null?p.getNode(m)?.content:void 0;if(m!=null&&j?.blob===d)return{status:"unchanged",source_id:o,cid:m,blob:d};if(m==null){for(let[i,l]of p.heads.entries())if(!(i===o||l==null)&&p.getNode(l)?.content.blob===d){if(v&&await v(i))return{status:"unchanged",source_id:i,cid:l,blob:d};break}}let S={},g,c=null,_=null;if(r.media.kind==="pdf"){if(!E)throw new Error("PDF_CONVERTER_MISSING: pdf ingestion requires the converter \u2014 the command layer wires it");let i=await E(a);c=Buffer.from(i.projection,"utf8");let l=P({source_id:o,source_cid:"sha256:".padEnd(71,"0"),doc_kind:"pdf",numbered_text:C(c)});if(l>4e5)throw new Error(`PROJECTION_TOO_LARGE: serialized source payload ${l} bytes > ${4e5} \u2014 split the document and re-ingest`);S={text_blob:h(c),...i.inventory.length>0?{images:i.inventory}:{},converter:i.converter},_=i.blobs,g={pages:i.pages,delivered:i.delivered.length,omitted:i.inventory.length-i.delivered.length}}if(f(n,a),c!==null&&f(n,c),_!==null)for(let[,i]of _)f(n,i);let y=A(o,d),x=I("source",y);if(x.length>0)throw new Error(`source node fails ${x[0].code}: ${x[0].detail}`);let b=B("source",y);return N(n,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:b,label:O.SOURCE,content:y}],edges:[],review:[],supersessions:[],media:{[o]:{format:r.media.kind,media_type:r.media.media_type,anchors_supported:r.media.kind==="pdf"?["L-L","img#ref"]:r.media.cite==="verbatim"?["L-L"]:[],...S}},source_head_moves:{[o]:b}}),{status:m!=null?"versioned":"created",source_id:o,cid:b,blob:d,...u.length?{warnings:u}:{},...g?{pdf:g}:{}}}export{M as a,q as b,fe as c,ue as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as K,c as V,d as z,e as ee,f as te}from"./chunk-BLHCGRSK.js";import{c as J}from"./chunk-IQFUBT6Z.js";import{a as Q}from"./chunk-NKCXCCPM.js";import{a as Z}from"./chunk-FPFOW6BS.js";import{b as H}from"./chunk-VRVSOGXH.js";import{b as W}from"./chunk-PV4EDQY4.js";import{h as E}from"./chunk-M5JQXOCE.js";import{a as O}from"./chunk-2WVKOZ6W.js";import{a as _}from"./chunk-K4ERF7GT.js";import{a as k,b as A,d as Y}from"./chunk-VE3SUJMA.js";import{a as q}from"./chunk-BUVRZXO3.js";import{a as G}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as I,j as X}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var i=F(ue(),1);var r=F(G(),1);function _e({resultRef:h,mode:d="singleshot",loginCompleteRef:f}){let{exit:m}=X(),C=(0,i.useRef)(new q),S=(0,i.useRef)(new Q),v=(0,i.useRef)(new J),t=C.current,l=S.current,$=v.current,ne=K(),[P,g]=(0,i.useState)(d==="login"?"login":"gate"),[L,re]=(0,i.useState)(null),[de,R]=(0,i.useState)(null),[ge,T]=(0,i.useState)(null),[N,oe]=(0,i.useState)(null),[U,B]=(0,i.useState)([]),x=(0,i.useCallback)((e,n,s,o)=>$.log(e,n,s,o),[$]),pe=(0,i.useCallback)((e,n)=>{e?k(t,l,e,n):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[t,l]),y=(0,i.useCallback)(()=>{d==="login"?(f&&(f.current=!0),m()):g("input")},[d,m,f]),D=(0,i.useCallback)((e,n)=>{let s=k(t,l,e,n);if(d==="login"){g("ensure-project");return}Y(s)?y():s.projectId?g("ensure-folder"):g("ensure-project")},[t,l,y,d]);I((e,n)=>{n.ctrl&&e==="c"&&E(0,"Ctrl+C exit")});let M=(0,i.useRef)(!1);i.default.useEffect(()=>{M.current||(M.current=!0,d!=="login"&&te(t,x).then(e=>{re(e),e.status==="authenticated"?D(e.result.profile,e.result.env):e.status==="needs_pick"?g("pick"):(R(e.profile??null),T(e.env??null),g("login"))}).catch(e=>{oe(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[t,x]);let ie=(0,i.useCallback)(e=>{h.current={objective:e},m()},[h,m]),se=(0,i.useCallback)(async(e,n)=>{t.setActiveProfile(e),t.setDefaultEnv(n),(await ee(t,e,n,x)).status==="authenticated"?D(e,n):(R(e),T(n),g("login"))},[t,x,D]),w=(0,i.useCallback)(()=>{let e=t.getActiveProfile(),n=t.getDefaultEnv();if(!e)return null;let s=_(n),o=t.loadBasicAuth(e,n);return new Z(s.controllerBaseUrl,async()=>t.loadCredentials(e,n)?.access_token??null,o,x)},[t,x]),le=(0,i.useCallback)(async()=>{let e=w();if(!e)return null;let n=e.cached??await e.resolve();if(!n)return null;let s=_(t.getDefaultEnv()),o=new O(s.tmsBaseUrl,n.username,n.access_key);try{let p=(await o.listProjects()).find(b=>b.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let j=await o.createProject("KaneAI Generated");return{id:j.id,name:j.name}}catch{return null}},[w,t]),ae=(0,i.useCallback)(async e=>{let n=w();if(!n)return null;let s=n.cached??await n.resolve();if(!s)return null;let o=_(t.getDefaultEnv()),a=new O(o.tmsBaseUrl,s.username,s.access_key);try{let j=(await a.listFolders(e)).find(ce=>ce.name==="Untitled");if(j)return{id:j.id,name:j.name};let b=await a.createFolder(e,"Untitled");return{id:b.id,name:b.name}}catch{return null}},[w,t]);if(P==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(N)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:N}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(P==="pick"&&L?.status==="needs_pick")return(0,r.jsx)(fe,{profiles:L.profiles,onSelect:se});if(P==="login")return(0,r.jsx)(z,{devMode:process.env.KANE_DEV_MODE==="1",profiles:t.listProfiles(),onBasicLogin:async(e,n,s,o)=>{let{validateBasicAuth:a}=await import("./validate-basic-XEJGB4GN.js");await a(n,s,o),t.saveBasicAuth(e,n,{username:s,access_key:o}),t.setActiveProfile(e),t.setDefaultEnv(n)},onOAuthLogin:async(e,n)=>{let{LoginFlow:s}=await import("./login-flow-OVEZXSMW.js");t.setDefaultEnv(n),t.setActiveProfile(e),await new s(e,n,t).login()},onComplete:(e,n)=>{R(e),T(n),t.setActiveProfile(e),t.setDefaultEnv(n),D(e,n)},onCancel:()=>{E(0,"Login cancelled")}});if(P==="ensure-project"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=()=>{if(d==="login"){g("ensure-folder");return}k(t,l,e,n).folderId?y():g("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(H,{resolver:w(),currentProjectId:l.load().project_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{projectId:o,projectName:a}),B(p=>[...p,`\u2713 Project: ${a} (${o})`]),s()},onCancel:async()=>{let o=await le();o&&(A(t,l,e,n,{projectId:o.id,projectName:o.name}),B(a=>[...a,`\u2713 Default project: ${o.name} (${o.id})`]),s())}})]})}if(P==="ensure-folder"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=t.loadProfileConfig(e,n);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(W,{resolver:w(),projectId:s?.project_id??"",currentFolderId:l.load().folder_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{folderId:o,folderName:a}),B(p=>[...p,`\u2713 Folder: ${a} (${o})`]),y()},onCancel:async()=>{if(!s?.project_id)return;let o=await ae(s.project_id);o&&(A(t,l,e,n,{folderId:o.id,folderName:o.name}),B(a=>[...a,`\u2713 Default folder: ${o.name} (${o.id})`]),y())}})]})}return P==="input"?(0,r.jsxs)(c,{flexDirection:"column",children:[U.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:U.map((e,n)=>(0,r.jsx)(u,{color:"green",children:e},n))}),(0,r.jsx)(V,{onSubmit:ie,onEscape:()=>E(0,"User pressed Escape"),history:ne,placeholder:"Type an objective..."})]}):(0,r.jsx)(r.Fragment,{})}function fe({profiles:h,onSelect:d}){let[f,m]=(0,i.useState)(0),[C,S]=(0,i.useState)(!1);return I((v,t)=>{if(!C){if(t.escape){E(0,"Profile picker cancelled");return}if(t.upArrow&&f>0&&m(l=>l-1),t.downArrow&&f<h.length-1&&m(l=>l+1),t.return){S(!0);let l=h[f];d(l.profile,l.env).catch(()=>S(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:h.map((v,t)=>(0,r.jsxs)(u,{children:[t===f?"\u276F ":" ",(0,r.jsx)(u,{color:t===f?"#ff9500":"white",bold:t===f,children:v.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),C&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{_e as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-4SXD6XWV.js";import{y as r}from"./chunk-6SGPN76K.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
2
+ import{a as R}from"./chunk-MEHEGW3V.js";import{y as r}from"./chunk-PXPXK4Q7.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as c,c as p}from"./chunk-YKZIACYJ.js";import{spawn as y}from"child_process";var h=new Set(["progress","ask_user","graph_query","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete"]);function w(l,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:c();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=l.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=y(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(l.session_id,n.auth)});if(t.stdin.write(JSON.stringify(l)+`
3
+ `),n.onStderr){let e="";t.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
4
+ `))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&n.onStderr(o)}})}let d=new Promise(e=>{t.on("exit",(r,i)=>e({code:r,signal:i}))});async function*m(){let e="",r=!1;for await(let i of t.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
5
+ `))>=0;){let g=e.slice(0,o).trim();if(e=e.slice(o+1),!g)continue;let u;try{u=JSON.parse(g)}catch{n.onWarn?.(`agent: skipping malformed line: ${g.slice(0,120)}`);continue}let s=u;if(!s||typeof s!="object"||!h.has(s.type)){n.onWarn?.(`agent: skipping unknown event type "${s&&typeof s=="object"?String(s.type??"?"):"?"}"`);continue}if(yield s,s.type==="done"){r=!0;break}}if(r)break}await d.catch(()=>{})}return{events:m(),send:e=>{t.stdin&&!t.stdin.destroyed&&t.stdin.write(JSON.stringify(e)+`
6
+ `)},kill:()=>{t.kill("SIGTERM")},exited:d}}export{w as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as c}from"./chunk-ZG2V2ODK.js";import{d as l}from"./chunk-5YPBPZUR.js";function h(f,o,u){let n=o.resolve(u);if(!n)return{target:null,entries:[]};let t=new Set([n.cid]),r=n.cid;for(;o.superseded.has(r);){let s=o.superseded.get(r);if(typeof s!="string"||t.has(s))break;t.add(s),r=s}let d=o.nodeLabel.get(n.cid)??"(unknown)",{records:p}=c(f),i=[];for(let s of p){for(let e of s.nodes)t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"minted",detail:`minted ${e.label} ${e.cid}`});for(let e of s.judgements??[])t.has(e.about)&&i.push({seq:s.seq,ts:s.ts,kind:"judgement",rationale:e.rationale,detail:`judgement on ${e.about}`,by:e.by});for(let e of s.review)t.has(e.id)&&i.push({seq:s.seq,ts:s.ts,kind:"review",detail:`${e.resolution}${e.reason?` \u2014 ${e.reason}`:""}`,by:e.by});for(let e of s.supersessions)e.kind==="node"&&(t.has(e.old)||e.new!==null&&t.has(e.new))&&i.push({seq:s.seq,ts:s.ts,kind:"supersession",detail:`${e.old} \u2192 ${String(e.new)} \u2014 ${e.reason}`,by:e.by});for(let e of s.names??[])t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"name",detail:`named ${e.slug}`,by:e.by});if(d===l.SOURCE)for(let[e,a]of Object.entries(s.source_head_moves))(t.has(a??"")||o.heads.get(e)!==void 0&&t.has(n.cid)&&e===o.getNode(n.cid)?.content?.source_id)&&i.push({seq:s.seq,ts:s.ts,kind:"head_move",detail:`${e} head \u2192 ${String(a)}`})}return i.sort((s,e)=>e.seq-s.seq),{target:{cid:n.cid,tip:n.tip,label:d,slug:o.nameOf.get(n.cid)},entries:i}}export{h as a};
2
+ import{b as c}from"./chunk-MBXWXBDM.js";import{d as l}from"./chunk-5YPBPZUR.js";function h(f,o,u){let n=o.resolve(u);if(!n)return{target:null,entries:[]};let t=new Set([n.cid]),r=n.cid;for(;o.superseded.has(r);){let s=o.superseded.get(r);if(typeof s!="string"||t.has(s))break;t.add(s),r=s}let d=o.nodeLabel.get(n.cid)??"(unknown)",{records:p}=c(f),i=[];for(let s of p){for(let e of s.nodes)t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"minted",detail:`minted ${e.label} ${e.cid}`});for(let e of s.judgements??[])t.has(e.about)&&i.push({seq:s.seq,ts:s.ts,kind:"judgement",rationale:e.rationale,detail:`judgement on ${e.about}`,by:e.by});for(let e of s.review)t.has(e.id)&&i.push({seq:s.seq,ts:s.ts,kind:"review",detail:`${e.resolution}${e.reason?` \u2014 ${e.reason}`:""}`,by:e.by});for(let e of s.supersessions)e.kind==="node"&&(t.has(e.old)||e.new!==null&&t.has(e.new))&&i.push({seq:s.seq,ts:s.ts,kind:"supersession",detail:`${e.old} \u2192 ${String(e.new)} \u2014 ${e.reason}`,by:e.by});for(let e of s.names??[])t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"name",detail:`named ${e.slug}`,by:e.by});if(d===l.SOURCE)for(let[e,a]of Object.entries(s.source_head_moves))(t.has(a??"")||o.heads.get(e)!==void 0&&t.has(n.cid)&&e===o.getNode(n.cid)?.content?.source_id)&&i.push({seq:s.seq,ts:s.ts,kind:"head_move",detail:`${e} head \u2192 ${String(a)}`})}return i.sort((s,e)=>e.seq-s.seq),{target:{cid:n.cid,tip:n.tip,label:d,slug:o.nameOf.get(n.cid)},entries:i}}export{h as a};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  function l(r){let{isAgent:c,log:m}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{c&&process.stdout.write(JSON.stringify(t)+`
3
- `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-JXRXMACE.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-ULRSPKY3.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-4T545XRB.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-ZS25VTBY.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
3
+ `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-GQP2QGFU.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-VIEZQNZ5.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-HCDIWKPS.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-3B2KO5S4.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-6XHAXAL2.js";import{b as D}from"./chunk-D7L6UW5Z.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
2
+ import{a as $}from"./chunk-IQFUBT6Z.js";import{b as D}from"./chunk-K7P6VNLI.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
3
3
 
4
4
  `))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
5
5
  `))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-4SXD6XWV.js";import{y as t}from"./chunk-6SGPN76K.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
2
+ import{a as m}from"./chunk-MEHEGW3V.js";import{y as t}from"./chunk-PXPXK4Q7.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-AKHUNBQS.js";import{a as h}from"./chunk-P4HW2NTZ.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-K4ERF7GT.js";import{a as h}from"./chunk-BUVRZXO3.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-CFVOA62N.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-NQZJEUQE.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
@@ -0,0 +1,11 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Ke}from"./chunk-NKCXCCPM.js";import{a as Fe}from"./chunk-NKUA3TSO.js";import{a as Ne}from"./chunk-FPFOW6BS.js";import{a as Oe}from"./chunk-YCCUBQY4.js";import{a as $e}from"./chunk-K4ERF7GT.js";import{a as Ue}from"./chunk-VE3SUJMA.js";import{a as me}from"./chunk-MEHEGW3V.js";import{c as _e,y as u}from"./chunk-PXPXK4Q7.js";import{a as te}from"./chunk-HCBYKLMW.js";import{a as p,b as f,h as De,i as be,k as ke}from"./chunk-C44QQJR4.js";import{a as xe}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var We=$(xe(),1);import{readFileSync as tt,writeFileSync as nt,mkdirSync as rt}from"fs";import{dirname as ot,join as He}from"path";var it=He(_e,"command-history.json"),At=He(_e,"generate-history.json"),st=200,Ie=class{entries;filePath;max;constructor(t=it,e=st){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),i=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&i.push(this.entries[s]);return i}_load(){if(this.filePath===null)return[];try{let t=tt(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{rt(ot(this.filePath),{recursive:!0}),nt(this.filePath,JSON.stringify(this.entries)+`
3
+ `)}catch{}}};function Ct(r){let t=(0,We.useRef)(null);return t.current||(t.current=new Ie(r)),t.current}var D=$(xe(),1);var Pe=$(xe(),1);var Q=$(te(),1);function Ge({history:r,onSelect:t,onClose:e}){let[i,s]=(0,Pe.useState)(""),[l,h]=(0,Pe.useState)(0),w=i?r.search(i).slice(0,8):[];return be((T,m)=>{if(m.escape){e();return}if(m.return){w.length>0&&w[l]?t(w[l]):e();return}if(m.upArrow){h(S=>Math.max(0,S-1));return}if(m.downArrow){h(S=>Math.min(w.length-1,S+1));return}if(m.backspace||m.delete){s(S=>S.slice(0,-1)),h(0);return}T&&!m.ctrl&&!m.meta&&(s(S=>S+T),h(0))}),(0,Q.jsxs)(p,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,Q.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,Q.jsxs)(p,{gap:1,children:[(0,Q.jsx)(f,{color:u.dim,children:"search:"}),(0,Q.jsx)(f,{children:i}),(0,Q.jsx)(f,{color:u.orange,children:"\u2588"})]}),w.length>0&&(0,Q.jsx)(f,{children:" "}),w.map((T,m)=>(0,Q.jsx)(p,{marginLeft:2,children:(0,Q.jsxs)(f,{color:m===l?u.orange:u.dim,bold:m===l,children:[m===l?"\u25B8 ":" ",T]})},`${m}-${T}`))]})}var ue=$(te(),1);function Ve({commands:r,selectedIndex:t}){return r.length===0?null:(0,ue.jsx)(p,{flexDirection:"column",marginBottom:0,children:r.map((e,i)=>{let s=i===t;return(0,ue.jsxs)(p,{children:[(0,ue.jsx)(f,{color:s?u.orange:u.dim,children:s?"\u276F ":" "}),(0,ue.jsxs)(f,{color:s?u.orange:void 0,bold:s,children:["/",e.name]}),e.args&&(0,ue.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,ue.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var qe=$(xe(),1);var G=$(te(),1),je={scenario:"Scenarios",case:"Test Cases",file:"Files"};function Ye(r){let t={scenario:0,case:0,file:0};for(let e of r)t[e.kind]++;return["scenario","case","file"].filter(e=>t[e]>0).map(e=>`${t[e]} ${je[e]}`).join(" \xB7 ")}var Ee=7;function ze({items:r,selectedIndex:t,accent:e=u.orange}){let i=r.length;if(i===0)return null;let s=Math.floor(Ee/2),l=i<=Ee?0:Math.max(0,Math.min(t-s,i-Ee)),h=Math.min(i,l+Ee),w=l,T=i-h;return(0,G.jsxs)(p,{flexDirection:"column",marginBottom:0,children:[w>0&&(0,G.jsx)(p,{children:(0,G.jsx)(f,{color:u.dim,children:` \u22EF ${w} above \u2014 ${Ye(r.slice(0,l))}`})}),r.slice(l,h).map((m,S)=>{let U=l+S,k=U===t,C=S===0||r[U-1].kind!==m.kind;return(0,G.jsxs)(qe.default.Fragment,{children:[C&&(0,G.jsx)(p,{children:(0,G.jsx)(f,{color:u.dim,children:je[m.kind]})}),(0,G.jsxs)(p,{children:[(0,G.jsx)(f,{color:k?e:u.dim,children:k?"\u276F ":" "}),(0,G.jsx)(f,{color:k?e:void 0,bold:k,children:m.label})]})]},`${m.kind}:${m.value}:${U}`)}),T>0&&(0,G.jsx)(p,{children:(0,G.jsx)(f,{color:u.dim,children:` \u22EF ${T} more \u2014 ${Ye(r.slice(h))}`})})]})}var ye=$(xe(),1);var lt=27,at=127,ct=11;function ut(r){return r>=64&&r<=126}function ft(r,t){r===ct&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(r)})}function dt(r,t){r===at&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function mt(r,t){let e=r.map(s=>String.fromCharCode(s)).join(""),i=/^\[1;([0-9]+)([A-D])$/.exec(e);if(i){let s=parseInt(i[1],10),l=i[2],h={raw:"\x1B"+e};if(s===2)h.shift=!0;else if(s===3)h.meta=!0;else if(s===5)h.ctrl=!0;else return;l==="A"?h.arrowUp=!0:l==="B"?h.arrowDown=!0:l==="C"?h.arrowRight=!0:l==="D"&&(h.arrowLeft=!0),t(h);return}if(e==="[H"||e==="[1~"||e==="[7~"){t({home:!0,raw:"\x1B"+e});return}if(e==="[F"||e==="[4~"||e==="[8~"){t({end:!0,raw:"\x1B"+e});return}if(e==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+e});return}if(e==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+e});return}}function ht(r,t){r===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(r)}):r===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(r)})}function gt(){let r="IDLE",t=[];function e(){r="IDLE",t=[]}return{feed(i,s){for(let l of i)r==="IDLE"?l===lt?(r="ESC",t=[]):ft(l,s):r==="ESC"?l===91?(r="CSI",t=[]):l===79?(r="SS3",t=[]):(dt(l,s),e()):r==="CSI"?(t.push(l),ut(l)&&(mt([91,...t],s),e())):r==="SS3"&&(ht(l,s),e())},flushIdle(i){r==="ESC"&&t.length===0&&i({raw:"\x1B"}),e()}}}function Xe(r,t={}){let e=(0,ye.useRef)(r);e.current=r;let{stdin:i}=De();(0,ye.useEffect)(()=>{if(t.isActive===!1||!i)return;let s=gt(),l=null,h=w=>{l&&(clearTimeout(l),l=null);let T=Buffer.isBuffer(w)?w:Buffer.from(w,"binary");s.feed(T,m=>e.current(m)),l=setTimeout(()=>{s.flushIdle(m=>e.current(m)),l=null},50)};return i.on("data",h),()=>{i.removeListener("data",h),l&&clearTimeout(l)}},[t.isActive,i])}var y=$(te(),1);function pt(r,t){let e=t-1;for(;e>=0&&r[e]!=="@"&&r[e]!==" "&&r[e]!==`
4
+ `;)e--;return e<0||r[e]!=="@"||e>0&&r[e-1]!==" "&&r[e-1]!==`
5
+ `?null:{at:e,query:r.slice(e+1,t).join("")}}var Me=10;function xt(r){return r.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
6
+ `).replace(/\r/g,`
7
+ `).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function bt(r,t){let e=[],i=0;for(;i<=r.length;){let s=i;for(;s<r.length&&r[s]!==`
8
+ `;)s++;if(i===s)e.push({start:i,end:i});else{let l=i;for(;l<s;){let h=Math.min(l+t,s);e.push({start:l,end:h}),l=h}}if(s>=r.length)break;i=s+1}return e}function Tt(r,t,e){if(r.length===0)return 0;if(t>=e.length)return r.length-1;if(e[t]===`
9
+ `){for(let i=r.length-1;i>=0;i--)if(r[i].end===t)return i;return r.length-1}for(let i=0;i<r.length;i++){let s=r[i];if(s.start<=t&&t<s.end)return i}return r.length-1}function Je(r,t,e,i){let s=bt(r,e);if(s.length===0)return null;let l=Tt(s,t,r),h=l+i;if(h<0||h>=s.length)return null;let w=t-s[l].start,T=s[h],m=T.end-T.start;return T.start+Math.min(w,m)}function jt({onSubmit:r,onEscape:t,history:e,placeholder:i="Type an objective or /command...",commands:s,clearSeq:l,submitVerb:h,footerBindings:w,inert:T=!1,clearOnSubmit:m=!0,noHistory:S=!1,accent:U=u.orange,scenarios:k,mentionFiles:C,submitEmpty:M=!1}){let[c,v]=(0,D.useState)([]),[d,b]=(0,D.useState)(0),[V,q]=(0,D.useState)("none"),[Y,O]=(0,D.useState)(-1),oe=(0,D.useRef)(""),[Te,H]=(0,D.useState)(!0),{stdout:ve}=ke(),F=ve?.columns??80,[ie,j]=(0,D.useState)(0),[Z,se]=(0,D.useState)(0),[Ae,le]=(0,D.useState)([]),[Ce,_]=(0,D.useState)(null),R=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(l!==void 0){if(!R.current){R.current=!0;return}v([]),b(0),O(-1),oe.current="",H(!0),q("none"),j(0)}},[l]);let g=c.join(""),P=(()=>{if(V!=="none"||c.length===0)return"";if(g.startsWith("/")&&s&&g.length>=2){let n=g.slice(1).toLowerCase(),o=s.find(E=>E.name.startsWith(n)&&E.name!==n);return o?`/${o.name}`.slice(g.length):""}if(g.startsWith("/")||S)return"";let a=e.getAll();for(let n=a.length-1;n>=0;n--)if(a[n].startsWith(g)&&a[n]!==g)return a[n].slice(g.length);return""})(),B=(()=>{if(!s||!g.startsWith("/"))return[];let a=g.length>=2?g.slice(1).toLowerCase():"";return a&&s.some(n=>n.name===a)?[]:s.filter(n=>!a||n.name.startsWith(a))})(),he=B.length>0&&g.startsWith("/"),z=!!C||!!(k&&k.length)?pt(c,d):null,Re=z?z.query:null,ne=(()=>{if(!z)return[];let a=z.query.toLowerCase(),n=[];(k??[]).forEach((o,E)=>{let A=`s${E+1}`;(!a||A.includes(a)||(o.title??"").toLowerCase().includes(a))&&n.push({kind:"scenario",value:A,label:`@${A} ${o.title??o.sid??""}`.trim()})}),(k??[]).forEach((o,E)=>{let I=E+1;(o.test_cases??[]).forEach((A,N)=>{let X=`s${I}.c${N+1}`;(!a||X.includes(a)||(A.title??"").toLowerCase().includes(a))&&n.push({kind:"case",value:X,label:`@${X} ${A.title??""}`.trim()})})});for(let o of Ae)n.push({kind:"file",value:o,label:o});return n})(),ge=z!==null&&z.at!==Ce&&!he&&V==="none"&&ne.length>0;(0,D.useEffect)(()=>{if(!C||Re===null){le([]);return}let a=!1;return C(Re).then(n=>{a||le(n)}).catch(()=>{a||le([])}),()=>{a=!0}},[Re,C]),(0,D.useEffect)(()=>{Z>=ne.length&&se(0)},[ne.length]);let Be=a=>{if(!z)return;let n=a.kind==="file"&&/\s/.test(a.value)?`@"${a.value}"`:`@${a.value}`,o=[...c.slice(0,z.at),...n,...c.slice(d)];v(o),b(z.at+n.length),se(0),_(z.at),H(!1)};if(be((a,n)=>{if(Te&&a&&H(!1),n.return){if(ge&&ne[Z]){Be(ne[Z]);return}if(he&&B[ie]){let o=`/${B[ie].name}`;S||e.push(o),r(o),v([]),b(0),q("none"),O(-1),oe.current="",H(!0),j(0);return}g.trim()?(S||e.push(g.trim()),r(g.trim()),m&&(v([]),b(0),q("none"),O(-1),oe.current="",H(!0),j(0))):M&&r("");return}if(n.escape){if(ge){_(z.at);return}V!=="none"?q("none"):c.length>0?(v([]),b(0),O(-1),oe.current=""):t?.();return}if(n.tab&&!n.shift){if(ge&&ne[Z]){Be(ne[Z]);return}if(he&&B[ie]){let o=`/${B[ie].name}`;v([...o]),b(o.length),j(0);return}if(P){let o=g+P;v([...o]),b(o.length);return}return}if(n.ctrl&&a==="r"){if(S)return;q("search");return}if(n.ctrl&&a==="a"){b(0);return}if(n.ctrl&&a==="e"){b(c.length);return}if(n.ctrl&&a==="w"){if(d===0)return;let o=d-1;for(;o>0&&c[o]===" ";)o--;for(;o>0&&c[o-1]!==" ";)o--;let E=[...c.slice(0,o),...c.slice(d)];v(E),b(o);return}if(n.ctrl&&a==="u"){v([]),b(0),O(-1),q("none");return}if(n.meta&&a==="b"){let o=d-1;for(;o>0&&c[o]===" ";)o--;for(;o>0&&c[o-1]!==" ";)o--;b(Math.max(0,o));return}if(n.meta&&a==="f"){let o=d;for(;o<c.length&&c[o]!==" ";)o++;for(;o<c.length&&c[o]===" ";)o++;b(o);return}if(n.leftArrow){if(n.ctrl||n.shift)return;b(o=>Math.max(0,o-1));return}if(n.rightArrow){if(n.ctrl||n.shift)return;if(d>=c.length&&P){let o=g+P;v([...o]),b(o.length)}else b(o=>Math.min(c.length,o+1));return}if(n.upArrow){if(n.shift)return;if(ge){se(o=>Math.max(0,o-1));return}if(he){j(o=>Math.max(0,o-1));return}if(V==="none"){let o=Math.max(1,F-2),E=Je(c,d,o,-1);if(E!==null){b(E);return}if(S)return;let I=e.getAll();if(I.length===0)return;if(Y===-1){oe.current=g,O(I.length-1);let A=I[I.length-1];v([...A]),b(A.length)}else if(Y>0){let A=Y-1;O(A);let N=I[A];v([...N]),b(N.length)}}return}if(n.downArrow){if(n.shift)return;if(ge){se(o=>Math.min(ne.length-1,o+1));return}if(he){j(o=>Math.min(B.length-1,o+1));return}if(V==="none"){let o=Math.max(1,F-2),E=Je(c,d,o,1);if(E!==null){b(E);return}if(S)return;let I=e.getAll();if(Y===-1)return;if(Y<I.length-1){let A=Y+1;O(A);let N=I[A];v([...N]),b(N.length)}else{O(-1);let A=oe.current;v([...A]),b(A.length)}}return}if(n.backspace||n.delete){if(n.meta||n.ctrl)return;if(d>0){let o=[...c.slice(0,d-1),...c.slice(d)];v(o),b(d-1),O(-1),j(0),_(null),se(0)}return}if(a&&!n.ctrl&&!n.meta){let o=xt(a);if(!o)return;let E=[...c.slice(0,d),...o,...c.slice(d)];v(E),b(d+o.length),O(-1),j(0),_(null),se(0)}},{isActive:!T&&V!=="search"}),Xe(a=>{if(a.home){b(0);return}if(a.end){b(c.length);return}if(a.killToEnd){v(c.slice(0,d));return}if(a.arrowLeft&&(a.ctrl||a.meta)){let n=d-1;for(;n>0&&c[n]===" ";)n--;for(;n>0&&c[n-1]!==" ";)n--;b(Math.max(0,n));return}if(a.arrowRight&&(a.ctrl||a.meta)){let n=d;for(;n<c.length&&c[n]!==" ";)n++;for(;n<c.length&&c[n]===" ";)n++;b(n);return}if(a.backspace&&a.meta){if(d===0)return;let n=d-1;for(;n>0&&c[n]===" ";)n--;for(;n>0&&c[n-1]!==" ";)n--;let o=[...c.slice(0,n),...c.slice(d)];v(o),b(n);return}if(a.delete&&(a.ctrl||a.meta)){let n=d;for(;n<c.length&&c[n]===" ";)n++;for(;n<c.length&&c[n]!==" ";)n++;v([...c.slice(0,d),...c.slice(n)]);return}},{isActive:!T&&V!=="search"}),T)return(0,y.jsxs)(p,{flexDirection:"column",children:[(0,y.jsx)(f,{color:u.muted,children:"\u2500".repeat(F)}),(0,y.jsxs)(p,{children:[(0,y.jsx)(f,{color:u.muted,children:"\u276F "}),(0,y.jsx)(f,{color:u.dim,children:i})]}),(0,y.jsx)(me,{bindings:w??[{keys:"ctrl+c",label:"cancel"},{keys:"/cancel",label:"stop turn"},{keys:"ctrl+t",label:"thinking"}],suppressEscBack:!0})]});let Ze=a=>{v([...a]),b(a.length),q("none")},et=()=>{q("none")},we=(()=>{if(Te&&c.length===0)return null;let a=d>=c.length,n=c.slice(0,d).join(""),o,E;a?(o=" ",E=""):c[d]===`
10
+ `?(o=" ",E=c.slice(d).join("")):(o=c[d],E=c.slice(d+1).join(""));let I=n+o+E+P,A=n.length,N=A+1,X=N+E.length,Se=Math.max(1,F-2),L=[],re=0;for(;re<=I.length;){let W=I.indexOf(`
11
+ `,re);if(W===-1&&(W=I.length),re===W)L.push({type:"content",start:re,end:re});else{let J=re;for(;J<W;){let ae=Math.min(J+Se,W);L.push({type:"content",start:J,end:ae}),J=ae}}if(W>=I.length)break;re=W+1}let ee=Math.max(0,L.findIndex(W=>W.start<=A&&A<=W.end)),de;if(L.length<=Me)de=L;else{let J=Me-1-4;if(ee<4||ee>=L.length-J)de=[...L.slice(0,4),{type:"ellipsis",hidden:L.length-4-J},...L.slice(L.length-J)];else{let ae=Me-2,Le=Math.floor(ae/2),ce=ee-Le,pe=ee+(ae-Le)-1;ce<1&&(pe+=1-ce,ce=1),pe>L.length-2&&(ce-=pe-(L.length-2),pe=L.length-2),ce=Math.max(1,ce),de=[{type:"ellipsis",hidden:ce},...L.slice(ce,pe+1),{type:"ellipsis",hidden:L.length-pe-1}]}}return{full:I,b:A,c:N,a:X,rows:de}})();return(0,y.jsxs)(p,{flexDirection:"column",children:[V==="search"&&(0,y.jsx)(Ge,{history:e,onSelect:Ze,onClose:et}),he&&(0,y.jsx)(Ve,{commands:B,selectedIndex:ie}),ge&&(0,y.jsx)(ze,{items:ne,selectedIndex:Z,accent:U}),(0,y.jsx)(f,{color:u.muted,children:"\u2500".repeat(F)}),we===null?(0,y.jsxs)(p,{children:[(0,y.jsx)(f,{color:U,children:"\u276F "}),(0,y.jsx)(f,{inverse:!0,children:" "}),(0,y.jsx)(f,{color:u.dim,children:i})]}):(()=>{let a=we.rows.findIndex(n=>n.type==="content");return(0,y.jsx)(p,{flexDirection:"column",children:we.rows.map((n,o)=>{if(n.type==="ellipsis")return(0,y.jsx)(p,{children:(0,y.jsxs)(f,{color:u.dim,children:[" \u22EF ","(",n.hidden," more line",n.hidden===1?"":"s",")"]})},o);let{full:E,b:I,c:A,a:N}=we,X=n.start,fe=n.end,Se=o===a,L=Se?"\u276F ":" ",re=Se?U:u.muted,ee=[(0,y.jsx)(f,{color:re,children:L},"p")];X<Math.min(I,fe)&&ee.push((0,y.jsx)(f,{children:E.slice(X,Math.min(I,fe))},"b"));let de=Math.max(I,X),W=Math.min(A,fe);de<W&&ee.push((0,y.jsx)(f,{color:U,inverse:!0,children:E.slice(de,W)},"c"));let J=Math.max(A,X),ae=Math.min(N,fe);return J<ae&&ee.push((0,y.jsx)(f,{children:E.slice(J,ae)},"a")),fe>N&&ee.push((0,y.jsx)(f,{color:u.dim,children:E.slice(Math.max(N,X),fe)},"g")),(0,y.jsx)(p,{children:ee},o)})})})(),(0,y.jsx)(me,{bindings:w??[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:h??"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var K=$(xe(),1);var x=$(te(),1);function vt(r){let t=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return r&&t.push({id:"env",label:"Environment",options:[{label:"prod",value:"prod"},{label:"stage",value:"stage"}]}),t.push({id:"profile",label:"Profile"}),t.push({id:"credentials",label:"Credentials"}),t}function tn({devMode:r,profiles:t,onBasicLogin:e,onOAuthLogin:i,onComplete:s,onCancel:l}){let h=vt(r),[w,T]=(0,K.useState)(0),[m,S]=(0,K.useState)(0),[U,k]=(0,K.useState)({}),[C,M]=(0,K.useState)("select"),[c,v]=(0,K.useState)(""),[d,b]=(0,K.useState)("username"),[V,q]=(0,K.useState)(""),[Y,O]=(0,K.useState)(null),[oe,Te]=(0,K.useState)(null),H=h[w],ve=U.method??"basic",F=U.env??"prod",ie=(0,K.useCallback)(()=>{let R=t.filter(g=>g.env===F).map(g=>({label:`${g.profile} [${g.env}]`,value:g.profile}));return R.push({label:"+ Create new",value:"__new__"}),R},[t,F]),j=(0,K.useCallback)(()=>{w===0?l():(T(_=>_-1),S(0),M("select"),v(""),O(null))},[w,l]),Z=(0,K.useCallback)(_=>{ve==="basic"?(M("text-input"),b("username"),v("")):(M("waiting"),i(_,F).then(()=>{Te(`Logged in via OAuth as ${_} [${F}]`),M("done")}).catch(R=>{O(R.message),M("error")}))},[ve,F,i]),se=(0,K.useCallback)(_=>{let R=_.trim();if(R){if(d==="profileName"){let g=R;k(P=>({...P,profile:g})),Z(g);return}if(d==="username"){q(R),v(""),b("accessKey"),M("text-input-masked");return}if(d==="accessKey"){let g=U.profile??"default";M("waiting"),(async()=>{try{await e(g,F,V,R),Te(`Logged in as ${g} [${F}] via basic auth`),M("done")}catch{O("Credentials not valid. Please use valid credentials."),q(""),v(""),b("username"),M("text-input")}})()}}},[d,U.profile,F,e,V,Z]),Ae=(0,K.useCallback)(_=>{v(_),Y&&O(null)},[Y]);be((_,R)=>{if(C==="done"){let P=U.profile??"default";s(P,F);return}if(C==="error"){l();return}if(C==="waiting"){R.escape&&l();return}if(C==="text-input"||C==="text-input-masked")return;if(R.escape){j();return}let g=H?.id==="profile"?ie():H?.options??[];if(R.upArrow){S(P=>Math.max(0,P-1));return}if(R.downArrow){S(P=>Math.min(g.length-1,P+1));return}if(R.return&&g[m]){let P=g[m];if(H.id==="profile"){if(P.value==="__new__"){M("text-input"),b("profileName"),v("");return}k(B=>({...B,profile:P.value})),T(B=>B+1),S(0),Z(P.value);return}k(B=>({...B,[H.id]:P.value})),T(B=>B+1),S(0)}});let le="Login";if(C==="done")return(0,x.jsxs)(p,{flexDirection:"column",borderStyle:"round",borderColor:u.green,paddingX:2,paddingY:1,children:[(0,x.jsxs)(f,{color:u.green,bold:!0,children:["\u2713 ",oe]}),(0,x.jsx)(p,{marginTop:1,children:(0,x.jsx)(f,{color:u.dim,children:"press any key"})})]});if(C==="error")return(0,x.jsxs)(p,{flexDirection:"column",borderStyle:"round",borderColor:u.red,paddingX:2,paddingY:1,children:[(0,x.jsx)(f,{color:u.red,bold:!0,children:"Login failed"}),(0,x.jsx)(p,{marginTop:1,children:(0,x.jsx)(f,{color:u.red,children:Y})}),(0,x.jsx)(p,{marginTop:1,children:(0,x.jsx)(f,{color:u.dim,children:"press any key"})})]});if(C==="waiting")return(0,x.jsxs)(p,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,x.jsxs)(f,{color:u.orange,bold:!0,children:[le," \u203A OAuth"]}),(0,x.jsx)(p,{marginTop:1,children:(0,x.jsx)(f,{color:u.secondary,children:"Opening browser for login..."})}),(0,x.jsx)(p,{marginTop:1,children:(0,x.jsx)(f,{color:u.orange,children:"Waiting for callback \u27F3"})}),(0,x.jsx)(me,{bindings:[],escBackLabel:"cancel"})]});if(C==="text-input"||C==="text-input-masked"){let _=d==="username"?"Username":d==="accessKey"?"Access Key":"Profile name",R=d==="username"||d==="accessKey"?`${le} \u203A Basic Auth`:`${le} \u203A New Profile`;return(0,x.jsxs)(p,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[Y&&(d==="username"||d==="accessKey")&&(0,x.jsx)(p,{marginBottom:1,children:(0,x.jsxs)(f,{color:u.red,children:["\u2717 ",Y]})}),(0,x.jsx)(f,{color:u.orange,bold:!0,children:R}),d==="accessKey"&&(0,x.jsxs)(p,{marginTop:1,children:[(0,x.jsx)(f,{color:u.secondary,children:"Username: "}),(0,x.jsx)(f,{children:V})]}),(0,x.jsxs)(p,{marginTop:1,children:[(0,x.jsxs)(f,{color:u.secondary,children:[_,": "]}),(0,x.jsx)(Oe,{value:c,onChange:Ae,onSubmit:se,onCancel:j,masked:C==="text-input-masked"})]}),(0,x.jsx)(me,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let Ce=H?.id==="profile"?ie():H?.options??[];return(0,x.jsxs)(p,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,x.jsx)(f,{color:u.orange,bold:!0,children:le}),(0,x.jsx)(p,{marginTop:1,children:(0,x.jsxs)(f,{color:u.secondary,children:[H?.label,":"]})}),(0,x.jsx)(p,{flexDirection:"column",marginTop:1,children:Ce.map((_,R)=>{let g=R===m,P=g?"\u276F ":" ",B=_.value==="__new__"?u.green:g?u.orange:void 0;return(0,x.jsxs)(f,{color:B,children:[P,_.label]},_.value)})}),(0,x.jsx)(me,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}async function Qe(r,t,e,i){let s=r.loadBasicAuth(t,e),l=r.loadCredentials(t,e);if(!s&&!l)return i("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:t,env:e}),{status:"needs_login",profile:t,env:e};let h=$e(e),w=async()=>r.loadCredentials(t,e)?.access_token??null,T=new Ne(h.controllerBaseUrl,w,s,i);i("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:t,env:e,method:s?"basic":"oauth"});let m=await T.resolve(!0);if(m)return i("info","STARTUP_GATE_VALID","Credentials validated",{profile:t,env:e,username:m.username,org_id:m.org_id}),{status:"authenticated",result:{profile:t,env:e,credentials:l,basicAuth:s,tmsCreds:m,resolver:T}};if(!s&&l){let S=l.refresh_token,k=r.loadClient(t,e)?.client_id;if(S&&k){i("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:t,env:e});try{let M=await new Fe(e).refreshToken(S,k);if(M.access_token){r.saveCredentials(t,e,{...l,...M,expires_at:Date.now()/1e3+(M.expires_in??3600)});let v=await T.resolve(!0);if(v)return i("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:t,env:e,username:v.username}),{status:"authenticated",result:{profile:t,env:e,credentials:{...l,...M},basicAuth:null,tmsCreds:v,resolver:T}}}i("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:t,env:e})}catch(C){i("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:t,env:e,error:C instanceof Error?C.message:String(C)})}}else i("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:t,env:e})}return i("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:t,env:e}),{status:"needs_login",profile:t,env:e}}async function cn(r,t,e=new Ke){let i=r.listProfiles();if(t("info","STARTUP_GATE_START","Auth startup gate",{profile_count:i.length}),i.length===0)return t("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(i.length>1){let h=r.getActiveProfile(),w=r.getDefaultEnv();if(h&&i.some(m=>m.profile===h&&m.env===w)){t("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:h,activeEnv:w});let m=await Qe(r,h,w,t);if(m.status==="authenticated")return m;t("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:h,activeEnv:w})}return t("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:i.map(T=>`${T.profile}/${T.env}`)}),{status:"needs_pick",profiles:i}}let{profile:s,env:l}=i[0];return r.setActiveProfile(s),r.setDefaultEnv(l),Ue(r,e,s,l),Qe(r,s,l,t)}export{At as a,Ct as b,jt as c,tn as d,Qe as e,cn as f};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as E}from"./chunk-YCCUBQY4.js";import{y as m}from"./chunk-PXPXK4Q7.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as h,b as s,i as C,k as S}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as w}from"./chunk-UR6MHSHU.js";var c=w(R(),1);function N(d){let n=d.findIndex(o=>o.free);return n>=0?n:null}var $=60;function W({headline:d,ask:n=!1,rows:o,sel:r,focused:x,legend:l,freeText:u=null,freeTextNote:f}){let{stdout:t}=S(),e=(t?.columns??80)<$,a=i=>x&&r===i?(0,c.jsx)(s,{color:m.generateAccent,children:"\u25B8"}):" ",p=0,g=(0,c.jsxs)(h,{flexDirection:"column",children:[n?(0,c.jsx)(s,{bold:!0,color:m.generateAccent,children:`? ${d}`}):(0,c.jsx)(s,{bold:!0,children:d}),o.map((i,T)=>i.free?u?(0,c.jsxs)(h,{flexDirection:"column",children:[(0,c.jsxs)(h,{children:[(0,c.jsxs)(s,{children:[" ",(0,c.jsx)(s,{color:m.generateAccent,children:"\u25B8"})," ",(0,c.jsx)(s,{color:m.dim,children:"\u270E "})]}),(0,c.jsx)(E,{value:u.value,onChange:u.onChange,onSubmit:u.onSubmit,onCancel:u.onCancel,placeholder:i.label})]}),f?(0,c.jsx)(s,{color:m.muted,children:` ${f}`}):null]},i.key):(0,c.jsxs)(s,{children:[" ",a(T)," ",(0,c.jsx)(s,{color:m.dim,children:`\u270E ${i.label}`})]},i.key):(p+=1,(0,c.jsxs)(s,{bold:x&&r===T,children:[" ",a(T),` ${p} ${i.label}`,i.detail?(0,c.jsx)(s,{color:m.dim,bold:!1,children:` \u2014 ${i.detail}`}):null]},i.key))),(0,c.jsx)(s,{color:m.muted,children:` ${l}`})]});return e?g:(0,c.jsx)(h,{flexDirection:"column",borderStyle:"round",borderColor:m.generateAccent,paddingX:1,children:g})}var A=w(R(),1),P="ctrl+t thinking \xB7 ctrl+c exit";function M(d,n){if(d.length<=n)return d;if(n<=1)return"\u2026";let o=Math.ceil((n-1)/2),r=Math.floor((n-1)/2);return`${d.slice(0,o)}\u2026${r>0?d.slice(-r):""}`}function L({verb:d,subject:n,pendingCount:o,creditsTotal:r,state:x,hints:l=P}){let{stdout:u}=S(),f=u?.columns??80,t=[];t.push(d),x&&t.push(x),r!==void 0&&t.push(`${r.toFixed(1)} credits`);let e=o?`[${o} pending]`:null,a=" \xB7 ",g=[...t,...e?[e]:[]].join(a).length,i,T=[...t,...n?[n]:[],...e?[e]:[],l].join(a);if(T.length<=f)i=T;else{let b=f-g-(n?a.length:0)-a.length-l.length;if(n&&b>=8)i=[...t,M(n,b),...e?[e]:[],l].join(a);else{let v=f-g-(n?a.length:0);i=[...t,...n&&v>=4?[M(n,v)]:[],...e?[e]:[]].join(a)}}if(x){let b=` \xB7 ${x}`,v=i.indexOf(b);if(v>=0)return(0,A.jsxs)(s,{color:m.dim,children:[i.slice(0,v+3),(0,A.jsx)(s,{color:m.generateAccent,children:x}),i.slice(v+b.length)]})}return(0,A.jsx)(s,{color:m.dim,children:i})}var O=w(B(),1);function q({onToggleThinking:d,onCtrlC:n,explorer:o,panel:r}){let l=(0,O.useRef)(null),u=(0,O.useRef)(""),f=()=>{l.current&&clearTimeout(l.current),l.current=null,u.current=""};return(0,O.useEffect)(()=>f,[]),C((t,e)=>{if(e.ctrl&&t==="t"){d();return}if(e.ctrl&&t==="c"){n();return}if(!e.ctrl&&t.includes("")){n();return}if(!e.ctrl&&t.includes("")){d();return}if(o&&o.isOpen()){let a=()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{f(),o.onBack()},150)};if(l.current){if(e.upArrow||e.downArrow||e.return){f(),e.return?o.onEnter():o.onMove(e.upArrow?-1:1);return}if(u.current+=t,u.current==="["){a();return}let p=u.current;f();let g=/^\[([AB])/.exec(p);if(g){o.onMove(g[1]==="A"?-1:1);return}o.onBack();return}if(e.upArrow){o.onMove(-1);return}if(e.downArrow){o.onMove(1);return}if(e.return){o.onEnter();return}if(e.escape){u.current="",a();return}return}if(r&&r.isFocused()){let a=()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{f(),r.onBack()},150)};if(l.current){if(e.upArrow||e.downArrow||e.return){f(),e.return?r.onSelect():r.onMove(e.upArrow?-1:1);return}if(u.current+=t,u.current==="["){a();return}let p=u.current;f();let g=/^\[([AB])/.exec(p);if(g){r.onMove(g[1]==="A"?-1:1);return}r.onBack();return}if(e.upArrow){r.onMove(-1);return}if(e.downArrow){r.onMove(1);return}if(e.return){r.onSelect();return}if(e.escape){u.current="",a();return}if(/^[1-9]$/.test(t)){r.onDigit(Number(t));return}if(e.tab){r.onTab?.();return}if(t===" "&&r.isMulti()){r.onSpace();return}if(t&&!e.ctrl&&!e.meta){r.onType(t);return}return}}),null}export{N as a,W as b,L as c,q as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as g}from"./chunk-6SGPN76K.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
2
+ import{c as g}from"./chunk-PXPXK4Q7.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
3
3
  `),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
4
4
  `),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
5
5
  `)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as t}from"./chunk-427OQS2N.js";import{a,b as s,c as n}from"./chunk-5YPBPZUR.js";function y(o="extract"){let i=new Set(t(o)),c=Object.fromEntries(Object.keys(s).map(r=>{let e=s[r];return[r,{hashed:[...e.hashed],unhashed:[...e.unhashed??[]],required:[...e.required],enums:Object.fromEntries(Object.entries(e.enums).map(([p,g])=>[p,[...g]])),mintable:i.has(r)}]})),d=Object.fromEntries(Object.keys(n).map(r=>{let e=n[r];return[r,{src:[...e.src],dst:[...e.dst],salient:[...e.salient],props:[...e.props],cardinality:e.cardinality,acyclic:e.acyclic,direction:"dependent->dependency"}]}));return{schema_version:a,nodes:c,edges:d,mint_gate:t(o),blob_fingerprint:{algo:"sha256",domain:"assurance.blob\0",prefix:"sha256:"}}}export{y as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,f as o}from"./chunk-6SGPN76K.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
2
+ import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,f as o}from"./chunk-PXPXK4Q7.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as sn}from"./chunk-GLS46X7N.js";import{c as Tt,d as Qr}from"./chunk-EWTX7HSU.js";import{d as Wr}from"./chunk-2YQ6TW77.js";import{a as Lt,b as Zr,c as et,d as tt,e as Xr,f as Dt,g as rn,h as nn}from"./chunk-RHNKYNNZ.js";import{a as Te,b as ne,e as _e,f as xt,k as Yr,p as he,q as Pt,t as Jr}from"./chunk-RKWJG3WW.js";import{b as Se}from"./chunk-6XHAXAL2.js";import{a as Ze,b as At}from"./chunk-5JJ245FW.js";import{a as Or,b as Et}from"./chunk-D7L6UW5Z.js";import{a as Le,b as en}from"./chunk-C5UNZ6ZY.js";import{c as tn}from"./chunk-S3DAAAE5.js";import{a as we}from"./chunk-WAOCHXJ5.js";import{B as jr,C as Fr,D as Nr,F as $r,G as Mr,I as Vr,J as Kr,K as Hr,X as qr,aa as Gr,ba as zr,j as Xe,x as Ur}from"./chunk-4A6BLXQN.js";import{a as Br}from"./chunk-BC7UVJJB.js";import{a as xr,c as kt,d as Ct,e as Qe,f as Pr,g as Tr}from"./chunk-M5JQXOCE.js";import{g as Lr,h as Dr}from"./chunk-2BWRAY3Y.js";import{a as Je}from"./chunk-2WVKOZ6W.js";import{a as We,b as Ar}from"./chunk-NLCCBXXV.js";import{a as M}from"./chunk-RZ4F3BHX.js";import{a as re}from"./chunk-AKHUNBQS.js";import{a as Cr}from"./chunk-E47GFYXA.js";import{a as ze,c as _t,j as Er,k as Ye,l as It,m as Rt}from"./chunk-6SGPN76K.js";import{join as le,basename as as}from"path";import{existsSync as Ro,readFileSync as cs}from"fs";function on(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let n=e.steps[r],s=t[r],o=" ".repeat(n.trace.length-1),i=`step ${n.flatIndex}`;s.kind==="replay"?process.stderr.write(`[replay-trace] ${o}${i}: REPLAY (would skip; v1 always authors)
2
+ import{c as sn}from"./chunk-GLS46X7N.js";import{c as Tt,d as Qr}from"./chunk-FCZ2YFD3.js";import{d as Wr}from"./chunk-2YQ6TW77.js";import{a as Lt,b as Zr,c as et,d as tt,e as Xr,f as Dt,g as rn,h as nn}from"./chunk-RHNKYNNZ.js";import{a as Te,b as ne,e as _e,f as xt,k as Yr,p as he,q as Pt,t as Jr}from"./chunk-RKWJG3WW.js";import{b as Se}from"./chunk-IQFUBT6Z.js";import{a as Ze,b as At}from"./chunk-TAUSKB3O.js";import{a as Or,b as Et}from"./chunk-K7P6VNLI.js";import{a as Le,b as en}from"./chunk-C5UNZ6ZY.js";import{c as tn}from"./chunk-S3DAAAE5.js";import{a as we}from"./chunk-WAOCHXJ5.js";import{B as jr,C as Fr,D as Nr,F as $r,G as Mr,I as Vr,J as Kr,K as Hr,X as qr,aa as Gr,ba as zr,j as Xe,x as Ur}from"./chunk-EYZWG32F.js";import{a as Br}from"./chunk-BC7UVJJB.js";import{a as xr,c as kt,d as Ct,e as Qe,f as Pr,g as Tr}from"./chunk-M5JQXOCE.js";import{g as Lr,h as Dr}from"./chunk-YTK3IQUB.js";import{a as Je}from"./chunk-2WVKOZ6W.js";import{a as We,b as Ar}from"./chunk-NLCCBXXV.js";import{a as M}from"./chunk-RZ4F3BHX.js";import{a as re}from"./chunk-K4ERF7GT.js";import{a as Cr}from"./chunk-E47GFYXA.js";import{a as ze,c as _t,j as Er,k as Ye,l as It,m as Rt}from"./chunk-PXPXK4Q7.js";import{join as le,basename as as}from"path";import{existsSync as Ro,readFileSync as cs}from"fs";function on(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let n=e.steps[r],s=t[r],o=" ".repeat(n.trace.length-1),i=`step ${n.flatIndex}`;s.kind==="replay"?process.stderr.write(`[replay-trace] ${o}${i}: REPLAY (would skip; v1 always authors)
3
3
  `):process.stderr.write(`[replay-trace] ${o}${i}: AUTHOR (${s.reason})
4
4
  `)}}function Ie(e){process.env.KANE_REPLAY_TRACE==="1"&&process.stderr.write(e)}function an(e,t){let r=e===0?"(none)":`0..${e-1}`,n=e>=t?"(none)":`${e}..${t-1}`;Ie(`[replay-trace] phase: replay ${r}, author ${n}
5
5
  `)}function ln(e,t){Ie(`[replay-trace] step ${e}: REPLAY ${t==="ok"?"OK":"FAILED"}
@@ -44,7 +44,7 @@ import{c as sn}from"./chunk-GLS46X7N.js";import{c as Tt,d as Qr}from"./chunk-EWT
44
44
  `);else if(_r&&(_||m.isFirstRun))process.stderr.write(`note: --no-evidence-publish has no effect on author/commit runs
45
45
  `);else if(Ir){let d=c.basicAuth,u=L,p=F,b=await ss({controller:new we(A.controllerBaseUrl,{username:d.username,accessKey:d.access_key}),tms:new Je(A.tmsBaseUrl,c.resolvedCreds?.username??d.username,c.resolvedCreds?.access_key??d.access_key),testId:m.testId,sessionId:l.sessionId,executionId:u.executionId,sealedPackPath:Z.pack,projectId:p});b.ok?l.log("info","EVIDENCE_INGESTED","Replay evidence uploaded and ingested",{execution_id:u.executionId,project_id:p}):(l.log("warn","EVIDENCE_PUBLISH_FAILED","Replay evidence publish failed",{execution_id:u.executionId,stage:b.stage,error:b.error}),process.stderr.write(` \u26A0 evidence publish failed (${b.stage}): ${b.error}
46
46
  `)),t.onAgentEvent({type:"test_md_evidence_ingest",status:b.ok?"ok":"failed",evidence_id:u.executionId,...b.ok?{}:{stage:b.stage}})}await Lo(n,m,l,z.outcomes,z.overallStatus,Ve,ge,oe.uploadResult,j,o,{resolvedAuth:c,tmsBaseUrl:A.tmsBaseUrl},_,J);try{let d=he(n);if(Qr({shouldUploadPipeline:He,uploadSucceeded:!!oe.uploadResult?.success,metaCommitId:d?.commit_id,metaTestId:d?.test_id})){let u=await Tt({sourcePath:n,testId:d.test_id,sessionId:l.sessionId,commitId:d.commit_id,controller:new we(A.controllerBaseUrl,{username:c.basicAuth.username,accessKey:c.basicAuth.access_key})});u.ok?l.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:d.commit_id,bytes:u.bytes}):(l.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:d.commit_id,stage:u.stage,error:u.error}),process.stderr.write(` \u26A0 bundle sync failed (${u.stage}): ${u.error}
47
- `)),t.onAgentEvent({type:"test_md_bundle_sync",status:u.ok?"ok":"failed",commit_id:d.commit_id,path:n,...u.ok?{bytes:u.bytes}:{stage:u.stage}})}}catch(d){l.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{error:d instanceof Error?d.message:String(d)})}if(He&&oe.uploadResult?.success)for(let d of m.unitLocks)try{let u=he(d.file);if(u?.commit_id!==l.sessionId||!u?.test_id)continue;let p=await Tt({sourcePath:d.file,testId:String(u.test_id),sessionId:l.sessionId,commitId:String(u.commit_id),controller:new we(A.controllerBaseUrl,{username:c.basicAuth.username,accessKey:c.basicAuth.access_key})});p.ok?l.log("info","BUNDLE_SYNC_OK","unit bundle pushed",{commit_id:u.commit_id,path:d.file,bytes:p.bytes}):l.log("warn","BUNDLE_SYNC_FAILED","unit bundle sync failed",{commit_id:u.commit_id,path:d.file,stage:p.stage,error:p.error}),t.onAgentEvent({type:"test_md_bundle_sync",status:p.ok?"ok":"failed",commit_id:u.commit_id,path:d.file,...p.ok?{bytes:p.bytes}:{stage:p.stage}})}catch(u){l.log("warn","BUNDLE_SYNC_FAILED","unit bundle sync threw",{path:d.file,error:u instanceof Error?u.message:String(u)})}let Rr=re(w),qe=oe.uploadResult?.testcaseId,Ge=qe&&oe.uploadResult?.shareId&&F?ot(Rr.testManagerUiUrl,F,qe,oe.uploadResult.shareId):void 0,Ss=a.unitFiles.filter(d=>d.file!==a.rootPath).map(d=>{let u=a.steps.filter(g=>g.owningFile===d.file),p=u.filter(g=>ce.has(g.flatIndex)).length,h=(d.kind==="test"?he(d.file):null)?.commit_id===l.sessionId;return{path:d.file,kind:d.kind,replayed:u.length-p,authored:p,committed:h,...h?{commit_id:l.sessionId}:{}}}),kr={overallStatus:z.overallStatus,durationS:ge,decisions:m.decisions,outcomes:z.outcomes,cancelled:J,retryTriggered:X,lockHeld:_,anyAuthorStepRan:D,isFirstRun:m.isFirstRun,wantsPush:o.push===!0,uploadResult:oe.uploadResult,shouldUploadArtifacts:ve,shouldReplaceLocalOutput:D&&!J,shouldCommit:(_||m.isFirstRun)&&!J&&z.overallStatus==="passed"&&!m.degradedReadonly,shareUrl:Ge,imports:Ss},{buildSummaryEvent:ws}=await import("./SummaryBox-4T545XRB.js");if(i?t.onAgentEvent(ws(kr)):await t.onSummary(kr),!i){let d=qe&&F?Ln(Rr.testManagerUiUrl,F,qe):void 0;await t.onLinks({recordedTestPath:n,outputDir:ne(n),shareableLink:Ge,testCaseLink:d,codeExportDir:oe.uploadResult?.codeExportDir})}if(ae.ownsLifecycle&&Z&&wr){let{offerEvidenceView:d}=await import("./evidence-7VE5EGEF.js");await d({packPath:Z.pack,env:w,isTTY:!i&&!J&&!!process.stdin.isTTY&&!!process.stderr.isTTY,log:u=>process.stderr.write(u+`
47
+ `)),t.onAgentEvent({type:"test_md_bundle_sync",status:u.ok?"ok":"failed",commit_id:d.commit_id,path:n,...u.ok?{bytes:u.bytes}:{stage:u.stage}})}}catch(d){l.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{error:d instanceof Error?d.message:String(d)})}if(He&&oe.uploadResult?.success)for(let d of m.unitLocks)try{let u=he(d.file);if(u?.commit_id!==l.sessionId||!u?.test_id)continue;let p=await Tt({sourcePath:d.file,testId:String(u.test_id),sessionId:l.sessionId,commitId:String(u.commit_id),controller:new we(A.controllerBaseUrl,{username:c.basicAuth.username,accessKey:c.basicAuth.access_key})});p.ok?l.log("info","BUNDLE_SYNC_OK","unit bundle pushed",{commit_id:u.commit_id,path:d.file,bytes:p.bytes}):l.log("warn","BUNDLE_SYNC_FAILED","unit bundle sync failed",{commit_id:u.commit_id,path:d.file,stage:p.stage,error:p.error}),t.onAgentEvent({type:"test_md_bundle_sync",status:p.ok?"ok":"failed",commit_id:u.commit_id,path:d.file,...p.ok?{bytes:p.bytes}:{stage:p.stage}})}catch(u){l.log("warn","BUNDLE_SYNC_FAILED","unit bundle sync threw",{path:d.file,error:u instanceof Error?u.message:String(u)})}let Rr=re(w),qe=oe.uploadResult?.testcaseId,Ge=qe&&oe.uploadResult?.shareId&&F?ot(Rr.testManagerUiUrl,F,qe,oe.uploadResult.shareId):void 0,Ss=a.unitFiles.filter(d=>d.file!==a.rootPath).map(d=>{let u=a.steps.filter(g=>g.owningFile===d.file),p=u.filter(g=>ce.has(g.flatIndex)).length,h=(d.kind==="test"?he(d.file):null)?.commit_id===l.sessionId;return{path:d.file,kind:d.kind,replayed:u.length-p,authored:p,committed:h,...h?{commit_id:l.sessionId}:{}}}),kr={overallStatus:z.overallStatus,durationS:ge,decisions:m.decisions,outcomes:z.outcomes,cancelled:J,retryTriggered:X,lockHeld:_,anyAuthorStepRan:D,isFirstRun:m.isFirstRun,wantsPush:o.push===!0,uploadResult:oe.uploadResult,shouldUploadArtifacts:ve,shouldReplaceLocalOutput:D&&!J,shouldCommit:(_||m.isFirstRun)&&!J&&z.overallStatus==="passed"&&!m.degradedReadonly,shareUrl:Ge,imports:Ss},{buildSummaryEvent:ws}=await import("./SummaryBox-HCDIWKPS.js");if(i?t.onAgentEvent(ws(kr)):await t.onSummary(kr),!i){let d=qe&&F?Ln(Rr.testManagerUiUrl,F,qe):void 0;await t.onLinks({recordedTestPath:n,outputDir:ne(n),shareableLink:Ge,testCaseLink:d,codeExportDir:oe.uploadResult?.codeExportDir})}if(ae.ownsLifecycle&&Z&&wr){let{offerEvidenceView:d}=await import("./evidence-ZFYDHO73.js");await d({packPath:Z.pack,env:w,isTTY:!i&&!J&&!!process.stdin.isTTY&&!!process.stderr.isTTY,log:u=>process.stderr.write(u+`
48
48
  `)})}return t.onAgentEvent({type:"test_md_done",overall_status:z.overallStatus,duration_s:ge,session_id:l.sessionId,...Ge?{share_url:Ge}:{}}),{overallStatus:z.overallStatus,exitCode:z.overallStatus==="passed"?0:1,outputDir:ne(n),durationS:ge,uploadResult:oe.uploadResult,anyAuthorStepRan:D,resultCode:Ur(Ke),...St.length?{pendingInvestigations:St}:{}}}function Ao(e,t){let r={...e,...t},n=Object.keys(r).length>0?Se(r,""):{variables:{},objective:"",keyMap:{}};return{raw:r,auteur:n.variables,auteurObjective:"",secretEntries:Object.entries(r).filter(([,s])=>s.secret),nonSecretEntries:Object.entries(r).filter(([,s])=>!s.secret)}}function Ce(e,t,r){let n={...e,...t??{}};if(Object.keys(n).length===0)return{raw:n,variables:{},objective:r};let s=Se(n,r);return{raw:n,variables:qn(s.variables,s.objective),objective:s.objective}}function xo(e,t,r){let n=Ce(e,t,r).variables;return Object.keys(n).length>0?n:void 0}function ls(e,t){let r=new Set(dt),n={...e};for(let[s,o]of Object.entries(t))r.has(s)||s!=="variables"&&o!==void 0&&e[s]===void 0&&(n[s]=o);return n}function Po(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function To(e,t,r,n,s,o){let i=Zr(t);on(t,i);let f=_e(e),a=Ro(f)?JSON.parse(cs(f,"utf8")):null,c=a?.testcase_id,y=a?.test_id,w=a?.commit_id,A=r.push===!0,R=r.retry===!0||r.retryCount!==void 0,x=r.author===!0;A&&!c&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
49
49
  `),x&&(c=void 0,y=void 0,w=void 0);let k=n.resolvedAuth.basicAuth;if(!k){let N=await n.resolvedAuth.resolver.resolve(!0);N?.username&&N?.access_key&&(k={username:N.username,access_key:N.access_key},n.resolvedAuth.basicAuth=k)}let C=!!k,l=!r.local&&C&&y!=null&&w!=null&&c!=null,H=l&&(et(i)||A);if(A&&!l)return process.stderr.write(`error: --push requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
50
50
  `),{resolved:t,decisions:i,testId:y,testcaseId:c,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:C,canLock:l,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(R&&!l)return process.stderr.write(`error: --retry requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{d as o}from"./chunk-NVGBE2DR.js";function s(n,r,e){let t=r.mediaOf(e),l=typeof t?.text_blob=="string"&&t.text_blob!==""?t.text_blob:null;if(l!==null)return o(n,l);let i=String(r.getNode(e)?.content.blob??"");return i===""?null:o(n,i)}function b(n){return n.toString("utf8").replace(/\n$/,"").split(`
3
+ `).map((e,t)=>`${String(t+1).padStart(4,"0")}| ${e}`).join(`
4
+ `)}export{s as a,b};
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as k}from"./chunk-NVGBE2DR.js";function C(t,n){let{width:e,height:o,channels:i}=n;if(t.length!==e*o*i)throw new Error(`appearanceSignature: buffer ${t.length} bytes does not match ${e}x${o}x${i}`);let s=9,r=8,f=new Array(s*r);for(let u=0;u<r;u++){let h=Math.floor(u*o/r),g=Math.min(o,Math.max(h+1,Math.floor((u+1)*o/r)));for(let p=0;p<s;p++){let A=Math.floor(p*e/s),d=Math.min(e,Math.max(A+1,Math.floor((p+1)*e/s))),E=0,w=0;for(let I=h;I<g;I++)for(let l=A;l<d;l++){let m=(I*e+l)*i;E+=i===1?t[m]:Math.floor((t[m]*299+t[m+1]*587+t[m+2]*114)/1e3),w+=1}f[u*s+p]=Math.floor(E/w)}}let c="",P=0,_=0;for(let u=0;u<r;u++)for(let h=0;h<s-1;h++)P=P<<1|(f[u*s+h+1]>f[u*s+h]?1:0),_+=1,_===4&&(c+=P.toString(16),P=0,_=0);return c}import{deflateSync as N}from"zlib";var G=(()=>{let t=new Uint32Array(256);for(let n=0;n<256;n++){let e=n;for(let o=0;o<8;o++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e>>>0}return t})();function Y(t){let n=4294967295;for(let e of t)n=G[(n^e)&255]^n>>>8;return(n^4294967295)>>>0}function R(t,n){let e=Buffer.alloc(4);e.writeUInt32BE(n.length);let o=Buffer.concat([Buffer.from(t,"latin1"),n]),i=Buffer.alloc(4);return i.writeUInt32BE(Y(o)),Buffer.concat([e,o,i])}var X={1:0,3:2,4:6};function F(t,n){let{width:e,height:o,channels:i}=n;if(t.byteLength!==e*o*i)throw new Error(`pngEncode: raw length ${t.byteLength} != ${e}x${o}x${i}`);let s=Buffer.alloc(13);s.writeUInt32BE(e,0),s.writeUInt32BE(o,4),s[8]=8,s[9]=X[i];let r=e*i,f=Buffer.alloc(o*(r+1));for(let c=0;c<o;c++)f[c*(r+1)]=0,t.copy(f,c*(r+1)+1,c*r,(c+1)*r);return Buffer.concat([Buffer.from([137,80,78,71,13,10,26,10]),R("IHDR",s),R("IDAT",N(f)),R("IEND",Buffer.alloc(0))])}var U=64,J=16,V=12e6,W=6e6,K=5e3,H=3e4,q="",v=class extends Error{constructor(e,o){super(`${e}: ${o}`);this.code=e}};async function z(t,n,e){let o=t.objs.has(n)?t.objs:t.commonObjs.has(n)?t.commonObjs:null;if(o)try{return o.get(n)??null}catch{return null}if(e.remainingMs<=0)return null;let i=n.startsWith("g_")?t.commonObjs:t.objs,s,r=Date.now();try{return await Promise.race([new Promise(f=>{try{i.get(n,c=>f(c??null))}catch{f(null)}}),new Promise(f=>{s=setTimeout(()=>f(null),Math.min(K,e.remainingMs))})])}finally{clearTimeout(s),e.remainingMs-=Date.now()-r}}async function Q(){let t=await import("pdfjs-dist/legacy/build/pdf.mjs");return t.default??t}async function ie(t,n){let e=await Q();q=e.version;let o={remainingMs:n?.resolveBudgetMs??H},i,s=e.getDocument({data:new Uint8Array(t),isEvalSupported:!1,verbosity:0});try{i=await s.promise}catch(r){throw r.name==="PasswordException"?new v("PDF_ENCRYPTED","password-protected \u2014 decrypt and re-ingest"):new v("PDF_UNREADABLE",String(r.message??r))}try{let r=[],f=[],c=new Map,P=[],_=new Map,u=0,h=0;for(let g=1;g<=i.numPages;g++){let p=await i.getPage(g);r.push(`[page ${g}]`);let A=await p.getTextContent(),d="",E=null;for(let l of A.items){if(typeof l!="object"||l===null||!("str"in l))continue;let m=l,x=Math.round(m.transform[5]);E!==null&&x!==E&&d.trim()!==""&&(r.push(d.trimEnd()),d=""),d!==""&&!d.endsWith(" ")&&m.str!==""&&!m.str.startsWith(" ")&&x===E&&(d+=" "),d+=m.str,h+=m.str.trim().length,E=x,m.hasEOL&&d.trim()!==""&&(r.push(d.trimEnd()),d="",E=null)}d.trim()!==""&&r.push(d.trimEnd());let w=await p.getOperatorList(),I=0;for(let l=0;l<w.fnArray.length;l++){let m=w.fnArray[l]===e.OPS.paintImageXObject,x=w.fnArray[l]===e.OPS.paintInlineImageXObject;if(!m&&!x)continue;I+=1;let B=`p${g}-${I}`,y=(j,S,O,$)=>{f.push({ref:B,page:g,media_type:"image/png",...S?{blob:S}:{},...$?{appearance:$}:{},delivery:j,...O?{duplicate_of:O}:{}}),r.push(j==="duplicate"&&O?`[img#${B}: image on page ${g} \u2014 same as img#${O}; cite img#${O}]`:`[img#${B} omitted: ${j}]`)};if(x){y("unsupported-image-kind");continue}let a=await z(p,w.argsArray[l][0],o);if(!a?.data||!a.width||!a.height){y("undecodable");continue}let T;if(a.kind===e.ImageKind.RGB_24BPP)T=3;else if(a.kind===e.ImageKind.RGBA_32BPP)T=4;else{y("unsupported-image-kind");continue}let D;try{D=F(Buffer.from(a.data.buffer,a.data.byteOffset,a.data.byteLength),{width:a.width,height:a.height,channels:T})}catch{y("undecodable");continue}let b=k(D);c.set(b,D);let M=C(Buffer.from(a.data.buffer,a.data.byteOffset,a.data.byteLength),{width:a.width,height:a.height,channels:T});if(a.width<U||a.height<U){y("below-dimension-floor",b,void 0,M);continue}let L=_.get(b);if(L!==void 0){y("duplicate",b,L,M);continue}if(D.byteLength>W){y("image-too-large",b,void 0,M);continue}if(u+D.byteLength>V){y("vision-byte-budget-reached",b,void 0,M);continue}if(P.length>=J){y("image-cap-reached",b,void 0,M);continue}_.set(b,B),u+=D.byteLength,P.push(B),f.push({ref:B,page:g,media_type:"image/png",blob:b,appearance:M,delivery:"selected"}),r.push(`[img#${B}: image on page ${g}]`)}}if(h===0&&i.numPages>0)throw new v("PDF_NO_TEXT_LAYER","no extractable text \u2014 image-only or scanned pdfs are not supported yet");return{projection:r.join(`
3
+ `)+`
4
+ `,inventory:f,blobs:c,delivered:P,pages:i.numPages,converter:{name:"pdfjs-dist",version:e.version,policy:"v1"}}}finally{await s.destroy().catch(()=>{})}}export{U as a,J as b,V as c,W as d,q as e,v as f,ie as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-6NIV7AVZ.js";import{y as s}from"./chunk-6SGPN76K.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
2
+ import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-F4FXE466.js";import{y as s}from"./chunk-PXPXK4Q7.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as S}from"./chunk-6NIV7AVZ.js";import{y as o}from"./chunk-6SGPN76K.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,d=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${l} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let r=e.uploadResult?.testcaseId;u=r?`\u2713 pushed (testcase=${r})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,l=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:l},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),l=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};
2
+ import{a as S}from"./chunk-F4FXE466.js";import{y as o}from"./chunk-PXPXK4Q7.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,d=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${l} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let r=e.uploadResult?.testcaseId;u=r?`\u2713 pushed (testcase=${r})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,l=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:l},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),l=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};