open-agents-ai 0.103.21 → 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.
Files changed (2) hide show
  1. package/dist/index.js +70 -27
  2. 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
- this._tunnelUrl = await this.startCloudflared(port);
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
- try {
27935
- this._tunnelUrl = await this.startCloudflared(this._proxyPort);
27936
- this._stats.status = "active";
27937
- this.emitStats();
27938
- this.options.onInfo?.(`Tunnel restarted with new URL \u2014 share with consumers:
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
- if (this._stateDir) {
27941
- writeExposeState(this._stateDir, {
27942
- pid: this._cloudflaredPid,
27943
- tunnelUrl: this._tunnelUrl,
27944
- authKey: this._authKey,
27945
- proxyPort: this._proxyPort,
27946
- targetUrl: this._targetUrl,
27947
- kind: this._kind,
27948
- startedAt: (/* @__PURE__ */ new Date()).toISOString()
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
  /**
@@ -29703,7 +29738,7 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
29703
29738
  }
29704
29739
  const resp = await fetch(url, {
29705
29740
  headers,
29706
- signal: AbortSignal.timeout(1e4)
29741
+ signal: AbortSignal.timeout(15e3)
29707
29742
  });
29708
29743
  if (!resp.ok) {
29709
29744
  throw new Error(`Failed to fetch models: HTTP ${resp.status}`);
@@ -29768,25 +29803,33 @@ async function fetchModels(baseUrl, apiKey) {
29768
29803
  }
29769
29804
  const provider = detectProvider(baseUrl);
29770
29805
  if (provider.id === "ollama") {
29806
+ let ollamaErr;
29771
29807
  try {
29772
29808
  return await fetchOllamaModels(baseUrl);
29773
- } catch {
29809
+ } catch (err) {
29810
+ ollamaErr = err instanceof Error ? err : new Error(String(err));
29774
29811
  try {
29775
29812
  return await fetchOpenAIModels(baseUrl, apiKey);
29776
29813
  } catch {
29777
- throw new Error("Cannot reach Ollama at " + baseUrl);
29814
+ throw new Error(`Cannot reach Ollama at ${baseUrl}: ${ollamaErr.message}`);
29778
29815
  }
29779
29816
  }
29780
29817
  }
29781
- try {
29782
- return await fetchOpenAIModels(baseUrl, apiKey);
29783
- } catch {
29818
+ let lastErr;
29819
+ for (let attempt = 0; attempt < 2; attempt++) {
29784
29820
  try {
29785
- return await fetchOllamaModels(baseUrl);
29786
- } catch {
29787
- throw new Error(`Cannot fetch models from ${provider.label} at ${baseUrl}`);
29821
+ return await fetchOpenAIModels(baseUrl, apiKey);
29822
+ } catch (err) {
29823
+ lastErr = err instanceof Error ? err : new Error(String(err));
29824
+ if (attempt === 0)
29825
+ await new Promise((r) => setTimeout(r, 1e3));
29788
29826
  }
29789
29827
  }
29828
+ try {
29829
+ return await fetchOllamaModels(baseUrl);
29830
+ } catch {
29831
+ throw new Error(`Cannot fetch models from ${provider.label} at ${baseUrl}: ${lastErr?.message ?? "unknown error"}`);
29832
+ }
29790
29833
  }
29791
29834
  function findModel(models, query) {
29792
29835
  const exact = models.find((m) => m.name === query);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.103.21",
3
+ "version": "0.103.23",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",