@north-light/cli 0.3.718 → 0.3.719

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.
@@ -1,4 +1,4 @@
1
- export type ModelCooldownFamily = 'opus' | 'sonnet';
1
+ export type ModelCooldownFamily = 'opus' | 'sonnet' | 'haiku' | 'fable' | 'mythos';
2
2
  export type RateLimitScope = {
3
3
  kind: 'account';
4
4
  } | {
@@ -1 +1 @@
1
- var d=Object.defineProperty;var i=(e,t)=>d(e,"name",{value:t,configurable:!0});const m={seven_day_opus:"opus",seven_day_sonnet:"sonnet"},l=48,p=256;function y(e){if(e){if(/opus/i.test(e))return"opus";if(/sonnet/i.test(e))return"sonnet"}}i(y,"modelCooldownFamily");function L(e){return e?typeof Headers<"u"&&e instanceof Headers?[...e.entries()]:Object.entries(e).filter(t=>typeof t[1]=="string"):[]}i(L,"entries");function _(e){return e.startsWith("anthropic-ratelimit-")||e.startsWith("x-ratelimit-")||e==="retry-after"||e==="retry-after-ms"}i(_,"isRateLimitHeader");function b(e){const t={};for(const[s,r]of L(e)){const n=s.toLowerCase();if(_(n)){if(Object.keys(t).length>=l)break;t[n]=r.slice(0,p)}}return t}i(b,"rateLimitHeaders");function k(e,t,s=Date.now()){const r=b(e),n=r["anthropic-ratelimit-unified-representative-claim"]?.trim()||void 0,u=r["anthropic-ratelimit-unified-status"]?.trim()==="rejected",o=Number(r["anthropic-ratelimit-unified-reset"]),a=u&&Number.isFinite(o)&&o>0&&o*1e3>s?o*1e3:void 0,c=n===void 0?void 0:m[n],f=y(t);return{scope:u&&c!==void 0&&c===f?{kind:"model",family:c}:{kind:"account"},...n!==void 0?{claim:n}:{},...a!==void 0?{resetAt:a}:{},headers:r}}i(k,"classifyRateLimit");function x(e){return e.kind==="account"?"account":`model:${e.family}`}i(x,"describeRateLimitScope");export{k as classifyRateLimit,x as describeRateLimitScope,y as modelCooldownFamily,b as rateLimitHeaders};
1
+ var _=Object.defineProperty;var o=(e,t)=>_(e,"name",{value:t,configurable:!0});const h={seven_day_opus:"opus",seven_day_sonnet:"sonnet"},L=new Set(["five_hour","seven_day","seven_day_overage_included","overage"]),v=["opus","sonnet","haiku","fable","mythos"],w=48,A=256;function k(e){if(!e)return;const t=e.toLowerCase();return v.find(r=>t.includes(r))}o(k,"modelCooldownFamily");function b(e){return e?typeof Headers<"u"&&e instanceof Headers?[...e.entries()]:Object.entries(e).filter(t=>typeof t[1]=="string"):[]}o(b,"entries");function C(e){return e.startsWith("anthropic-ratelimit-")||e.startsWith("x-ratelimit-")||e==="retry-after"||e==="retry-after-ms"}o(C,"isRateLimitHeader");function S(e){const t={};for(const[r,i]of b(e)){const n=r.toLowerCase();if(C(n)){if(Object.keys(t).length>=w)break;t[n]=i.slice(0,A)}}return t}o(S,"rateLimitHeaders");function M(e,t,r=Date.now()){const i=S(e),n=i["anthropic-ratelimit-unified-representative-claim"]?.trim()||void 0,u=i["anthropic-ratelimit-unified-status"]?.trim()==="rejected",s=Number(i["anthropic-ratelimit-unified-reset"]),a=u&&Number.isFinite(s)&&s>0&&s*1e3>r?s*1e3:void 0,d=n===void 0?void 0:h[n],c=k(t),f=i["anthropic-ratelimit-unified-7d-status"]?.trim(),l=i["anthropic-ratelimit-unified-5h-status"]?.trim(),p=f!==void 0&&f!=="rejected"&&l!=="rejected",y=n!==void 0&&d===void 0&&!L.has(n),m=d!==void 0?d===c?c:void 0:y&&p?c:void 0;return{scope:u&&m!==void 0?{kind:"model",family:m}:{kind:"account"},...n!==void 0?{claim:n}:{},...a!==void 0?{resetAt:a}:{},headers:i}}o(M,"classifyRateLimit");function x(e){return e.kind==="account"?"account":`model:${e.family}`}o(x,"describeRateLimitScope");export{M as classifyRateLimit,x as describeRateLimitScope,k as modelCooldownFamily,S as rateLimitHeaders};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.718",
3
+ "version": "0.3.719",
4
4
  "description": "crtr — agent runtime with memory, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,8 +158,8 @@
158
158
  },
159
159
  "license": "UNLICENSED",
160
160
  "dependencies": {
161
- "@north-light/identity": "0.3.718",
162
- "@north-light/plugin": "0.3.718",
161
+ "@north-light/identity": "0.3.719",
162
+ "@north-light/plugin": "0.3.719",
163
163
  "@earendil-works/chord": "1.5.2",
164
164
  "@earendil-works/pi-agent-core": "1.5.2",
165
165
  "@earendil-works/pi-ai": "1.5.2",
@@ -5,24 +5,28 @@
5
5
  // headers. `-status` is `allowed` | `allowed_warning` | `rejected`;
6
6
  // `-representative-claim` names the binding window (`five_hour`, `seven_day`,
7
7
  // `seven_day_opus`, `seven_day_sonnet`, `seven_day_overage_included`,
8
- // `overage`, …); `-reset` is the epoch second it frees up. The grammar is read
9
- // from Claude Code's client, not from published docs, so the classifier fails
10
- // safe: only a rejected response whose claim is a per-model weekly window that
11
- // matches the requested model's family is model-scoped. Anything else —
12
- // unknown claims, missing status, a claim for a different family, other
13
- // providers — cools the whole account exactly as before.
8
+ // `overage`, …); `-reset` is the epoch second it frees up; `-5h-status` and
9
+ // `-7d-status` report the account-wide windows on their own. The grammar is
10
+ // read from Claude Code's client, not from published docs, so the classifier
11
+ // fails safe. A rejected response is model-scoped when its claim is a known
12
+ // per-model weekly window matching the requested model's family, or when its
13
+ // claim is not a known account-wide window and the response itself reports the
14
+ // account-wide weekly window as not rejected (a per-model window such as the
15
+ // Fable weekly cap, whatever its claim is called). Anything else — missing
16
+ // status, no account-window evidence, a known window for a different family,
17
+ // models with no family, other providers — cools the whole account.
14
18
  const MODEL_CLAIMS = { seven_day_opus: 'opus', seven_day_sonnet: 'sonnet' };
19
+ /** Claims that name an account-wide window: never model-scoped, whatever the per-window statuses say. */
20
+ const ACCOUNT_CLAIMS = new Set(['five_hour', 'seven_day', 'seven_day_overage_included', 'overage']);
21
+ const FAMILIES = ['opus', 'sonnet', 'haiku', 'fable', 'mythos'];
15
22
  const MAX_HEADERS = 48;
16
23
  const MAX_VALUE = 256;
17
24
  /** The cooldown family a model id belongs to, or undefined when only account-wide cooldowns apply to it. */
18
25
  export function modelCooldownFamily(modelId) {
19
26
  if (!modelId)
20
27
  return undefined;
21
- if (/opus/i.test(modelId))
22
- return 'opus';
23
- if (/sonnet/i.test(modelId))
24
- return 'sonnet';
25
- return undefined;
28
+ const id = modelId.toLowerCase();
29
+ return FAMILIES.find((family) => id.includes(family));
26
30
  }
27
31
  function entries(headers) {
28
32
  if (!headers)
@@ -56,7 +60,13 @@ export function classifyRateLimit(headers, modelId, now = Date.now()) {
56
60
  const resetAt = rejected && Number.isFinite(resetSeconds) && resetSeconds > 0 && resetSeconds * 1000 > now ? resetSeconds * 1000 : undefined;
57
61
  const claimed = claim === undefined ? undefined : MODEL_CLAIMS[claim];
58
62
  const family = modelCooldownFamily(modelId);
59
- const scope = rejected && claimed !== undefined && claimed === family ? { kind: 'model', family: claimed } : { kind: 'account' };
63
+ // The response reports the account-wide weekly window and it is not what refused the call (the five-hour window, when reported, neither).
64
+ const weekly = recorded['anthropic-ratelimit-unified-7d-status']?.trim();
65
+ const fiveHour = recorded['anthropic-ratelimit-unified-5h-status']?.trim();
66
+ const accountWindowsOpen = weekly !== undefined && weekly !== 'rejected' && fiveHour !== 'rejected';
67
+ const unknownWindow = claim !== undefined && claimed === undefined && !ACCOUNT_CLAIMS.has(claim);
68
+ const scopedFamily = claimed !== undefined ? (claimed === family ? family : undefined) : unknownWindow && accountWindowsOpen ? family : undefined;
69
+ const scope = rejected && scopedFamily !== undefined ? { kind: 'model', family: scopedFamily } : { kind: 'account' };
60
70
  return { scope, ...(claim !== undefined ? { claim } : {}), ...(resetAt !== undefined ? { resetAt } : {}), headers: recorded };
61
71
  }
62
72
  export function describeRateLimitScope(scope) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.718",
3
+ "version": "0.3.719",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.718",
3
+ "version": "0.3.719",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.718",
3
+ "version": "0.3.719",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
28
28
  },
29
29
  "dependencies": {
30
- "@north-light/api": "0.3.718",
31
- "@north-light/identity": "0.3.718"
30
+ "@north-light/api": "0.3.719",
31
+ "@north-light/identity": "0.3.719"
32
32
  },
33
33
  "license": "UNLICENSED",
34
34
  "publishConfig": {
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.718",
3
+ "version": "0.3.719",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.718",
9
+ "version": "0.3.719",
10
10
  "hasInstallScript": true,
11
11
  "license": "UNLICENSED",
12
12
  "workspaces": [
@@ -28,8 +28,8 @@
28
28
  "@milkdown/preset-gfm": "^7.22.3",
29
29
  "@milkdown/prose": "^7.22.3",
30
30
  "@milkdown/utils": "^7.22.3",
31
- "@north-light/identity": "0.3.718",
32
- "@north-light/plugin": "0.3.718",
31
+ "@north-light/identity": "0.3.719",
32
+ "@north-light/plugin": "0.3.719",
33
33
  "cron-parser": "^5.6.0",
34
34
  "esbuild": "0.28.2",
35
35
  "jose": "^6.2.12",
@@ -11902,17 +11902,17 @@
11902
11902
  },
11903
11903
  "packages/crouter-api": {
11904
11904
  "name": "@north-light/api",
11905
- "version": "0.3.718",
11905
+ "version": "0.3.719",
11906
11906
  "license": "UNLICENSED"
11907
11907
  },
11908
11908
  "packages/crouter-env-docker": {
11909
11909
  "name": "@north-light/env-docker",
11910
- "version": "0.3.718",
11910
+ "version": "0.3.719",
11911
11911
  "license": "UNLICENSED"
11912
11912
  },
11913
11913
  "packages/crouter-identity": {
11914
11914
  "name": "@north-light/identity",
11915
- "version": "0.3.718",
11915
+ "version": "0.3.719",
11916
11916
  "license": "UNLICENSED",
11917
11917
  "dependencies": {
11918
11918
  "jose": "^6.2.1"
@@ -11920,21 +11920,21 @@
11920
11920
  },
11921
11921
  "packages/crouter-plugin": {
11922
11922
  "name": "@north-light/plugin",
11923
- "version": "0.3.718",
11923
+ "version": "0.3.719",
11924
11924
  "license": "UNLICENSED",
11925
11925
  "dependencies": {
11926
- "@north-light/api": "0.3.718",
11927
- "@north-light/identity": "0.3.718"
11926
+ "@north-light/api": "0.3.719",
11927
+ "@north-light/identity": "0.3.719"
11928
11928
  }
11929
11929
  },
11930
11930
  "packages/crouter-sdk": {
11931
11931
  "name": "@north-light/sdk",
11932
- "version": "0.3.718",
11932
+ "version": "0.3.719",
11933
11933
  "license": "UNLICENSED",
11934
11934
  "dependencies": {
11935
- "@north-light/api": "0.3.718",
11936
- "@north-light/identity": "0.3.718",
11937
- "@north-light/plugin": "0.3.718",
11935
+ "@north-light/api": "0.3.719",
11936
+ "@north-light/identity": "0.3.719",
11937
+ "@north-light/plugin": "0.3.719",
11938
11938
  "jose": "^6.2.1"
11939
11939
  },
11940
11940
  "bin": {