@commonlyai/cli 0.1.288 → 0.1.289

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.288",
3
+ "version": "0.1.289",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -65,8 +65,9 @@ const jsonBody404 = (text) => {
65
65
  }
66
66
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return false;
67
67
  const error = parsed.error && typeof parsed.error === 'object' ? parsed.error : parsed;
68
- const is404 = [parsed.status, parsed.code, error.status, error.code]
69
- .some((value) => String(value) === '404') || error.type === 'not_found_error';
68
+ const statuses = [parsed.status, parsed.code, error.status, error.code];
69
+ if (statuses.some((value) => Number(value) >= 500)) return false;
70
+ const is404 = statuses.some((value) => String(value) === '404') || error.type === 'not_found_error';
70
71
  const message = error.message ?? parsed.message;
71
72
  return is404 && typeof message === 'string' && modelShaped(message);
72
73
  };
@@ -114,11 +115,13 @@ export const modelUnavailableFailure = (error, { fallbackModel = null } = {}) =>
114
115
  const lines = text.split('\n');
115
116
  const keyScope = NOT_AVAILABLE_FOR_KEY_RE.test(text) && (attached !== null ? attached === 403
116
117
  : lines.some((line) => STATUS_403_RE.test(line) && NOT_AVAILABLE_FOR_KEY_RE.test(line)));
118
+ // The attached status reads the message, so its model shape must be on the
119
+ // message's own first line, not in what later stderr happens to mention.
117
120
  const notFound = attached !== null
118
- ? attached === 404 && (lines.some(modelShaped) || jsonBody404(text))
121
+ ? attached === 404 && (modelShaped(String(error.message).split('\n')[0]) || jsonBody404(text))
119
122
  : sameLine404(text) || jsonBody404(text);
120
123
  const matched = keyScope
121
- || error.providerCode === 'model_not_found'
124
+ || (error.providerCode === 'model_not_found' && !(attached >= 500))
122
125
  || notFound;
123
126
  if (!matched) return null;
124
127
  for (const pattern of MODEL_NAME_RES) {
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { PUBLIC_MCP_NOT_READY_CODE, PUBLIC_TOOL_FAILED_CODE } from './public-tool-error.js';
11
11
  import { PUBLIC_CODEX_VERSION_CODE } from './adapters/tested-version.js';
12
+ import { modelUnavailableFailure } from './model-unavailable.js';
12
13
 
13
14
  export const SPAWN_FAILURE_CLASS = Object.freeze({
14
15
  // The provider refused the request's CONTENT. Re-sending the same content
@@ -125,6 +126,8 @@ const THROTTLE_WORDING_RE = /(?:rate[ -]?limit|too many requests|overloaded|capa
125
126
  const RATE_LIMIT_RE = /(?:rate[ -]?limit|too many requests|\b429\b|overloaded|capacity)/i;
126
127
  const CONFIGURATION_RE = /(?:ENOENT|command not found|not on PATH|login required|not logged in|invalid api key|authentication failed|unauthori[sz]ed|forbidden|\b40[13]\b)/i;
127
128
 
129
+ const CONNECTION_FAULT_RE = /(?:ECONNRESET|ECONNREFUSED|ETIMEDOUT|EPIPE|socket hang up|fetch failed)/;
130
+
128
131
  const errorText = (error) => [
129
132
  error?.message,
130
133
  error?.stderr,
@@ -170,11 +173,17 @@ export const classifySpawnFailure = (error) => {
170
173
  if (error?.status === 429 || RATE_LIMIT_RE.test(text)) {
171
174
  return SPAWN_FAILURE_CLASS.RATE_LIMIT;
172
175
  }
176
+ // A model the provider won't run fails the same way until someone changes it.
177
+ // A 403 for that reads as configuration below; a 404 has no status of its own
178
+ // there, so without this it retried in seconds against the same answer. A
179
+ // turn's text can hold a tool's 404 from before a dropped connection killed
180
+ // the turn, so a connection fault keeps the quick retry.
173
181
  if (
174
182
  error?.code === 'ENOENT'
175
183
  || error?.status === 401
176
184
  || error?.status === 403
177
185
  || CONFIGURATION_RE.test(text)
186
+ || (modelUnavailableFailure(error) && !CONNECTION_FAULT_RE.test(text))
178
187
  ) {
179
188
  return SPAWN_FAILURE_CLASS.CONFIGURATION;
180
189
  }