@commonlyai/cli 0.1.155 → 0.1.156

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.155",
3
+ "version": "0.1.156",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -27,6 +27,7 @@ export const SPAWN_RETRY_JITTER_MAX_RATIO = 0.2;
27
27
  // outage has already been misclassified. Twice now:
28
28
  // 2026-08-03 codex "Your workspace is out of credits." → `out of credits`
29
29
  // 2026-08-18 claude "You've hit your session limit" → `session limit`
30
+ // 2026-08-25 claude "You've hit your weekly limit" → the phrase below
30
31
  // The second one is the instructive failure: `usage limit` was already here —
31
32
  // it is Claude's OTHER exhaustion wording — so the fleet stalled for an hour on
32
33
  // a string one word away from a pattern we had. Both times the miss meant
@@ -62,7 +63,41 @@ export const SPAWN_RETRY_JITTER_MAX_RATIO = 0.2;
62
63
  // nothing else until the kernel retired the event. Only the refusal wordings
63
64
  // themselves are matched, so an ordinary failure that mentions a flag is not.
64
65
  const CONTENT_REFUSED_RE = /(?:flagged for possible cybersecurity risk|this content was flagged|content[_ ]policy[_ ]violation|cyber[_ ]policy)/i;
65
- const QUOTA_RE = /(?:quota|usage limit|session limit|credit balance|out of credits|billing|insufficient[_ -]?quota|resource exhausted|spending limit)/i;
66
+ // The third miss is why there is now a PHRASE as well as a word list, and it is
67
+ // a different failure from the first two. Measured across the fleet's logs on
68
+ // 2026-08-25: 283 failures reading "You've hit your weekly limit", 55 reading
69
+ // "You've hit your session limit" (matched), and 6 reading "You've reached your
70
+ // Fable 5 limit" (not matched). Three wordings, one sentence shape, and the list
71
+ // had caught exactly one of them. Enumerating per-wording keeps failing because
72
+ // the variable part is a BILLING PERIOD or a MODEL NAME, both of which the
73
+ // providers keep adding, so a list is structurally one release behind.
74
+ //
75
+ // `QUOTA_POSSESSIVE_RE` matches that shape and nothing looser: the subject must
76
+ // be the caller's own allowance ("you've hit/reached YOUR ... limit"), which is
77
+ // what distinguishes exhaustion from a server-side throttle. The negative
78
+ // lookahead keeps "you've hit your rate limit" out — QUOTA is tested first, and
79
+ // without it that string would take the 15-minute cooldown instead of the
80
+ // 60-second rate-limit backoff. The length bound stops it spanning sentences.
81
+ //
82
+ // The character class admits a dot ONLY when a digit follows it, and that
83
+ // carve-out is load-bearing rather than cosmetic (sprint-review, 2026-08-25):
84
+ // a plain `[^.\n]` reads as "stay inside one sentence" and silently also means
85
+ // "no model names". Every model we run is dotted, so "you've reached your Haiku
86
+ // 4.5 limit" fell through to RUNTIME, the shortest backoff — the class excluded
87
+ // the exact variable part this paragraph says keeps changing.
88
+ //
89
+ // Known limit of `\.(?=\d)`, kept rather than papered over: a period with a
90
+ // digit immediately after it is admitted even at a sentence boundary, so
91
+ // "You've reached your goal.5 things have no limit" classes as QUOTA. The space
92
+ // in ordinary prose ("goal. 5 things") is what terminates the match, and
93
+ // adjacent `.`+digit is rare enough in provider copy to accept. The test below
94
+ // pins what the pattern ACTUALLY has — a space after the period ends the match —
95
+ // rather than the stronger property it does not have.
96
+ const QUOTA_RE = /(?:quota|usage limit|session limit|weekly limit|credit balance|out of credits|billing|insufficient[_ -]?quota|resource exhausted|spending limit)/i;
97
+ const QUOTA_POSSESSIVE_RE = /you'?ve (?:hit|reached) your (?!rate[ -]?limit)(?:[^.\n]|\.(?=\d)){0,40}?limit/i;
98
+ // The status code is not a throttle wording: "429: You've reached your Fable 5
99
+ // limit" is an exhausted allowance that a provider reports as HTTP 429.
100
+ const THROTTLE_WORDING_RE = /(?:rate[ -]?limit|too many requests|overloaded|capacity)/i;
66
101
  const RATE_LIMIT_RE = /(?:rate[ -]?limit|too many requests|\b429\b|overloaded|capacity)/i;
67
102
  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;
68
103
 
@@ -85,6 +120,17 @@ export const classifySpawnFailure = (error) => {
85
120
  // Prefer the more specific body/message over the generic status code so a
86
121
  // hard quota failure gets the long cooldown rather than a one-minute probe.
87
122
  if (QUOTA_RE.test(text)) return SPAWN_FAILURE_CLASS.QUOTA;
123
+ // The possessive shape is deliberately loose about what sits between "your"
124
+ // and "limit", and its `(?!rate[ -]?limit)` lookahead only guards the word
125
+ // IMMEDIATELY after "your" — so "you've hit your API rate limit" walked past
126
+ // it into the 15-minute circuit, where main correctly gives the 60-second
127
+ // rate-limit probe (otto, gate on #2491; it was a regression, not a gap).
128
+ // A throttle wording anywhere in the text therefore wins over the shape.
129
+ // QUOTA_RE is still tested first, so an explicit quota word keeps QUOTA even
130
+ // when the same message also mentions rate limits.
131
+ if (QUOTA_POSSESSIVE_RE.test(text) && !THROTTLE_WORDING_RE.test(text)) {
132
+ return SPAWN_FAILURE_CLASS.QUOTA;
133
+ }
88
134
  if (error?.status === 429 || RATE_LIMIT_RE.test(text)) {
89
135
  return SPAWN_FAILURE_CLASS.RATE_LIMIT;
90
136
  }