@testmuai/kane-cli 0.6.4 → 0.6.7
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/bin/kane-cli.cjs +91 -0
- package/bin/resolve-runtime.cjs +45 -0
- package/dist/{ChatSurface-VXYU6KFW.js → ChatSurface-Y2M6HB2R.js} +1 -1
- package/dist/{ChromeProfilePicker-QWTM7DK6.js → ChromeProfilePicker-IW3K43VC.js} +1 -1
- package/dist/{CliFeedbackPrompt-6NVWMONO.js → CliFeedbackPrompt-ZJ4LZGPK.js} +1 -1
- package/dist/{CliUploadProgress-2YRQLECI.js → CliUploadProgress-SMPVN7Q6.js} +1 -1
- package/dist/{ConfigView-I4R5M7BO.js → ConfigView-RTAGKZH4.js} +1 -1
- package/dist/EvidenceViewOffer-LHPIZUGQ.js +2 -0
- package/dist/{FolderPicker-5VWBYTAK.js → FolderPicker-QUY7LNVZ.js} +1 -1
- package/dist/{HelpView-OJZW4XWX.js → HelpView-47J2NZWJ.js} +1 -1
- package/dist/{InfoBox-TGELGCBR.js → InfoBox-G63WZAMH.js} +1 -1
- package/dist/{LinksBox-B5EBRY26.js → LinksBox-2HIHDT5K.js} +1 -1
- package/dist/{ProfilesView-3SJRIBHQ.js → ProfilesView-TUXQXPXJ.js} +1 -1
- package/dist/{ProjectPicker-72HKMBEY.js → ProjectPicker-VUABWG2P.js} +1 -1
- package/dist/{SaveSessionPrompt-CK5SGNRO.js → SaveSessionPrompt-PNVGNLGO.js} +1 -1
- package/dist/SingleShotApp-BZV5CULT.js +2 -0
- package/dist/{SummaryBox-ABB7ST26.js → SummaryBox-36MDDDYQ.js} +1 -1
- package/dist/TestMdRunView-A655PMEY.js +2 -0
- package/dist/{WhoamiView-OF354UGC.js → WhoamiView-LHU6RGIY.js} +1 -1
- package/dist/{bind-BWILBZGR.js → bind-E67W2DXG.js} +2 -2
- package/dist/{bridge-LNDJS3HH.js → bridge-WVFTWHKP.js} +1 -1
- package/dist/{changelog-BWCEZQ23.js → changelog-D4Y5QJIZ.js} +1 -1
- package/dist/chat-committer-WOTCC7L3.js +2 -0
- package/dist/chat-controller-MONWZKS7.js +4 -0
- package/dist/{chunk-YI4XULHR.js → chunk-3CY3DZDH.js} +15 -15
- package/dist/{chunk-IOTJZTHX.js → chunk-3GOZ7R4G.js} +12 -12
- package/dist/{chunk-DNOBOZPO.js → chunk-3NR6OTHL.js} +1 -1
- package/dist/{chunk-MK2G7VIF.js → chunk-5J3HQZNU.js} +1 -1
- package/dist/{chunk-ADOXYGZE.js → chunk-6EC54ZHT.js} +1 -1
- package/dist/{chunk-CLTANA4L.js → chunk-77PBBYRZ.js} +2 -2
- package/dist/{chunk-GYW7LVVL.js → chunk-7Z64BL5D.js} +1 -1
- package/dist/{chunk-5CTMOJG4.js → chunk-7ZMYAXES.js} +1 -1
- package/dist/{chunk-WFEGGQJ4.js → chunk-A2AZQ4PQ.js} +1 -1
- package/dist/{chunk-HNE4TDOZ.js → chunk-AASBJJCU.js} +4 -4
- package/dist/{chunk-5KSB5MOF.js → chunk-BBZBXSTP.js} +1 -1
- package/dist/chunk-CIFVUX3B.js +4 -0
- package/dist/chunk-CVOGP253.js +2 -0
- package/dist/{chunk-O66EU5UV.js → chunk-DCWCANNS.js} +1 -1
- package/dist/{chunk-4MUHS3UL.js → chunk-DL5CXC64.js} +1 -1
- package/dist/chunk-DNNZ353O.js +4 -0
- package/dist/chunk-E4EHWO3J.js +4 -0
- package/dist/{chunk-AXABTFCD.js → chunk-EDM6YACR.js} +1 -1
- package/dist/{chunk-YMSN25DX.js → chunk-FYSWQ4K7.js} +1 -1
- package/dist/{chunk-QZI43UNV.js → chunk-G5CYSC23.js} +1 -1
- package/dist/chunk-GAD6IBZ6.js +12 -0
- package/dist/chunk-GLS46X7N.js +5 -0
- package/dist/chunk-GLVDOR5G.js +2 -0
- package/dist/chunk-I37UOX73.js +14 -0
- package/dist/chunk-IAHKTEET.js +2 -0
- package/dist/{chunk-IXVR66NS.js → chunk-IX34JIXK.js} +1 -1
- package/dist/{chunk-BNN6ZDJW.js → chunk-IYTHPCQ2.js} +1 -1
- package/dist/chunk-JR37W7IJ.js +6 -0
- package/dist/{chunk-IRRGSC7B.js → chunk-KVAALPTA.js} +1 -1
- package/dist/{chunk-ZZLR3O5A.js → chunk-L4JIMNKW.js} +1 -1
- package/dist/{chunk-WT3SMSY5.js → chunk-LVWB6TB2.js} +1 -1
- package/dist/chunk-MBXWXBDM.js +4 -0
- package/dist/{chunk-UZSG54OY.js → chunk-MTG2LRGV.js} +1 -1
- package/dist/chunk-NEHF4C6X.js +7 -0
- package/dist/chunk-NMKZHHB6.js +2 -0
- package/dist/{chunk-DXK55KGR.js → chunk-NMZATEKQ.js} +8 -8
- package/dist/{chunk-2PQXEEVY.js → chunk-NVGBE2DR.js} +1 -1
- package/dist/{chunk-ANIVHX3P.js → chunk-OPDJD7WS.js} +2 -2
- package/dist/{chunk-6GTOYTCQ.js → chunk-OSALXGD4.js} +1 -1
- package/dist/{chunk-ZQP3MCZW.js → chunk-QG6LJCZG.js} +1 -1
- package/dist/{chunk-MCQXRJGH.js → chunk-QHFUDBQH.js} +1 -1
- package/dist/{chunk-MVF4KRHA.js → chunk-QVJ7C4GW.js} +1 -1
- package/dist/{chunk-W36P7S5W.js → chunk-QYTMD6NM.js} +1 -1
- package/dist/{chunk-OB6CKLEL.js → chunk-R7NNIQMH.js} +1 -1
- package/dist/{chunk-652FEDL4.js → chunk-RBLZUDMZ.js} +2 -2
- package/dist/chunk-RGDQMKNJ.js +4 -0
- package/dist/{chunk-XUJ5EPVW.js → chunk-RGQIBS32.js} +1 -1
- package/dist/{chunk-FV4LLU3T.js → chunk-RWIHSR4H.js} +1 -1
- package/dist/{chunk-I2JUBAPU.js → chunk-SK2GVMTJ.js} +1 -1
- package/dist/{chunk-POI6DCP6.js → chunk-TADJIOHV.js} +1 -1
- package/dist/{chunk-PYB2EXRE.js → chunk-TSWGQKUK.js} +2 -2
- package/dist/{chunk-64QURIT6.js → chunk-TTJ4XMWP.js} +1 -1
- package/dist/{chunk-WE57PD6K.js → chunk-UQVKNUYO.js} +1 -1
- package/dist/chunk-UZWOHCFX.js +4 -0
- package/dist/chunk-VLC24QVT.js +2 -0
- package/dist/{chunk-2K4XOHVK.js → chunk-WFQUDSKY.js} +1 -1
- package/dist/{chunk-3WJJ43MT.js → chunk-WJG4ZPUH.js} +1 -1
- package/dist/{chunk-STH6I3UB.js → chunk-X47VFBIV.js} +1 -1
- package/dist/{chunk-PICCLJSO.js → chunk-XUHVQ5VL.js} +1 -1
- package/dist/{chunk-3HEPW6SN.js → chunk-Y6HPW2OQ.js} +1 -1
- package/dist/{chunk-BYUARJE7.js → chunk-YB54MHKU.js} +1 -1
- package/dist/{chunk-CY5NDMO7.js → chunk-YTZUYCFZ.js} +1 -1
- package/dist/{chunk-QNNBNIR7.js → chunk-YZBLBPOE.js} +2 -2
- package/dist/{chunk-BOO7YXAV.js → chunk-Z34XRBKQ.js} +1 -1
- package/dist/{chunk-FJTWJ243.js → chunk-ZPDM6FO7.js} +1 -1
- package/dist/{config-OJF53CHL.js → config-BZ7C5NU5.js} +1 -1
- package/dist/cover-cmd-DN5D6A3S.js +2 -0
- package/dist/{credentials-NLJHSVBY.js → credentials-BPJL6YIZ.js} +1 -1
- package/dist/{descriptor-EHK3DRCZ.js → descriptor-KXDJ4XYD.js} +1 -1
- package/dist/evidence-E5B24ZO6.js +2 -0
- package/dist/evolve-cmd-V7H4PLCX.js +2 -0
- package/dist/explain-VTRHEVUQ.js +2 -0
- package/dist/{explain-cmd-U367SD4N.js → explain-cmd-AG6ZDXV6.js} +1 -1
- package/dist/{explain-cmd-KV5YUXKB.js → explain-cmd-NZPC6537.js} +1 -1
- package/dist/{extract-bind-SSTKQGTV.js → extract-bind-3QBBCWYE.js} +2 -2
- package/dist/{extract-cmd-GO4UV7ER.js → extract-cmd-4PGUDJMU.js} +1 -1
- package/dist/gaps-cmd-42LPHWFP.js +2 -0
- package/dist/{generate-headless-2HYMSVN5.js → generate-headless-NZUDYIKJ.js} +2 -2
- package/dist/index.js +12 -12
- package/dist/ingest-GOKIMEP4.js +2 -0
- package/dist/ingest-cmd-BTYHVJ33.js +3 -0
- package/dist/{interactive-bind-Q5TQFQ6N.js → interactive-bind-TKRWAPJU.js} +3 -3
- package/dist/lifecycle-cmd-E6AXODQD.js +2 -0
- package/dist/list-cmd-RJVLH2GR.js +3 -0
- package/dist/{list-commands-6WDXAECV.js → list-commands-55RCFEOL.js} +1 -1
- package/dist/logical-ids-QZQRQ3TV.js +2 -0
- package/dist/login-flow-WNIHDQXF.js +2 -0
- package/dist/maintenance-cmd-UJG4LPWD.js +2 -0
- package/dist/pdf-convert-KYXI4FU4.js +2 -0
- package/dist/{persist-recorded-session-KHIMN4A3.js → persist-recorded-session-HK7JUONC.js} +1 -1
- package/dist/pipeline-FTLXJQRT.js +2 -0
- package/dist/readmodel-KTNI6QDC.js +2 -0
- package/dist/reconcile-cmd-5XC4AUSJ.js +2 -0
- package/dist/{recording-banner-SADVYNEP.js → recording-banner-5IYX2KBV.js} +1 -1
- package/dist/{require-project-folder-LP7V26IU.js → require-project-folder-J4Q4FRQ4.js} +1 -1
- package/dist/revert-FRXNIP5R.js +2 -0
- package/dist/review-cmd-XB2DCTMZ.js +4 -0
- package/dist/run-2RFR2ASQ.js +2 -0
- package/dist/run-3ZYJQBBC.js +2 -0
- package/dist/{run-test-md-ATB2HZRG.js → run-test-md-WN6BH3PC.js} +2 -2
- package/dist/{skill-installer-DE2LSSKU.js → skill-installer-4HYPUBNB.js} +1 -1
- package/dist/{spawner-GOTVIFR5.js → spawner-VD6YFZ43.js} +1 -1
- package/dist/tcg-generate-77QKMB63.js +2 -0
- package/dist/{testmd-actions-RYQHBX4K.js → testmd-actions-LT5FNIR6.js} +1 -1
- package/dist/token-refresh-PCOAZBKK.js +2 -0
- package/dist/{validate-basic-6BQ2L7TT.js → validate-basic-XWGKC5VF.js} +1 -1
- package/dist/{version-check-YW3FUWDH.js → version-check-6FDTS6MK.js} +1 -1
- package/dist/{view-cmd-FRMQF76B.js → view-cmd-PCDG3FIC.js} +1 -1
- package/dist/walk-session-YS62CWX5.js +2 -0
- package/package.json +16 -7
- package/bin/kane-cli.js +0 -2
- package/dist/EvidenceViewOffer-54GEARRX.js +0 -2
- package/dist/SingleShotApp-AJBIWW74.js +0 -2
- package/dist/TestMdRunView-5PMLLLFT.js +0 -2
- package/dist/chat-committer-ADJJTDUT.js +0 -2
- package/dist/chat-controller-VAC57IEV.js +0 -3
- package/dist/chunk-6AYUSR7X.js +0 -2
- package/dist/chunk-6LRKYF67.js +0 -14
- package/dist/chunk-74RUSHIB.js +0 -4
- package/dist/chunk-ACEODVSC.js +0 -14
- package/dist/chunk-CT2I5KUM.js +0 -2
- package/dist/chunk-E3BO7OVR.js +0 -7
- package/dist/chunk-HJGUEZLW.js +0 -2
- package/dist/chunk-IJPFAWBH.js +0 -5
- package/dist/chunk-OLXOZJ7X.js +0 -6
- package/dist/chunk-QPZRHAYK.js +0 -4
- package/dist/chunk-SJ2KQKOV.js +0 -3
- package/dist/chunk-WIA7TPK3.js +0 -2
- package/dist/chunk-ZG2V2ODK.js +0 -4
- package/dist/cover-cmd-K3LCXHAQ.js +0 -2
- package/dist/evidence-UPOFW3XC.js +0 -2
- package/dist/evolve-cmd-MVALOB3G.js +0 -2
- package/dist/explain-VFIZTHFN.js +0 -2
- package/dist/gaps-cmd-DTVDIOED.js +0 -2
- package/dist/ingest-C5ANIN7S.js +0 -2
- package/dist/ingest-cmd-LLC5CDQ5.js +0 -3
- package/dist/lifecycle-cmd-BXE5IMFN.js +0 -2
- package/dist/list-cmd-KBWPYJMV.js +0 -3
- package/dist/logical-ids-3Y6RX5C2.js +0 -2
- package/dist/login-flow-XQMJFC4H.js +0 -2
- package/dist/maintenance-cmd-VS3APIUN.js +0 -2
- package/dist/pipeline-2HRAWT5U.js +0 -2
- package/dist/readmodel-XOGOELUP.js +0 -2
- package/dist/reconcile-cmd-DH4VV6PG.js +0 -2
- package/dist/revert-AQQ2VHRM.js +0 -2
- package/dist/review-cmd-4WZUUOE4.js +0 -4
- package/dist/run-RT2VMPTQ.js +0 -2
- package/dist/run-XAZMT7WO.js +0 -2
- package/dist/tcg-generate-7PUXJ5R4.js +0 -2
- package/dist/token-refresh-F5KRV7ER.js +0 -2
- package/dist/walk-session-O4TMVORI.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{x as s}from"./chunk-NMKZHHB6.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:process.env.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl,mediaArtefactsHost:process.env.KANE_STAGE_MEDIA_ARTEFACTS_HOST??e.mediaArtefactsHost}}export{n as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as $e}from"./chunk-
|
|
2
|
+
import{c as $e}from"./chunk-6EC54ZHT.js";import{a as te}from"./chunk-WFQUDSKY.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-TADJIOHV.js";import{a as ve}from"./chunk-KVAALPTA.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{y as i}from"./chunk-NMKZHHB6.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
|
|
3
3
|
`)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
|
|
4
4
|
`).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as J}from"./chunk-
|
|
2
|
+
import{b as J}from"./chunk-NEHF4C6X.js";import{e as H,g as P}from"./chunk-M5JQXOCE.js";import{a as ce}from"./chunk-6YGTRKDT.js";import{e as ue}from"./chunk-UR6MHSHU.js";var u=ue(ce(),1);function $(p,r){let f=null,R=(b,j)=>{for(let S=0;S<b.length;S++){let y=b[S],l=[...j,S];r(y)&&(f===null||l.length>f.length)&&(f=l),y.children&&y.children.length>0&&R(y.children,l)}};return R(p,[]),f}function T(p,r,f){if(r.length===0)return[...p];let R=r[0],b=[...p],j=b[R];if(r.length===1)b[R]=f(j);else{let S=r.slice(1),y=T(j.children??[],S,f);b[R]={...j,children:y}}return b}function K(){return{steps:[],maxOrdinal:0}}function le(p,r){if(r.type==="run_start"&&r.environment?.resolution)return{...p,resolution:r.environment.resolution};if(r.type==="step_end"&&typeof r.ordinal=="number"&&r.id){let f={id:r.id,ordinal:r.ordinal,status:r.status,...r.kind?{kind:r.kind}:{},...typeof r.duration=="number"?{duration_ms:Math.round(r.duration*1e3)}:{},...typeof r.action_id=="string"&&r.action_id?{action_id:r.action_id}:{}};return{...p,steps:[...p.steps,f],maxOrdinal:Math.max(p.maxOrdinal,r.ordinal)}}return p}function D(p){let r=p.indexOf(": ");return r>0&&r<15?p.slice(r+2):p}function W(p){return p.map(r=>{let f=r.children?W(r.children):r.children;return r.status==="running"?{...r,status:"stopped",phase:void 0,children:f}:f!==r.children?{...r,children:f}:r})}function Se(p,r,f,R,b){let[j,S]=(0,u.useState)(!1),[y,l]=(0,u.useState)([]),[Q,B]=(0,u.useState)(null),[X,F]=(0,u.useState)(null),[Y,w]=(0,u.useState)(null),[Z,L]=(0,u.useState)(null),[ee,q]=(0,u.useState)([]),[ne,G]=(0,u.useState)(null),[te,ie]=(0,u.useState)(void 0),m=(0,u.useRef)(null),x=(0,u.useRef)(null),_=(0,u.useRef)(0),A=(0,u.useRef)(!1),O=(0,u.useRef)(K()),re=(0,u.useCallback)(async(I,V)=>{let z=m.current;if(z){try{await z.exited}catch{}m.current=null}l([]),B(null),F(null),w(null),L(null),q([]),G(null),ie(I.max_steps),S(!0),x.current=null,_.current=0,O.current=K();let h;try{h=J(I,V)}catch(E){w(E instanceof Error?E.message:String(E)),S(!1);return}m.current=h,H("runner",()=>h.cancel()),(async()=>{A.current=!1;let E=!1;for await(let e of h.events){if(A.current)break;switch(O.current=le(O.current,e),e.type){case"run_start":if(e.child_id)break;if(x.current&&!x.current.isSingleFlow){let o=_.current;_.current++,l(d=>d.map((i,s)=>s===o?{...i,status:"running"}:i.status==="running"&&!i.children?.some(n=>n.status==="running")?{...i,status:i.children?.some(n=>n.status==="failed")?"failed":"passed"}:i))}break;case"bifurcation":{let o=e.flows??[],d=e.count??o.length,i={flows:o,isSingleFlow:e.is_single_flow??d<=1};L(i),x.current=i,_.current=0,l(o.map((s,n)=>({index:n+1,objective:s??`Flow ${n+1}`,status:"pending"})));break}case"step_start":{r?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let o=e.index,d=e.objective??`Step ${o}`,i=e.child_id,s=x.current&&!x.current.isSingleFlow;if(i)l(n=>{let t=$(n,a=>a.branchChildId===i)??$(n,a=>a.status==="running");return t?T(n,t,a=>{let c=(a.children??[]).map(g=>g.status==="running"&&g.childId===i?{...g,status:"stopped",phase:void 0}:g);return c.push({index:o,objective:d,status:"running",childId:i}),{...a,children:c}}):n});else if(s){let n=Math.max(0,_.current-1);l(t=>{let a=[...t];if(n>=a.length)return t;let c={...a[n]},k=[...c.children??[]].map(U=>U.status==="running"&&U.childId===void 0?{...U,status:"stopped",phase:void 0}:U);return k.push({index:o,objective:d,status:"running"}),c.children=k,c.status="running",a[n]=c,a})}else l(n=>{let t=W(n);return t.some(c=>c.index===o)?t.map(c=>c.index===o?{...c,status:"running",objective:d}:c):[...t,{index:o,objective:d,status:"running"}]});break}case"step_event":{r?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let o=e.child_id,d=x.current&&!x.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){q(i=>[...i,e.checkpoint_count]);break}if(e.event==="replay_started"){G({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&f?.(e.detail),o){let i=n=>{if(n.index!==e.index||n.childId!==o)return n;let t={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(t.objective=e.detail),e.action_type&&(t.actionType=e.action_type),{...n,...t}},s=n=>n.map(t=>{let a=i(t);return a!==t?a:t.children&&t.children.length>0?{...t,children:s(t.children)}:t});l(n=>n.map(t=>t.children?{...t,children:s(t.children)}:t))}else if(d){let i=Math.max(0,_.current-1);l(s=>{let n=[...s];if(i>=n.length)return s;let t={...n[i]},a=[...t.children??[]];if(!a.some(g=>g.index===e.index&&g.childId===void 0))a.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let g=0;g<a.length;g++){if(a[g].index!==e.index||a[g].childId!==void 0)continue;let k={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(k.objective=e.detail),e.action_type&&(k.actionType=e.action_type),a[g]={...a[g],...k}}return t.children=a,n[i]=t,n})}else l(i=>i.some(n=>n.index===e.index)?i.map(n=>{if(n.index!==e.index)return n;let t={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(t.objective=e.detail),e.action_type&&(t.actionType=e.action_type),{...n,...t}}):[...W(i),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{r?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),R?.();let o=e.child_id,d=x.current&&!x.current.isSingleFlow;if(o){let i=n=>n.index===e.index&&n.childId===o?{...n,status:e.status,duration:e.duration,phase:void 0,objective:n.objective.startsWith("Step ")?D(e.summary||n.objective):n.objective}:n,s=n=>n.map(t=>{let a=i(t);return a!==t?a:t.children&&t.children.length>0?{...t,children:s(t.children)}:t});l(n=>n.map(t=>t.children?{...t,children:s(t.children)}:t))}else if(d){let i=Math.max(0,_.current-1);l(s=>{let n=[...s];if(i>=n.length)return s;let t={...n[i]},a=(t.children??[]).map(c=>c.index===e.index&&c.childId===void 0?{...c,status:e.status,duration:e.duration,phase:void 0,objective:c.objective.startsWith("Step ")?D(e.summary||c.objective):c.objective}:c);return t.children=a,n[i]=t,n})}else l(i=>i.map(s=>s.index===e.index?{...s,status:e.status,duration:e.duration,phase:void 0,objective:s.objective.startsWith("Step ")?D(e.summary||s.objective):s.objective}:s));{let s=x.current&&!x.current.isSingleFlow?Math.max(0,_.current-1):0,n=typeof e.ordinal=="number"&&e.id?{ordinal:e.ordinal,id:e.id}:void 0;p?.(e.index,s,e.child_id,n)}break}case"child_agent_start":{let o=e.objective??"",d=e.child_id;l(i=>{let s=$(i,n=>n.status==="running");return s?T(i,s,n=>({...n,objective:`${o} (branch)`,phase:`child: ${o.slice(0,50)}`,branchObjective:o,branchChildId:d})):i});break}case"child_agent_end":{let o=e.child_id,d=`child ${e.success?"done":"failed"}`;l(i=>{let s=$(i,n=>n.branchChildId===o);return s?T(i,s,n=>({...n,phase:d})):i.map(n=>n.phase?.startsWith("child:")?{...n,phase:d}:n)});break}case"describe_trigger":b?.(e);break;case"ask_user":B(e.question??"");break;case"run_end":l(o=>o.map(d=>d.status==="running"?{...d,status:e.status,phase:void 0}:d)),S(!1),F(e),E=!0;break;case"error":S(!1),w(e.message??"Runner error"),l(o=>o.map(d=>d.status==="running"?{...d,status:"failed",phase:void 0}:d));break}}let{code:v,signal:M}=await h.exited,N=h.stderr,de=v===0&&!M,C=[];v!==null&&v!==0&&C.push(`Runner exited with code ${v}`),M&&C.push(`Runner killed by signal ${M}`),N&&(!de||!E?C.push(N):V?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:N})),m.current===h&&(C.length>0&&w(C.join(`
|
|
3
3
|
`)),S(!1),P("runner","Event stream ended"),m.current=null)})().catch(E=>{let v=[`Runner event loop error: ${E}`];h.exitCode!==null&&h.exitCode!==0&&v.push(`Exit code: ${h.exitCode}`),h.exitSignal&&v.push(`Signal: ${h.exitSignal}`),h.stderr&&v.push(h.stderr),m.current===h&&(w(v.join(`
|
|
4
4
|
`)),S(!1),P("runner","Event loop error"),m.current=null)})},[p,r,f,R,b]),se=(0,u.useCallback)(I=>{m.current?.sendUserResponse(I),B(null)},[]),ae=(0,u.useCallback)(()=>{let I=m.current;I&&(I.sendCancel("user"),S(!1),B(null),setTimeout(()=>{m.current===I&&(P("runner","User cancelled run"),m.current=null)},5e3))},[]),oe=(0,u.useCallback)(()=>{l([]),F(null),w(null)},[]);return(0,u.useEffect)(()=>()=>{A.current=!0,P("runner","Component unmounted"),m.current=null},[]),{isRunning:j,steps:y,askingUser:Q,lastRunEnd:X,runError:Y,bifurcationInfo:Z,cmInitCounts:ee,replayInfo:ne,maxSteps:te,startRun:re,sendAnswer:se,cancelRun:ae,clearLastRun:oe,getEvidenceState:()=>O.current}}export{K as a,le as b,Se as c};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as B,b as V,c as se}from"./chunk-
|
|
2
|
+
import{a as B,b as V,c as se}from"./chunk-TSWGQKUK.js";import{a as j,b as N}from"./chunk-YB54MHKU.js";import{a as ne,b as oe}from"./chunk-2YQ6TW77.js";import{a as C,b as Y,e as M,f as te,m as re}from"./chunk-RKWJG3WW.js";import{a as L}from"./chunk-QYTMD6NM.js";import{a as ee}from"./chunk-WAOCHXJ5.js";import{a as Z}from"./chunk-XUHVQ5VL.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as H}from"./chunk-3NR6OTHL.js";import{a as O}from"./chunk-Z34XRBKQ.js";import{y as h}from"./chunk-NMKZHHB6.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Je,rmSync as pe,unlinkSync as Ke}from"fs";import{resolve as G}from"path";import{promises as ie,realpathSync as ke}from"fs";import{homedir as be}from"os";import{join as q,parse as Te,relative as ae,resolve as ce}from"path";var le=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ue(e){try{return ke(ce(e))}catch{return ce(e)}}function Ee(e){let r=ue(e),s=ue(be()),n=Te(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Ee(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await ie.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of m){if(t++,t>r){c=!0,f="max_entries";break}let w=b.name,E=q(a,w);if(b.isDirectory()){if(le.has(w)||w.startsWith(".")||w.startsWith("output-")||n.has(w))continue;l.push(E)}else if(b.isFile()&&w.endsWith("_test.md")&&(o.push({path:E,relPath:ae(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let m=[{dir:q(e.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:b,depth:w}=m.shift(),E;try{E=await ie.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let x=u.name,y=q(b,x);if(u.isDirectory()){if(w>=20||x.startsWith(".")||x.startsWith("output-")||le.has(x))continue;m.push({dir:y,depth:w+1})}else if(u.isFile()&&x.endsWith("_test.md")&&(o.push({path:y,relPath:ae(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as Se}from"fs";function W(e){try{return re(e,Se(e,"utf8")).global.tags??[]}catch{return[]}}import{mkdirSync as ve,writeFileSync as Re}from"fs";import{join as Pe}from"path";function de(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Me(e){let r=ne({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:de(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function De(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:de(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);ve(e.outDir,{recursive:!0});for(let l of c.url){let a=Pe(e.outDir,l.file_name),m=await A(l.file_url);if(!m.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let b=await m.text();Re(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function fe(e){return await Me(e),await De(e)}var T=v(X(),1);import{existsSync as $e,readFileSync as Ce}from"fs";var p=v(F(),1);function Ie(e){B(e);let r=M(e);if(!$e(r))return null;try{return JSON.parse(Ce(r,"utf8"))}catch{return{}}}function Fe(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Oe(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ae(e){return e==="tests-dir"?"\u2726":" "}function Le(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Be(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,m]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),x=[];for(let y of u.results){let K=Ie(y.path);K?.org_id!==void 0&&K.org_id!==r||x.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Fe(K),source:y.source,tags:W(y.path)})}t(x),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Le(u,a)).map(u=>({id:u.path,label:`${Oe(u.status)} ${Ae(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),w=(0,T.useMemo)(()=>Ne(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:i})})]});let E=a==="all"?"all":je(a);return(0,p.jsx)(Z,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let x=o.find(y=>y.path===u.id);x&&s(x)},onCancel:n,onTab:()=>m(u=>Be(u)),extraHint:"cycle filter",footer:w})}function je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ne(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(g,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(g,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(g,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Ue,readFileSync as We}from"fs";var d=v(F(),1);function ge({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Ue(a))try{i(JSON.parse(We(a,"utf8")))}catch{i(null)}},[e]),Q((a,m)=>{if(m.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,d.jsxs)(g,{children:[(0,d.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Je(r,"utf8"))}catch{return null}}function he(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return he(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
|
|
3
3
|
Switch profiles with \`kane-cli profiles switch\` to act on it.
|
|
4
4
|
`),2)}async function Ut(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await V({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Wt(e,r){if(process.stdin.isTTY&&!e.json)return await Ye(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
|
|
5
5
|
`),2;throw o}for(let o of n.results){let t=$(o.path);if(!he(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
|
|
6
6
|
`)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
|
|
7
|
-
`),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-
|
|
7
|
+
`),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-WN6BH3PC.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===ye&&_.path){let t=await qe(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Ve(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Jt(e,r){let s=G(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
|
|
8
8
|
`),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
|
|
9
9
|
`),0}async function Ve(e,r,s){let n=G(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
|
|
10
10
|
`),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{b as c}from"./chunk-MBXWXBDM.js";import{d as l}from"./chunk-5YPBPZUR.js";function h(f,o,u){let n=o.resolve(u);if(!n)return{target:null,entries:[]};let t=new Set([n.cid]),r=n.cid;for(;o.superseded.has(r);){let s=o.superseded.get(r);if(typeof s!="string"||t.has(s))break;t.add(s),r=s}let d=o.nodeLabel.get(n.cid)??"(unknown)",{records:p}=c(f),i=[];for(let s of p){for(let e of s.nodes)t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"minted",detail:`minted ${e.label} ${e.cid}`});for(let e of s.judgements??[])t.has(e.about)&&i.push({seq:s.seq,ts:s.ts,kind:"judgement",rationale:e.rationale,detail:`judgement on ${e.about}`,by:e.by});for(let e of s.review)t.has(e.id)&&i.push({seq:s.seq,ts:s.ts,kind:"review",detail:`${e.resolution}${e.reason?` \u2014 ${e.reason}`:""}`,by:e.by});for(let e of s.supersessions)e.kind==="node"&&(t.has(e.old)||e.new!==null&&t.has(e.new))&&i.push({seq:s.seq,ts:s.ts,kind:"supersession",detail:`${e.old} \u2192 ${String(e.new)} \u2014 ${e.reason}`,by:e.by});for(let e of s.names??[])t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"name",detail:`named ${e.slug}`,by:e.by});if(d===l.SOURCE)for(let[e,a]of Object.entries(s.source_head_moves))(t.has(a??"")||o.heads.get(e)!==void 0&&t.has(n.cid)&&e===o.getNode(n.cid)?.content?.source_id)&&i.push({seq:s.seq,ts:s.ts,kind:"head_move",detail:`${e} head \u2192 ${String(a)}`})}return i.sort((s,e)=>e.seq-s.seq),{target:{cid:n.cid,tip:n.tip,label:d,slug:o.nameOf.get(n.cid)},entries:i}}export{h as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-DL5CXC64.js";import{c as k}from"./chunk-RFHMDQXZ.js";import{a as C}from"./chunk-Z34XRBKQ.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-NMKZHHB6.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
|
|
3
3
|
Please open this URL manually: ${e}
|
|
4
4
|
`)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|
|
5
5
|
<html lang="en">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{y as m}from"./chunk-NMKZHHB6.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $}from"./chunk-
|
|
2
|
+
import{a as $}from"./chunk-SK2GVMTJ.js";import{b as D}from"./chunk-NEHF4C6X.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
3
3
|
|
|
4
|
-
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let
|
|
5
|
-
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,
|
|
6
|
-
`).trim()}function wt(e){return{mode:"bifurcate",objective:e.objective,model:e.model,session_id:e.sessionId,run_index:0,width:0,height:0,stream:!0,variables:e.variables,...e.auth}}async function St(e,t,n){let i=D(e,t),
|
|
4
|
+
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
|
|
5
|
+
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
|
|
6
|
+
`).trim()}function wt(e){return{mode:"bifurcate",objective:e.objective,model:e.model,session_id:e.sessionId,run_index:0,width:0,height:0,stream:!0,variables:e.variables,...e.auth}}async function St(e,t,n){let i=D(e,t),d=()=>i.cancel();n?.addEventListener("abort",d);let r=null,o=null;try{for await(let p of i.events)if(p.type==="bifurcation_result"){let a=p,c=(a.sub_objectives??[]).map((g,m)=>({...g,sequence_index:m}));r={sub_objectives:c,extracted_variables:a.extracted_variables??{},total_flows:c.length,is_single_flow:c.length<=1,credits_consumed:a.credits_consumed??0}}else p.type==="error"&&(o=p.message??"bifurcation error")}finally{n?.removeEventListener("abort",d),i.cancel()}if(r)return r;throw new Error(o??"bifurcation produced no result")}export{U as a,je as b,q as c,Re as d,Ce as e,P as f,v as g,Ue as h,R as i,ct as j,Y as k,ft as l,Ae as m,ht as n,wt as o,St as p,de as q,Ge as r,B as s,Xe as t,tt as u,rt as v};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
function l(r){let{isAgent:c,log:m}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{c&&process.stdout.write(JSON.stringify(t)+`
|
|
3
|
-
`)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-
|
|
3
|
+
`)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-A655PMEY.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-SMPVN7Q6.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-36MDDDYQ.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-2HIHDT5K.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
var d=/^L([1-9]\d*)-L([1-9]\d*)$/,l=/^img#(p[1-9]\d*-[1-9]\d*)$/;function a(e){if(e==="img#whole")return{kind:"img-whole"};let n=l.exec(e);if(n)return{kind:"img-part",ref:n[1]};let r=d.exec(e);return r?{kind:"lines",a:parseInt(r[1],10),b:parseInt(r[2],10)}:null}function u(e,n){let r=/^L(\d+)-L(\d+)$/.exec(n);if(!r)return null;let t=parseInt(r[1],10),o=parseInt(r[2],10),i=e.split(`
|
|
3
|
+
`);return t<1||o<t||o>i.length?null:i.slice(t-1,o).map(s=>s.replace(/^\d+\| /,"")).join(`
|
|
4
|
+
`)}function g(e,n,r){let t=a(n.anchor);if(e.format==="image")return t?.kind==="img-whole"?[]:[{code:"CITE_ANCHOR_INVALID",detail:`image cites are anchor-only (img#whole), got ${n.anchor}`}];if(t?.kind==="img-part")return new Set((e.images??[]).map(s=>s.ref)).has(t.ref)?[]:[{code:"CITE_ANCHOR_INVALID",detail:`anchor ${n.anchor} names no embedded image of this source version`}];if(!n.anchor||n.quote===void 0||n.quote==="")return[{code:"MISSING_CITE",detail:"text-kind cites need anchor+quote"}];let o=r!==null?u(r,n.anchor):null;return o===null?[{code:"BAD_ANCHOR",detail:`anchor ${n.anchor} does not resolve in the source`}]:o.includes(n.quote)?[]:[{code:"QUOTE_MISMATCH",detail:`quote is not verbatim within ${n.anchor}`}]}export{a,u as b,g as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as t}from"./chunk-427OQS2N.js";import{a,b as s,c as n}from"./chunk-5YPBPZUR.js";function y(o="extract"){let i=new Set(t(o)),c=Object.fromEntries(Object.keys(s).map(r=>{let e=s[r];return[r,{hashed:[...e.hashed],unhashed:[...e.unhashed??[]],required:[...e.required],enums:Object.fromEntries(Object.entries(e.enums).map(([p,g])=>[p,[...g]])),mintable:i.has(r)}]})),d=Object.fromEntries(Object.keys(n).map(r=>{let e=n[r];return[r,{src:[...e.src],dst:[...e.dst],salient:[...e.salient],props:[...e.props],cardinality:e.cardinality,acyclic:e.acyclic,direction:"dependent->dependency"}]}));return{schema_version:a,nodes:c,edges:d,mint_gate:t(o),blob_fingerprint:{algo:"sha256",domain:"assurance.blob\0",prefix:"sha256:"}}}export{y as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-KVAALPTA.js";import{y as l}from"./chunk-NMKZHHB6.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";var u=p(f(),1),T=5;function _({thinking:t,expanded:e,thinkingDone:o,maxLines:i=T}){if(!e)return(0,u.jsxs)(m,{paddingX:1,children:[(0,u.jsx)(s,{color:l.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,u.jsx)(s,{color:l.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let g=t.split(`
|
|
3
3
|
`),n=Math.max(0,g.length-i),a=n>0?g.slice(-i).join(`
|
|
4
4
|
`):t;return(0,u.jsxs)(b,{variant:"default",paddingX:1,children:[n>0&&(0,u.jsxs)(s,{color:l.muted,children:["\u22EE (",n," earlier line",n===1?"":"s"," hidden)"]}),(0,u.jsx)(s,{color:l.dim,children:a}),o&&(0,u.jsx)(s,{color:l.muted,children:"\u2014 thinking complete"})]})}function k(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
|
|
5
5
|
`),e}var c=p(f(),1),B=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},g=(a,d,r)=>(a===0||!B(t[a-1]))&&(d+r>=t.length||!B(t[d+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),d=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||g(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(d==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(d==="*"||d==="_"){let r=t.indexOf(d,n+1);if(r!==-1&&r>n+1&&(d==="*"||g(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=d,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?l.dim:void 0,children:e.text},o))}function S(t){return t.split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as n}from"./chunk-RZ4F3BHX.js";import{a as c}from"./chunk-
|
|
2
|
+
import{a as n}from"./chunk-RZ4F3BHX.js";import{a as c}from"./chunk-3NR6OTHL.js";import{v as s,w as a}from"./chunk-NMKZHHB6.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{d as o}from"./chunk-NVGBE2DR.js";function s(n,r,e){let t=r.mediaOf(e),l=typeof t?.text_blob=="string"&&t.text_blob!==""?t.text_blob:null;if(l!==null)return o(n,l);let i=String(r.getNode(e)?.content.blob??"");return i===""?null:o(n,i)}function b(n){return n.toString("utf8").replace(/\n$/,"").split(`
|
|
3
|
+
`).map((e,t)=>`${String(t+1).padStart(4,"0")}| ${e}`).join(`
|
|
4
|
+
`)}export{s as a,b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as k}from"./chunk-NVGBE2DR.js";function C(t,n){let{width:e,height:o,channels:i}=n;if(t.length!==e*o*i)throw new Error(`appearanceSignature: buffer ${t.length} bytes does not match ${e}x${o}x${i}`);let s=9,r=8,f=new Array(s*r);for(let u=0;u<r;u++){let h=Math.floor(u*o/r),g=Math.min(o,Math.max(h+1,Math.floor((u+1)*o/r)));for(let p=0;p<s;p++){let A=Math.floor(p*e/s),d=Math.min(e,Math.max(A+1,Math.floor((p+1)*e/s))),E=0,w=0;for(let I=h;I<g;I++)for(let l=A;l<d;l++){let m=(I*e+l)*i;E+=i===1?t[m]:Math.floor((t[m]*299+t[m+1]*587+t[m+2]*114)/1e3),w+=1}f[u*s+p]=Math.floor(E/w)}}let c="",P=0,_=0;for(let u=0;u<r;u++)for(let h=0;h<s-1;h++)P=P<<1|(f[u*s+h+1]>f[u*s+h]?1:0),_+=1,_===4&&(c+=P.toString(16),P=0,_=0);return c}import{deflateSync as N}from"zlib";var G=(()=>{let t=new Uint32Array(256);for(let n=0;n<256;n++){let e=n;for(let o=0;o<8;o++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e>>>0}return t})();function Y(t){let n=4294967295;for(let e of t)n=G[(n^e)&255]^n>>>8;return(n^4294967295)>>>0}function R(t,n){let e=Buffer.alloc(4);e.writeUInt32BE(n.length);let o=Buffer.concat([Buffer.from(t,"latin1"),n]),i=Buffer.alloc(4);return i.writeUInt32BE(Y(o)),Buffer.concat([e,o,i])}var X={1:0,3:2,4:6};function F(t,n){let{width:e,height:o,channels:i}=n;if(t.byteLength!==e*o*i)throw new Error(`pngEncode: raw length ${t.byteLength} != ${e}x${o}x${i}`);let s=Buffer.alloc(13);s.writeUInt32BE(e,0),s.writeUInt32BE(o,4),s[8]=8,s[9]=X[i];let r=e*i,f=Buffer.alloc(o*(r+1));for(let c=0;c<o;c++)f[c*(r+1)]=0,t.copy(f,c*(r+1)+1,c*r,(c+1)*r);return Buffer.concat([Buffer.from([137,80,78,71,13,10,26,10]),R("IHDR",s),R("IDAT",N(f)),R("IEND",Buffer.alloc(0))])}var U=64,J=16,V=12e6,W=6e6,K=5e3,H=3e4,q="",v=class extends Error{constructor(e,o){super(`${e}: ${o}`);this.code=e}};async function z(t,n,e){let o=t.objs.has(n)?t.objs:t.commonObjs.has(n)?t.commonObjs:null;if(o)try{return o.get(n)??null}catch{return null}if(e.remainingMs<=0)return null;let i=n.startsWith("g_")?t.commonObjs:t.objs,s,r=Date.now();try{return await Promise.race([new Promise(f=>{try{i.get(n,c=>f(c??null))}catch{f(null)}}),new Promise(f=>{s=setTimeout(()=>f(null),Math.min(K,e.remainingMs))})])}finally{clearTimeout(s),e.remainingMs-=Date.now()-r}}async function Q(){let t=await import("pdfjs-dist/legacy/build/pdf.mjs");return t.default??t}async function ie(t,n){let e=await Q();q=e.version;let o={remainingMs:n?.resolveBudgetMs??H},i,s=e.getDocument({data:new Uint8Array(t),isEvalSupported:!1,verbosity:0});try{i=await s.promise}catch(r){throw r.name==="PasswordException"?new v("PDF_ENCRYPTED","password-protected \u2014 decrypt and re-ingest"):new v("PDF_UNREADABLE",String(r.message??r))}try{let r=[],f=[],c=new Map,P=[],_=new Map,u=0,h=0;for(let g=1;g<=i.numPages;g++){let p=await i.getPage(g);r.push(`[page ${g}]`);let A=await p.getTextContent(),d="",E=null;for(let l of A.items){if(typeof l!="object"||l===null||!("str"in l))continue;let m=l,x=Math.round(m.transform[5]);E!==null&&x!==E&&d.trim()!==""&&(r.push(d.trimEnd()),d=""),d!==""&&!d.endsWith(" ")&&m.str!==""&&!m.str.startsWith(" ")&&x===E&&(d+=" "),d+=m.str,h+=m.str.trim().length,E=x,m.hasEOL&&d.trim()!==""&&(r.push(d.trimEnd()),d="",E=null)}d.trim()!==""&&r.push(d.trimEnd());let w=await p.getOperatorList(),I=0;for(let l=0;l<w.fnArray.length;l++){let m=w.fnArray[l]===e.OPS.paintImageXObject,x=w.fnArray[l]===e.OPS.paintInlineImageXObject;if(!m&&!x)continue;I+=1;let B=`p${g}-${I}`,y=(j,S,O,$)=>{f.push({ref:B,page:g,media_type:"image/png",...S?{blob:S}:{},...$?{appearance:$}:{},delivery:j,...O?{duplicate_of:O}:{}}),r.push(j==="duplicate"&&O?`[img#${B}: image on page ${g} \u2014 same as img#${O}; cite img#${O}]`:`[img#${B} omitted: ${j}]`)};if(x){y("unsupported-image-kind");continue}let a=await z(p,w.argsArray[l][0],o);if(!a?.data||!a.width||!a.height){y("undecodable");continue}let T;if(a.kind===e.ImageKind.RGB_24BPP)T=3;else if(a.kind===e.ImageKind.RGBA_32BPP)T=4;else{y("unsupported-image-kind");continue}let D;try{D=F(Buffer.from(a.data.buffer,a.data.byteOffset,a.data.byteLength),{width:a.width,height:a.height,channels:T})}catch{y("undecodable");continue}let b=k(D);c.set(b,D);let M=C(Buffer.from(a.data.buffer,a.data.byteOffset,a.data.byteLength),{width:a.width,height:a.height,channels:T});if(a.width<U||a.height<U){y("below-dimension-floor",b,void 0,M);continue}let L=_.get(b);if(L!==void 0){y("duplicate",b,L,M);continue}if(D.byteLength>W){y("image-too-large",b,void 0,M);continue}if(u+D.byteLength>V){y("vision-byte-budget-reached",b,void 0,M);continue}if(P.length>=J){y("image-cap-reached",b,void 0,M);continue}_.set(b,B),u+=D.byteLength,P.push(B),f.push({ref:B,page:g,media_type:"image/png",blob:b,appearance:M,delivery:"selected"}),r.push(`[img#${B}: image on page ${g}]`)}}if(h===0&&i.numPages>0)throw new v("PDF_NO_TEXT_LAYER","no extractable text \u2014 image-only or scanned pdfs are not supported yet");return{projection:r.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`,inventory:f,blobs:c,delivered:P,pages:i.numPages,converter:{name:"pdfjs-dist",version:e.version,policy:"v1"}}}finally{await s.destroy().catch(()=>{})}}export{U as a,J as b,V as c,W as d,q as e,v as f,ie as g};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as L}from"./chunk-RFHMDQXZ.js";import{Q as O,S}from"./chunk-
|
|
2
|
+
import{c as L}from"./chunk-RFHMDQXZ.js";import{Q as O,S}from"./chunk-YZBLBPOE.js";import{e as P,f as R}from"./chunk-M5JQXOCE.js";import{y as s}from"./chunk-NMKZHHB6.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-
|
|
2
|
+
import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-XUHVQ5VL.js";import{a as T}from"./chunk-2WVKOZ6W.js";import{a as k}from"./chunk-3NR6OTHL.js";import{a as _}from"./chunk-RGQIBS32.js";import{y as i}from"./chunk-NMKZHHB6.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=k(c),F=new T(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=k(c),f=await new T(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,
|
|
2
|
+
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,f as o}from"./chunk-NMKZHHB6.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{f as je}from"./chunk-K5JGCJ2K.js";import{a as pe,e as Te,g as Ne,h as qe}from"./chunk-NMZATEKQ.js";import{b as Fe,f as Ue,g as He,h as Ge}from"./chunk-FXPPQL4D.js";import{a as Pe}from"./chunk-RE3BZVGE.js";import{a as Ae,b as Ie}from"./chunk-JFAFKHDX.js";import{e as V,f as se}from"./chunk-VLC24QVT.js";import{c as Oe}from"./chunk-OSALXGD4.js";import{a as re,b as Ee}from"./chunk-DNNZ353O.js";import{b as Me}from"./chunk-YKTYVJBN.js";import{a as Be}from"./chunk-CVOGP253.js";import{a as z}from"./chunk-NVGBE2DR.js";import{a as R}from"./chunk-QHFUDBQH.js";import{b as Re}from"./chunk-IAHKTEET.js";import{d as H}from"./chunk-5YPBPZUR.js";import{appendFileSync as st,mkdirSync as he,writeFileSync as _e}from"fs";import{extname as ot,join as M}from"path";var E=class extends Error{code;constructor(e,c){super(`${e}: ${c}`),this.name="ProposalAdapterError",this.code=e}};function Le(s){return s.version===2}function We(s,e){if(s.read_basis.length!==1)throw new E("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${s.read_basis.length}`);let c=s.read_basis[0],x=s.use_cases.map(o=>{if(o.cite.length!==1)throw new E("CITE_COUNT",`${o.temp_ref}: cite must have exactly 1 element, got ${o.cite.length}`);let g=o.cite[0];if(g.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}: cite source ${g.source_id} != read_basis source ${c.source_id} (single-source)`);return{temp_ref:o.temp_ref,title:o.title,...o.description!==void 0?{description:o.description}:{},...o.summary!==void 0?{summary:o.summary}:{},...o.actors!==void 0?{actors:o.actors}:{},...o.value!==void 0?{value:o.value}:{},risk:o.risk,cite:{anchor:g.anchor,quote:g.quote},...o.criteria!=null&&o.criteria.length>0?{criteria:o.criteria.map((d,p)=>{if(d.cite.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}.criteria[${p}]: cite source ${d.cite.source_id} != read_basis source ${c.source_id} (single-source)`);return{text:d.text,cite:{anchor:d.cite.anchor,quote:d.cite.quote}}})}:{},depends_on_hint:o.depends_on_hint,matches_existing:o.matches_existing,...o.conflicts_with!=null?{conflicts_with:o.conflicts_with}:{},...o.changed?{changed:!0}:{},...o.updated!=null?{updated:{...o.updated.title!=null?{title:o.updated.title}:{},...o.updated.description!=null?{description:o.updated.description}:{},...o.updated.summary!=null?{summary:o.updated.summary}:{},...o.updated.actors!=null?{actors:o.updated.actors}:{},...o.updated.value!=null?{value:o.updated.value}:{},...o.updated.risk!=null?{risk:o.updated.risk}:{},...o.updated.criteria!=null?{criteria:o.updated.criteria.map((d,p)=>{if(d.cite.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}.updated.criteria[${p}]: cite source ${d.cite.source_id} != read_basis source ${c.source_id} (single-source)`);return{text:d.text,cite:{anchor:d.cite.anchor,quote:d.cite.quote}}})}:{}}}:{},...o.change_note!=null?{change_note:o.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:c.source_id,source_cid:c.source_cid},use_cases:x}}function ze(s){let{contextDir:e,graph:c}=s,x=s.maxDigestBytes??4096,o={},g=[];for(let[u,l]of c.heads){if(o[u]=l,typeof l!="string")continue;let _=c.mediaOf(l),D=c.getNode(l)?.content?.blob;if(typeof D=="string")if(_.format==="image")g.push({source_id:u,cid:l,format:"image",blobRef:{path:z(e,D),cid:D}});else{let n=re(e,c,l)?.toString("utf8")??"";g.push({source_id:u,cid:l,format:_.format,text:n})}}g.sort((u,l)=>u.source_id<l.source_id?-1:1);let d=[];for(let u of c.byLabel(H.STYLENOTE).sort((l,_)=>l.cid<_.cid?-1:1))c.superseded.has(u.cid)||d.push(`\u2022 ${String(u.content.statement)} [${String(u.content.learned_from_kind)}]`);let p="";for(let u of d){if(Buffer.byteLength(p+u+`
|
|
3
|
+
`,"utf8")>x)break;p+=u+`
|
|
4
|
+
`}return{read_basis:o,sources:g,styleNoteDigest:p}}function Ve(s,e){let c=ze({contextDir:s,graph:e}).styleNoteDigest;return c.length>0?c:void 0}function it(s){return s.length>8&&s[0]===137&&s[1]===80&&s[2]===78&&s[3]===71?"image/png":s.length>3&&s[0]===255&&s[1]===216&&s[2]===255?"image/jpeg":s.length>12&&s.toString("ascii",0,4)==="RIFF"&&s.toString("ascii",8,12)==="WEBP"?"image/webp":null}function Je(s){return s.toISOString().replace(/[-:]/g,"").slice(0,15)}function nt(s){return s.startsWith("su-conv-")?`conv-${Re(Buffer.from(s,"utf8")).slice(0,8)}`:s}function Qe(s){return s.source_id.startsWith("su-conv-")?"the conversation":s.source_id}function at(s,e,c){return`reading ${Qe(s)}${c>1?` (source ${e} of ${c})`:""}`}function J(s){return s.toLowerCase().trim().replace(/\s+/g," ")}function Xe(s,e){let c=new Map,x=new Map,o=new Map;for(let{cid:d,content:p}of e.byLabel(H.USECASE)){if(e.superseded.has(d))continue;(e.trust.get(d)==="archived"?o:x).set(J(String(p.title??"")),d)}let g=d=>e.trust.get(d)==="archived"?{cid:d,archived:!0,reason:e.archivedReason.get(d)}:{cid:d};for(let d of s.use_cases){if(d.matches_existing){let l=d.matches_existing.cid;if(e.superseded.has(l)){let _=e.tipOf(l);l=e.superseded.has(_)?null:_}if(l!==null){c.set(d.temp_ref,g(l));continue}}let p=x.get(J(d.title));if(p){c.set(d.temp_ref,{cid:p});continue}let u=o.get(J(d.title));u&&c.set(d.temp_ref,g(u))}return c}var Ye=/^(\S+)\.criteria\[(\d+)\]/;function ct(s,e,c){if(e.length===0||!e.every(o=>Ye.test(o.detail)))return!1;let x=new Map;for(let o of e){let g=Ye.exec(o.detail),d=x.get(g[1])??new Set;d.add(Number(g[2])),x.set(g[1],d)}for(let o of s.use_cases){let g=x.get(o.temp_ref);g?.size&&(o.criteria=(o.criteria??[]).filter((d,p)=>!g.has(p)),c(`${o.temp_ref}: dropped ${g.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function Ke(s,e,c,x,o=()=>{},g){let d=(p,u)=>o(p,u,s.session_id);return Ne(s,e,c,x,o,{async onProposalEvent(p){let u=p,l=null,_=null;if(Le(u))try{l=We(u,s.read_basis),d("adapter",{ok:!0,use_cases:l.use_cases.length})}catch(D){_=D instanceof E?D.message:String(D),d("adapter",{ok:!1,error:_})}else l=u;return l&&l.use_cases.length===0&&e.out("warning: the agent proposed ZERO use-cases for this source"),l&&g&&await g(l),{proposal:l,error:_}}})}var dt=new Set(["agent","ci","override"]);async function Gt(s,e){let c=s.mode??"interactive";if(c==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!dt.has(c))return e.out(`extract: unknown mode "${c}" \u2014 interactive | agent | ci | override`),2;let x=Je(e.now?.()??new Date),o=M(e.contextDir,"logs");he(o,{recursive:!0});let g=M(o,`extract-${x}.log`),d=`run-${x}-${Math.random().toString(36).slice(2,8)}`,p=t=>t==="error"||t==="failed_proposal"?"error":t==="repair_respawn"?"warn":"info",u=(t,a,m)=>{try{st(g,JSON.stringify({ts:new Date().toISOString(),level:p(t),run_id:d,...m?{session_id:m}:{},kind:t,data:a})+`
|
|
5
|
+
`)}catch{}};e.out(`trace: ${pe(g)}`),e.emit?.({type:"run_start",mode:c,trace:g});let l=Me();if(l&&e.out(l),e.preflightTurn){let t=await e.preflightTurn();if(u("preflight",t),!t.ok)return e.out(t.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:t.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let _=R(e.contextDir),D=Ve(e.contextDir,_);if(s.source){if(s.resume){let a="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_WITH_RESUME"}),2}let t=_.heads.get(s.source);if(typeof t!="string"){let a=t===null?`error: --source ${s.source} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${s.source} is not an ingested source (kane-cli context list shows them)`;return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_UNKNOWN"}),2}}let n=null;if(s.resume){try{n=Ge(e.contextDir,s.resume,_)}catch(m){return e.out(`error: ${m instanceof Error?m.message:String(m)}`),e.emit?.({type:"error",message:`error: ${m instanceof Error?m.message:String(m)}`}),1}let t=n.handle.state.change_basis;if(t&&(_.heads.get(t.source_id)??null)!==t.new_head){let m=`error: ${t.source_id} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${s.resume} is defunct and can be ignored)`;return e.out(m),e.emit?.({type:"error",message:m,code:"CHANGE_BASIS_MOVED"}),n.handle.release(),2}n.staleBasis.length>0&&e.out(`note: changed since the pause: ${n.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let a=n.handle.state.held_receipts??[];if(a.length>0)if(e.chat?.holdReceipt)for(let m of a)e.chat.holdReceipt(m);else e={...e,initialMessage:[a.join(`
|
|
6
|
+
|
|
7
|
+
`),e.initialMessage].filter(Boolean).join(`
|
|
8
|
+
|
|
9
|
+
`)};n.handle.state.assumed.length>0&&e.out(`note: ${n.handle.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${s.resume} lists them`)}let xe=_.extractedSourceCids,X=!!(s.force||n?.handle.state.force),y=[],P=[];for(let[t,a]of _.heads.entries())if(a!=null&&!(s.source&&t!==s.source)){if(!s.source&&!n&&t.startsWith("su-conv-")){e.out(`skipped: ${t} \u2014 conversation source (extract it explicitly with --source ${t})`),P.push({source_id:t,reason:"conversation"});continue}if(n){let m=t in n.handle.state.read_basis,I=n.handle.state.corpus_cursor.remaining.includes(t);if(!m&&!I)continue;if(I&&!X&&xe.has(a)){e.out(`cached: ${t} @ ${a.slice(0,19)} already extracted \u2014 skipping`),P.push({source_id:t,reason:"cached"});continue}}else if(!X&&xe.has(a)){e.out(`cached: ${t} @ ${a.slice(0,19)} already extracted \u2014 skipping`),P.push({source_id:t,reason:"cached"});continue}y.push({source_id:t,cid:a})}let Ze=t=>{let a=je(e.contextDir,t);a&&e.out(`note: a reconcile plan for ${t} is pending (${a.pending} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${a.path}\``)};for(let t of P)t.reason==="cached"&&Ze(t.source_id);if(e.emit?.({type:"corpus",sources:y,skipped:P}),y.length===0){if(n){let m=`error: resumed session's paused source (${Object.keys(n.handle.state.read_basis).join(", ")||"unknown"}) is no longer in the corpus \u2014 restore/re-ingest it and re-run --resume ${s.resume}, or discard with: kane-cli context sessions clean ${s.resume}`;return e.out(m),e.emit?.({type:"error",message:m,code:"SOURCE_MISSING"}),n.handle.release(),2}let t=P.length>0&&P.every(a=>a.reason==="conversation");return e.out(s.source?`extract: nothing to do \u2014 ${s.source} is already extracted at its current snapshot (--force to re-run)`:t?"extract: nothing to do \u2014 only conversation sources here (extract one explicitly with --source <id>)":"extract: nothing to do \u2014 every ingested source is already extracted"),0}let Y=new Map;if(n&&n.questions.length>0&&!s.message){e.out(`re-presenting ${n.questions.length} unanswered question(s) from the paused session`);let t=await e.ask(n.questions.map(Ue));for(let a of t)Y.set(a.id,a)}let G=e.by??{kind:"human",id:"owner"},A=c==="interactive"&&!s.plan&&!!e.chat,oe=0,ye=0;try{for(let t of y){let a=R(e.contextDir),m={current:a};e.chat?.attachOnCommitted?.(r=>{m.current=r});let I=a.getNode(t.cid),K=String(I?.content.blob??""),ie=re(e.contextDir,a,t.cid);if(!ie)return e.out(`error: ${t.source_id}: blob ${K} missing from .context/blobs`),e.emit?.({type:"error",source_id:t.source_id,message:`error: ${t.source_id}: blob ${K} missing from .context/blobs`,code:"BLOB_MISSING"}),1;let T=a.mediaOf(t.cid),ne=T.media_type.startsWith("image/");if(!ne){let r=it(ie);if(r){e.out(`skipping ${t.source_id}: binary ${r} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`),e.emit?.({type:"source_skipped",source_id:t.source_id,reason:"binary_pre_media"});continue}}let q=ne?`0001| (image source ${t.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:Ee(ie),ve=Je(e.now?.()??new Date),N=`${ve}-${t.source_id}`,$e=!!(n&&t.source_id in n.handle.state.read_basis)?s.resume:`ext-${ve}-${nt(t.source_id)}`,F="";if(A){let r=Oe({contextDir:e.contextDir,graph:R(e.contextDir),sessionStamp:$e,by:G});r.errors===null||r.errors[0]?.code==="CONV_SOURCE_EXISTS"?(F=r.sourceId,e.chat.attachConversationSource?.(F),m.current=R(e.contextDir)):e.out(`warning: conversation source unavailable (${r.errors[0]?.detail}) \u2014 chat adds will not land this session`)}let b={type:"run_config",version:1,session_id:$e,mode:c,source:{source_id:t.source_id,source_cid:t.cid,kind:T.format==="pdf"?"pdf":ot(t.source_id)||"md",numbered_text:q,...T.format==="pdf"&&(T.images??[]).some(r=>r.delivery==="selected")?{images:(T.images??[]).filter(r=>r.delivery==="selected").map(r=>({ref:r.ref,page:r.page,media_type:r.media_type,blob_ref:{path:z(e.contextDir,r.blob),cid:r.blob}}))}:{}},existing_use_cases:a.byLabel(H.USECASE).filter(({cid:r})=>a.trust.get(r)!=="archived"&&!a.superseded.has(r)).map(({cid:r,content:i})=>({id:r,title:String(i.title??""),summary:String(i.summary??"")})),read_basis:m.current.latestHash,max_free_text_rounds:Te,graph_reads:!0,verb:"extract",...D!==void 0?{style_note_digest:D}:{},...s.changeContext&&s.changeContext.source_id===t.source_id?{change_context:s.changeContext}:{},topology:Be(),...A?{chat:!0}:{},...ne?{image_sources:[{source_id:t.source_id,source_cid:t.cid,media_type:T.media_type,blob_ref:{path:z(e.contextDir,K),cid:K}}]}:{},...n&&t.source_id in n.handle.state.read_basis?{resume:{agent_state:n.handle.state.agent_state}}:{}};A||e.out(n&&t.source_id in n.handle.state.read_basis?`resuming: ${t.source_id} (session ${s.resume})`:`extracting: ${t.source_id} @ ${t.cid.slice(0,19)}`),e.emit?.({type:"source_start",source_id:t.source_id,cid:t.cid,index:y.indexOf(t)+1,total:y.length,resumed:!!(n&&t.source_id in n.handle.state.read_basis)}),e.chat?.ledger?.({kind:"banner",text:at(t,y.indexOf(t)+1,y.length)}),e.chat?.setWorking?.(`Reading ${Qe(t)}\u2026`);let be=new Map;u("spawn",{source_id:t.source_id,source_cid:t.cid,resume:!!n,chat:A},b.session_id);let we=!1,et=async r=>{let i=V(r,q,R(e.contextDir));if(u("kane_validate",{errors:i.map(h=>h.code)},b.session_id),i.length>0){e.chat.submit("[auto-repair] the proposal failed validation: "+i.map(h=>`${h.code}: ${h.detail}`).join("; ")+" \u2014 please re-finalize with these fixed.");return}let v=R(e.contextDir),k=Xe(r,v),ee=M(e.contextDir,"proposals",N);he(ee,{recursive:!0}),_e(M(ee,"proposal.json"),JSON.stringify(r,null,2)+`
|
|
10
|
+
`);let rt=new Map(r.use_cases.map(h=>[h.temp_ref,{resolution:"skipped"}])),te=se({contextDir:e.contextDir,graph:v,proposal:r,proposalId:N,verdicts:rt,by:{kind:"ai",id:"extract-agent"},autoName:!0});if(te.errors){e.chat.ledger?.({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:te.errors.map(h=>`${h.code}: ${h.detail}`)});return}we=!0;let j=te.record.nodes.length;oe+=j;let U=r.use_cases.length-j;{let h=R(e.contextDir),De=new Map;for(let{cid:$,content:C}of h.byLabel(H.USECASE))h.superseded.has($)||De.set(J(String(C.title??"")),$);let fe=[];for(let $ of r.use_cases){let C=null;if($.matches_existing?.cid&&h.hasNode($.matches_existing.cid)){let W=h.tipOf($.matches_existing.cid);C=h.superseded.has(W)?null:W}C=C??De.get(J($.title))??null,C&&fe.push({ref:$.temp_ref,cid:C})}fe.length>0&&e.chat.registerAliases?.(fe),m.current=h;let ke=$=>{for(let[C,W]of h.names)if(W===$&&!h.superseded.has(W))return C},Ce=Pe({verb:"extract",commitN:1,phase:"proposal",committed:te.record.nodes.map($=>({cid:$.cid,...ke($.cid)?{logical_id:ke($.cid)}:{}})),reused:U},h);e.emit?.(Ce.event),e.chat.holdReceipt?.(Ce.text)}u("commit",{derived:j,evidence_matched:U,chat:!0},b.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:j===0&&U>0?`all ${U} matched existing \u2014 nothing new to save`:`saved ${j} use-case${j===1?"":"s"} as drafts`+(U>0?` \xB7 ${U} matched existing`:"")})},Se=!!(n&&t.source_id in n.handle.state.read_basis),Q=Se&&Y.size>0?{...e,ask:async r=>r.every(i=>Y.has(i.id))?(n.handle.markApplied(r.map(i=>`resolveq:${s.resume}:${i.id}`)),e.out(`answered ${r.length} re-asked question(s) from the held resume answers`),r.map(i=>Y.get(i.id))):e.ask(r)}:e;Se&&s.message&&(Q={...Q,initialMessage:s.message});let f=await Ke(b,{...Q,graphSlot:m},be,a,u,A?et:void 0);if(e.chat?.setWorking?.(null),f.error)return e.out(`error: agent failed for ${t.source_id}: ${f.error}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: agent failed for ${t.source_id}: ${f.error}`}),1;if(f.highRisk)return e.out(`error: ${f.highRisk.length} high-risk decision${f.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",source_id:t.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${f.highRisk.map(r=>r.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(f.paused){let r=y.slice(y.indexOf(t)+1).map(ee=>ee.source_id),i=n?.handle??Fe(e.contextDir,{sid:b.session_id,mode:"agent",created_at:(e.now?.()??new Date).toISOString(),expires_at:new Date((e.now?.()??new Date).getTime()+1440*60*1e3).toISOString(),agent_state:f.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[t.source_id]:t.cid},corpus_cursor:{remaining:r},conv_source:F,verb:"extract",...X?{force:!0}:{},...s.changeContext?{change_basis:{source_id:s.changeContext.source_id,new_head:s.changeContext.new_head}}:{}});F&&i.state.conv_source!==F&&i.save({conv_source:F});let v=e.chat?.drainHeldReceipts?.()??[];(v.length>0||(i.state.held_receipts?.length??0)>0)&&i.save({held_receipts:v}),n?.handle&&i.save({read_basis:{[t.source_id]:t.cid},corpus_cursor:{remaining:r},...X&&!i.state.force?{force:!0}:{}}),He(i,f.paused),u("session_paused",{sid:i.state.sid},b.session_id);let k=`kane-cli context extract --resume ${i.state.sid} --mode ${c}`;return e.out(`paused: session ${i.state.sid} saved \u2014 resume with: ${k}`),e.emit?.({type:"session_paused",sid:i.state.sid,source_id:t.source_id,mode:c,resume:k,expires_at:i.state.expires_at,pending_questions:f.paused.pending.questions}),e.chat?.ledger?.({kind:"pause",sid:i.state.sid,expires_at:i.state.expires_at,resume:k,messageForm:`${k} --message "<your words>"`}),3}if(A){if(ye+=f.assumedDefaults??0,f.error)return 1;if(!we){let r=y.length-y.indexOf(t)-1;return e.out(`done \u2014 nothing committed for ${t.source_id} (no finalize before the session ended)`+(r>0?`; stopping here \u2014 ${r} remaining source(s) not extracted (re-run kane-cli context extract to continue)`:"")),n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null),0}n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null);continue}if(!f.proposal)return e.out(`error: agent ended without a proposal for ${t.source_id}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: agent ended without a proposal for ${t.source_id}`}),1;let S=V(f.proposal,q,a);if(u("kane_validate",{errors:S.map(r=>r.code)},b.session_id),S.length>0&&ct(f.proposal,S,r=>e.out(r))&&(u("criteria_dropped",{source_id:t.source_id},b.session_id),S=V(f.proposal,q,a)),S.length>0){if(e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:t.source_id,codes:S.map(r=>r.code),repairing:!0}),u("repair_respawn",{source_id:t.source_id},b.session_id),f=await Ke(b,{...Q,graphSlot:m},be,a,u),f.error||!f.proposal)return e.out(`error: repair run failed for ${t.source_id}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: repair run failed for ${t.source_id}`}),1;if(S=V(f.proposal,q,a),S.length>0){for(let r of S)e.out(` ${r.detail}`);return e.emit?.({type:"validate_failed",source_id:t.source_id,codes:S.map(r=>r.code),repairing:!1}),e.emit?.({type:"error",source_id:t.source_id,message:`error: proposal failed validation after repair (${S.map(r=>r.code).join(", ")})`}),1}}let w=f.proposal,Z=Xe(w,a),ae=M(e.contextDir,"proposals",N);if(he(ae,{recursive:!0}),_e(M(ae,"proposal.json"),JSON.stringify(w,null,2)+`
|
|
11
|
+
`),s.plan){e.out(`plan: ${w.use_cases.length} use-case(s) proposed from ${t.source_id} (nothing committed)`);for(let r of w.use_cases){let i=Z.get(r.temp_ref),v=i?i.archived?` \u2248 matches ARCHIVED ${i.cid.slice(0,19)}${i.reason?` \u2014 previously rejected: "${i.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${i.cid.slice(0,19)}`:"";e.out(` [${r.risk}] ${r.title} \u2014 cite ${r.cite.anchor}${v}`)}e.emit?.({type:"plan",source_id:t.source_id,use_cases:w.use_cases.map(r=>{let i=Z.get(r.temp_ref);return{risk:r.risk,title:r.title,anchor:r.cite.anchor,...i?{match:i.cid,match_archived:!!i.archived}:{}}})}),f.assumedDefaults&&e.out(`assumed: ${f.assumedDefaults} default(s) auto-taken (flagged)`);continue}for(let r of w.use_cases){if(!r.conflicts_with?.length)continue;let i=r.conflicts_with.filter(k=>a.resolve(k)!==null),v=r.conflicts_with.filter(k=>a.resolve(k)===null);v.length>0&&(e.out(`note: ${r.temp_ref}: dropped unresolvable conflict hint(s): ${v.join(", ")}`),r.conflicts_with=i.length>0?i:void 0)}u("review_start",{use_cases:w.use_cases.length,flags:Z.size},b.session_id);let L=await e.review(w.use_cases,Z);u("review_verdicts",[...L.entries()].map(([r,i])=>({ref:r,resolution:i.resolution})),b.session_id),_e(M(ae,"review.json"),JSON.stringify(w.use_cases.map(r=>{let i=L.get(r.temp_ref)??{resolution:"skipped"};return{id:r.temp_ref,kind:"review-item",resolution:i.resolution,edit:i.edit??null,reason:i.reason??null,...i.supersedeTarget?{supersede_target:i.supersedeTarget}:{},by:G}}),null,2)+`
|
|
12
|
+
`);let ce=a,O=se({contextDir:e.contextDir,graph:ce,proposal:w,proposalId:N,verdicts:L,by:G,autoName:!0});if(O.errors&&O.errors[0]?.code==="STALE_BASIS"){if(!await e.confirmStale(`the context changed while you reviewed (${O.errors[0].detail}) \u2014 commit against the new head anyway?`))return e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:t.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),e.emit?.({type:"done",status:"aborted",exit_code:1}),1;ce=R(e.contextDir),O=se({contextDir:e.contextDir,graph:ce,proposal:w,proposalId:N,verdicts:L,by:G,allowStaleBasis:!0,autoName:!0})}if(O.errors){for(let r of O.errors)e.out(` ${r.detail}`);return e.emit?.({type:"error",source_id:t.source_id,message:`error: commit failed: ${O.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}`}),1}let tt=new Date().toISOString();for(let r of w.use_cases){let i=L.get(r.temp_ref)??{resolution:"skipped"};for(let v of Ie({ts:tt,command:"context extract",id:r.temp_ref,by:G},i.resolution))Ae(e.contextDir,v)}let B=O.record,de=new Map(B.review.map(r=>[r.id,r.resolution])),ue=[...de.values()].filter(r=>r==="approved"||r==="edited").length,le=[...de.values()].filter(r=>r==="rejected").length,me=B.nodes.filter(r=>!de.has(r.cid)).length,ge=B.supersessions.filter(r=>r.kind==="node"&&r.new!==r.old).length;u("commit",{trusted:ue,derived:me,archived:le},b.session_id),e.out(`committed: ${ue} trusted, ${me} derived (queued), ${le} archived`+(ge>0?`, ${ge} superseded`:"")),f.assumedDefaults&&e.out(`assumed: ${f.assumedDefaults} default(s) auto-taken (flagged)`),e.emit?.({type:"commit",source_id:t.source_id,proposal_id:N,trusted:ue,derived:me,archived:le,superseded:ge,assumed:f.assumedDefaults??0,evidence_matched:Math.max(0,w.use_cases.length-B.nodes.length),minted:B.nodes.map(r=>{let i=B.names?.find(v=>v.cid===r.cid)?.slug;return{cid:r.cid,...i?{logical_id:i}:{}}})}),n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),e.out(`session ${s.resume} complete`),e.emit?.({type:"session_complete",sid:s.resume,source_id:t.source_id}),n=null)}}finally{n?.handle.release()}if(A){let t=e.chat?.state.ledger.filter(I=>I.kind==="answer"&&I.receipt.form==="assumed").length??0,a=ye+t,m=e.chat?.state.credits?.total;e.chat?.ledger?.({kind:"summary",lines:[`saved ${oe} use-case${oe===1?"":"s"} across ${y.length} source${y.length===1?"":"s"}`,...a>0?[`${a} assumed default(s)`]:[],...m!==void 0?[`credits used: ${m.toFixed(1)}`]:[],`trace: ${pe(g)}`]})}return s.plan||qe(e.contextDir),0}export{nt as a,Qe as b,at as c,Xe as d,Gt as e};
|