sootsim 0.1.40 → 0.1.41
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/README.md +15 -15
- package/dist-cli/bin.js +3 -3
- package/dist-cli/chunks/{agent-3F5PO4NL.js → agent-7BJ2ZP22.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-LVUUZRWL.js → agent-wrapper-OXBYRJVT.js} +2 -2
- package/dist-cli/chunks/{assert-4WMVS3WU.js → assert-NZTYFTTT.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-4KQT4TCR.js +2 -0
- package/dist-cli/chunks/beta-3S56PNSS.js +2 -0
- package/dist-cli/chunks/{chunk-DSTHAISO.js → chunk-2T6UOHPO.js} +1 -1
- package/dist-cli/chunks/chunk-334L67M2.js +2 -0
- package/dist-cli/chunks/{chunk-Y5CFIRLN.js → chunk-33R6QMNO.js} +1 -1
- package/dist-cli/chunks/{chunk-WPS3TIOB.js → chunk-4UA6P3T2.js} +1 -1
- package/dist-cli/chunks/{chunk-WQXG4I5N.js → chunk-5JOYGXCS.js} +2 -2
- package/dist-cli/chunks/{chunk-PNGBWMQH.js → chunk-6PLNIOJP.js} +2 -2
- package/dist-cli/chunks/{chunk-WZE6T3GT.js → chunk-7YZJHZ7X.js} +1 -1
- package/dist-cli/chunks/{chunk-QUULF2II.js → chunk-ANDSHXLU.js} +2 -2
- package/dist-cli/chunks/chunk-AOYBIMKL.js +4 -0
- package/dist-cli/chunks/chunk-ASSV2FFC.js +1 -0
- package/dist-cli/chunks/chunk-BR6QRN7U.js +11 -0
- package/dist-cli/chunks/{chunk-EOWN4ZFJ.js → chunk-C4AMFYK3.js} +2 -2
- package/dist-cli/chunks/{chunk-BZED27B2.js → chunk-ECIRRKKE.js} +2 -2
- package/dist-cli/chunks/{chunk-LCES5ZJI.js → chunk-FZB4W23Y.js} +2 -2
- package/dist-cli/chunks/{chunk-PKB6IEGM.js → chunk-G2QUPNHI.js} +2 -2
- package/dist-cli/chunks/{chunk-FNIL6BYS.js → chunk-GB3G5LVB.js} +1 -1
- package/dist-cli/chunks/{chunk-KGVH3YAG.js → chunk-GI7FXE7J.js} +2 -2
- package/dist-cli/chunks/{chunk-6XI4VHIL.js → chunk-GOFKXREQ.js} +2 -2
- package/dist-cli/chunks/{chunk-YJMXGTP4.js → chunk-HAVQS3PI.js} +1 -1
- package/dist-cli/chunks/{chunk-6X5NQJT7.js → chunk-HZVPHAJX.js} +20 -20
- package/dist-cli/chunks/{chunk-5IAIIX7B.js → chunk-I5Y4IECP.js} +3 -3
- package/dist-cli/chunks/{chunk-MLCBIX7O.js → chunk-IF33CQL4.js} +2 -2
- package/dist-cli/chunks/chunk-IP2MARRU.js +27 -0
- package/dist-cli/chunks/{chunk-YKEBL6GE.js → chunk-J3JJRXIP.js} +1 -1
- package/dist-cli/chunks/{chunk-OV5TY7M3.js → chunk-LMNB7NYI.js} +2 -2
- package/dist-cli/chunks/{chunk-CCZHRBXJ.js → chunk-LX6KS6TL.js} +1 -1
- package/dist-cli/chunks/{chunk-KVOMVYG6.js → chunk-MBGNDWGV.js} +2 -2
- package/dist-cli/chunks/{chunk-DEBXVPIE.js → chunk-N7DDNZTO.js} +1 -1
- package/dist-cli/chunks/chunk-NZ5O2OEL.js +56 -0
- package/dist-cli/chunks/{chunk-4L45Q3YX.js → chunk-OJFHAMXD.js} +2 -2
- package/dist-cli/chunks/{chunk-W2XRHDQQ.js → chunk-OPDPXAYA.js} +2 -2
- package/dist-cli/chunks/{chunk-U3JD6X75.js → chunk-OXTFYLZJ.js} +2 -2
- package/dist-cli/chunks/{chunk-TK2IPNHL.js → chunk-Q6DGMQ2V.js} +2 -2
- package/dist-cli/chunks/{chunk-553OZX4H.js → chunk-S3SQITOO.js} +2 -2
- package/dist-cli/chunks/{chunk-QMBYRPRK.js → chunk-SHHUVGL2.js} +1 -1
- package/dist-cli/chunks/{chunk-Y66CDFAT.js → chunk-SWHWVYZS.js} +1 -1
- package/dist-cli/chunks/{chunk-5GK4YX7O.js → chunk-TBIGAH3T.js} +1 -1
- package/dist-cli/chunks/chunk-UNJTJDZZ.js +62 -0
- package/dist-cli/chunks/chunk-WN6YFWS5.js +117 -0
- package/dist-cli/chunks/{chunk-Z3I2I4IO.js → chunk-WZDE344I.js} +3 -3
- package/dist-cli/chunks/{chunk-LXR5EI74.js → chunk-Y2YNXUBT.js} +2 -2
- package/dist-cli/chunks/chunk-YFX2XIR4.js +1 -0
- package/dist-cli/chunks/chunk-YKFRPIVC.js +1 -0
- package/dist-cli/chunks/chunk-ZPURE62G.js +1 -0
- package/dist-cli/chunks/{compat-NBFWHK5S.js → compat-BA6HDW3Q.js} +5 -5
- package/dist-cli/chunks/{config-JEDQ3NHA.js → config-QQ63IS5P.js} +2 -2
- package/dist-cli/chunks/control-GNJNC524.js +2 -0
- package/dist-cli/chunks/cpu-profile-3DDV2SYN.js +2 -0
- package/dist-cli/chunks/{daemon-HOL7J3BI.js → daemon-RYSVONEV.js} +2 -2
- package/dist-cli/chunks/{debug-LNVMIWD6.js → debug-YXE4XZLP.js} +3 -3
- package/dist-cli/chunks/demo-app-registry-3VFEW4NV.js +2 -0
- package/dist-cli/chunks/{detox-EEZPH3DZ.js → detox-2UI3EAXA.js} +2 -2
- package/dist-cli/chunks/{device-GVLYQI7X.js → device-UGDJBZKD.js} +2 -2
- package/dist-cli/chunks/diagnose-IRDRYKYZ.js +41 -0
- package/dist-cli/chunks/drivers-EAONIWG3.js +2 -0
- package/dist-cli/chunks/{electron-UDV6K3IH.js → electron-ZCYWIZAE.js} +3 -3
- package/dist-cli/chunks/flow-ECSMFTKS.js +2 -0
- package/dist-cli/chunks/{hints-46PJLATZ.js → hints-OWOBCWJH.js} +2 -2
- package/dist-cli/chunks/{home-paths-XD7AOYU7.js → home-paths-5QMCFTBP.js} +2 -2
- package/dist-cli/chunks/{inspect-EDIKZ6O2.js → inspect-K4VXPM5J.js} +94 -92
- package/dist-cli/chunks/install-YFE7C2NU.js +2 -0
- package/dist-cli/chunks/{install-desktop-CX6ATQTR.js → install-desktop-U3723T63.js} +3 -3
- package/dist-cli/chunks/{keys-CXQIYEVW.js → keys-IFVXJ7C2.js} +2 -2
- package/dist-cli/chunks/{launch-DCFRKVD3.js → launch-NDGFTRZ5.js} +3 -3
- package/dist-cli/chunks/{login-HCIZL5GT.js → login-KEU6RAV3.js} +4 -4
- package/dist-cli/chunks/{logout-7X2YHJY3.js → logout-KNFLP5OQ.js} +2 -2
- package/dist-cli/chunks/{maestro-TY622MIW.js → maestro-GBUBLS6L.js} +2 -2
- package/dist-cli/chunks/{preview-DYI6ESOK.js → preview-7OKMPPMN.js} +2 -2
- package/dist-cli/chunks/{profile-7SXJEJTG.js → profile-CHKDPGJF.js} +2 -2
- package/dist-cli/chunks/{react-VGSDY766.js → react-GYI5VITJ.js} +2 -2
- package/dist-cli/chunks/record-DQR2TEIF.js +45 -0
- package/dist-cli/chunks/runtime-XXNKSGFE.js +2 -0
- package/dist-cli/chunks/{runtime-delivery-PWLODFCY.js → runtime-delivery-JCAY2QVQ.js} +2 -2
- package/dist-cli/chunks/{screenshot-PTKY4UU4.js → screenshot-3T6MNPH7.js} +2 -2
- package/dist-cli/chunks/{screenshot-mode-HSV7VY4G.js → screenshot-mode-BUGXY7SQ.js} +2 -2
- package/dist-cli/chunks/{screenshots-VY7VAGSV.js → screenshots-EMTXGI2Q.js} +2 -2
- package/dist-cli/chunks/server-46H2M4TF.js +35 -0
- package/dist-cli/chunks/setup-repo-P4LCPAF6.js +2 -0
- package/dist-cli/chunks/{skills-KEPQLCMR.js → skills-2RP2CFPD.js} +2 -2
- package/dist-cli/chunks/{start-5CJTBNRM.js → start-QFREXALP.js} +4 -4
- package/dist-cli/chunks/store-GH77HGEB.js +2 -0
- package/dist-cli/chunks/telemetry-WC5J4TE5.js +2 -0
- package/dist-cli/chunks/{test-REKHGKFE.js → test-LI4PGGTE.js} +3 -3
- package/dist-cli/chunks/{three-mode-FZYHB4ZQ.js → three-mode-PKINB46T.js} +2 -2
- package/dist-cli/chunks/{timeline-CWZAY52K.js → timeline-5AREJDL5.js} +2 -2
- package/dist-cli/chunks/{upgrade-AIUJEF5F.js → upgrade-W2AGIOSC.js} +2 -2
- package/dist-cli/chunks/upload-RLS6KTG6.js +2 -0
- package/dist-cli/chunks/web-JM6WDSZQ.js +2 -0
- package/dist-cli/chunks/{what-happened-JSQQVQGE.js → what-happened-SVCASJKT.js} +2 -2
- package/dist-cli/chunks/whoami-5NJ6IPLT.js +2 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +14 -8
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/vite-base.cjs +14 -8
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/auto-bootstrap-Q4A3PTF5.js +0 -2
- package/dist-cli/chunks/beta-CLLKUB5X.js +0 -2
- package/dist-cli/chunks/chunk-4IAKB3C4.js +0 -117
- package/dist-cli/chunks/chunk-CAJ247SC.js +0 -2
- package/dist-cli/chunks/chunk-D2ZMP7G4.js +0 -61
- package/dist-cli/chunks/chunk-D4Z7MWQY.js +0 -11
- package/dist-cli/chunks/chunk-DHJIXXWG.js +0 -27
- package/dist-cli/chunks/chunk-DPZDTJVQ.js +0 -1
- package/dist-cli/chunks/chunk-FFR7EA4U.js +0 -1
- package/dist-cli/chunks/chunk-I7KXFJDK.js +0 -1
- package/dist-cli/chunks/chunk-J6BPROH4.js +0 -4
- package/dist-cli/chunks/chunk-S4PJMUC7.js +0 -2
- package/dist-cli/chunks/chunk-XWXFUFB2.js +0 -1
- package/dist-cli/chunks/control-IMWZVYC3.js +0 -2
- package/dist-cli/chunks/cpu-profile-MQPUSRHG.js +0 -22
- package/dist-cli/chunks/demo-app-registry-4RFMJ4FM.js +0 -2
- package/dist-cli/chunks/diagnose-JQ7DPTSL.js +0 -41
- package/dist-cli/chunks/drivers-JUW6JBWH.js +0 -2
- package/dist-cli/chunks/flow-JOW23WNH.js +0 -2
- package/dist-cli/chunks/install-CCC3IF5S.js +0 -2
- package/dist-cli/chunks/record-7JX2SMVP.js +0 -37
- package/dist-cli/chunks/runtime-FTOQD7QK.js +0 -2
- package/dist-cli/chunks/server-EDB3EK4K.js +0 -35
- package/dist-cli/chunks/setup-repo-S2GFZR7F.js +0 -2
- package/dist-cli/chunks/store-SCRULNVS.js +0 -2
- package/dist-cli/chunks/telemetry-RC3OT67I.js +0 -2
- package/dist-cli/chunks/upload-UDA5ITTE.js +0 -2
- package/dist-cli/chunks/whoami-5WUUPIRN.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as ye}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as ye}from"./chunk-OJFHAMXD.js";import{a as be}from"./chunk-GOFKXREQ.js";import{a as Se}from"./chunk-IP2MARRU.js";import{a as V,b as M,c as me,d as Y,f as pe,g as fe}from"./chunk-GI7FXE7J.js";import{f as he,l as ge}from"./chunk-BR6QRN7U.js";import{b as ue}from"./chunk-SHHUVGL2.js";import{a as we}from"./chunk-7YZJHZ7X.js";import{a as ve}from"./chunk-Y2YNXUBT.js";import{f as ne}from"./chunk-33R6QMNO.js";import{c as q,d as ce,e as de}from"./chunk-6PLNIOJP.js";import{c as le}from"./chunk-SWHWVYZS.js";import{a as ae,b as z}from"./chunk-OPDPXAYA.js";import*as $ from"fs";import{tmpdir as $e}from"os";import*as g from"path";import*as w from"fs";import*as f from"path";var U=1e4,B=393,C=852,xe="__sootsimCliPerf",Ne="maestroCopiedText",X=new Map;function m(o){return new Promise(e=>setTimeout(e,o))}function De(o){return o?f.basename(o)===".maestro"?f.dirname(o):o:process.cwd()}function Re(o,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(f.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let i=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():De(t.flowDir);return f.resolve(i,r)}return f.join(o,r)}function Ve(o){if(typeof o=="string")return{path:o,withFrame:!1};let e=o.path?.trim()||o.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:o.withFrame===!0}}function G(o){let[e,t]=o.split(",").map(i=>i.trim()),r=(i,n)=>i.endsWith("%")?Number.parseFloat(i)/100*n:Number.parseFloat(i);return{x:r(e,B),y:r(t,C)}}function Z(o){return typeof o=="string"?o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>{if(X.has(t))return X.get(t);let r=process.env[t];if(r===void 0)throw new Error(`missing environment variable for flow placeholder: ${t}`);return r}):Array.isArray(o)?o.map(e=>Z(e)):o&&typeof o=="object"?Object.fromEntries(Object.entries(o).map(([e,t])=>[e,Z(t)])):o}function Ue(o){let e=o.split(/^---$/m),t=e.length>1?e[e.length-1]:o,r=Z(M.parse(t));return Array.isArray(r)?r:[]}var W=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingDurationMs=null;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let r=t.searchParams.toString();return`${t.origin}${t.pathname}${r?`?${r}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(a=>a.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(a=>a.id===this.opts.simId&&a.readyState==="open")||!this.simRouteHint)return;let i=this.simRouteHint&&e.find(a=>a.readyState==="open"&&this.normalizeSimRoute(a.url||a.origin)===this.simRouteHint);if(!i)return;let n=e.find(a=>a.isPrimary&&a.readyState==="open"),s=e.find(a=>a.readyState==="open"),l=i??n??s;l&&(this.opts.simId=l.id,console.log(` [flow] sim rotated to ${l.id}`))}catch{}}async evaluate(e){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e})}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=U){let t=Date.now()+e,r=null;for(;Date.now()<t;){try{let i=await this.evaluate(`(async () => {
|
|
3
3
|
const test = window.__sootsimTest
|
|
4
4
|
if (!test) return { count: 0, loading: true }
|
|
5
5
|
const count = (await test.getNodeCount?.()) || 0
|
|
@@ -19,7 +19,7 @@ import{a as ye}from"./chunk-4L45Q3YX.js";import{a as be}from"./chunk-6XI4VHIL.js
|
|
|
19
19
|
const openingAppNode = await test.findByText?.('opening app')
|
|
20
20
|
const isLoading = !!loadingNode || !!capturingNode || !!openingAppNode || count < 5
|
|
21
21
|
return { count, loading: isLoading, error: null }
|
|
22
|
-
})()`);if(i?.error)throw new Error(`app failed to load: ${i.error}`);if(i&&i.count>10&&!i.loading)return}catch(i){r=i instanceof Error?i:new Error(String(i)),await this.refreshSimId()}await m(500)}throw r?.message.startsWith("app failed to load:")?r:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(await
|
|
22
|
+
})()`);if(i?.error)throw new Error(`app failed to load: ${i.error}`);if(i&&i.count>10&&!i.loading)return}catch(i){r=i instanceof Error?i:new Error(String(i)),await this.refreshSimId()}await m(500)}throw r?.message.startsWith("app failed to load:")?r:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(await Se("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
|
|
23
23
|
const rec = window.__sootsimRecorder
|
|
24
24
|
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
25
25
|
if (rec.state() === 'recording') return { ok: true, format: 'webm' }
|
|
@@ -88,7 +88,7 @@ import{a as ye}from"./chunk-4L45Q3YX.js";import{a as be}from"./chunk-6XI4VHIL.js
|
|
|
88
88
|
)
|
|
89
89
|
}
|
|
90
90
|
return direct
|
|
91
|
-
})()`)}async tap(e,t){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let a=
|
|
91
|
+
})()`)}async tap(e,t){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let a=G(t.point);(await this.activatePressAt(a.x,a.y))?.ok||await this.tap(a.x,a.y),await m(300);return}let r=5e3,i=150,n=Date.now()+r,s=await this.findElement({text:t.text,id:t.id});for(;!s&&Date.now()<n;)await m(i),s=await this.findElement({text:t.text,id:t.id});if(s&&!s.isTextInput&&(await this.activatePressTarget(t))?.ok){await m(300);return}if(s){let a=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,p=a?.cx??s.absolutePosition.x+s.layout.width/2,h=a?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(p,h))?.hit!==!1){await m(300);return}}if((await this.activatePressTarget(t))?.ok){await m(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async tapAtCoords(e,t){await this.tap(e,t),await m(300)}async doubleTapAtCoords(e,t,r=80){let i=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
|
|
92
92
|
const interact = window.__sootsimInteract
|
|
93
93
|
if (interact?.doubleTap) {
|
|
94
94
|
return !!(await interact.doubleTap(${e}, ${t}, ${i}))
|
|
@@ -109,7 +109,7 @@ import{a as ye}from"./chunk-4L45Q3YX.js";import{a as be}from"./chunk-6XI4VHIL.js
|
|
|
109
109
|
visible: !!keyboard?.isVisible?.(),
|
|
110
110
|
focused: !!test?.isTextInputFocused?.(),
|
|
111
111
|
}
|
|
112
|
-
})()`);if(!t?.visible&&!t?.focused){await m(80);return}await m(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.pressKey("Backspace");await m(100)}async waitFor(e){let t=Date.now()+(e.timeout||U);for(;Date.now()<t;){if(await this.findElement(e))return;await m(200)}throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||U}ms`)}async takeScreenshot(e){await m(250);let t=
|
|
112
|
+
})()`);if(!t?.visible&&!t?.focused){await m(80);return}await m(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.pressKey("Backspace");await m(100)}async waitFor(e){let t=Date.now()+(e.timeout||U);for(;Date.now()<t;){if(await this.findElement(e))return;await m(200)}throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||U}ms`)}async takeScreenshot(e){await m(250);let t=Ve(e),r=Re(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});w.mkdirSync(f.dirname(r),{recursive:!0});let n=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,""),s=Buffer.from(n,"base64");if(t.withFrame){let l=await this.readCurrentDeviceModel();if(!l)throw new Error("could not read current device model for framed screenshot");let a=await be(s,l);w.writeFileSync(r,a),console.log(`[flow] screenshot: ${r} (frame: ${l})`);return}w.writeFileSync(r,s),console.log(`[flow] screenshot: ${r}`)}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",simId:this.opts.simId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in ne)?null:t}async captureFailureScreenshot(e){w.mkdirSync(f.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");w.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){w.mkdirSync(e,{recursive:!0});let r=(p,h)=>{try{w.writeFileSync(f.join(e,p),h)}catch{}},i=async p=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:p})}catch{return null}};r("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString()},null,2));try{let h=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(h,"base64"))}catch{}let n=await i(`(async () => {
|
|
113
113
|
const t = window.__sootsimTest
|
|
114
114
|
const mainShell = window.SootSim?.bridges?.mainShell
|
|
115
115
|
if (!t) return { error: 'no test bridge' }
|
|
@@ -131,7 +131,7 @@ import{a as ye}from"./chunk-4L45Q3YX.js";import{a as be}from"./chunk-6XI4VHIL.js
|
|
|
131
131
|
if (!interact?.drag) return { ok: false }
|
|
132
132
|
const value = await interact.drag(${e}, ${t}, ${r}, ${i}, ${Math.max(1,Math.round(n))}, ${Math.max(0,Math.round(s))})
|
|
133
133
|
return { ok: !!value, value }
|
|
134
|
-
})()`))?.ok)throw new Error("drag failed");await m(300)}async swipeCoords(e,t,r=300){let i=
|
|
134
|
+
})()`))?.ok)throw new Error("drag failed");await m(300)}async swipeCoords(e,t,r=300){let i=G(e),n=G(t),s=Math.max(10,Math.round(r/16));await this.drag(i.x,i.y,n.x,n.y,s,16)}async swipeFrom(e,t="UP",r=300){let i=await this.findElement(e);if(!i)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let n=i.absolutePosition.x+i.layout.width/2,s=i.absolutePosition.y+i.layout.height/2,l=180,a=n,p=s;switch(t.toUpperCase()){case"UP":p-=l;break;case"DOWN":p+=l;break;case"LEFT":a-=l;break;case"RIGHT":a+=l;break}let h=Math.max(10,Math.round(r/16));await this.drag(n,s,a,p,h,16)}async scrollTo(e,t,r){let i=await this.callTest("scrollTo",e,t,r,!1);if(!i?.ok)throw new Error(`scrollTo failed: ${i?.reason||"unknown error"}`);await m(250)}async pinch(e){let t=await this.evaluate(`(async () => {
|
|
135
135
|
const interact = window.__sootsimInteract
|
|
136
136
|
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
137
137
|
const ok = await interact.pinch(
|
|
@@ -251,13 +251,13 @@ import{a as ye}from"./chunk-4L45Q3YX.js";import{a as be}from"./chunk-6XI4VHIL.js
|
|
|
251
251
|
} catch {}
|
|
252
252
|
})()`)}async clearState(){await this.evaluate(`(async () => {
|
|
253
253
|
await (${V})
|
|
254
|
-
})()`)}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let i=r.text??r.testID??"";
|
|
254
|
+
})()`)}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let i=r.text??r.testID??"";X.set(Ne,i),console.log(`[flow] copied text: ${JSON.stringify(i)}`)}async evalScript(e){let r=await this.evaluate(`(async () => {
|
|
255
255
|
try {
|
|
256
256
|
return { ok: true, value: await (async () => { ${e} })() }
|
|
257
257
|
} catch (err) {
|
|
258
258
|
return { ok: false, error: err && err.message ? err.message : String(err) }
|
|
259
259
|
}
|
|
260
|
-
})()`);if(!r.ok)throw new Error(`evalScript failed: ${r.error}`);r.value!==void 0&&console.log("[flow] evalScript ->",r.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await m(300),await this.refreshSimId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([n])=>n!=="when"&&n!=="optional"),i=r?r[1]:void 0;return!!(i&&typeof i=="object"&&"optional"in i&&i.optional)}async runStep(e,t){let r=Object.keys(e).find(i=>i!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${r}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let i=!!(e.extendedWaitUntil||e.waitFor||e.scrollUntilVisible||e.launchApp||e.runFlow),n=1e4,s=this.runStepInner(e);if(i)await s;else{let a=null,p=new Promise((h,y)=>{a=setTimeout(()=>{y(new Error(`step watchdog: ${r} made no progress in ${n}ms \u2014 bridge or bundle probably hung`))},n)});try{await Promise.race([s,p])}finally{a&&clearTimeout(a)}}let l=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!l&&await m(this.stepDelay)}catch(i){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${i.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:r,target:e[r]},i}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo)await this.scrollTo(e.scrollTo.id,e.scrollTo.x,e.scrollTo.y);else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd)await this.waitForAnimationToEnd(typeof e.waitForAnimationToEnd=="number"?e.waitForAnimationToEnd:2e3);else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await m(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat)for(let t=0;t<e.repeat.times;t++)for(let r=0;r<e.repeat.commands.length;r++)await this.runStep(e.repeat.commands[r],r);else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")await this.evalScript(e.evalScript);else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,r=typeof t=="string"?t:t.file,i=typeof t=="string"?void 0:t.when;if(i&&!await this.evaluateWhen(i)){console.log(`[flow] runFlow skipped (when predicate false): ${r}`);return}let n=f.resolve(this.opts.flowDir,r),s=w.readFileSync(n,"utf8"),l=this.opts.flowDir;this.opts.flowDir=f.dirname(n),await this.runFlow(
|
|
260
|
+
})()`);if(!r.ok)throw new Error(`evalScript failed: ${r.error}`);r.value!==void 0&&console.log("[flow] evalScript ->",r.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await m(300),await this.refreshSimId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([n])=>n!=="when"&&n!=="optional"),i=r?r[1]:void 0;return!!(i&&typeof i=="object"&&"optional"in i&&i.optional)}async runStep(e,t){let r=Object.keys(e).find(i=>i!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${r}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let i=!!(e.extendedWaitUntil||e.waitFor||e.scrollUntilVisible||e.launchApp||e.runFlow),n=1e4,s=this.runStepInner(e);if(i)await s;else{let a=null,p=new Promise((h,y)=>{a=setTimeout(()=>{y(new Error(`step watchdog: ${r} made no progress in ${n}ms \u2014 bridge or bundle probably hung`))},n)});try{await Promise.race([s,p])}finally{a&&clearTimeout(a)}}let l=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!l&&await m(this.stepDelay)}catch(i){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${i.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:r,target:e[r]},i}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo)await this.scrollTo(e.scrollTo.id,e.scrollTo.x,e.scrollTo.y);else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd)await this.waitForAnimationToEnd(typeof e.waitForAnimationToEnd=="number"?e.waitForAnimationToEnd:2e3);else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await m(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat)for(let t=0;t<e.repeat.times;t++)for(let r=0;r<e.repeat.commands.length;r++)await this.runStep(e.repeat.commands[r],r);else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")await this.evalScript(e.evalScript);else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,r=typeof t=="string"?t:t.file,i=typeof t=="string"?void 0:t.when;if(i&&!await this.evaluateWhen(i)){console.log(`[flow] runFlow skipped (when predicate false): ${r}`);return}let n=f.resolve(this.opts.flowDir,r),s=w.readFileSync(n,"utf8"),l=this.opts.flowDir;this.opts.flowDir=f.dirname(n),await this.runFlow(Ue(s)),this.opts.flowDir=l}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],r=[],i=[];for(let s of e){let l=Object.keys(s);if(l.length===1&&l[0]==="onFlowStart"&&Array.isArray(s.onFlowStart)){t.push(...s.onFlowStart);continue}if(l.length===1&&l[0]==="onFlowComplete"&&Array.isArray(s.onFlowComplete)){r.push(...s.onFlowComplete);continue}i.push(s)}if(t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let s=0;s<t.length;s++)await this.runStep(t[s],s)}let n=null;try{await this.runFlowBody(i)}catch(s){n=s instanceof Error?s:new Error(String(s))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let s=0;s<r.length;s++)try{await this.runStep(r[s],s)}catch(l){console.warn(`[flow] onFlowComplete step ${s+1} failed: ${l instanceof Error?l.message:l}`)}}if(n)throw n}async runFlowBody(e){for(let t=0;t<e.length;t++){let r=e[t],i=typeof r.wait=="number"?r.wait:0,n=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,s=Math.max(6e4,i+15e3,n+15e3);if(r.runFlow){await this.runStep(r,t);continue}await Promise.race([this.runStep(r,t),new Promise((l,a)=>setTimeout(()=>a(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${s}ms deadline`)),s))])}}};function ke(o){let e={},t=o,r=o.match(/^---\n([\s\S]*?)\n---\n?/);if(r){try{e=M.parse(r[1])??{}}catch(s){console.warn(` warn: could not parse frontmatter: ${s.message}`)}t=o.slice(r[0].length);let n=M.parse(t);return{frontmatter:e,steps:Array.isArray(n)?n:[]}}if(/\n---\s*\n/.test(o))try{let n=M.parseAllDocuments(o);if(n.length>=2){let s=n[0].toJS(),l=n[n.length-1].toJS();return{frontmatter:s&&typeof s=="object"?s:{},steps:Array.isArray(l)?l:[]}}}catch(n){console.warn(` warn: could not parse multi-doc flow: ${n.message}`)}let i=M.parse(t);return{frontmatter:e,steps:Array.isArray(i)?i:[]}}async function Be(){let o=await ye(),e=o.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=o[0];return t?`http://localhost:${t.port}/__soot/`:null}async function Ae(o){(o.length===0||o.includes("--help")||o.includes("-h"))&&(console.log(`
|
|
261
261
|
sootsim flow \u2014 run flows or manage a draft
|
|
262
262
|
|
|
263
263
|
usage:
|
|
@@ -324,25 +324,25 @@ flow extension:
|
|
|
324
324
|
takeScreenshot:
|
|
325
325
|
path: marketing/hero
|
|
326
326
|
withFrame: true
|
|
327
|
-
`),process.exit(0));let e=o[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=d=>o.find((c,v)=>o[v-1]===d),r=o.includes("--profile"),i=o.includes("--new"),n=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||"/tmp/sootsim-flow",l=t("--screenshot-paths")==="flow"?"flow":"dir",a=t("--device")?.trim()||"",p=o.includes("--slow")?+(t("--slow")||"500"):0,h=o.includes("--electron"),y=o.includes("--preview"),j=await
|
|
327
|
+
`),process.exit(0));let e=o[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=d=>o.find((c,v)=>o[v-1]===d),r=o.includes("--profile"),i=o.includes("--new"),n=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||"/tmp/sootsim-flow",l=t("--screenshot-paths")==="flow"?"flow":"dir",a=t("--device")?.trim()||"",p=o.includes("--slow")?+(t("--slow")||"500"):0,h=o.includes("--electron"),y=o.includes("--preview"),j=await ve(t("--preview-origin")),Q=t("--preview-public-origin"),Me=o.includes("--preview-open"),Ee=o.flatMap((d,c)=>o[c-1]==="--replace"?["--replace",d]:[]),x=o.includes("--record")||y,ee=o.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):x?2e3:0,Pe=$.readFileSync(e,"utf8"),{frontmatter:k,steps:E}=ke(Pe);E.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let I=a||k.device||"",O=h||k.electron===!0,L=k.app===void 0||k.app===null?"":typeof k.app=="number"?String(k.app):k.app,te={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver"]},S=q(o,te),Ie=t("--url")||"";O&&!we()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let re=O?"desktop companion":"bridge",_e=L?` | target: ${L}`:"";console.log(`
|
|
328
328
|
sootsim flow \u2014 ${g.basename(e)}
|
|
329
|
-
${E.length} steps | ${
|
|
330
|
-
`),y&&ae({event:"preview_flow_started",properties:{flowName:g.basename(e),stepCount:E.length,mode:
|
|
329
|
+
${E.length} steps | ${re}${_e}${x?" | recording":""}${r?" | profiling":""}${p?` | ${p}ms delay`:""}
|
|
330
|
+
`),y&&ae({event:"preview_flow_started",properties:{flowName:g.basename(e),stepCount:E.length,mode:re,electron:O,record:x,profile:r,previewOrigin:j}});let F=Ie||L||"",K=i||O&&S.simIdSource!=="flag",ie=!1;if(!F&&!K&&S.simIdSource==="none"){let d=de(S);try{let c=await d.listSims(),v=c.find(R=>R.isPrimary&&R.readyState==="open"),D=c.find(R=>R.readyState==="open"),se=v??D;se&&(ie=!0,console.log(` reusing active sim: ${se.id}`))}catch{}finally{d.close()}}if(!F&&!ie&&(K||S.simIdSource==="none")){let d=await Be();d||(console.error(" error: no current sim and no sootsim target found"),await z(),process.exit(1)),F=d}if(F&&I){let d=new URL(await he(F));d.searchParams.set("device",I),F=d.toString()}if(F){let d=[F];d.push(...Ee),K&&d.push("--new"),S.simIdSource==="flag"&&S.simId&&d.push("--sim",S.simId);let c=t("--driver");c&&d.push("--driver",c),o.includes("--headless")&&d.push("--headless"),await ge(d,{port:S.wsPort,timeoutMs:S.commandTimeoutMs})}let P=q(o,te),J=P.simIdSource==="flag"?P.simId:le()||P.simId,Ce=P.simIdSource==="flag"?"flag":J?"saved":"none",T=ce(P.wsPort,{commandTimeoutMs:P.commandTimeoutMs,simId:J,simIdSource:Ce,fallbackOnMissingSimId:!1}),u,oe=async()=>{if(!I)return!1;let d=await T.send({type:"evaluate",simId:u.simId,code:"window.location.href"});if(typeof d=="string"&&d.length>0){let c=new URL(d);c.searchParams.set("device",I),u.setSimRouteHint(c.toString())}return!!await T.send({type:"call",simId:u.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",I]})};u=new W(T,{screenshotDir:s,flowDir:g.dirname(g.resolve(e)),screenshotPathMode:l,simId:J,recordingOutputDir:x?n:void 0,billingOriginOverride:y?j:void 0,allowGitHubRecording:y,onAfterLaunch:async()=>{await oe()&&await u.waitForTree(12e4),y&&await T.send({type:"evaluate",simId:u.simId,code:`(() => {
|
|
331
331
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
332
332
|
return r?.start?.() ?? false
|
|
333
|
-
})()`})}}),p&&(u.stepDelay=p);let
|
|
333
|
+
})()`})}}),p&&(u.stepDelay=p);let A=null,b=null,_=null,H=null,N=0,Oe=!!E[0]?.launchApp;try{await u.waitForTree(12e4),await oe()&&await u.waitForTree(12e4),x&&(Oe?u.prepareRecording():await u.startRecording()),r&&await u.startProfile(),y&&(await T.send({type:"evaluate",simId:u.simId,code:`(() => {
|
|
334
334
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
335
335
|
return r?.start?.() ?? false
|
|
336
|
-
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await u.runFlow(E),r&&(
|
|
336
|
+
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await u.runFlow(E),r&&(A=await u.stopProfile()),x&&ee>0&&await new Promise(c=>setTimeout(c,ee)),x&&(b=await u.stopRecording(),_=u.getLastRecordingDurationMs()),y&&(H=await T.send({type:"evaluate",simId:u.simId,code:`(() => {
|
|
337
337
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
338
338
|
return r?.stop?.() ?? []
|
|
339
|
-
})()`}),console.log(` captured ${
|
|
340
|
-
+ completed (${E.length} steps)`),
|
|
339
|
+
})()`}),console.log(` captured ${H.length} replay events`)),console.log(`
|
|
340
|
+
+ completed (${E.length} steps)`),A&&Te(A),b&&console.log(` video: ${b}`),console.log()}catch(d){if(r&&!A)try{A=await u.stopProfile()}catch{}if(x&&!b)try{b=await u.stopRecording(),_=u.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}console.error(`
|
|
341
341
|
x failed: ${d.message}
|
|
342
|
-
`),
|
|
343
|
-
preparing preview upload\u2026`);let{runUpload:v}=await import("./upload-
|
|
342
|
+
`),A&&(console.log(" partial profile:"),Te(A)),b&&console.log(` partial video: ${b}`);try{let c=u.lastFailedStep,v=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",D=g.join(s,v);await u.captureFailureBundle(D,{error:d,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),console.log(` failure bundle: ${D}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let v=g.join(s,"error.png");await u.captureFailureScreenshot(v),console.log(` error screenshot: ${v}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await ue(T,{errorsCommand:`sootsim get errors 5${u.simId?` --sim ${u.simId}`:""}`,warningsCommand:`sootsim get warnings 5${u.simId?` --sim ${u.simId}`:""}`,requestsCommand:`sootsim get requests 5${u.simId?` --sim ${u.simId}`:""}`}),N=1}finally{T.close()}if(N===0&&y)try{let d=await We(H??[]),c=["--origin",j,"--events",d];Q&&c.push("--public-origin",Q),b&&c.push("--video",b),b&&_&&Number.isFinite(_)&&c.push("--video-duration-ms",String(Math.round(_))),u.simId&&c.push("--sim",u.simId),Me&&c.push("--open"),console.log(`
|
|
343
|
+
preparing preview upload\u2026`);let{runUpload:v}=await import("./upload-RLS6KTG6.js");await v(c,{})}catch(d){console.error(` preview upload failed: ${d?.message||d}`),N=1}return await z(),N}async function We(o){let{gzipSync:e}=await import("zlib"),t=o.map(n=>JSON.stringify(n)).join(`
|
|
344
344
|
`)+(o.length?`
|
|
345
|
-
`:""),r=e(Buffer.from(t,"utf8")),i=g.join($e(),`sootsim-events-${Date.now()}.jsonl.gz`);return $.writeFileSync(i,r),console.log(` events: ${o.length} written to ${i} (${r.length} bytes gz)`),i}async function
|
|
346
|
-
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=a;return}
|
|
345
|
+
`:""),r=e(Buffer.from(t,"utf8")),i=g.join($e(),`sootsim-events-${Date.now()}.jsonl.gz`);return $.writeFileSync(i,r),console.log(` events: ${o.length} written to ${i} (${r.length} bytes gz)`),i}async function je(o){let e=o[0],t=r=>o.find((i,n)=>o[n-1]===r);switch(e){case"start":{let{path:r,state:i}=me();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${i.steps.length}`);return}case"keep":case"good":{let r=pe();if(r.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!r.kept){console.log(" no pending action to keep");return}console.log(` kept: ${r.candidate.summary}`),console.log(` steps: ${r.stepCount}`);return}case"end":{let r=t("--output")||(o[1]&&!o[1].startsWith("-")?o[1]:void 0),i=o.includes("--validate")||o.includes("--video"),n=o.includes("--video"),s=fe(r||(i?Ke():void 0));if(s.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),i){let l=Je(o,s.outputPath),a=await Ae(l);if(a!==0){console.error(`
|
|
346
|
+
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=a;return}Y(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),n&&console.log(" video: recorded during validation run");return}if(Y(),console.log(` flow draft ended (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath){console.log(` saved: ${s.outputPath}`),console.log(` next: sootsim flow ${s.outputPath} --record`);return}console.log(""),process.stdout.write(s.yaml);return}case"validate":{let r=o[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let i=Le(r);if(i.length>0){console.error(` x ${r} failed validation:`);for(let n of i)console.error(` - ${n}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}var Fe=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function Le(o){let e=[];if(!$.existsSync(o))return[`file not found: ${o}`];let t;try{t=$.readFileSync(o,"utf8")}catch(n){return[`cannot read file: ${n.message}`]}if(t.trim().length===0)return["file is empty"];let r;try{r=ke(t)}catch(n){return[`yaml parse error: ${n.message}`]}if(!Array.isArray(r.steps)||r.steps.length===0)return e.push("flow body must be a non-empty YAML array of steps"),e;let i=0;for(let n=0;n<r.steps.length;n++){let s=r.steps[n];s&&typeof s=="object"?Object.keys(s).some(a=>Fe.has(a))&&(i+=1):typeof s=="string"&&Fe.has(s)&&(i+=1)}return i===0&&e.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),e}async function dt(o){let e=o[0];if(e==="start"||e==="keep"||e==="good"||e==="end"||e==="validate")return await je(o),0;let t=await Ae(o);return t!==0&&(process.exitCode=t),t}function Te(o){let e=o.avgMs>0?(1e3/o.avgMs).toFixed(1):"?",t=o.sampleCount>0?(o.jankFrames/o.sampleCount*100).toFixed(1):"0";console.log(`
|
|
347
347
|
profile:`),console.log(` frames: ${o.frames}`),console.log(` total: ${o.totalMs.toFixed(1)}ms`),console.log(` avg: ${o.avgMs.toFixed(2)}ms (${e} fps)`),console.log(` max: ${o.maxMs.toFixed(2)}ms`),o.layoutAvgMs!==void 0&&console.log(` breakdown: layout ${o.layoutAvgMs.toFixed(2)}ms | render ${o.renderAvgMs?.toFixed(2)||"0.00"}ms | copy ${o.copyAvgMs?.toFixed(2)||"0.00"}ms`),console.log(` p95: ${o.p95.toFixed(2)}ms`),console.log(` p99: ${o.p99.toFixed(2)}ms`),console.log(` jank: ${o.jankFrames}/${o.sampleCount} (${t}%) >16.67ms`);let r=Array.isArray(o.worstFrames)?o.worstFrames:[];if(r.length!==0){if(console.log(`
|
|
348
|
-
worst frames:`),o.mode==="render-worker"){console.log(" total layout render copy t+");for(let i of r){let[n,s,l,a,p]=i;console.log(` ${s.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${String(n).padStart(5)}`)}return}console.log(` ${r.map(i=>i.toFixed(2)).join(", ")}`)}}function
|
|
348
|
+
worst frames:`),o.mode==="render-worker"){console.log(" total layout render copy t+");for(let i of r){let[n,s,l,a,p]=i;console.log(` ${s.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${String(n).padStart(5)}`)}return}console.log(` ${r.map(i=>i.toFixed(2)).join(", ")}`)}}function Ke(){return g.join($e(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Je(o,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let r=1;r<o.length;r++){let i=o[r];if(!(i==="--validate"||i==="--video")){if(i==="--output"){r+=1;continue}r===1&&!i.startsWith("-")||t.push(i)}}return!t.includes("--record")&&o.includes("--video")&&t.push("--record"),t}export{ke as a,Be as b,Ae as c,dt as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as d}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as d}from"./chunk-6PLNIOJP.js";import{a as p,d as w,h as $,j as y}from"./chunk-OXTFYLZJ.js";import{A as g,B as f,i as h,y as m,z as a}from"./chunk-J3JJRXIP.js";import b from"fs";import{WebSocket as D}from"ws";async function P(n,e={}){let[o,...t]=n;if(!o||o==="--help"||o==="-h"){R();return}switch(o){case"install":return O(t,e);case"list":case"ls":return S(t);case"use":return T(t);case"remove":case"rm":return N(t);case"which":case"active":return F();default:console.error(` unknown runtime subcommand: ${o}`),R(),process.exit(1)}}function R(){console.log(`
|
|
3
3
|
sootsim runtime \u2014 manage engine runtimes under ~/.sootsim/runtimes/
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -22,4 +22,4 @@ examples:
|
|
|
22
22
|
sootsim runtime install 1.2.3
|
|
23
23
|
sootsim runtime install --channel beta
|
|
24
24
|
sootsim runtime use 1.2.3
|
|
25
|
-
`)}async function O(n,e){let{version:o,flags:t}=_(n),s=t.channel??e.channel??"stable",l=t.force===!0,c=t.setActive!==!1;m(),console.log("sootsim runtime install"),console.log(` cdn: ${w()}`);try{let i=await y({version:o,channel:s,force:l,setActive:c});console.log(` version: ${i.version} (channel: ${i.channel})`),i.installed?console.log(` installed ${i.version}`):console.log(` already installed at ${i.runtimeDir}`),c&&await k(i.version)}catch(i){console.error(` ${I(i)}`),process.exit(1)}}async function k(n){g(n),console.log(` active: ${n}`),await A(n)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${n})`)}async function A(n){let{isDaemonLockfileFresh:e,readDaemonLockfile:o}=await import("./home-paths-
|
|
25
|
+
`)}async function O(n,e){let{version:o,flags:t}=_(n),s=t.channel??e.channel??"stable",l=t.force===!0,c=t.setActive!==!1;m(),console.log("sootsim runtime install"),console.log(` cdn: ${w()}`);try{let i=await y({version:o,channel:s,force:l,setActive:c});console.log(` version: ${i.version} (channel: ${i.channel})`),i.installed?console.log(` installed ${i.version}`):console.log(` already installed at ${i.runtimeDir}`),c&&await k(i.version)}catch(i){console.error(` ${I(i)}`),process.exit(1)}}async function k(n){g(n),console.log(` active: ${n}`),await A(n)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${n})`)}async function A(n){let{isDaemonLockfileFresh:e,readDaemonLockfile:o}=await import("./home-paths-5QMCFTBP.js"),t=o();if(!e(t))return!1;let s=d();return new Promise(l=>{let c=!1,i=!1,u=x=>{c||(c=!0,l(x))},r=new D(`ws://127.0.0.1:${s}`,{handshakeTimeout:800}),v=setTimeout(()=>{try{r.close()}catch{}u(i)},1500);r.on("open",()=>{try{r.send(JSON.stringify({type:"runtime:use",version:n,id:0})),i=!0}catch{}setTimeout(()=>{try{r.close()}catch{}},100)}),r.on("close",()=>{clearTimeout(v),u(i)}),r.on("error",()=>{clearTimeout(v),u(!1)})})}async function S(n){m();let e=f(),o=a();if(console.log("installed:"),e.length===0)console.log(" (none)");else for(let t of e)console.log(` ${t===o?"*":" "} ${t}`);try{let t=await $();console.log("available (latest per channel):");for(let[s,l]of Object.entries(t.channels))console.log(` ${s.padEnd(8)} ${l.latest}`)}catch(t){console.log(`available: (could not fetch manifest: ${I(t)})`)}}async function T(n){let e=n[0];e||(console.error(" usage: sootsim runtime use <version>"),process.exit(1));let o=f();o.includes(e)||(console.error(` version ${e} is not installed`),console.error(` installed: ${o.join(", ")||"(none)"}`),console.error(` run \`sootsim runtime install ${e}\` first`),process.exit(1)),await k(e)}async function N(n){let e=n[0];e||(console.error(" usage: sootsim runtime remove <version>"),process.exit(1)),a()===e&&(console.error(` cannot remove active runtime ${e}`),console.error(" switch with `sootsim runtime use <other>` first, or install another version"),process.exit(1));let t=h(e);if(!b.existsSync(t)){console.error(` ${e} is not installed`);return}b.rmSync(t,{recursive:!0,force:!0}),console.log(` removed ${e}`)}async function F(){let n=a();if(!n){console.log(" no active runtime");return}console.log(n)}function _(n){let e={},o=[];for(let t=0;t<n.length;t++){let s=n[t];if(s==="--channel"&&t+1<n.length){e.channel=n[t+1],t++;continue}if(s.startsWith("--channel=")){e.channel=s.slice(10);continue}if(s==="--force"){e.force=!0;continue}if(s==="--set-active=false"||s==="--no-set-active"){e.setActive=!1;continue}o.push(s)}return{version:o[0]??null,flags:e}}function I(n){return n instanceof Error?n.message:String(n)}export{P as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{b as d}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{b as d}from"./chunk-SWHWVYZS.js";import{existsSync as S,mkdirSync as h,readFileSync as b,writeFileSync as H,rmSync as m}from"fs";import{tmpdir as w}from"os";import{dirname as v,join as p}from"path";var y=new Map;function i(e,r){y.set(e,r)}var a=1;function s(){return p(w(),`sootsim-cli-hints-${d()}.json`)}function l(){return p(w(),"sootsim-cli-hints-global.json")}function u(e){if(!S(e))return{version:a,shown:{}};try{let r=JSON.parse(b(e,"utf8"));return r?.version!==a||!r?.shown?{version:a,shown:{}}:r}catch{return{version:a,shown:{}}}}function f(e,r){try{h(v(e),{recursive:!0}),H(e,JSON.stringify(r)+`
|
|
3
3
|
`)}catch{}}function F(){let e=(process.env.SOOTSIM_HINTS||"").toLowerCase();return e==="off"||e==="0"||e==="false"?"off":e==="always"||e==="verbose"?"always":"normal"}function x(e,r){let o=F();if(o==="off")return!1;if(o==="always"||r==="always")return!0;let n=Date.now();if(r==="once-per-identity"){let t=u(s());return t.shown[e]?!1:(t.shown[e]=n,f(s(),t),!0)}if(r==="once-ever"){let t=u(l());return t.shown[e]?!1:(t.shown[e]=n,f(l(),t),!0)}if(typeof r=="object"&&"cooldownMs"in r){let t=u(s()),c=t.shown[e]??0;return n-c<r.cooldownMs?!1:(t.shown[e]=n,f(s(),t),!0)}return!0}function M(e,...r){let o=y.get(e);if(!o)return process.env.SOOTSIM_HINTS_DEBUG&&console.error(` [hints] no hint registered for id "${e}"`),!1;if(!x(e,o.frequency))return!1;let n=o.render(...r);if(n==null)return!1;let t=Array.isArray(n)?n:[n],c=o.stream==="error"?console.error:console.log;for(let g of t)c(` hint: ${g}`);return!0}function O(){m(s(),{force:!0})}function k(){m(l(),{force:!0})}function T(){return Array.from(y.entries()).map(([e,r])=>({id:e,frequency:r.frequency}))}i("app-still-loading",{frequency:{cooldownMs:6e4},render:e=>`app may still be loading (${e} nodes). run \`sootsim wait ready\` first.`});i("wait-selector-for-missing-testid",{frequency:"once-per-identity",render:e=>`sootsim wait selector ${e}`,stream:"error"});i("prefer-cli-over-eval",{frequency:"once-per-identity",render:e=>e.length?["try the CLI shortcut instead:",...e.map(r=>` ${r}`)]:null,stream:"error"});i("describe-use-filters",{frequency:"once-per-identity",render:()=>["describe output is long. narrow it with:"," sootsim describe --only '*Bottom Sheet*'"," sootsim describe --testid-like 'swap-*'"," sootsim describe --subtree <testID>"]});i("subtree-root-not-found",{frequency:"always",render:e=>`no node with testID/id "${e}" \u2014 try \`sootsim find --testid ${e}\` to discover available ids.`,stream:"error"});export{M as a,O as b,k as c,T as d};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as p}from"./chunk-Y2YNXUBT.js";import{d as c,e as l}from"./chunk-ANDSHXLU.js";import{a}from"./chunk-S3SQITOO.js";async function g(e,t){if(t)return t.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let i=a();return i?.origin?i.origin.replace(/\/$/,""):(await p()).replace(/\/$/,"")}async function m(e,t={}){let i=c();if(i||(process.stderr.write(`
|
|
3
|
+
sootsim ${e} needs auth before it can check recording access.
|
|
4
|
+
|
|
5
|
+
pick one:
|
|
6
|
+
\u2022 run \`sootsim login\`
|
|
7
|
+
\u2022 set SOOTSIM_API_KEY=sk_sootsim_... (recommended for CI)
|
|
8
|
+
\u2022 save a personal key with \`sootsim keys use sk_sootsim_...\`
|
|
9
|
+
|
|
10
|
+
`),process.exit(1)),i.kind==="github"&&t.allowGitHubAuth)return;let s=await g(i,t.originOverride),r;try{r=await fetch(`${s}/api/sootsim/billing/subscription`,{headers:{authorization:l(i)}})}catch(n){process.stderr.write(`
|
|
11
|
+
sootsim ${e} couldn't verify recording access.
|
|
12
|
+
${n instanceof Error?n.message:String(n)}
|
|
13
|
+
|
|
14
|
+
`),process.exit(1)}if(r.status===401&&(process.stderr.write(`
|
|
15
|
+
sootsim ${e} couldn't verify recording access with the current auth against ${s}.
|
|
16
|
+
sign in again for that origin, or provide a valid SOOTSIM_API_KEY.
|
|
17
|
+
|
|
18
|
+
`),process.exit(1)),!r.ok){let n=await r.text().catch(()=>"");process.stderr.write(`
|
|
19
|
+
sootsim ${e} couldn't verify recording access (${r.status}).
|
|
20
|
+
${n||"unexpected billing response"}
|
|
21
|
+
|
|
22
|
+
`),process.exit(1)}let o=await r.json();if(o.entitlements?.desktopRecording===!0)return;let u=o.plan??"free";process.stderr.write(`
|
|
23
|
+
sootsim ${e} recording requires Personal, Team, or an active trial.
|
|
24
|
+
current plan: ${u}.
|
|
25
|
+
free keeps basic 3d mode; the trial unlocks the full Personal surface.
|
|
26
|
+
|
|
27
|
+
`),process.exit(1)}export{m as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import r from"node:fs";import{homedir as O}from"node:os";import n from"node:path";var L="SOOTSIM_HOME",E="active",A="daemon.json",j="config.json",I=3e4;function c(){let e=process.env[L];return e&&e.length>0?n.resolve(e):n.join(O(),".sootsim")}function K(){if(process.env.SOOTSIM_FORCE_DAEMON_INSTALL==="1")return!1;let e=process.env.SOOTSIM_DEV;if(e==="1"||e==="true")return!0;if(e==="0"||e==="false")return!1;let t=process.argv[1];if(!t)return!1;try{return r.realpathSync(t).includes(`${n.sep}packages${n.sep}sootsim${n.sep}`)}catch{return!1}}function f(){return n.join(c(),"runtimes")}function _(e){return n.join(f(),e)}function D(){return n.join(f(),E)}function S(){return n.join(c(),"electron")}function U(){return n.join(S(),"userData")}function Y(e){return n.join(S(),e)}function N(){return n.join(c(),"profiles")}function F(){return n.join(c(),"daemon-app")}function T(){return n.join(F(),"SootSim Daemon.app")}function G(){return n.join(T(),"Contents","MacOS","sootsim-daemon")}function C(){return n.join(c(),"cache")}function p(){return n.join(c(),A)}function d(){return n.join(c(),j)}function v(){try{let e=r.readFileSync(d(),"utf8"),t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function M(e){y();let t=v(),s={...t,...e};e.settings&&typeof e.settings=="object"&&(s.settings={...t.settings&&typeof t.settings=="object"?t.settings:{},...e.settings});let u=`${d()}.tmp`;return r.writeFileSync(u,`${JSON.stringify(s,null,2)}
|
|
3
3
|
`,"utf8"),r.renameSync(u,d()),s}function X(){return v().telemetry!==!1}function q(e){M({telemetry:e})}function y(){r.mkdirSync(c(),{recursive:!0}),r.mkdirSync(f(),{recursive:!0}),r.mkdirSync(S(),{recursive:!0}),r.mkdirSync(N(),{recursive:!0}),r.mkdirSync(C(),{recursive:!0})}function w(){try{let e=r.readFileSync(D(),"utf8").trim();return e.length>0?e:null}catch{return null}}function z(e){r.mkdirSync(f(),{recursive:!0}),r.writeFileSync(D(),`${e}
|
|
4
4
|
`,"utf8")}function Q(){try{return r.readdirSync(f(),{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort(P)}catch{return[]}}function P(e,t){let s=i=>{let a=i.indexOf("-"),l=a>=0?i.slice(0,a):i,k=a>=0?i.slice(a+1):"",b=l.split(".").map(g=>Number.parseInt(g,10));return b.some(g=>!Number.isFinite(g))?[[Number.POSITIVE_INFINITY],i]:[b,k]},[u,o]=s(e),[x,m]=s(t);for(let i=0;i<Math.max(u.length,x.length);i++){let a=u[i]??0,l=x[i]??0;if(a!==l)return a-l}return o===m?0:o?m?o<m?-1:1:-1:1}function W(){let e=w();if(!e)return null;let t=_(e);try{if(r.statSync(t).isDirectory())return t}catch{}return null}var h=16*1024;function R(){try{let e=r.openSync(p(),"r");try{let t=Buffer.alloc(h),s=r.readSync(e,t,0,h,0),u=t.subarray(0,s).toString("utf8"),o=JSON.parse(u);return o&&o.schema===1&&typeof o.pid=="number"&&typeof o.bridgePort=="number"&&typeof o.runtimePort=="number"&&typeof o.startedAt=="number"&&typeof o.heartbeatAt=="number"?o:null}finally{r.closeSync(e)}}catch{return null}}function $(e,t=Date.now()){if(!e||t-e.heartbeatAt>I)return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}function H(e){y();let t=`${p()}.tmp`;r.writeFileSync(t,`${JSON.stringify(e,null,2)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as R}from"./chunk-DSTHAISO.js";import{l as D}from"./chunk-YKEBL6GE.js";import{a as T}from"./chunk-DEBXVPIE.js";function Y(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function I(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return Y(r)?r:null}catch{return null}}import{randomBytes as G,createHash as q}from"node:crypto";import m from"node:fs";import y from"node:path";var N=null;function _(){if(N)return N;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||D()}function h(){return _()}function U(){return y.join(_(),"attached-projects.json")}function $(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=m.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return $();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{m.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return $()}}function X(e){let t=U();m.mkdirSync(y.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=m.openSync(r,"w",384);try{m.writeFileSync(n,JSON.stringify(e,null,2)),m.fsyncSync(n)}finally{m.closeSync(n)}m.renameSync(r,t)}function w(e){let t=S();return e(t),X(t),t}function B(e){return q("sha256").update(y.resolve(e)).digest("hex").slice(0,16)}function K(){return`s_${G(10).toString("hex")}`}function ge(e){let t=y.resolve(e.cwd),r=B(t),n;return w(o=>{let s=o.attachedProjects.find(c=>c.id===r);if(s){let c={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=c,n=c;return}let a=Date.now(),d={id:r,name:e.name??y.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:a,updatedAt:a};o.attachedProjects.push(d),n=d}),n}function F(e){return S().attachedProjects.find(t=>t.id===e)??null}function ye(){return S().attachedProjects}var Q=336*60*60*1e3;function he(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],a=o-Q,d=s.filter(c=>c.ts>=a);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Se(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function we(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function M(e){let t;return w(r=>{if(e.id){let a=r.agentSessions.find(d=>d.id===e.id);if(a){let d={...a,...e,lastSeenAt:Date.now()},c=r.agentSessions.indexOf(a);r.agentSessions[c]=d,t=d;return}}let n=r.attachedProjects.find(a=>a.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??K(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function C(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function v(e,t){w(r=>{let n=r.agentSessions.find(s=>s.id===e);if(!n)return;let o=r.agentSessions.indexOf(n);r.agentSessions[o]={...n,...t,id:n.id,projectId:n.projectId,createdAt:n.createdAt,lastSeenAt:Date.now()}})}async function ve(){if(S().attachedProjects.length>0)return;let t;try{t=(await import("./demo-app-registry-4RFMJ4FM.js")).APPS}catch(n){console.warn("[sootsim] seedFromDemoAppRegistry: could not load demo registry:",n.message);return}if(!Array.isArray(t))return;let r=t;w(n=>{for(let o of r){if(!m.existsSync(o.dir))continue;let s=y.resolve(o.dir),a=B(s);if(n.attachedProjects.some(c=>c.id===a))continue;let d=Date.now();n.attachedProjects.push({id:a,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as V,spawnSync as z}from"node:child_process";import{randomUUID as Z}from"node:crypto";import i,{constants as f}from"node:fs";import u from"node:path";import ee from"node:readline";function j(e){return u.join(h(),"sessions",e)}function W(e){return u.join(j(e),"prompt.in")}function J(e){return u.join(j(e),"events.out")}function te(e){return u.join(h(),"transcripts",`${e}.log`)}function O(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(j(t)))}function re(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ne();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("sootsim CLI not found. set SOOTSIM_BIN to the path of the sootsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ne(){try{let e=se();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli` (watch:cli:binary builds dist-bin/ instead).")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function se(){try{let r=T.resolve("sootsim/package.json");return u.dirname(r)}catch{}let e=oe();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name==="sootsim")return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function oe(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function ie(e,t,r){let n=u.join(h(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,a=null;for(;a===null;)try{a=i.openSync(o,f.O_WRONLY|f.O_CREAT|f.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let c=Number(i.readFileSync(o,"utf8").trim());if(c&&!ce(c)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(c=>setTimeout(c,50))}try{return i.writeFileSync(a,String(process.pid)),await r()}finally{try{i.closeSync(a)}catch{}try{i.unlinkSync(o)}catch{}}}function ce(e){try{return process.kill(e,0),!0}catch{return!1}}function L(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=z("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Te(e){let t=F(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return ie(t.id,r,async()=>{let n=C(t.id).find(p=>p.provider===r&&p.status!=="ended"&&O(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`sootsim agent end <sessionId>\`.`);let o=r==="claude"?Z():void 0,s=M({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),a=W(s.id),d=J(s.id),c=te(s.id);L(a),L(d);let g=u.dirname(c);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:H}=re(),P=[...H,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",a,"--events-out",d,"--transcript",c];e.codexBin&&P.push("--codex-bin",e.codexBin),e.claudeBin&&P.push("--claude-bin",e.claudeBin),e.freshThread&&P.push("--fresh-thread"),o&&P.push("--claude-session-uuid",o);let x=V(A,P,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:h()}});x.unref();let E=e.readyTimeoutMs??6e3,b=await ae(d,p=>p.type==="ready"||p.type==="error",E);if(!b||b.type==="error"){if(x.pid)try{process.kill(x.pid,"SIGTERM")}catch{}try{i.rmSync(j(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=b&&b.type==="error"?b.message:`no ready event within ${E}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:x.pid,status:"idle"}),{session:k(s.id),wrapperPid:x.pid}})}async function De(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!O(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=W(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,f.O_WRONLY);try{let s=R(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as R}from"./chunk-2T6UOHPO.js";import{l as D}from"./chunk-J3JJRXIP.js";import{a as T}from"./chunk-N7DDNZTO.js";function Y(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.type=="string"&&typeof t.ts=="number"}function I(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return Y(r)?r:null}catch{return null}}import{randomBytes as G,createHash as q}from"node:crypto";import m from"node:fs";import y from"node:path";var N=null;function _(){if(N)return N;let e=process.env.SOOTSIM_USER_DATA_DIR;return e||D()}function h(){return _()}function U(){return y.join(_(),"attached-projects.json")}function $(){return{version:1,attachedProjects:[],previewAttachments:[],agentSessions:[]}}function S(){let e=U(),t;try{t=m.readFileSync(e,"utf8")}catch(r){if(r.code==="ENOENT")return $();throw r}try{let r=JSON.parse(t);if(!r||typeof r!="object")throw new Error("not an object");return{version:1,attachedProjects:Array.isArray(r.attachedProjects)?r.attachedProjects:[],previewAttachments:Array.isArray(r.previewAttachments)?r.previewAttachments:[],agentSessions:Array.isArray(r.agentSessions)?r.agentSessions:[]}}catch(r){let n=`${e}.corrupt-${Date.now()}`;try{m.renameSync(e,n),console.warn(`[sootsim] attached-projects.json was unparseable; quarantined to ${n}. original error: ${r.message}`)}catch{}return $()}}function X(e){let t=U();m.mkdirSync(y.dirname(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}`,n=m.openSync(r,"w",384);try{m.writeFileSync(n,JSON.stringify(e,null,2)),m.fsyncSync(n)}finally{m.closeSync(n)}m.renameSync(r,t)}function w(e){let t=S();return e(t),X(t),t}function B(e){return q("sha256").update(y.resolve(e)).digest("hex").slice(0,16)}function K(){return`s_${G(10).toString("hex")}`}function ge(e){let t=y.resolve(e.cwd),r=B(t),n;return w(o=>{let s=o.attachedProjects.find(c=>c.id===r);if(s){let c={...s,...e,id:r,cwd:t,sourceRoots:e.sourceRoots??s.sourceRoots,knownBundleUrls:e.knownBundleUrls??s.knownBundleUrls,pinnedSourceResolutions:e.pinnedSourceResolutions??s.pinnedSourceResolutions,telemetry:e.telemetry??s.telemetry,updatedAt:Date.now(),createdAt:s.createdAt},g=o.attachedProjects.indexOf(s);o.attachedProjects[g]=c,n=c;return}let a=Date.now(),d={id:r,name:e.name??y.basename(t),cwd:t,repoRoot:e.repoRoot,sourceRoots:e.sourceRoots??[t],framework:e.framework??"unknown",bundleId:e.bundleId,knownBundleUrls:e.knownBundleUrls??[],preferredProvider:e.preferredProvider??"codex",preferredTransport:e.preferredTransport??"tmux",editorOpenCommand:e.editorOpenCommand,moshiWebhookToken:e.moshiWebhookToken,pinnedSourceResolutions:e.pinnedSourceResolutions??{},isolateDiscovery:e.isolateDiscovery,git:e.git,telemetry:e.telemetry??{lastOpened:0,runsCompleted:0},createdAt:a,updatedAt:a};o.attachedProjects.push(d),n=d}),n}function F(e){return S().attachedProjects.find(t=>t.id===e)??null}function ye(){return S().attachedProjects}var Q=336*60*60*1e3;function he(e,t={}){w(r=>{let n=r.attachedProjects.find(s=>s.id===e);if(!n)return;let o=t.ts??Date.now();if(n.telemetry.runsCompleted=(n.telemetry.runsCompleted??0)+1,typeof t.usd=="number"&&Number.isFinite(t.usd)&&t.usd>=0){let s=n.telemetry.costHistory??[],a=o-Q,d=s.filter(c=>c.ts>=a);d.push({ts:o,usd:t.usd}),n.telemetry.costHistory=d}n.updatedAt=o})}function Se(e,t=Date.now()){let r=t-6048e5,n=e.telemetry.costHistory??[],o=0;for(let s of n)s.ts>=r&&(o+=s.usd);return o}function we(e){w(t=>{t.attachedProjects=t.attachedProjects.filter(r=>r.id!==e),t.agentSessions=t.agentSessions.filter(r=>r.projectId!==e),t.previewAttachments=t.previewAttachments.filter(r=>r.projectId!==e)})}function M(e){let t;return w(r=>{if(e.id){let a=r.agentSessions.find(d=>d.id===e.id);if(a){let d={...a,...e,lastSeenAt:Date.now()},c=r.agentSessions.indexOf(a);r.agentSessions[c]=d,t=d;return}}let n=r.attachedProjects.find(a=>a.id===e.projectId);if(!n)throw new Error(`upsertSession: no AttachedProject with id=${e.projectId}`);let o=Date.now(),s={id:e.id??K(),projectId:e.projectId,provider:e.provider,transport:e.transport??n.preferredTransport,cwd:e.cwd??n.cwd,claudeSessionUuid:e.claudeSessionUuid,tmuxSessionName:e.tmuxSessionName,wrapperPid:e.wrapperPid,status:e.status??"idle",needsAttention:e.needsAttention??!1,lastPrompt:e.lastPrompt,lastSummary:e.lastSummary,lastTurnFiles:e.lastTurnFiles,currentlyEditing:e.currentlyEditing,lastSeenAt:o,createdAt:o};r.agentSessions.push(s),t=s}),t}function k(e){return S().agentSessions.find(t=>t.id===e)??null}function C(e){let t=S().agentSessions;return e?t.filter(r=>r.projectId===e):t}function v(e,t){w(r=>{let n=r.agentSessions.find(s=>s.id===e);if(!n)return;let o=r.agentSessions.indexOf(n);r.agentSessions[o]={...n,...t,id:n.id,projectId:n.projectId,createdAt:n.createdAt,lastSeenAt:Date.now()}})}async function ve(){if(S().attachedProjects.length>0)return;let t;try{t=(await import("./demo-app-registry-3VFEW4NV.js")).APPS}catch(n){console.warn("[sootsim] seedFromDemoAppRegistry: could not load demo registry:",n.message);return}if(!Array.isArray(t))return;let r=t;w(n=>{for(let o of r){if(!m.existsSync(o.dir))continue;let s=y.resolve(o.dir),a=B(s);if(n.attachedProjects.some(c=>c.id===a))continue;let d=Date.now();n.attachedProjects.push({id:a,name:o.label,cwd:s,sourceRoots:[s],framework:o.framework,knownBundleUrls:[`http://localhost:${o.preferredPort}/index.bundle`],preferredProvider:"codex",preferredTransport:"tmux",pinnedSourceResolutions:{},telemetry:{lastOpened:0,runsCompleted:0},createdAt:d,updatedAt:d})}})}import{spawn as V,spawnSync as z}from"node:child_process";import{randomUUID as Z}from"node:crypto";import i,{constants as f}from"node:fs";import u from"node:path";import ee from"node:readline";function j(e){return u.join(h(),"sessions",e)}function W(e){return u.join(j(e),"prompt.in")}function J(e){return u.join(j(e),"events.out")}function te(e){return u.join(h(),"transcripts",`${e}.log`)}function O(e,t){if(!e)return!1;try{process.kill(e,0)}catch{return!1}return!(t&&!i.existsSync(j(t)))}function re(){if(process.env.SOOTSIM_BIN)return{cmd:process.env.SOOTSIM_BIN,prefixArgs:[]};if(process.versions.electron){let n=process.resourcesPath;if(n){let o=[u.join(n,"bin","sootsim"),u.join(n,"bin",`sootsim-${process.platform}-${process.arch}`)];for(let s of o)if(i.existsSync(s))return{cmd:s,prefixArgs:[]}}}let e=ne();if(e)return e;let t=process.argv[0],r=process.argv[1];if(r&&/\.(ts|tsx|mjs|cjs|js)$/.test(r))return{cmd:t,prefixArgs:[r]};if(!r||r.includes("/.bin/"))throw new Error("sootsim CLI not found. set SOOTSIM_BIN to the path of the sootsim binary, or build the workspace CLI via `bun run --cwd packages/sootsim build:cli`.");return{cmd:t,prefixArgs:[]}}function ne(){try{let e=se();if(!e)return null;let t=`sootsim-${process.platform}-${process.arch}`,r=u.join(e,"dist-bin",t);if(i.existsSync(r))return{cmd:r,prefixArgs:[]};let n=u.join(e,"dist-cli","bin.js");if(i.existsSync(n)){try{let o=u.join(e,"cli","commands","agent-wrapper.ts");if(i.existsSync(o)){let s=i.statSync(o).mtimeMs;i.statSync(n).mtimeMs<s&&console.warn("[sootsim] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with `bun run --cwd packages/sootsim build:cli` (watch:cli:binary builds dist-bin/ instead).")}}catch{}return{cmd:process.execPath,prefixArgs:[n]}}return null}catch{return null}}function se(){try{let r=T.resolve("sootsim/package.json");return u.dirname(r)}catch{}let e=oe();if(!e)return null;let t=u.dirname(e);for(let r=0;r<8;r++){let n=u.join(t,"package.json");try{if(i.existsSync(n)&&JSON.parse(i.readFileSync(n,"utf8")).name==="sootsim")return t}catch{}let o=u.dirname(t);if(o===t)break;t=o}return null}function oe(){try{let e=import.meta.url;return!e||!e.startsWith("file://")?null:decodeURIComponent(e.slice(7))}catch{return null}}async function ie(e,t,r){let n=u.join(h(),"locks");i.mkdirSync(n,{recursive:!0});try{i.chmodSync(n,448)}catch{}let o=u.join(n,`start-${e}-${t}.lock`),s=Date.now()+4e3,a=null;for(;a===null;)try{a=i.openSync(o,f.O_WRONLY|f.O_CREAT|f.O_EXCL,384)}catch(d){if(d.code!=="EEXIST")throw d;try{let c=Number(i.readFileSync(o,"utf8").trim());if(c&&!ce(c)){i.unlinkSync(o);continue}}catch{}if(Date.now()>s)throw new Error(`another start is in progress for project=${e} provider=${t} (lock: ${o})`);await new Promise(c=>setTimeout(c,50))}try{return i.writeFileSync(a,String(process.pid)),await r()}finally{try{i.closeSync(a)}catch{}try{i.unlinkSync(o)}catch{}}}function ce(e){try{return process.kill(e,0),!0}catch{return!1}}function L(e){let t=u.dirname(e);i.mkdirSync(t,{recursive:!0});try{i.chmodSync(t,448)}catch{}if(i.existsSync(e))try{if(i.statSync(e).isFIFO()){try{i.chmodSync(e,384)}catch{}return}i.unlinkSync(e)}catch{i.unlinkSync(e)}let r=z("mkfifo",["-m","600",e]);if(r.status!==0)throw new Error(`mkfifo(${e}) failed: ${r.stderr?.toString().trim()||"unknown error"}`)}var l=class extends Error{code;constructor(t,r){super(r),this.code=t}};async function Te(e){let t=F(e.projectId);if(!t)throw new l("NO_PROJECT",`no project with id=${e.projectId}`);let r=e.provider||t.preferredProvider||"codex";return ie(t.id,r,async()=>{let n=C(t.id).find(p=>p.provider===r&&p.status!=="ended"&&O(p.wrapperPid,p.id));if(n)throw new l("ALREADY_RUNNING",`session already running for project=${t.id} provider=${r} (session ${n.id}, pid ${n.wrapperPid}). end it first with \`sootsim agent end <sessionId>\`.`);let o=r==="claude"?Z():void 0,s=M({projectId:t.id,provider:r,transport:"pty",cwd:t.cwd,status:"idle",claudeSessionUuid:o}),a=W(s.id),d=J(s.id),c=te(s.id);L(a),L(d);let g=u.dirname(c);i.mkdirSync(g,{recursive:!0});try{i.chmodSync(g,448)}catch{}let{cmd:A,prefixArgs:H}=re(),P=[...H,"agent-wrapper","--session-id",s.id,"--project-id",t.id,"--provider",r,"--cwd",t.cwd,"--prompt-in",a,"--events-out",d,"--transcript",c];e.codexBin&&P.push("--codex-bin",e.codexBin),e.claudeBin&&P.push("--claude-bin",e.claudeBin),e.freshThread&&P.push("--fresh-thread"),o&&P.push("--claude-session-uuid",o);let x=V(A,P,{detached:!0,stdio:"ignore",env:{...process.env,SOOTSIM_USER_DATA_DIR:h()}});x.unref();let E=e.readyTimeoutMs??6e3,b=await ae(d,p=>p.type==="ready"||p.type==="error",E);if(!b||b.type==="error"){if(x.pid)try{process.kill(x.pid,"SIGTERM")}catch{}try{i.rmSync(j(s.id),{recursive:!0,force:!0})}catch{}v(s.id,{status:"ended"});let p=b&&b.type==="error"?b.message:`no ready event within ${E}ms`;throw new l("WRAPPER_FAILED",p)}return v(s.id,{wrapperPid:x.pid,status:"idle"}),{session:k(s.id),wrapperPid:x.pid}})}async function De(e,t){let r=k(e);if(!r)throw new l("NO_SESSION",`no session with id=${e}`);if(!O(r.wrapperPid,e))throw v(e,{status:"ended"}),new l("NOT_ALIVE",`session wrapper is not alive (pid=${r.wrapperPid}). start a new session.`);let n=W(e);if(!i.existsSync(n))throw new l("NO_FIFO",`prompt FIFO missing: ${n}`);let o=i.openSync(n,f.O_WRONLY);try{let s=R(t);if(!s)throw new l("EMPTY_PROMPT","prompt text is empty");i.writeSync(o,s+`
|
|
3
3
|
`)}finally{i.closeSync(o)}v(e,{lastPrompt:t.displayText??t.text,status:"working"})}async function Re(e){let t=k(e);if(!t)throw new l("NO_SESSION",`no session with id=${e}`);if(O(t.wrapperPid,e))try{process.kill(t.wrapperPid,"SIGTERM")}catch{}let r=j(e),n=h();if(r.startsWith(n))try{i.rmSync(r,{recursive:!0,force:!0})}catch{}v(e,{status:"ended",wrapperPid:void 0})}function Ne(e,t){let r=J(e);if(!i.existsSync(r))throw new l("NO_FIFO",`events FIFO missing: ${r}`);let n=i.openSync(r,f.O_RDWR),o=i.createReadStream("",{fd:n,autoClose:!0}),s=ee.createInterface({input:o,crlfDelay:1/0});s.on("line",d=>{let c=I(d);c&&t(c)});let a=!1;return()=>{if(!a){a=!0;try{s.close()}catch{}try{o.destroy()}catch{}}}}async function ae(e,t,r){let n=i.openSync(e,f.O_RDWR|f.O_NONBLOCK),o=Buffer.alloc(8192),s="",a=Date.now()+r;try{for(;Date.now()<a;){let d=0;try{d=i.readSync(n,o,0,o.length,null)}catch(c){if(c.code!=="EAGAIN")throw c;d=0}if(d>0){s+=o.subarray(0,d).toString("utf8");let c;for(;(c=s.indexOf(`
|
|
4
4
|
`))>=0;){let g=s.slice(0,c);s=s.slice(c+1);let A=I(g);if(A&&t(A))return A}}else await new Promise(c=>setTimeout(c,30))}return null}finally{i.closeSync(n)}}export{I as a,h as b,ge as c,F as d,ye as e,he as f,Se as g,we as h,k as i,C as j,v as k,ve as l,j as m,W as n,J as o,te as p,O as q,re as r,l as s,Te as t,De as u,Re as v,Ne as w};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var i="sootsimConfig";function e(n){return!!n&&Object.keys(n).length>0}function s(n){return n?e(n.modules)||e(n.turboModules)||e(n.nativeModules)||e(n.env)||e(n.settings)||e(n.initialState):!1}function u(n,o){let t=new URL(n);return s(o)?t.searchParams.set(i,JSON.stringify(o)):t.searchParams.delete(i),t.toString()}var g="/index.bundle?platform=ios&dev=true&hot=true&minify=false";function r(n){return/^https?:\/\//i.test(n)}function a(n){return n.endsWith(".bundle")}function l(n){try{let o=r(n),t=new URL(n,"http://soot.local");return t.pathname=t.pathname.replace(/\.\.bundle$/,".bundle"),a(t.pathname)?(t.searchParams.delete("transform.bytecode"),o?t.toString():`${t.pathname}${t.search}${t.hash}`):n}catch{return n}}export{u as a,g as b,l as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{v as p}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{v as p}from"./chunk-GB3G5LVB.js";import{d as u,h as m,i as w}from"./chunk-6PLNIOJP.js";var y={timeoutMs:1800,settleMs:48,startWindowMs:64};function c(e){return new Promise(t=>setTimeout(t,e))}function h(e){return e.includes("--json")}function S(e){process.stdout.write(`${JSON.stringify(e??null,null,2)}
|
|
3
3
|
`)}async function g(e,t,...r){return m(e,`__sootsimTest.${t}`,...r)}async function f(e,t,...r){return w(e,`SootSim.bridges.mainShell.${t}`,...r)}async function T(e,t={}){try{let r=await g(e,"waitForScreenTransitions",y);if(!t.verbose||!r?.started)return;if(r.timedOut){console.log(` screen transition still active after ${r.waitedMs}ms; continuing`);return}r.waitedMs>0&&console.log(` waited ${r.waitedMs}ms for screen transition settle`)}catch{}}async function v(e,t,r,...n){let o=Date.now()+Math.max(0,r);for(;;)try{return await f(e,t,...n)}catch(s){if(!p(s)||Date.now()>=o)throw s;await c(50)}}async function x(e,t,r,n={}){let o=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<o;a++){let l=u(e,{commandTimeoutMs:t,simId:r});try{let d=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof d=="number"&&d>i)return{bridge:l,count:d}}catch{}l.close(),await c(s)}return null}async function _(e,t,r,n={}){let o=n.timeoutMs??8e3,s=n.intervalMs??250,i=Date.now()+o;for(;Date.now()<i;){let a=u(e,{commandTimeoutMs:t,simId:r});try{return await a.send({type:"evaluate",code:"1"}),a}catch{a.close()}await c(s)}return null}async function W(e,t={}){let r=t.timeoutMs??1e4,n=t.errorGraceMs??3e3,o=t.pollIntervalMs??200;return await e.send({type:"evaluate",code:`(async () => {
|
|
4
4
|
const start = Date.now()
|
|
5
5
|
const deadline = start + ${r}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var d=Object.defineProperty;var e=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var f=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0})};export{e as a,f as b};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as c,b as p}from"./chunk-7YZJHZ7X.js";import{a as m,c as h}from"./chunk-Q6DGMQ2V.js";import{a as l,b as u,c as d}from"./chunk-C4AMFYK3.js";function L(){let e=l();return e?{available:!0,reason:null,detail:e}:{available:!1,reason:"no chromium-family browser found (chrome, chromium, edge, brave, arc)"}}async function O(e){if(e.headless)return{launched:!1,message:"the chromium driver launches a visible browser window and cannot run headless \u2014 a headless `chrome --headless=new` process exits immediately and the sim never connects. for headless automation use `--driver playwright`."};let r=l();if(!r)return{launched:!1,message:"chromium not found \u2014 install chrome or run `sootsim list --drivers`"};if(!e.url)return{launched:!1,message:"chromium driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current Chrome profile"};try{let i=await d(e.url,{detached:e.detached??!0});return{launched:!0,message:`chromium launched \u2192 ${e.url}`,pid:i.pid,target:i.target??r,attachUrl:e.url}}catch(i){return{launched:!1,message:`chromium spawn failed: ${i instanceof Error?i.message:String(i)}`}}}var f={id:"chromium",name:"chromium",description:"system chrome / chromium / edge \u2014 visible window (headless: use playwright)",kind:"browser",availability:L,launch:O};function k(){let e=c();return e?{available:!0,reason:null,detail:`${e.kind} @ ${e.path}`}:{available:!1,reason:"sootsim desktop app not installed (run `sootsim install-desktop`)"}}async function x(e){let r=c();if(!r)return{launched:!1,message:"sootsim desktop app not installed"};try{let i=await p(e.url,r,{device:e.device,profileId:e.profileId,ephemeralProfile:e.ephemeralProfile});return i.launched?{launched:!0,message:e.url?`electron launched via ${i.via} \u2192 ${e.url}`:`electron launched via ${i.via}`,target:i.target,attachUrl:e.url}:{launched:!1,message:"desktop companion failed to start"}}catch(i){return{launched:!1,message:`electron launch failed: ${i instanceof Error?i.message:String(i)}`}}}var v={id:"electron",name:"electron",description:"sootsim desktop companion app (native window, menu bar)",kind:"native",availability:k,launch:x};import{spawn as I}from"child_process";import{closeSync as R,mkdtempSync as A,openSync as $,readFileSync as _,rmSync as U}from"fs";import{createRequire as T}from"module";import{tmpdir as g}from"os";import{join as w}from"path";var E=`
|
|
3
|
+
const modulePath = process.env.SOOTSIM_PW_MODULE;
|
|
4
|
+
const url = process.env.SOOTSIM_PW_URL;
|
|
5
|
+
const headless = process.env.SOOTSIM_PW_HEADLESS === '1';
|
|
6
|
+
const userDataDir = process.env.SOOTSIM_PW_USERDATADIR || '';
|
|
7
|
+
(async () => {
|
|
8
|
+
const pw = require(modulePath);
|
|
9
|
+
let browser = null;
|
|
10
|
+
let context;
|
|
11
|
+
// channel 'chromium' forces the FULL Chromium build. playwright's
|
|
12
|
+
// default \`headless: true\` launches the stripped "headless shell"
|
|
13
|
+
// binary, which omits Web Platform features sootsim debugging relies
|
|
14
|
+
// on (full WebGL / CanvasKit GPU readback in particular). the full
|
|
15
|
+
// build runs headless via Chrome's new headless mode at full feature
|
|
16
|
+
// parity. NOTE: this is NOT enough to make \`sootsim cpu-profile\`
|
|
17
|
+
// work \u2014 that profiles the tenant *worker*, and the JS Self-Profiler
|
|
18
|
+
// API cannot be constructed in a dedicated worker by any means (see
|
|
19
|
+
// worker-handlers/cpu-profile.ts). cpu-profile needs a CDP-based
|
|
20
|
+
// profiler instead.
|
|
21
|
+
const launchOpts = { headless, channel: 'chromium' };
|
|
22
|
+
if (userDataDir) {
|
|
23
|
+
context = await pw.chromium.launchPersistentContext(userDataDir, launchOpts);
|
|
24
|
+
} else {
|
|
25
|
+
browser = await pw.chromium.launch(launchOpts);
|
|
26
|
+
context = await browser.newContext();
|
|
27
|
+
}
|
|
28
|
+
const page = await context.newPage();
|
|
29
|
+
// surface page-side failures (engine boot crash, failed WS registration)
|
|
30
|
+
// to stderr so a sim that never connects produces a real diagnostic
|
|
31
|
+
// instead of a silent "timed out waiting for opened sim to connect".
|
|
32
|
+
page.on('pageerror', (e) => {
|
|
33
|
+
process.stderr.write('[pageerror] ' + ((e && e.stack) || e) + '\\n');
|
|
34
|
+
});
|
|
35
|
+
page.on('console', (m) => {
|
|
36
|
+
if (m.type() === 'error') {
|
|
37
|
+
process.stderr.write('[console.error] ' + m.text() + '\\n');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
page.on('crash', () => process.stderr.write('[page] renderer crashed\\n'));
|
|
41
|
+
try {
|
|
42
|
+
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
|
43
|
+
} catch (err) {
|
|
44
|
+
process.stderr.write('[goto] ' + String((err && err.message) || err) + '\\n');
|
|
45
|
+
}
|
|
46
|
+
const keepAlive = setInterval(() => {}, 1 << 30);
|
|
47
|
+
const shutdown = () => { clearInterval(keepAlive); process.exit(0); };
|
|
48
|
+
if (browser) browser.on('disconnected', shutdown);
|
|
49
|
+
context.on('close', shutdown);
|
|
50
|
+
page.on('close', () => { context.close().catch(() => {}); });
|
|
51
|
+
})().catch((err) => {
|
|
52
|
+
process.stderr.write(String((err && err.stack) || err) + '\\n');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
`;function y(){try{let e=T(process.cwd()+"/");for(let r of["playwright","playwright-chromium","playwright-core"])try{return{spec:r,modulePath:e.resolve(r)}}catch{}}catch{}return null}function W(){let e=y();return e?{available:!0,reason:null,detail:`resolved via ${e.spec}`}:{available:!1,reason:"playwright not installed in the current workspace"}}function C(e){return e.profileId?m(h(e.profileId).id):e.ephemeralProfile?A(w(g(),"sootsim-playwright-profile-")):""}async function M(e){let r=y();if(!r)return{launched:!1,message:"playwright not installed \u2014 run `bun add -D playwright` first"};if(!e.url)return{launched:!1,message:"playwright driver requires a target url"};let i=w(g(),`sootsim-playwright-host-${Date.now().toString(36)}-${process.pid}.log`),a=$(i,"a");try{let t=I(process.execPath,["-e",E],{detached:!0,stdio:["ignore","ignore",a],env:{...process.env,SOOTSIM_PW_MODULE:r.modulePath,SOOTSIM_PW_URL:e.url,SOOTSIM_PW_HEADLESS:e.headless??!0?"1":"0",SOOTSIM_PW_USERDATADIR:C(e)}});t.unref();let o=await new Promise(n=>{let S=setTimeout(()=>n(null),4e3);t.once("exit",P=>{clearTimeout(S),n(P??0)})});if(o!==null&&o!==0){let n=_(i,"utf8").trim();return U(i,{force:!0}),{launched:!1,message:`playwright host exited early (code ${o})${n?`: ${n.split(`
|
|
56
|
+
`).slice(-3).join(" ")}`:""}`}}return{launched:!0,message:`playwright chromium launched \u2192 ${e.url}`,pid:t.pid,target:r.spec,attachUrl:e.url}}catch(t){return{launched:!1,message:`playwright launch failed: ${t instanceof Error?t.message:String(t)}`}}finally{R(a)}}var D={id:"playwright",name:"playwright",description:"programmatic chromium via the playwright package \u2014 headless default",kind:"automation",availability:W,launch:M};function q(){return process.platform!=="darwin"&&process.platform!=="linux"&&process.platform!=="win32"?{available:!1,reason:`unsupported platform: ${process.platform}`}:{available:!0,reason:null,detail:process.platform==="darwin"?"open(1)":process.platform==="win32"?"cmd /c start":"xdg-open(1)"}}async function H(e){if(e.headless)return{launched:!1,message:"system driver does not support --headless; use chromium or playwright"};if(!e.url)return{launched:!1,message:"system driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current browser profile"};try{let r=await u(e.url,{detached:e.detached??!0,newWindow:e.newWindow});return{launched:!0,message:`${r.via} launch \u2192 ${e.url}`,pid:r.pid,target:r.target,attachUrl:e.url}}catch(r){return{launched:!1,message:`system launch failed: ${r instanceof Error?r.message:String(r)}`}}}var b={id:"system",name:"system",description:"shared browser launcher \u2014 system default or chromium window",kind:"delegate",availability:q,launch:H};var s=[f,v,D,b];function ae(){return s}function ne(e){return s.find(r=>r.id===e)??null}function se(e,r){if(e)return s.find(a=>a.id===e)??null;for(let i of r){let a=s.find(t=>t.id===i);if(a&&a.availability().available)return a}return null}function oe(){return s.map(e=>{let r=e.availability();return{id:e.id,name:e.name,kind:e.kind,description:e.description,available:r.available,reason:r.reason,detail:r.detail??null}})}export{f as a,v as b,D as c,b as d,s as e,ae as f,ne as g,se as h,oe as i};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as y,c as C}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as y,c as C}from"./chunk-LX6KS6TL.js";import{a as x}from"./chunk-FZB4W23Y.js";import{exec as U}from"child_process";import _ from"http";import D from"net";import{promisify as T}from"util";var P=T(U),E=250,A=1500,M=120;function R(e,r=M){return new Promise(s=>{let t=new D.Socket,o=!1,i=a=>{o||(o=!0,t.destroy(),s(a))};t.setTimeout(r),t.once("connect",()=>i(!0)),t.once("timeout",()=>i(!1)),t.once("error",()=>i(!1)),t.connect(e,"localhost")})}function h(e,r,s="GET",t=E,o={}){return new Promise(i=>{let a=_.request({hostname:"localhost",port:e,path:r,method:s,timeout:t,headers:o},n=>{let c="";n.on("data",l=>c+=l.toString());let u=(()=>{let l=n.headers["content-type"];if(typeof l=="string")return l;if(Array.isArray(l))return l[0]})();n.on("end",()=>i({statusCode:n.statusCode||0,body:c,contentType:u}))});a.on("error",()=>i(null)),a.setTimeout(t,()=>{a.destroy(),i(null)}),a.end()})}var N=[8081,8082,8083,8084,8085,8086,3e3,3001,19e3].map(e=>({port:e,pid:0}));function v(e,r){return!(e<=0||e>=2e4||r.has(e)||e>=5170&&e<=5200)}async function L(e=[]){let r=new Set(e);try{let{stdout:s}=await P("lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'",{encoding:"utf8",timeout:2e3});if(s.trim()){let t=new Map;for(let o of s.trim().split(`
|
|
3
3
|
`)){let i=o.trim().split(/\s+/);if(i.length<9)continue;let a=Number(i[1]),c=i[8].match(/:(\d+)$/);if(!c)continue;let u=Number(c[1]);v(u,r)&&(t.has(u)||t.set(u,a))}if(t.size>0)return[...t.entries()].map(([o,i])=>({port:o,pid:i}))}}catch{}try{let{stdout:s}=await P(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,{encoding:"utf8",timeout:2e3});if(s.trim()){let t=new Map;for(let o of s.trim().split(`
|
|
4
4
|
`)){let i=o.match(/:(\d+)\s/),a=o.match(/pid=(\d+)/);if(!i)continue;let n=Number(i[1]),c=a?Number(a[1]):0;v(n,r)&&(t.has(n)||t.set(n,c))}if(t.size>0)return[...t.entries()].map(([o,i])=>({port:o,pid:i}))}}catch{}return N.filter(s=>v(s.port,r))}var S=new Map;async function $(e){if(e<=0)return null;let r=S.get(e);if(r)return r;try{let{stdout:s}=await P(`lsof -p ${e} -a -d cwd -Fn 2>/dev/null`,{encoding:"utf8",timeout:1500});for(let t of s.split(`
|
|
5
5
|
`))if(t.startsWith("n")&&t.length>1){let o=t.slice(1).trim();if(o)return S.set(e,o),o}}catch{}return null}function I(e,r){return{port:e,framework:r,bundleUrl:m(e,`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()}}function m(e,r){let s=x.find(o=>o.preferredPort===e),t=s?.runtimeConfig?y(r,s.runtimeConfig):r;return C(t)}function O(e){return e.includes("/node_modules/one/metro-entry.bundle")}function j(e){try{let r=JSON.parse(e);return r&&typeof r=="object"?r:null}catch{return null}}function w(e,r,s){if(!r)return e;try{let t=JSON.parse(r.body),o=t?.extra?.expoClient||t?.extra||{};o.name&&(e.projectName=o.name),o.ios?.bundleIdentifier&&(e.bundleId=o.ios.bundleIdentifier),e.framework==="metro"&&o.sdkVersion&&(e.framework="expo");let i=t?.launchAsset?.url;i&&!e.patched&&!O(e.bundleUrl)&&(e.bundleUrl=m(e.port,i));let a=o.iconUrl||o.ios?.iconUrl||o.icon||o.ios?.icon;if(a)if(e.iconPath=a,s)if(a.startsWith("http"))e.iconUrl=s(a);else{let n=a.replace(/^\.\//,"");e.iconUrl=s(`http://localhost:${e.port}/assets/${n}`)}else e.iconUrl=a.startsWith("http")?a:`http://localhost:${e.port}/assets/${a.replace(/^\.\//,"")}`}catch{}return e}var d=new Set,f=new Set,b=new Set;async function H(e,r){if(!await R(e))return null;let s="/node_modules/one/metro-entry.bundle?platform=ios&dev=true",[t,o,i,a,n]=await Promise.all([d.has(e)?Promise.resolve(null):h(e,"/__soot/"),h(e,"/status"),h(e,s,"HEAD"),b.has(e)?Promise.resolve(null):h(e,"/","GET",A,{"expo-platform":"ios"}),f.has(e)?Promise.resolve(null):h(e,"/_expo/status")]);n&&n.statusCode===200?f.delete(e):f.has(e)||f.add(e);let c=a?j(a.body):null,u=typeof c?.launchAsset?.url=="string"?c.launchAsset.url:null,l=c?.extra?.expoClient||c?.extra||{};if(c&&(u||typeof l.name=="string")){d.add(e);let p=u||`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`,k=p.includes("/one/metro-entry.bundle")?"one":"expo";return w({port:e,framework:k,bundleUrl:m(e,p),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},a,r)}return i&&i.statusCode>0&&i.statusCode<400&&/application\/javascript/i.test(i.contentType||"")?(d.add(e),b.add(e),w({port:e,framework:"one",bundleUrl:m(e,`http://localhost:${e}${s}&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},a,r)):o&&o.body.includes("packager-status:running")?(d.add(e),w(I(e,n&&n.statusCode===200?"expo":"metro"),a,r)):t&&t.statusCode===200&&t.body.includes("sootsim-patched")?(d.delete(e),w({port:e,framework:"one",bundleUrl:m(e,`http://localhost:${e}/__soot/bundle.js`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now(),patched:!0},a,r)):(d.add(e),null)}function B(e){let r=e.projectName?.trim().toLowerCase();return!!(r==="soot"||r==="sootsim"||e.bundleId?.trim().toLowerCase()?.startsWith("dev.soot"))}var g=new Map,G=3e4,W=1500;function F(e){return!e||e.framework==="metro"||e.framework==="unknown"}function z(e){return e?m(e.port,e.bundleUrl)===e.bundleUrl:!0}function q(e,r,s=Date.now()){if(r===0||e.pid!==r||!z(e.result))return!1;let t=s-e.cachedAt;return!(e.result===null&&t>=G||F(e.result)&&t>=W)}async function ee(e={}){let r=await L(e.excludePorts),s=new Set(r.map(n=>n.port));for(let n of[...g.keys()])s.has(n)||g.delete(n);for(let n of[...d])s.has(n)||d.delete(n);for(let n of[...f])s.has(n)||f.delete(n);for(let n of[...b])s.has(n)||b.delete(n);let t=[],o=[];for(let{port:n,pid:c}of r){let u=g.get(n);if(u&&q(u,c)){u.result&&t.push(u.result);continue}u&&u.pid!==c&&(d.delete(n),f.delete(n),b.delete(n)),o.push({port:n,pid:c})}o.length>0&&(await Promise.all(o.map(c=>H(c.port,e.buildIconProxyUrl)))).forEach((c,u)=>{let{port:l,pid:p}=o[u];p!==0&&g.set(l,{pid:p,result:c,cachedAt:Date.now()}),c&&t.push(c)});let i=new Map;for(let{port:n,pid:c}of r)c>0&&i.set(n,c);await Promise.all(t.map(async n=>{let c=i.get(n.port);if(!c)return;n.pid=c;let u=await $(c);u&&(n.cwd=u)}));let a=new Set(i.values());for(let n of[...S.keys()])a.has(n)||S.delete(n);return t.filter(n=>!B(n))}export{ee as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as s}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as s}from"./chunk-S3SQITOO.js";import{w as o}from"./chunk-J3JJRXIP.js";function u(){let e=process.env.DO_NOT_TRACK;return e==="1"||e==="true"||!o()}function a(){if(u())return null;let e=process.env.SOOT_POSTHOG_API_KEY||process.env.VITE_POSTHOG_API_KEY||"";if(!e)return null;let t=process.env.SOOT_POSTHOG_HOST||process.env.VITE_POSTHOG_HOST||"https://us.i.posthog.com";return{apiKey:e,host:t.replace(/\/+$/,"")}}function c(e){return e?e.userId?e.userId:e.installationId!=null?`install:${e.installationId}`:e.repoId?`repo:${e.repoId}`:e.shareId?`share:${e.shareId}`:"anonymous-cli":"anonymous-cli"}function p(e){let t=e.identity??{},n={$lib:"soot-cli",source:t.source??"cli",...e.properties};return t.userId&&(n.userId=t.userId),t.repoId&&(n.repoId=t.repoId),t.installationId!=null&&(n.installationId=String(t.installationId)),t.shareId&&(n.shareId=t.shareId),t.plan&&(n.plan=t.plan),{event:e.event,distinct_id:c(t),properties:n,timestamp:new Date().toISOString()}}var r=[],l=!1;async function i(){if(r.length===0)return;let e=a();if(!e){r.length=0;return}let t=r.splice(0,r.length).map(p);try{await fetch(`${e.host}/batch/`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({api_key:e.apiKey,batch:t}),signal:AbortSignal.timeout(2e3)})}catch{}}function d(){l||(l=!0,process.on("beforeExit",()=>{i()}),process.on("exit",()=>{i()}))}function h(e){if(u())return;d();let t=null;try{t=s()?.user?.id??null}catch{t=null}r.push({...e,identity:{source:"cli",userId:t,...e.identity}})}async function g(){await i()}export{h as a,g as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{A as R,C as w,i as p,r as S,t as O,y as v,z as f}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{A as R,C as w,i as p,r as S,t as O,y as v,z as f}from"./chunk-J3JJRXIP.js";import{spawn as I}from"child_process";import C from"crypto";import s from"fs";import l from"path";import{Readable as k}from"stream";import{pipeline as M}from"stream/promises";var N="https://sootbean.com",D="SOOTSIM_CDN_ORIGIN",E="SOOTSIM_RUNTIME_CHANNEL";function $(){try{let e=JSON.parse(s.readFileSync(O(),"utf8"));return e&&typeof e=="object"?e:{}}catch{return{}}}function d(e){let t=$();return(e||process.env[D]||t.cdnOrigin||N).replace(/\/+$/,"")}function x(e){let t=$();return e||process.env[E]||t.runtimeChannel||"stable"}function T(e){let t=new URL(`${d(e)}/runtimes/manifest.json`);return t.searchParams.set("t",String(Date.now())),t.toString()}function P(e,t){return`${d(t)}/runtimes/sootsim-runtime-${e}.tar.gz`}async function y(e){let t=T(e),r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`manifest fetch failed: ${r.status} ${r.statusText} (${t})`);return await r.json()}function U(e,t={}){let r=x(t.channel),n=t.version||e.channels[r]?.latest;if(!n)throw new Error(`no version specified and channel '${r}' has no latest entry in the manifest`);let i=e.versions[n];if(!i)throw new Error(`version ${n} not found in manifest; available: ${Object.keys(e.versions).slice(-10).join(", ")||"(none)"}`);return{version:n,channel:r,entry:i}}async function V(e={}){v();let t=d(e.cdnOrigin),r=await y(t),{version:n,channel:i,entry:o}=U(r,e),a=p(n),c=e.setActive!==!1;if(!e.force&&s.existsSync(l.join(a,"index.html")))return c&&R(n),{version:n,channel:i,cdnOrigin:t,runtimeDir:a,installed:!1,activated:c,manifest:r};let g=o.tarball||P(n,t),m=l.join(S(),`sootsim-runtime-${n}.tar.gz`);process.stderr.write(`sootsim: downloading runtime ${n}\u2026
|
|
3
3
|
`),await _(g,m),process.stderr.write(`sootsim: extracting runtime ${n}\u2026
|
|
4
4
|
`);let h=await j(m);if(h!==o.sha256)throw s.rmSync(m,{force:!0}),new Error(`sha256 mismatch for runtime ${n}: expected ${o.sha256}, actual ${h}`);let u=l.join(l.dirname(a),`.installing-${n}-${process.pid}`);s.rmSync(u,{recursive:!0,force:!0}),s.mkdirSync(u,{recursive:!0});try{if(await A(m,u),!s.existsSync(l.join(u,"index.html")))throw new Error(`extracted tarball for runtime ${n} is missing index.html`);s.rmSync(a,{recursive:!0,force:!0}),s.renameSync(u,a)}catch(b){throw s.rmSync(u,{recursive:!0,force:!0}),b}return c&&R(n),{version:n,channel:i,cdnOrigin:t,runtimeDir:a,installed:!0,activated:c,manifest:r}}async function q(e={}){v();let t=d(e.cdnOrigin),r=x(e.channel),n=await y(t),i=n.channels[r]?.latest;if(!i)return{checked:!0,updated:!1,reason:`channel '${r}' has no latest runtime`,activeVersion:f()};if(!n.versions[i])return{checked:!0,updated:!1,reason:`manifest is missing version ${i}`,activeVersion:f(),latestVersion:i};let a=f(),c=a?p(a):null,g=c?s.existsSync(l.join(c,"index.html")):!1;if(!(!a||!g||w(i,a)>0))return{checked:!0,updated:!1,reason:"active runtime is current",activeVersion:a,latestVersion:i};let h=await V({version:i,channel:r,cdnOrigin:t,setActive:!1});return{checked:!0,updated:!0,activeVersion:i,latestVersion:i,install:h}}async function B(e={}){let t=f();try{let r=await y(d(e.cdnOrigin)),n=x(e.channel),i=r.channels[n]?.latest??null,o=!!(i&&(!t||w(i,t)>0));return{active:t,latest:i,outdated:o}}catch{return{active:t,latest:null,outdated:!1}}}async function _(e,t){let r=await fetch(e);if(!r.ok||!r.body)throw new Error(`download failed: ${r.status} ${r.statusText} (${e})`);s.mkdirSync(l.dirname(t),{recursive:!0});let n=`${t}.partial`;try{await M(k.fromWeb(r.body),s.createWriteStream(n)),s.renameSync(n,t)}catch(i){try{s.unlinkSync(n)}catch{}throw i}}function j(e){return new Promise((t,r)=>{let n=C.createHash("sha256"),i=s.createReadStream(e);i.on("data",o=>n.update(o)),i.on("error",r),i.on("end",()=>t(n.digest("hex")))})}function A(e,t){return new Promise((r,n)=>{let i=I("tar",["-xzf",e,"-C",t],{stdio:["ignore","inherit","inherit"]});i.on("error",n),i.on("exit",o=>{o===0?r():n(new Error(`tar exited with code ${o}`))})})}export{N as a,D as b,E as c,d,x as e,T as f,P as g,y as h,U as i,V as j,q as k,B as l};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{l as P,n as a,y as m}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{l as P,n as a,y as m}from"./chunk-J3JJRXIP.js";import l from"fs";import c from"path";var s="default",S="profiles.json",i=1;function o(e){let r=e.trim();if(!r)throw new Error("profile id is required");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(r))throw new Error("profile ids must start with a letter or number and contain only letters, numbers, dot, dash, or underscore");if(r==="."||r==="..")throw new Error(`invalid profile id: ${r}`);return r}function d(){return c.join(a(),S)}function I(e){return`sootsim-profile-${o(e)}`}function h(e){return c.join(P(),"Partitions",I(e))}function A(e){return c.join(a(),"playwright",o(e))}function u(){try{let e=JSON.parse(l.readFileSync(d(),"utf8"));if(!e||e.version!==i)return{version:i,profiles:[]};let r=Array.isArray(e.profiles)?e.profiles.filter(t=>!!t&&typeof t.id=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string").map(t=>({id:o(t.id),createdAt:t.createdAt,updatedAt:t.updatedAt})):[];return{version:i,profiles:r}}catch{return{version:i,profiles:[]}}}function x(e){return[...e].sort((r,t)=>r.id===s?-1:t.id===s?1:r.id.localeCompare(t.id))}function p(e){if(e.profiles.some(t=>t.id===s))return{...e,profiles:x(e.profiles)};let r=new Date().toISOString();return{version:i,profiles:x([{id:s,createdAt:r,updatedAt:r},...e.profiles])}}function g(e){m();let r=p(e),t=`${d()}.tmp`;return l.writeFileSync(t,`${JSON.stringify(r,null,2)}
|
|
3
3
|
`,"utf8"),l.renameSync(t,d()),r}function y(){return g(u()).profiles}function E(e){let r=o(e);return y().find(t=>t.id===r)??null}function _(e=s){let r=o(e),t=E(r);return t||D(r)}function D(e){let r=o(e),t=p(u());if(t.profiles.some(w=>w.id===r))throw new Error(`profile already exists: ${r}`);let f=new Date().toISOString(),n={id:r,createdAt:f,updatedAt:f};return g({version:i,profiles:[...t.profiles,n]}),n}function F(e){let r=o(e);if(r===s)throw new Error("the default profile cannot be deleted; clear it instead");let t=p(u()),f=t.profiles.find(n=>n.id===r);if(!f)throw new Error(`profile not found: ${r}`);return g({version:i,profiles:t.profiles.filter(n=>n.id!==r)}),v(r),f}function v(e){let r=o(e);for(let t of[h(r),A(r)])try{l.rmSync(t,{recursive:!0,force:!0})}catch{}}export{A as a,y as b,_ as c,D as d,F as e,v as f};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{l as c}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{l as c}from"./chunk-J3JJRXIP.js";import{chmodSync as m,existsSync as g,mkdirSync as k,readFileSync as A,rmSync as i,writeFileSync as y}from"node:fs";import{dirname as l,join as D,resolve as p}from"node:path";var s=1,S="SOOTSIM_SHARED_AUTH_FILE",u="https://sootbean.com";function v(){let t=process.env[S];return t?.trim()?l(p(t)):c()}function a(){let t=process.env[S];return t?.trim()?p(t):D(v(),"desktop-auth.json")}function f(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.id!="string"||!e.id.trim()?null:{id:e.id.trim(),name:typeof e.name=="string"?e.name:void 0,email:typeof e.email=="string"?e.email:void 0,image:typeof e.image=="string"?e.image:void 0}}function w(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==s||typeof e.token!="string"||!e.token.trim())return null;let r=typeof e.origin=="string"&&e.origin.trim()?e.origin.trim():u,n=e.source==="cli"||e.source==="electron"||e.source==="browser"||e.source==="unknown"?e.source:"unknown",o=typeof e.updatedAt=="string"&&e.updatedAt?e.updatedAt:new Date().toISOString(),h=typeof e.validatedAt=="string"&&e.validatedAt?e.validatedAt:void 0;return{version:s,token:e.token.trim(),user:f(e.user),origin:r,source:n,updatedAt:o,validatedAt:h}}function O(){let t=a();if(!g(t))return null;try{let e=JSON.parse(A(t,"utf8")),r=w(e);return r||(i(t,{force:!0}),null)}catch{return i(t,{force:!0}),null}}function I(t){let e=a();k(l(e),{recursive:!0});let r={version:s,token:t.token.trim(),user:t.user?f(t.user):null,origin:t.origin?.trim()||u,source:t.source,updatedAt:t.updatedAt||new Date().toISOString(),validatedAt:t.validatedAt};y(e,JSON.stringify(r,null,2)+`
|
|
3
3
|
`);try{m(e,384)}catch{}return r}function d(){i(a(),{force:!0})}async function N(t){let e=O();if(!e?.token)return null;let r=t||e.origin||u;try{let n=await fetch(`${r.replace(/\/$/,"")}/api/auth/me`,{headers:{authorization:`Bearer ${e.token}`}});if(n.status===401)return d(),null;if(!n.ok)return e;let o=await n.json();return o.user?.id?I({token:e.token,user:o.user,origin:r,source:e.source,validatedAt:new Date().toISOString()}):(d(),null)}catch{return e}}export{O as a,I as b,d as c,N as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
function d(t){let e=t.displayUrl||t.url;return t.status!=null?`${t.method} ${e} -> ${t.status}${t.statusText?` ${t.statusText}`:""}`:t.error?`${t.method} ${e} -> ${t.error}`:`${t.method} ${e}`}async function u(t,e,...o){return t.send({type:"call",path:`__sootsimTest.${e}`,args:o})}async function g(t,e={}){let o=await t.send({type:"evaluate",code:"window.__sootsimConsole?.count?.() || { errors: 0, warnings: 0, total: 0 }"});if(!o||typeof o!="object")return;let n=Math.max(0,Number(o.errors)||0),s=Math.max(0,Number(o.warnings)||0);if(n===0&&s===0)return;let r=[];if(n>0&&r.push(`${n} console error${n===1?"":"s"}`),s>0&&r.push(`${s} console warning${s===1?"":"s"}`),console.log(`
|
|
3
3
|
console: ${r.join(", ")}`),e.errorsCommand&&console.log(` inspect: ${e.errorsCommand}`),s>0&&e.warningsCommand&&console.log(` inspect: ${e.warningsCommand}`),!e.includeTail||n===0)return;let i=await t.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors?.(5) || []"});if(!(!Array.isArray(i)||i.length===0)){console.log(`
|
|
4
4
|
recent console errors:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import{existsSync as C,mkdirSync as D,readFileSync as O,rmSync as s,writeFileSync as g}from"fs";import{tmpdir as P}from"os";import{dirname as R,join as A,resolve as x}from"path";import{execFileSync as a}from"child_process";import{readFileSync as I}from"fs";import{createRequire as S}from"module";var o=null;function u(r){o||(o=_());try{return o(r)}catch{return null}}function _(){let r=Number(process.env.PPID);if(Number.isFinite(r)&&r>1&&r!==process.ppid)return()=>r;if(process.platform==="linux")return y();if(process.platform==="darwin"){let n=E();return n||T()}return()=>null}function y(){return r=>{try{let n=I(`/proc/${r}/stat`,"utf8"),t=n.lastIndexOf(")");if(t<0)return null;let i=n.slice(t+1).trim().split(/\s+/),e=Number(i[1]);return Number.isFinite(e)&&e>0?e:null}catch{return null}}}var N=3,d=216,b=16;function E(){if(!process.versions?.bun)return null;try{let r=S(import.meta.url),{dlopen:n,FFIType:t}=r("bun:ffi"),i=n("/usr/lib/libproc.dylib",{proc_pidinfo:{args:[t.i32,t.i32,t.u64,t.ptr,t.i32],returns:t.i32}}),e=Buffer.alloc(d);return m=>{if(Number(i.symbols.proc_pidinfo(m,N,0n,e,d))<=0)return null;let p=e.readUInt32LE(b);return p>0?p:null}}catch{return null}}function T(){return r=>{try{let t=a("lsof",["-R","-p",String(r),"-d","cwd","-a"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(`
|
|
3
3
|
`)[1];if(!t)return null;let i=t.trim().split(/\s+/),e=Number(i[2]);return Number.isFinite(e)&&e>1?e:null}catch{return null}}}var c=1,f="SOOTSIM_CLI_CURRENT_SIM_PATH",v=["SOOTSIM_CLI_IDENTITY","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","TERM_SESSION_ID","ITERM_SESSION_ID","TMUX_PANE","STY","KITTY_WINDOW_ID","WEZTERM_PANE","ALACRITTY_WINDOW_ID","WINDOWID","VSCODE_INJECTION"];function F(r,n=20){let t=u(r);if(!t||t<=1)return null;for(let i=0;i<n;i++){let e=u(t);if(!e||e<=1)return t;t=e}return t}function k(){for(let n of v){let t=process.env[n];if(t&&t.trim())return{key:`${n}:${t.trim()}`,source:n,stable:!0}}let r=F(process.ppid);return r&&r>1?{key:`gppid-${r}`,source:"grand-ppid",stable:!0}:{key:`pid-${process.ppid}`,source:"ppid",stable:!1}}function L(){return k().key}function l(){if(process.env[f])return x(process.env[f]);let r=L();return A(P(),`sootsim-current-sim-${r}.json`)}function h(){let r=l();if(!C(r))return null;try{let n=JSON.parse(O(r,"utf8"));return n.version!==c||typeof n.simId!="string"||!n.simId.trim()||typeof n.updatedAt!="string"?(s(r,{force:!0}),null):{version:c,simId:n.simId.trim(),updatedAt:n.updatedAt}}catch{return s(r,{force:!0}),null}}function J(){return h()?.simId||null}function j(r){let n=r.trim();if(!n)return;let t=l();D(R(t),{recursive:!0}),g(t,JSON.stringify({version:c,simId:n,updatedAt:new Date().toISOString()},null,2)+`
|
|
4
4
|
`)}function K(){s(l(),{force:!0})}export{k as a,L as b,J as c,j as d,K as e};
|