open-agents-ai 0.103.22 → 0.103.23
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.js +53 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27508,7 +27508,30 @@ var init_expose = __esm({
|
|
|
27508
27508
|
this.server.listen(port, "127.0.0.1", () => resolve31());
|
|
27509
27509
|
this.server.on("error", reject);
|
|
27510
27510
|
});
|
|
27511
|
-
|
|
27511
|
+
let lastStartErr;
|
|
27512
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
27513
|
+
try {
|
|
27514
|
+
this._tunnelUrl = await this.startCloudflared(port);
|
|
27515
|
+
break;
|
|
27516
|
+
} catch (err) {
|
|
27517
|
+
lastStartErr = err instanceof Error ? err : new Error(String(err));
|
|
27518
|
+
const is429 = lastStartErr.message.includes("429") || lastStartErr.message.includes("Too Many Requests");
|
|
27519
|
+
if (is429 && attempt < 2) {
|
|
27520
|
+
const delaySec = (attempt + 1) * 15;
|
|
27521
|
+
this.options.onInfo?.(`Cloudflare rate limited \u2014 retrying in ${delaySec}s (attempt ${attempt + 2}/3)...`);
|
|
27522
|
+
await new Promise((r) => setTimeout(r, delaySec * 1e3));
|
|
27523
|
+
continue;
|
|
27524
|
+
}
|
|
27525
|
+
if (this.server) {
|
|
27526
|
+
await new Promise((r) => this.server.close(() => r()));
|
|
27527
|
+
this.server = null;
|
|
27528
|
+
}
|
|
27529
|
+
throw lastStartErr;
|
|
27530
|
+
}
|
|
27531
|
+
}
|
|
27532
|
+
if (!this._tunnelUrl) {
|
|
27533
|
+
throw lastStartErr ?? new Error("Cloudflared tunnel start failed after retries");
|
|
27534
|
+
}
|
|
27512
27535
|
this._stats.status = "active";
|
|
27513
27536
|
this.emitStats();
|
|
27514
27537
|
if (this._stateDir) {
|
|
@@ -27931,25 +27954,37 @@ var init_expose = __esm({
|
|
|
27931
27954
|
async restartCloudflared() {
|
|
27932
27955
|
if (!this.server || this._proxyPort === 0)
|
|
27933
27956
|
return;
|
|
27934
|
-
|
|
27935
|
-
|
|
27936
|
-
|
|
27937
|
-
|
|
27938
|
-
|
|
27957
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
27958
|
+
try {
|
|
27959
|
+
this._tunnelUrl = await this.startCloudflared(this._proxyPort);
|
|
27960
|
+
this._stats.status = "active";
|
|
27961
|
+
this.emitStats();
|
|
27962
|
+
this.options.onInfo?.(`Tunnel restarted with new URL \u2014 share with consumers:
|
|
27939
27963
|
${this.formatConnectionInfo()}`);
|
|
27940
|
-
|
|
27941
|
-
|
|
27942
|
-
|
|
27943
|
-
|
|
27944
|
-
|
|
27945
|
-
|
|
27946
|
-
|
|
27947
|
-
|
|
27948
|
-
|
|
27949
|
-
|
|
27964
|
+
if (this._stateDir) {
|
|
27965
|
+
writeExposeState(this._stateDir, {
|
|
27966
|
+
pid: this._cloudflaredPid,
|
|
27967
|
+
tunnelUrl: this._tunnelUrl,
|
|
27968
|
+
authKey: this._authKey,
|
|
27969
|
+
proxyPort: this._proxyPort,
|
|
27970
|
+
targetUrl: this._targetUrl,
|
|
27971
|
+
kind: this._kind,
|
|
27972
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
27973
|
+
});
|
|
27974
|
+
}
|
|
27975
|
+
return;
|
|
27976
|
+
} catch (err) {
|
|
27977
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
27978
|
+
const is429 = msg.includes("429") || msg.includes("Too Many Requests");
|
|
27979
|
+
if (is429 && attempt < 2) {
|
|
27980
|
+
const delaySec = (attempt + 1) * 15;
|
|
27981
|
+
this.options.onInfo?.(`Cloudflare rate limited \u2014 retrying in ${delaySec}s...`);
|
|
27982
|
+
await new Promise((r) => setTimeout(r, delaySec * 1e3));
|
|
27983
|
+
continue;
|
|
27984
|
+
}
|
|
27985
|
+
this.options.onError?.(`Tunnel restart failed: ${msg}`);
|
|
27986
|
+
return;
|
|
27950
27987
|
}
|
|
27951
|
-
} catch (err) {
|
|
27952
|
-
this.options.onError?.(`Tunnel restart failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
27953
27988
|
}
|
|
27954
27989
|
}
|
|
27955
27990
|
/**
|
package/package.json
CHANGED