@qablehq/atto 0.0.42 → 0.0.43

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.
Files changed (2) hide show
  1. package/out/main/index.js +42 -4
  2. package/package.json +1 -1
package/out/main/index.js CHANGED
@@ -422,6 +422,15 @@ function attachEngineForRemoteAnswers(adapter) {
422
422
  }, 800);
423
423
  answerPollTimer.unref?.();
424
424
  }
425
+ const remoteEventChains = /* @__PURE__ */ new Map();
426
+ function enqueueRemoteSessionEvent(jobId, run) {
427
+ const previous = remoteEventChains.get(jobId) || Promise.resolve();
428
+ const next = previous.then(run).catch(() => void 0);
429
+ remoteEventChains.set(jobId, next);
430
+ void next.finally(() => {
431
+ if (remoteEventChains.get(jobId) === next) remoteEventChains.delete(jobId);
432
+ });
433
+ }
425
434
  function mirrorEngineEventToChat(event) {
426
435
  const jobId = remoteJobByDesktopSession.get(event.sessionId);
427
436
  if (!jobId) return;
@@ -442,7 +451,9 @@ function mirrorEngineEventToChat(event) {
442
451
  content: String(file.content || "").slice(0, 12e4)
443
452
  })) : void 0
444
453
  } : event;
445
- void postRemoteSessionEvent(jobId, basePayload).catch(() => void 0);
454
+ enqueueRemoteSessionEvent(jobId, async () => {
455
+ await postRemoteSessionEvent(jobId, basePayload);
456
+ });
446
457
  if (event.type === "narration_step" && Array.isArray(event.attachments)) {
447
458
  const shot = event.attachments.find((item) => item.kind === "screenshot" && item.url);
448
459
  if (shot?.url?.startsWith("taa-media://")) {
@@ -456,18 +467,45 @@ function mirrorEngineEventToChat(event) {
456
467
  if (event.type === "session_status_changed") {
457
468
  const status = event.status;
458
469
  if (status === "failed" || status === "stopped" || status === "awaiting_review" || status === "approved") {
459
- void ackAttoRemoteSession(jobId, status === "failed" ? "failed" : "done").catch(() => void 0);
460
- activeRemoteJobIds.delete(jobId);
470
+ enqueueRemoteSessionEvent(jobId, async () => {
471
+ await ackAttoRemoteSession(jobId, status === "failed" ? "failed" : "done");
472
+ activeRemoteJobIds.delete(jobId);
473
+ });
461
474
  }
462
475
  }
463
476
  }
464
477
  async function postRemoteSessionEvent(jobId, event) {
465
478
  const link = readLink();
466
479
  if (!link) return;
467
- await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(jobId)}/events`, {
480
+ const response = await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(jobId)}/events`, {
468
481
  method: "POST",
469
482
  body: JSON.stringify(event)
470
483
  });
484
+ if (response.ok) return;
485
+ if (event.type === "code_generated") {
486
+ const files = Array.isArray(event.files) ? event.files : [];
487
+ const slim = {
488
+ ...event,
489
+ content: String(event.content || "").slice(0, 4e4),
490
+ files: files.slice(0, 40).map((file) => {
491
+ const row = file && typeof file === "object" ? file : {};
492
+ return {
493
+ path: String(row.path || ""),
494
+ kind: row.kind,
495
+ change: row.change,
496
+ content: String(row.content || "").slice(0, 4e4)
497
+ };
498
+ })
499
+ };
500
+ const retry = await tesboFetch(link, `/api/atto/sessions/${encodeURIComponent(jobId)}/events`, {
501
+ method: "POST",
502
+ body: JSON.stringify(slim)
503
+ });
504
+ if (retry.ok) return;
505
+ console.error("[tesbo] code_generated sync failed", retry.status, await retry.text().catch(() => ""));
506
+ return;
507
+ }
508
+ console.error("[tesbo] session event sync failed", event.type, response.status);
471
509
  }
472
510
  function enrichWebsiteAnswerText(raw) {
473
511
  const text2 = typeof raw === "string" ? raw.trim() : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qablehq/atto",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "Atto — AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {