@testmuai/kane-cli 0.6.3 → 0.6.6
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-LV3KW6WN.js +8 -0
- package/dist/{ChromeProfilePicker-UUGUMJPI.js → ChromeProfilePicker-6PLUQ5TW.js} +1 -1
- package/dist/{CliFeedbackPrompt-JZWESL7Z.js → CliFeedbackPrompt-I4F56IVK.js} +1 -1
- package/dist/{CliUploadProgress-62U3LAUU.js → CliUploadProgress-ULRSPKY3.js} +1 -1
- package/dist/{ConfigView-WHEFCVHR.js → ConfigView-7NMYALEA.js} +1 -1
- package/dist/EvidenceViewOffer-KQKPTMXA.js +2 -0
- package/dist/{FolderPicker-HJUUHQEI.js → FolderPicker-4IOVDO2P.js} +1 -1
- package/dist/{HelpView-EWHP7LSJ.js → HelpView-SHMVMHNU.js} +1 -1
- package/dist/{InfoBox-GQQJVTI5.js → InfoBox-W2LZVGQS.js} +1 -1
- package/dist/{LinksBox-EWCPAZFN.js → LinksBox-ZS25VTBY.js} +1 -1
- package/dist/{ProfilesView-5FJNQMUW.js → ProfilesView-XBBRIQ3U.js} +1 -1
- package/dist/{ProjectPicker-IN7GFN7I.js → ProjectPicker-AUN47FXS.js} +1 -1
- package/dist/{SaveSessionPrompt-ISODGFP7.js → SaveSessionPrompt-Z2K225VN.js} +1 -1
- package/dist/SingleShotApp-M7R5PW4X.js +2 -0
- package/dist/{SummaryBox-R6WHU7VD.js → SummaryBox-4T545XRB.js} +1 -1
- package/dist/TestMdRunView-JXRXMACE.js +2 -0
- package/dist/{WhoamiView-YRQNOSOH.js → WhoamiView-GCVD35EX.js} +1 -1
- package/dist/bind-JLMT57Q3.js +6 -0
- package/dist/{bridge-7UMWMIJJ.js → bridge-PDJEOSAJ.js} +1 -1
- package/dist/{changelog-YQC2QDCO.js → changelog-D65HWZDM.js} +1 -1
- package/dist/{chat-committer-GHDZY5XF.js → chat-committer-ADJJTDUT.js} +1 -1
- package/dist/{chat-controller-QXFAB2DK.js → chat-controller-VAC57IEV.js} +1 -1
- package/dist/{chunk-B5LJCGAY.js → chunk-24OFJ7SE.js} +1 -1
- package/dist/{chunk-PJDOXRLB.js → chunk-24VYAMMK.js} +1 -1
- package/dist/chunk-262ES67I.js +14 -0
- package/dist/{chunk-CIW2KP4C.js → chunk-2BWRAY3Y.js} +1 -1
- package/dist/{chunk-KHDUQ33H.js → chunk-2PQXEEVY.js} +1 -1
- package/dist/{chunk-F66SSA4C.js → chunk-2WO7G2HO.js} +1 -1
- package/dist/{chunk-Y6LMHBLE.js → chunk-32GP7KTM.js} +1 -1
- package/dist/{chunk-NNZV5RCE.js → chunk-3C5GMAM4.js} +1 -1
- package/dist/{chunk-SHSV64GX.js → chunk-3Z3UIW5H.js} +1 -1
- package/dist/{chunk-OE7TVGNB.js → chunk-4A6BLXQN.js} +3 -3
- package/dist/chunk-4R2HOA7J.js +14 -0
- package/dist/{chunk-AV5SUGRY.js → chunk-4SXD6XWV.js} +1 -1
- package/dist/{chunk-FFL2TQEJ.js → chunk-5JJ245FW.js} +1 -1
- package/dist/chunk-5YPBPZUR.js +2 -0
- package/dist/chunk-64LC36AF.js +2 -0
- package/dist/{chunk-Z56AWGVY.js → chunk-6AYUSR7X.js} +1 -1
- package/dist/{chunk-Y7KW5AEN.js → chunk-6CZIEK6B.js} +1 -1
- package/dist/{chunk-VJUIW2ES.js → chunk-6GTOYTCQ.js} +1 -1
- package/dist/{chunk-EWFFJBAM.js → chunk-6NIV7AVZ.js} +1 -1
- package/dist/chunk-6SGPN76K.js +2 -0
- package/dist/{chunk-7MV5UF6O.js → chunk-6XHAXAL2.js} +1 -1
- package/dist/{chunk-AE6SS34N.js → chunk-74RUSHIB.js} +1 -1
- package/dist/{chunk-RLG5NUTE.js → chunk-AKHUNBQS.js} +1 -1
- package/dist/{chunk-53VDR5DN.js → chunk-BLSZ4H5W.js} +12 -12
- package/dist/{chunk-OGVIHL5G.js → chunk-BV5QKFMJ.js} +1 -1
- package/dist/{chunk-SL7AJ7JQ.js → chunk-C42WWO7Y.js} +1 -1
- package/dist/{chunk-FYOCF7DY.js → chunk-CJJXT5DO.js} +1 -1
- package/dist/chunk-D7L6UW5Z.js +7 -0
- package/dist/chunk-EHN5HTUD.js +147 -0
- package/dist/{chunk-P46TIMGQ.js → chunk-EOLQUB4Q.js} +1 -1
- package/dist/{chunk-C5POEXSX.js → chunk-EWTX7HSU.js} +2 -2
- package/dist/{chunk-RGEAEAZB.js → chunk-FJTWJ243.js} +1 -1
- package/dist/{chunk-CE664P73.js → chunk-GBBVP2JW.js} +1 -1
- package/dist/chunk-GLS46X7N.js +5 -0
- package/dist/{chunk-AD46OCZ4.js → chunk-GRB66C5S.js} +1 -1
- package/dist/{chunk-22A2ECA2.js → chunk-GYW7LVVL.js} +1 -1
- package/dist/{chunk-BO3JA2GS.js → chunk-HA5GE57Z.js} +15 -15
- package/dist/{chunk-VXGOWBET.js → chunk-HWA7WD44.js} +1 -1
- package/dist/{chunk-7YQW4TFI.js → chunk-JF7Q2I45.js} +1 -1
- package/dist/{chunk-TTSYHJLX.js → chunk-JTEY32TL.js} +1 -1
- package/dist/{chunk-DEEBPSJN.js → chunk-JU5KRCKD.js} +4 -4
- package/dist/chunk-JV356AYH.js +5 -0
- package/dist/chunk-K5JGCJ2K.js +6 -0
- package/dist/{chunk-UXJPCWGW.js → chunk-KI2DVQSA.js} +1 -1
- package/dist/chunk-KNCHEM6A.js +9 -0
- package/dist/{chunk-YZSYXNMB.js → chunk-KYHXDJN4.js} +1 -1
- package/dist/{chunk-326XAPMW.js → chunk-L26LU6TU.js} +2 -2
- package/dist/{chunk-WFRL54GK.js → chunk-LABIRPOT.js} +1 -1
- package/dist/{chunk-BFFCGEUH.js → chunk-LEQ2B3PR.js} +1 -1
- package/dist/{chunk-EEO4XWY6.js → chunk-LLS47HUA.js} +1 -1
- package/dist/{chunk-2S4S2XJC.js → chunk-LURGFJEE.js} +1 -1
- package/dist/{chunk-D5T4ARTB.js → chunk-MCQXRJGH.js} +1 -1
- package/dist/{chunk-2TVRHXRK.js → chunk-MSPZOEFB.js} +1 -1
- package/dist/{chunk-YZKPZXHY.js → chunk-MY32TBBR.js} +1 -1
- package/dist/{chunk-BGGNBWAJ.js → chunk-N6DO2LBH.js} +1 -1
- package/dist/{chunk-ARS72637.js → chunk-OFEOWKM3.js} +1 -1
- package/dist/{chunk-TZZYRDCF.js → chunk-P4HW2NTZ.js} +1 -1
- package/dist/{chunk-LMJTY32X.js → chunk-RHNKYNNZ.js} +1 -1
- package/dist/{chunk-RZFINU7J.js → chunk-RIMJDJWY.js} +1 -1
- package/dist/{chunk-ZKYYZ5NO.js → chunk-RN4OSVTG.js} +2 -2
- package/dist/{chunk-ME5QSYWX.js → chunk-RV2NXHIC.js} +1 -1
- package/dist/{chunk-SQFNMZJ2.js → chunk-S2C62SDY.js} +1 -1
- package/dist/chunk-SJ2KQKOV.js +3 -0
- package/dist/{chunk-G6AF2JUA.js → chunk-UZJ7MRBV.js} +1 -1
- package/dist/{chunk-XBE7PGVY.js → chunk-VBCE4U4B.js} +1 -1
- package/dist/chunk-WIA7TPK3.js +2 -0
- package/dist/{chunk-F2K3XFFH.js → chunk-WJGBXJT4.js} +2 -2
- package/dist/{chunk-7LFCSSPX.js → chunk-WWH7CW5R.js} +1 -1
- package/dist/{chunk-NFGG5DA2.js → chunk-XQL53VB7.js} +1 -1
- package/dist/{chunk-B2PZAB7J.js → chunk-ZG2V2ODK.js} +1 -1
- package/dist/{chunk-GIRXJOJI.js → chunk-ZZLR3O5A.js} +1 -1
- package/dist/{config-5OOP2BO3.js → config-6PAZZ7CR.js} +1 -1
- package/dist/{cover-cmd-Y5L4O4Q3.js → cover-cmd-K3LCXHAQ.js} +1 -1
- package/dist/{credentials-XCP6DJZZ.js → credentials-BJCIWQWA.js} +1 -1
- package/dist/descriptor-EHK3DRCZ.js +2 -0
- package/dist/{evidence-AX67Q6RN.js → evidence-7VE5EGEF.js} +1 -1
- package/dist/evolve-cmd-RUGUWKAG.js +2 -0
- package/dist/explain-VFIZTHFN.js +2 -0
- package/dist/{explain-cmd-RIDEMDMY.js → explain-cmd-KV5YUXKB.js} +1 -1
- package/dist/{explain-cmd-55WRDIMW.js → explain-cmd-U367SD4N.js} +1 -1
- package/dist/{extract-bind-ZDAXRQUS.js → extract-bind-YS7C4KZ3.js} +2 -2
- package/dist/{extract-cmd-5GGI6LAM.js → extract-cmd-Z4PMDIMZ.js} +2 -2
- package/dist/{gaps-cmd-P2DRK6FW.js → gaps-cmd-DTVDIOED.js} +1 -1
- package/dist/{gate-FACZRGOC.js → gate-B6C6KLFA.js} +1 -1
- package/dist/{generate-headless-DRDE46ON.js → generate-headless-IWY32HC4.js} +2 -2
- package/dist/{headless-io-GXHKDPHB.js → headless-io-PWW6YKH2.js} +1 -1
- package/dist/index.js +43 -43
- package/dist/ingest-C5ANIN7S.js +2 -0
- package/dist/ingest-cmd-LLC5CDQ5.js +3 -0
- package/dist/interactive-bind-ZIIJDRBU.js +7 -0
- package/dist/{lifecycle-cmd-55NZL3UO.js → lifecycle-cmd-BXE5IMFN.js} +1 -1
- package/dist/{list-cmd-JB2ABACD.js → list-cmd-KBWPYJMV.js} +1 -1
- package/dist/{list-commands-UDAL3SBY.js → list-commands-SSXJQGE7.js} +1 -1
- package/dist/{logical-ids-ATVR6PF2.js → logical-ids-3Y6RX5C2.js} +1 -1
- package/dist/login-flow-HRS6YACY.js +2 -0
- package/dist/{maintenance-cmd-E3HEEVQW.js → maintenance-cmd-VS3APIUN.js} +1 -1
- package/dist/{persist-recorded-session-BW3YSFMP.js → persist-recorded-session-3AOYZJT2.js} +1 -1
- package/dist/pipeline-IZSODNCC.js +2 -0
- package/dist/readmodel-XOGOELUP.js +2 -0
- package/dist/reconcile-cmd-6HVZJFG3.js +2 -0
- package/dist/{recording-banner-6FVTCUWQ.js → recording-banner-KKEUWS3N.js} +1 -1
- package/dist/{require-project-folder-AQUVEEJB.js → require-project-folder-NPTKR2AW.js} +1 -1
- package/dist/{revert-3TKLOYQA.js → revert-AQQ2VHRM.js} +1 -1
- package/dist/{review-cmd-RXPPC5GK.js → review-cmd-4WZUUOE4.js} +1 -1
- package/dist/run-2A7M7EJK.js +2 -0
- package/dist/run-6AFY35QW.js +2 -0
- package/dist/{run-test-md-AUK7NGLL.js → run-test-md-QNC6KDMN.js} +2 -2
- package/dist/{skill-installer-2MNPCPRD.js → skill-installer-ULFNSE6X.js} +1 -1
- package/dist/{spawner-XCOMTJJC.js → spawner-DWONVIPI.js} +1 -1
- package/dist/tcg-generate-IHHPRVNG.js +2 -0
- package/dist/{testmd-actions-TU4KTO32.js → testmd-actions-S3ZNOZEK.js} +1 -1
- package/dist/token-refresh-CFVOA62N.js +2 -0
- package/dist/{validate-basic-IYMPP7C7.js → validate-basic-4OLDKIA2.js} +1 -1
- package/dist/{version-check-MUPSKONS.js → version-check-UL4S6R4N.js} +1 -1
- package/dist/{view-cmd-QE2FS3GB.js → view-cmd-FRMQF76B.js} +1 -1
- package/dist/walk-session-N3BP57HK.js +2 -0
- package/package.json +16 -8
- package/bin/kane-cli.js +0 -2
- package/dist/ChatSurface-J777M5WC.js +0 -8
- package/dist/EvidenceViewOffer-JQDEAE2T.js +0 -2
- package/dist/SingleShotApp-QANGFAPO.js +0 -2
- package/dist/TestMdRunView-74A3LCNE.js +0 -2
- package/dist/archive-committer-3NI773TP.js +0 -2
- package/dist/bind-FZ4X4SOK.js +0 -6
- package/dist/chunk-6RQAUK5F.js +0 -5
- package/dist/chunk-E4OYR32M.js +0 -2
- package/dist/chunk-FTD3B7QA.js +0 -2
- package/dist/chunk-GIGD4M7V.js +0 -5
- package/dist/chunk-I2S6KNZW.js +0 -2
- package/dist/chunk-IACKIGPX.js +0 -2
- package/dist/chunk-NFOBDHZK.js +0 -147
- package/dist/chunk-Q4HLQOJI.js +0 -7
- package/dist/chunk-SGU72YLH.js +0 -9
- package/dist/chunk-TY5LWU6I.js +0 -14
- package/dist/chunk-YANCBRER.js +0 -3
- package/dist/descriptor-SL5A7RQE.js +0 -2
- package/dist/distill-cmd-EYCCCFL3.js +0 -2
- package/dist/evolve-cmd-HR25DRTC.js +0 -2
- package/dist/explain-JIXUWEFJ.js +0 -2
- package/dist/ingest-4CGBXC2L.js +0 -2
- package/dist/ingest-cmd-X7BWGIN7.js +0 -3
- package/dist/interactive-bind-T6OBLZCT.js +0 -7
- package/dist/login-flow-LJ4BH3OS.js +0 -2
- package/dist/pipeline-TZJ652NT.js +0 -2
- package/dist/readmodel-MPTENJ2R.js +0 -2
- package/dist/reconcile-cmd-242S7XNO.js +0 -8
- package/dist/run-UGAOGR3B.js +0 -2
- package/dist/signals-cmd-LXHZQLXZ.js +0 -2
- package/dist/tcg-generate-E5X23RVP.js +0 -2
- package/dist/token-refresh-GGLARJV4.js +0 -2
|
@@ -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-6XHAXAL2.js";import{b as D}from"./chunk-D7L6UW5Z.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as O}from"./chunk-3C5GMAM4.js";import{a as S,b as A,d as P}from"./chunk-GRB66C5S.js";import{a as U}from"./chunk-JFAFKHDX.js";import{a as G}from"./chunk-QPZRHAYK.js";import{d as T}from"./chunk-2PQXEEVY.js";import{a as E,b as $}from"./chunk-MCQXRJGH.js";import{d as g,e as m}from"./chunk-5YPBPZUR.js";var v=(e,t,n=new Set)=>{let o=e.nameOf.get(t);if(o!==void 0)return o;if(n.has(t))return t;n.add(t);for(let[s,r]of e.superseded){if(r!==t)continue;let c=v(e,s,n);if(c!==s)return c}return t};function M(e,t){let n=e.stale(t);if(n==="fresh")return;if(n==="orphaned")return"orphaned \u2014 no live source evidences this item";let o=[],s=new Map;for(let r of e.derivesInto(t))s.set(String(r.props.source_id),r);for(let[r,c]of s){let i=e.heads.get(r);if(i==null||i===c.props.source_cid)continue;let u=e.convChains.get(r)?.chain;u&&u.includes(String(c.props.source_cid))||o.push(`DERIVES pin ${r}@${String(c.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let r of e.edgesFrom(t)){if(r.type===m.DERIVES||!e.superseded.has(r.dst))continue;let c=e.tipOf(r.dst);if(e.superseded.has(c)){o.push(`${r.type} pin \u2192 ${v(e,r.dst)} \u2014 target retired`);continue}let i=L(e,r.dst,c);o.push(i.length>0?`${v(e,r.dst)} updated: ${i.map(u=>u.field).join(", ")}`:`${r.type} pin \u2192 ${v(e,r.dst)} \u2014 target superseded`)}return o.length>0?o.join("; "):"stale \u2014 a pinned dependency moved"}function L(e,t,n){let o=e.getNode(t)?.content??{},s=e.getNode(n)?.content??{},r=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),c=[];for(let i of[...new Set([...Object.keys(o),...Object.keys(s)])].sort())JSON.stringify(o[i])!==JSON.stringify(s[i])&&c.push({field:i,old:r(o[i]),new:r(s[i])});return c}function V(e,t){let n=[];for(let{cid:o}of e.byLabel(g.SCENARIO))e.superseded.has(o)||e.edgesFrom(o).some(s=>s.type===m.BELONGS_TO&&e.tipOf(s.dst)===t)&&n.push(o);return n}function R(e,t){let n=[],o=[],s=[],r=V(e,t),c=new Set(r),i=(u,f)=>{let d=M(e,f);return d===void 0?u:{...u,stale:!0,stale_reason:d}};for(let u of r){let f=e.getNode(u)?.content??{};n.push(i({ref:v(e,u),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},u));for(let d of e.edgesInto(u)){if(d.type!==m.AUTOMATES||e.superseded.has(d.src))continue;let a=e.getNode(d.src)?.content??{},l=e.edgesFrom(d.src).filter(p=>p.type===m.VERIFIES&&!e.superseded.has(p.dst)).map(p=>v(e,p.dst));o.push(i({ref:v(e,d.src),title:String(a.title??""),check:a.check,verifies:l},d.src))}}for(let{cid:u}of e.byLabel(g.AC)){if(e.superseded.has(u))continue;let f=e.edgesFrom(u).find(p=>p.type===m.SCOPED_TO);if(!f)continue;let d=e.tipOf(f.dst);if(!(d===t||c.has(d)))continue;let l=e.getNode(u)?.content??{};s.push(i({ref:v(e,u),text:String(l.text??""),kind:String(l.kind??""),scope:d===t?"use-case":v(e,d)},u))}return{scenarios:n,tests:o,acs:s}}function I(e,t,n){let o=t.getNode(n)?.content.blob;if(typeof o!="string")return null;let s=T(e,o);return s===null?null:s.toString("utf8")}function q(e,t){let n=t.split(`
|
|
3
|
+
`).map(s=>s.replace(/^\d+\| /,"")),o=[];for(let s of e.split(`
|
|
4
|
+
`)){let r=s.trim();if(r.length===0)continue;let c=n.find(i=>i.includes(r));c!==void 0&&!o.includes(c.trim())&&o.push(c.trim())}return o.length>0?o.join(`
|
|
5
|
+
`):{removed:!0}}function J(e,t,n,o){if(o!==void 0&&o.trim().length>0)return{kind:"user-directive",text:o.trim()};let s=[n,...R(t,n).acs.map(u=>t.resolve(u.ref)?.cid??"")].filter(Boolean),r=[],c=new Set;for(let u of s){let f=new Map;for(let d of t.derivesInto(u))f.set(String(d.props.source_id),d);for(let[d,a]of f){let l=t.heads.get(d);if(l==null||l===a.props.source_cid)continue;let p=String(a.props.anchor),b=`${d}\0${p}`;if(c.has(b)||p==="img#whole")continue;c.add(b);let k=I(e,t,String(a.props.source_cid)),w=k===null?null:G(k,p);if(w===null)continue;let x=I(e,t,l);r.push({source_id:d,anchor:p,old_anchor_text:w,new_anchor_text:x===null?{removed:!0}:q(w,x)})}}let i;for(let[u,f]of t.superseded){if(f!==n||t.nodeLabel.get(u)!==g.USECASE)continue;let d=L(t,u,n);d.length>0&&(i=d);break}return{kind:"source-change",changes:r,...i?{uc_updated:i}:{}}}function N(e,t,n,o){let s=R(t,n);if(s.scenarios.length===0&&s.tests.length===0&&s.acs.length===0)return;let r=J(e,t,n,o);if(!(r.kind==="source-change"&&r.changes.length===0&&!r.uc_updated))return{prior_design:s,change_delta:r}}var _=new Set([g.USECASE,g.SCENARIO,g.AC,g.TEST]);function h(e,t){return!e.superseded.has(t)&&e.trust.get(t)!=="archived"}function y(e,t,n){let o=e.edgesFrom(t).find(s=>s.type===n);return o?e.tipOf(o.dst):null}function D(e,t,n){if(n===g.USECASE)return t;if(n===g.SCENARIO)return y(e,t,m.BELONGS_TO);if(n===g.AC){let o=y(e,t,m.SCOPED_TO);return o?e.nodeLabel.get(o)===g.USECASE?o:y(e,o,m.BELONGS_TO):null}if(n===g.TEST){let o=y(e,t,m.AUTOMATES);return o?y(e,o,m.BELONGS_TO):null}return null}function j(e,t){let n=e.nameOf.get(t);if(n)return n;for(let[o,s]of e.names)if(e.tipOf(s)===t)return o;return t}function B(e,t){return{ucTip:t,display:j(e,t),seamRef:e.nameOf.get(t)??t}}function Y(e,t){let n=e.resolve(t);if(!n)return{ok:!1,message:`unknown ref '${t}' \u2014 no test/scenario/ac/use-case by that id or cid`};let o=n.tip,s=e.nodeLabel.get(o);if(!s||!_.has(s))return{ok:!1,message:`'${t}' is a ${s??"missing node"} \u2014 evolve takes a test, scenario, acceptance criterion, or use-case`};let r=D(e,o,s);return!r||e.nodeLabel.get(r)!==g.USECASE?{ok:!1,message:`cannot resolve '${t}' to a parent use-case \u2014 its ${s} chain is broken`}:e.superseded.has(r)?{ok:!1,message:`use-case ${j(e,r)} was removed \u2014 nothing to evolve`}:{ok:!0,target:B(e,r)}}function de(e,t){return C(e,t)}function C(e,t){let n=[];for(let{cid:s}of e.byLabel(g.SCENARIO)){if(!h(e,s)||!e.edgesFrom(s).some(c=>c.type===m.BELONGS_TO&&e.tipOf(c.dst)===t))continue;let r=e.edgesInto(s).filter(c=>c.type===m.AUTOMATES&&h(e,c.src));if(r.length===0)n.push({scenario:s,test:null});else for(let c of r)n.push({scenario:s,test:c.src})}let o=new Map;for(let{cid:s}of e.byLabel(g.AC)){if(!h(e,s)||D(e,s,g.AC)!==t)continue;let r=e.edgesInto(s).filter(c=>c.type===m.VERIFIES&&h(e,c.src)).map(c=>c.src).sort();o.set(s,r)}return{pairs:n,verifies:o}}function H(e,t){let n=c=>`${c.scenario}\0${c.test??""}`,o=new Set(e.pairs.map(n)),s=new Set(t.pairs.map(n)),r=[];for(let[c,i]of e.verifies){let u=t.verifies.get(c);u&&(i.length===u.length&&i.every((f,d)=>f===u[d])||r.push({ac:c,before:i,after:u}))}return{superseded:e.pairs.filter(c=>!s.has(n(c))),minted:t.pairs.filter(c=>!o.has(n(c))),retained:t.pairs.filter(c=>o.has(n(c))),moves:r}}function z(e,t,n,o,s){let r=i=>t.nameOf.get(i)??i,c=i=>` - ${r(i.scenario)} \xB7 ${i.test?r(i.test):"(no test)"}`;e.out(`evolved: use-case ${n} \u2014 design record ${o.before} \u2192 ${o.after}`),e.out(`superseded: ${s.superseded.length} pair(s)`);for(let i of s.superseded)e.out(c(i));e.out(`minted: ${s.minted.length} pair(s)`);for(let i of s.minted)e.out(c(i));e.out(`retained: ${s.retained.length} pair(s)`);for(let i of s.retained)e.out(c(i));if(s.moves.length===0)e.out("verifies moves: none");else{e.out("verifies moves:");for(let i of s.moves){let u=f=>f.length>0?f.map(r).join(" + "):"(none)";e.out(` - ${r(i.ac)}: ${u(i.before)} \u2192 ${u(i.after)}`)}}}async function F(e,t,n,o,s,r){let c=E(e),i=O(c,t.ucTip);if(!i)return r==="batch"?(o.out(`note: ${t.display} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${t.display} first`),{code:0,outcome:"no-design"}):(S(o,`nothing to evolve \u2014 run kane-cli design tests --use-case ${t.display} first (no design output)`),{code:2,outcome:"no-design"});let u=C(c,t.ucTip),f=`evolve re-designs the parent use-case ${t.display}; ${u.pairs.length} pair(s) affected`;if(n.yes)o.out(f);else if(!await o.confirm(`${f} \u2014 proceed?`))return o.out(r==="batch"?`skipped ${t.display}`:"declined \u2014 nothing evolved"),{code:0,outcome:"declined"};let d=N(e,c,t.ucTip,n.because),a=await s(t.seamRef,{yes:!!n.yes,...n.mode?{mode:n.mode}:{},...n.because?{because:n.because}:{},...d!==void 0?{changeDelta:d.change_delta,priorDesign:d.prior_design}:{}});if(a===3)return o.out(`design session for ${t.display} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`),{code:a,outcome:"paused"};if(a!==0)return S(o,`design run for ${t.display} ended with exit code ${a} \u2014 no diff to report`),{code:a,outcome:"failed"};let l=E(e),p=l.tipOf(t.ucTip),b=O(l,p)?.seq;return z(o,l,t.display,{before:i.seq,after:b??"?"},H(u,C(l,p))),{code:0,outcome:"evolved"}}function K(e){let t=new Map,n=0;for(let{cid:s,state:r}of e.staleList()){if(r==="superseded")continue;let c=e.nodeLabel.get(s);if(!c||!_.has(c)||!h(e,s)||!$(e,s))continue;let i=D(e,s,c);!i||e.nodeLabel.get(i)!==g.USECASE||e.superseded.has(i)||(n++,t.has(i)||t.set(i,B(e,i)))}return{targets:[...t.values()].sort((s,r)=>s.display<r.display?-1:s.display>r.display?1:0),staleCount:n}}function Q(e,t){for(let{cid:n,state:o}of e.staleList()){if(o==="superseded")continue;let s=e.nodeLabel.get(n);if(!(!s||!_.has(s)||!h(e,n))&&$(e,n)&&D(e,n,s)===t)return!0}return!1}async function W(e,t,n,o={},s=process.cwd()){if(e&&t.fromStale)return S(n,"pass a <ref> OR --from-stale, not both"),2;if(!e&&!t.fromStale)return S(n,"evolve needs a <ref> or --from-stale"),2;let r=A(s,n);if(!r)return 2;let c=o.runDesignForUc??X;n.out(`evolving ${e??"stale use-cases"}: reading the graph\u2026`);let i=E(r),u,f=null;if(e){let a=Y(i,e);if(!a.ok)return S(n,a.message),2;if(!t.because&&O(i,a.target.ucTip)&&!Q(i,a.target.ucTip))return S(n,`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`),2;u=[a.target]}else{let{targets:a,staleCount:l}=K(i);if(a.length===0)return n.out("nothing stale \u2014 nothing to evolve"),0;f=`from-stale: ${l} stale node(s) \u2192 ${a.length} use-case(s)`,u=a}if(!t.yes&&!n.isTTY)return S(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless evolution rides `kane-cli maintain reconcile`"),2;if(f&&n.out(f),e){let a=await F(r,u[0],t,n,c,"single");return a.outcome==="evolved"&&t.because&&U(r,{ts:new Date().toISOString(),command:"evolve",id:e,verdict:"gap-resolved-evolve",polarity:"preference",by:{kind:"human",id:process.env.USER??"operator"},target:e,reason:t.because}),a.code}let d=0;for(let a of u){let{code:l}=await F(r,a,t,n,c,"batch");l!==0&&d===0&&(d=l)}return d}var X=async(e,t)=>{let{designTestsCommand:n}=await import("./bind-JLMT57Q3.js"),o=()=>n({useCase:e,force:!0,...t.mode?{mode:t.mode}:t.yes?{mode:"override"}:{},...t.because?{because:t.because}:{},...t.changeDelta!==void 0?{changeDelta:t.changeDelta}:{},...t.priorDesign!==void 0?{priorDesign:t.priorDesign}:{}});if(t.mode!=="agent")return o();let s=process.stdout.write;process.stdout.write=((...r)=>!0);try{return await o()}finally{process.stdout.write=s}};async function ae(e,t){return W(e,t,P(),{})}export{Y as a,de as b,F as c,K as d,W as e,X as f,ae as g};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{closeSync as A,existsSync as $,mkdirSync as h,openSync as k,readFileSync as p,readdirSync as w,renameSync as S,rmSync as g,writeFileSync as m}from"fs";import{join as l}from"path";var a=class extends Error{constructor(r,t){super(`${r}: ${t}`);this.code=r}},d=e=>l(e,"reconcile","plans");function u(e,n){let r=`${e}.tmp-${process.pid}`;m(r,n,{mode:384}),S(r,e)}function N(e,n){let r=d(e);h(r,{recursive:!0});let t=l(r,`${n.created}-${n.source_id}.json`);return u(t,JSON.stringify(n,null,2)+`
|
|
3
|
+
`),t}function y(e,n){let r=n;if(r===void 0){let s=d(e),c=[];try{c=w(s).filter(P=>P.endsWith(".json")).sort()}catch{}if(c.length===0)return{error:`no stored plans under ${s} \u2014 run reconcile --plan first`};r=l(s,c[c.length-1])}if(!$(r))return{error:`no such plan file: ${r}`};let t;try{t=p(r,"utf8")}catch(s){return{error:`cannot read plan ${r}: ${s instanceof Error?s.message:String(s)}`}}let i;try{i=JSON.parse(t)}catch(s){return{error:`corrupted plan ${r}: ${s instanceof Error?s.message:String(s)}`}}let o=i?.version;return o===1?{error:`plan predates the vocabulary change \u2014 recompute with --from <file> --source-id <id> (${r})`}:o!==2?{error:`unsupported plan version ${String(o)} in ${r} (expected 2)`}:Array.isArray(i.rows)?{plan:i,path:r}:{error:`not a reconcile plan \u2014 ${r} has no rows[] (hand-edited?)`}}function R(e){let n=e.archive_state??{};return(e.changeset??[]).filter(r=>r.kind==="ARCHIVE"&&n[r.ref]===void 0).map(r=>r.ref)}function D(e,n,r){let t=y("",e);if("error"in t)throw new a("PLAN_UNREADABLE",t.error);let i=t.plan,o=i.archive_state??{};if(o[n]!==void 0)throw new a("ROW_ALREADY_APPLIED",`archive ${n} already ${o[n].outcome}`);o[n]={at:new Date().toISOString(),outcome:r},i.archive_state=o,u(e,JSON.stringify(i,null,2)+`
|
|
4
|
+
`)}function _(e,n){let r=d(e),t=[];try{t=w(r).filter(i=>i.endsWith(`-${n}.json`)).sort()}catch{}return t.length===0?null:y(e,l(r,t[t.length-1]))}function O(e,n){let r=_(e,n);if(r===null||"error"in r)return null;let t=r.plan.rows.filter(i=>i.applied===void 0).length+R(r.plan).length;return t>0?{path:r.path,created:r.plan.created,pending:t}:null}function I(e,n,r){let t;try{t=JSON.parse(p(e,"utf8"))}catch(o){throw new a("PLAN_UNREADABLE",`${e}: ${o instanceof Error?o.message:String(o)}`)}let i=t.rows?.[n];if(!i)throw new a("ROW_MISSING",`${e} has no row ${n}`);if(i.applied)throw new a("ROW_ALREADY_APPLIED",`row ${n} of ${e} was already applied (${i.applied.outcome} at ${i.applied.at})`);i.applied={at:new Date().toISOString(),outcome:r},u(e,JSON.stringify(t,null,2)+`
|
|
5
|
+
`)}function x(e){let n=d(e);h(n,{recursive:!0});let r=l(n,".walk-lock");for(let t=0;t<2;t++)try{let i=k(r,"wx");return m(i,`${process.pid}
|
|
6
|
+
`),A(i),()=>{try{g(r)}catch{}}}catch(i){if(i.code!=="EEXIST")throw i;let o=f(r);if(!Number.isFinite(o)){let c=Date.now()+50;for(;Date.now()<c;);o=f(r)}if(Number.isFinite(o)&&v(o))throw new a("WALK_LOCKED",`another reconcile walk is running (pid ${o}) \u2014 remove ${r} if that process is gone`);try{g(r)}catch{}}throw new a("WALK_LOCKED",`could not take the walk lock at ${l(n,".walk-lock")}`)}function f(e){try{return parseInt(p(e,"utf8").trim(),10)}catch{return NaN}}function v(e){try{return process.kill(e,0),!0}catch{return!1}}export{N as a,y as b,R as c,D as d,_ as e,O as f,I as g,x as h};
|
|
@@ -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-5JJ245FW.js";import{a as te}from"./chunk-2WO7G2HO.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-6NIV7AVZ.js";import{a as ve}from"./chunk-3Z3UIW5H.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{y as i}from"./chunk-6SGPN76K.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};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as K,d as W}from"./chunk-RE3BZVGE.js";import{d as D}from"./chunk-JFAFKHDX.js";import{a as G}from"./chunk-YKTYVJBN.js";import{d as X}from"./chunk-2PQXEEVY.js";import{a as Q}from"./chunk-MCQXRJGH.js";import{a as H}from"./chunk-ZZLR3O5A.js";import{g as z}from"./chunk-ZG2V2ODK.js";import{d as U,f as j}from"./chunk-5YPBPZUR.js";import{a as P,c as B}from"./chunk-6SGPN76K.js";function lt(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?`~${t.slice(e.length)}`:t}import{readFileSync as Se,writeFileSync as Ee,renameSync as $e,mkdirSync as Re}from"fs";import{dirname as Ce,join as Te}from"path";var O=1,Me=720*60*1e3;function F(t){return Te(B,"embeddings",`alias-${t}.json`)}function J(t,e=Date.now()){return t!==null&&e-t.fetchedAt<Me}function Y(t){try{let e=JSON.parse(Se(t,"utf-8"));return e.wrapperVersion!==O||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:O,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function Z(t,e,n=F(t)){let r=Y(n)?.purposes?.[e];return!r||typeof r.alias!="string"||typeof r.dims!="number"||typeof r.fetchedAt!="number"?null:{alias:r.alias,dims:r.dims,fetchedAt:r.fetchedAt}}function q(t,e,n,s=F(t)){try{Re(Ce(s),{recursive:!0});let a=Y(s)?.purposes??{};a[e]={alias:n.alias,dims:n.dims,fetchedAt:Date.now()};let o={wrapperVersion:O,writtenByVersion:P,purposes:a},m=`${s}.tmp`;Ee(m,JSON.stringify(o,null,2)+`
|
|
3
|
+
`),$e(m,s)}catch(r){process.stderr.write(`[embed] Failed to save alias cache: ${r instanceof Error?r.message:String(r)}
|
|
4
|
+
`)}}function De(t){return t.TESTMUAI_ENV==="stage"?"stage":"prod"}function ee(t){let e=t.env??process.env,n=t.auth?.TESTMUAI_BASIC_AUTH||e.TESTMUAI_BASIC_AUTH;if(n)return{authorization:`Basic ${n}`};let s=t.auth?.TESTMUAI_API_KEY||e.TESTMUAI_API_KEY;return s?{authorization:`Bearer ${s}`}:{}}async function te(t,e={}){let n=e.env??process.env,s=De(n),r=e.aliasCacheFile??F(s),a=e.now??Date.now,o=Z(s,t,r);if(J(o,a()))return{alias:o.alias,dims:o.dims};let d=`${G(n)}/assurance/embed/alias?purpose=${encodeURIComponent(t)}`,f=await(e.fetchImpl??fetch)(d,{method:"GET",headers:ee(e)});if(!f.ok)throw new Error(`embed alias resolve failed: ${f.status}`);let c=await f.json();return q(s,t,{alias:c.alias,dims:c.dims},r),{alias:c.alias,dims:c.dims}}async function ne(t,e,n={}){let s=n.env??process.env,r=G(s),a=await(n.fetchImpl??fetch)(`${r}/assurance/embed`,{method:"POST",headers:{...ee(n),"content-type":"application/json"},body:JSON.stringify({purpose:t,input:e})});if(!a.ok)throw new Error(`embed failed: ${a.status}`);return await a.json()}import{randomBytes as nt}from"crypto";function re(t,e){let n=Math.min(t.length,e.length),s=0,r=0,a=0;for(let o=0;o<n;o++)s+=t[o]*e[o],r+=t[o]*t[o],a+=e[o]*e[o];return r===0||a===0?0:s/(Math.sqrt(r)*Math.sqrt(a))}function se(t,e,n){return n*t+(1-n)*e}var ie=.7;import{readFileSync as Fe,writeFileSync as Ne,renameSync as Le,mkdirSync as Ge}from"fs";import{dirname as Oe,join as oe}from"path";function Ve(t){return oe(t,"embeddings")}function Ie(t){let e=t.indexOf(":");return e>=0?t.slice(e+1):t}function ae(t,e,n){let s=Ie(n);return oe(Ve(t),e,s.slice(0,2),`${s.slice(2)}.f32`)}function ce(t,e,n){try{let s=Fe(ae(t,e,n)),r=new Float32Array(Math.floor(s.length/4));for(let a=0;a<r.length;a++)r[a]=s.readFloatLE(a*4);return r}catch{return null}}function le(t,e,n,s){try{let r=ae(t,e,n);Ge(Oe(r),{recursive:!0});let a=Buffer.alloc(s.length*4);for(let m=0;m<s.length;m++)a.writeFloatLE(s[m],m*4);let o=`${r}.tmp`;Ne(o,a),Le(o,r)}catch(r){process.stderr.write(`[embed] Failed to cache vector: ${r instanceof Error?r.message:String(r)}
|
|
5
|
+
`)}}var Pe=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar"],Be=["source_read","source_grep"],Ue=[...Pe,...Be],fe=50,V=200,pe=10,ge=50,ue=20,je=200,He=50;function N(t,e,n){let s=typeof t=="number"&&Number.isFinite(t)?Math.floor(t):e;return Math.max(1,Math.min(s,n))}function $(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new w(`param "${e}" must be a non-empty string`);return n}function E(t,e){let n=t[e];if(n==null)return null;if(typeof n!="string")throw new w(`param "${e}" must be a string when present`);return n}var w=class extends Error{};function I(t,e){let n=t.getNode(e);return n?{cid:e,label:n.label,content:n.content,trust:t.trust.get(e)??null,freshness:t.stale(e)}:null}function de(t){return new Set(t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function he(t,...e){let n=de(t);if(n.size===0)return 0;let s=t.trim().toLowerCase(),r=0;for(let a of e){let o=de(a);if(o.size===0)continue;let m=0;for(let c of n)o.has(c)&&m++;let d=n.size+o.size-m,f=d===0?0:m/d;s&&a.toLowerCase().includes(s)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function ze(t,e){let n=$(e,"cid"),s=E(e,"type"),r=E(e,"direction")??"both";if(!["out","in","both"].includes(r))throw new w('param "direction" must be out|in|both');let a=N(e.limit,fe,V),o=[];return(r==="out"||r==="both")&&o.push(...t.edgesFrom(n)),(r==="in"||r==="both")&&o.push(...t.edgesInto(n)),o.filter(m=>s==null||m.type===s).slice(0,a)}function Qe(t,e){let n=$(e,"source_id"),s=t.heads.get(n)??null,r=[];for(let a of t.nodeLabel.keys()){let o=t.derivesInto(a).filter(d=>d.props.source_id===n).map(d=>({source_cid:d.props.source_cid,anchor:d.props.anchor??null}));if(o.length===0)continue;let m=I(t,a);if(m&&(r.push({...m,pins:o,pinned_to_head:s!=null&&o.some(d=>d.source_cid===s)}),r.length>=V))break}return r}function Xe(t,e){let n=$(e,"label"),s=E(e,"trust"),r=E(e,"freshness"),a=N(e.limit,fe,V),o=[];for(let{cid:m}of t.byLabel(n)){let d=I(t,m);if(d&&!(s!=null&&d.trust!==s)&&!(r!=null&&d.freshness!==r)&&(o.push(d),o.length>=a))break}return o}function Ke(t){return t.staleList().map(({cid:e,state:n})=>{let s=t.getNode(e);return{cid:e,state:n,label:s?.label??null,title:s?.content.title??null}})}function We(t,e){let n=$(e,"text"),s=E(e,"label")??"usecase",r=N(e.k,pe,ge),a=[];for(let{cid:o,content:m}of t.byLabel(s)){let d=String(m.title??""),f=String(m.summary??""),c=he(n,d,f);c<=0||a.push({cid:o,title:d,summary:f,score:Math.round(c*1e3)/1e3,trust:t.trust.get(o)??null,freshness:t.stale(o)})}return a.sort((o,m)=>m.score-o.score||o.cid.localeCompare(m.cid)),a.slice(0,r)}function _e(t,e,n){let s=t.heads.get(n);if(typeof s!="string"){let o=[...t.heads.keys()].sort().join(", ");throw new w(`unknown source_id "${n}" \u2014 known: ${o||"(none)"}`)}if(t.mediaOf(s).format==="image")throw new w(`source "${n}" is an image \u2014 no line window (cite img#whole)`);let r=t.getNode(s)?.content?.blob,a=typeof r=="string"?X(e,r):null;if(a==null)throw new w(`source "${n}" blob is missing from the store`);return{head:s,lines:a.toString("utf8").replace(/\n$/,"").split(`
|
|
6
|
+
`)}}function Je(t,e,n){return t.slice(e-1,n).map((s,r)=>`${String(e+r).padStart(4,"0")}| ${s}`).join(`
|
|
7
|
+
`)}function Ye(t,e,n){let s=$(e,"source_id"),r=E(e,"anchor"),a=e.line_range;if(r!=null&&a!=null)throw new w("give anchor OR line_range, not both");let{head:o,lines:m}=_e(t,n,s),d=m.length,f,c;if(r!=null){let p=/^L(\d+)-L(\d+)$/.exec(r);if(!p)throw new w(`anchor "${r}" is not L<a>-L<b>`);let y=Number(p[1]),u=Number(p[2]);if(y<1||u<y||u>d)throw new w(`anchor "${r}" does not resolve (source has ${d} lines)`);f=Math.max(1,y-ue),c=Math.min(d,u+ue)}else if(a!=null){if(!Array.isArray(a)||a.length!==2||!a.every(u=>Number.isInteger(u)))throw new w('param "line_range" must be [from_line, to_line]');let[p,y]=a;if(p<1||y<p)throw new w('param "line_range" must be 1-based with from \u2264 to');if(p>d)throw new w(`line_range starts past the end (source has ${d} lines)`);f=p,c=Math.min(y,d)}else f=1,c=d;return c=Math.min(c,f+je-1),{window:Je(m,f,c),from_line:f,to_line:c,source_cid:o}}function Ze(t,e,n){let s=$(e,"pattern"),r=E(e,"source_id"),a;try{a=new RegExp(s,"u")}catch(f){throw new w(`invalid pattern: ${f instanceof Error?f.message:String(f)}`)}let o=r!=null?[r]:[...t.heads.keys()].sort(),m=[],d=!1;e:for(let f of o){if(r==null){let p=t.heads.get(f);if(typeof p!="string"||t.mediaOf(p).format==="image")continue}let{lines:c}=_e(t,n,f);for(let p=0;p<c.length;p++)if(a.test(c[p])){if(m.length>=He){d=!0;break e}m.push({source_id:f,line:p+1,text:c[p]})}}return{matches:m,truncated:d}}function qe(t,e,n,s){try{switch(e){case"get_node":return{ok:!0,result:I(t,$(n,"cid"))};case"get_edges":return{ok:!0,result:ze(t,n)};case"find_by_provenance":return{ok:!0,result:Qe(t,n)};case"match_by_type":return{ok:!0,result:Xe(t,n)};case"stale_nodes":return{ok:!0,result:Ke(t)};case"search_similar":return{ok:!0,result:We(t,n)};case"source_read":case"source_grep":{if(s==null)throw new w("source text unavailable (no context store)");return{ok:!0,result:(e==="source_read"?Ye:Ze)(t,n,s)}}default:return{ok:!1,error:`unknown method: ${e} \u2014 available: ${Ue.join(", ")}`}}}catch(r){return r instanceof w?{ok:!1,error:`${e}: ${r.message}`}:{ok:!1,error:`${e}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}}var me="assurance.sim";function et(t){return[t.title,t.summary,t.description].filter(Boolean).join(`
|
|
8
|
+
`)}async function tt(t,e,n){let s=$(e,"text"),r=E(e,"label")??"usecase",a=N(e.k,pe,ge),o=[];for(let{cid:d,content:f}of t.byLabel(r)){if(t.superseded.has(d))continue;let c=String(f.title??""),p=String(f.summary??""),y=String(f.description??"");o.push({cid:d,title:c,summary:p,description:y,lex:he(s,c,p,y)})}let m=d=>{let f=[];for(let c of o){let p=d(c);p.score<=0||f.push({cid:c.cid,title:c.title,summary:c.summary,score:Math.round(p.score*1e3)/1e3,trust:t.trust.get(c.cid)??null,freshness:t.stale(c.cid),...p.dense!==void 0?{dense_score:Math.round(p.dense*1e3)/1e3,lexical_score:Math.round(c.lex*1e3)/1e3}:{}})}return f.sort((c,p)=>p.score-c.score||c.cid.localeCompare(p.cid)),f.slice(0,a)};try{let d=n.readVector??ce,f=n.writeVector??le,c=n.alpha??ie,{alias:p}=await n.resolveAlias(me),y=new Map,u=[],b=[];for(let h of o){let k=d(n.contextDir,p,h.cid);k?y.set(h.cid,k):(u.push(h.cid),b.push(et(h)))}let{vectors:v}=await n.embed(me,[s,...b]),A=Float32Array.from(v[0]);for(let h=0;h<u.length;h++){let k=Float32Array.from(v[h+1]);y.set(u[h],k),f(n.contextDir,p,u[h],k)}return m(h=>{let k=y.get(h.cid),x=k?re(A,k):0;return{score:se(x,h.lex,c),dense:x}})}catch{return m(d=>({score:d.lex}))}}async function ye(t,e,n,s){if(e==="search_similar"&&s)try{return{ok:!0,result:await tt(t,n,s)}}catch(r){return r instanceof w?{ok:!1,error:`${e}: ${r.message}`}:{ok:!1,error:`${e}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}return qe(t,e,n,s?.contextDir)}var rt=2,we=10,st=2;function be(t,e,n){return t.map(s=>{let r=e.find(a=>a.id===s.id);return r&&r.selected_index!=null&&r.selected_index>=0&&r.selected_index<s.options.length?{id:s.id,resolution:"answered",selected_index:r.selected_index,free_text:null}:r&&r.free_text!=null&&s.allow_free_text?{id:s.id,resolution:"answered",selected_index:-1,free_text:r.free_text}:n.explicitAcceptDefaults?{id:s.id,resolution:"assumed-default",selected_index:s.recommended_index,flagged:!0}:{id:s.id,resolution:"deferred",selected_index:null}})}async function Tt(t,e,n,s,r=()=>{},a){let o=(i,l)=>r(i,l,t.session_id),m=(process.env.ASSURANCE_LOG_LEVEL??"info").toLowerCase()==="debug",d={contextDir:e.contextDir,resolveAlias:i=>te(i,{env:process.env,auth:e.auth}),embed:(i,l)=>ne(i,l,{env:process.env,auth:e.auth})},f=0,c=e.agent(t,{auth:e.auth,onWarn:i=>{o("warn",i),e.out(i)},onStderr:i=>o("agent_stderr",i)}),p=null,y=null,u;e.chat?.attachSender?.(i=>c.send(i)),e.initialMessage&&(c.send({type:"user_message",message_id:`msg-${t.session_id}-${nt(3).toString("hex")}`,text:e.initialMessage}),o("user_message_sent",{chars:e.initialMessage.length,...m?{text:e.initialMessage}:{}}),e.emit?.({type:"message_sent",sid:t.session_id,chars:e.initialMessage.length}),e.chat?.note(`delivered your message to the agent: "${e.initialMessage}"`));let b,v=0,A=0,h=0,k,x=K(),C=e.progress??e.out;try{for await(let i of c.events){try{e.chat?.onAgentEvent(i)}catch(l){o("chat_mirror_error",{event_type:i.type,message:l instanceof Error?l.message:String(l)})}if(i.type==="reasoning_delta"?(f+=i.text.length,process.env.KANE_TRACE_REASONING&&o("reasoning_delta",i.text)):o(i.type,i),i.type==="reasoning_done"&&o("reasoning_chars",f),i.type==="progress")C(`\u2026 ${i.stage}${i.n?` #${i.n}`:""}`),e.emit?.({type:"agent_activity",kind:"progress",label:`${i.stage}${i.n?` #${i.n}`:""}`});else if(i.type==="reasoning_delta"||i.type==="reasoning_done"||i.type==="tool_activity"||i.type==="decision_activity"){e.onStreamEvent?.(i);let l=x;if(x=W(x,i),x===l)continue;i.type==="reasoning_delta"?x.liveThinking===i.text&&C("\u2237 thinking\u2026"):i.type==="reasoning_done"?i.present&&(C(`thought for ${(i.took_ms/1e3).toFixed(1)}s`),e.emit?.({type:"agent_activity",kind:"thinking_done",label:`thought for ${(i.took_ms/1e3).toFixed(1)}s`})):i.type==="tool_activity"?i.status!=="done"&&(C(x.activity[x.activity.length-1].label),e.emit?.({type:"agent_activity",kind:"tool",label:x.activity[x.activity.length-1].label})):(C(`\xB7 ${x.activity[x.activity.length-1].label}`),e.emit?.({type:"agent_activity",kind:"decision",label:x.activity[x.activity.length-1].label}))}else if(i.type==="usage")k=i.total_credits,e.emit?.({type:"usage",credits:i.credits,total_credits:i.total_credits});else if(i.type==="graph_query"){let l=await ye(e.graphSlot?.current??s,i.method,i.params??{},d),S=l.ok?{type:"graph_result",id:i.id,ok:!0,result:l.result}:{type:"graph_result",id:i.id,ok:!1,error:l.error};o("graph_result",m?{id:i.id,method:i.method,ok:l.ok,result:l.ok?l.result:l.error}:{id:i.id,method:i.method,ok:l.ok}),c.send(S)}else if(i.type==="session_paused")u=i;else if(i.type==="ask_user"){i.text&&(e.chat?e.chat.ledger({kind:"agent",text:i.text}):e.out(i.text));let l=t.mode;if(l!=="interactive"){let g=i.questions.filter(_=>_.risk==="high");if(l==="ci"&&g.length>0){b=g,c.kill();break}if(l==="agent"&&g.length>0){o("pause_requested",{high:g.map(_=>_.id)}),c.send({type:"pause"});continue}let R=be(i.questions,[],{explicitAcceptDefaults:!0});v+=R.length;for(let _ of R)o("assumed_default",{id:_.id,resolution:_.resolution}),e.emit?.({type:"assumed_default",id:_.id,selected_index:_.selected_index,risk:i.questions.find(M=>M.id===_.id)?.risk});let T={type:"user_response",answers:R.map(_=>({id:_.id,selected_index:_.resolution==="deferred"?null:_.selected_index,free_text:null}))};c.send(T);continue}let S=await e.ask(i.questions),xe=be(i.questions,S,{explicitAcceptDefaults:!1}),ke={type:"user_response",answers:i.questions.map(g=>{let R=S.find(_=>_.id===g.id);if(R?.free_text!=null){let _=n.get(g.id)??0;if(!g.allow_free_text||_>=rt){let M=g.options[g.recommended_index]?.label??"recommended option";if(v+=1,e.emit?.({type:"assumed_default",id:g.id,selected_index:g.recommended_index,risk:g.risk}),e.chat?.noteCoercion)e.chat.noteCoercion(g,M);else{let L=g.text.replace(/\?+\s*$/,""),Ae=L.length<=36?L:`${L.slice(0,33)}\u2026`;e.out(`note: couldn't use a typed answer for "${Ae}" \u2014 kept the recommended option (${M})`)}return{id:g.id,selected_index:g.recommended_index,free_text:null}}return n.set(g.id,_+1),{id:g.id,selected_index:null,free_text:R.free_text}}let T=xe.find(_=>_.id===g.id);return T.resolution==="deferred"?{id:g.id,selected_index:null,free_text:null}:{id:g.id,selected_index:T.selected_index,free_text:null}})};c.send(ke)}else if(i.type==="chat_ops"&&!e.chat){let l=i.chat_ops??i,S=Array.isArray(l.ops)?l.ops.length:0;if(S===0)l.text&&e.out(l.text),c.send({type:"session_complete"}),o("headless_zero_op_chat_turn_complete",{chars:l.text?.length??0});else if(h<st)h+=1,c.send({type:"user_message",message_id:`nochat-${t.session_id}-${h}`,text:"[auto-repair] chat ops are unavailable in this mode \u2014 commit through finalize_design, or finish if nothing remains."}),o("headless_chat_ops_nudge",{n:h,ops:S});else{y="agent kept sending chat ops in a mode with no chat plane",e.out("error: agent kept sending chat ops in a mode with no chat plane \u2014 closing the session"),o("headless_chat_ops_terminal",{ops:S}),c.kill();break}}else if(i.type===(a.terminalEventType??"proposal")){let l=await a.onProposalEvent(i[i.type]);if(p=l.proposal,l.error&&(y=l.error),l.receipt)e.emit?.(l.receipt.event),t.mode!=="interactive"?(A+=1,l.sessionComplete||A>=we?(l.sessionComplete||(e.out(`warning: ${we} commits without completion \u2014 closing the session (runaway guard)`),o("receipt_runaway_cap",{commits:A})),c.send({type:"session_complete"}),o("session_complete_sent",{commit_n:l.receipt.event.commit_n,runaway:!l.sessionComplete})):(c.send({type:"user_message",message_id:`receipt-${t.session_id}-${String(l.receipt.event.commit_n??0)}`,text:l.receipt.text}),o("receipt_sent",{commit_n:l.receipt.event.commit_n,chars:l.receipt.text.length}))):e.chat?.holdReceipt&&(e.chat.holdReceipt(l.receipt.text),o("receipt_held",{commit_n:l.receipt.event.commit_n}));else if(l.error&&t.mode!=="interactive"){e.out("error: commit failed with no repair channel \u2014 closing the session"),o("headless_commit_error_terminal",{error:l.error}),c.kill();break}}else if(i.type==="error"){y=i.message;let l=i.failed_proposal;l&&o("failed_proposal",l)}}}finally{c.kill()}return{proposal:p,error:y,paused:u,highRisk:b,...v>0?{assumedDefaults:v}:{},...k!==void 0?{creditsTotal:k}:{}}}var it=3,ot={edit:"edit",reject:"mistake",dedup_dropped:"mistake",approve:"usage",enhance:"directed-edit",add:"directed-edit",default_accepted:"usage",default_overridden:"edit",gap_resolution:"usage",dedup_kept:"usage"};function ve(t){let{contextDir:e,graph:n,watermark:s,by:r}=t,{signals:a}=D(e,s),o=a.filter(u=>u.event_id===void 0||n.appliedEvents.has(u.event_id)),m=new Map;for(let u of o){let b=u.event_id??`${u.ts}|${u.id}|${u.verdict}|${u.polarity}`;m.has(`${b}|${u.polarity}|${u.verdict}`)||m.set(`${b}|${u.polarity}|${u.verdict}`,u)}let d=[...m.values()].sort((u,b)=>(u.event_id??u.ts)<(b.event_id??b.ts)?-1:1),f=new Map;for(let u of d){let b=`${u.verdict}|${u.tag??""}`,v=f.get(b)??{verdict:u.verdict,tag:u.tag,events:new Set};v.events.add(u.event_id??u.ts),f.set(b,v)}let c=[],p=0;for(let[,u]of[...f.entries()].sort(([b],[v])=>b<v?-1:1)){if(u.events.size<it)continue;let v={derived:!0,statement:`${u.verdict}${u.tag?`/${u.tag}`:""} recurs (${u.events.size} distinct events) \u2014 bias future proposals ${u.verdict==="approve"?"toward":"away from"} this pattern`,learned_from_kind:ot[u.verdict]??"usage",learned_from:[...u.events].sort()},A=j("stylenote",v);if(A.length>0)return{record:null,errors:A.map(k=>({code:k.code,detail:k.detail})),minted:0};let h=H("stylenote",v);n.hasNode(h)||(c.push({cid:h,label:U.STYLENOTE,content:v}),p+=1)}return c.length===0?{record:null,errors:null,minted:0}:{record:z(e,{ts:new Date().toISOString(),proposal_id:null,nodes:c,edges:[],review:[],supersessions:[],source_head_moves:{}},{expectPrev:n.latestHash}).record,errors:null,minted:p}}var at={kind:"system",id:"distiller"};function Pt(t,e=n=>process.stderr.write(n+`
|
|
9
|
+
`)){try{let n=Q(t),{watermark:s}=D(t),r=ve({contextDir:t,graph:n,watermark:s,by:at});if(r.errors){let a=r.errors.map(o=>`${o.code}: ${o.detail}`).join("; ");return e(`warning: style-note distill skipped \u2014 ${a}`),{minted:0,error:a}}return{minted:r.minted,error:null}}catch(n){let s=n instanceof Error?n.message:String(n);return e(`warning: style-note distill skipped \u2014 ${s}`),{minted:0,error:s}}}export{lt as a,ye as b,te as c,ne as d,rt as e,be as f,Tt as g,Pt as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{existsSync as l}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(l(e))return{cmd:e,args:[]}}let a=i(r,"../assurance-agent/dist",n);if(l(a))return{cmd:a,args:[]};let t=i(r,"../assurance-agent/main.py");if(l(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:l(s)?s:"python3",args:[t]}}}return null}function w(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function x(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-
|
|
2
|
+
import{existsSync as l}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(l(e))return{cmd:e,args:[]}}let a=i(r,"../assurance-agent/dist",n);if(l(a))return{cmd:a,args:[]};let t=i(r,"../assurance-agent/main.py");if(l(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:l(s)?s:"python3",args:[t]}}}return null}function w(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function x(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-BJCIWQWA.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",r=new o,a=r.getActiveProfile()??"default",t={TESTMUAI_ENV:n},s=r.loadBasicAuth(a,n);if(s)return t.TESTMUAI_BASIC_AUTH=Buffer.from(`${s.username}:${s.access_key}`,"utf8").toString("base64"),t;let e=r.loadCredentials(a,n);if(e){try{let{refreshOAuthToken:u}=await import("./token-refresh-CFVOA62N.js");await u({creds:r,profile:a,env:n,credentials:e})}catch{}let c=r.loadCredentials(a,n)??e;if(typeof c.access_token=="string"){let u=await E(n,c.access_token);return u?(t.TESTMUAI_BASIC_AUTH=u,t):(t.TESTMUAI_API_KEY=c.access_token,t)}}return{}}catch{return{}}}var _=8e3;function m(){return process.stderr.write("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry\n"),null}async function E(o,n){if(process.env.TESTMUAI_BASE_URL)return null;try{let[{getEnvironment:r},{ControllerClient:a}]=await Promise.all([import("./config-6PAZZ7CR.js"),import("./controller-client-RD2YEMAH.js")]),t=new a(r(o).controllerBaseUrl,n),s;try{let e=await Promise.race([t.getTmsCredentials().catch(()=>null),new Promise(c=>{s=setTimeout(()=>c(null),_)})]);return typeof e?.username!="string"||!e.username||typeof e.access_key!="string"||!e.access_key?m():Buffer.from(`${e.username}:${e.access_key}`,"utf8").toString("base64")}finally{clearTimeout(s)}}catch{return m()}}export{A as a,h as b,w as c,x as d};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-
|
|
2
|
+
import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-AKHUNBQS.js";import{a as h}from"./chunk-P4HW2NTZ.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
|
|
3
3
|
`)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
|
|
4
|
-
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-
|
|
4
|
+
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-CFVOA62N.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
|
|
5
5
|
`,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
|
|
6
6
|
`,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
|
|
7
7
|
`,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
|
|
@@ -1,2 +1,2 @@
|
|
|
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-4SXD6XWV.js";import{n as d,y as o}from"./chunk-6SGPN76K.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as h}from"./chunk-
|
|
2
|
+
import{a as h}from"./chunk-4SXD6XWV.js";import{y as l}from"./chunk-6SGPN76K.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-
|
|
2
|
+
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-6NIV7AVZ.js";import{y as s}from"./chunk-6SGPN76K.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as c,c as p}from"./chunk-
|
|
2
|
+
import{b as c,c as p}from"./chunk-KYHXDJN4.js";import{spawn as m}from"child_process";var y=new Set(["progress","ask_user","graph_query","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete"]);function S(d,s={}){let a=s.spawnCmd!==void 0?s.spawnCmd:c();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let n=m(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(d.session_id,s.auth)});if(n.stdin.write(JSON.stringify(d)+`
|
|
3
3
|
`),s.onStderr){let e="";n.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
|
|
4
4
|
`))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&s.onStderr(o)}})}let g=new Promise(e=>{n.on("exit",(r,i)=>e({code:r,signal:i}))});async function*f(){let e="",r=!1;for await(let i of n.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
|
|
5
5
|
`))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let u;try{u=JSON.parse(l)}catch{s.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let t=u;if(!t||typeof t!="object"||!y.has(t.type)){s.onWarn?.(`agent: skipping unknown event type "${t&&typeof t=="object"?String(t.type??"?"):"?"}"`);continue}if(yield t,t.type==="done"){r=!0;break}}if(r)break}await g.catch(()=>{})}return{events:f(),send:e=>{n.stdin&&!n.stdin.destroyed&&n.stdin.write(JSON.stringify(e)+`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as L,b as N}from"./chunk-
|
|
2
|
+
import{a as L,b as N}from"./chunk-74RUSHIB.js";import{c as G}from"./chunk-ZG2V2ODK.js";import{e as _,g as v}from"./chunk-5YPBPZUR.js";import{existsSync as k,readFileSync as q}from"fs";function J(a){let s=N(a),u=new Map(Object.entries(s.heads)),d=new Map(Object.entries(s.trust)),r=new Map(Object.entries(s.nodeLabel)),i=new Map(Object.entries(s.superseded)),g=new Map(Object.entries(s.names)),R=new Map(Object.entries(s.archivedReason)),I=new Set(s.appliedEvents),S=new Map(Object.entries(s.conv)),T=e=>s.media[e]??{format:"text",media_type:"text/plain",anchors_supported:["L-L"]},M=new Map;for(let[e,t]of g)M.set(t,e);let h=new Map,E=e=>{if(h.has(e))return h.get(e);if(!r.has(e))return h.set(e,null),null;let t=L(a,e);if(!k(t))throw new G(`derived node file missing for ${e} \u2014 run kane-cli context rebuild`);let n=JSON.parse(q(t,"utf8"));return h.set(e,n),n},m=e=>{let t=e,n=new Set;for(;i.has(t)&&!n.has(t);){n.add(t);let o=i.get(t);if(typeof o!="string")break;t=o}return t},x=e=>{let t=u.get(e),n=r.has(e)?e:g.get(e)??(typeof t=="string"?t:void 0);if(n===void 0||!r.has(n))return null;let o=m(n);return{cid:n,tip:o,superseded:i.has(n)||i.has(o)}},b=new Map;for(let e of Object.values(s.forward))for(let t of e){let n=b.get(t.dst);n?n.push(t):b.set(t.dst,[t])}let w=e=>(e??[]).filter(t=>!i.has(t.ecid)),C=e=>w(b.get(e)),O=e=>C(e).filter(t=>t.type===_.DERIVES),y=e=>w(s.forward[e]).some(t=>v(t.type)?.pin?.comparesTo==="dst_tip"&&i.has(t.dst)),F=e=>{if(i.has(e))return"superseded";let t=O(e);if(t.length===0)return y(e)?"stale":"fresh";let n=new Map;for(let p of t)n.set(p.props.source_id,p);let o=!1,f=!1;for(let[p,c]of n){let l=u.get(p);if(l!=null&&(o=!0,l!==c.props.source_cid)){let j=S.get(p)?.chain;(!j||!j.includes(c.props.source_cid))&&(f=!0)}}return o?f||y(e)?"stale":"fresh":"orphaned"};return{heads:u,trust:d,nodeLabel:r,superseded:i,names:g,nameOf:M,archivedReason:R,appliedEvents:I,convChains:S,mediaOf:T,extractedSourceCids:new Set(s.extracted),designOf:new Map(Object.entries(s.design_of??{})),latestHash:s.applied.hash,lastSeq:s.applied.seq,hasNode:e=>r.has(e),getNode:E,byLabel:e=>[...r.entries()].filter(([,t])=>t===e).map(([t])=>({cid:t,content:E(t)?.content??{}})),edgesFrom:e=>w(s.forward[e]),edgesInto:C,derivesInto:O,resolve:x,tipOf:m,stale:F,staleList:()=>[...r.keys()].map(e=>({cid:e,state:F(e)})).filter(e=>e.state!=="fresh"),execHistory:e=>{let t=x(e);if(!t)return[];let n=m(t.cid),o=new Set([n]),f=!0;for(;f;){f=!1;for(let[c,l]of i)l!==null&&o.has(l)&&!o.has(c)&&(o.add(c),f=!0)}let p=[];for(let c of Object.entries(s.exec??{}))o.has(c[0])&&p.push(...c[1]);return p.sort((c,l)=>c.started_at<l.started_at?-1:1)}}}function V(a,s){if(a.stale(s)!=="stale")return!1;let u=new Map;for(let d of a.derivesInto(s))u.set(d.props.source_id,d);for(let[d,r]of u){let i=a.heads.get(d);if(i==null||i===r.props.source_cid)continue;let g=a.convChains.get(d)?.chain;if(!g||!g.includes(r.props.source_cid))return!0}for(let d of a.edgesFrom(s)){if(v(d.type)?.pin?.comparesTo!=="dst_tip"||!a.superseded.has(d.dst))continue;let r=a.tipOf(d.dst);if(a.superseded.has(r)||a.nodeLabel.get(r)==="usecase")return!0}return!1}export{J as a,V as b};
|
|
@@ -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-C42WWO7Y.js";import{c as k}from"./chunk-RFHMDQXZ.js";import{a as C}from"./chunk-P4HW2NTZ.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-6SGPN76K.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
|
|
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{a as R}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-4SXD6XWV.js";import{y as r}from"./chunk-6SGPN76K.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-
|
|
2
|
+
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-MY32TBBR.js";import{a as k}from"./chunk-2WVKOZ6W.js";import{a as B}from"./chunk-AKHUNBQS.js";import{a as R}from"./chunk-4SXD6XWV.js";import{y as c}from"./chunk-6SGPN76K.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=B(m),T=new k(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=B(m),s=await new k(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
|
|
@@ -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-3Z3UIW5H.js";import{y as l}from"./chunk-6SGPN76K.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,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as g}from"./chunk-
|
|
2
|
+
import{c as g}from"./chunk-6SGPN76K.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
|
|
3
3
|
`),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
|
|
4
4
|
`),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
|
|
5
5
|
`)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as G,c as P,e as J,h as q,i as z,j as Q,m as V,n as X,o as T}from"./chunk-RKWJG3WW.js";import{e as U}from"./chunk-
|
|
2
|
+
import{b as G,c as P,e as J,h as q,i as z,j as Q,m as V,n as X,o as T}from"./chunk-RKWJG3WW.js";import{e as U}from"./chunk-EHN5HTUD.js";import{copyFileSync as ae,cpSync as le,existsSync as w,mkdirSync as ue,readFileSync as je,readdirSync as pe,rmSync as Fe,writeFileSync as Oe}from"fs";import{dirname as Te,isAbsolute as _e,join as R,relative as Le,resolve as Ae}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as Re}from"fs";import{dirname as Ie,basename as Y}from"path";function ee(e){let t=e.outPath??P(e.sourcePath);Se(Ie(t),{recursive:!0});let r=[];r.push("---"),r.push(`test: ../${Y(e.sourcePath)}`),r.push(`status: ${e.overallStatus}`),r.push(`started: ${e.startedISO}`),r.push(`duration_s: ${e.durationS}`),r.push(`session_id: ${e.sessionId}`),r.push("---",""),r.push(`# ${e.title??Y(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let a=e.rootSteps[l],i=e.outcomes.find(p=>p.rootStepIndex===l+1);if(r.push(xe(a,i)),i?.stepMd5&&r.push(`md5: ${i.stepMd5}`),i?.status==="failed"&&i.reason&&r.push(`Reason: ${i.reason}`),i?.softFailures?.length)for(let p of i.softFailures){let o=p.reason?`: ${p.reason}`:"";r.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}a.body.kind==="objective"&&i?.status!=="skipped"&&r.push(a.body.text),r.push("")}return ge(t,r.join(`
|
|
3
3
|
`),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let r=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let a=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${r}${a})`}if(t.refKind&&t.status==="failed"){let a=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",i=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${a}, ${r}${i})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${r})`:`## ${e.heading} \u2717 failed${l} (${r})`}var ye=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,be=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,ke=/^md5:\s+([a-f0-9]{32})\s*$/;function Z(e,t){for(let r=t;r<e.length&&!/^##\s/.test(e[r]);r++){if(e[r].trim()==="")continue;let l=ke.exec(e[r]);return l?l[1]:null}return null}function $(e){let r=Re(e,"utf8").split(`
|
|
4
4
|
`),l="passed";if(r[0]?.trim()==="---")for(let i=1;i<r.length&&r[i].trim()!=="---";i++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(r[i]);p&&(l=p[1])}let a=[];for(let i=0;i<r.length;i++){let p=ye.exec(r[i]);if(!p)continue;let o=p[1],s=p[2],c=p[3]??"",m=s.startsWith("\u2713")?"passed":s.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=be.exec(c),b=f?.[1]??"",g=f?.[2]??null;a.push({kind:"import",heading:o,status:m,md5:Z(r,i+1),importPath:b,helperResultRelPath:g})}else a.push({kind:"objective",heading:o,status:m,md5:Z(r,i+1)})}return{overallStatus:l,steps:a}}import{copyFileSync as te,existsSync as N,mkdirSync as ve,writeFileSync as se,promises as Be}from"fs";import{join as D,dirname as re,basename as Pe}from"path";async function ne(e){for(let t=0;t<e.totalRunDirs;t++){let r=e.runIndex+t,l=D(e.sessionDir,"runs",String(r)),a=D(e.stagingStepDir,"flows",String(t));ve(a,{recursive:!0});let i=D(a,"actions.ndjson");if(e.packTestDir){let s=D(e.packTestDir,"logs",`${r}-actions.ndjson`);if(N(s)){te(s,i);continue}let c=re(re(e.packTestDir)),m=Pe(e.packTestDir),I=N(c)?await U(c,`tests/${m}/logs/${r}-actions.ndjson`).catch(()=>null):null;se(i,I??"");continue}let p=[D(l,"run-test","actions.ndjson"),D(l,"actions.ndjson")],o=!1;for(let s of p)if(N(s)){te(s,i),o=!0;break}o||se(i,"")}}import{existsSync as K}from"fs";import{dirname as we,join as j,basename as H}from"path";function Ye(e){let t=[],r=new Set,l=new Map;function a(s){if(l.has(s))return l.get(s);let c=P(s),m=K(c)?$(c):null;return l.set(s,m),m}let i=new Map;function p(s){if(i.has(s))return i.get(s);let c=j(s,"Result.md"),m=K(c)?$(c):null;return i.set(s,m),m}function o(s){for(let c=1;c<s.trace.length;c++){let m=s.trace[c-1],I=a(m.file);if(!I)continue;let f=I.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(H(f.importPath)!==H(s.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let s of e.steps){let c=s.trace[s.trace.length-1].stepIndex,m=r.has(s.owningFile);for(let g=0;g<s.trace.length-1&&!m;g++)r.has(s.trace[g].file)&&(m=!0);if(m){t.push({kind:"author",reason:a(s.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let I=o(s);if(I){t.push(I);for(let g=0;g<s.trace.length;g++)r.add(s.trace[g].file);continue}let f=a(s.owningFile),b;if(f===null&&s.trace.length>1){let g=W(s.trace);b=ie(s,p(g),c,g)}else b=ie(s,f,c);if(t.push(b),b.kind==="author"){r.add(s.owningFile);for(let g=0;g<s.trace.length-1;g++)r.add(s.trace[g].file)}}return t}function ie(e,t,r,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let a=t.steps[r-1];if(!a)return{kind:"author",reason:"no-result-md"};if(a.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(a.status!=="passed")return{kind:"author",reason:"recorded-failed"};let i=T(e);if(i!==a.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?Q(e.owningFile,r,i.slice(0,8)):j(l,".internal","steps",`${r}-${i.slice(0,8)}`),o=j(p,"flows","0","actions.ndjson");return K(o)?{kind:"replay",recordingDir:p}:{kind:"author",reason:"missing-recording"}}function Ze(e){return e.some(t=>t.kind==="author")}function et(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function W(e){let t=i=>{let p=H(i);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},r=t(e[0].file),l=t(e[e.length-1].file),a=e.slice(0,-1).map(i=>String(i.stepIndex));return j(we(e[e.length-1].file),`helper-output-${l}-${r}-${a.join("-")}`)}function tt(e){return j(e.recordingDir,"flows","0","actions.ndjson")}import{existsSync as oe,mkdirSync as $e,rmSync as De,cpSync as Me}from"fs";function de(e,t){oe(e)&&(oe(t)&&De(t,{recursive:!0,force:!0}),$e(t,{recursive:!0}),Me(e,t,{recursive:!0}))}async function mt(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let r=e.authoredFlatIdx??new Set,l=[],a=[],i=new Map,p=o=>{if(i.has(o))return i.get(o);let s=R(o,"Result.md"),c=w(s)?$(s):null;return i.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let s=o.file===e.resolvedTest.rootPath,c=V(o.file,je(o.file,"utf8")),m=P(o.file),I=w(m)?$(m):null,f=[],b=[],g=[],M=[];if(!s)for(let d of e.resolvedTest.steps){if(d.owningFile!==o.file||d.trace.length<2)continue;let n=W(d.trace);M.includes(n)||M.push(n)}let F=d=>{if(I!==null)return null;for(let n of M){let v=p(n)?.steps[d-1];if(v)return{row:v,dir:n}}return null},C=[],_=!1,B=!1,L=!1,A=!1;for(let d of c.steps){let n=d.index,u=I?.steps[n-1];if(d.body.kind==="objective"){let h=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===n&&t.has(S.flatIndex)),x=h.length>0?h[h.length-1]:null;if(x){_=!0,r.has(x.flatIndex)&&(B=!0);let S=T(x),y;s?y=e.outcomes.find(he=>he.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}:y={rootStepIndex:n,status:ce(x,e.outcomes)},y.status==="failed"&&(L=!0),y.stepMd5==null&&(y.stepMd5=S),f.push(y),b.push({stepIndex:n,md5:S,rec:t.get(x.flatIndex)}),(!u||u.kind!=="objective"||u.status!==y.status||y.status==="passed"&&u.md5!==S)&&(A=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:n,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),g.push(n);else if(!s&&F(n)?.row.kind==="objective"){let S=F(n),y=S.row;f.push({rootStepIndex:n,status:y.status,...y.md5?{stepMd5:y.md5}:{}}),C.push({psIdx:n,dir:S.dir})}else s?f.push(e.outcomes.find(S=>S.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}):f.push({rootStepIndex:n,status:"skipped"});continue}let v=_e(d.body.path)?d.body.path:Ae(Te(o.file),d.body.path),O=X({path:d.body.path,bindings:d.body.bindings,optional:d.optional??!1}),me=Le(G(o.file),P(v)),E=e.resolvedTest.steps.filter(h=>h.trace.some((x,S)=>S<h.trace.length-1&&x.file===o.file&&x.stepIndex===n)&&t.has(h.flatIndex));if(E.length>0){_=!0;let h;if(s)h=e.outcomes.find(x=>x.rootStepIndex===n)??{rootStepIndex:n,status:"passed",refKind:"import",refLabel:d.body.path};else{let x=E.some(S=>ce(S,e.outcomes)==="failed");h={rootStepIndex:n,status:x?"failed":"passed",refKind:"import",refLabel:d.body.path,inlinedCount:E.length}}h.status==="failed"&&(L=!0),h.stepMd5==null&&(h.stepMd5=O),h.helperResultRelPath==null&&(h.helperResultRelPath=me),f.push(h),(!u||u.kind!=="import"||u.status!==h.status||u.md5!==O)&&(A=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:n,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!s&&F(n)?.row.kind==="import"){let h=F(n).row;f.push({rootStepIndex:n,status:h.status,refKind:"import",refLabel:d.body.path})}else s?f.push(e.outcomes.find(h=>h.rootStepIndex===n)??{rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path}):f.push({rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path})}if(!(s||_&&(B||L||I===null||A)))continue;l.push(o.file);let k=q(o.file);ue(R(k,".internal"),{recursive:!0});for(let d of b){let n=R(k,".internal","steps",`${d.stepIndex}-${d.md5.slice(0,8)}`);ue(n,{recursive:!0}),await ne({sessionDir:e.sessionDir,runIndex:d.rec.runIndex,totalRunDirs:d.rec.totalRunDirs,stagingStepDir:n,packTestDir:e.packTestDir})}if(g.length>0){let d=z(o.file);if(w(d))for(let n of pe(d)){let u=parseInt(n.split("-")[0]??"",10);!Number.isNaN(u)&&g.includes(u)&&le(R(d,n),R(k,".internal","steps",n),{recursive:!0})}}for(let d of C){let n=R(d.dir,".internal","steps");if(w(n))for(let u of pe(n))parseInt(u.split("-")[0]??"",10)===d.psIdx&&le(R(n,u),R(k,".internal","steps",u),{recursive:!0})}let fe=f.some(d=>d.status==="failed");if(ee({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:s?e.overallStatus:fe?"failed":"passed",startedISO:e.startedISO,durationS:s?e.durationS:0,sessionId:e.sessionId,outPath:R(k,"Result.md")}),s){let d={};e.commitId&&(d.commit_id=e.commitId),e.tmsIds.testId&&(d.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(d.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(d.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(d.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(d.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(d.session_name=e.tmsIds.sessionName),Oe(R(k,".internal","meta.json"),JSON.stringify(d,null,2)+`
|
|
5
5
|
`,"utf8");let n=R(e.sessionDir,"execution.json");if(w(n))try{ae(n,R(k,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",v=R(k,`playwright-${u}-code`);try{de(e.codeExportDir,v)}catch(O){process.stderr.write(`warn: codegen copy failed: ${O.message}
|