neoagent 2.3.1-beta.89 → 2.3.1-beta.90

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.
@@ -9,6 +9,10 @@ const APK_UPLOAD_ROOT = path.resolve(
9
9
  const MAX_APK_BYTES = Number(process.env.NEOAGENT_ANDROID_APK_MAX_BYTES || 512 * 1024 * 1024);
10
10
  const IDLE_TIMEOUT_MS = Number(process.env.NEOAGENT_VM_IDLE_TIMEOUT_MS || 10 * 60 * 1000);
11
11
 
12
+ function sleep(ms) {
13
+ return new Promise((resolve) => setTimeout(resolve, ms));
14
+ }
15
+
12
16
  function assertPathInside(baseDir, candidatePath, label) {
13
17
  const resolvedBase = path.resolve(baseDir);
14
18
  const resolvedCandidate = path.resolve(candidatePath);
@@ -181,19 +185,37 @@ class VmBrowserProvider {
181
185
  }
182
186
 
183
187
  let file = null;
184
- for (const candidate of readablePathCandidates) {
185
- try {
186
- file = await this.client.request('POST', '/files/read', {
187
- path: candidate,
188
- encoding: 'base64',
189
- });
190
- if (file?.content) {
191
- break;
188
+ const maxAttempts = 20;
189
+ for (let attempt = 0; attempt < maxAttempts && !file?.content; attempt += 1) {
190
+ for (const candidate of readablePathCandidates) {
191
+ try {
192
+ file = await this.client.request('POST', '/files/read', {
193
+ path: candidate,
194
+ encoding: 'base64',
195
+ });
196
+ if (file?.content) {
197
+ break;
198
+ }
199
+ } catch (error) {
200
+ if (attempt === maxAttempts - 1) {
201
+ console.warn('[Runtime:browser_vm] screenshot materialization read failed', {
202
+ userId: this.userId,
203
+ candidate,
204
+ error: String(error?.message || error),
205
+ });
206
+ }
192
207
  }
193
- } catch {}
208
+ }
209
+ if (!file?.content) {
210
+ await sleep(250);
211
+ }
194
212
  }
195
213
  if (!file?.content) {
196
214
  if (typeof result.screenshotPath === 'string' && result.screenshotPath.startsWith('/screenshots/')) {
215
+ console.warn('[Runtime:browser_vm] unresolved VM screenshot path suppressed', {
216
+ userId: this.userId,
217
+ screenshotPath: result.screenshotPath,
218
+ });
197
219
  return {
198
220
  ...result,
199
221
  screenshotPath: null,