sootsim 0.1.194 → 0.1.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cli/bin.js +3 -3
- package/dist-cli/chunks/{agent-CM42FXZ2.js → agent-7VV2YS5K.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-RTNUXAUA.js → agent-wrapper-HEZELILJ.js} +2 -2
- package/dist-cli/chunks/{app-fonts-GRO4JNA7.js → app-fonts-CTFO7N3A.js} +2 -2
- package/dist-cli/chunks/{assert-KOOROQJI.js → assert-QCFTPXWT.js} +2 -2
- package/dist-cli/chunks/{auth-ASS7OY74.js → auth-5PL2DUSY.js} +2 -2
- package/dist-cli/chunks/beta-56TUG33G.js +2 -0
- package/dist-cli/chunks/{camera-LPPMHGJQ.js → camera-CDODMF26.js} +2 -2
- package/dist-cli/chunks/{chunk-63GQM7YC.js → chunk-3VDYVNXU.js} +2 -2
- package/dist-cli/chunks/{chunk-I7YBEJW2.js → chunk-4DBQ7YGH.js} +2 -2
- package/dist-cli/chunks/{chunk-HSC4YJX7.js → chunk-4FPIEYJQ.js} +2 -2
- package/dist-cli/chunks/{chunk-SIQUJOVP.js → chunk-64S5TQC3.js} +2 -2
- package/dist-cli/chunks/{chunk-RM4Q4CME.js → chunk-6B5ZSUG4.js} +4 -4
- package/dist-cli/chunks/{chunk-6RARYOEL.js → chunk-6S6Z5BWE.js} +2 -2
- package/dist-cli/chunks/chunk-7DESH3Y6.js +119 -0
- package/dist-cli/chunks/{chunk-DZCTXHGC.js → chunk-BUWXWDBA.js} +2 -2
- package/dist-cli/chunks/{chunk-YFT6QNH3.js → chunk-DBFIJJQS.js} +1 -1
- package/dist-cli/chunks/{chunk-QWZBLVT4.js → chunk-DKELBKSC.js} +1 -1
- package/dist-cli/chunks/{chunk-JPWVEJEC.js → chunk-DNXN75YR.js} +1 -1
- package/dist-cli/chunks/{chunk-HU4ZXOLS.js → chunk-DSK5O7XJ.js} +1 -1
- package/dist-cli/chunks/{chunk-JOFQ67LV.js → chunk-FCQEJWWZ.js} +1 -1
- package/dist-cli/chunks/chunk-FL2VXRHB.js +567 -0
- package/dist-cli/chunks/{chunk-5WHIIC72.js → chunk-GRWR6D2G.js} +2 -2
- package/dist-cli/chunks/{chunk-FFR4USO5.js → chunk-GRZH3TNX.js} +2 -2
- package/dist-cli/chunks/{chunk-NBT3VVSY.js → chunk-HDENRNBX.js} +2 -2
- package/dist-cli/chunks/chunk-I4LN4LGH.js +1 -0
- package/dist-cli/chunks/{chunk-K5IZM7I5.js → chunk-IKUTXUNH.js} +1 -1
- package/dist-cli/chunks/{chunk-H6CPDHFG.js → chunk-JVNX623C.js} +3 -3
- package/dist-cli/chunks/{chunk-Z2VLPNTW.js → chunk-KPYISBO7.js} +1 -1
- package/dist-cli/chunks/{chunk-4YYFY5HM.js → chunk-L2PR5XCL.js} +1 -1
- package/dist-cli/chunks/{chunk-454SCBS7.js → chunk-LDQF2IQA.js} +2 -2
- package/dist-cli/chunks/{chunk-EKLBXHUK.js → chunk-LEQWAE5B.js} +1 -1
- package/dist-cli/chunks/{chunk-CGC6VL3E.js → chunk-MI473PXL.js} +1 -1
- package/dist-cli/chunks/{chunk-LCX3R5GU.js → chunk-MLP4W2JW.js} +2 -2
- package/dist-cli/chunks/{chunk-P5VG36UG.js → chunk-O44TU6LO.js} +2 -2
- package/dist-cli/chunks/{chunk-NZCCIUPD.js → chunk-OA6H52UT.js} +2 -2
- package/dist-cli/chunks/chunk-OZTROCAR.js +92 -0
- package/dist-cli/chunks/{chunk-YZD3FUOU.js → chunk-P4AAS73X.js} +2 -2
- package/dist-cli/chunks/{chunk-IKNJYCUF.js → chunk-RTWIWFA6.js} +1 -1
- package/dist-cli/chunks/{chunk-TC34NFOE.js → chunk-SFRIHAPF.js} +1 -1
- package/dist-cli/chunks/{chunk-EZCGWPX4.js → chunk-SOUGUL4Y.js} +1 -1
- package/dist-cli/chunks/{chunk-JVJJWIDH.js → chunk-SZ6GB3RE.js} +3 -3
- package/dist-cli/chunks/{chunk-IXLWH3XE.js → chunk-T7YVS2SC.js} +4 -4
- package/dist-cli/chunks/{chunk-7CNBR64U.js → chunk-U5K2QCYY.js} +1 -1
- package/dist-cli/chunks/{chunk-V4U35I2X.js → chunk-VP5STTLY.js} +2 -2
- package/dist-cli/chunks/chunk-WEWPXSFB.js +1 -0
- package/dist-cli/chunks/{chunk-LDWXDKXP.js → chunk-WZNDVTK5.js} +1 -1
- package/dist-cli/chunks/{chunk-CQPAW4BG.js → chunk-XW6N7M6O.js} +2 -2
- package/dist-cli/chunks/{chunk-PIK54AHY.js → chunk-ZPSX53VU.js} +2 -2
- package/dist-cli/chunks/cli-version-GSRVHYD2.js +2 -0
- package/dist-cli/chunks/{compat-7T7W3OC2.js → compat-7DNTENZC.js} +3 -3
- package/dist-cli/chunks/{config-UMBFP5RC.js → config-OKXVJMWL.js} +2 -2
- package/dist-cli/chunks/{control-IC2NOIT3.js → control-ZK62SB6E.js} +2 -2
- package/dist-cli/chunks/daemon-L3GLGV2C.js +2 -0
- package/dist-cli/chunks/{debug-GTIWLJJM.js → debug-DSN6URLQ.js} +3 -3
- package/dist-cli/chunks/{desktop-3P4KTBZ6.js → desktop-H6V3QBVQ.js} +3 -3
- package/dist-cli/chunks/{detox-HCQMS3NM.js → detox-NQKPGIDN.js} +2 -2
- package/dist-cli/chunks/{device-7FBDA6PX.js → device-LWGRBUSC.js} +2 -2
- package/dist-cli/chunks/{diagnose-PETKX4PH.js → diagnose-C2WITABK.js} +2 -2
- package/dist-cli/chunks/drivers-E5YNBAEJ.js +2 -0
- package/dist-cli/chunks/flow-EB2IAY7O.js +2 -0
- package/dist-cli/chunks/help-LGJMWZ3D.js +2 -0
- package/dist-cli/chunks/{home-paths-WB64RMAZ.js → home-paths-K225NTYF.js} +2 -2
- package/dist-cli/chunks/inspect-KM2FF6CB.js +2 -0
- package/dist-cli/chunks/install-desktop-2BC7NTGT.js +2 -0
- package/dist-cli/chunks/{login-M2GVH7KT.js → login-COKO7POR.js} +4 -4
- package/dist-cli/chunks/{logout-52H5QYAR.js → logout-5S2FPEMI.js} +2 -2
- package/dist-cli/chunks/{maestro-G7YGMCVS.js → maestro-PEOFOZLJ.js} +2 -2
- package/dist-cli/chunks/mode-OSOIV7X5.js +95 -0
- package/dist-cli/chunks/optional-demo-registry-N7PJSAG7.js +2 -0
- package/dist-cli/chunks/{perf-5QN2GXUG.js → perf-E6E46PSB.js} +2 -2
- package/dist-cli/chunks/{record-LNYLU7SU.js → record-WGT4NYDD.js} +3 -3
- package/dist-cli/chunks/runtime-VP2R27QI.js +2 -0
- package/dist-cli/chunks/{screenshot-command-A5U6EWBL.js → screenshot-command-IVWNLSH7.js} +3 -3
- package/dist-cli/chunks/{serve-B3H4W7FQ.js → serve-WYMZH2OM.js} +2 -2
- package/dist-cli/chunks/{setup-P27VDHJN.js → setup-7NINUVSO.js} +3 -3
- package/dist-cli/chunks/{skills-VYXXJXES.js → skills-VSG2L2D5.js} +2 -2
- package/dist-cli/chunks/{storage-5RS7F336.js → storage-YTGOWC6P.js} +2 -2
- package/dist-cli/chunks/store-YSH3Y7TU.js +2 -0
- package/dist-cli/chunks/telemetry-HSELJJF7.js +2 -0
- package/dist-cli/chunks/{test-2NPQK3UG.js → test-BNI37OJN.js} +5 -5
- package/dist-cli/chunks/{timeline-NTNC5Q3Z.js → timeline-5HATH52U.js} +2 -2
- package/dist-cli/chunks/{upgrade-MS6NV4ZZ.js → upgrade-CZ4IDZPJ.js} +2 -2
- package/dist-cli/chunks/upload-SCPAVRE5.js +2 -0
- package/dist-cli/chunks/{version-NJWSIVF7.js → version-6IFPJNN5.js} +2 -2
- package/dist-cli/chunks/{web-7UB25AI6.js → web-WVJWPFIA.js} +2 -2
- package/dist-cli/chunks/{what-happened-YY6QNNFX.js → what-happened-J6XI43BG.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.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/beta.cjs +1 -1
- package/dist-lib/beta.mjs +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/detox/index.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 +1 -1
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +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/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +3 -1
- package/dist-lib/sdk.mjs +3 -1
- package/dist-lib/skills.cjs +129 -13
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/beta-G6FAR5KL.js +0 -2
- package/dist-cli/chunks/chunk-DJSMPGAY.js +0 -1
- package/dist-cli/chunks/chunk-JQYDRLG5.js +0 -1
- package/dist-cli/chunks/chunk-NQCAVMZZ.js +0 -87
- package/dist-cli/chunks/chunk-ZKV5SZCW.js +0 -119
- package/dist-cli/chunks/chunk-ZXTNCFPG.js +0 -565
- package/dist-cli/chunks/cli-version-L74S57R3.js +0 -2
- package/dist-cli/chunks/daemon-PCQPUR6K.js +0 -2
- package/dist-cli/chunks/drivers-LY2JUEY7.js +0 -2
- package/dist-cli/chunks/flow-7DF6U3ID.js +0 -2
- package/dist-cli/chunks/help-PXW7E7CP.js +0 -2
- package/dist-cli/chunks/inspect-65JGU7SX.js +0 -2
- package/dist-cli/chunks/install-desktop-G4BHZ4HW.js +0 -2
- package/dist-cli/chunks/mode-SZKIDZVN.js +0 -99
- package/dist-cli/chunks/optional-demo-registry-DUIJDZXH.js +0 -2
- package/dist-cli/chunks/runtime-S74NISZH.js +0 -2
- package/dist-cli/chunks/store-VYO4FWD5.js +0 -2
- package/dist-cli/chunks/telemetry-BKSSASRW.js +0 -2
- package/dist-cli/chunks/upload-JUANX7G7.js +0 -2
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
/*! sootsim v0.1.196 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as pe,c as he,d as fe,e as qe,f as me,g as ge,h as ze,i as we,j as Ye}from"./chunk-T7YVS2SC.js";import{a as Ke}from"./chunk-LDQF2IQA.js";import{a as Ze}from"./chunk-P4AAS73X.js";import{a as Xe}from"./chunk-OZTROCAR.js";import{h as Ue,p as Ve,r as Je,v as Ge}from"./chunk-6S6Z5BWE.js";import{f as De}from"./chunk-4DBQ7YGH.js";import{a as _e}from"./chunk-DNXN75YR.js";import{h as ue,m as je}from"./chunk-BUWXWDBA.js";import{I as U,m as Be,n as Ce,o as Ne,p as Le}from"./chunk-6B5ZSUG4.js";import{g as ce,h as de,i as He}from"./chunk-4FPIEYJQ.js";import{a as We}from"./chunk-WZNDVTK5.js";import{a as Ae,b as ae}from"./chunk-O44TU6LO.js";import{d as le,e as Oe}from"./chunk-U5K2QCYY.js";import{g as Re,h as Me}from"./chunk-RTWIWFA6.js";import*as $ from"fs";import{tmpdir as re}from"os";import*as b from"path";import*as S from"fs";import*as y from"path";var gt=52,ye=18,be=42,Qe=96,Se=54,wt=1.5,yt="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",et=1;function bt(i){let e=Me(i),t=e.scale,r=!e.dynamicIsland&&e.homeIndicatorHeight===0&&e.cornerRadius===0,n=e.width,o=e.height,a=r?e.width+ye*2:e.width+32,s=r?e.height+be+Qe:e.height+32,l=9.5,p=et,h=a+l*2,g=s+et*2,F=l+(r?ye:16),m=r?be:16,k=r?gt:e.cornerRadius+16,_=[{side:"right",top:e.hardwareButtons.lock.top,height:e.hardwareButtons.lock.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.ringToggle.top,height:e.hardwareButtons.ringToggle.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeUp.top,height:e.hardwareButtons.volumeUp.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeDown.top,height:e.hardwareButtons.volumeDown.height,width:e.hardwareButtons.width}];return{model:i,renderScale:t,outerWidth:Math.round(h*t),outerHeight:Math.round(g*t),logicalOuterWidth:h,logicalOuterHeight:g,logicalFrameWidth:a,logicalFrameHeight:s,logicalFrameLeft:l,logicalFrameTop:p,logicalScreenWidth:n,logicalScreenHeight:o,logicalScreenLeft:F,logicalScreenTop:m,logicalScreenRadius:r?0:e.cornerRadius,logicalFrameRadius:k,frameBackground:r?"linear-gradient(180deg, #1b1c20 0%, #0f1012 42%, #050608 100%)":"#000000",frameOutline:r?"0 0 0 1px #1f2125":"0 0 0 1px #333",metallicRingShadow:r?null:yt,buttons:_,legacyHomeButton:r?{top:be+e.height+(Qe-Se)/2,left:e.width/2-Se/2+ye,size:Se,ring:wt}:null,showHomeIndicator:e.homeIndicatorHeight>0,logicalHomeIndicatorStripHeight:e.homeIndicatorHeight}}function St(i){let e=i.side==="right",t=e?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
|
|
3
|
+
<div
|
|
4
|
+
aria-hidden="true"
|
|
5
|
+
style="
|
|
6
|
+
position:absolute;
|
|
7
|
+
${e?`right:-${i.width}px;`:`left:-${i.width}px;`}
|
|
8
|
+
top:${i.top}px;
|
|
9
|
+
width:${i.width}px;
|
|
10
|
+
height:${i.height}px;
|
|
11
|
+
background-color:#212121;
|
|
12
|
+
border-top-left-radius:${e?0:1.5}px;
|
|
13
|
+
border-bottom-left-radius:${e?0:1.5}px;
|
|
14
|
+
border-top-right-radius:${e?1.5:0}px;
|
|
15
|
+
border-bottom-right-radius:${e?1.5:0}px;
|
|
16
|
+
box-shadow:
|
|
17
|
+
inset 0 0.5px 0 #616161,
|
|
18
|
+
inset 0 -0.5px 0 #3F3F3F,
|
|
19
|
+
${e?"inset -0.5px 0 0 #3F3F3F,":"inset 0.5px 0 0 #3F3F3F,"}
|
|
20
|
+
0 0 0 0.5px #676767,
|
|
21
|
+
0 0 0 1.5px #000;
|
|
22
|
+
clip-path:${t};
|
|
23
|
+
pointer-events:none;
|
|
24
|
+
z-index:2;
|
|
25
|
+
"
|
|
26
|
+
></div>
|
|
27
|
+
`}function vt(i,e){let t=i.buttons.map(St).join(""),r=i.metallicRingShadow?`
|
|
28
|
+
<div
|
|
29
|
+
aria-hidden="true"
|
|
30
|
+
style="
|
|
31
|
+
position:absolute;
|
|
32
|
+
inset:0;
|
|
33
|
+
border-radius:${i.logicalFrameRadius}px;
|
|
34
|
+
box-shadow:${i.metallicRingShadow};
|
|
35
|
+
pointer-events:none;
|
|
36
|
+
z-index:10;
|
|
37
|
+
"
|
|
38
|
+
></div>
|
|
39
|
+
`:"",n=i.legacyHomeButton?`
|
|
40
|
+
<div
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
style="
|
|
43
|
+
position:absolute;
|
|
44
|
+
top:${i.legacyHomeButton.top}px;
|
|
45
|
+
left:${i.legacyHomeButton.left}px;
|
|
46
|
+
width:${i.legacyHomeButton.size}px;
|
|
47
|
+
height:${i.legacyHomeButton.size}px;
|
|
48
|
+
border-radius:50%;
|
|
49
|
+
background:
|
|
50
|
+
radial-gradient(circle at 35% 32%, rgba(62,64,68,0.35) 0%, rgba(17,18,20,0.98) 72%, rgba(8,9,11,1) 100%);
|
|
51
|
+
box-shadow:
|
|
52
|
+
inset 0 0 0 1px rgba(255,255,255,0.06),
|
|
53
|
+
inset 0 0 0 ${i.legacyHomeButton.ring}px rgba(184,192,204,0.45),
|
|
54
|
+
0 0 0 1px rgba(0,0,0,0.5);
|
|
55
|
+
z-index:3;
|
|
56
|
+
pointer-events:none;
|
|
57
|
+
display:flex;
|
|
58
|
+
align-items:center;
|
|
59
|
+
justify-content:center;
|
|
60
|
+
"
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
style="
|
|
64
|
+
width:16px;
|
|
65
|
+
height:16px;
|
|
66
|
+
border-radius:4px;
|
|
67
|
+
box-shadow:inset 0 0 0 1.5px rgba(188,194,202,0.5);
|
|
68
|
+
"
|
|
69
|
+
></div>
|
|
70
|
+
</div>
|
|
71
|
+
`:"",o=i.showHomeIndicator?`
|
|
72
|
+
<div
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
style="
|
|
75
|
+
position:absolute;
|
|
76
|
+
left:0;
|
|
77
|
+
right:0;
|
|
78
|
+
bottom:4px;
|
|
79
|
+
height:${i.logicalHomeIndicatorStripHeight}px;
|
|
80
|
+
display:flex;
|
|
81
|
+
align-items:center;
|
|
82
|
+
justify-content:center;
|
|
83
|
+
pointer-events:none;
|
|
84
|
+
z-index:10;
|
|
85
|
+
"
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
style="
|
|
89
|
+
width:134px;
|
|
90
|
+
height:5px;
|
|
91
|
+
border-radius:2.5px;
|
|
92
|
+
background-color:rgb(150, 150, 150);
|
|
93
|
+
opacity:0.5;
|
|
94
|
+
"
|
|
95
|
+
></div>
|
|
96
|
+
</div>
|
|
97
|
+
`:"";return`<!doctype html>
|
|
98
|
+
<html>
|
|
99
|
+
<head>
|
|
100
|
+
<meta charset="utf-8" />
|
|
101
|
+
<style>
|
|
102
|
+
html, body {
|
|
103
|
+
margin: 0;
|
|
104
|
+
width: ${i.outerWidth}px;
|
|
105
|
+
height: ${i.outerHeight}px;
|
|
106
|
+
background: transparent;
|
|
107
|
+
}
|
|
108
|
+
body {
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
}
|
|
111
|
+
img {
|
|
112
|
+
display: block;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
}
|
|
116
|
+
</style>
|
|
117
|
+
</head>
|
|
118
|
+
<body>
|
|
119
|
+
<div
|
|
120
|
+
id="frame-export-root"
|
|
121
|
+
style="
|
|
122
|
+
position:relative;
|
|
123
|
+
width:${i.outerWidth}px;
|
|
124
|
+
height:${i.outerHeight}px;
|
|
125
|
+
overflow:hidden;
|
|
126
|
+
background:transparent;
|
|
127
|
+
"
|
|
128
|
+
>
|
|
129
|
+
<div
|
|
130
|
+
id="frame-scale-layer"
|
|
131
|
+
style="
|
|
132
|
+
position:absolute;
|
|
133
|
+
top:0;
|
|
134
|
+
left:0;
|
|
135
|
+
width:${i.logicalOuterWidth}px;
|
|
136
|
+
height:${i.logicalOuterHeight}px;
|
|
137
|
+
transform:scale(${i.renderScale});
|
|
138
|
+
transform-origin:top left;
|
|
139
|
+
overflow:visible;
|
|
140
|
+
"
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
id="frame"
|
|
144
|
+
style="
|
|
145
|
+
position:absolute;
|
|
146
|
+
top:${i.logicalFrameTop}px;
|
|
147
|
+
left:${i.logicalFrameLeft}px;
|
|
148
|
+
width:${i.logicalFrameWidth}px;
|
|
149
|
+
height:${i.logicalFrameHeight}px;
|
|
150
|
+
border-radius:${i.logicalFrameRadius}px;
|
|
151
|
+
box-sizing:border-box;
|
|
152
|
+
overflow:visible;
|
|
153
|
+
background:${i.frameBackground};
|
|
154
|
+
box-shadow:${i.frameOutline};
|
|
155
|
+
"
|
|
156
|
+
>
|
|
157
|
+
${t}
|
|
158
|
+
${r}
|
|
159
|
+
${n}
|
|
160
|
+
<div
|
|
161
|
+
id="screen"
|
|
162
|
+
style="
|
|
163
|
+
position:absolute;
|
|
164
|
+
top:${i.logicalScreenTop}px;
|
|
165
|
+
left:${i.logicalScreenLeft-i.logicalFrameLeft}px;
|
|
166
|
+
width:${i.logicalScreenWidth}px;
|
|
167
|
+
height:${i.logicalScreenHeight}px;
|
|
168
|
+
border-radius:${i.logicalScreenRadius}px;
|
|
169
|
+
overflow:hidden;
|
|
170
|
+
background:#000;
|
|
171
|
+
"
|
|
172
|
+
>
|
|
173
|
+
<img src="${e}" alt="" />
|
|
174
|
+
${o}
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</body>
|
|
180
|
+
</html>`}async function tt(i,e){let{chromium:t}=await import("playwright"),r=await t.launch({headless:!0});try{let n=await xt(r);try{return await n.compose(i,e)}finally{await n.close()}}finally{await r.close()}}async function xt(i){let e=new Map;async function t(r){let n=e.get(r);if(n)return n;let o=bt(r),a=await i.newContext({viewport:{width:o.outerWidth,height:o.outerHeight},deviceScaleFactor:1}),s=await a.newPage(),l={layout:o,context:a,page:s};return e.set(r,l),l}return{async compose(r,n){let o=await t(n),a=`data:image/png;base64,${r.toString("base64")}`;return await o.page.setContent(vt(o.layout,a),{waitUntil:"load"}),await o.page.waitForTimeout(20),await o.page.screenshot({type:"png",clip:{x:0,y:0,width:o.layout.outerWidth,height:o.layout.outerHeight},omitBackground:!0})},async close(){for(let r of e.values())await r.context.close();e.clear()}}}import{spawnSync as Tt}from"child_process";import*as N from"vm";var Ft=3e5,Et=`
|
|
181
|
+
let input = '';
|
|
182
|
+
process.stdin.on('data', (c) => { input += c });
|
|
183
|
+
process.stdin.on('end', async () => {
|
|
184
|
+
try {
|
|
185
|
+
const req = JSON.parse(input);
|
|
186
|
+
const res = await fetch(req.url, {
|
|
187
|
+
method: req.method,
|
|
188
|
+
headers: req.headers,
|
|
189
|
+
body: req.body === undefined || req.body === null ? undefined : req.body,
|
|
190
|
+
});
|
|
191
|
+
const body = await res.text();
|
|
192
|
+
const headers = {};
|
|
193
|
+
for (const [k, v] of res.headers.entries()) {
|
|
194
|
+
headers[k] = headers[k] ? headers[k] + ',' + v : v;
|
|
195
|
+
}
|
|
196
|
+
process.stdout.write(JSON.stringify({ ok: res.ok, status: res.status, body, headers }));
|
|
197
|
+
} catch (err) {
|
|
198
|
+
process.stdout.write(JSON.stringify({ __error: (err && err.message) || String(err) }));
|
|
199
|
+
process.exitCode = 1;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
`;function J(i,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by sootsim yet");let r={...process.env};for(let s of Object.keys(r))(s.startsWith("BUN_INSPECT")||s==="NODE_OPTIONS")&&delete r[s];let n=Tt(process.execPath,["-e",Et],{input:JSON.stringify({url:i,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:Ft,maxBuffer:64*1024*1024,env:r});if(n.error)throw new Error(`http ${e} ${i} failed: ${n.error.message}`);let o;try{o=JSON.parse(n.stdout||"")}catch{throw new Error(`http ${e} ${i} failed: no response (${(n.stderr||"").trim().slice(0,200)})`)}let a=o;if(a.__error)throw new Error(`http ${e} ${i} failed: ${a.__error}`);return a}var It=/(?<!\\)\$\{([^$]*)\}/g,$t=/\\(\$\{[^$]*\})/g,kt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,X=class{context;envBinding=new Map;envScopeStack=[];syncedEnvKeys=new Set;output={};maestro;constructor(e={}){this.maestro={copiedText:null,platform:e.platform??"ios"};let t=e.onLog??(n=>console.log(`[flow] js: ${n}`)),r={output:this.output,maestro:this.maestro,http:{get:(n,o)=>J(n,"GET",o),post:(n,o)=>J(n,"POST",o),put:(n,o)=>J(n,"PUT",o),delete:(n,o)=>J(n,"DELETE",o),request:(n,o)=>J(n,(o?.method??"GET").toUpperCase(),o)},console:{log:(...n)=>t(n.map(o=>typeof o=="string"?o:rt(o)).join(" "))}};this.context=N.createContext(r),N.runInContext(`
|
|
203
|
+
globalThis.__maestroScope = new Proxy(globalThis, {
|
|
204
|
+
has() { return true },
|
|
205
|
+
get(target, key) { return target[key] },
|
|
206
|
+
})
|
|
207
|
+
function json(text) { return JSON.parse(text) }
|
|
208
|
+
function relativePoint(x, y) {
|
|
209
|
+
var xPercent = Math.ceil(x * 100) + '%'
|
|
210
|
+
var yPercent = Math.ceil(y * 100) + '%'
|
|
211
|
+
return xPercent + ',' + yPercent
|
|
212
|
+
}
|
|
213
|
+
`,this.context);for(let[n,o]of Object.entries(process.env))o!==void 0&&this.envBinding.set(n,o)}putEnv(e,t){this.envBinding.set(e,t)}setCopiedText(e){this.maestro.copiedText=e}enterEnvScope(){this.envScopeStack.push(new Map(this.envBinding))}leaveEnvScope(){let e=this.envScopeStack.pop();if(e){this.envBinding.clear();for(let[t,r]of e)this.envBinding.set(t,r)}}evaluate(e,t={}){let r=t.env;if(r&&Object.keys(r).length>0){this.enterEnvScope();try{for(let[n,o]of Object.entries(r))this.envBinding.set(n,o);return this.evalRaw(e)}finally{this.leaveEnvScope()}}return this.evalRaw(e)}evalRaw(e){this.syncEnvToContext();let t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${");return N.runInContext(`(function(){ with(__maestroScope){ return eval(\`${t}\`) } })()`,this.context)}syncEnvToContext(){let e=N.runInContext("globalThis",this.context);for(let t of this.syncedEnvKeys)this.envBinding.has(t)||delete e[t];this.syncedEnvKeys=new Set;for(let[t,r]of this.envBinding)try{e[t]=r,this.syncedEnvKeys.add(t)}catch{}}evaluateStringTemplate(e){return e.replace(It,(r,n)=>{if(n.trim().length===0)return"";let o=this.evaluate(n);if(o===void 0&&kt.test(n.trim()))throw new Error(`missing variable for flow placeholder: ${n.trim()}`);return rt(o)}).replace($t,(r,n)=>n)}interpolateStep(e){return this.interpolateValue(e,null)}interpolateValue(e,t){return typeof e=="string"?t==="evalScript"?e:this.evaluateStringTemplate(e):Array.isArray(e)?t==="commands"||t==="onFlowStart"||t==="onFlowComplete"?e:e.map(r=>this.interpolateValue(r,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,this.interpolateValue(n,r)])):e}};function rt(i){if(i===void 0)return"undefined";if(i===null)return"null";if(typeof i=="object")try{return JSON.stringify(i)}catch{return String(i)}return String(i)}function nt(i){if(i==null)return!1;if(typeof i=="boolean")return i;let e=String(i);if(e.trim().length===0||e.toLowerCase()==="false"||e==="undefined"||e==="null")return!1;let t=Number(e);return!(!Number.isNaN(t)&&t===0)}var Z=1e4,ee=393,L=852;function f(i){return new Promise(e=>setTimeout(e,i))}function ve(i){return!!(i&&typeof i=="object"&&!Array.isArray(i))}function G(i,e){if(!ve(i))return null;let t=i[e];return typeof t=="string"&&t.length>0?t:null}function Pt(i,e){return ve(i)?i[e]===!0:!1}function At(i){if(!i)return null;let e=i.recentApps;if(Array.isArray(e))for(let r of e){let n=G(r,"id");if(n)return n}let t=i.surfaceBindings;return G(t,"app:one")||G(t,"app:two")||null}function Rt(i){return i?y.basename(i)===".maestro"?y.dirname(i):i:process.cwd()}function Mt(i,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(y.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let n=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():Rt(t.flowDir);return y.resolve(n,r)}return y.join(i,r)}function Ot(i){if(typeof i=="string")return{path:i,withFrame:!1};let e=i.path?.trim()||i.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:i.withFrame===!0,layers:i.layers}}function Q(i,e){let[t,r]=i.split(",").map(s=>s.trim()),n=(s,l)=>s.endsWith("%")?Number.parseFloat(s)/100*l:Number.parseFloat(s),o=e?.x??0,a=e?.y??0;return{x:o+n(t,e?.width??ee),y:a+n(r,e?.height??L)}}function _t(i){switch(i){case"back":return{back:!0};case"hideKeyboard":return{hideKeyboard:!0};case"waitForAnimationToEnd":return{waitForAnimationToEnd:!0};case"stopApp":return{stopApp:!0};case"clearState":return{clearState:!0};case"clearKeychain":return{clearKeychain:!0};case"eraseText":return{eraseText:50};case"scroll":case"scrollDown":return{scroll:{direction:"DOWN"}};case"scrollUp":return{scroll:{direction:"UP"}};default:return{[i]:!0}}}function Dt(i){let e=i.split(/^---$/m),t=e.length>1?e[e.length-1]:i,r=Ke.parse(t);return Array.isArray(r)?r:[]}var te=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new X({platform:"ios",onLog:e=>console.log(`[flow] js: ${e}`)});firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingStartedAtMs=null;lastRecordingDurationMs=null;lastRecordingFrameStats=null;flowTraceSteps=[];lastVisualSettledAtMs=0;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(l=>l.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(l=>l.id===this.opts.simId&&l.readyState==="open")||!this.simRouteHint)return;let n=this.simRouteHint&&e.find(l=>l.readyState==="open"&&this.normalizeSimRoute(l.url||l.origin)===this.simRouteHint);if(!n)return;let o=e.find(l=>l.isPrimary&&l.readyState==="open"),a=e.find(l=>l.readyState==="open"),s=n??o??a;s&&(this.opts.simId=s.id,console.log(` [flow] sim rotated to ${s.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=Z){let t=Date.now()+e,r=Date.now(),n=null,o=0,a=0,s=-1,l=r;for(;Date.now()<t;){try{let h=await this.evaluate(Be,8e3);if(o=0,h?.externalError)throw new Error(`app failed to load: ${h.externalError}`);if(h){let g=Date.now();h.nodes!==s&&(s=h.nodes,l=g);let F=h.flag===!0&&Ne(h),m=h.flag!==!0&&Le(h);if((F||m)&&h.externalReady!==!1&&!h.externalError&&!h.loadingText&&g-l>=Ce)return}}catch(h){if(n=h instanceof Error?h:new Error(String(h)),n.message.startsWith("app failed to load:"))throw n;if(o++,o>=4)throw new Error(`target sim is not responding to the bridge (${n.message}). it is likely a stale orphan \u2014 run \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let p=Date.now()-r;p-a>=5e3&&(a=p,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(p/1e3)}s)`)),await f(500)}throw n?.message.startsWith("app failed to load:")?n:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(this.opts.requireRecordingEntitlement&&await Ze("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
|
|
214
|
+
const rec = window.__sootsimRecorder
|
|
215
|
+
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
216
|
+
const format = ${JSON.stringify(this.opts.recordingFormat??"webm")}
|
|
217
|
+
if (rec.state() === 'recording') return { ok: true, format }
|
|
218
|
+
return rec.start({ format, fps: 24 })
|
|
219
|
+
})()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=typeof t.startedAtMs=="number"&&Number.isFinite(t.startedAtMs)?t.startedAtMs:e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}getLastRecordingStartedAtMs(){return this.lastRecordingStartedAtMs}getLastRecordingFrameStats(){return this.lastRecordingFrameStats}getFlowTraceSteps(){return[...this.flowTraceSteps]}flowStepTargetLabel(e,t){if(t==="inputText"||t==="runScript"||t==="evalScript")return;let r=e[t];if(typeof r=="string")return r.slice(0,80);if(typeof r=="number"||typeof r=="boolean")return String(r);if(!r||typeof r!="object")return;let n=r,o=n.id??n.text??n.name??n.path;if(typeof o=="string"&&o)return o.slice(0,80);if(n.point&&typeof n.point=="string")return n.point.slice(0,80);if(typeof n.x=="number"&&typeof n.y=="number")return`${Math.round(n.x)}, ${Math.round(n.y)}`}recordFlowTraceStep(e){let t=Date.now(),r={stepIndex:e.stepIndex,stepName:e.stepName,...e.targetLabel?{targetLabel:e.targetLabel}:{},startedAtMs:e.startedAtMs,endedAtMs:t,durationMs:Math.max(0,t-e.startedAtMs),status:e.status};e.error!=null&&(r.error=e.error instanceof Error?e.error.message:String(e.error)),this.flowTraceSteps.push(r)}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1;let e=Date.now(),t=await this.evaluate("window.__sootsimRecorder.stop()");if(!t?.ok)throw this.recordingStartedAtMs=null,this.lastRecordingFrameStats=null,new Error(t?.error||"recording stop failed");this.lastRecordingStartedAtMs=this.recordingStartedAtMs,this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.lastRecordingFrameStats=t.frameStats??null,this.recordingStartedAtMs=null;let r=[],n=0;for(;;){let l=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${n}, chunk: 2097152 })`);if(!l||(r.push(Buffer.from(l.data,"base64")),n=l.offset,l.done))break}if(r.length===0)throw new Error("recording requested but no video buffer was produced");S.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let a=(t.mime||this.opts.recordingFormat||"video/webm").includes("mp4")?"mp4":"webm",s=y.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.${a}`);return S.writeFileSync(s,Buffer.concat(r)),s}async waitForRecordingTail(e){if(!this.recordingEnabled)return;let t=Math.max(0,Math.round(e.maxMs));if(t<=0)return;if(!e.smart){await f(t);return}let r=await we({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(r.settled?` [flow] recording tail settled in ${r.elapsed}ms`:` [flow] recording tail reached ${r.elapsed}ms budget`)}async findElement(e){if(e.childOf!=null||typeof e.index=="number")return this.findElementScoped(e);let t=!!e.text&&/[.*+?^$()[\]{}|\\]/.test(e.text);return this.evaluate(`(async () => {
|
|
220
|
+
const test = window.__sootsimTest
|
|
221
|
+
if (!test) return null
|
|
222
|
+
let node = null
|
|
223
|
+
if (${JSON.stringify(!!e.text)}) {
|
|
224
|
+
node = await test.findByText(${JSON.stringify(e.text||"")})
|
|
225
|
+
// maestro matches a text selector against the element's ACCESSIBILITY
|
|
226
|
+
// text too, not just rendered glyphs \u2014 icon-only buttons (e.g. bluesky's
|
|
227
|
+
// "Pin to Home" / "Mute accounts" pin/menu controls) carry the label on
|
|
228
|
+
// accessibilityLabel with no visible text node, so findByText misses
|
|
229
|
+
// them. fall back to an exact a11y-label match, mirroring the real
|
|
230
|
+
// driver. findByLabel resolves a node, but its info shape omits nodeId/
|
|
231
|
+
// isTextInput; re-resolve through findByTestId/findById when it exposes
|
|
232
|
+
// an id so tapOn still gets a resolveTapTarget-able nodeId.
|
|
233
|
+
if (!node) {
|
|
234
|
+
const labelled = await test.findByLabel?.(${JSON.stringify(e.text||"")})
|
|
235
|
+
if (labelled) {
|
|
236
|
+
const reId = labelled.testID || labelled.id
|
|
237
|
+
node =
|
|
238
|
+
(reId &&
|
|
239
|
+
((await test.findByTestId?.(reId)) || (await test.findById?.(reId)))) ||
|
|
240
|
+
labelled
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (!node && ${JSON.stringify(t)} && test.queryAll) {
|
|
244
|
+
// regex selector fallback: match the pattern against each visible
|
|
245
|
+
// node's text; prefer the narrowest matching node so a tight <text>
|
|
246
|
+
// wins over a wide container that merely contains it.
|
|
247
|
+
let re = null
|
|
248
|
+
try { re = new RegExp(${JSON.stringify(e.text||"")}) } catch (e) { re = null }
|
|
249
|
+
if (re) {
|
|
250
|
+
const all = (await test.queryAll({ pruneHidden: true })) || []
|
|
251
|
+
const hits = all.filter(
|
|
252
|
+
(n) =>
|
|
253
|
+
n && n.absolutePosition && n.layout &&
|
|
254
|
+
typeof n.text === 'string' && re.test(n.text),
|
|
255
|
+
)
|
|
256
|
+
hits.sort((a, b) => (a.text || '').length - (b.text || '').length)
|
|
257
|
+
if (hits[0]) node = hits[0]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (!node && ${JSON.stringify(!!e.id)}) {
|
|
262
|
+
node = (await test.findByTestId(${JSON.stringify(e.id||"")})) || (await test.findById(${JSON.stringify(e.id||"")}))
|
|
263
|
+
}
|
|
264
|
+
if (!node || !node.absolutePosition || !node.layout) return null
|
|
265
|
+
return {
|
|
266
|
+
nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
|
|
267
|
+
id: node.id || null,
|
|
268
|
+
testID: node.testID || null,
|
|
269
|
+
text: node.text || null,
|
|
270
|
+
absolutePosition: node.absolutePosition,
|
|
271
|
+
layout: node.layout,
|
|
272
|
+
isTextInput: !!node.isTextInput,
|
|
273
|
+
}
|
|
274
|
+
})()`)}async findElementScoped(e){let t=typeof e.index=="number"?e.index:0;return this.evaluate(`(async () => {
|
|
275
|
+
const test = window.__sootsimTest
|
|
276
|
+
if (!test || !test.queryAll) return null
|
|
277
|
+
// NOT pruneHidden: that over-filters (it dropped every postDropdownBtn in a
|
|
278
|
+
// feed and made index:0 resolve to nothing \u2014 worse than findByTestId). reach
|
|
279
|
+
// for the same set findByTestId sees, then PREFER on-screen ones below.
|
|
280
|
+
const filter = {}
|
|
281
|
+
if (${JSON.stringify(!!e.id)}) filter.hasId = ${JSON.stringify(e.id||"")}
|
|
282
|
+
if (${JSON.stringify(!!e.text)}) filter.hasText = ${JSON.stringify(e.text||"")}
|
|
283
|
+
let candidates = (await test.queryAll(filter)) || []
|
|
284
|
+
// a11y-label fallback (icon-only buttons) for text matchers, mirroring
|
|
285
|
+
// findElement's simple path.
|
|
286
|
+
if (${JSON.stringify(!!e.text)} && candidates.length === 0) {
|
|
287
|
+
const all = (await test.queryAll({})) || []
|
|
288
|
+
candidates = all.filter((n) => (n.accessibilityLabel || '') === ${JSON.stringify(e.text||"")})
|
|
289
|
+
}
|
|
290
|
+
candidates = candidates.filter((n) => n && n.absolutePosition && n.layout)
|
|
291
|
+
// prefer on-screen matches (findByTestId's visible-first behavior); only
|
|
292
|
+
// fall back to off-screen ones when nothing is on-screen, so index: still
|
|
293
|
+
// resolves a target that needs scrolling into view.
|
|
294
|
+
const onScreen = candidates.filter((n) => {
|
|
295
|
+
const cy = n.absolutePosition.y + n.layout.height / 2
|
|
296
|
+
return cy > 0 && cy < ${L}
|
|
297
|
+
})
|
|
298
|
+
if (onScreen.length > 0) candidates = onScreen
|
|
299
|
+
${e.childOf?`
|
|
300
|
+
const container = ${e.childOf.id?`(await test.findByTestId(${JSON.stringify(e.childOf.id)})) || (await test.findById(${JSON.stringify(e.childOf.id)}))`:`await test.findByText(${JSON.stringify(e.childOf.text||"")})`}
|
|
301
|
+
if (!container || !container.absolutePosition || !container.layout) return null
|
|
302
|
+
const x0 = container.absolutePosition.x
|
|
303
|
+
const y0 = container.absolutePosition.y
|
|
304
|
+
const x1 = x0 + container.layout.width
|
|
305
|
+
const y1 = y0 + container.layout.height
|
|
306
|
+
candidates = candidates.filter((n) => {
|
|
307
|
+
const cx = n.absolutePosition.x + n.layout.width / 2
|
|
308
|
+
const cy = n.absolutePosition.y + n.layout.height / 2
|
|
309
|
+
return cx >= x0 && cx <= x1 && cy >= y0 && cy <= y1
|
|
310
|
+
})`:""}
|
|
311
|
+
const node = candidates[${t}]
|
|
312
|
+
if (!node) return null
|
|
313
|
+
return {
|
|
314
|
+
nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
|
|
315
|
+
id: node.id || null,
|
|
316
|
+
testID: node.testID || null,
|
|
317
|
+
text: node.text || null,
|
|
318
|
+
absolutePosition: node.absolutePosition,
|
|
319
|
+
layout: node.layout,
|
|
320
|
+
isTextInput: !!node.isTextInput,
|
|
321
|
+
}
|
|
322
|
+
})()`)}async resolveTapTarget(e){return this.evaluate(`(async () => {
|
|
323
|
+
const test = window.__sootsimTest
|
|
324
|
+
if (!test?.resolveTapTarget) return null
|
|
325
|
+
return await test.resolveTapTarget(${e})
|
|
326
|
+
})()`)}async activatePressTarget(e){let t=e.id?{id:e.id,testID:e.id,text:null}:{id:null,testID:null,text:e.text??null};return this.evaluate(`(async () => {
|
|
327
|
+
const test = window.__sootsimTest
|
|
328
|
+
if (!test) return null
|
|
329
|
+
const node = ${e.id?`(await test.findByTestId?.(${JSON.stringify(e.id)})) || (await test.findById?.(${JSON.stringify(e.id)}))`:`await test.findByText?.(${JSON.stringify(e.text||"")})`}
|
|
330
|
+
let point = null
|
|
331
|
+
if (node?.absolutePosition && node?.layout) {
|
|
332
|
+
point = {
|
|
333
|
+
x: node.absolutePosition.x + node.layout.width / 2,
|
|
334
|
+
y: node.absolutePosition.y + node.layout.height / 2,
|
|
335
|
+
}
|
|
336
|
+
if (typeof node.nodeId === 'number' && test.resolveTapTarget) {
|
|
337
|
+
const resolved = await test.resolveTapTarget(node.nodeId)
|
|
338
|
+
if (
|
|
339
|
+
resolved &&
|
|
340
|
+
Number.isFinite(resolved.cx) &&
|
|
341
|
+
Number.isFinite(resolved.cy)
|
|
342
|
+
) {
|
|
343
|
+
point = { x: resolved.cx, y: resolved.cy }
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
${e.id?`const direct = await test.activatePressById?.(${JSON.stringify(e.id)})`:`const direct = await test.activatePressByText?.(${JSON.stringify(e.text||"")})`}
|
|
348
|
+
if (direct?.ok && point) {
|
|
349
|
+
window.dispatchEvent(
|
|
350
|
+
new CustomEvent('sootsim:agentAction', {
|
|
351
|
+
detail: { type: 'tap', x: point.x, y: point.y, target: ${JSON.stringify(t)} },
|
|
352
|
+
}),
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
return direct || null
|
|
356
|
+
})()`)}async activatePressAt(e,t){return this.evaluate(`(async () => {
|
|
357
|
+
const test = window.__sootsimTest
|
|
358
|
+
if (!test?.activatePressAt) return null
|
|
359
|
+
const direct = await test.activatePressAt(${e}, ${t})
|
|
360
|
+
if (direct?.ok) {
|
|
361
|
+
window.dispatchEvent(
|
|
362
|
+
new CustomEvent('sootsim:agentAction', {
|
|
363
|
+
detail: { type: 'tap', x: ${e}, y: ${t} },
|
|
364
|
+
}),
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
return direct
|
|
368
|
+
})()`)}async tap(e,t,r){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:r})}async longPress(e,t,r,n){return await this.bridge.send({type:"longPress",simId:this.opts.simId,x:e,y:t,durationMs:r,target:n})}async waitForElement(e,t=5e3){let r=Date.now()+t,n=await this.findElement(e);for(;!n&&Date.now()<r;)await f(150),n=await this.findElement(e);return n}replayTargetForElement(e,t,r){return{id:e.id??r?.target?.id??t.id??null,testID:e.id??r?.target?.testID??t.testID??null,text:e.text??r?.target?.text??r?.target?.accessibilityLabel??t.text??t.accessibilityLabel??null,type:r?.target?.type??t.type??null}}async resolveInteractionPoint(e){if(e.point&&!e.id&&!e.text&&e.index===void 0&&!e.childOf)return{...Q(e.point),element:null,target:void 0};let t=await this.waitForElement(e);if(!t)return null;let r=typeof t.nodeId=="number"?await this.resolveTapTarget(t.nodeId):null,n=this.replayTargetForElement(e,t,r);return e.point?{...Q(e.point,{x:t.absolutePosition.x,y:t.absolutePosition.y,width:t.layout.width,height:t.layout.height}),element:t,target:n}:{x:r?.cx??t.absolutePosition.x+t.layout.width/2,y:r?.cy??t.absolutePosition.y+t.layout.height/2,element:t,target:n}}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let o=await this.resolveInteractionPoint(t);if(!o)throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`);(await this.activatePressAt(o.x,o.y))?.ok||await this.tap(o.x,o.y,o.target),await f(300);return}let r=await this.waitForElement(t);if(r){let o=r.isTextInput?4:1;for(let a=0;a<o;a++){let s=a===0?r:await this.findElement({text:t.text,id:t.id});if(!s)break;let l=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,p=l?.cx??s.absolutePosition.x+s.layout.width/2,h=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(p,h,this.replayTargetForElement(t,s,l)))?.hit===!0){if(await f(300),!s.isTextInput||await this.waitForFocusedTextInput(600,s))return;continue}break}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async longPressOn(e){let t=typeof e=="string"?{text:e}:e,r=await this.resolveInteractionPoint(t);if(!r)throw new Error(`longPressOn: element not found: ${JSON.stringify(t)}`);let n=await this.longPress(r.x,r.y,3e3,r.target);if(n?.ok===!1||n?.value===!1)throw new Error(`longPressOn: long press missed: ${JSON.stringify(t)}`);await f(300)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,r=80){let n=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
|
|
369
|
+
const interact = window.__sootsimInteract
|
|
370
|
+
if (interact?.doubleTap) {
|
|
371
|
+
return !!(await interact.doubleTap(${e}, ${t}, ${n}))
|
|
372
|
+
}
|
|
373
|
+
if (!interact?.tap) return false
|
|
374
|
+
const first = await interact.tap(${e}, ${t})
|
|
375
|
+
if (!first || first.hit === false) return false
|
|
376
|
+
await new Promise((resolve) => setTimeout(resolve, ${n}))
|
|
377
|
+
const second = await interact.tap(${e}, ${t})
|
|
378
|
+
return !!second && second.hit !== false
|
|
379
|
+
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let o=0;o<15;o++){if(await this.isElementVisible(t))return;await f(200)}let r=await this.findElement(t),n=r?` (matched node at y=${Math.round(r.absolutePosition.y)} h=${Math.round(r.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${n}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let r=await this.findElement(t),n=r?` at (${Math.round(r.absolutePosition.x)},${Math.round(r.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${n}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<L)}async inputText(e){if(!await this.waitForFocusedTextInput())throw new Error("inputText: no focused TextInput; tap the input and wait for focus before typing");await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await f(200)}focusedTextInputMatches(e,t){if(!t||typeof t.nodeId=="number"&&typeof e.nodeId=="number"&&t.nodeId===e.nodeId)return!0;let r=t.testID??null,n=e.testID??null;if(r&&n&&r===n)return!0;let o=t.id??null,a=e.id??null;return!!(o&&a&&o===a)}async waitForFocusedTextInput(e=1500,t){let r=Date.now()+e;for(;Date.now()<r;){try{let n=await this.callTest("getFocusedNode");if(n&&this.focusedTextInputMatches(n,t))return!0}catch{}await f(50)}return!1}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await f(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await f(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
|
|
380
|
+
const keyboard =
|
|
381
|
+
window.__sootsimKeyboard ??
|
|
382
|
+
window.SootSim?.bridges?.keyboard ??
|
|
383
|
+
null
|
|
384
|
+
const test = window.__sootsimTest
|
|
385
|
+
return {
|
|
386
|
+
visible: !!keyboard?.isVisible?.(),
|
|
387
|
+
focused: !!test?.isTextInputFocused?.(),
|
|
388
|
+
}
|
|
389
|
+
})()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:"Backspace"});await f(100)}async waitFor(e){let t=Date.now()+(e.timeout||Z);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}let r=await this.findElement(e),n=r?` (matched node y=${Math.round(r.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||Z}ms${n}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await f(250)}catch{}let t=Ot(e),r=Mt(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});S.mkdirSync(y.dirname(r),{recursive:!0});let n=t.layers??this.opts.screenshotLayers,o={type:"screenshot",simId:this.opts.simId};n&&n!=="full"&&(o.layers=n);let s=(await this.bridge.send(o)).replace(/^data:image\/png;base64,/,""),l=Buffer.from(s,"base64");if(t.withFrame){let p=await this.readCurrentDeviceModel();if(!p)throw new Error("could not read current device model for framed screenshot");let h=await tt(l,p);S.writeFileSync(r,h),console.log(`[flow] screenshot: ${r} (frame: ${p})`);return}S.writeFileSync(r,l),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 Re)?null:t}async captureFailureScreenshot(e){S.mkdirSync(y.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");S.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){S.mkdirSync(e,{recursive:!0});let r=(h,g)=>{try{S.writeFileSync(y.join(e,h),g)}catch{}},n=async h=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:h})}catch{return null}},o=await n(`(async () => {
|
|
390
|
+
const out = {
|
|
391
|
+
simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
|
|
392
|
+
url: location.href,
|
|
393
|
+
title: document.title,
|
|
394
|
+
hidden: document.hidden,
|
|
395
|
+
}
|
|
396
|
+
try {
|
|
397
|
+
const params = new URL(location.href).searchParams
|
|
398
|
+
const bundle = params.get('bundle')
|
|
399
|
+
if (bundle) {
|
|
400
|
+
const baseMatch = bundle.match(/^https?:\\/\\/[^/]+/)
|
|
401
|
+
if (baseMatch) {
|
|
402
|
+
const res = await fetch(baseMatch[0] + '/', {
|
|
403
|
+
headers: { 'expo-platform': 'ios' },
|
|
404
|
+
cache: 'no-store',
|
|
405
|
+
})
|
|
406
|
+
if (res.ok) {
|
|
407
|
+
out.manifest = await res.json().catch(() => null)
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
} catch {}
|
|
412
|
+
return out
|
|
413
|
+
})()`);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(),sim:o??null},null,2));try{let g=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(g,"base64"))}catch{}let a=await n(`(async () => {
|
|
414
|
+
const t = window.__sootsimTest
|
|
415
|
+
const mainShell = window.SootSim?.bridges?.mainShell
|
|
416
|
+
if (!t) return { error: 'no test bridge' }
|
|
417
|
+
let shell = null
|
|
418
|
+
try {
|
|
419
|
+
shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
|
|
420
|
+
} catch {}
|
|
421
|
+
const all = await t.queryAll({ pruneHidden: true })
|
|
422
|
+
return { shell, nodes: all, url: location.href, title: document.title }
|
|
423
|
+
})()`);a&&r("describe.json",JSON.stringify(a,null,2));let s=await n("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof s=="string"&&r("a11y.txt",s);let l=await n("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof l=="string"&&r("tree.txt",l);let p=await n(`(() => {
|
|
424
|
+
const c = window.__sootsimConsole
|
|
425
|
+
return {
|
|
426
|
+
errors: c?.getErrors?.() ?? [],
|
|
427
|
+
warnings: c?.getWarnings?.() ?? [],
|
|
428
|
+
requests: (window.__sootsimGetFailedRequests?.() ?? []),
|
|
429
|
+
}
|
|
430
|
+
})()`);return p&&r("console.json",JSON.stringify(p,null,2)),e}async swipe(e="UP",t=300){let r=ee/2,n=L/2,o=200,a=r,s=n,l=r,p=n;switch(e.toUpperCase()){case"UP":s+=o,p-=o;break;case"DOWN":s-=o,p+=o;break;case"LEFT":a+=o,l-=o;break;case"RIGHT":a-=o,l+=o;break}let h=Math.max(10,Math.round(t/16));await this.drag(a,s,l,p,h,16)}async drag(e,t,r,n,o=12,a=16){if(!(await this.evaluate(`(async () => {
|
|
431
|
+
const interact = window.__sootsimInteract
|
|
432
|
+
if (!interact?.drag) return { ok: false }
|
|
433
|
+
const value = await interact.drag(${e}, ${t}, ${r}, ${n}, ${Math.max(1,Math.round(o))}, ${Math.max(0,Math.round(a))})
|
|
434
|
+
return { ok: !!value, value }
|
|
435
|
+
})()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,r=300){let n=Q(e),o=Q(t),a=Math.max(10,Math.round(r/16));await this.drag(n.x,n.y,o.x,o.y,a,16)}async swipeFrom(e,t="UP",r=300){let n=await this.findElement(e);if(!n)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let o=n.absolutePosition.x+n.layout.width/2,a=n.absolutePosition.y+n.layout.height/2,s=180,l=o,p=a;switch(t.toUpperCase()){case"UP":p-=s;break;case"DOWN":p+=s;break;case"LEFT":l-=s;break;case"RIGHT":l+=s;break}let h=Math.max(10,Math.round(r/16));await this.drag(o,a,l,p,h,16)}async scrollTo(e,t,r){let n=await this.callTest("scrollTo",e,t,r,!1);if(!n?.ok)throw new Error(`scrollTo failed: ${n?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.evaluate(`(async () => {
|
|
436
|
+
const interact = window.__sootsimInteract
|
|
437
|
+
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
438
|
+
const ok = await interact.pinch(
|
|
439
|
+
${e.from[0]}, ${e.from[1]}, ${e.from[2]}, ${e.from[3]},
|
|
440
|
+
${e.to[0]}, ${e.to[1]}, ${e.to[2]}, ${e.to[3]},
|
|
441
|
+
${e.steps||12}, ${e.stepMs||16}
|
|
442
|
+
)
|
|
443
|
+
return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
|
|
444
|
+
})()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await f(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){let t=Math.max(0,Math.round(e));if(t<=0)return;(await we({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:32,stablePolls:2,strict:!0})).settled&&this.markVisualSettled()}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",n=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<t;){let o=await this.findElement({text:e.element});if(o&&o.absolutePosition.y>=0&&o.absolutePosition.y+o.layout.height>0&&o.absolutePosition.y<L-50){if(e.centerElement){let a=L/2,s=o.absolutePosition.y-a;if(Math.abs(s)>100){let l=Math.min(150,Math.abs(s)*.5),p=s>0?a-l:a+l;await this.drag(ee/2,a,ee/2,p,10,16)}}return}await this.swipe(n,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+(e.timeout||Z);for(;Date.now()<t;){let r=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,n=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(r&&n)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async reloadGuestApp(e){if(e){let n=!1;for(let o=0;o<3&&!n;o++)try{n=await this.evaluate(pe(!0),2e4)}catch{await f(1e3)}n||console.warn(" warn: tenant storage clear did not ack \u2014 hard-reloading anyway (worker reset follows)")}await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId()}async softReloadGuestApp(e){if(!await this.evaluate(pe(e),12e4))throw new Error("guest app soft reload bridge unavailable")}async rearmCaptureAfterRuntimeReload(){if(!this.recordingEnabled&&!this.profilingEnabled)return;let e=Date.now()+1e4,t=null;for(;Date.now()<e;){await this.refreshSimId();try{this.recordingEnabled&&await this.ensureRecordingStarted(),this.profilingEnabled&&await this.startProfile();return}catch(r){t=r,await f(250)}}throw new Error(`capture re-arm failed after app reload: ${t instanceof Error?t.message:String(t)}`)}async launchApp(e){await this.refreshSimId(),e&&typeof e=="object"&&e.arguments&&console.log("[flow] launchApp.arguments ignored (sootsim has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),r=Pt(e,"resetRuntime");if(!this.firstLaunchDone&&!t){if(this.firstLaunchDone=!0,r){let n=await U(this.bridge).catch(()=>null),o=n?.state==="home"&&n.activeApp==null;await this.softReloadGuestApp(!1),await this.waitForTree(12e4),o&&(await ue(this.bridge,"goHome",1e3),await this.waitForShellHome(1e3)),await this.launchShellAppFromHomeIfNeeded(e,o?{...n??{},state:"home",activeApp:null}:null)}else await this.launchShellAppFromHomeIfNeeded(e);await this.waitForTree(3e4)}else if(this.firstLaunchDone=!0,await this.reloadGuestApp(t),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(n){console.warn(` warn: onAfterLaunch hook threw: ${n instanceof Error?n.message:n}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
|
|
445
|
+
requestAnimationFrame(() => {
|
|
446
|
+
requestAnimationFrame(() => {
|
|
447
|
+
requestAnimationFrame(() => {
|
|
448
|
+
setTimeout(resolve, 180)
|
|
449
|
+
})
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
})`),this.markVisualSettled()}catch{await f(180),this.markVisualSettled()}}markVisualSettled(){this.lastVisualSettledAtMs=Date.now()}hasFreshVisualSettle(){return Date.now()-this.lastVisualSettledAtMs<750}resolveShellLaunchAppId(e,t){if(typeof e=="string"&&e.length>0)return e;if(ve(e)){let r=G(e,"appId")||G(e,"id");if(r)return r}return At(t)||"connect"}async waitForShellAppLaunched(e,t){let r=Date.now()+t,n=null;for(;Date.now()<r;){try{n=await U(this.bridge)}catch{n=null}if(n?.state==="app"&&n.activeApp===e&&n.showSwitcher===!1&&typeof n.launchProgress=="number"&&n.launchProgress>=.98)return;await f(16)}}async waitForShellHome(e){let t=Date.now()+e;for(;Date.now()<t;){let r=await U(this.bridge).catch(()=>null);if(r?.state==="home"&&r.activeApp==null&&r.showSwitcher===!1)return;await f(16)}}async launchShellAppFromHomeIfNeeded(e,t){let r=null;if(t)r=t;else try{r=await U(this.bridge)}catch{return!1}if(r?.state!=="home"||r.activeApp!=null)return!1;let n=this.resolveShellLaunchAppId(e,r);return this.recordingEnabled&&await this.ensureRecordingStarted(),await ue(this.bridge,"launchApp",1e3,n),await this.waitForShellAppLaunched(n,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
|
|
453
|
+
if (!window.__sootsimShellPerf) {
|
|
454
|
+
return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
|
|
455
|
+
}
|
|
456
|
+
window.__sootsimShellPerf.start()
|
|
457
|
+
return { started: true }
|
|
458
|
+
})()`);if(e?.error)throw new Error(e.error);this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async () => {
|
|
459
|
+
if (!window.__sootsimShellPerf) {
|
|
460
|
+
return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
|
|
461
|
+
}
|
|
462
|
+
return await window.__sootsimShellPerf.stop()
|
|
463
|
+
})()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(!1),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.reloadGuestApp(!0),await this.rearmCaptureAfterRuntimeReload()}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 n=r.text??r.testID??"";this.js.setCopiedText(n),this.js.putEnv("maestroCopiedText",n),console.log(`[flow] copied text: ${JSON.stringify(n)}`)}evalScript(e){let r=/(?<!\\)\$\{[^$]*\}/.test(e)?this.js.evaluateStringTemplate(e):this.js.evaluate(e);r!==void 0&&r!==""&&console.log("[flow] evalScript ->",r)}runScript(e){let t=typeof e=="string"?{file:e}:e;if(!t.file)throw new Error("runScript requires a file");let r=y.resolve(this.opts.flowDir,t.file),n=S.readFileSync(r,"utf8");this.js.evaluate(n,{env:t.env}),console.log(`[flow] runScript: ${t.file} done`)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");let r=await this.callTest("openDeepLink",t);if(!r?.ok)throw new Error(`openLink failed: ${r?.error||"no test bridge"}`);await f(300)}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()===this.js.maestro.platform.toLowerCase():e.true!==void 0?nt(e.true):!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([o])=>o!=="when"&&o!=="optional"),n=r?r[1]:void 0;return!!(n&&typeof n=="object"&&"optional"in n&&n.optional)}async runStep(e,t){let r=typeof e=="string"?_t(e):e,n=Object.keys(r).find(l=>l!=="when")||Object.keys(r)[0];console.log(`[flow] step ${t+1}: ${n}`);let o=Date.now(),a=this.flowStepTargetLabel(r,n),s;try{s=this.js.interpolateStep(r),a=this.flowStepTargetLabel(s,n)??a}catch(l){if(this.isOptional(r)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:n,target:r[n]},this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}if(s.when&&!await this.evaluateWhen(s.when)){console.log("[flow] (when: predicate false, skipped)"),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"skipped"});return}try{let l=!!(s.extendedWaitUntil||s.waitFor||s.scrollUntilVisible||s.launchApp||s.runFlow||s.runScript),p=1e4,h=this.runStepInner(s);if(l)await h;else{let F=null,m=new Promise((k,_)=>{F=setTimeout(()=>{_(new Error(`step watchdog: ${n} made no progress in ${p}ms \u2014 bridge or bundle probably hung`))},p)});try{await Promise.race([h,m])}finally{F&&clearTimeout(F)}}let g=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!g&&await f(this.stepDelay),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"success"})}catch(l){if(this.isOptional(s)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:n,target:s[n]},this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.longPressOn)await this.longPressOn(e.longPressOn);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){let t=typeof e.scrollTo.nodeId=="number"?{nodeId:e.scrollTo.nodeId}:e.scrollTo.id;if(!t)throw new Error("scrollTo requires id or nodeId");await this.scrollTo(t,e.scrollTo.x,e.scrollTo.y)}else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd){let t=e.waitForAnimationToEnd;await this.waitForAnimationToEnd(typeof t=="number"?t:typeof t=="object"&&typeof t.timeout=="number"?t.timeout: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 f(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&&Array.isArray(e.repeat.commands)){let t=e.repeat.times,r=t==null||t===""?Number.MAX_SAFE_INTEGER:Number(t);if(!Number.isFinite(r))throw new Error(`repeat.times is not a number: ${t}`);let n=e.repeat.when??e.repeat.condition,o=async()=>n?this.evaluateWhen(n):!0,a=n?r:Math.min(r,1e3),s=0;for(;s<a&&await o();){for(let l=0;l<e.repeat.commands.length;l++)await this.runStep(e.repeat.commands[l],l);s++}}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")this.evalScript(e.evalScript);else if(e.runScript){let t=e.runScript,r=typeof t=="string"?void 0:t.when;if(r&&!await this.evaluateWhen(r)){console.log("[flow] runScript skipped (when predicate false)");return}this.runScript(t)}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,n=typeof t=="string"?void 0:t.commands,o=typeof t=="string"?void 0:t.env,a=typeof t=="string"?void 0:t.when;if(a&&!await this.evaluateWhen(a)){console.log(`[flow] runFlow skipped (when predicate false): ${r??"inline commands"}`);return}if(!r&&!n)throw new Error("runFlow requires either file or commands");this.js.enterEnvScope();try{if(o)for(let[s,l]of Object.entries(o))this.js.putEnv(s,l);if(r){let s=y.resolve(this.opts.flowDir,r),l=S.readFileSync(s,"utf8"),p=this.opts.flowDir;this.opts.flowDir=y.dirname(s);try{await this.runFlow(Dt(l))}finally{this.opts.flowDir=p}}else if(n)for(let s=0;s<n.length;s++)await this.runStep(n[s],s)}finally{this.js.leaveEnvScope()}}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],r=[],n=[];for(let a of e){let s=Object.keys(a);if(s.length===1&&s[0]==="onFlowStart"&&Array.isArray(a.onFlowStart)){t.push(...a.onFlowStart);continue}if(s.length===1&&s[0]==="onFlowComplete"&&Array.isArray(a.onFlowComplete)){r.push(...a.onFlowComplete);continue}n.push(a)}if(t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let a=0;a<t.length;a++)await this.runStep(t[a],a)}let o=null;try{await this.runFlowBody(n)}catch(a){o=a instanceof Error?a:new Error(String(a))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let a=0;a<r.length;a++)try{await this.runStep(r[a],a)}catch(s){console.warn(`[flow] onFlowComplete step ${a+1} failed: ${s instanceof Error?s.message:s}`)}}if(o)throw o}async runFlowBody(e){for(let t=0;t<e.length;t++){let r=e[t],n=typeof r.wait=="number"?r.wait:0,o=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,a=Math.max(6e4,n+15e3,o+15e3);if(r.runFlow||r.launchApp){await this.runStep(r,t);continue}await Promise.race([this.runStep(r,t),new Promise((s,l)=>setTimeout(()=>l(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${a}ms deadline`)),a))])}}};var xe=null;function xr(){return xe}async function Bt(i){if(!i)return"";let e=i.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let r=(await _e()).find(n=>n.name.toLowerCase()===e.toLowerCase());return r?String(r.preferredPort):e}async function Ct(){let i=await De(),e=i.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=i[0];return t?`http://localhost:${t.port}/__soot/`:null}async function ot(i){xe=null,(i.length===0||i.includes("--help")||i.includes("-h"))&&(console.log(`
|
|
464
|
+
sootsim flow \u2014 run flows or manage a draft
|
|
465
|
+
|
|
466
|
+
usage:
|
|
467
|
+
sootsim flow <flow.yaml> [options]
|
|
468
|
+
sootsim flow start
|
|
469
|
+
sootsim flow keep
|
|
470
|
+
sootsim flow end [--output <path>] [--validate] [--video]
|
|
471
|
+
sootsim flow validate <path>
|
|
472
|
+
|
|
473
|
+
options:
|
|
474
|
+
--record record a webm artifact while the flow runs
|
|
475
|
+
--profile capture perf stats while the flow runs
|
|
476
|
+
--out <dir> output directory (default: /tmp/sootsim-recordings)
|
|
477
|
+
--device <model> override the flow frontmatter device for this run
|
|
478
|
+
--slow <ms> delay between steps for natural pacing
|
|
479
|
+
--tail-wait <ms> hold the recording open after the last step so the
|
|
480
|
+
final UI state is captured (default: smart idle up to
|
|
481
|
+
6000ms for --preview, fixed 2000ms for --record, 0 otherwise)
|
|
482
|
+
--url <url> load this target before running the flow
|
|
483
|
+
--screenshot-paths <mode>
|
|
484
|
+
screenshot path mode: dir (default) or flow
|
|
485
|
+
--no-shell capture every screenshot tenant-only (no status bar,
|
|
486
|
+
keyboard, notification center, or other shell overlays).
|
|
487
|
+
use for clean demo asset sets. per-step \`layers:\`
|
|
488
|
+
still wins over this default.
|
|
489
|
+
--shell-only inverse \u2014 capture shell chrome only
|
|
490
|
+
--replace <m>=<f> replace a Metro module with a local file for this run
|
|
491
|
+
--new open a fresh sim before running the flow
|
|
492
|
+
--driver <id> when paired with --new, launch through a specific
|
|
493
|
+
driver from the registry (e.g. playwright for
|
|
494
|
+
hermetic CI runs); see 'sootsim list --drivers'
|
|
495
|
+
--headless pass headless=true to the launch driver (useful
|
|
496
|
+
with --driver playwright)
|
|
497
|
+
--headed force a fresh, VISIBLE window for this run (implies
|
|
498
|
+
--new; overrides --headless). use when you want to
|
|
499
|
+
watch the flow run live even if the current sim is
|
|
500
|
+
headless or stale
|
|
501
|
+
--electron prefer opening the target in the desktop companion
|
|
502
|
+
--sim <id> target a specific current sim
|
|
503
|
+
--validate replay the drafted flow before clearing it
|
|
504
|
+
--video replay and record the drafted flow before clearing it
|
|
505
|
+
--preview record events+video, upload, and print /preview/<id>
|
|
506
|
+
--preview-open open the uploaded preview link after a successful run
|
|
507
|
+
--preview-origin <url>
|
|
508
|
+
upload target for --preview (default: auto)
|
|
509
|
+
--preview-public-origin <url>
|
|
510
|
+
public link origin for --preview (default: sootsim.com
|
|
511
|
+
for prod uploads)
|
|
512
|
+
--billing-kind test_run
|
|
513
|
+
meter the chained preview upload as a test run
|
|
514
|
+
--owner <org> associate preview upload with a linked org repo
|
|
515
|
+
--repo <repo> repo name for --owner; user must belong to the team
|
|
516
|
+
|
|
517
|
+
frontmatter (top of flow.yaml between --- markers):
|
|
518
|
+
app: 8081 load this target before the flow starts
|
|
519
|
+
device: iphone-14 set the live device model for this flow run
|
|
520
|
+
electron: true prefer the desktop companion sim for this flow
|
|
521
|
+
|
|
522
|
+
default runtime:
|
|
523
|
+
bridge-backed flow playback against the current sim
|
|
524
|
+
if no current sim exists, flow opens the discovered target first
|
|
525
|
+
recording and profiling both run on the same bridge-backed path
|
|
526
|
+
|
|
527
|
+
examples:
|
|
528
|
+
sootsim flow login.yaml
|
|
529
|
+
sootsim flow demo.yaml --url 8081 --record --slow 500 --out ./recordings
|
|
530
|
+
sootsim flow demo.yaml --sim a2
|
|
531
|
+
sootsim flow start
|
|
532
|
+
sootsim flow keep
|
|
533
|
+
sootsim flow end --output ./flows/draft.yaml
|
|
534
|
+
sootsim flow end --output ./flows/draft.yaml --validate
|
|
535
|
+
sootsim flow end --output ./flows/draft.yaml --video
|
|
536
|
+
sootsim flow validate ./flows/draft.yaml
|
|
537
|
+
|
|
538
|
+
flow extension:
|
|
539
|
+
takeScreenshot: hero
|
|
540
|
+
takeScreenshot:
|
|
541
|
+
path: marketing/hero
|
|
542
|
+
withFrame: true
|
|
543
|
+
`),process.exit(0));let e=i[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=u=>i.find((c,w)=>i[w-1]===u),r=i.includes("--profile"),n=i.includes("--headed"),o=i.includes("--new")||n,a=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||(t("--out")?a:"/tmp/sootsim-flow"),l=t("--screenshot-paths")==="flow"?"flow":"dir",p=i.includes("--no-shell")?"tenant":i.includes("--shell-only")?"shell":void 0,h=t("--device")?.trim()||"",g=i.includes("--slow")?+(t("--slow")||"500"):0,F=i.includes("--electron"),m=i.includes("--preview"),k=await Xe(t("--preview-origin")),_=t("--preview-public-origin"),st=i.includes("--preview-open"),Te=t("--owner")?.trim()||"",Fe=t("--repo")?.trim()||"",H=t("--billing-kind")?.trim()||"";H&&H!=="test_run"&&(console.error(` error: invalid --billing-kind: ${H}`),process.exit(1));let at=i.flatMap((u,c)=>i[c-1]==="--replace"?["--replace",u]:[]),lt=i.flatMap((u,c)=>i[c-1]==="--remap"?["--remap",u]:[]),P=i.includes("--record")||m,ct=i.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):P?m?6e3:2e3:0,dt=$.readFileSync(e,"utf8"),{frontmatter:T,steps:A}=he(dt);A.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let j=h||T.device||"",K=F||T.electron===!0,ut=T.app===void 0||T.app===null?"":typeof T.app=="number"?String(T.app):T.app,ne=await Bt(ut),Ee={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless","--headed"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--remap","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver","--billing-kind","--owner","--repo"]},v=ce(i,Ee),pt=t("--url")||"";K&&!We()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let Ie=K?"desktop companion":"bridge",ht=ne?` | target: ${ne}`:"";console.log(`
|
|
544
|
+
sootsim flow \u2014 ${b.basename(e)}
|
|
545
|
+
${A.length} steps | ${Ie}${ht}${P?" | recording":""}${r?" | profiling":""}${g?` | ${g}ms delay`:""}
|
|
546
|
+
`),m&&Ae({event:"preview_flow_started",properties:{flowName:b.basename(e),stepCount:A.length,mode:Ie,electron:K,record:P,profile:r,previewOrigin:k}});let I=pt||ne||"",ie=o||K&&v.simIdSource!=="flag",$e=t("--driver")||"",oe=!1,se=new Set,ke=!1;if(!I&&!ie&&v.simIdSource==="none"){let u=He(v);try{let c=await u.listSims(),w=c.find(C=>C.isPrimary&&C.readyState==="open"),O=c.find(C=>C.readyState==="open"),W=w??O;W&&(ke=!0,console.log(` reusing active sim: ${W.id}`))}catch{}finally{u.close()}}if(!I&&!ke&&(ie||v.simIdSource==="none")){let u=await Ct();u||(console.error(" error: no current sim and no sootsim target found"),await ae(),process.exit(1)),I=u}if(I&&j){let u=new URL(await Ue(I));u.searchParams.set("device",j),I=u.toString()}if(I){let u=[I];if(u.push(...at),u.push(...lt),ie&&u.push("--new"),u.push("--no-describe"),v.simIdSource==="flag"&&v.simId&&u.push("--sim",v.simId),$e&&(u.push("--driver",$e),oe=!0),i.includes("--headless")&&!n&&u.push("--headless"),await Je(u,{port:v.wsPort,timeoutMs:v.commandTimeoutMs}),oe){let c=le();c&&se.add(c)}}let D=ce(i,Ee),q=D.simIdSource==="flag"?D.simId:le()||D.simId,ft=D.simIdSource==="flag"?"flag":q?"saved":"none",E=de(D.wsPort,{commandTimeoutMs:D.commandTimeoutMs,simId:q,simIdSource:ft}),d,Pe=async()=>{if(!j)return!1;let u=await E.send({type:"evaluate",simId:d.simId,code:"window.location.href"});if(typeof u=="string"&&u.length>0){let c=new URL(u);c.searchParams.set("device",j),d.setSimRouteHint(c.toString())}return!!await E.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",j]})};if(d=new te(E,{screenshotDir:s,flowDir:b.dirname(b.resolve(e)),screenshotPathMode:l,screenshotLayers:p,simId:q,recordingOutputDir:P?a:void 0,recordingFormat:m?"mp4":"webm",billingOriginOverride:m?k:void 0,allowGitHubRecording:m,requireRecordingEntitlement:m,onAfterLaunch:async()=>{await Pe()&&await d.waitForTree(12e4),m&&await E.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
547
|
+
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
548
|
+
return r?.start?.() ?? false
|
|
549
|
+
})()`})}}),g&&(d.stepDelay=g),d.js.putEnv("MAESTRO_FILENAME",b.basename(e,b.extname(e))),T.env&&typeof T.env=="object")for(let[u,c]of Object.entries(T.env))d.js.putEnv(u,c);let R=null,x=null,B=null,M=null,z=0,Y=!!A[0]?.launchApp;try{Y||await d.waitForTree(12e4),await Pe()&&!Y&&await d.waitForTree(12e4),m&&!Y&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await d.launchApp({clearState:!0}),P&&(Y?d.prepareRecording():await d.startRecording()),r&&await d.startProfile(),m&&(await E.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
550
|
+
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
551
|
+
return r?.start?.() ?? false
|
|
552
|
+
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(A),r&&(R=await d.stopProfile()),await d.waitForRecordingTail({maxMs:ct,smart:m}),P&&(x=await d.stopRecording(),B=d.getLastRecordingDurationMs()),m&&(M=await E.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
553
|
+
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
554
|
+
return r?.stop?.() ?? []
|
|
555
|
+
})()`}),console.log(` captured ${M.length} replay events`));let c=A.filter(w=>w&&typeof w=="object"&&"takeScreenshot"in w).length;console.log(`
|
|
556
|
+
+ completed (${A.length} steps)`),c>0&&console.log(` screenshots: ${c} \u2192 ${s}`),R&&it(R),x&&console.log(` video: ${x}`),console.log()}catch(u){if(r&&!R)try{R=await d.stopProfile()}catch{}if(P&&!x)try{x=await d.stopRecording(),B=d.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}if(m&&!M)try{M=await E.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
557
|
+
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
558
|
+
return r?.stop?.() ?? []
|
|
559
|
+
})()`}),console.log(` captured ${M.length} partial replay events`)}catch(c){console.warn(` event recorder stop failed: ${c?.message||String(c)}`)}console.error(`
|
|
560
|
+
x failed: ${u.message}
|
|
561
|
+
`),R&&(console.log(" partial profile:"),it(R)),x&&console.log(` partial video: ${x}`);try{let c=d.lastFailedStep,w=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",O=b.join(s,w);await d.captureFailureBundle(O,{error:u,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),console.log(` failure bundle: ${O}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let w=b.join(s,"error.png");await d.captureFailureScreenshot(w),console.log(` error screenshot: ${w}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await je(E,{errorsCommand:`sootsim get errors 5${d.simId?` --sim ${d.simId}`:""}`,warningsCommand:`sootsim get warnings 5${d.simId?` --sim ${d.simId}`:""}`,requestsCommand:`sootsim get requests 5${d.simId?` --sim ${d.simId}`:""}`}),z=1}if(m&&(z===0||x||M))try{let u=await Lt(M??[]),c=["--origin",k,"--events",u];_&&c.push("--public-origin",_),x&&c.push("--video",x),x&&B&&Number.isFinite(B)&&(c.push("--video-duration-ms",String(Math.round(B))),c.push("--recorded-duration-ms",String(Math.round(B))));let w=d.getLastRecordingStartedAtMs();w&&Number.isFinite(w)&&c.push("--recording-started-at-ms",String(Math.round(w))),v.wsPort&&c.push("--port",String(v.wsPort)),d.simId&&c.push("--sim",d.simId),st&&c.push("--open"),Te&&c.push("--owner",Te),Fe&&c.push("--repo",Fe),H&&c.push("--billing-kind",H),console.log(`
|
|
562
|
+
preparing preview upload\u2026`);let O=d.getFlowTraceSteps();O.length>0&&c.push("--timeline-events",await Ht(O));let W=d.getLastRecordingFrameStats();W&&c.push("--trace-frame-stats",await jt(W));let{runUpload:C}=await import("./upload-SCPAVRE5.js");xe=await C(c,{})}catch(u){console.error(` preview upload failed: ${u?.message||u}`),z=1}return E.close(),oe?(d.simId&&se.add(d.simId),await Nt(v.wsPort,v.commandTimeoutMs,[...se])):d.simId&&d.simId!==q&&Oe(d.simId),await ae(),z}async function Nt(i,e,t){let r=[...new Set(t.filter(Boolean))];if(r.length===0)return;let n=de(i,{commandTimeoutMs:e});try{let o=await n.listSims(),a=r.filter(l=>o.some(p=>p.id===l&&p.readyState==="open"));if(a.length===0)return;let s=await Ge(n,i,e,a);await Ve(o,a),s.closed.length>0&&console.log(` closed flow sim(s): ${s.closed.join(", ")}`),s.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${s.remaining.join(", ")}`)}catch(o){console.warn(` warn: failed to close flow sim(s): ${o instanceof Error?o.message:String(o)}`)}finally{n.close()}}async function Lt(i){let{gzipSync:e}=await import("zlib"),t=i.map(o=>JSON.stringify(o)).join(`
|
|
563
|
+
`)+(i.length?`
|
|
564
|
+
`:""),r=e(Buffer.from(t,"utf8")),n=b.join(re(),`sootsim-events-${Date.now()}.jsonl.gz`);return $.writeFileSync(n,r),console.log(` events: ${i.length} written to ${n} (${r.length} bytes gz)`),n}async function Ht(i){let{gzipSync:e}=await import("zlib"),t=i.map((a,s)=>({schemaVersion:1,t:a.endedAtMs,seq:1e6+s,context:"host",kind:"flow-step",id:`flow-step-${a.stepIndex}`,data:{stepIndex:a.stepIndex,stepNumber:a.stepIndex+1,stepName:a.stepName,...a.targetLabel?{targetLabel:a.targetLabel}:{},status:a.status,durationMs:a.durationMs,startedAtMs:a.startedAtMs,endedAtMs:a.endedAtMs,...a.error?{error:a.error}:{}}})),r=t.map(a=>JSON.stringify(a)).join(`
|
|
565
|
+
`)+`
|
|
566
|
+
`,n=e(Buffer.from(r,"utf8")),o=b.join(re(),`sootsim-flow-steps-${Date.now()}.jsonl.gz`);return $.writeFileSync(o,n),console.log(` flow trace: ${t.length} step events written to ${o} (${n.length} bytes gz)`),o}async function jt(i){let e=b.join(re(),`sootsim-frame-stats-${Date.now()}.json`);return $.writeFileSync(e,JSON.stringify(i)),console.log(` frame stats: written to ${e}`),e}async function Wt(i){let e=i[0],t=r=>i.find((n,o)=>i[o-1]===r);switch(e){case"start":{let{path:r,state:n}=qe();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${n.steps.length}`);return}case"keep":case"good":{let r=ge();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")||(i[1]&&!i[1].startsWith("-")?i[1]:void 0),n=i.includes("--validate")||i.includes("--video"),o=i.includes("--video"),a=ge();a.active&&a.kept&&console.log(` auto-kept trailing action: ${a.candidate.summary}`);let s=ze(r||(n?Vt():void 0));if(s.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!s.valid){console.error(" flow draft is not valid:");for(let l of s.issues)console.error(` - ${l}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim flow start` to reset"),process.exit(1)}if(n){let l=Jt(i,s.outputPath),p=await ot(l);if(p!==0){console.error(`
|
|
567
|
+
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=p;return}me(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),o&&console.log(" video: recorded during validation run");return}if(me(),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=i[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let n=fe(r);if(n.length>0){console.error(` x ${r} failed validation:`);for(let o of n)console.error(` - ${o}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}function Ut(i){return i[0]==="--sim"&&i.length>=2?[...i.slice(2),"--sim",i[1]]:i}async function Tr(i){let e=Ut(i),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await Wt(e),0;let r=await ot(e);return r!==0&&(process.exitCode=r),r}function it(i){console.log(""),Ye(i)}function Vt(){return b.join(re(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Jt(i,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let r=1;r<i.length;r++){let n=i[r];if(!(n==="--validate"||n==="--video")){if(n==="--output"){r+=1;continue}r===1&&!n.startsWith("-")||t.push(n)}}return!t.includes("--record")&&i.includes("--video")&&t.push("--record"),t}export{tt as a,xt as b,xr as c,Ct as d,ot as e,Ut as f,Tr as g};
|