@testmuai/kane-cli 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatSurface-B3ULYDYC.js +8 -0
- package/dist/{ChromeProfilePicker-AUU7JF6F.js → ChromeProfilePicker-T77E7ZSC.js} +1 -1
- package/dist/{CliFeedbackPrompt-4W74Y3UF.js → CliFeedbackPrompt-FQ2XV5DZ.js} +1 -1
- package/dist/{CliUploadProgress-6HL7WTEX.js → CliUploadProgress-TZ55LONO.js} +1 -1
- package/dist/{ConfigView-6BSCZP5Y.js → ConfigView-WWQMH36G.js} +1 -1
- package/dist/EvidenceViewOffer-L5FVBQNK.js +2 -0
- package/dist/FolderPicker-6Z3CYSHF.js +2 -0
- package/dist/{HelpView-TU7ED43J.js → HelpView-XXPCPJNF.js} +1 -1
- package/dist/{InfoBox-JLTMKVDE.js → InfoBox-SHBRHQX5.js} +1 -1
- package/dist/{LinksBox-LREUUJDV.js → LinksBox-ENNF7TDJ.js} +1 -1
- package/dist/{ProfilesView-W3GX2N2E.js → ProfilesView-CNF2FXF3.js} +1 -1
- package/dist/{ProjectPicker-SYQUJK2J.js → ProjectPicker-PVPLS642.js} +1 -1
- package/dist/{SaveSessionPrompt-MR5NJMRP.js → SaveSessionPrompt-4QP4GNGO.js} +1 -1
- package/dist/SingleShotApp-M3HNSUMZ.js +2 -0
- package/dist/{SummaryBox-UAYSVFB7.js → SummaryBox-HYNINDNN.js} +1 -1
- package/dist/TestMdRunView-ISOVQ7YP.js +2 -0
- package/dist/{WhoamiView-2YU76ASQ.js → WhoamiView-NN2HOK6H.js} +1 -1
- package/dist/app-client-ZCCNE3RV.js +2 -0
- package/dist/{app-download-AEEFQ63M.js → app-download-5UJMXPF3.js} +1 -1
- package/dist/{auth-HET3TBRI.js → auth-QKBTOWQX.js} +1 -1
- package/dist/{bind-STKXOUYI.js → bind-LVGP5KHO.js} +2 -2
- package/dist/bootstrap-RUJBMB2P.js +2 -0
- package/dist/bridge-QDPBIIOW.js +2 -0
- package/dist/{changelog-7OWRHFHZ.js → changelog-HBPBPR2O.js} +1 -1
- package/dist/{chat-controller-T2FAI55V.js → chat-controller-R4THYYPU.js} +1 -1
- package/dist/chunk-2E3ZWGIK.js +12 -0
- package/dist/{chunk-ZVHCQMJ6.js → chunk-2KH2JUGL.js} +2 -2
- package/dist/{chunk-ZIUAOEUC.js → chunk-2TYCUPCN.js} +1 -1
- package/dist/{chunk-FEJXWJ3L.js → chunk-2ZZDNPFN.js} +1 -1
- package/dist/{chunk-KFSUPQAG.js → chunk-3654GK6O.js} +43 -43
- package/dist/{chunk-RFR4ZKIC.js → chunk-3NHO5R4P.js} +2 -2
- package/dist/{chunk-3LJWYRAA.js → chunk-4II6VDXG.js} +1 -1
- package/dist/chunk-4J6DQFPC.js +4 -0
- package/dist/{chunk-SDPRO2LE.js → chunk-4U4OSOA4.js} +1 -1
- package/dist/chunk-5NIYYD7O.js +2 -0
- package/dist/{chunk-L7MXYCD7.js → chunk-5SNT2MK5.js} +1 -1
- package/dist/chunk-6J5T5FEY.js +2 -0
- package/dist/chunk-6N726QLP.js +349 -0
- package/dist/chunk-7F2ZV46B.js +2 -0
- package/dist/{chunk-BRHNRCEZ.js → chunk-7S3JZ6FQ.js} +1 -1
- package/dist/chunk-A2SQD2AY.js +4 -0
- package/dist/{chunk-AW2XUHH4.js → chunk-AJQT4IWZ.js} +1 -1
- package/dist/{chunk-6XX4LEVJ.js → chunk-AN2ZPHCE.js} +1 -1
- package/dist/{chunk-3POR47RC.js → chunk-ATGRRKEV.js} +2 -2
- package/dist/chunk-AXTPNZPX.js +2 -0
- package/dist/{chunk-RC52N7PC.js → chunk-BKVDAZEJ.js} +1 -1
- package/dist/{chunk-2WVKOZ6W.js → chunk-BPMSNGXQ.js} +1 -1
- package/dist/{chunk-UV462FZR.js → chunk-BSYX225I.js} +1 -1
- package/dist/{chunk-DZGCXKKI.js → chunk-CAMO26QU.js} +1 -1
- package/dist/chunk-ECZMYPLJ.js +19 -0
- package/dist/{chunk-65ZTD5SJ.js → chunk-FNS2EAA5.js} +2 -2
- package/dist/{chunk-7BZSCUPP.js → chunk-GNIFMQNK.js} +3 -3
- package/dist/chunk-GUVM6SZF.js +2 -0
- package/dist/{chunk-2BGUUWNF.js → chunk-HFFPPCZO.js} +2 -2
- package/dist/{chunk-T5Y6MOLM.js → chunk-HRZOFTV7.js} +1 -1
- package/dist/chunk-HWH3UYD6.js +4 -0
- package/dist/{chunk-EDSZJZFG.js → chunk-I7RQS65W.js} +1 -1
- package/dist/chunk-IUEEFGEW.js +11 -0
- package/dist/{chunk-DO5HAO3H.js → chunk-IV76ZXCY.js} +1 -1
- package/dist/{chunk-UXDL4XDL.js → chunk-IZ2FJYHG.js} +1 -1
- package/dist/{chunk-766WGMBU.js → chunk-J7KT44IC.js} +1 -1
- package/dist/{chunk-QW6EZC53.js → chunk-JEDLXUO5.js} +1 -1
- package/dist/chunk-JGOZUAMC.js +2 -0
- package/dist/{chunk-XO5ZH3ZR.js → chunk-JHKM7W5X.js} +1 -1
- package/dist/{chunk-IOFZSQAA.js → chunk-JJN76EXE.js} +1 -1
- package/dist/{chunk-YFYCCTSL.js → chunk-JUVQQP42.js} +1 -1
- package/dist/chunk-KKRNTSLL.js +6 -0
- package/dist/{chunk-IP2O264K.js → chunk-LDCLZR2U.js} +1 -1
- package/dist/chunk-LQQXPY5B.js +4 -0
- package/dist/{chunk-FMRSMN34.js → chunk-LVCY5IYI.js} +1 -1
- package/dist/{chunk-G7VQCS4J.js → chunk-LVN6VHFN.js} +1 -1
- package/dist/chunk-MMBBQ4OZ.js +2 -0
- package/dist/{chunk-QSDH5P7C.js → chunk-MTIC65NK.js} +1 -1
- package/dist/chunk-NHBYZCSX.js +4 -0
- package/dist/{chunk-GZPK6FRP.js → chunk-NRUD56FY.js} +1 -1
- package/dist/{chunk-GKYPNSQP.js → chunk-NXFAEDHV.js} +2 -2
- package/dist/{chunk-ELM6MXGJ.js → chunk-NXXJ56QA.js} +1 -1
- package/dist/{chunk-JJHG3BWO.js → chunk-O3AHFP3K.js} +1 -1
- package/dist/{chunk-FQLIW3LM.js → chunk-OAVPM6YJ.js} +1 -1
- package/dist/{chunk-QRZRSAZH.js → chunk-OJTCIZDK.js} +1 -1
- package/dist/{chunk-YJELGSKJ.js → chunk-OOEPLMKA.js} +1 -1
- package/dist/{chunk-6O3DDOP2.js → chunk-PXCMEI73.js} +1 -1
- package/dist/{chunk-C7HSWZP6.js → chunk-R4UCBA5R.js} +1 -1
- package/dist/chunk-RKXHVP2Z.js +2 -0
- package/dist/{chunk-KU6IXFGZ.js → chunk-RN4PKQFR.js} +1 -1
- package/dist/chunk-RUCSRS4C.js +5 -0
- package/dist/chunk-TAOHYWEO.js +2 -0
- package/dist/{chunk-TFPPEOAK.js → chunk-U5GHOGLM.js} +1 -1
- package/dist/chunk-UJZZDPDY.js +2 -0
- package/dist/{chunk-EWCAFKLX.js → chunk-UODLRQQ4.js} +1 -1
- package/dist/chunk-VK3NU742.js +21 -0
- package/dist/{chunk-DCY6R5DP.js → chunk-VPRNGWIY.js} +1 -1
- package/dist/{chunk-NX7TM662.js → chunk-WOEQDUJ6.js} +1 -1
- package/dist/{chunk-OMQCD3KR.js → chunk-WQPQNL4S.js} +1 -1
- package/dist/{chunk-HMYMSRA4.js → chunk-WV27D55O.js} +1 -1
- package/dist/{chunk-GCBKDX2J.js → chunk-WVCH66YH.js} +1 -1
- package/dist/{chunk-7JWKHKFU.js → chunk-YCLG3T5E.js} +1 -1
- package/dist/chunk-YGMC3FGJ.js +26 -0
- package/dist/{chunk-TKGUT425.js → chunk-YHYTCENI.js} +1 -1
- package/dist/{chunk-UDIQOJEL.js → chunk-YSSYT5F5.js} +1 -1
- package/dist/{chunk-OTTGS2TE.js → chunk-YTDSQAYN.js} +1 -1
- package/dist/{chunk-HCKH44I2.js → chunk-ZEDAPY7M.js} +1 -1
- package/dist/chunk-ZI6UIJUN.js +11 -0
- package/dist/{config-RS47F5SC.js → config-RLDXM5ZH.js} +1 -1
- package/dist/{credentials-OH6AVI6N.js → credentials-CALNKQMN.js} +1 -1
- package/dist/deps-bundle-GVHIMZ5E.js +2 -0
- package/dist/{deps-resolve-XC5S53DG.js → deps-resolve-T6P4EACP.js} +1 -1
- package/dist/{dispatch-SE5GY3Z2.js → dispatch-ECUEAMXS.js} +1 -1
- package/dist/doctor-SIBHJVGC.js +2 -0
- package/dist/evidence-ZVQHPELX.js +2 -0
- package/dist/evolve-cmd-JGCFTXWA.js +2 -0
- package/dist/extract-bind-EXW32RUY.js +10 -0
- package/dist/{extract-cmd-UZMEZMGP.js → extract-cmd-7IOLJJCL.js} +1 -1
- package/dist/gaps-cmd-WPCJPLGB.js +3 -0
- package/dist/{generate-headless-D3SVQ2AI.js → generate-headless-U4GTG234.js} +2 -2
- package/dist/index.js +61 -60
- package/dist/{ingest-cmd-EAE7N5RC.js → ingest-cmd-YYNAKI2U.js} +1 -1
- package/dist/interactive-bind-Y65XV4Y5.js +25 -0
- package/dist/{list-commands-MRXL5HGS.js → list-commands-3EROWJWV.js} +1 -1
- package/dist/login-flow-TRINUSBB.js +2 -0
- package/dist/mobile-prompts-TP3ODM5M.js +2 -0
- package/dist/{persist-recorded-session-TLDQ5HKP.js → persist-recorded-session-EHYT3PVN.js} +1 -1
- package/dist/{phase-seed-VFHIH6FL.js → phase-seed-DIRETNU6.js} +1 -1
- package/dist/{pipeline-UOM4LNAI.js → pipeline-5GOS2KV2.js} +1 -1
- package/dist/prepare-target-BUEOZVJV.js +2 -0
- package/dist/reconcile-cmd-TY3MWZL3.js +2 -0
- package/dist/reconcile-deps-6KTJHBMJ.js +4 -0
- package/dist/reconcile-engine-O7QEZVX6.js +2 -0
- package/dist/{recording-banner-4M7XHVGI.js → recording-banner-BWWFOJCR.js} +1 -1
- package/dist/registry-KXEDLM6X.js +2 -0
- package/dist/{require-project-folder-4UPQNEBJ.js → require-project-folder-CXDRRWEQ.js} +1 -1
- package/dist/resolve-run-intent-PZXEQTHC.js +7 -0
- package/dist/{resolver-UBOZLFFE.js → resolver-FTU5KO7H.js} +1 -1
- package/dist/{run-URPGHOQM.js → run-CMFBSYWF.js} +1 -1
- package/dist/run-WKHPVWUN.js +2 -0
- package/dist/{run-test-md-76ZPKXO6.js → run-test-md-7HGOZJSU.js} +2 -2
- package/dist/session-items-2ATN7VXG.js +2 -0
- package/dist/{skill-installer-CIS6GAYF.js → skill-installer-QNUDLGPD.js} +1 -1
- package/dist/{spawner-J67QR4QP.js → spawner-DQZRJIE6.js} +1 -1
- package/dist/tcg-generate-XKSTMCOG.js +2 -0
- package/dist/{testmd-actions-77ELR5UU.js → testmd-actions-IFRW7NGG.js} +1 -1
- package/dist/{tms-client-VD3B3SMU.js → tms-client-V3TR4QW3.js} +1 -1
- package/dist/token-refresh-FP6JFLXB.js +2 -0
- package/dist/{validate-basic-2GVSQ2R5.js → validate-basic-3CNUDDH7.js} +1 -1
- package/dist/{verdicts-TRSTJLCL.js → verdicts-NYCSBWUC.js} +1 -1
- package/dist/{version-check-O6PYTI4T.js → version-check-7TSAVA6V.js} +1 -1
- package/dist/walk-session-AINBHZKB.js +2 -0
- package/dist/with-telemetry-3DL7ZEZL.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-U37VZDCW.js +0 -8
- package/dist/EvidenceViewOffer-62XHEEGW.js +0 -2
- package/dist/FolderPicker-S7U2EN2M.js +0 -2
- package/dist/SingleShotApp-XOKVOM7C.js +0 -2
- package/dist/TestMdRunView-7UVSDAF4.js +0 -2
- package/dist/app-client-OEXESV4U.js +0 -2
- package/dist/bootstrap-44YKVWWE.js +0 -2
- package/dist/bridge-5Z3BIB77.js +0 -2
- package/dist/chunk-27U4PLPX.js +0 -2
- package/dist/chunk-2KDGIZED.js +0 -4
- package/dist/chunk-3PECJD6S.js +0 -11
- package/dist/chunk-7Q6M6P4X.js +0 -26
- package/dist/chunk-CTW2VQKS.js +0 -6
- package/dist/chunk-FNH55WSR.js +0 -19
- package/dist/chunk-GPG3FIN3.js +0 -21
- package/dist/chunk-HEAIJCGZ.js +0 -2
- package/dist/chunk-KCCSWEGA.js +0 -4
- package/dist/chunk-MA34UWKX.js +0 -4
- package/dist/chunk-MBF3FP5P.js +0 -5
- package/dist/chunk-MXHHMIO2.js +0 -349
- package/dist/chunk-QGKPLOUI.js +0 -2
- package/dist/chunk-RLRNLIRS.js +0 -2
- package/dist/chunk-TYLYFERW.js +0 -10
- package/dist/chunk-V2R3LCA3.js +0 -12
- package/dist/chunk-VGFTNLQQ.js +0 -2
- package/dist/chunk-W2JFDDIB.js +0 -2
- package/dist/chunk-YRFMPIU2.js +0 -4
- package/dist/doctor-FSECFZUU.js +0 -2
- package/dist/evidence-OYPHZUKI.js +0 -2
- package/dist/evolve-cmd-BCPNXAMV.js +0 -2
- package/dist/extract-bind-LLEASZAK.js +0 -10
- package/dist/gaps-cmd-IVXFPFAQ.js +0 -3
- package/dist/interactive-bind-ORMN2REX.js +0 -25
- package/dist/login-flow-QJQM3RHT.js +0 -2
- package/dist/mobile-prompts-TOX35ER6.js +0 -2
- package/dist/prepare-target-QYWIJIVQ.js +0 -2
- package/dist/reconcile-cmd-3H34KVVD.js +0 -2
- package/dist/reconcile-deps-XIH75ZLY.js +0 -4
- package/dist/reconcile-engine-UKWPG2LV.js +0 -2
- package/dist/registry-PYOTKZYZ.js +0 -2
- package/dist/resolve-run-intent-X72V3KJA.js +0 -7
- package/dist/run-2COODVX2.js +0 -2
- package/dist/tcg-generate-BDTRKY2A.js +0 -2
- package/dist/token-refresh-4BPAPXKK.js +0 -2
- package/dist/walk-session-CHJXHZMO.js +0 -2
- package/dist/with-telemetry-CQCWLVOC.js +0 -2
- /package/dist/{lifecycle-cmd-O2324GN6.js → lifecycle-cmd-HO5VL7AM.js} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as wn,b as me,c as It,d as $n,e as Dt,g as rt,h as it,i as Cn,j as Rn,l as Sn,m as Bt,n as In}from"./chunk-5NIYYD7O.js";import{a as le,b as Oe,c as vn}from"./chunk-6J5T5FEY.js";import{b as Rt}from"./chunk-UJZZDPDY.js";import{a as yn}from"./chunk-CLGC7VEO.js";import{a as tt}from"./chunk-LQQXPY5B.js";import{a as nt,d as _e,e as Tn,f as St}from"./chunk-RKXHVP2Z.js";import{a as xn,b as kn,c as bn}from"./chunk-AXTPNZPX.js";import"./chunk-L2TV4G56.js";import"./chunk-6KPPGMO2.js";import{a as gn,b as hn,c as pn}from"./chunk-4II6VDXG.js";import"./chunk-NVGBE2DR.js";import{a as dn}from"./chunk-5Y2G4NC7.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import{a as et}from"./chunk-YCCUBQY4.js";import{a as mn}from"./chunk-2ZZDNPFN.js";import{y as r}from"./chunk-7F2ZV46B.js";import{b as fn}from"./chunk-DFS4RMVP.js";import{a as Q}from"./chunk-HCBYKLMW.js";import{a as k,b as n,k as Ze}from"./chunk-C44QQJR4.js";import{a as Mr}from"./chunk-6YGTRKDT.js";import{e as V}from"./chunk-UR6MHSHU.js";var m=V(Mr(),1);var a=V(Q(),1),Ar=60,Lr=100;function Et(t,o){let l=t.options.length,u=l,g=t.multi_select?u++:null,x=t.allow_free_text?u++:null,f=o?u++:null;return{optionCount:l,doneIdx:g,freeIdx:x,batchIdx:f,maxSel:u-1}}var Or="\xA0",_r={high:{text:`\u203C${Or}high`,color:r.red},med:{text:"med",color:"yellow"},low:{text:"low",color:r.dim}};function Pr(t){let o=(t.header??t.text.split(/\s+/).slice(0,3).join(" ")).trim();return o.length>16?`${o.slice(0,15)}\u2026`:o}function qr(t,o,l){let u=p=>t[p].length+6,g=u(o),x=o,f=o;for(;;){let p=f+1<t.length?u(f+1):1/0,C=x-1>=0?u(x-1):1/0;if(p===1/0&&C===1/0)break;if(p<=C){if(g+p>l)break;g+=p,f+=1}else{if(g+C>l)break;g+=C,x-=1}}return{lo:x,hi:f}}function Dn({batch:t,qView:o,sel:l=0,focused:u=!1,freeText:g=null,optionText:x=null,attach:f=null,multiSelFor:p,childPrefix:C}){let{stdout:M}=Ze(),v=M?.columns??80,T=v<Ar,W=Math.min(v-1,Lr),$=Math.max(0,Math.min(t.questions.length-1,o??(t.cursor<0?0:t.cursor))),I=t.questions[$],N=t.resolution[$],L=t.resolution.filter(D=>!D).length,B=t.questions.length-L,P=tt(t),O=Et(I,P!==""),H=p?p($):[],K=_r[I.risk],re=D=>u&&l===D?(0,a.jsx)(n,{color:r.assuranceAccent,children:"\u276F"}):" ",S=`? ${C??""}the agent needs ${L===1?"one answer":`${L} answers`}`,$e=t.questions.length>1?` \xB7 ${$+1} of ${t.questions.length} \xB7 ${B} answered`:"",z=(0,a.jsxs)(k,{flexDirection:"column",children:[(0,a.jsx)(k,{paddingLeft:2,children:(0,a.jsxs)(n,{bold:!0,children:[I.text,K?(0,a.jsx)(n,{color:K.color,bold:!1,children:` ${K.text}`}):null]})}),(0,a.jsx)(k,{paddingLeft:2,children:(0,a.jsx)(n,{color:r.dim,children:I.rationale})}),(0,a.jsx)(n,{children:" "}),I.options.map((D,w)=>{let X=u&&l===w;return x&&x.optionIndex===w?(0,a.jsx)(k,{flexDirection:"column",children:(0,a.jsxs)(k,{children:[(0,a.jsxs)(n,{children:[(0,a.jsx)(n,{color:r.assuranceAccent,children:"\u276F"})," ",(0,a.jsx)(n,{color:r.assuranceAccent,children:`${w+1}. ${D.label}`}),(0,a.jsx)(n,{color:r.dim,children:" \u270E "})]}),(0,a.jsx)(et,{value:x.value,onChange:x.onChange,onSubmit:x.onSubmit,onCancel:x.onCancel,placeholder:D.detail||"type your answer"})]})},`o-${w}`):(0,a.jsxs)(k,{flexDirection:"column",children:[(0,a.jsxs)(n,{children:[re(w)," ",I.multi_select?(0,a.jsx)(n,{color:H.includes(w)?r.green:r.dim,children:H.includes(w)?"[x] ":"[ ] "}):null,(0,a.jsx)(n,{color:X?r.assuranceAccent:void 0,children:`${w+1}. ${D.label}`}),w===I.recommended_index?(0,a.jsx)(n,{color:r.dim,children:" (recommended)"}):null,N?.selected_index===w?(0,a.jsx)(n,{color:r.dim,children:" (current)"}):null]}),D.detail?(0,a.jsx)(k,{paddingLeft:5,children:(0,a.jsx)(n,{color:r.dim,children:D.detail})}):null]},`o-${w}`)}),I.multi_select&&O.doneIdx!=null?(0,a.jsxs)(n,{children:[re(O.doneIdx)," ",(0,a.jsx)(n,{color:r.green,children:"\u2714"}),(0,a.jsx)(n,{color:u&&l===O.doneIdx?r.assuranceAccent:void 0,children:" done \u2014 confirm selection"})]}):null,I.allow_free_text?(0,a.jsx)(n,{children:" "}):null,I.allow_free_text?g?(0,a.jsxs)(k,{children:[(0,a.jsxs)(n,{children:[(0,a.jsx)(n,{color:r.assuranceAccent,children:"\u276F"})," ",(0,a.jsx)(n,{color:r.dim,children:"\u270E "})]}),(0,a.jsx)(et,{value:g.value,onChange:g.onChange,onSubmit:g.onSubmit,onCancel:g.onCancel,placeholder:"Tell me what to do"})]}):(0,a.jsxs)(n,{children:[O.freeIdx!=null?re(O.freeIdx):" "," ",(0,a.jsx)(n,{color:u&&O.freeIdx!=null&&l===O.freeIdx?r.assuranceAccent:r.dim,children:"\u270E Tell me what to do"})]}):null,f?(0,a.jsxs)(k,{flexDirection:"column",marginTop:1,children:[(0,a.jsxs)(k,{children:[(0,a.jsxs)(n,{children:[(0,a.jsx)(n,{color:r.assuranceAccent,children:"\u276F"})," ",(0,a.jsx)(n,{color:r.assuranceAccent,children:"@ attach a file or URL"}),(0,a.jsx)(n,{color:r.dim,children:" \u270E "})]}),(0,a.jsx)(et,{value:f.value,onChange:f.onChange,onSubmit:f.onSubmit,onCancel:f.onCancel,placeholder:"path or URL"})]}),(0,a.jsx)(k,{paddingLeft:2,children:(0,a.jsx)(n,{color:r.dim,children:"the questions are set aside \u2014 the agent reads the source and re-asks what's still open"})})]}):null]}),j=P!==""?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n,{children:" "}),(0,a.jsxs)(n,{children:[u&&O.batchIdx!=null&&l===O.batchIdx?(0,a.jsx)(n,{color:r.assuranceAccent,children:"\u276F"}):" "," ",(0,a.jsx)(n,{color:r.assuranceAccent,children:"\xBB"}),(0,a.jsx)(n,{bold:!0,color:u&&O.batchIdx!=null&&l===O.batchIdx?r.assuranceAccent:void 0,children:" Go with recommendations"}),L>=5?(0,a.jsx)(n,{color:r.dim,children:` \u2014 resolves all ${L} open`}):null,(0,a.jsx)(n,{color:r.dim,children:" (tab)"})]})]}):null;if(T)return(0,a.jsxs)(k,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,a.jsx)(n,{color:r.assuranceAccent,bold:!0,children:S}),t.questions.length>1?(0,a.jsx)(n,{color:r.dim,children:$e.replace(/^ · /,"")}):null,(0,a.jsx)(n,{children:" "}),z,j]});let h=t.questions.map(D=>Pr(D)),ce=t.questions.length>1?qr(h,$,W-8):null;return(0,a.jsxs)(k,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,a.jsxs)(n,{color:r.assuranceAccent,children:[(0,a.jsx)(n,{bold:!0,children:S}),$e?(0,a.jsx)(n,{color:r.dim,children:$e}):null]}),ce?(0,a.jsx)(k,{marginTop:1,children:(0,a.jsxs)(n,{children:[ce.lo>0?(0,a.jsx)(n,{color:r.dim,children:"\u25C0 "}):" ",t.questions.slice(ce.lo,ce.hi+1).map((D,w)=>{let X=ce.lo+w,Pe=w>0?" ":"";return X===$?(0,a.jsxs)(n,{children:[Pe,(0,a.jsx)(n,{backgroundColor:r.assuranceAccent,color:"#0d1117",bold:!0,children:` ${h[X]} `})]},D.id):(0,a.jsxs)(n,{children:[Pe,t.resolution[X]?(0,a.jsxs)(n,{children:[(0,a.jsx)(n,{color:r.green,children:"\u2713 "}),(0,a.jsx)(n,{color:r.dim,children:h[X]})]}):(0,a.jsx)(n,{color:r.dim,children:`\u25CB ${h[X]}`})]},D.id)}),ce.hi<t.questions.length-1?(0,a.jsx)(n,{color:r.dim,children:" \u25B6"}):null]})}):null,(0,a.jsx)(n,{children:" "}),z,j]})}var A=V(Q(),1),Bn={high:0,med:1,low:2},jr={high:r.red,med:"yellow",low:r.dim};function Fr(t){return t.map((o,l)=>({r:o,i:l})).sort((o,l)=>(Bn[o.r.risk??"zz"]??3)-(Bn[l.r.risk??"zz"]??3)||o.i-l.i).map(({r:o})=>o)}function En({rows:t,width:o=120,badgeHeader:l="risk"}){if(t.length===0)return null;let u=Fr(t),g=B=>B.staged||!B.id?"(staged)":yn(B.id),x=Math.max(2,...u.map(B=>g(B).length)),f=Math.max(l.length,...u.map(B=>(B.badge??"").length)),p=o>=84&&u.some(B=>B.summary),M=o-(p?13:10)-x-f,v=Math.max(...u.map(B=>Math.max(B.title.length,(B.marker??"").length)),5),T=Math.max(5,p?Math.min(v,Math.max(16,Math.floor(M*.5))):Math.min(v,M)),W=p?Math.max(7,M-T):0,$=(B,P,O,H)=>vn(B,P,O,H.map(K=>K.length)),I=(B,P,O,H)=>[Oe(le(B,x),x),Oe(le(P,T),T),Oe(le(O,f),f),...p?[Oe(le(H,W),W)]:[]],N=I("id","title",l,"summary"),L=[];L.push((0,A.jsx)(n,{color:r.dim,children:$("\u250C","\u252C","\u2510",N)},"t")),L.push((0,A.jsxs)(n,{children:[N.map((B,P)=>(0,A.jsxs)(n,{children:[(0,A.jsx)(n,{color:r.dim,children:P===0?"\u2502 ":" \u2502 "}),(0,A.jsx)(n,{bold:!0,children:B})]},P)),(0,A.jsx)(n,{color:r.dim,children:" \u2502"})]},"h")),L.push((0,A.jsx)(n,{color:r.dim,children:$("\u251C","\u253C","\u2524",N)},"m"));for(let[B,P]of u.entries()){let O=I(g(P),le(P.title,T),le(P.badge??"",f),le(P.summary??"",W)),H=P.badgeColor??jr[P.badge??""]??r.dim;if(L.push((0,A.jsxs)(n,{children:[(0,A.jsx)(n,{color:r.dim,children:"\u2502 "}),(0,A.jsx)(n,{color:r.assuranceAccent,children:O[0]}),(0,A.jsx)(n,{color:r.dim,children:" \u2502 "}),O[1],(0,A.jsx)(n,{color:r.dim,children:" \u2502 "}),(0,A.jsx)(n,{color:H,children:O[2]}),p?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(n,{color:r.dim,children:" \u2502 "}),O[3]]}):null,(0,A.jsx)(n,{color:r.dim,children:" \u2502"})]},`r-${B}`)),P.marker){let K=I("",le(P.marker,T),"","");L.push((0,A.jsx)(n,{color:r.dim,children:`\u2502 ${K.join(" \u2502 ")} \u2502`},`mk-${B}`))}}return L.push((0,A.jsx)(n,{color:r.dim,children:$("\u2514","\u2534","\u2518",N)},"b")),(0,A.jsx)(A.Fragment,{children:L})}var y=V(Q(),1);function Wr(t){let o=t.form==="assumed"?" (assumed)":t.form==="deferred"?"":" (you)",l=t.note?` \u2014 ${t.note}`:"";return t.form==="deferred"?`\u21B3 deferred q${t.qNum} ${t.stub}${l}`:t.form==="changed"?`\u21B3 changed q${t.qNum} ${t.stub}: ${t.prev??"?"} \u2192 ${t.choice??"?"}${o}${l}`:`\u21B3 ${t.form} q${t.qNum} ${t.stub}: ${t.choice??"?"}${o}${l}`}var Vr=()=>(process.stdout?.columns??100)-12;function Mn({block:t,annotations:o}){let l=t.era??0,u=Nr(t,o??null);return l>0?(0,y.jsx)(k,{marginLeft:l*2,children:u}):u}function Nr(t,o){switch(t.kind){case"banner":return(0,y.jsx)(k,{marginTop:1,children:(0,y.jsx)(n,{bold:!0,color:r.assuranceAccent,children:` ${t.text}`})});case"user":return(0,y.jsxs)(k,{marginTop:1,children:[(0,y.jsx)(n,{color:r.orange,children:"\u276F "}),(0,y.jsx)(n,{children:t.text})]});case"note":return(0,y.jsx)(n,{color:r.dim,children:` ${t.text}`});case"agent":return(0,y.jsx)(k,{marginTop:1,children:(0,y.jsx)(hn,{text:t.text,accent:r.assuranceAccent})});case"worked":return(0,y.jsx)(k,{marginTop:1,children:(0,y.jsx)(n,{color:r.dim,children:` \u2699 ${bn(t.durS,t.toolCalls,t.tools)}`})});case"usage":return(0,y.jsx)(n,{color:r.dim,children:` \xB7 ${t.credits.toFixed(1)} credits \u2014 total ${t.total.toFixed(1)}`});case"turn":{let l=o,u=l?l.fresh:t.items.map((v,T)=>({item:v,num:T+1,updated:!1})),g={usecase:"risk","use-case":"risk",ac:"check",scenario:"kind",test:"check",gap:"severity",stylenote:"kind"},x=v=>v.kind??"use-case",f=new Map;for(let v of u){let T=v.item,W=x(v.item),$=T.risk==="high"||T.risk==="med"||T.risk==="low"?T.risk:void 0,I={id:T.logical_id??"",staged:!T.logical_id,title:T.title,badge:T.badge??T.risk??"",summary:T.why??T.summary??T.description??"",...$?{risk:$}:{},...v.updated?{marker:"\u21B3 changed"}:{}},N=f.get(W)??[];N.push(I),f.set(W,N)}let p=u.some(v=>!!v.item.kind),C=(l?.unchanged??[]).reduce((v,T)=>v+T.count,0),M=l?.headerStats?` \u2014 ${l.headerStats}${C>0?` (${C} unchanged)`:""}`:"";return(0,y.jsxs)(k,{flexDirection:"column",marginLeft:2,children:[(0,y.jsxs)(n,{bold:!0,children:[p?"design":t.heading,M?(0,y.jsx)(n,{bold:!1,color:r.dim,children:M}):null]}),[...f.entries()].map(([v,T])=>(0,y.jsxs)(k,{flexDirection:"column",children:[f.size>1?(0,y.jsx)(n,{color:r.dim,children:`${nt(v)} \xB7 ${T.length}`}):null,(0,y.jsx)(En,{rows:T,width:Vr(),badgeHeader:g[v]??"info"})]},v)),l&&l.unchanged.length>0&&(0,y.jsx)(n,{color:r.dim,children:` \u22EE unchanged: ${l.unchanged.map(v=>`${v.count} ${v.label}`).join(" \xB7 ")}`})]})}case"answer":return(0,y.jsx)(n,{color:r.dim,children:Wr(t.receipt)});case"continued":return(0,y.jsx)(n,{color:r.dim,children:"\u21B3 continued"});case"childOpen":{let{ing:l}=Rt(t.verb);return(0,y.jsx)(k,{marginTop:1,children:(0,y.jsxs)(n,{color:r.assuranceAccent,children:[`\u25CF ${l} ${t.subject}`,t.sid?(0,y.jsx)(n,{color:r.dim,children:` \u2014 ${t.sid}`}):null,t.note?(0,y.jsx)(n,{color:r.dim,children:` ${t.note}`}):null]})})}case"childClose":{let{ed:l}=Rt(t.verb);if(!t.ok)return(0,y.jsxs)(n,{color:r.red,children:[`\u25CF ${t.verb} failed \u2014 ${t.exitCode!=null?`exited ${t.exitCode}`:"error"}`,t.fixCmd?(0,y.jsx)(n,{color:r.dim,children:` \xB7 ${t.fixCmd}`}):null]});let u=[kn(t.durS),...t.results?[t.results]:[],...t.credits!==void 0?[`${t.credits.toFixed(1)} credits`]:[]].join(" \xB7 ");return(0,y.jsx)(n,{color:r.green,children:`\u25CF ${l} ${t.subject} \u2014 ${u}`})}case"childBack":return(0,y.jsx)(n,{color:r.dim,children:`back with ${t.parentVerb} \u2014 ${t.context}`});case"commit":return(0,y.jsxs)(k,{flexDirection:"column",children:[(0,y.jsx)(n,{color:t.ok?r.green:r.red,children:` ${t.ok?"\u2714":"\u2717"} ${t.line}`}),(t.warnings??[]).map((l,u)=>(0,y.jsx)(n,{color:r.dim,children:` \u26A0 ${l}`},`w-${u}`))]});case"error":return(0,y.jsxs)(mn,{variant:"error",paddingX:1,children:[(0,y.jsx)(n,{color:r.red,children:t.title}),t.detail.map((l,u)=>(0,y.jsx)(n,{color:r.dim,children:l},`d-${u}`))]})}}var Te=V(Q(),1);function An({item:t}){return(0,Te.jsxs)(k,{flexDirection:"column",marginLeft:2,children:[(t.cite??[]).map((o,l)=>(0,Te.jsx)(n,{dimColor:!0,children:`cite ${o.anchor??"conv"} \u2014 "${o.quote??""}"`},`cite-${l}`)),(t.depends_on_hint??[]).length>0&&(0,Te.jsx)(n,{dimColor:!0,children:`depends on: ${(t.depends_on_hint??[]).join(", ")}`}),Object.entries(t.extra??{}).map(([o,l])=>(0,Te.jsx)(n,{dimColor:!0,children:`${o}: ${l}`},`extra-${o}`))]})}var R=V(Q(),1),Mt=(t,o)=>Math.max(0,Math.min(o,t));function ot(t,o,l){switch(o.type){case"move":return t.level==="detail"?{...t,scroll:Math.max(0,(t.scroll??0)+o.delta)}:{...t,cursor:Mt(t.cursor+o.delta,Math.max(0,l-1))};case"enter":return t.level==="list"?{...t,level:"detail",scroll:0}:t;case"back":return t.level==="detail"?{...t,level:"list",scroll:0}:null}}var On={"use-case":"use-cases",ac:"acs",scenario:"scenarios",test:"tests",gap:"gaps"};function _n(t,o){if(t.level==="detail")return{level:"detail",cursor:Mt(t.num-1,Math.max(0,o.entries.length-1))};if(t.section){let l=o.entries.findIndex(u=>On[u.kind]===t.section);if(l>=0)return{level:"list",cursor:l}}return{level:"list",cursor:0}}function Kr(t){let o=[];for(let l of t.entries){let u=o.find(g=>g.kind===l.kind);u?u.entries.push(l):o.push({kind:l.kind,entries:[l]})}return o}var Ln=3;function Ur({items:t,cursor:o,verb:l,more:u}){let g=`view \xB7 ${l} so far \xB7 ${t.counts.map(f=>`${f.count} ${f.count===1?f.label.replace(/s$/,""):f.label}`).join(" \xB7 ")}`,x=t.entries[o];return(0,R.jsxs)(k,{flexDirection:"column",children:[(0,R.jsx)(n,{bold:!0,color:r.assuranceAccent,children:g}),Kr(t).map(({kind:f,entries:p})=>{let C=x?.kind===f,M=C?p.findIndex($=>$.ref===x.ref):-1,v=C?Mt(M-1,Math.max(0,p.length-Ln)):0,T=p.slice(v,v+(C?Ln:1)),W=p.length-T.length;return(0,R.jsxs)(k,{flexDirection:"column",children:[(0,R.jsx)(n,{color:r.dim,children:`${On[f]??nt(f)} \xB7 ${p.length}`}),T.map($=>{let I=C&&$.ref===x.ref,N=$.item.badge;return(0,R.jsxs)(n,{children:[(0,R.jsx)(n,{color:r.assuranceAccent,children:I?"\u203A ":" "}),(0,R.jsx)(n,{children:`${$.num} \xB7 ${$.item.title}`}),N?(0,R.jsx)(n,{color:r.dim,children:` \xB7 ${N}`}):null]},`${$.kind}:${$.ref}`)}),W>0&&(0,R.jsx)(n,{color:r.dim,children:` \u22EE ${W} more`})]},f)}),u?(0,R.jsxs)(n,{children:[(0,R.jsx)(n,{color:r.assuranceAccent,children:o===t.entries.length?"\u203A ":" "}),(0,R.jsx)(n,{color:r.dim,children:`\u22EF show all \u2014 ${u.hidden} more from earlier turns`})]}):null]})}var st=14;function Qr({items:t,cursor:o,explain:l,grandTotal:u,dossier:g,scroll:x=0}){let f=t.entries[o];if(!f)return(0,R.jsx)(n,{color:r.dim,children:"nothing to show"});if(g){let C=Math.max(0,Math.min(x,Math.max(0,g.lines.length-st))),M=g.lines.slice(C,C+st);return(0,R.jsxs)(k,{flexDirection:"column",children:[(0,R.jsxs)(n,{bold:!0,children:[`view \xB7 ${g.id}`,g.id.toLowerCase()!==g.rawId?(0,R.jsx)(n,{bold:!1,color:r.dim,children:` \xB7 ${g.rawId}`}):null]}),(0,R.jsx)(n,{bold:!0,children:g.title}),C>0?(0,R.jsx)(n,{color:r.muted,children:`\u22EE ${C} above`}):null,M.map((v,T)=>(0,R.jsx)(n,{color:v.dim?r.dim:void 0,children:v.text},`dl-${T}`)),g.lines.length>C+st?(0,R.jsx)(n,{color:r.muted,children:`\u22EE ${g.lines.length-C-st} more`}):null]})}let p=f.item;return(0,R.jsxs)(k,{flexDirection:"column",children:[(0,R.jsx)(n,{bold:!0,children:`view \xB7 ${f.kind} ${f.num} of ${u??t.entries.length}`}),(0,R.jsx)(n,{children:f.item.title}),p.badge?(0,R.jsx)(n,{color:r.dim,children:`kind: ${p.badge}`}):null,p.why?(0,R.jsx)(n,{color:r.dim,children:p.why}):null,(0,R.jsx)(An,{item:f.item}),l?.map((C,M)=>(0,R.jsx)(n,{color:r.dim,children:C},`ex-${M}`)),(0,R.jsx)(n,{color:r.dim,children:"view-only \u2014 approvals happen in chat"})]})}function Pn({items:t,state:o,verb:l,more:u,explain:g,grandTotal:x,dossier:f=null}){return o.level==="list"?(0,R.jsx)(Ur,{items:t,cursor:o.cursor,verb:l,more:u}):(0,R.jsx)(Qr,{items:t,cursor:o.cursor,explain:g,grandTotal:x,dossier:f,scroll:o.scroll??0})}var J=V(Q(),1),At=14;function Hr(t){let o=[],l=null;for(let u of t)u.field!==l&&(l=u.field,o.push({kind:"field",field:l})),o.push({kind:"line",field:l,line:u});return o}function qn({title:t,lines:o,offset:l=0}){let u=Hr(o),g=Math.max(0,Math.min(l,Math.max(0,u.length-At))),x=u.slice(g,g+At),f=g,p=Math.max(0,u.length-g-At),C=`view \xB7 diff \xB7 ${t} \xB7 current \u2192 proposed`;return(0,J.jsxs)(k,{flexDirection:"column",children:[(0,J.jsx)(n,{bold:!0,color:r.assuranceAccent,children:C}),f>0?(0,J.jsx)(k,{paddingLeft:2,children:(0,J.jsx)(n,{color:r.dim,children:`\u22EE ${f} above`})}):null,x.map((M,v)=>M.kind==="field"?(0,J.jsx)(k,{paddingLeft:2,children:(0,J.jsx)(n,{color:r.dim,children:M.field==="criteria"?"criteria":M.field})},`r-${g+v}`):(0,J.jsx)(k,{paddingLeft:4,children:(0,J.jsx)(n,{color:M.line.op==="-"?"red":"green",children:`${M.line.op==="-"?"\u2212":"+"} ${M.line.text}`})},`r-${g+v}`)),p>0?(0,J.jsx)(k,{paddingLeft:2,children:(0,J.jsx)(n,{color:r.dim,children:`\u22EE ${p} more`})}):null]})}var zr={"use-cases":"use-cases",usecases:"use-cases","use-case":"use-cases",acs:"acs",ac:"acs",scenarios:"scenarios",scenario:"scenarios",tests:"tests",test:"tests",gaps:"gaps",gap:"gaps"};function jn(t){let o=(t??"").trim().toLowerCase();if(!o)return{level:"list"};if(/^\d+$/.test(o)){let u=parseInt(o,10);return u>=1?{level:"detail",num:u}:{error:"items are numbered from 1 \u2014 /view 1"}}let l=zr[o];return l?{level:"list",section:l}:{error:"try /view, /view <number>, or /view acs|scenarios|tests"}}var E=V(Q(),1),Xr=6,Fn=12;function Gr(t,o,l){let u=Math.max(20,o),g=[];for(let f of t.split(`
|
|
3
|
+
`)){if(f.length<=u){g.push(f);continue}let p="";for(let C of f.split(" "))p&&p.length+1+C.length>u?(g.push(p),p=C):p=p?`${p} ${C}`:C;g.push(p)}let x=Math.max(0,g.length-l);return{body:g.slice(-l).join(`
|
|
4
|
+
`),hidden:x}}function Wn(t){let o={key:"redesign",label:"re-design from scratch",detail:"replaces the current design"},l={key:"keep",label:"keep the existing design",detail:"back to the list"};return t.designed==="stale"?[{...o,detail:"the use-case changed since it was designed"},l]:[l,o]}function Xi({controller:t,verb:o="extract",onCtrlC:l,chain:u=null,inspect:g=null,reconcile:x=null,autoReview:f=!1,onReviewExit:p,meta:C=null}){let[,M]=(0,m.useState)(0),[v,T]=(0,m.useState)(!1),[W,$]=(0,m.useState)(null),[I,N]=(0,m.useState)(null),L=(0,m.useRef)(null),[B,P]=(0,m.useState)(null),O=(0,m.useRef)(null),H=e=>{O.current=e,P(e)},K=e=>{L.current=e,N(e),e===null&&H(null)},re=(0,m.useRef)([]),[S,$e]=(0,m.useState)(null),z=(0,m.useRef)(null),j=e=>{z.current=e,$e(e)},[h,ce]=(0,m.useState)(null),D=(0,m.useRef)(null),w=e=>{D.current=e,ce(e)},[X,Pe]=(0,m.useState)(null),Lt=(0,m.useRef)(null),he=e=>{Lt.current=e,Pe(e)},lt=(0,m.useRef)({approved:0,rejected:0,deferred:0}),Ce=(0,m.useRef)(!1),ae=(0,m.useRef)(null),Ot=fn(),{stdout:Vn}=Ze(),Nn=Vn?.columns??80,_t=(0,m.useRef)(0),ct=(0,m.useRef)(0);(0,m.useEffect)(()=>{let e=()=>{let i=t.state.ledger;for(let c=_t.current;c<i.length;c++){let d=i[c],b=d.kind==="turn"?Tn(t.state.turns,d.turnIndex):void 0;Ot.append((0,E.jsx)(Mn,{block:d,annotations:b},`lg-${c}`))}_t.current=i.length};e();let s=t.subscribe(()=>{e();let i=t.state;L.current&&(i.pending||i.status==="pausing")&&(K(null),i.pending&&$("questions arrived \u2014 back to chat")),M(c=>c+1)});return M(i=>i+1),s},[t,Ot]);let{thinking:ue,status:de,pending:_,confirm:qe,ledger:ie,activeTurn:Pt,stream:Kn,notice:je}=t.state,qt=(Kn?.text??"").trimEnd(),jt=qt.length>0,Un=v&&(ue.liveThinking.length>0||ue.thinkingLog.length>0),Qn=Gr(ue.liveThinking||ue.thinkingLog.map(e=>e.text).join(`
|
|
5
|
+
`),Nn-6,Fn),Ft=jt?qt.split(`
|
|
6
|
+
`).slice(-Xr):[];Pt&&(ct.current=Pt.turnIndex);let Hn=_?_.resolution.filter(e=>!e).length:0,at;for(let e=ie.length-1;e>=0;e--){if(re.current.some(i=>i.end!=null&&e>=i.start&&e<i.end))continue;let s=ie[e];if(s.kind==="banner"&&!s.text.startsWith("kane")){at=s.text;break}}let Re=ue.activity[ue.activity.length-1],zn=Re?Re.status==="decision"?Re.label:xn({name:Re.name,status:Re.status}):void 0,Wt=de==="streaming"||de==="working",[,Xn]=(0,m.useState)(0);dn(()=>Xn(e=>e+1),Wt||S?.kind==="running"||h?.st.kind==="running"?120:null);let Gn=t.state.busySince?Math.floor((Date.now()-t.state.busySince)/1e3):0,Yn=t.state.turns.some(e=>e.role==="agent"),[Jn,Zn]=(0,m.useState)(0),[er,tr]=(0,m.useState)(!1),[ut,nr]=(0,m.useState)(null),pe=(0,m.useRef)(0),Vt=(0,m.useRef)(!1),Nt=(0,m.useRef)(null),Se=e=>{pe.current=e,Zn(e)},Kt=e=>{Vt.current=e,tr(e)},xe=e=>{Nt.current=e,nr(e)},[Ie,rr]=(0,m.useState)(null),dt=(0,m.useRef)(null),ke=e=>{dt.current=e,rr(e)},[mt,ir]=(0,m.useState)(null),Ut=(0,m.useRef)(null),De=e=>{Ut.current=e,ir(e)},[Fe,sr]=(0,m.useState)(0),G=(0,m.useRef)(0),Be=e=>{G.current=e,sr(e)},Qt=_?_.questions[0]?.id??"b":null;(0,m.useEffect)(()=>{_&&Be(_.cursor<0?0:_.cursor)},[Qt,_?.cursor]);let We=()=>{let e=Z.current;if(!e)return;let s=e.questions.length;for(let i=1;i<=s;i++){let c=(G.current+i)%s;if(!e.resolution[c]){Be(c);return}}},Ve=_?_.questions[Math.max(0,Math.min(_.questions.length-1,Fe))]:void 0,te=(0,m.useRef)(Ve);te.current=Ve;let Z=(0,m.useRef)(_);Z.current=_;let or=_?`${Qt}:${Fe}`:null;(0,m.useEffect)(()=>{if(xe(null),ke(null),De(null),te.current){Kt(!0);let e=Z.current?.resolution[G.current]?.selected_index;Se(e??te.current.recommended_index??0)}else Kt(!1)},[or]);let Ne=e=>{let s=Z.current;return Et(e,s?tt(s)!=="":!1)},lr={isFocused:()=>Vt.current&&te.current!=null&&Nt.current==null&&dt.current==null&&Ut.current==null||D.current!=null&&D.current.st.kind!=="running"&&Lt.current==null||z.current!=null&&z.current.kind!=="running"||U.current&&cn.current==null,onMove:e=>{let s=te.current;if(s){Se(Math.max(0,Math.min(Ne(s).maxSel,pe.current+e)));return}let i=D.current;if(i){let d=i.items[i.i];if(i.st.kind==="card"&&d){let b=it(d.card)??rt(d.card).length-1;w({...i,st:{kind:"card",sel:Math.max(0,Math.min(b,i.st.sel+e))}});return}if(i.st.kind==="view"&&d){w({...i,st:{kind:"view",offset:Math.max(0,i.st.offset+e)}});return}if(i.st.kind==="offer"||i.st.kind==="done"){let b=i.st.kind==="offer"?1:Ge.current.length-1;w({...i,st:{...i.st,sel:Math.max(0,Math.min(b,i.st.sel+e))}});return}if(i.st.kind==="running"&&!U.current)return}let c=z.current;if(c?.kind==="picker"){j({...c,sel:Math.max(0,Math.min(c.items.length-1,c.sel+e))});return}if(c?.kind==="ask"||c?.kind==="confirm"||c?.kind==="failed"){let d=(c.kind==="ask"?He.current.length:c.kind==="failed"?ze.current.length:2)-1;j({...c,sel:Math.max(0,Math.min(d,c.sel+e))});return}c&&!U.current||U.current&&ye(Math.max(0,Math.min(Le.current.length-1,vt.current+e)))},onSelect:()=>{let e=te.current,s=Z.current;if(!e||!s){let d=D.current;if(d&&d.st.kind!=="running"){let q=d.items[d.i];if(d.st.kind==="card"&&q){let F=d.st.sel;if(F===it(q.card)){he("");return}let ge=rt(q.card)[F];if(!ge)return;if(ge.v==="view_diff"){w({...d,st:{kind:"view",offset:0}});return}let Er=ge.v==="approve"||ge.v==="archive"?"approve":ge.v==="skip"?"reject":"defer";xr(d,Er);return}if(d.st.kind==="view"){w({...d,st:{kind:"card",sel:0}});return}if(d.st.kind==="offer"){d.st.sel===0?rn(d,d.st.offer):we(d);return}if(d.st.kind==="done"){Ge.current[d.st.sel]?.key==="view"?Je(""):(w(null),p?.());return}return}if(d&&!U.current)return;let b=z.current;if(b?.kind==="picker"){let q=b.items[b.sel];q&&(q.designed?j({kind:"confirm",item:q,sel:0}):bt(q,!1));return}if(b?.kind==="confirm"){Wn(b.item)[b.sel]?.key==="redesign"?bt(b.item,!0):kt();return}if(b?.kind==="ask"){let q=He.current[b.sel]?.key;q==="another"?kt():q==="view"?Je(""):j(null);return}if(b?.kind==="failed"){let q=ze.current[b.sel]?.key;q==="retry"?bt(b.item,b.force):q==="view"?Je(""):j(null);return}if(b&&!U.current||!U.current)return;switch(Le.current[vt.current]?.key){case"reconcile-review":tn();return;case"finish":t.completeSession();return;case"continue":t.continueParked();return;case"design-chain":kt();return;case"view":Je("",ct.current);return;case"free":ve("");return}return}let i=Ne(e),c=pe.current;if(i.batchIdx!=null&&c===i.batchIdx){t.goWithRecommendations();return}if(i.freeIdx!=null&&c===i.freeIdx){xe("");return}if(i.doneIdx!=null&&c===i.doneIdx){t.confirmMulti(G.current),We();return}if(e.multi_select){t.toggleOption(G.current,c);return}if(e.options[c]?.input===!0){ke({opt:c,value:""});return}t.submitAnswer(G.current,c),We()},onLeft:()=>{Z.current&&Be(Math.max(0,G.current-1))},onRight:()=>{let e=Z.current;e&&Be(Math.min(e.questions.length-1,G.current+1))},onDigit:e=>{let s=te.current;if(s){e-1<s.options.length&&Se(e-1);return}let i=D.current;if(i){let d=i.items[i.i];if(i.st.kind==="card"&&d){e-1<rt(d.card).length&&w({...i,st:{kind:"card",sel:e-1}});return}if(i.st.kind==="offer"){e-1<2&&w({...i,st:{...i.st,sel:e-1}});return}if(i.st.kind==="done"){e-1<Ge.current.length&&w({...i,st:{...i.st,sel:e-1}});return}if(i.st.kind!=="running"||!U.current)return}let c=z.current;if(c?.kind==="picker"){e-1<c.items.length&&j({...c,sel:e-1});return}if(c?.kind==="ask"){e-1<He.current.length&&j({...c,sel:e-1});return}if(c?.kind==="failed"){e-1<ze.current.length&&j({...c,sel:e-1});return}if(c?.kind==="confirm"){e-1<2&&j({...c,sel:e-1});return}if(!(c&&!U.current)&&U.current){let d=Le.current,b=0;for(let Y=0;Y<d.length;Y++)if(!d[Y].free&&(b+=1,b===e)){ye(Y);return}}},isMulti:()=>{let e=te.current;return!!e?.multi_select&&pe.current<(e?.options.length??0)},onSpace:()=>{Z.current&&t.toggleOption(G.current,pe.current)},onTab:()=>{let e=te.current;if(!e)return;let s=Ne(e);s.batchIdx!=null&&Se(s.batchIdx)},onType:e=>{let s=te.current;if(s){if(e==="@"&&t.canIngest()){De("");return}let c=pe.current;if(s.options[c]?.input===!0){ke({opt:c,value:e});return}if(!s.allow_free_text)return;let d=Ne(s);Se(d.freeIdx??0),xe(e);return}let i=D.current;if(i){if(i.st.kind==="card"){let c=it(i.items[i.i].card);c!=null&&(w({...i,st:{kind:"card",sel:c}}),he(e));return}if(i.st.kind!=="running"||!U.current)return}if(!(z.current&&!U.current)&&U.current){let c=wn(Le.current);if(c==null)return;ye(c),ve(e)}},onBack:()=>{let e=D.current;if(e){e.st.kind==="view"?w({...e,st:{kind:"card",sel:0}}):e.st.kind==="offer"?we(e):e.st.kind==="done"&&(w(null),p?.());return}let s=z.current;if(s&&s.kind!=="running"){j(null);return}let i=Z.current;if(i){for(let c=G.current-1;c>=0;c--)if(i.resolution[c]){Be(c);return}}}},cr=ut!=null?{value:ut,onChange:e=>xe(e),onSubmit:e=>{xe(null),e.trim()&&Z.current&&(t.submitFreeText(G.current,e),We())},onCancel:()=>xe(null)}:null,ar=mt!=null?{value:mt,onChange:e=>De(e),onSubmit:e=>{De(null),e.trim()&&t.ingestAttach(e)},onCancel:()=>De(null)}:null,ur=Ie!=null?{optionIndex:Ie.opt,value:Ie.value,onChange:e=>ke({opt:Ie.opt,value:e}),onSubmit:e=>{let s=dt.current?.opt;ke(null),s!=null&&Z.current&&(t.submitAnswerWithText(G.current,s,e),We())},onCancel:()=>ke(null)}:null,Ke=(0,m.useRef)(!1),ft=l??(()=>t.requestPause()),Ht=()=>{if(Ce.current&&!Ke.current){Ke.current=!0,$("finishing the verdict \u2014 exiting once it lands (ctrl+c again = force)");return}ft()},se=t.state.checkpoint,Ee=S?.kind==="running"&&de==="idle",gt=h?.st.kind==="running"&&de==="idle"&&ae.current!=null,fe=de==="idle"&&Yn&&!_&&!I&&(!S||Ee)&&(!h||gt),U=(0,m.useRef)(!1);U.current=fe;let ee=_e(t.state.turns).entries.length,Me,ne;for(let e=ie.length-1;e>=0;e--){if(re.current.some(i=>i.end!=null&&e>=i.start&&e<i.end))continue;let s=ie[e];if(!Me&&s.kind==="commit"&&s.ok&&(Me=s.line),!ne&&s.kind==="banner"&&s.text.startsWith("designing: ")&&(ne=s.text.slice(11)),Me&&ne)break}let ht;for(let e=ie.length-1;e>=0;e--){let s=ie[e];if(s.kind==="user")break;if(s.kind==="commit"&&s.ok&&/\bapplied\b/.test(s.line)){ht=s.line;break}}let oe=ne?{"acceptance criteria":"scenarios",scenarios:"acceptance criteria + exercises","acceptance criteria + exercises":"tests + gaps"}[ne]:void 0,zt={"acceptance criteria":"the promises every path of this use-case must keep",scenarios:"the concrete user journeys that exercise those promises","acceptance criteria + exercises":"the wiring pass \u2014 per-journey checks, tied to the promises each journey exercises","tests + gaps":"runnable browser tests \u2014 anything unautomatable is recorded as a gap"},Xt=ne?zt[ne]:void 0,Gt=oe?zt[oe]:void 0,dr="phases: acceptance criteria \u2192 scenarios \u2192 wiring \u2192 tests \xB7 stop anytime with finish",mr=(()=>{for(let e=ie.length-1;e>=0;e--){let s=ie[e];if(s.kind==="agent")return s.text}return null})(),be=/\?\s*$/.test((mr??"").trimEnd()),Yt=o==="design"&&!se&&(be||oe!==void 0),Jt=ne==="tests + gaps",Ue=S?.kind==="running"?S.title:"the design",Zt=!!t.state.error&&!t.senderAlive(),fr=Ee?"\u25CF design \xB7 ":gt?`\u25CF ${ae.current??"design"} \xB7 `:"",gr=qe?"the agent needs a clarification before it can apply that":Ee&&!se?be?`${Ue} \u2014 the agent asked a question`:ht?`${Ue} \u2014 ${ht}`:Jt?`${Ue} \u2014 design complete`:`${Ue} \u2014 the agent is waiting on you`:se?ne?`${ne} done${oe?` \u2014 next: ${oe}`:""}`:Me??"phase done":Zt?"the agent stopped \u2014 the session is view-only":Yt?be?"the agent asked a question \u2014 answer or continue":`design incomplete \u2014 ${oe} not started`:Me??"waiting on you",[Ae,hr]=(0,m.useState)(null),pr=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!x)return;let e=fe||se?x.pending():null;pr.current=e,hr(e)},[fe,se,ie.length,h==null]);let en=Ae?[{key:"reconcile-review",label:Ae.kind==="cards"?`review ${Ae.count} change(s) from ${Ae.source}`:`review change(s) detected in ${Ae.source}`}]:[],Qe=qe?[{key:"free",label:"clarify \u2014 type which one you meant",free:!0}]:Ee&&!se?Jt&&!be?[{key:"finish",label:"finish this design"},...ee>0?[{key:"view",label:"view what's saved"}]:[],{key:"free",label:"reply \u2014 tell the agent what to change",free:!0}]:[{key:"continue",label:be?"continue \u2014 go with your suggestion":"continue designing"},...ee>0?[{key:"view",label:"view what's saved"}]:[],{key:"finish",label:"finish this design"},{key:"free",label:"reply \u2014 tell the agent what to change",free:!0}]:se?[...en,{key:"continue",label:oe?`continue to ${oe}`:"continue"},...ee>0?[{key:"view",label:"view what's saved"}]:[],{key:"finish",label:"finish here"},{key:"free",label:"adjust \u2014 tell me what to change",free:!0}]:Zt?[...ee>0?[{key:"view",label:"view what's saved"}]:[],{key:"free",label:"tell me what to change",free:!0}]:Yt?[{key:"continue",label:be?"continue \u2014 go with your suggestion":`continue \u2014 ${oe} next`},...ee>0?[{key:"view",label:"view the design"}]:[],{key:"finish",label:"finish anyway"},{key:"free",label:"reply \u2014 answer and continue",free:!0}]:[...en,{key:"finish",label:o==="design"?"finish":"looks good \u2014 finish the session"},...u?[{key:"design-chain",label:"design tests for a use-case\u2026"}]:[],...ee>0?[{key:"view",label:o==="design"?"view the design":`view the ${ee} draft${ee===1?"":"s"}`}]:[],{key:"free",label:o==="design"?"keep adjusting \u2014 tell me what to change":"tell me what to change",free:!0}],pt=[{key:"another",label:"design another use-case\u2026"},...ee>0?[{key:"view",label:"view what was designed"}]:[],{key:"back",label:"done \u2014 back"}],He=(0,m.useRef)(pt);He.current=pt;let xt=[{key:"retry",label:"try again"},...ee>0?[{key:"view",label:"view what's saved"}]:[],{key:"back",label:"back"}],ze=(0,m.useRef)(xt);ze.current=xt;let Xe=[...ee>0?[{key:"view",label:"view what's saved"}]:[],{key:"back",label:"back to the check-in"}],Ge=(0,m.useRef)(Xe);Ge.current=Xe;let kt=()=>{let e=u?.listUcs()??[];if(e.length===0){$("no use-cases to design yet");return}j({kind:"picker",items:e,sel:0})},bt=(e,s)=>{let i={start:t.state.ledger.length,end:null};re.current.push(i);let c=()=>{i.end=t.state.ledger.length};j({kind:"running",title:e.title,item:e,force:s,startedAt:Date.now()}),u.runDesignChild(e.key,s).then(d=>{c(),j(d===0?{kind:"ask",title:e.title,sel:0}:{kind:"failed",item:e,force:s,detail:`child exited ${d}`,sel:0})}).catch(d=>{c();let b=d instanceof Error?d.message:String(d);t.ledger({kind:"childClose",verb:"design",subject:e.title,ok:!1,durS:Math.max(1,Math.round((Date.now()-(z.current?.kind==="running"?z.current.startedAt:Date.now()))/1e3))}),t.note(b),j({kind:"failed",item:e,force:s,detail:b,sel:0})})},tn=()=>{if(D.current?.st.kind==="running")return;let e=x?.pending();if(!e){$("nothing awaiting review");return}if(lt.current={approved:0,rejected:0,deferred:0},e.kind==="needs-run"){w({items:[],i:0,st:{kind:"running",label:`reviewing changes in ${e.source}`,startedAt:Date.now()}}),x.startReview(e.source).then(()=>{let i=x.loadCards();if(i.length===0){t.note("no reviewable changes came back \u2014 the source may be unchanged"),w(null);return}w({items:i,i:0,st:{kind:"card",sel:0}})}).catch(i=>{t.note(`the review run failed \u2014 ${i instanceof Error?i.message:String(i)}`),w(null)});return}let s=x.loadCards();if(s.length===0){$("nothing awaiting review");return}w({items:s,i:0,st:{kind:"card",sel:0}})},nn=e=>{let s=lt.current,i=`${s.approved} approved \xB7 ${s.rejected} rejected \xB7 ${s.deferred} deferred`;w({...e,st:{kind:"done",sel:0,summary:i}})},we=e=>{if(e.i+1<e.items.length){w({...e,i:e.i+1,st:{kind:"card",sel:0}});return}let s=x?.loadCards()??[];s.length===0?nn(e):w({items:s,i:0,st:{kind:"card",sel:0}})},rn=(e,s)=>{if(!u){we(e);return}ae.current=s.kind;let i={start:t.state.ledger.length,end:null};re.current.push(i),w({...e,st:{kind:"running",label:`${s.kind==="evolve"?"Evolving":"Designing"} ${s.title}`,startedAt:Date.now()}}),u.runDesignChild(s.key,s.kind==="evolve",s.kind).then(()=>{ae.current=null,i.end=t.state.ledger.length,we(D.current??e)}).catch(c=>{ae.current=null,i.end=t.state.ledger.length,t.ledger({kind:"childClose",verb:s.kind,subject:s.title,ok:!1,durS:1}),t.note(c instanceof Error?c.message:String(c)),we(D.current??e)})},xr=(e,s,i)=>{let c=e.items[e.i];!c||Ce.current||(Ce.current=!0,x.applyVerdict(c.key,s,i).then(d=>{if(Ce.current=!1,Ke.current){ft();return}let b=D.current??e;if(!d.ok){t.note(d.refusal);let Y=x.loadCards();Y.length===0?nn(b):w({items:Y,i:Math.min(b.i,Y.length-1),st:{kind:"card",sel:0}});return}lt.current[s==="approve"?"approved":s==="reject"?"rejected":"deferred"]+=1,t.ledger({kind:"commit",ok:!0,line:d.line}),d.note&&t.note(d.note),d.offer?rn(b,d.offer):we(b)}).catch(d=>{if(Ce.current=!1,Ke.current){ft();return}t.note(`the verdict did not land \u2014 ${d instanceof Error?d.message:String(d)}; try the card again`)}))},kr=e=>{x?.noteSteer?.(),w(null),he(null),$(null),t.submit(e)},br=X!=null?{value:X,onChange:e=>he(e),onSubmit:e=>{let s=e.trim();s?kr(s):he(null)},onCancel:()=>he(null)}:null,sn=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!f||sn.current||(sn.current=!0,x?.pending()?tn():p?.())},[f]);let Le=(0,m.useRef)(Qe);Le.current=Qe;let wt=fe&&se&&Xt!==void 0,yt=re.current.find(e=>e.end==null)?.start??"top",on=(0,m.useRef)(new Set),[wr,ln]=(0,m.useState)(!1);(0,m.useEffect)(()=>{wt?on.current.has(yt)||(on.current.add(yt),ln(!0)):ln(!1)},[wt,yt]);let yr=wt?[...wr?[dr]:[],`${Xt}${Gt?` \xB7 next: ${Gt}`:""}`]:[],[vr,Tr]=(0,m.useState)(0),[Ye,$r]=(0,m.useState)(null),vt=(0,m.useRef)(0),cn=(0,m.useRef)(null),ye=e=>{vt.current=e,Tr(e)},ve=e=>{cn.current=e,$r(e)},Cr=`${fe}:${se}:${ct.current}`;(0,m.useEffect)(()=>{ye(0),ve(null)},[Cr]);let Rr=Ye!=null?{value:Ye,onChange:e=>ve(e),onSubmit:e=>{ve(null),ye(0);let s=e.trim();s&&($(null),t.submit(s))},onCancel:()=>{ve(null),ye(0)}}:null,Je=(e,s)=>{if(/^(uc|sc|ac|t|gap|sty)-\d+$/i.test(e.trim())){let b=e.trim().toLowerCase(),q=_e(t.state.turns).entries.findIndex(F=>(F.item.logical_id??"").toLowerCase()===b);if(q<0){$(`${e.trim().toUpperCase()} isn't in this session's items \u2014 view lists what this session minted`);return}K({level:"detail",cursor:q,scroll:0}),H(null);return}let i=jn(e);if("error"in i){$(i.error);return}let c=_e(t.state.turns);if(c.entries.length===0){$("nothing proposed yet \u2014 the first turn is still coming");return}if(i.level==="detail"&&i.num>c.entries.length){$(`no item ${i.num} \u2014 the set has ${c.entries.length} item${c.entries.length===1?"":"s"}`);return}let d=s!=null?St(c,s):c;K(_n(i,d)),H(s!=null&&d.entries.length<c.entries.length?s:null)},Tt=jt?"writing":zn??(t.state.workingLabel?It(t.state.workingLabel):o==="design"?"designing":"thinking"),Sr=ue.liveThinking.length>0||ue.thinkingLog.length>0,$t=S?.kind==="running"?{verb:"design"}:h?.st.kind==="running"&&ae.current?{verb:ae.current}:void 0,Ir=_?{kind:"waiting",pending:Hn}:de==="pausing"?{kind:"working",step:"pausing \u2014 saving session"}:S?.kind==="running"?Ee?{kind:"child-waiting"}:{kind:"child-working",step:Tt}:h?.st.kind==="running"?gt?{kind:"child-waiting"}:ae.current?{kind:"child-working",step:Tt}:{kind:"working",step:It(h.st.label)}:h?.st.kind==="card"&&h.items.length>0?{kind:"card",n:h.i+1,m:h.items.length}:S||h?{kind:"idle"}:Wt?{kind:"working",step:Tt,elapsedS:Gn}:{kind:"idle"},Dr=ut!=null||Ie!=null||mt!=null||X!=null||Ye!=null,an=h?h.items[h.i]:void 0,Br=[...Dr?["\u23CE submit","esc back"]:I?I.level==="list"?["\u2191\u2193 move","\u23CE open","esc back"]:["\u2191\u2193 scroll","esc back"]:_&&Ve?Sn(Ve,{batchCount:_.questions.length,canAttach:t.canIngest(),escBack:_.resolution.slice(0,Fe).some(e=>!!e)}).keys:h?.st.kind==="card"&&an?In(an.card).keys:h?.st.kind==="view"?["\u2191\u2193 scroll","esc back"]:h?.st.kind==="offer"?["\u2191\u2193 select","\u23CE confirm","esc later"]:h?.st.kind==="done"?Bt(Xe,{escBack:!0}).keys:S?.kind==="picker"||S?.kind==="confirm"||S?.kind==="ask"||S?.kind==="failed"?["\u2191\u2193 select","\u23CE confirm","esc back"]:fe?Bt(Qe,{escBack:!1}).keys:[],...Sr?["ctrl+t thinking"]:[],de==="pausing"?"ctrl+c force quit":"ctrl+c exit"],Ct=C??{verb:o,sid:"",env:""},un=(0,E.jsx)($n,{status:Ir,meta:{...Ct,...at??Ct.subject?{subject:at??Ct.subject}:{}},tallies:Rn(t.state,o),keys:Br,child:$t});if(I){let e=_e(t.state.turns),s=B!=null?St(e,B):e,i=e.entries.length-s.entries.length,c=I.level==="list"&&i>0,d=s.entries.length+(c?1:0),b=s.entries[I.cursor],Y=I.level==="detail"&&b?t.explainLines(b.item.slug??b.item.temp_ref):null,q=I.level==="detail"&&b&&g?g(b.item.logical_id??t.aliasOf(b.item.temp_ref)??b.item.temp_ref):null;return(0,E.jsxs)(k,{flexDirection:"column",children:[(0,E.jsx)(Dt,{onToggleThinking:()=>T(F=>!F),onCtrlC:Ht,explorer:{isOpen:()=>L.current!==null,onMove:F=>K(L.current&&ot(L.current,{type:"move",delta:F},d)),onEnter:()=>{let F=L.current;if(F){if(F.level==="list"&&c&&F.cursor===s.entries.length){H(null);return}K(ot(F,{type:"enter"},d))}},onBack:()=>{K(L.current&&ot(L.current,{type:"back"},d)),setTimeout(()=>M(F=>F+1),0)}}}),(0,E.jsx)(Pn,{items:s,state:I,verb:o,more:c?{hidden:i}:null,explain:Y,grandTotal:e.entries.length,dossier:q}),(je??W)&&(je??W).split(`
|
|
7
|
+
`).map((F,ge)=>(0,E.jsx)(n,{color:r.orange,children:F},`nt-${ge}`)),un]})}return(0,E.jsxs)(k,{flexDirection:"column",children:[(0,E.jsx)(Dt,{onToggleThinking:()=>T(e=>!e),onCtrlC:Ht,panel:lr}),Un&&(0,E.jsx)(pn,{thinking:Qn.body,expanded:!0,thinkingDone:de!=="streaming",maxLines:Fn+1}),Ft.length>0&&(0,E.jsx)(k,{flexDirection:"column",children:Ft.map((e,s)=>(0,E.jsx)(n,{children:gn(e).map((i,c)=>(0,E.jsx)(n,{bold:i.bold,italic:i.italic,color:i.code?r.dim:void 0,children:i.text},c))},`st-${s}`))}),_&&(0,E.jsx)(Dn,{childPrefix:$t?`${$t.verb} \xB7 `:void 0,batch:_,qView:Fe,sel:Jn,focused:er,freeText:cr,optionText:ur,attach:ar,multiSelFor:e=>t.multiSelection(e)}),qe&&(0,E.jsx)(n,{color:"yellow",children:qe.prompt}),(je??W)&&(je??W).split(`
|
|
8
|
+
`).map((e,s)=>(0,E.jsx)(n,{color:r.orange,children:e},`nt-${s}`)),fe&&(0,E.jsx)(me,{headline:`${fr}${gr}`,rows:Qe,sel:vr,focused:Ye==null,freeText:Rr,sublines:yr}),h?.st.kind==="card"&&h.items[h.i]&&(0,E.jsx)(Cn,{card:h.items[h.i].card,position:{n:h.i+1,of:h.items.length},sel:h.st.sel,focused:X==null,freeText:br,editorIntent:"steer"}),h?.st.kind==="view"&&h.items[h.i]&&(0,E.jsx)(qn,{title:h.items[h.i].card.title,lines:h.items[h.i].viewLines,offset:h.st.offset}),h?.st.kind==="offer"&&(0,E.jsx)(me,{ask:!0,headline:h.st.offer.kind==="evolve"?`approved \u2014 the design for ${h.st.offer.title} should evolve with it`:`approved \u2014 ${h.st.offer.title} has no tests yet`,rows:[{key:"run",label:h.st.offer.kind==="evolve"?"evolve the design now":"design tests now"},{key:"later",label:"later \u2014 next change"}],sel:h.st.sel,focused:!0}),h?.st.kind==="done"&&(0,E.jsx)(me,{headline:`review complete \u2014 ${h.st.summary}`,rows:Xe,sel:h.st.sel,focused:!0}),S?.kind==="picker"&&(0,E.jsx)(me,{ask:!0,headline:"design tests for which use-case?",rows:S.items.map(e=>({key:e.key,label:e.title,detail:e.badge})),sel:S.sel,focused:!0}),S?.kind==="confirm"&&(0,E.jsx)(me,{ask:!0,headline:`${S.item.title} is already designed${S.item.designed==="stale"?" \u2014 and the use-case has changed since":""}`,rows:Wn(S.item).map(e=>({key:e.key,label:e.label,detail:e.detail})),sel:S.sel,focused:!0}),S?.kind==="ask"&&(0,E.jsx)(me,{headline:`designed ${S.title}`,rows:pt,sel:S.sel,focused:!0}),S?.kind==="failed"&&(0,E.jsx)(me,{headline:`design failed \u2014 ${S.item.title} (${S.detail})`,rows:xt,sel:S.sel,focused:!0}),un]})}export{Xi as ChatSurface,Gr as tailVisualRows};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-BKVDAZEJ.js";import"./chunk-U5GHOGLM.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{c as ChromeProfilePicker,b as formatChromeProfileLine,a as listChromeProfiles};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as r}from"./chunk-
|
|
2
|
+
import{a as r}from"./chunk-VPRNGWIY.js";import"./chunk-U5GHOGLM.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import{c as e}from"./chunk-C44QQJR4.js";import{a as i}from"./chunk-6YGTRKDT.js";import{e as m}from"./chunk-UR6MHSHU.js";var t=m(i(),1);async function d(){return new Promise(o=>{let c=e(t.default.createElement(r,{onSubmit:n=>{c.unmount(),o(n)}}),{stdout:process.stderr,exitOnCtrlC:!1})})}export{d as renderFeedbackPrompt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as P,b as g,c as f}from"./chunk-
|
|
2
|
+
import{a as P,b as g,c as f}from"./chunk-BSYX225I.js";import"./chunk-UODLRQQ4.js";import"./chunk-5Y2G4NC7.js";import"./chunk-7F2ZV46B.js";import{a as c}from"./chunk-HCBYKLMW.js";import{c as d}from"./chunk-C44QQJR4.js";import{a as h}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var e=p(h(),1);var m=p(c(),1);function w({pipeline:t,buildShareUrl:r,onDone:o}){let[n,i]=(0,e.useState)(P()),[S,l]=(0,e.useState)("uploading"),[U,R]=(0,e.useState)(),[C,E]=(0,e.useState)();return(0,e.useEffect)(()=>{let x=t.config.onProgress;t.config.onProgress=(s,u,a)=>{x(s,u,a),i(y=>g(y,s,u,a))},t.execute().then(s=>{s.success?(R(r?.(s)),l("success")):(E(s.error),l("failed")),setTimeout(()=>o(s),1500)})},[]),(0,m.jsx)(f,{steps:n,status:S,testUrl:U,error:C})}async function O(t,r){return new Promise(o=>{let n=d(e.default.createElement(w,{pipeline:t,buildShareUrl:r,onDone:i=>{n.unmount(),o(i)}}),{stdout:process.stderr,exitOnCtrlC:!1})})}export{O as renderUploadProgress};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as l,c as n}from"./chunk-
|
|
2
|
+
import{a as b,b as l,c as n}from"./chunk-2ZZDNPFN.js";import{y as o}from"./chunk-7F2ZV46B.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a as u,j as v}from"./chunk-C44QQJR4.js";import{a as S}from"./chunk-6YGTRKDT.js";import{e as a}from"./chunk-UR6MHSHU.js";var C=a(S(),1);var e=a(p(),1);function O({model:x,authLabel:w,profile:B,env:h,defaultUrl:s,projectId:i,projectName:d,folderId:t,folderName:f,windowSize:D,chromeProfile:P,target:r,deviceLabel:m,appLabel:g}){let R=i?d?`${d} (${i})`:i:"(none)",V=t?f?`${f} (${t})`:t:"(none)",{exit:c}=v();return(0,C.useEffect)(()=>{let $=setTimeout(()=>c(),50);return()=>clearTimeout($)},[c]),(0,e.jsx)(u,{flexDirection:"column",children:(0,e.jsx)(b,{title:"Configuration",children:(0,e.jsxs)(u,{flexDirection:"column",paddingY:1,children:[(0,e.jsx)(n,{label:"Auth"}),(0,e.jsx)(l,{label:" method",value:w}),(0,e.jsx)(l,{label:" profile",value:B}),(0,e.jsx)(l,{label:" env",value:h}),(0,e.jsx)(n,{label:"Defaults"}),(0,e.jsx)(l,{label:" url",value:s??"(none)",valueColor:s?o.orange:o.dim}),(0,e.jsx)(l,{label:" model",value:x}),(0,e.jsx)(l,{label:" window",value:D}),(0,e.jsx)(l,{label:" project",value:R}),(0,e.jsx)(l,{label:" folder",value:V}),r!==void 0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{label:" target",value:r}),r!=="desktop"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{label:" device",value:m??"(not set)",valueColor:m?void 0:o.dim}),(0,e.jsx)(l,{label:" app",value:g??"(not set)",valueColor:g?void 0:o.dim})]})]}),(0,e.jsx)(n,{label:"Paths"}),(0,e.jsx)(l,{label:" chrome",value:P,valueColor:o.dim})]})})})}export{O as ConfigView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-JUVQQP42.js";import"./chunk-2KH2JUGL.js";import"./chunk-5DBK6QNS.js";import"./chunk-CJJXT5DO.js";import"./chunk-XWKUZJCP.js";import"./chunk-ZPDM6FO7.js";import"./chunk-EHN5HTUD.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-L5LI2JF4.js";import"./chunk-6IA6QMPH.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-NHBYZCSX.js";import"./chunk-RFHMDQXZ.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-IUEEFGEW.js";import"./chunk-MSGW4JDG.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-4JOD47QI.js";import"./chunk-LVN6VHFN.js";import"./chunk-RZ4F3BHX.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as EvidenceViewOffer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b}from"./chunk-IZ2FJYHG.js";import"./chunk-YCCUBQY4.js";import"./chunk-5SNT2MK5.js";import"./chunk-BPMSNGXQ.js";import"./chunk-U5GHOGLM.js";import"./chunk-LVN6VHFN.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as FolderPicker,a as formatFolderLine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f,b as r,y as t}from"./chunk-
|
|
2
|
+
import{a as f,b as r,y as t}from"./chunk-7F2ZV46B.js";import{a as T}from"./chunk-HCBYKLMW.js";import{a as s,b as o,j as x,k as p}from"./chunk-C44QQJR4.js";import{a as v}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var w=h(v(),1);var e=h(T(),1),b="https://www.testmuai.com/support/docs/kane-cli-introduction",S="https://github.com/LambdaTest/kane-cli/issues";function L(){let{exit:c}=x(),{stdout:a}=p(),l=a?.columns??80;return(0,w.useEffect)(()=>{let m=setTimeout(()=>c(),50);return()=>clearTimeout(m)},[c]),(0,e.jsxs)(s,{flexDirection:"column",children:[(0,e.jsxs)(s,{paddingX:1,paddingTop:1,flexDirection:"column",children:[(0,e.jsx)(o,{color:t.orange,bold:!0,children:r}),(0,e.jsxs)(s,{children:[(0,e.jsx)(o,{color:t.dim,children:"Browser automation powered by AI "}),(0,e.jsxs)(o,{color:t.muted,children:[" v",f]})]})]}),(0,e.jsx)(o,{children:" "}),(0,e.jsxs)(d,{title:"USAGE",children:[(0,e.jsx)(g,{cmd:`${r}`,desc:"Single-shot prompt (no args, TTY)"}),(0,e.jsx)(g,{cmd:`${r} --tui`,desc:"Full interactive TUI",highlight:!0}),(0,e.jsx)(g,{cmd:`${r} run "<objective>"`,desc:"Inline objective"}),(0,e.jsx)(g,{cmd:`${r} testmd run <path>.md`,desc:"Replay a saved *_test.md file"})]}),(0,e.jsxs)(d,{title:"HELP",children:[(0,e.jsx)(g,{cmd:`${r} --help`,desc:"Show this help (long form)"}),(0,e.jsx)(g,{cmd:`${r} -h`,desc:"Show this help (short form)"}),(0,e.jsx)(g,{cmd:`${r} help`,desc:"Show this help (subcommand form)"}),(0,e.jsxs)(s,{marginLeft:2,marginTop:0,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:["These are the only supported help invocations. Anything else (e.g. ",(0,e.jsx)(o,{color:t.orange,children:"-help"}),") is an unknown flag."]}),(0,e.jsxs)(o,{color:t.dim,children:["Terminal tab-completion is a shell feature; ",r," does not ship shell-completion scripts, so any flag your shell suggests is a generic guess \u2014 not from ",r,"."]})]})]}),(0,e.jsxs)(d,{title:"COMMANDS",children:[(0,e.jsx)(i,{cmd:"run",args:"<objective>",desc:"Run an objective (inline string)",highlight:!0}),(0,e.jsx)(i,{cmd:"testmd",args:"run|list|status|delete|export",desc:"Manage *_test.md files"}),(0,e.jsx)(i,{cmd:"testrun",args:"run",desc:"Run M *_test.md files as one sealed execution"}),(0,e.jsx)(i,{cmd:"login",desc:"Auth setup (interactive, --oauth, or --username)"}),(0,e.jsx)(i,{cmd:"logout",desc:"Revoke tokens + delete profile"}),(0,e.jsx)(i,{cmd:"whoami",desc:"Show authenticated identity"}),(0,e.jsx)(i,{cmd:"config",args:"show|set-mode|set-assertion-mode|\u2026",desc:"Chrome, run & generate settings"}),(0,e.jsx)(i,{cmd:"profiles",args:"list|switch|delete",desc:"Manage auth profiles"}),(0,e.jsx)(i,{cmd:"evidence",args:"validate|serve|merge",desc:"Validate, serve (viewer) or merge evidence packs"}),(0,e.jsx)(i,{cmd:"changelog",args:"[--all]",desc:"Show recent release notes"}),(0,e.jsx)(i,{cmd:"context",args:"ingest|extract|list|review|sessions|\u2026",desc:"Build & manage the assurance context store"}),(0,e.jsx)(i,{cmd:"design",args:"tests --use-case <ref>",desc:"Design tests from the context store"})]}),(0,e.jsxs)(d,{title:"TESTMD ACTIONS",children:[(0,e.jsx)(i,{cmd:"testmd run",args:"<path>",desc:"Replay a saved *_test.md file",highlight:!0}),(0,e.jsx)(i,{cmd:"testmd list",desc:"List *_test.md files in cwd (recursive)"}),(0,e.jsx)(i,{cmd:"testmd status",args:"<path>",desc:"Print local meta.json for a test"}),(0,e.jsx)(i,{cmd:"testmd delete",args:"<path>",desc:"Remove output-<stem>/ and the source file"}),(0,e.jsx)(i,{cmd:"testmd export",args:"<path> --language <py|js>",desc:"Generate standalone Playwright code"})]}),(0,e.jsxs)(d,{title:"RUN FLAGS",children:[(0,e.jsx)(n,{long:"--max-steps",arg:"<n>",desc:"Max agent steps (default: 50)"}),(0,e.jsx)(n,{long:"--timeout",arg:"<sec>",desc:"Kill run after N seconds"}),(0,e.jsx)(n,{long:"--headless",desc:"No visible browser window"}),(0,e.jsx)(n,{long:"--mode",arg:"<action|testing>",desc:"Run mode (default: testing)"}),(0,e.jsx)(n,{long:"--name",arg:"<name>",desc:"Persist session under this name"}),(0,e.jsx)(n,{long:"--variables",arg:"<json>",desc:"Inline variables as JSON"}),(0,e.jsx)(n,{long:"--variables-file",arg:"<path>",desc:"Load variables from file"}),(0,e.jsx)(n,{long:"--session-context",arg:"<json>",desc:"Prior runs context JSON"}),(0,e.jsx)(n,{long:"--global-context",arg:"<file>",desc:"Override global context markdown"}),(0,e.jsx)(n,{long:"--local-context",arg:"<file>",desc:"Override local context markdown"}),(0,e.jsx)(n,{long:"--ws-endpoint",arg:"<url>",desc:"Remote browser (LambdaTest)"}),(0,e.jsx)(n,{long:"--cdp-endpoint",arg:"<url>",desc:"Connect to existing Chrome CDP"}),(0,e.jsx)(n,{long:"--task-skills",desc:"Domain-specific task skills (experimental)"}),(0,e.jsx)(n,{long:"--code-export",desc:"Generate code export after upload"}),(0,e.jsx)(n,{long:"--code-language",arg:"<lang>",desc:"Code export language: python | javascript"}),(0,e.jsx)(n,{long:"--skip-code-validation",desc:"Skip post-codegen validation"}),(0,e.jsx)(n,{long:"--username",arg:"<user>",desc:"Basic auth (skip OAuth)"}),(0,e.jsx)(n,{long:"--access-key",arg:"<key>",desc:"Basic auth access key"}),(0,e.jsx)(n,{long:"--env",arg:"<name>",desc:"Environment (prod or stage)"}),(0,e.jsx)(n,{long:"--agent",desc:"NDJSON output (no UI)",highlight:!0})]}),(0,e.jsxs)(d,{title:"EXAMPLES",children:[(0,e.jsx)(u,{label:"Inline objective",cmd:`${r} run "Search for laptop"`}),(0,e.jsx)(u,{label:"Replay a saved test",cmd:`${r} testmd run smoke_test.md`}),(0,e.jsx)(u,{label:"Variables",cmd:`${r} run "Login as {{user}}" --variables '{"user":{"value":"alice"}}'`}),(0,e.jsx)(u,{label:"Agent mode (NDJSON)",cmd:`${r} run "Add to cart" --agent | jq .status`})]}),(0,e.jsx)(d,{title:"TEST FILES",children:(0,e.jsxs)(s,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:[(0,e.jsx)(o,{color:t.orange,children:"*_test.md"})," \u2014 markdown test files with YAML frontmatter and ",(0,e.jsx)(o,{color:t.orange,children:"## "}),"step headings."]}),(0,e.jsxs)(o,{color:t.dim,children:["Run with ",(0,e.jsxs)(o,{color:t.orange,children:[r," testmd run path/to/foo_test.md"]}),". (`.md` paths are not accepted by `",r," run`.)"]}),(0,e.jsxs)(o,{color:t.dim,children:["Sessions you run in TUI auto-save to ",(0,e.jsx)(o,{color:t.orange,children:"<cwd>/.testmuai/tests/<name>_test.md"})," (testing mode prompts on exit)."]})]})}),(0,e.jsxs)(s,{flexDirection:"column",marginTop:0,paddingX:1,children:[(0,e.jsx)(o,{color:t.muted,children:"\u2500".repeat(Math.min(l-2,70))}),(0,e.jsxs)(s,{gap:3,children:[(0,e.jsxs)(s,{children:[(0,e.jsx)(o,{color:t.dim,children:"Docs "}),(0,e.jsx)(o,{color:t.orange,underline:!0,children:b})]}),(0,e.jsxs)(s,{children:[(0,e.jsx)(o,{color:t.dim,children:"Bugs "}),(0,e.jsx)(o,{color:t.orange,underline:!0,children:S})]})]})]}),(0,e.jsx)(o,{children:" "})]})}function d({title:c,children:a}){return(0,e.jsxs)(s,{flexDirection:"column",marginBottom:1,children:[(0,e.jsx)(s,{marginLeft:1,children:(0,e.jsx)(o,{bold:!0,color:t.dim,children:c})}),a]})}function g({cmd:c,desc:a,highlight:l}){return(0,e.jsxs)(s,{marginLeft:2,children:[(0,e.jsxs)(s,{width:40,children:[(0,e.jsx)(o,{color:t.dim,children:"$ "}),(0,e.jsx)(o,{color:l?t.orange:t.orange,children:c})]}),(0,e.jsx)(o,{color:t.dim,children:a})]})}function i({cmd:c,args:a,desc:l,highlight:m}){return(0,e.jsxs)(s,{marginLeft:2,children:[(0,e.jsx)(s,{width:16,children:(0,e.jsx)(o,{color:m?t.orange:t.green,bold:!0,children:c})}),(0,e.jsx)(s,{width:32,children:a?(0,e.jsx)(o,{color:t.dim,children:a}):null}),(0,e.jsx)(o,{color:t.dim,children:l})]})}function n({long:c,arg:a,desc:l,highlight:m}){return(0,e.jsxs)(s,{marginLeft:2,children:[(0,e.jsxs)(s,{width:30,children:[(0,e.jsx)(o,{color:m?t.orange:t.orange,children:c}),a&&(0,e.jsxs)(o,{color:t.dim,children:[" ",a]})]}),(0,e.jsx)(o,{color:t.dim,children:l})]})}function u({label:c,cmd:a}){return(0,e.jsxs)(s,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:["# ",c]}),(0,e.jsxs)(o,{color:t.orange,children:["$ ",a]})]})}export{L as HelpView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-YSSYT5F5.js";import"./chunk-2ZZDNPFN.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as InfoBox};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-O3AHFP3K.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as LinksBox};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-WOEQDUJ6.js";import"./chunk-U5GHOGLM.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as ProfilesView,a as formatProfileLine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-OJTCIZDK.js";import"./chunk-YCCUBQY4.js";import"./chunk-5SNT2MK5.js";import"./chunk-BPMSNGXQ.js";import"./chunk-U5GHOGLM.js";import"./chunk-LVN6VHFN.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as ProjectPicker,a as formatProjectLine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-R4UCBA5R.js";import"./chunk-S3DAAAE5.js";import"./chunk-YSSYT5F5.js";import"./chunk-2ZZDNPFN.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as SaveSessionPrompt,b as defaultSessionTimestamp,c as renderSavePrompt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-OAVPM6YJ.js";import"./chunk-ZI6UIJUN.js";import"./chunk-JJN76EXE.js";import"./chunk-WV27D55O.js";import"./chunk-L5LI2JF4.js";import"./chunk-TDPWFYTJ.js";import"./chunk-HRZOFTV7.js";import"./chunk-YTDSQAYN.js";import"./chunk-OJTCIZDK.js";import"./chunk-IZ2FJYHG.js";import"./chunk-YCCUBQY4.js";import"./chunk-5SNT2MK5.js";import"./chunk-BPMSNGXQ.js";import"./chunk-VE3SUJMA.js";import"./chunk-TZXXJWHA.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-AJQT4IWZ.js";import"./chunk-TAOHYWEO.js";import"./chunk-U5GHOGLM.js";import"./chunk-J7KT44IC.js";import"./chunk-LVN6VHFN.js";import"./chunk-DPUV6OSP.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-PXCMEI73.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as SingleShotApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-YHYTCENI.js";import"./chunk-YSSYT5F5.js";import"./chunk-2ZZDNPFN.js";import"./chunk-7F2ZV46B.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{d as AutoExitSummaryBox,c as SummaryBox,b as buildSummaryEvent,a as buildSummaryRendered};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{g as a}from"./chunk-2TYCUPCN.js";import"./chunk-KKRNTSLL.js";import"./chunk-NRUD56FY.js";import"./chunk-6IA6QMPH.js";import"./chunk-TDPWFYTJ.js";import"./chunk-HRZOFTV7.js";import"./chunk-UODLRQQ4.js";import"./chunk-5Y2G4NC7.js";import"./chunk-ECZMYPLJ.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-IUEEFGEW.js";import"./chunk-MSGW4JDG.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-4JOD47QI.js";import"./chunk-LVN6VHFN.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-YSSYT5F5.js";import"./chunk-2ZZDNPFN.js";import"./chunk-7F2ZV46B.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as TestMdRunView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as r}from"./chunk-
|
|
2
|
+
import{a as b,b as r}from"./chunk-2ZZDNPFN.js";import{y as o}from"./chunk-7F2ZV46B.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a as i,b as l,j as s}from"./chunk-C44QQJR4.js";import{a as T}from"./chunk-6YGTRKDT.js";import{e as a}from"./chunk-UR6MHSHU.js";var f=a(T(),1);var e=a(p(),1);function V({profile:g,env:v,authenticated:n,authMethod:h,username:c,tokenStatus:t,expiresAt:d,serverStatus:u,detail:m}){let{exit:x}=s();return(0,f.useEffect)(()=>{let B=setTimeout(()=>x(),50);return()=>clearTimeout(B)},[x]),(0,e.jsx)(i,{flexDirection:"column",children:(0,e.jsx)(b,{title:"Identity",variant:n?"success":"warning",children:(0,e.jsxs)(i,{flexDirection:"column",paddingY:1,children:[(0,e.jsx)(i,{children:u==="rejected"?(0,e.jsx)(l,{color:o.red,bold:!0,children:"\u2717 Not authenticated"}):u==="unreachable"?(0,e.jsx)(l,{color:o.orange,bold:!0,children:"\u26A0 Couldn't verify"}):n?(0,e.jsx)(l,{color:o.green,bold:!0,children:"\u2713 Authenticated"}):(0,e.jsx)(l,{color:o.orange,bold:!0,children:"\u26A0 Not logged in"})}),(0,e.jsxs)(i,{flexDirection:"column",marginTop:1,children:[(0,e.jsx)(r,{label:"Profile",value:g}),(0,e.jsx)(r,{label:"Environment",value:v}),(0,e.jsx)(r,{label:"Method",value:h}),c&&(0,e.jsx)(r,{label:"User",value:c}),t&&(0,e.jsx)(r,{label:"Token",value:t,valueColor:t==="valid"?o.green:t==="expired"?o.red:o.dim}),d&&(0,e.jsx)(r,{label:"Expires",value:d}),m&&(0,e.jsx)(r,{label:"Detail",value:m})]})]})})})}export{V as WhoamiView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-TAOHYWEO.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{h as AppClient,g as AppUploadError,a as UPLOAD_CONTENT_TYPE,e as parseAppDetails,b as parseAppListPage,d as parseSignedDownload,c as parseUploadResponse,f as transportReason};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as a,c as b}from"./chunk-
|
|
2
|
+
import{b as a,c as b}from"./chunk-AJQT4IWZ.js";import"./chunk-TAOHYWEO.js";import"./chunk-RZ4F3BHX.js";import"./chunk-7F2ZV46B.js";import"./chunk-UR6MHSHU.js";export{a as isAppId,b as resolveCloudApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import"./chunk-UR6MHSHU.js";async function i(e){try{let[{CredentialsManager:n},{AuthResolver:a},{getEnvironment:s}]=await Promise.all([import("./credentials-
|
|
2
|
+
import"./chunk-UR6MHSHU.js";async function i(e){try{let[{CredentialsManager:n},{AuthResolver:a},{getEnvironment:s}]=await Promise.all([import("./credentials-CALNKQMN.js"),import("./resolver-FTU5KO7H.js"),import("./config-RLDXM5ZH.js")]),t=new n,o=t.getActiveProfile()??"default",c=t.loadCredentials(o,e);if(typeof c?.access_token!="string")return null;let r=await new a(s(e).controllerBaseUrl,async()=>c.access_token,null).resolve();return typeof r?.username!="string"||!r.username||typeof r.access_key!="string"||!r.access_key?null:Buffer.from(`${r.username}:${r.access_key}`,"utf8").toString("base64")}catch{return null}}async function u(e={}){let n=e.env??process.env,s=await(e.resolveBase??(async()=>(await import("./spawner-DQZRJIE6.js")).resolveAgentAuthEnv()))();if(s.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH)return s;let t=n.TESTMUAI_ENV==="stage"?"stage":"prod",o=await(e.exchange??i)(t);return o?{...s,TESTMUAI_BASIC_AUTH:o}:s}export{u as resolveLisAuthEnv};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as _}from"./chunk-
|
|
2
|
+
import{a as _}from"./chunk-6N726QLP.js";import"./chunk-KHU7C6EE.js";import"./chunk-IOD3HQVW.js";import"./chunk-3Q6WAK6P.js";import"./chunk-AFPHLUQ5.js";import"./chunk-JZ26R6UL.js";import"./chunk-RN4PKQFR.js";import"./chunk-FNS2EAA5.js";import"./chunk-ZGBSGZZM.js";import"./chunk-7S3JZ6FQ.js";import"./chunk-BB2W35TW.js";import"./chunk-AXTPNZPX.js";import"./chunk-L2TV4G56.js";import"./chunk-JFAFKHDX.js";import"./chunk-6KPPGMO2.js";import"./chunk-GNIFMQNK.js";import"./chunk-GFKCTYCA.js";import"./chunk-YKTYVJBN.js";import"./chunk-IMR64OCZ.js";import"./chunk-427OQS2N.js";import"./chunk-4U4OSOA4.js";import"./chunk-W4B5LOEX.js";import"./chunk-DNNZ353O.js";import"./chunk-R7QAS6LZ.js";import"./chunk-KRKGZ2ZW.js";import"./chunk-2UIHS2FH.js";import"./chunk-Q2F5QB2W.js";import"./chunk-BKHXPBWN.js";import"./chunk-N2P4MI32.js";import"./chunk-5DT7PIGB.js";import"./chunk-ZPDM6FO7.js";import"./chunk-NVGBE2DR.js";import{a as m}from"./chunk-CH273NAE.js";import"./chunk-L5LI2JF4.js";import"./chunk-IDX3TOPY.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-MSGW4JDG.js";import"./chunk-5EOX4MEY.js";import"./chunk-7F2ZV46B.js";import"./chunk-UR6MHSHU.js";import{existsSync as O}from"fs";var P=new Set(["interactive","agent","ci","override"]);function H(e){return e.mode!=null&&!P.has(e.mode)?{error:`design: --mode must be interactive | agent | ci | override, got '${e.mode}'`}:e.strength!=null&&e.strength!=="pairwise"&&e.strength!=="3-wise"?{error:`design: --strength must be pairwise | 3-wise, got '${e.strength}'`}:e.max!=null&&(!Number.isInteger(e.max)||e.max<1)?{error:"design: --max must be a positive integer"}:!e.useCase&&!e.resume?{error:"design: --use-case is required (or --resume <sid> \u2014 the session remembers its use-case)"}:{useCase:e.useCase,max:e.max,strength:e.strength,mode:e.mode,force:e.force,resume:e.resume,plan:e.plan,message:e.message,phase:e.phase,allowUnreviewed:e.allowUnreviewed,because:e.because,changeDelta:e.changeDelta,priorDesign:e.priorDesign}}async function B(e){let p=async(t,r)=>{if(e.mode!=="agent")return process.stderr.write(t+`
|
|
3
3
|
`),2;let{makeHeadlessIO:s,agentRefusal:d}=await import("./headless-io-66RG5NN5.js");return d(s("ndjson","design"),t,r)};if(e.mode!=null&&!["interactive","agent","ci","override"].includes(e.mode)){let{makeHeadlessIO:t,agentRefusal:r}=await import("./headless-io-66RG5NN5.js");return r(t("ndjson","design"),`design: --mode must be interactive | agent | ci | override, got '${e.mode}'`,"MODE_USAGE")}let T=H(e);if("error"in T)return p(T.error);let o=T;{let{validateResumeMessage:t}=await import("./headless-io-66RG5NN5.js"),r=t(o,"design");if(r)return p(r)}{let{gateStructuredFlags:t}=await import("./structured-answers-5EY2AZN7.js"),r=t(e,"design");if(r)return p(r,"STRUCTURED_FLAGS_USAGE")}if(!O(m(process.cwd())))return p("error: no context store here (run `kane-cli context ingest` + `kane-cli context extract` first)","NO_STORE");let y=!!o.resume;if(o.useCase&&o.resume&&!e.allowUnreviewed)try{let{peekSession:t}=await import("./sessions-GIEXOCE4.js"),r=t(m(process.cwd()),o.resume);y=!!(r&&r.use_case===o.useCase)}catch{y=!1}if(o.useCase&&!y&&!e.allowUnreviewed)try{let[{openGraph:t},{designEntryCheck:r}]=await Promise.all([import("./readmodel-XOYGGQ3S.js"),import("./trust-gate-EX7R2P4Y.js")]),s=r(t(m(process.cwd())),o.useCase);if(!s.ok&&(s.code==="UC_UNREVIEWED"||s.code==="UC_ARCHIVED"))if((o.mode??"interactive")==="interactive"&&process.stdin.isTTY&&process.stdout.isTTY){let{createInterface:l}=await import("readline/promises"),c=l({input:process.stdin,output:process.stderr}),f=(await c.question(`design: ${s.detail}
|
|
4
4
|
Design against it anyway? (y/N) `)).trim().toLowerCase();if(c.close(),f!=="y"&&f!=="yes")return process.stderr.write(`aborted \u2014 approve it first: ${s.reviewCmd}
|
|
5
5
|
`),2}else if(e.mode==="agent"){let{makeHeadlessIO:l}=await import("./headless-io-66RG5NN5.js"),c=l("ndjson","design");return c.event({type:"error",code:s.code,message:`design: ${s.detail}`,next:[s.reviewCmd]}),c.event({type:"done",status:"refused",exit_code:2,next:[s.reviewCmd,`kane-cli design tests --use-case ${o.useCase} --mode agent --allow-unreviewed`]}),2}else return process.stderr.write(`design: ${s.detail} (${s.reviewCmd})
|
|
6
6
|
`),2}catch(t){process.env.KANE_DEBUG&&process.stderr.write(`trust gate skipped: ${String(t)}
|
|
7
7
|
`)}let i=null,x=null;try{if(!o.mode&&!process.stdin.isTTY)return process.stderr.write(`design: no TTY \u2014 pass an explicit --mode agent|ci|override to run headless
|
|
8
8
|
`),2;let t=o.mode??"interactive";if(t==="interactive"){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stderr.write(`design: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
9
|
-
`),2;let{bindDesignInteractive:n}=await import("./interactive-bind-
|
|
9
|
+
`),2;let{bindDesignInteractive:n}=await import("./interactive-bind-Y65XV4Y5.js");return await n(o)}let{resolveAgentAuthEnv:r}=await import("./spawner-DQZRJIE6.js"),{runAgent:s}=await import("./bridge-QDPBIIOW.js"),{preflightTurn:d}=await import("./turn-preflight-JGYT7LXP.js"),{makeInterruptGuard:l}=await import("./interrupt-guard-UREUWNRL.js"),{baseUrlAdvisory:c}=await import("./turn-preflight-JGYT7LXP.js"),{makeHeadlessIO:f,resolveEncoding:D,guardedChannels:R}=await import("./headless-io-66RG5NN5.js"),{withStructuredNext:A,prepareStructuredResume:U}=await import("./structured-answers-5EY2AZN7.js");i=A(f(D(t),"design"));let{runWithChannel:$}=await import("./run-channel-RGH4WIQX.js"),w=i,I=D(t)==="ndjson"?n=>$({event:g=>w.event(g)},n):n=>n(),E=n=>{w.out(n),w.event({type:"note",text:n})},{telemetryBootstrap:N,telemetryEnvName:G}=await import("./bootstrap-RUJBMB2P.js"),u=N({verb:"design",mode:t,contextRoot:m(process.cwd()),env:G(),resumeSid:o.resume,write:!0,longSession:!0});x=n=>u.end(n);let a=U({opts:e,contextDir:m(process.cwd()),verb:"design"});if(a.kind==="refuse")return i.out(a.error),t==="agent"&&i.event({type:"error",message:a.error,code:a.code}),await u.end({exit_code:2}),t==="agent"?i.done(2,"refused"):2;let C;if(a.kind==="apply"){for(let n of a.notes)E(n);if(a.matchedQids.length>0){E(`applying ${a.matchedQids.length} structured answer(s) from --answer to the paused session's pending questions`);for(let n of a.matchedQids)i.event({type:"panel_resolved",id:n,by:"user",via:"flag"})}a.statement&&(C=[o.message,a.statement].filter(Boolean).join(`
|
|
10
10
|
|
|
11
11
|
`))}let b=c();b&&E(b);let v=l(s,n=>i.out(n)),k=R(i,()=>v.interrupted(),/^error: (design agent failed|the design agent ended)/);try{let n=t==="interactive"&&process.stdin.isTTY&&process.stdout.isTTY?async h=>{let{createInterface:Y}=await import("readline/promises"),S=Y({input:process.stdin,output:process.stdout});try{return/^y(es)?$/i.test((await S.question(`${h} [y/N] `)).trim())}finally{S.close()}}:void 0,g=await I(async()=>{let h={...await r(),...u.spawnEnv()};return _({...o,mode:t,...C!==void 0?{message:C}:{},...n?{confirmRetarget:n}:{}},{contextDir:m(process.cwd()),agent:v.agent,preflightTurn:()=>d(h),ask:async()=>[],out:k.out,emit:k.emit,progress:w.progress,isTTY:!1,auth:h,telemetry:u})});return v.interrupted()&&g!==3?(i.out("interrupted \u2014 no session saved"),await u.end({exit_code:130}),i.done(130)):(g===1&&i.out(u.supportFooter()),await u.end({exit_code:g}),i.done(g))}finally{v.dispose()}}catch(t){x&&await x({exit_code:1}).catch(()=>{});let r=t instanceof Error?t.message:String(t);i?.event({type:"error",message:`error: design failed: ${r}`});let s=i?d=>i.out(d):d=>process.stderr.write(d+`
|
|
12
12
|
`);return s(`error: design failed: ${r}`),(process.env.ASSURANCE_LOG_LEVEL??"").toLowerCase()==="debug"&&t instanceof Error&&t.stack&&s(t.stack),s('hint: the full trace is in the file named on the "trace:" line at the start of this run'),i?i.done(1):1}}export{B as designTestsCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b}from"./chunk-LDCLZR2U.js";import"./chunk-R5T4RLF5.js";import"./chunk-KBM3XHAM.js";import"./chunk-2YEHV2CX.js";import"./chunk-IDX3TOPY.js";import"./chunk-BKM2LWU2.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-7F2ZV46B.js";import"./chunk-UR6MHSHU.js";export{b as telemetryBootstrap,a as telemetryEnvName};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-MTIC65NK.js";import"./chunk-WQPQNL4S.js";import"./chunk-4U4OSOA4.js";import"./chunk-UD7KKHPW.js";import"./chunk-7F2ZV46B.js";import"./chunk-UR6MHSHU.js";export{a as runAgent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-RZ4F3BHX.js";import{c as i,g as c}from"./chunk-
|
|
2
|
+
import{a as l}from"./chunk-RZ4F3BHX.js";import{c as i,g as c}from"./chunk-7F2ZV46B.js";import"./chunk-UR6MHSHU.js";import{readFileSync as u,writeFileSync as g,mkdirSync as d}from"fs";import{join as f}from"path";var h=f(i,"changelog-cache.json"),p=3600*1e3;function y(){try{let e=JSON.parse(u(h,"utf-8"));if(Date.now()-e.cachedAt<p)return e}catch{}return null}function m(e){try{d(i,{recursive:!0}),g(h,JSON.stringify({entries:e,cachedAt:Date.now()}))}catch{}}async function A(e){try{let t=y();if(t){let r=t.entries;return e?.all?r:r.slice(0,5)}let n=new AbortController,o=setTimeout(()=>n.abort(),5e3),a=await l(`${c}?per_page=30`,{headers:{Accept:"application/vnd.github+json"},signal:n.signal});if(clearTimeout(o),!a.ok)return[];let s=(await a.json()).map(r=>({version:r.tag_name.replace(/^v/,""),date:r.published_at?r.published_at.slice(0,10):"",body:r.body??""}));return m(s),e?.all?s:s.slice(0,5)}catch{return[]}}function v(e){if(e.length===0)return"Could not fetch changelog. Visit https://github.com/LambdaTest/kane-cli/releases";let t=["kane-cli Changelog","\u2500".repeat(40),""];for(let n of e){if(t.push(`v${n.version} (${n.date})`),n.body){let o=n.body.split(`
|
|
3
3
|
`).filter(a=>a.trim());for(let a of o)t.push(` ${a}`)}t.push("")}return t.join(`
|
|
4
4
|
`)}export{A as fetchChangelog,v as formatChangelog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-LQQXPY5B.js";import"./chunk-AXTPNZPX.js";import"./chunk-L2TV4G56.js";import"./chunk-6KPPGMO2.js";import"./chunk-NVGBE2DR.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{c as makeChatController,b as questionStub,a as recommendationPicks};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as jt}from"./chunk-ZMNJBUAO.js";import{f as tr}from"./chunk-W5TTF7GB.js";import{a as Bt}from"./chunk-I7TIGB7K.js";import{a as te,c as Yt,e as Zt,f as qe,g as Qt,h as nr}from"./chunk-RN4PKQFR.js";import{a as Xt,b as rr,c as sr,d as ir,e as dt,f as or}from"./chunk-ZGBSGZZM.js";import{a as ke,b as qt,c as Gt,d as Lt,e as Vt}from"./chunk-7S3JZ6FQ.js";import{a as zt}from"./chunk-L2TV4G56.js";import{a as Kt,b as Jt}from"./chunk-JFAFKHDX.js";import{c as Wt}from"./chunk-6KPPGMO2.js";import{a as Nt,e as Ht}from"./chunk-GFKCTYCA.js";import{b as Ft}from"./chunk-YKTYVJBN.js";import{a as er}from"./chunk-IMR64OCZ.js";import{e as Ut}from"./chunk-WQPQNL4S.js";import{a as Fe}from"./chunk-4U4OSOA4.js";import{d as Mt}from"./chunk-W4B5LOEX.js";import{a as $e,b as ct}from"./chunk-DNNZ353O.js";import{a as Se}from"./chunk-NVGBE2DR.js";import{b as nt}from"./chunk-IDX3TOPY.js";import{A as ee,k as be,o as Be}from"./chunk-TH47OOBV.js";import{f as It}from"./chunk-DUAXZYAD.js";import{e as at}from"./chunk-DBIBROYW.js";import{d as me}from"./chunk-WXHQYYD5.js";import{b as Ot}from"./chunk-IAHKTEET.js";import{a as At}from"./chunk-5EOX4MEY.js";import{appendFileSync as wr,mkdirSync as ut,rmdirSync as br,writeFileSync as lt}from"fs";import{dirname as mr,extname as Sr,join as ce}from"path";var X=class extends Error{code;constructor(e,a){super(`${e}: ${a}`),this.name="ProposalAdapterError",this.code=e}};function cr(r){return r.version===2}var ar=8;function vr(r){let e=/^extract@(\d+)$/.exec(r??"");return e?Number.parseInt(e[1],10):null}var yr=r=>typeof r=="object"&&r!==null&&"op"in r;function Ge(r,e,a){return{anchor:r.anchor,quote:r.quote,...a||r.source_id!==e?{source_id:r.source_id}:{}}}function dr(r,e,a={}){let m=vr(a.templateVersion),x=m!==null&&m>=5,_=m!==null&&m<5,y=r.archived!=null&&r.archived.length>0&&m!==null&&m<5;if(y&&a.warn?.(`dropped ${r.archived.length} archive op(s): the bound extract template @${m} never described archiving \u2014 nothing was archived; the use-cases still land`),!x&&r.read_basis.length!==1)throw new X("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${r.read_basis.length}`);if(r.read_basis.length===0)throw new X("READ_BASIS_COUNT","read_basis must not be empty");let v=r.read_basis[0],h=r.read_basis.length>1,$=r.use_cases.map(i=>{if(_&&i.cite.length!==1)throw new X("CITE_COUNT",`${i.temp_ref}: cite must have exactly 1 element, got ${i.cite.length}`);if(i.cite.length<1||i.cite.length>ar)throw new X("CITE_COUNT",`${i.temp_ref}: 1..${ar} cites allowed, got ${i.cite.length}`);let M=(f,re)=>{if(!x&&f!==v.source_id)throw new X("SOURCE_MISMATCH",`${re}: cite source ${f} != read_basis source ${v.source_id} (single-source)`)};M(i.cite[0].source_id,i.temp_ref);let P=i.cite.map(f=>(M(f.source_id,i.temp_ref),Ge(f,v.source_id,x&&(h||f.source_id!==v.source_id)))),l=(i.updated?.criteria??[]).some(yr);if(!x&&l)throw new X("CRITERIA_OPS_UNSUPPORTED",`${i.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${a.templateVersion??"an unversioned template"}`);return{temp_ref:i.temp_ref,title:i.title,...i.description!==void 0?{description:i.description}:{},...i.summary!==void 0?{summary:i.summary}:{},...i.actors!==void 0?{actors:i.actors}:{},...i.value!==void 0?{value:i.value}:{},risk:i.risk,cite:P[0],...P.length>1?{cites:P}:{},...i.criteria!=null&&i.criteria.length>0?{criteria:i.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{},depends_on_hint:i.depends_on_hint,matches_existing:i.matches_existing,...i.conflicts_with!=null?{conflicts_with:i.conflicts_with}:{},...i.changed?{changed:!0}:{},...i.updated!=null?{updated:{...i.updated.title!=null?{title:i.updated.title}:{},...i.updated.description!=null?{description:i.updated.description}:{},...i.updated.summary!=null?{summary:i.updated.summary}:{},...i.updated.actors!=null?{actors:i.updated.actors}:{},...i.updated.value!=null?{value:i.updated.value}:{},...i.updated.risk!=null?{risk:i.updated.risk}:{},...i.updated.criteria!=null?{criteria:l?i.updated.criteria.map(f=>f.op==="set"?{op:"set",text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}:f.op==="keep"?{op:"keep",ref:f.ref,text:f.text}:{op:"remove",ref:f.ref,text:f.text,reason:f.reason}):i.updated.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.updated.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{}}}:{},...i.change_note!=null?{change_note:i.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:v.source_id,source_cid:v.source_cid},use_cases:$,...h?{sources:r.read_basis.map(i=>({source_id:i.source_id,source_cid:i.source_cid}))}:{},...r.extraction_of!=null&&r.extraction_of.length>0?{extraction_claims:r.extraction_of.map(i=>({source_id:i.source_id,completeness:i.completeness}))}:{},...r.archived!=null&&r.archived.length>0&&!y?{archived:r.archived.map(i=>({target:i.target,reason:i.reason,basis:i.basis}))}:{}}}function ur(r){let{contextDir:e,graph:a}=r,m=r.maxDigestBytes??4096,x={},_=[];for(let[h,$]of a.heads){if(x[h]=$,typeof $!="string")continue;let i=a.mediaOf($),M=a.getNode($)?.content?.blob;if(typeof M=="string")if(i.format==="image")_.push({source_id:h,cid:$,format:"image",blobRef:{path:Se(e,M),cid:M}});else{let P=$e(e,a,$)?.toString("utf8")??"";_.push({source_id:h,cid:$,format:i.format,text:P})}}_.sort((h,$)=>h.source_id<$.source_id?-1:1);let y=[];for(let h of a.byLabel(me.STYLENOTE).sort(($,i)=>$.cid<i.cid?-1:1))a.superseded.has(h.cid)||y.push(`\u2022 ${String(h.content.statement)} [${String(h.content.learned_from_kind)}]`);let v="";for(let h of y){if(Buffer.byteLength(v+h+`
|
|
3
|
+
`,"utf8")>m)break;v+=h+`
|
|
4
|
+
`}return{read_basis:x,sources:_,styleNoteDigest:v}}function lr(r,e){let a=ur({contextDir:r,graph:e}).styleNoteDigest;return a.length>0?a:void 0}function mt(r,e,a,m,x){let _=null,y=()=>_??=x&&Object.keys(x).length>0?Promise.resolve(x):Ut().catch(()=>({}));return{contextDir:r,rootSid:e,locks:at(r,e),probe:m??Bt(r,{resolveAlias:async v=>qt(v,{env:process.env,auth:await y()}),embed:async(v,h)=>Gt(v,h,{env:process.env,auth:await y()}),readVector:(v,h)=>Lt(r,v,h),writeVector:(v,h,$)=>Vt(r,v,h,$)}),...a?.length?{reservedEventIds:a}:{}}}function ht(r,e){let a=[],m=[];for(let x of r.use_cases){let _=x.matches_existing;_?.cid&&e.hasNode(_.cid)?a.push({ref:_.cid,expectedTip:e.tipOf(_.cid)}):m.push({tempRef:x.temp_ref,title:String(x.title??""),probeText:String(x.title??"")})}return{verb:"extract",ucTargets:a,newBuCandidates:m,sourcePins:[{source_id:r.source.source_id,source_cid:r.source.source_cid}],readBasis:r.read_basis??null}}function $r(r,e){let a=(r.images??[]).filter(m=>m.delivery==="selected");if(a.length!==0)return a.map(m=>({ref:m.ref,...m.page!==void 0?{page:m.page}:{},...m.loc!==void 0?{loc:m.loc}:{},media_type:m.media_type,blob_ref:{path:Se(e,m.blob),cid:m.blob}}))}function kr(r){return r.length>8&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71?"image/png":r.length>3&&r[0]===255&&r[1]===216&&r[2]===255?"image/jpeg":r.length>12&&r.toString("ascii",0,4)==="RIFF"&&r.toString("ascii",8,12)==="WEBP"?"image/webp":null}function Le(r){return r.toISOString().replace(/[-:]/g,"").slice(0,15)}function hr(r){return r.startsWith("su-conv-")?`conv-${Ot(Buffer.from(r,"utf8")).slice(0,8)}`:r}function pr(r){return r.source_id.startsWith("su-conv-")?"the conversation":r.source_id}function Rr(r,e,a){return`reading ${pr(r)}${a>1?` (source ${e} of ${a})`:""}`}function Re(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function gr(r,e){let a=new Map,m=new Map,x=new Map;for(let{cid:y,content:v}of e.byLabel(me.USECASE)){if(e.superseded.has(y))continue;(e.trust.get(y)==="archived"?x:m).set(Re(String(v.title??"")),y)}let _=y=>e.trust.get(y)==="archived"?{cid:y,archived:!0,reason:e.archivedReason.get(y)}:{cid:y};for(let y of r.use_cases){if(y.matches_existing){let $=y.matches_existing.cid;if(e.superseded.has($)){let i=e.tipOf($);$=e.superseded.has(i)?null:i}if($!==null){a.set(y.temp_ref,_($));continue}}let v=m.get(Re(y.title));if(v){a.set(y.temp_ref,{cid:v});continue}let h=x.get(Re(y.title));h&&a.set(y.temp_ref,_(h))}return a}var fr=/^(\S+)\.criteria\[(\d+)\]/;function Cr(r,e,a){if(e.length===0||!e.every(x=>fr.test(x.detail)))return!1;let m=new Map;for(let x of e){let _=fr.exec(x.detail),y=m.get(_[1])??new Set;y.add(Number(_[2])),m.set(_[1],y)}for(let x of r.use_cases){let _=m.get(x.temp_ref);_?.size&&(x.criteria=(x.criteria??[]).filter((y,v)=>!_.has(v)),a(`${x.temp_ref}: dropped ${_.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function gt(r,e,a,m,x=()=>{},_,y){let v=(h,$)=>x(h,$,r.session_id);return Zt(r,e,a,m,x,{async onProposalEvent(h){let $=h,i=null,M=null;if(cr($))try{i=dr($,r.read_basis,{templateVersion:y?.()??null,warn:P=>{e.out(`warning: ${P}`),v("adapter",{warn:P})}}),v("adapter",{ok:!0,use_cases:i.use_cases.length})}catch(P){M=P instanceof X?P.message:String(P),v("adapter",{ok:!1,error:M})}else i=$;return i&&i.use_cases.length===0&&(e.out("warning: the agent proposed ZERO use-cases for this source"),e.emit?.({type:"warning",code:"ZERO_USE_CASES",message:"the agent proposed ZERO use-cases for this source"})),i&&_&&await _(i),{proposal:i,error:M}}})}var Dr=new Set(["agent","ci","override"]);async function Ss(r,e){let a=`ext-${Le(e.now?.()??new Date)}-lk${Math.random().toString(36).slice(2,8)}`,x=at(e.contextDir,a,e.now?{now:e.now}:void 0).tryAcquire([{kind:"extract"}],{hold:"session",verb:"extract"});if("contended"in x){let _=x.contended.holder,y=`another extraction is running on this context${_?` (pid ${_.pid})`:""} \u2014 retry when it finishes`;return e.out(y),e.emit?.({type:"error",message:y,code:"EXTRACT_LOCKED"}),2}try{return await Er(r,e)}finally{x.release()}}async function Er(r,e){let a=r.mode??"interactive";if(r.posture==="reconcile"){if(r.trust==="hold"){let o="error: --trust hold has no meaning here \u2014 a reconcile IS the review; drop the flag";return e.out(`${o} [TRUST_USAGE]`),e.emit?.({type:"error",message:o,code:"TRUST_USAGE"}),2}if(!r.source||!r.changeContext){let o="reconcile posture needs a pinned source and its change context \u2014 internal wiring fault";return e.out(`error: ${o}`),e.emit?.({type:"error",message:o,code:"POSTURE_USAGE"}),2}if(a==="ci"){let o="reconcile posture is not available under --mode ci \u2014 a held changeset needs a durable session; use --mode agent";return e.out(`error: ${o}`),e.emit?.({type:"error",message:o,code:"POSTURE_USAGE"}),2}}if(r.trust==="hold"&&a==="interactive")return e.out("error: --trust hold only applies to headless runs \u2014 in interactive chat you review items in-session anyway; use --mode agent to hold everything for review"),e.emit?.({type:"error",message:"error: --trust hold only applies to headless runs \u2014 use --mode agent",code:"TRUST_USAGE"}),2;if(a==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!Dr.has(a))return e.out(`extract: unknown mode "${a}" \u2014 interactive | agent | ci | override`),2;if(r.trust!==void 0){if(a==="ci")return e.out("error: --trust is not available under --mode ci (ci is fail-closed \u2014 no trust dials)"),e.emit?.({type:"error",message:"error: --trust is not available under --mode ci",code:"TRUST_UNDER_CI"}),2;if(r.trust!=="auto"&&r.trust!=="hold")return e.out(`error: --trust must be auto | hold, got '${r.trust}'`),e.emit?.({type:"error",message:`error: --trust must be auto | hold, got '${r.trust}'`,code:"TRUST_USAGE"}),2}let m=e.telemetry?.enabled?e.telemetry:void 0,x=Le(e.now?.()??new Date),_=m?At(m.ids.context_instance_id??null,"extract",m.ids.session_id):ce(e.contextDir,"logs",`extract-${x}.log`);ut(mr(_),{recursive:!0});let y=`run-${x}-${Math.random().toString(36).slice(2,8)}`,v=o=>o==="error"||o==="failed_proposal"?"error":o==="repair_respawn"?"warn":"info",h=(o,u,s)=>{try{wr(_,JSON.stringify({ts:new Date().toISOString(),level:v(o),run_id:y,...m?{user_session_id:m.ids.session_id}:{},...s?{session_id:s}:{},kind:o,data:u})+`
|
|
5
|
+
`)}catch{}m?.wireTrace(o,u,s)};{let o=e.out;e.out=u=>{h("transcript",{line:u}),o(u)}}e.chat||e.out(`trace: ${te(_)}`),e.emit?.({type:"run_start",mode:a,trace:_,...m?{session:m.ids.session_id}:{}});let $=Ft();if($&&e.out($),e.preflightTurn){let o=await e.preflightTurn();if(h("preflight",o),!o.ok)return e.out(o.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:o.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let i=ee(e.contextDir),M=lr(e.contextDir,i),P=r.sources?.length?r.sources:r.source?[r.source]:[];if(P.length>0){if(r.resume){let o="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(o),e.emit?.({type:"error",message:o,code:"SOURCE_WITH_RESUME"}),2}for(let o of P){let u=i.heads.get(o);if(typeof u!="string"){let s=u===null?`error: --source ${o} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${o} is not an ingested source (kane-cli context list shows them)`;return e.out(s),e.emit?.({type:"error",message:s,code:"SOURCE_UNKNOWN"}),2}}}let l=null,f=null;if(r.resume){try{{let c=await or(e.contextDir,r.resume,i,{verb:"extract",deps:{onWarn:C=>e.out(`note: ${C}`)}});{let C=Object.keys(c.handle.state.read_basis??{});if(C.length>1){let B=`error: session ${r.resume} spans ${C.length} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (re-run kane-cli context extract for anything remaining)`;return e.out(B),e.emit?.({type:"error",message:B,code:"MULTI_SOURCE_RESUME"}),c.handle.release(),2}f=c,h("resume_kind",{kind:c.view.pointer===null?"bare-base":c.view.pointer.at==="final"?"pause":"crash"}),l={handle:c.handle,represent:c.represent,questions:c.questions,staleBasis:c.drift.map(B=>B.subject)}}}}catch(c){let C=c instanceof Error?c.message:String(c);return e.out(`error: ${C}`),e.emit?.({type:"error",message:`error: ${C}`,...c instanceof dt?{code:c.code}:{}}),c instanceof dt?2:1}let o=f?null:Xt(l.handle.state.verb,"extract",r.resume);if(o)return e.out(o.message),e.emit?.({type:"error",message:o.message,code:o.code}),l.handle.release(),2;let u=l.handle.state.change_basis;if(u&&(i.heads.get(u.source_id)??null)!==u.new_head){let c=`error: ${u.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 ${r.resume} is defunct and can be ignored)`;return e.out(c),e.emit?.({type:"error",message:c,code:"CHANGE_BASIS_MOVED"}),l.handle.release(),2}if(f&&f.view.pointer!==null&&f.drift.length>0){if(!await e.confirmStale(`changed since the pause: ${f.drift.map(C=>C.subject).join(", ")} \u2014 re-ground and continue against the current versions?`)){let C=`resume aborted: the context moved since the pause (${f.drift.map(B=>B.subject).join(", ")}) \u2014 session ${r.resume} is preserved`;return e.out(C),e.emit?.({type:"error",message:C,code:"RESUME_DRIFT"}),l.handle.release(),2}}else l.staleBasis.length>0&&e.out(`note: changed since the pause: ${l.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let s=[...new Set([...l.handle.state.held_receipts??[],...f?.view.kane?.held_receipts??[]])];if(s.length>0)if(e.chat?.holdReceipt)for(let c of s)e.chat.holdReceipt(c);else e={...e,initialMessage:[s.join(`
|
|
6
|
+
|
|
7
|
+
`),e.initialMessage].filter(Boolean).join(`
|
|
8
|
+
|
|
9
|
+
`)};l.handle.state.assumed.length>0&&e.out(`note: ${l.handle.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${r.resume} lists them`)}let re=i.extractedSourceCids,he=!!(r.force||l?.handle.state.force),se=[],oe=[],Ce=P.length>0?new Set(P):null;for(let[o,u]of i.heads.entries())if(u!=null&&!(Ce&&!Ce.has(o))){if(!Ce&&!l&&o.startsWith("su-conv-")){e.out(`skipped ${o} \u2014 conversation source; extract it explicitly with --source ${o}`),oe.push({source_id:o,reason:"conversation"});continue}if(l){let s=o in l.handle.state.read_basis,c=l.handle.state.corpus_cursor.remaining.includes(o);if(!s&&!c)continue;if(c&&!he&&re.has(u)){e.out(`${o} already extracted \u2014 skipped (--force re-runs it)`),oe.push({source_id:o,reason:"cached"});continue}}else if(!he&&re.has(u)){e.out(`${o} already extracted \u2014 skipped (--force re-runs it)`),oe.push({source_id:o,reason:"cached"});continue}se.push({source_id:o,cid:u})}let _r=o=>{let u=tr(e.contextDir,o);u&&e.out(`note: a reconcile plan for ${o} is pending (${u.pending} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${u.path}\``)};for(let o of oe)o.reason==="cached"&&_r(o.source_id);if(e.emit?.({type:"corpus",sources:se,skipped:oe}),se.length===0){if(l){let s=`error: resumed session's paused source (${Object.keys(l.handle.state.read_basis).join(", ")||"unknown"}) is no longer in the corpus \u2014 restore/re-ingest it and re-run --resume ${r.resume}, or discard with: kane-cli context sessions clean ${r.resume}`;return e.out(s),e.emit?.({type:"error",message:s,code:"SOURCE_MISSING"}),l.handle.release(),2}let o=oe.length>0&&oe.every(u=>u.reason==="conversation");return e.out(Ce?`extract: nothing to do \u2014 ${P.join(", ")} ${P.length===1?"is":"are all"} already extracted at the current snapshot (--force to re-run)`:o?"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 ie=!r.plan&&a!=="ci",De=e.now?.()??new Date,Ee=r.resume??`ext-${Le(De)}-${hr(se[0].source_id)}`,T=null,Pe=!1;ie&&!l&&(T=nt(e.contextDir,{sid:Ee,mode:"agent",created_at:De.toISOString(),expires_at:new Date(De.getTime()+1440*60*1e3).toISOString(),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},assumed:[],read_basis:{[se[0].source_id]:se[0].cid},corpus_cursor:{remaining:se.slice(1).map(o=>o.source_id)},conv_source:"",verb:"extract",...he?{force:!0}:{},...r.changeContext?{change_basis:{source_id:r.changeContext.source_id,new_head:r.changeContext.new_head}}:{},...m?{user_session_id:m.ids.session_id}:{}}));let Ve=f?f.represent.map(o=>o.event_id).filter(o=>typeof o=="string"):[],S=l?.handle??T,ft=!1,pt=()=>{try{br(ce(e.contextDir,"sessions"))}catch{}},_t=()=>{if(T){try{T.complete()}catch{T.release()}T=null,S=null,pt()}},Te=new Map;if(l&&l.questions.length>0&&!r.message&&!r.withSource){e.out(`re-presenting ${l.questions.length} unanswered question(s) from the paused session`);let o=await e.ask(l.questions.map(rr));if(Array.isArray(o))for(let u of o)Te.set(u.id,u)}let ge=e.by??{kind:"human",id:"owner"},I=a==="interactive"&&!r.plan&&!!e.chat,Y=0,xt=0,Ae=!1,de=0,We=()=>{Ae||(Ae=!0,e.out("note: duplicate detection is running in a reduced mode this run \u2014 new items will be held for your review instead of committed"),m?.event("ASR_EMBED_DEGRADED",{}),e.emit?.({type:"degraded",reason:"embed_fallback"}))},Oe=null,fe=()=>S??T,ze=(o,u,s)=>{let c=fe();if(!c)return;let C=u.map(w=>({label:"usecase",content:{title:w.title,...w.summary!==void 0?{summary:w.summary}:{},...w.risk!==void 0?{risk:w.risk}:{},derived:!0,_held:{source_id:o.source_id,source_cid:o.cid,anchor:w.cite?.anchor??"L1-L1",quote:w.cite?.quote??""}},rationale:`held (${s==="degraded"?"embed degraded \u2014 lexical dedup only":"--trust hold"}): ${o.source_id} @ ${o.cid.slice(0,19)} ${w.cite?.anchor??""}`,edges:[],tempRef:w.temp_ref})),B=c.state.pending;c.save({pending:{questions:B.questions,proposals:[...B.proposals,...C]}}),de+=C.length,Oe=c.state.sid,e.emit?.({type:"held",source_id:o.source_id,count:C.length,reason:s==="degraded"?"embed_degraded":"trust_hold"})},q=[],vt=!1,U=[...se];try{let o=u=>{let s=S;if(!s)return;let c=s.state.ingest_schedule??[];if(!c.some(w=>w.status==="pending"))return;let C=ee(e.contextDir),B=c.map(w=>w.status!=="pending"?w:(C.heads.get(w.source_id)??null)!==w.cid?(e.out(`note: ${w.source_id} changed after it was added \u2014 skipping its extraction this run; re-run kane-cli context extract to pick up the newer version`),{...w,status:"skipped",note:"head moved since landing"}):C.extractedSourceCids.has(w.cid)||U.some(W=>W.source_id===w.source_id&&W.cid===w.cid)?{...w,status:"done"}:U.some(W=>W.source_id===w.source_id)?(e.out(`note: an older version of ${w.source_id} is already queued this run \u2014 the newly landed version is not extracted; re-run kane-cli context extract to pick it up`),{...w,status:"skipped",note:"an older version of the source was already queued this run"}):(U.push({source_id:w.source_id,cid:w.cid}),e.out(`queued ${w.source_id} for extraction in this run (landed mid-run)`),{...w,status:"done"}));s.save({ingest_schedule:B,corpus_cursor:{remaining:U.slice(u+1).map(w=>w.source_id)}})};for(let u=0;u<U.length;o(u),u++){let s=U[u],c=ee(e.contextDir),C={current:c};e.chat?.attachOnCommitted?.(t=>{C.current=t});let B=c.getNode(s.cid),w=String(B?.content.blob??""),Ie=$e(e.contextDir,c,s.cid);if(!Ie){e.out(`error: ${s.source_id}: its stored content is missing \u2014 re-ingest the file (kane-cli context ingest <file>) [BLOB_MISSING]`),e.emit?.({type:"error",source_id:s.source_id,message:`error: ${s.source_id}: blob ${w} missing from .context/blobs`,code:"BLOB_MISSING"}),q.push(s.source_id);continue}let W=c.mediaOf(s.cid),Ke=W.media_type.startsWith("image/");if(!Ke){let t=kr(Ie);if(t){e.out(`skipping ${s.source_id}: binary ${t} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`),e.emit?.({type:"source_skipped",source_id:s.source_id,reason:"binary_pre_media"});continue}}let yt=Ke?`0001| (image source ${s.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:ct(Ie),Me=(t,n)=>{let d=new Map;d.set(s.source_id,{media:W,numberedText:yt});for(let g of n.sources??[]){if(d.has(g.source_id))continue;let D=$e(e.contextDir,t,g.source_cid);if(!D)continue;let k=t.mediaOf(g.source_cid),E=k.media_type.startsWith("image/")?`0001| (image source ${g.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:ct(D);d.set(g.source_id,{media:k,numberedText:E})}return d},wt=Le(e.now?.()??new Date),ne=`${wt}-${s.source_id}`,pe=!!(l&&s.source_id in l.handle.state.read_basis),Ue=S?Ee:`ext-${wt}-${hr(s.source_id)}`,Je=U.slice(u+1).map(t=>t.source_id);S&&ie&&!pe&&S.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:Je}});let ae="";if(I){let t=Wt({contextDir:e.contextDir,graph:ee(e.contextDir),sessionStamp:Ue,by:ge});t.errors===null||t.errors[0]?.code==="CONV_SOURCE_EXISTS"?(ae=t.sourceId,e.chat.attachConversationSource?.(ae),C.current=ee(e.contextDir)):e.out(`warning: notes you add in chat can't be saved to the context this session (${t.errors[0]?.detail})`)}let bt={type:"run_config",version:1,session_id:Ue,mode:a,source:{source_id:s.source_id,source_cid:s.cid,kind:Mt.has(W.format)?W.format:Sr(s.source_id)||"md",numbered_text:yt,...(()=>{let t=$r(W,e.contextDir);return t?{images:t}:{}})()},existing_use_cases:c.byLabel(me.USECASE).filter(({cid:t})=>c.trust.get(t)!=="archived"&&!c.superseded.has(t)).map(({cid:t,content:n})=>({id:t,title:String(n.title??""),summary:String(n.summary??"")})),read_basis:C.current.latestHash,max_free_text_rounds:Yt,graph_reads:!0,verb:"extract",...M!==void 0?{style_note_digest:M}:{},...r.changeContext&&r.changeContext.source_id===s.source_id?{change_context:r.changeContext}:{},topology:er(),...I?{chat:!0}:{},...Ke?{image_sources:[{source_id:s.source_id,source_cid:s.cid,media_type:W.media_type,blob_ref:{path:Se(e.contextDir,w),cid:w}}]}:{},...l&&!f&&s.source_id in l.handle.state.read_basis?{resume:{agent_state:l.handle.state.agent_state}}:{},...ie&&S?{checkpoints:!0}:{}},R=f&&pe?{...f.spawnConfig,mode:a}:bt;if(ie&&S&&!ft){ft=!0;let{resume:t,...n}=bt;Ht(e.contextDir,Ee,{schema:Nt,kind:"base",sid:Ee,verb:"extract",mode:a,created_at:De.toISOString(),run_config:n,conv_source:ae||S.state.conv_source||"",store_watermark:It(e.contextDir)})}let St=f&&pe?0:S?.state.checkpoint?.seq??0,_e={current:null};if(R.resume&&"schema"in R.resume){let t=R.resume.binding?.template_version;typeof t=="string"&&(_e.current=t)}let Xe=ie&&S?ir({contextDir:e.contextDir,handle:S,seqBase:()=>St,peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>({[s.source_id]:s.cid}),corpusCursor:()=>({remaining:Je}),onSoftCap:t=>e.out(t),onStat:t=>h("ckpt_stat",t,R.session_id),...e.now?{now:e.now}:{}}):void 0,ue=Xe?{...Xe,persist:t=>{let n=t.binding?.template_version;return typeof n=="string"&&n&&(_e.current=n),Xe.persist(t)}}:void 0;I||e.out(l&&s.source_id in l.handle.state.read_basis?`resuming: ${s.source_id} (session ${r.resume})`:`reading ${s.source_id} (source ${u+1} of ${U.length})`),e.emit?.({type:"source_start",source_id:s.source_id,cid:s.cid,index:u+1,total:U.length,resumed:!!(l&&s.source_id in l.handle.state.read_basis)}),e.chat?.ledger?.({kind:"banner",text:Rr(s,u+1,U.length)}),e.chat?.setWorking?.(`Reading ${pr(s)}\u2026`);let Ye=new Map;h("spawn",{source_id:s.source_id,source_cid:s.cid,resume:!!l,chat:I},R.session_id);let $t=!1,kt=!1,Ze=!1,Rt=async t=>{let n=ee(e.contextDir),d=be(t,Me(n,t),n);if(h("kane_validate",{errors:d.map(p=>p.code)},R.session_id),d.length>0){if(e.nested){e.chat?.ledger?.({kind:"commit",ok:!1,line:"proposal failed validation \u2014 nothing landed",warnings:d.map(p=>`${p.code}: ${p.detail}`)}),kt=!0;return}e.chat.submit("[auto-repair] the proposal failed validation: "+d.map(p=>`${p.code}: ${p.detail}`).join("; ")+" \u2014 please re-finalize with these fixed.");return}let g=ee(e.contextDir),D=gr(t,g),k=ce(e.contextDir,"proposals",ne);ut(k,{recursive:!0}),lt(ce(k,"proposal.json"),JSON.stringify(t,null,2)+`
|
|
10
|
+
`);let E=new Map(t.use_cases.map(p=>[p.temp_ref,{resolution:"skipped"}])),Q=mt(e.contextDir,R.session_id,Ve,e.probe,e.auth),O=await ke(Q,ht(t,g),p=>{if(p.degradedProbe&&fe()!==null&&t.use_cases.some(ye=>ye.matches_existing==null))return{result:{degradedHold:!0},record:null};let K=Be({contextDir:e.contextDir,graph:p.graph,proposal:t,proposalId:ne,verdicts:E,by:{kind:"ai",id:"extract-agent"},autoName:!0,allowStaleBasis:!0,eventIds:p.eventIds("extract",1),...ie?{sid:p.sid}:{},probeHits:p.probeHits});return K.errors!==null?{errors:K.errors}:{result:K,record:K.record}}),N=O.ok&&"result"in O?O.result:null;if(N!==null&&"degradedHold"in N){We(),ze(s,t.use_cases,"degraded"),Ze=!0,e.chat.ledger?.({kind:"commit",ok:!1,line:`held ${t.use_cases.length} item(s) for review \u2014 semantic dedup ran degraded (embeddings unavailable); nothing saved this turn`});return}let V=N??{record:null,errors:O.ok?null:O.kind==="validation"?O.errors:[{code:O.kind==="contended"?O.err.code:"UNSETTLED",detail:O.kind==="contended"?`held by ${O.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};if(V.errors){e.chat.ledger?.({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:V.errors.map(p=>`${p.code}: ${p.detail}`)});return}$t=!0,V.record?.event_ids?.length&&S?.markApplied(V.record.event_ids);{let p=V.record.review.filter(K=>K.kind==="pending_update");p.length>0&&(I||e.out(`${p.length} update(s) held for review`),e.emit?.({type:"update_held",count:p.length,targets:p.map(K=>K.id)}),e.chat?.ledger?.({kind:"commit",ok:!0,line:`${p.length} update(s) held for review`}))}let z=V.record.nodes.length;Y+=z;let H=t.use_cases.length-z;{let p=ee(e.contextDir),K=new Map;for(let{cid:j,content:J}of p.byLabel(me.USECASE))p.superseded.has(j)||K.set(Re(String(J.title??"")),j);let ye=[];for(let j of t.use_cases){let J=null;if(j.matches_existing?.cid&&p.hasNode(j.matches_existing.cid)){let we=p.tipOf(j.matches_existing.cid);J=p.superseded.has(we)?null:we}J=J??K.get(Re(j.title))??null,J&&ye.push({ref:j.temp_ref,cid:J,...p.displayNameOf(J)?{id:p.displayNameOf(J)}:{}})}ye.length>0&&e.chat.registerAliases?.(ye),C.current=p;let Pt=j=>{for(let[J,we]of p.names)if(we===j&&!p.superseded.has(we))return J},Tt=zt({verb:"extract",commitN:1,phase:"proposal",committed:V.record.nodes.map(j=>({cid:j.cid,...Pt(j.cid)?{logical_id:Pt(j.cid)}:{}})),reused:H},p);e.emit?.(Tt.event),e.chat.holdReceipt?.(Tt.text)}h("commit",{derived:z,evidence_matched:H,chat:!0},R.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:z===0&&H>0?`all ${H} matched existing \u2014 nothing new to save`:`saved ${z} use-case${z===1?"":"s"} as drafts`+(H>0?` \xB7 ${H} matched existing`:"")})},Qe=!!(l&&s.source_id in l.handle.state.read_basis),G=Qe&&Te.size>0?{...e,ask:async t=>t.every(n=>Te.has(n.id))?(l.handle.markApplied(t.map(n=>`resolveq:${r.resume}:${n.id}`)),e.out(`answered ${t.length} re-asked question(s) from the held resume answers`),t.map(n=>Te.get(n.id))):e.ask(t)}:e;Qe&&r.message&&(G={...G,initialMessage:r.message}),G={...G,onEmbedDegraded:We};let le,et;if(S){let t=S,n=G.ask,d=Qt({contextDir:e.contextDir,cwd:mr(e.contextDir),handle:t,note:g=>e.chat?e.chat.note(g):e.out(g),schedule:r.trust!=="hold",...r.trust==="hold"?{scheduleRefused:"this run holds items for review, so its extraction is not scheduled \u2014 kane-cli context extract runs it after the review"}:{},graphSlot:C,...e.now?{now:e.now}:{}});if(G={...G,ask:async g=>{let D=await n(g);if(Array.isArray(D)){let k=D.filter(E=>{if(E.free_text==null||E.free_text.trim()==="")return!1;let Q=g.find(O=>O.id===E.id);return E.selected_index!=null&&Q?.options[E.selected_index]?.input===!0}).map(E=>E.free_text.trim());if(k.length>0){let E=t.state.ingest_registry;for(let Q of k)E=qe(E,Q,e.now?.()??new Date);t.save({ingest_registry:E})}}return D},ingest:d},Qe&&r.withSource){let g=(t.state.pending?.proposals??[]).filter(E=>E.content?._held!=null).length;if(r.trust==="hold"||g>0){let E=g>0?`error: --with-source can't add a source to a session holding ${g} item(s) for review \u2014 resume without --with-source to finish the review first, then land it with kane-cli context ingest [HOLD_MULTI_SOURCE]`:"error: --with-source is not available with --trust hold \u2014 held work from a multi-source run can't be resumed yet; drop --trust hold, or land the source separately with kane-cli context ingest [HOLD_MULTI_SOURCE]";return e.out(E),e.emit?.({type:"error",code:"HOLD_MULTI_SOURCE",message:E}),2}let D=r.withSource;t.save({ingest_registry:qe(t.state.ingest_registry,D,e.now?.()??new Date)});let k=await d({id:`withsource-${t.state.sid}`,ref:D,purpose:null});if(!k.ok)return e.out(`error: --with-source: ${k.error.message}`),e.emit?.({type:"error",code:k.error.code,message:`--with-source: ${k.error.message}`}),2;G={...G,pendingDeferral:{ingested:{source_id:k.result.source_id,cid:k.result.cid}}}}et=()=>{if(!e.chat?.attachIngest)return;let g=e.chat;le=g.attachIngest(async D=>{try{t.save({ingest_registry:qe(t.state.ingest_registry,D,e.now?.()??new Date)});let k=await d({id:`attach-${t.state.sid}-${(t.state.ingest_registry??[]).length}`,ref:D,purpose:null});return k.ok?(g.deferBatch({source_id:k.result.source_id,cid:k.result.cid}),{ok:!0}):{ok:!1,error:k.error.message}}catch(k){return{ok:!1,error:k instanceof Error?k.message:String(k)}}})},et()}let b;try{b=await gt(R,{...G,graphSlot:C,...ue?{checkpoint:ue}:{}},Ye,c,h,I?Rt:void 0,()=>_e.current)}catch(t){if(t instanceof Fe)return le?.(),e.chat?.setWorking?.(null),e.out(`error: ${t.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:t.message}),2;throw t}if(le?.(),e.chat?.setWorking?.(null),b.errorCode==="binding_mismatch"&&f&&pe){let t=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(t)?t.find(g=>g.id==="binding-mismatch"):void 0)?.selected_index!==0){let g=`resume abandoned: binding mismatch on session ${Ue} \u2014 the session is preserved`;return e.out(g),e.emit?.({type:"error",message:g,code:"BINDING_MISMATCH"}),2}h("binding_migrate",{sid:Ue},R.session_id),et?.();let d=R.resume&&"schema"in R.resume?{...R.resume,binding:{}}:void 0;try{b=await gt({...R,...d?{resume:d}:{}},{...G,graphSlot:C,...ue?{checkpoint:ue}:{}},Ye,c,h,I?Rt:void 0,()=>_e.current)}catch(g){if(g instanceof Fe)return le?.(),e.chat?.setWorking?.(null),e.out(`error: ${g.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:g.message}),2;throw le?.(),g}le?.(),e.chat?.setWorking?.(null)}if(b.error){let t=b.error.startsWith("proposal failed validation after repair:");t&&h("agent_error_detail",{error:b.error},R.session_id);let n=t?`error: the agent could not produce a valid proposal for ${s.source_id} \u2014 re-run kane-cli context extract to retry`:`error: agent failed for ${s.source_id}: ${b.error}`;e.out(n),e.emit?.({type:"error",source_id:s.source_id,message:n}),q.push(s.source_id);continue}if(b.highRisk)return e.out(`error: ${b.highRisk.length} high-risk decision${b.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:s.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${b.highRisk.map(t=>t.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(b.paused){let t=U.slice(u+1).map(D=>D.source_id),n=l?.handle??T,d=n??nt(e.contextDir,{sid:R.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:b.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:t},conv_source:ae,verb:"extract",...he?{force:!0}:{},...r.changeContext?{change_basis:{source_id:r.changeContext.source_id,new_head:r.changeContext.new_head}}:{},...m?{user_session_id:m.ids.session_id}:{}});Pe=!0;try{ae&&d.state.conv_source!==ae&&d.save({conv_source:ae});let D=e.chat?.drainHeldReceipts?.()??[];(D.length>0||(d.state.held_receipts?.length??0)>0)&&d.save({held_receipts:D}),n&&d.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:t},...he&&!d.state.force?{force:!0}:{},...m&&d.state.user_session_id!==m.ids.session_id?{user_session_id:m.ids.session_id}:{}}),sr(d,b.paused)}catch(D){let k=d.state.checkpoint,E=`error: couldn't persist the pause for session ${d.state.sid}`+(k?` \u2014 last durable checkpoint: seq ${k.seq} @ ${k.ts}`:" \u2014 no durable checkpoint exists")+` (${D instanceof Error?D.message:String(D)})`;return e.out(E),e.emit?.({type:"error",message:E,code:"PAUSE_PERSIST_FAILED",sid:d.state.sid}),1}h("session_paused",{sid:d.state.sid},R.session_id);let g=`kane-cli context extract --resume ${d.state.sid} --mode ${a}`;if(I||e.out(`paused: session ${d.state.sid} saved \u2014 resume with: ${g}`),e.emit?.({type:"session_paused",sid:d.state.sid,source_id:s.source_id,mode:a,resume:g,expires_at:d.state.expires_at,pending_questions:b.paused.pending.questions}),I){let D=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"ctrl+c",facts:[`session ${d.state.sid} saved`+(Y>0?` \u2014 ${Y} use-case${Y===1?"":"s"} committed so far`:""),...d.state.expires_at?[`expires: ${d.state.expires_at}`]:[],...D!==void 0?[`credits used: ${D.toFixed(1)}`]:[]],resume:g,resumeMessage:`${g} --message "<your words>"`,tracePath:te(_)})}return 3}if(b.crashed){let t=S?.state.checkpoint;if(S&&t){let n=`kane-cli context extract --resume ${S.state.sid} --mode ${a}`;try{S.save({read_basis:{[s.source_id]:s.cid},corpus_cursor:{remaining:Je}})}catch{}if(h("agent_crashed_resumable",{sid:S.state.sid,seq:t.seq},R.session_id),I||e.out(`agent crashed \u2014 session ${S.state.sid} is resumable at checkpoint seq ${t.seq} (at most the in-flight turn lost); resume with: ${n}`),e.emit?.({type:"session_paused",sid:S.state.sid,source_id:s.source_id,mode:a,resume:n,expires_at:S.state.expires_at,crashed:!0}),I){let d=e.chat?.state.credits?.total;e.onSummary?.({state:"crashed",facts:[`agent crashed \u2014 session ${S.state.sid} is resumable at checkpoint seq ${t.seq}`,"at most the in-flight turn was lost",...d!==void 0?[`credits used: ${d.toFixed(1)}`]:[]],resume:n,resumeMessage:`${n} --message "<your words>"`,tracePath:te(_)})}return Pe=!0,S.release(),3}e.out(`error: agent crashed for ${s.source_id} with no durable checkpoint`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent crashed for ${s.source_id} with no durable checkpoint`,code:"AGENT_CRASHED"}),q.push(s.source_id);continue}if(I){if(xt+=b.assumedDefaults??0,b.error||kt)return 1;if(!$t&&!Ze){let t=U.length-u-1,n=`done \u2014 nothing committed for ${s.source_id} (no finalize before the session ended)`+(t>0?`; stopping here \u2014 ${t} remaining source(s) not extracted (re-run kane-cli context extract to continue)`:"");I||e.out(n),e.onSummary?.({state:"complete",facts:[n,...Y>0?[`${Y} use-case${Y===1?"":"s"} saved earlier in this run`]:[]],tracePath:te(_)});{let d=(S?.state.ingest_schedule??[]).filter(g=>g.status==="pending");d.length>0&&e.out(`note: ${d.length} source(s) landed this session (${d.map(g=>g.source_id).join(", ")}) were not extracted \u2014 the session ended first; kane-cli context extract runs them`)}return l&&s.source_id in l.handle.state.read_basis&&(l.handle.complete(),l=null,S=null),_t(),0}l&&s.source_id in l.handle.state.read_basis&&!Ze&&(o(u),l.handle.complete(),l=null,S=null);continue}if(!b.proposal){e.out(`error: agent ended without a proposal for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: agent ended without a proposal for ${s.source_id}`}),q.push(s.source_id);continue}let L=be(b.proposal,Me(c,b.proposal),c);if(h("kane_validate",{errors:L.map(t=>t.code)},R.session_id),L.length>0&&Cr(b.proposal,L,t=>e.out(t))&&(h("criteria_dropped",{source_id:s.source_id},R.session_id),L=be(b.proposal,Me(c,b.proposal),c)),L.length>0){e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:L.map(t=>t.code),repairing:!0}),h("repair_respawn",{source_id:s.source_id},R.session_id),f&&pe||(St=S?.state.checkpoint?.seq??0);try{b=await gt(R,{...G,graphSlot:C,...ue?{checkpoint:ue}:{}},Ye,c,h,void 0,()=>_e.current)}catch(t){if(t instanceof Fe)return e.out(`error: ${t.message}`),e.emit?.({type:"error",code:"PAIR_MISMATCH",message:t.message}),2;throw t}if(b.error||!b.proposal){e.out(`error: repair run failed for ${s.source_id}`),e.emit?.({type:"error",source_id:s.source_id,message:`error: repair run failed for ${s.source_id}`}),q.push(s.source_id);continue}if(L=be(b.proposal,Me(c,b.proposal),c),L.length>0){h("validation_details",{errors:L.map(t=>({code:t.code,detail:t.detail}))},R.session_id),e.out(`\u2717 validation failed \u2014 ${L.map(t=>t.code).join(", ")} (details: ${te(_)})`),e.emit?.({type:"validate_failed",source_id:s.source_id,codes:L.map(t=>t.code),repairing:!1}),e.emit?.({type:"error",source_id:s.source_id,message:`error: proposal failed validation after repair (${L.map(t=>t.code).join(", ")})`}),q.push(s.source_id);continue}}let A=b.proposal,Ne=gr(A,c),tt=ce(e.contextDir,"proposals",ne);if(ut(tt,{recursive:!0}),lt(ce(tt,"proposal.json"),JSON.stringify(A,null,2)+`
|
|
11
|
+
`),r.plan){e.out(`plan: ${A.use_cases.length} use-case(s) proposed from ${s.source_id} (nothing committed)`);for(let t of A.use_cases){let n=Ne.get(t.temp_ref),d=n?n.archived?` \u2248 matches ARCHIVED ${n.cid.slice(0,19)}${n.reason?` \u2014 previously rejected: "${n.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${n.cid.slice(0,19)}`:"";e.out(` [${t.risk}] ${t.title} \u2014 cite ${t.cite.anchor}${d}`)}e.emit?.({type:"plan",source_id:s.source_id,use_cases:A.use_cases.map(t=>{let n=Ne.get(t.temp_ref);return{risk:t.risk,title:t.title,anchor:t.cite.anchor,...n?{match:n.cid,match_archived:!!n.archived}:{}}})}),b.assumedDefaults&&e.out(`assumed: ${b.assumedDefaults} default(s) auto-taken (assumed)`);continue}for(let t of A.use_cases){if(!t.conflicts_with?.length)continue;let n=t.conflicts_with.filter(g=>c.resolve(g)!==null),d=t.conflicts_with.filter(g=>c.resolve(g)===null);d.length>0&&(e.out(`note: ${t.temp_ref}: dropped unresolvable conflict hint(s): ${d.join(", ")}`),t.conflicts_with=n.length>0?n:void 0)}h("review_start",{use_cases:A.use_cases.length,flags:Ne.size},R.session_id);let He=await e.review(A.use_cases,Ne);if(h("review_verdicts",[...He.entries()].map(([t,n])=>({ref:t,resolution:n.resolution})),R.session_id),lt(ce(tt,"review.json"),JSON.stringify(A.use_cases.map(t=>{let n=He.get(t.temp_ref)??{resolution:"skipped"};return{id:t.temp_ref,kind:"review-item",resolution:n.resolution,edit:n.edit??null,reason:n.reason??null,...n.supersedeTarget?{supersede_target:n.supersedeTarget}:{},by:ge}}),null,2)+`
|
|
12
|
+
`),r.posture==="reconcile"){let t=jt(A),n=N=>t.passthrough.use_cases.filter(V=>{let z=V.matches_existing?.cid,H=z?N.resolve(z):null,p=H?N.tipOf(H.cid):null;return p!=null&&(N.trust.get(p)??null)!=="derived"}),d=n(c),g=t.passthrough.use_cases.length-d.length,D=mt(e.contextDir,R.session_id,Ve,e.probe,e.auth),k=new Set(d.map(N=>N.temp_ref));(await ke(D,ht({...t.passthrough,use_cases:d},c),N=>{let V={...t.passthrough,use_cases:n(N.graph).filter(p=>k.has(p.temp_ref))},z=new Map(V.use_cases.map(p=>[p.temp_ref,{resolution:"approved"}])),H=Be({contextDir:e.contextDir,graph:N.graph,proposal:V,proposalId:ne,verdicts:z,by:ge,autoName:!0,allowStaleBasis:!0,eventIds:N.eventIds("extract",1),...ie?{sid:N.sid}:{},probeHits:N.probeHits});return H.errors!==null?{errors:H.errors}:{result:H,record:H.record}})).ok||e.out("note: the unchanged-match evidence attach did not land this run \u2014 the held changeset is unaffected; re-run reconcile to refresh it"),g>0&&e.out(`note: ${g} unchanged match(es) target unreviewed (or no-longer-resolving) item(s) \u2014 evidence not attached (bless them with kane-cli context review; a later reconcile attaches)`);let Q=fe(),O=t.adds.length+t.updates.length+t.archives.length;Q&&O>0&&(Q.save({reconcile:{proposal_id:ne,verdicts:{}}}),de+=O,Oe=Q.state.sid,e.out(`held: ${O} change(s) from ${s.source_id} await your verdicts \u2014 nothing from the changeset committed`),e.emit?.({type:"held",source_id:s.source_id,count:O,reason:"reconcile"}));continue}if((Ae||r.trust==="hold")&&fe()&&A.use_cases.some(t=>t.matches_existing==null)){ze(s,A.use_cases,Ae?"degraded":"trust_hold");continue}let Ct=mt(e.contextDir,R.session_id,Ve,e.probe,e.auth),Dt=t=>{if(t.degradedProbe&&fe()!==null&&A.use_cases.some(d=>d.matches_existing==null))return{result:{degradedHold:!0},record:null};let n=Be({contextDir:e.contextDir,graph:t.graph,proposal:A,proposalId:ne,verdicts:He,by:ge,autoName:!0,allowStaleBasis:!0,eventIds:t.eventIds("extract",1),...ie?{sid:t.sid}:{},probeHits:t.probeHits});return n.errors!==null?{errors:n.errors}:{result:n,record:n.record}},Et=ht(A,c),F=await ke(Ct,Et,Dt);if(!F.ok&&F.kind==="drifted"){if(!await e.confirmStale(`the context changed while you reviewed (${F.asks.map(n=>n.detail).join("; ")}) \u2014 commit against the new head anyway?`)){e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:s.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),q.push(s.source_id);continue}F=await ke(Ct,{...Et,sourcePins:[]},Dt)}let rt=F.ok&&"result"in F?F.result:null;if(rt!==null&&"degradedHold"in rt){We(),ze(s,A.use_cases,"degraded");continue}let xe=rt??(F.ok?{record:null,errors:null}:{record:null,errors:F.kind==="validation"?F.errors:F.kind==="contended"?[{code:F.err.code,detail:`a use-case this proposal touches is held by ${F.err.holder?.owner_sid??"another session"} \u2014 try again when it frees`}]:[{code:"UNSETTLED",detail:"concurrent activity kept moving the store \u2014 retry when quieter"}]});if(xe.errors){h("commit_error_details",{errors:xe.errors.map(t=>({code:t.code,detail:t.detail}))},R.session_id),e.out(`\u2717 commit failed \u2014 ${xe.errors.map(t=>t.code).join(", ")} (details: ${te(_)})`),e.emit?.({type:"error",source_id:s.source_id,message:`error: commit failed: ${xe.errors.map(t=>`${t.code}: ${t.detail}`).join("; ")}`}),q.push(s.source_id);continue}let xr=new Date().toISOString();for(let t of A.use_cases){let n=He.get(t.temp_ref)??{resolution:"skipped"};for(let d of Jt({ts:xr,command:"context extract",id:t.temp_ref,by:ge},n.resolution))Kt(e.contextDir,d)}let Z=xe.record;Z.event_ids?.length&&S?.markApplied(Z.event_ids);let st=new Map(Z.review.map(t=>[t.id,t.resolution])),it=[...st.values()].filter(t=>t==="approved"||t==="edited").length,je=[...st.values()].filter(t=>t==="rejected").length,ve=Z.nodes.filter(t=>!st.has(t.cid)).length,ot=Z.supersessions.filter(t=>t.kind==="node"&&t.new!==t.old).length;h("commit",{trusted:it,derived:ve,archived:je},R.session_id),e.out(`saved ${it+ve} use-case(s)`+(ve>0?` \xB7 ${ve} awaiting review`:"")+(je>0?` \xB7 ${je} archived`:"")+(ot>0?` \xB7 ${ot} superseded`:""));{let t=Z.review.filter(n=>n.kind==="pending_update");t.length>0&&(e.out(`${t.length} update(s) held for review`),e.emit?.({type:"update_held",count:t.length,targets:t.map(n=>n.id)}))}b.assumedDefaults&&e.out(`assumed: ${b.assumedDefaults} default(s) auto-taken (assumed)`),e.emit?.({type:"commit",source_id:s.source_id,proposal_id:ne,trusted:it,derived:ve,archived:je,superseded:ot,assumed:b.assumedDefaults??0,evidence_matched:Math.max(0,A.use_cases.length-Z.nodes.length),minted:Z.nodes.map(t=>{let n=Z.names?.find(d=>d.cid===t.cid)?.slug;return{cid:t.cid,...n?{logical_id:n}:{}}})}),l&&s.source_id in l.handle.state.read_basis&&(o(u),l.handle.complete(),e.out(`session ${r.resume} complete`),e.emit?.({type:"session_complete",sid:r.resume,source_id:s.source_id}),m?.event("ASR_SESSION_COMPLETE",{}),l=null,S=null)}if(S){let u=S.state.ingest_schedule??[];u.some(s=>s.status==="pending")&&S.save({ingest_schedule:u.map(s=>s.status==="pending"?{...s,status:"skipped",note:"run ended before its turn \u2014 kane-cli context extract runs it"}:s)})}vt=!0}finally{if(l?.handle.release(),T&&!Pe&&!vt){let o=T.state.checkpoint;if(o){let u=`kane-cli context extract --resume ${T.state.sid} --mode ${a}`;e.out(`session ${T.state.sid} kept its last checkpoint (seq ${o.seq}, ${o.ts}) \u2014 resume with: ${u}`),T.release()}else{try{T.complete()}catch{T.release()}pt()}T=null}}if(I){let o=e.chat?.state.ledger.filter(c=>c.kind==="answer"&&c.receipt.form==="assumed").length??0,u=xt+o,s=e.chat?.state.credits?.total;e.onSummary?.({state:"complete",facts:[`saved ${Y} use-case${Y===1?"":"s"} across ${U.length} source${U.length===1?"":"s"}`,...u>0?[`${u} assumed default(s)`]:[],...s!==void 0?[`credits used: ${s.toFixed(1)}`]:[]],tracePath:te(_)})}if(r.plan||nr(e.contextDir),de>0&&(T||Oe)){Pe=!0;let o=T?.state.sid??Oe,u=`kane-cli context extract --resume ${o} --mode ${a}`;if(I||e.out(`paused: ${de} held item(s) await review \u2014 resume with: ${u}`),e.emit?.({type:"session_paused",sid:o,resume:u,held:de}),I){let s=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"held for review",facts:[`${de} held item(s) await your review`,...s!==void 0?[`credits used: ${s.toFixed(1)}`]:[]],resume:u,tracePath:te(_)})}return T?.release(),3}return q.length>0&&e.out(`${q.length} of ${U.length} source(s) failed \u2014 re-run kane-cli context extract to retry (${q.join(", ")})`),_t(),q.length>0?1:0}export{mt as a,$r as b,hr as c,pr as d,Rr as e,gr as f,Ss as g};
|