@openlimiter/connectors 0.4.0 → 1.3.1

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 (53) hide show
  1. package/dist/antigravity.d.ts +25 -5
  2. package/dist/antigravity.d.ts.map +1 -1
  3. package/dist/antigravity.js +56 -25
  4. package/dist/antigravity.js.map +1 -1
  5. package/dist/claude.d.ts +59 -20
  6. package/dist/claude.d.ts.map +1 -1
  7. package/dist/claude.js +452 -53
  8. package/dist/claude.js.map +1 -1
  9. package/dist/codex.d.ts +3 -20
  10. package/dist/codex.d.ts.map +1 -1
  11. package/dist/codex.js +99 -18
  12. package/dist/codex.js.map +1 -1
  13. package/dist/contract-gate.d.ts +56 -0
  14. package/dist/contract-gate.d.ts.map +1 -0
  15. package/dist/contract-gate.js +100 -0
  16. package/dist/contract-gate.js.map +1 -0
  17. package/dist/fixtures.d.ts +19 -0
  18. package/dist/fixtures.d.ts.map +1 -1
  19. package/dist/fixtures.js +213 -34
  20. package/dist/fixtures.js.map +1 -1
  21. package/dist/gemini-cli.d.ts +13 -0
  22. package/dist/gemini-cli.d.ts.map +1 -0
  23. package/dist/gemini-cli.js +86 -0
  24. package/dist/gemini-cli.js.map +1 -0
  25. package/dist/grok.d.ts +13 -0
  26. package/dist/grok.d.ts.map +1 -0
  27. package/dist/grok.js +143 -0
  28. package/dist/grok.js.map +1 -0
  29. package/dist/index.d.ts +4 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +10 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/kimi.d.ts +13 -0
  34. package/dist/kimi.d.ts.map +1 -0
  35. package/dist/kimi.js +141 -0
  36. package/dist/kimi.js.map +1 -0
  37. package/dist/manual.d.ts +3 -1
  38. package/dist/manual.d.ts.map +1 -1
  39. package/dist/manual.js +6 -3
  40. package/dist/manual.js.map +1 -1
  41. package/dist/opencode.d.ts +47 -7
  42. package/dist/opencode.d.ts.map +1 -1
  43. package/dist/opencode.js +203 -67
  44. package/dist/opencode.js.map +1 -1
  45. package/dist/openrouter.d.ts +3 -1
  46. package/dist/openrouter.d.ts.map +1 -1
  47. package/dist/openrouter.js +6 -3
  48. package/dist/openrouter.js.map +1 -1
  49. package/dist/shared.d.ts +17 -1
  50. package/dist/shared.d.ts.map +1 -1
  51. package/dist/shared.js +24 -0
  52. package/dist/shared.js.map +1 -1
  53. package/package.json +4 -3
@@ -1,4 +1,4 @@
1
- import type { ConnectorContract, RawMeter } from "@openlimiter/core";
1
+ import type { ConnectionTool, ConnectorContract, RawMeter } from "@openlimiter/core";
2
2
  /**
3
3
  * The Antigravity quota reader.
4
4
  *
@@ -47,11 +47,10 @@ export declare const ANTIGRAVITY_TRACKED_POOL = "gemini";
47
47
  */
48
48
  export declare const ANTIGRAVITY_WINDOWS: Readonly<Record<string, number>>;
49
49
  /**
50
- * The tracked pool's binding window, as one meter.
50
+ * Every documented window in the tracked pool, as its own meter.
51
51
  *
52
- * One meter rather than one per window, matching what the reference reader's
53
- * bar shows and what the registry declares: the BINDING window, meaning the one
54
- * with the highest usage, because that is the one that will stop the work.
52
+ * The shell may still derive one binding percentage for advice and the tray,
53
+ * but the dashboard must not discard the other window to get there.
55
54
  *
56
55
  * The third party pool that rides the same subscription is deliberately not
57
56
  * modelled. It is a real second wallet, and reporting it under this provider's
@@ -59,5 +58,26 @@ export declare const ANTIGRAVITY_WINDOWS: Readonly<Record<string, number>>;
59
58
  * identity in the registry before it can have one here.
60
59
  */
61
60
  export declare function parseAntigravityPayload(payload: unknown, now: string): RawMeter[] | null;
61
+ /**
62
+ * The same Code Assist quota document, read under this provider's name.
63
+ *
64
+ * Antigravity and Gemini CLI sit on one Google Code Assist backend and answer
65
+ * the same per model quota shape, so `parseGeminiCliPayload` above already
66
+ * knows how to read it. What differs is WHOSE credential asked and therefore
67
+ * which row a person is looking at, and that is a provider code, not a parser.
68
+ *
69
+ * The rename is exact rather than approximate: the two label sets are field for
70
+ * field identical, so nothing about the reading's honesty changes when the
71
+ * provider does. Duplicating the bucket reader to achieve the same thing would
72
+ * mean two parsers to keep in step with one backend, which is how one of them
73
+ * ends up silently behind.
74
+ *
75
+ * This is the shape the network path reads. The group and bucket summary the
76
+ * `parseAntigravityPayload` reader above handles is a different document from
77
+ * the same family and stays exactly as it was.
78
+ */
79
+ export declare function parseAntigravityCodeAssistPayload(payload: unknown, now: string): RawMeter[] | null;
80
+ /** The local application that owns this credential. */
81
+ export declare const ANTIGRAVITY_TOOL: ConnectionTool;
62
82
  export declare const antigravityConnector: ConnectorContract;
63
83
  //# sourceMappingURL=antigravity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"antigravity.d.ts","sourceRoot":"","sources":["../src/antigravity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAU3B;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,iBAAiB;;;;;CAKM,CAAC;AAErC,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,EAAG,MAAe,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGhE,CAAC;AAuDF;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GACV,QAAQ,EAAE,GAAG,IAAI,CAsCnB;AAED,eAAO,MAAM,oBAAoB,EAAE,iBAclC,CAAC"}
1
+ {"version":3,"file":"antigravity.d.ts","sourceRoot":"","sources":["../src/antigravity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAY3B;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,iBAAiB;;;;;CAKM,CAAC;AAErC,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,EAAG,MAAe,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGhE,CAAC;AA6DF;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GACV,QAAQ,EAAE,GAAG,IAAI,CAkCnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GACV,QAAQ,EAAE,GAAG,IAAI,CAQnB;AAED,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,EAAE,cAA8B,CAAC;AAE9D,eAAO,MAAM,oBAAoB,EAAE,iBAmBlC,CAAC"}
@@ -1,4 +1,5 @@
1
- import { boundedFraction, futureInstantFromRfc3339, plausibleResetHorizon, rawMeter, record, shortExpiry } from "./shared.js";
1
+ import { parseGeminiCliPayload } from "./gemini-cli.js";
2
+ import { boundedFraction, connectorConnection, futureInstantFromRfc3339, plausibleResetHorizon, rawMeter, record, shortExpiry } from "./shared.js";
2
3
  /**
3
4
  * The Antigravity quota reader.
4
5
  *
@@ -77,7 +78,12 @@ function readBuckets(buckets, now) {
77
78
  than a quota bar can show. Clamped, because floating point subtraction
78
79
  of a fraction can land a hair outside the range. */
79
80
  const percent = Math.round(Math.max(0, Math.min(100, (1 - fraction) * 100)) * 10) / 10;
80
- windows.push({ percent, seconds, resetAt });
81
+ windows.push({
82
+ meter: name.toLowerCase() === "5h" ? "FIVE_HOUR" : "SEVEN_DAY",
83
+ percent,
84
+ seconds,
85
+ resetAt
86
+ });
81
87
  }
82
88
  return windows.length === 0 ? null : windows;
83
89
  }
@@ -99,11 +105,10 @@ function poolPrefixes(buckets) {
99
105
  return prefixes;
100
106
  }
101
107
  /**
102
- * The tracked pool's binding window, as one meter.
108
+ * Every documented window in the tracked pool, as its own meter.
103
109
  *
104
- * One meter rather than one per window, matching what the reference reader's
105
- * bar shows and what the registry declares: the BINDING window, meaning the one
106
- * with the highest usage, because that is the one that will stop the work.
110
+ * The shell may still derive one binding percentage for advice and the tray,
111
+ * but the dashboard must not discard the other window to get there.
107
112
  *
108
113
  * The third party pool that rides the same subscription is deliberately not
109
114
  * modelled. It is a real second wallet, and reporting it under this provider's
@@ -141,24 +146,49 @@ export function parseAntigravityPayload(payload, now) {
141
146
  const expiresAt = shortExpiry(now);
142
147
  if (expiresAt === null)
143
148
  return null;
144
- let binding = tracked[0];
145
- for (const candidate of tracked.slice(1)) {
146
- if (candidate.percent > binding.percent)
147
- binding = candidate;
148
- }
149
- return [rawMeter({
150
- provider: "ANTIGRAVITY",
151
- meter: "PRIMARY",
152
- value: binding.percent,
153
- window: { kind: "rolling", durationSeconds: binding.seconds },
154
- resetAt: binding.resetAt,
155
- source: "internal_payload",
156
- precision: "estimated",
157
- observedAt: now,
158
- expiresAt,
159
- labels: antigravityLabels
160
- })];
149
+ return tracked.map((candidate) => rawMeter({
150
+ provider: "ANTIGRAVITY",
151
+ meter: candidate.meter,
152
+ value: candidate.percent,
153
+ window: { kind: "rolling", durationSeconds: candidate.seconds },
154
+ resetAt: candidate.resetAt,
155
+ source: "internal_payload",
156
+ precision: "estimated",
157
+ observedAt: now,
158
+ expiresAt,
159
+ labels: antigravityLabels
160
+ }));
161
+ }
162
+ /**
163
+ * The same Code Assist quota document, read under this provider's name.
164
+ *
165
+ * Antigravity and Gemini CLI sit on one Google Code Assist backend and answer
166
+ * the same per model quota shape, so `parseGeminiCliPayload` above already
167
+ * knows how to read it. What differs is WHOSE credential asked and therefore
168
+ * which row a person is looking at, and that is a provider code, not a parser.
169
+ *
170
+ * The rename is exact rather than approximate: the two label sets are field for
171
+ * field identical, so nothing about the reading's honesty changes when the
172
+ * provider does. Duplicating the bucket reader to achieve the same thing would
173
+ * mean two parsers to keep in step with one backend, which is how one of them
174
+ * ends up silently behind.
175
+ *
176
+ * This is the shape the network path reads. The group and bucket summary the
177
+ * `parseAntigravityPayload` reader above handles is a different document from
178
+ * the same family and stays exactly as it was.
179
+ */
180
+ export function parseAntigravityCodeAssistPayload(payload, now) {
181
+ const meters = parseGeminiCliPayload(payload, now);
182
+ if (meters === null)
183
+ return null;
184
+ return meters.map((meter) => ({
185
+ ...meter,
186
+ provider: "ANTIGRAVITY",
187
+ labels: antigravityLabels
188
+ }));
161
189
  }
190
+ /** The local application that owns this credential. */
191
+ export const ANTIGRAVITY_TOOL = "Antigravity";
162
192
  export const antigravityConnector = {
163
193
  id: "antigravity",
164
194
  displayName: "Antigravity",
@@ -169,9 +199,10 @@ export const antigravityConnector = {
169
199
  },
170
200
  async read(context) {
171
201
  const meters = parseAntigravityPayload(context.payload, context.now);
202
+ const connection = connectorConnection(meters !== null, context.payload, ANTIGRAVITY_TOOL);
172
203
  return meters === null
173
- ? { ok: false, reason: "unknown" }
174
- : { ok: true, meters };
204
+ ? { ok: false, reason: "unknown", connection }
205
+ : { ok: true, meters, connection };
175
206
  }
176
207
  };
177
208
  //# sourceMappingURL=antigravity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"antigravity.js","sourceRoot":"","sources":["../src/antigravity.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,QAAQ,EACR,MAAM,EACN,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,gBAAgB,EAAE,qBAAqB;IACvC,mBAAmB,EAAE,mBAAmB;IACxC,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,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,CAAC;QACF,OAAO,MAAM,KAAK,IAAI;YACpB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE;YAC9C,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IACvC,CAAC;CACF,CAAC"}
package/dist/claude.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ConnectorContract, RawMeter } from "@openlimiter/core";
1
+ import type { ConnectionTool, ConnectorContract, RawMeter } from "@openlimiter/core";
2
2
  export declare const claudeLabels: {
3
3
  readonly credentialOrigin: "official-local-tool";
4
4
  readonly dataInterfaceStatus: "native-statusline-payload";
@@ -11,41 +11,80 @@ export declare const claudeInput: {
11
11
  readonly readMode: "read_only";
12
12
  };
13
13
  /**
14
- * Parse the rate limit block of a Claude Code statusline payload.
14
+ * The longest a window this reader was never told the length of may run.
15
15
  *
16
- * Documented shape, from https://code.claude.com/docs/en/statusline
17
- * reviewed 2026-08-10:
16
+ * A bucket whose key spells out no cadence still needs SOME plausibility bound,
17
+ * or a corrupt reset becomes a countdown to the year 2038. A month is the
18
+ * longest subscription window any provider in this product uses, so a reset
19
+ * beyond it is a corrupt field rather than a long wait.
20
+ */
21
+ export declare const CLAUDE_UNKNOWN_WINDOW_SECONDS = 2678400;
22
+ /** The prefix every model scoped weekly bucket's code is built on. */
23
+ export declare const CLAUDE_MODEL_WEEKLY_PREFIX = "SEVEN_DAY_";
24
+ /** Longest source string this reader will turn into a meter code. */
25
+ export declare const MAX_METER_CODE_SOURCE_CHARS = 64;
26
+ /**
27
+ * Parse a Claude usage document, in either shape the same credential produces.
28
+ *
29
+ * SHAPE ONE, the statusline payload, from
30
+ * https://code.claude.com/docs/en/statusline and observed on Claude Code
31
+ * 2.1.261 on 2026-09-04:
18
32
  *
19
33
  * ```json
20
34
  * {
21
35
  * "rate_limits": {
22
- * "five_hour": { "used_percentage": 23.5, "resets_at": 1738425600 },
23
- * "seven_day": { "used_percentage": 41.2, "resets_at": 1738857600 }
36
+ * "five_hour": { "used_percentage": 23.5, "resets_at": 1738425600 },
37
+ * "seven_day": { "used_percentage": 41.2, "resets_at": 1738857600 },
38
+ * "seven_day_oauth_apps": { "used_percentage": 3.1, "resets_at": 1738857600 },
39
+ * "seven_day_opus": { "used_percentage": 61.0, "resets_at": 1738857600 },
40
+ * "seven_day_sonnet": { "used_percentage": 12.4, "resets_at": 1738857600 },
41
+ * "model_scoped": [
42
+ * { "display_name": "Fable 5", "utilization": 12, "resets_at": "2026-09-11T00:00:00Z" }
43
+ * ]
24
44
  * }
25
45
  * }
26
46
  * ```
27
47
  *
28
- * `used_percentage` is the share of the window consumed, from 0 to 100.
29
- * `resets_at` is Unix epoch SECONDS, a number, not a date string.
48
+ * SHAPE TWO, the `api/oauth/usage` document, which is what `openlimiter ingest`
49
+ * is handed. Its windows sit at the root, state `utilization` and an ISO reset,
50
+ * and it carries two things the statusline does not: an `extra_usage` pool
51
+ * stated in money, and a `limits` list of model scoped weekly buckets:
52
+ *
53
+ * ```json
54
+ * {
55
+ * "five_hour": { "utilization": 90, "resets_at": "2026-09-04T17:00:00Z" },
56
+ * "seven_day": { "utilization": 18, "resets_at": "2026-09-09T00:00:00Z" },
57
+ * "extra_usage": { "used_amount": 12.47, "limit_amount": 20, "currency": "USD" },
58
+ * "limits": [
59
+ * {
60
+ * "kind": "weekly_scoped",
61
+ * "percent": 61,
62
+ * "resets_at": "2026-09-09T00:00:00Z",
63
+ * "scope": { "model": { "display_name": "Opus" } }
64
+ * }
65
+ * ]
66
+ * }
67
+ * ```
68
+ *
69
+ * Refusing the second shape was finding F-201: a real document, from a real
70
+ * account, over a healthy connection, answered null because this parser knew
71
+ * only `used_percentage` and only epoch seconds.
30
72
  *
31
73
  * Three absences the documentation states, and none of them is an error:
32
74
  *
33
75
  * 1. `rate_limits` appears only for Claude.ai subscribers on Pro or Max, and
34
- * only after the first API response in the session. A payload without it is
35
- * an ordinary payload from a free account or a session that has not called
36
- * the API yet.
37
- * 2. Each window may be independently absent, so one present window is one
76
+ * only after the first API response in the session. A payload without it and
77
+ * without any usage document field is an ordinary payload from a free
78
+ * account or a session that has not called the API yet.
79
+ * 2. Each bucket may be independently absent, so one present bucket is one
38
80
  * meter and is a complete answer.
39
- * 3. No window present is the honest unknown, not zero.
40
- *
41
- * An earlier version of this parser read a field named `utilization` and an ISO
42
- * date string. No Claude Code release is known to have emitted either, and the
43
- * only thing that ever agreed with them was our own fixture, so nothing here
44
- * falls back to that shape.
81
+ * 3. No bucket present is the honest unknown, not zero.
45
82
  *
46
- * A window that fails validation is dropped and the other window still counts,
47
- * because one expired window is not a reason to forget the whole session.
83
+ * A bucket that fails validation is dropped and the rest still count, because
84
+ * one corrupt reset is not a reason to forget the whole session.
48
85
  */
49
86
  export declare function parseClaudePayload(payload: unknown, now: string): RawMeter[] | null;
87
+ /** The local application that owns this credential. */
88
+ export declare const CLAUDE_TOOL: ConnectionTool;
50
89
  export declare const claudeConnector: ConnectorContract;
51
90
  //# sourceMappingURL=claude.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAU3B,eAAO,MAAM,YAAY;;;;;CAKW,CAAC;AAErC,eAAO,MAAM,WAAW;;;;CAId,CAAC;AA0CX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAgBnF;AAED,eAAO,MAAM,eAAe,EAAE,iBAc7B,CAAC"}
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAGjB,QAAQ,EAIT,MAAM,mBAAmB,CAAC;AAY3B,eAAO,MAAM,YAAY;;;;;CAKW,CAAC;AAErC,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAKX;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,UAAY,CAAC;AAgCvD,sEAAsE;AACtE,eAAO,MAAM,0BAA0B,eAAe,CAAC;AAEvD,qEAAqE;AACrE,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAiY9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAmCnF;AAED,uDAAuD;AACvD,eAAO,MAAM,WAAW,EAAE,cAA8B,CAAC;AAEzD,eAAO,MAAM,eAAe,EAAE,iBAmB7B,CAAC"}