@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.
- package/dist/antigravity.d.ts +25 -5
- package/dist/antigravity.d.ts.map +1 -1
- package/dist/antigravity.js +56 -25
- package/dist/antigravity.js.map +1 -1
- package/dist/claude.d.ts +59 -20
- package/dist/claude.d.ts.map +1 -1
- package/dist/claude.js +452 -53
- package/dist/claude.js.map +1 -1
- package/dist/codex.d.ts +3 -20
- package/dist/codex.d.ts.map +1 -1
- package/dist/codex.js +99 -18
- package/dist/codex.js.map +1 -1
- package/dist/contract-gate.d.ts +56 -0
- package/dist/contract-gate.d.ts.map +1 -0
- package/dist/contract-gate.js +100 -0
- package/dist/contract-gate.js.map +1 -0
- package/dist/fixtures.d.ts +19 -0
- package/dist/fixtures.d.ts.map +1 -1
- package/dist/fixtures.js +213 -34
- package/dist/fixtures.js.map +1 -1
- package/dist/gemini-cli.d.ts +13 -0
- package/dist/gemini-cli.d.ts.map +1 -0
- package/dist/gemini-cli.js +86 -0
- package/dist/gemini-cli.js.map +1 -0
- package/dist/grok.d.ts +13 -0
- package/dist/grok.d.ts.map +1 -0
- package/dist/grok.js +143 -0
- package/dist/grok.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/kimi.d.ts +13 -0
- package/dist/kimi.d.ts.map +1 -0
- package/dist/kimi.js +141 -0
- package/dist/kimi.js.map +1 -0
- package/dist/manual.d.ts +3 -1
- package/dist/manual.d.ts.map +1 -1
- package/dist/manual.js +6 -3
- package/dist/manual.js.map +1 -1
- package/dist/opencode.d.ts +47 -7
- package/dist/opencode.d.ts.map +1 -1
- package/dist/opencode.js +203 -67
- package/dist/opencode.js.map +1 -1
- package/dist/openrouter.d.ts +3 -1
- package/dist/openrouter.d.ts.map +1 -1
- package/dist/openrouter.js +6 -3
- package/dist/openrouter.js.map +1 -1
- package/dist/shared.d.ts +17 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +24 -0
- package/dist/shared.js.map +1 -1
- package/package.json +4 -3
package/dist/antigravity.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
|
/**
|
|
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
|
-
*
|
|
50
|
+
* Every documented window in the tracked pool, as its own meter.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
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;
|
|
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"}
|
package/dist/antigravity.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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({
|
|
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
|
-
*
|
|
108
|
+
* Every documented window in the tracked pool, as its own meter.
|
|
103
109
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
package/dist/antigravity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antigravity.js","sourceRoot":"","sources":["../src/antigravity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"antigravity.js","sourceRoot":"","sources":["../src/antigravity.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAA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1D,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAO;QAChB,MAAM,MAAM,GAAG,uBAAuB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAmB,CACpC,MAAM,KAAK,IAAI,EACf,OAAO,CAAC,OAAO,EACf,gBAAgB,CACjB,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
|
-
*
|
|
14
|
+
* The longest a window this reader was never told the length of may run.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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":
|
|
23
|
-
* "seven_day":
|
|
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
|
-
*
|
|
29
|
-
*
|
|
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
|
|
35
|
-
* an ordinary payload from a free
|
|
36
|
-
* the API yet.
|
|
37
|
-
* 2. Each
|
|
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
|
|
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
|
|
47
|
-
*
|
|
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
|
package/dist/claude.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"
|
|
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"}
|