@canaryai/cli 0.2.6 → 0.2.7

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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __cr } from "module"; const require = __cr(import.meta.url);
2
2
  import {
3
3
  getCanaryTmpDir
4
- } from "./chunk-AHYNXUHF.js";
4
+ } from "./chunk-XAA5VQ5N.js";
5
5
  import {
6
6
  consoleLogger
7
7
  } from "./chunk-P5Z2Y5VV.js";
@@ -40747,7 +40747,10 @@ var BrowserToolExecutor = class {
40747
40747
  this.allowedHosts = options?.allowedHosts;
40748
40748
  this.autoSnapshotAfterAction = options?.autoSnapshotAfterAction !== false;
40749
40749
  this.includeScreenshotWithSnapshot = options?.includeScreenshotWithSnapshot !== false;
40750
- this.workspaceDir = options?.workspaceDir ?? path.join(getCanaryTmpDir(), `browser-workspace-${Date.now()}-${crypto2.randomUUID().slice(0, 8)}`);
40750
+ if (!options?.workspaceDir && !options?.tmpBaseDir) {
40751
+ options?.logger?.debug?.("[BrowserToolExecutor] No tmpBaseDir provided, using flat canary dir (not org-scoped)");
40752
+ }
40753
+ this.workspaceDir = options?.workspaceDir ?? path.join(options?.tmpBaseDir ?? getCanaryTmpDir(), `browser-workspace-${Date.now()}-${crypto2.randomUUID().slice(0, 8)}`);
40751
40754
  this.logger = options?.logger;
40752
40755
  fs2.mkdir(this.workspaceDir, { recursive: true }).catch(() => {
40753
40756
  });
@@ -42687,7 +42690,7 @@ var TOAST_CAPTURE_SCRIPT = `
42687
42690
  return (clone.textContent || '').trim();
42688
42691
  }
42689
42692
 
42690
- function pushToast(text, role) {
42693
+ function pushToast(text, role, el) {
42691
42694
  if (!text || text.length === 0 || text.length >= 1000) return;
42692
42695
  // Deduplicate: skip if we already have the same text from the last 2 seconds
42693
42696
  const now = Date.now();
@@ -42695,7 +42698,21 @@ var TOAST_CAPTURE_SCRIPT = `
42695
42698
  (t) => t.text === text && now - t.time < 2000
42696
42699
  );
42697
42700
  if (isDupe) return;
42698
- window.__capturedToasts.push({ text: text, role: role, time: now });
42701
+
42702
+ let placement = null;
42703
+ if (el && el.getBoundingClientRect) {
42704
+ const rect = el.getBoundingClientRect();
42705
+ if (rect.width > 0 && rect.height > 0) {
42706
+ placement = {
42707
+ x: Math.round(rect.x),
42708
+ y: Math.round(rect.y),
42709
+ width: Math.round(rect.width),
42710
+ height: Math.round(rect.height),
42711
+ };
42712
+ }
42713
+ }
42714
+
42715
+ window.__capturedToasts.push({ text: text, role: role, time: now, placement: placement });
42699
42716
  if (window.__capturedToasts.length > MAX_TOASTS) {
42700
42717
  window.__capturedToasts.shift();
42701
42718
  }
@@ -42714,7 +42731,7 @@ var TOAST_CAPTURE_SCRIPT = `
42714
42731
  if (el.matches && el.matches(TOAST_SELECTORS) && isElementVisible(el)) {
42715
42732
  const text = extractToastText(el);
42716
42733
  if (text) {
42717
- pushToast(text, el.getAttribute('role') || el.getAttribute('aria-live') || 'toast');
42734
+ pushToast(text, el.getAttribute('role') || el.getAttribute('aria-live') || 'toast', el);
42718
42735
  return;
42719
42736
  }
42720
42737
  }
@@ -42725,7 +42742,7 @@ var TOAST_CAPTURE_SCRIPT = `
42725
42742
  if (isElementVisible(desc)) {
42726
42743
  const text = extractToastText(desc);
42727
42744
  if (text) {
42728
- pushToast(text, desc.getAttribute('role') || desc.getAttribute('aria-live') || 'toast');
42745
+ pushToast(text, desc.getAttribute('role') || desc.getAttribute('aria-live') || 'toast', desc);
42729
42746
  }
42730
42747
  }
42731
42748
  }
@@ -42772,7 +42789,8 @@ var TOAST_CAPTURE_SCRIPT = `
42772
42789
  if (el.matches(TOAST_SELECTORS)) {
42773
42790
  pushToast(
42774
42791
  extractToastText(el),
42775
- el.getAttribute('role') || el.getAttribute('aria-live') || 'toast'
42792
+ el.getAttribute('role') || el.getAttribute('aria-live') || 'toast',
42793
+ el
42776
42794
  );
42777
42795
  // Install secondary observer if this is also a live-region container
42778
42796
  if (el.matches(LIVE_REGION_CONTAINER)) {
@@ -42787,7 +42805,8 @@ var TOAST_CAPTURE_SCRIPT = `
42787
42805
  for (const child of children) {
42788
42806
  pushToast(
42789
42807
  extractToastText(child),
42790
- child.getAttribute('role') || child.getAttribute('aria-live') || 'toast'
42808
+ child.getAttribute('role') || child.getAttribute('aria-live') || 'toast',
42809
+ child
42791
42810
  );
42792
42811
  }
42793
42812
  if (children.length > 0) return;
@@ -42803,7 +42822,7 @@ var TOAST_CAPTURE_SCRIPT = `
42803
42822
  const role = container
42804
42823
  ? container.getAttribute('role') || container.getAttribute('aria-live') || 'live-region'
42805
42824
  : 'live-region';
42806
- pushToast(text, role);
42825
+ pushToast(text, role, el);
42807
42826
  }
42808
42827
  // Install secondary observer on the container for future CSS toggles
42809
42828
  installContainerObserver(container);
@@ -43509,7 +43528,8 @@ function formatMcpResponse(input) {
43509
43528
  lines.push("### Toast Notifications");
43510
43529
  for (const toast of input.capturedToasts) {
43511
43530
  const remaining = toast.snapshotsRemaining ?? 1;
43512
- lines.push(`- [${toast.role}] ${toast.text} (expires in ${remaining} snapshot${remaining !== 1 ? "s" : ""})`);
43531
+ const placementHint = toast.placement ? ` [visible at (${toast.placement.x}, ${toast.placement.y}), ${toast.placement.width}\xD7${toast.placement.height}px]` : "";
43532
+ lines.push(`- [${toast.role}] ${toast.text}${placementHint} (expires in ${remaining} snapshot${remaining !== 1 ? "s" : ""})`);
43513
43533
  }
43514
43534
  lines.push("");
43515
43535
  }
@@ -43564,11 +43584,16 @@ var PlaywrightClient = class _PlaywrightClient {
43564
43584
  browserLease;
43565
43585
  logger;
43566
43586
  screencastEncoderFactory;
43587
+ tmpBaseDir;
43567
43588
  constructor(options) {
43568
43589
  this.browserLease = options?.browserLease ?? null;
43569
43590
  this.logger = options?.logger ?? consoleLogger;
43570
43591
  this.screencastEncoderFactory = options?.screencastEncoderFactory ?? null;
43571
43592
  this.cursorOverlay = new CursorOverlay({ enabled: false });
43593
+ if (!options?.tmpBaseDir) {
43594
+ this.logger.debug("[PlaywrightClient] No tmpBaseDir provided, using flat canary dir (not org-scoped)");
43595
+ }
43596
+ this.tmpBaseDir = options?.tmpBaseDir ?? getCanaryTmpDir();
43572
43597
  }
43573
43598
  /** Assign a stable monotonic ID to a page and return it. */
43574
43599
  _assignPageId(page) {
@@ -43718,7 +43743,7 @@ var PlaywrightClient = class _PlaywrightClient {
43718
43743
  const cursorOpts = typeof cursorOverlay === "object" ? cursorOverlay : {};
43719
43744
  this.cursorOverlay = new CursorOverlay({ ...cursorOpts, enabled: cursorEnabled });
43720
43745
  }
43721
- this._downloadDir = path3.join(getCanaryTmpDir(), `playwright-downloads-${Date.now()}`);
43746
+ this._downloadDir = path3.join(this.tmpBaseDir, `playwright-downloads-${Date.now()}`);
43722
43747
  await fs3.mkdir(this._downloadDir, { recursive: true });
43723
43748
  this.logger.info("[DirectPlaywright] Launching browser", {
43724
43749
  browserMode: resolvedBrowserMode,
@@ -43997,7 +44022,7 @@ var PlaywrightClient = class _PlaywrightClient {
43997
44022
  });
43998
44023
  }
43999
44024
  if (hasExtensions) {
44000
- this.userDataDir = extensions.userDataDir || path3.join(getCanaryTmpDir(), `playwright-userdata-${Date.now()}`);
44025
+ this.userDataDir = extensions.userDataDir || path3.join(this.tmpBaseDir, `playwright-userdata-${Date.now()}`);
44001
44026
  this.shouldCleanupUserDataDir = !extensions.persistUserData;
44002
44027
  await fs3.mkdir(this.userDataDir, { recursive: true });
44003
44028
  if (browserMode === "headless") {
@@ -45196,7 +45221,7 @@ Use coordinate-based clicking (x, y) to interact with elements visible in the sc
45196
45221
  const timestamp = Date.now();
45197
45222
  const shortId = crypto.randomUUID().slice(0, 8);
45198
45223
  const filename = `snapshot-${timestamp}-${shortId}.yaml`;
45199
- const filePath = path3.join(getCanaryTmpDir(), filename);
45224
+ const filePath = path3.join(this.tmpBaseDir, filename);
45200
45225
  await fs3.writeFile(filePath, yaml, "utf-8");
45201
45226
  this.snapshotFilePaths.add(filePath);
45202
45227
  this.logger.debug("[DirectPlaywright] Wrote snapshot to disk", {
@@ -45341,7 +45366,7 @@ Use coordinate-based clicking (x, y) to interact with elements visible in the sc
45341
45366
  async startTracing(_opts) {
45342
45367
  const context = await this.getContext();
45343
45368
  this.logger.info("[DirectPlaywright] Starting trace recording");
45344
- this.traceDir = path3.join(getCanaryTmpDir(), `playwright-trace-${Date.now()}`);
45369
+ this.traceDir = path3.join(this.tmpBaseDir, `playwright-trace-${Date.now()}`);
45345
45370
  await fs3.mkdir(this.traceDir, { recursive: true });
45346
45371
  await context.tracing.start({ screenshots: true, snapshots: true });
45347
45372
  this.tracingActive = true;
@@ -46296,7 +46321,7 @@ Use coordinate-based clicking (x, y) to interact with elements visible in the sc
46296
46321
  */
46297
46322
  resolveVideoConfig(recordVideo) {
46298
46323
  if (!recordVideo) return null;
46299
- const dir = recordVideo === true || !recordVideo.dir ? path3.join(getCanaryTmpDir(), `playwright-video-${Date.now()}`) : recordVideo.dir;
46324
+ const dir = recordVideo === true || !recordVideo.dir ? path3.join(this.tmpBaseDir, `playwright-video-${Date.now()}`) : recordVideo.dir;
46300
46325
  const size = recordVideo !== true && recordVideo.size ? recordVideo.size : DEFAULT_VIEWPORT;
46301
46326
  return { dir, size };
46302
46327
  }
@@ -46890,4 +46915,4 @@ playwright-extra/dist/index.esm.js:
46890
46915
  * @license MIT
46891
46916
  *)
46892
46917
  */
46893
- //# sourceMappingURL=chunk-PDC425CK.js.map
46918
+ //# sourceMappingURL=chunk-RL5Y6V3C.js.map