@agenticmail/core 0.3.1 → 0.3.3

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/index.d.ts CHANGED
@@ -1271,7 +1271,14 @@ declare class DependencyInstaller {
1271
1271
  */
1272
1272
  installDocker(): Promise<void>;
1273
1273
  /**
1274
- * Wait for Docker daemon to be ready (up to 60s).
1274
+ * Attempt to start the Docker daemon.
1275
+ * On macOS: opens Docker Desktop app.
1276
+ * On Linux: tries systemctl.
1277
+ */
1278
+ private startDockerDaemon;
1279
+ /**
1280
+ * Wait for Docker daemon to be ready (up to 3 minutes).
1281
+ * Docker Desktop can take 1-2+ minutes on first launch.
1275
1282
  */
1276
1283
  private waitForDocker;
1277
1284
  /**
package/dist/index.js CHANGED
@@ -5453,19 +5453,8 @@ var DependencyInstaller = class {
5453
5453
  execSync2("docker info", { timeout: 1e4, stdio: "ignore" });
5454
5454
  return;
5455
5455
  } catch {
5456
- this.onProgress("Starting Docker daemon...");
5457
- const os2 = platform2();
5458
- if (os2 === "darwin") {
5459
- try {
5460
- execSync2("open -a Docker", { timeout: 1e4, stdio: "ignore" });
5461
- } catch {
5462
- }
5463
- } else if (os2 === "linux") {
5464
- try {
5465
- execSync2("sudo systemctl start docker", { timeout: 15e3, stdio: "ignore" });
5466
- } catch {
5467
- }
5468
- }
5456
+ this.onProgress("Docker found but not running \u2014 starting it now...");
5457
+ this.startDockerDaemon();
5469
5458
  await this.waitForDocker();
5470
5459
  return;
5471
5460
  }
@@ -5480,10 +5469,7 @@ var DependencyInstaller = class {
5480
5469
  }
5481
5470
  execSync2("brew install --cask docker", { timeout: 3e5, stdio: "inherit" });
5482
5471
  this.onProgress("Docker installed. Starting Docker Desktop...");
5483
- try {
5484
- execSync2("open -a Docker", { timeout: 1e4, stdio: "ignore" });
5485
- } catch {
5486
- }
5472
+ this.startDockerDaemon();
5487
5473
  await this.waitForDocker();
5488
5474
  } else if (os === "linux") {
5489
5475
  this.onProgress("Installing Docker...");
@@ -5498,21 +5484,49 @@ var DependencyInstaller = class {
5498
5484
  }
5499
5485
  }
5500
5486
  /**
5501
- * Wait for Docker daemon to be ready (up to 60s).
5487
+ * Attempt to start the Docker daemon.
5488
+ * On macOS: opens Docker Desktop app.
5489
+ * On Linux: tries systemctl.
5490
+ */
5491
+ startDockerDaemon() {
5492
+ const os = platform2();
5493
+ if (os === "darwin") {
5494
+ try {
5495
+ execSync2("open -a Docker", { timeout: 1e4, stdio: "ignore" });
5496
+ } catch {
5497
+ }
5498
+ } else if (os === "linux") {
5499
+ try {
5500
+ execSync2("sudo systemctl start docker", { timeout: 15e3, stdio: "ignore" });
5501
+ } catch {
5502
+ }
5503
+ }
5504
+ }
5505
+ /**
5506
+ * Wait for Docker daemon to be ready (up to 3 minutes).
5507
+ * Docker Desktop can take 1-2+ minutes on first launch.
5502
5508
  */
5503
5509
  async waitForDocker() {
5504
- this.onProgress("Waiting for Docker to be ready...");
5505
- const maxWait = 6e4;
5510
+ this.onProgress("Waiting for Docker to start (this can take a minute)...");
5511
+ const maxWait = 18e4;
5506
5512
  const start = Date.now();
5513
+ let attempts = 0;
5507
5514
  while (Date.now() - start < maxWait) {
5508
5515
  try {
5509
5516
  execSync2("docker info", { timeout: 5e3, stdio: "ignore" });
5510
5517
  return;
5511
5518
  } catch {
5512
5519
  }
5520
+ attempts++;
5521
+ if (attempts % 5 === 0) {
5522
+ const elapsed = Math.round((Date.now() - start) / 1e3);
5523
+ this.onProgress(`Still waiting for Docker to start (${elapsed}s)...`);
5524
+ }
5513
5525
  await new Promise((r) => setTimeout(r, 3e3));
5514
5526
  }
5515
- throw new Error("Docker is installed but the daemon did not start within 60s. Start Docker Desktop manually and try again.");
5527
+ throw new Error(
5528
+ "Docker daemon did not start in time. Open Docker Desktop manually, wait for it to finish loading, then run this again."
5529
+ );
5516
5530
  }
5517
5531
  /**
5518
5532
  * Start the Stalwart mail server Docker container.
@@ -5525,18 +5539,7 @@ var DependencyInstaller = class {
5525
5539
  execSync2("docker info", { timeout: 1e4, stdio: "ignore" });
5526
5540
  } catch {
5527
5541
  this.onProgress("Starting Docker...");
5528
- const os = platform2();
5529
- if (os === "darwin") {
5530
- try {
5531
- execSync2("open -a Docker", { timeout: 1e4, stdio: "ignore" });
5532
- } catch {
5533
- }
5534
- } else if (os === "linux") {
5535
- try {
5536
- execSync2("sudo systemctl start docker", { timeout: 15e3, stdio: "ignore" });
5537
- } catch {
5538
- }
5539
- }
5542
+ this.startDockerDaemon();
5540
5543
  await this.waitForDocker();
5541
5544
  }
5542
5545
  this.onProgress("Starting Stalwart mail server...");
@@ -5580,12 +5583,11 @@ var DependencyInstaller = class {
5580
5583
  await mkdir2(binDir, { recursive: true });
5581
5584
  const os = platform2();
5582
5585
  const cpu = arch2();
5583
- let downloadUrl;
5584
- if (os === "darwin") {
5585
- downloadUrl = cpu === "arm64" ? "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-arm64" : "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-amd64";
5586
- } else if (os === "linux") {
5587
- downloadUrl = cpu === "arm64" ? "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64" : "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64";
5588
- } else {
5586
+ const archName = cpu === "arm64" ? "arm64" : "amd64";
5587
+ const isTgz = os === "darwin";
5588
+ const ext = isTgz ? ".tgz" : "";
5589
+ const downloadUrl = `https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-${os}-${archName}${ext}`;
5590
+ if (os !== "darwin" && os !== "linux") {
5589
5591
  throw new Error(`Unsupported platform: ${os}/${cpu}`);
5590
5592
  }
5591
5593
  const response = await fetch(downloadUrl);
@@ -5593,10 +5595,27 @@ var DependencyInstaller = class {
5593
5595
  throw new Error(`Failed to download cloudflared: ${response.statusText}`);
5594
5596
  }
5595
5597
  const buffer = Buffer.from(await response.arrayBuffer());
5596
- const tmpPath = binPath + ".tmp";
5597
- await writeFile(tmpPath, buffer);
5598
- await chmod2(tmpPath, 493);
5599
- await rename(tmpPath, binPath);
5598
+ if (isTgz) {
5599
+ const tgzPath = join6(binDir, "cloudflared.tgz");
5600
+ await writeFile(tgzPath, buffer);
5601
+ try {
5602
+ execSync2(`tar -xzf "${tgzPath}" -C "${binDir}" cloudflared`, { timeout: 15e3, stdio: "ignore" });
5603
+ await chmod2(binPath, 493);
5604
+ } finally {
5605
+ try {
5606
+ execSync2(`rm -f "${tgzPath}"`, { stdio: "ignore" });
5607
+ } catch {
5608
+ }
5609
+ }
5610
+ } else {
5611
+ const tmpPath = binPath + ".tmp";
5612
+ await writeFile(tmpPath, buffer);
5613
+ await chmod2(tmpPath, 493);
5614
+ await rename(tmpPath, binPath);
5615
+ }
5616
+ if (!existsSync4(binPath)) {
5617
+ throw new Error("cloudflared download succeeded but binary not found after extraction");
5618
+ }
5600
5619
  this.onProgress("cloudflared installed");
5601
5620
  return binPath;
5602
5621
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/core",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Core SDK for AgenticMail — programmatic email for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",