@openlimiter/connectors 0.1.0 → 0.4.0
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 +48 -0
- package/dist/antigravity.d.ts.map +1 -1
- package/dist/antigravity.js +137 -8
- package/dist/antigravity.js.map +1 -1
- package/dist/claude.d.ts +29 -2
- package/dist/claude.d.ts.map +1 -1
- package/dist/claude.js +38 -5
- package/dist/claude.js.map +1 -1
- package/dist/codex.d.ts +39 -0
- package/dist/codex.d.ts.map +1 -1
- package/dist/codex.js +50 -5
- package/dist/codex.js.map +1 -1
- package/dist/fixtures.d.ts +285 -2
- package/dist/fixtures.d.ts.map +1 -1
- package/dist/fixtures.js +802 -21
- package/dist/fixtures.js.map +1 -1
- package/dist/manual.d.ts.map +1 -1
- package/dist/manual.js +1 -0
- package/dist/manual.js.map +1 -1
- package/dist/opencode.d.ts +62 -0
- package/dist/opencode.d.ts.map +1 -1
- package/dist/opencode.js +280 -9
- package/dist/opencode.js.map +1 -1
- package/dist/openrouter.d.ts.map +1 -1
- package/dist/openrouter.js +10 -1
- package/dist/openrouter.js.map +1 -1
- package/dist/shared.d.ts +97 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +168 -1
- package/dist/shared.js.map +1 -1
- package/package.json +2 -2
package/dist/fixtures.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Connector fixtures, in three classes that mean three different things.
|
|
3
|
+
*
|
|
4
|
+
* The audit found the failure this file now exists to prevent: the Claude
|
|
5
|
+
* fixture had been written to match our parser instead of the provider, so the
|
|
6
|
+
* test suite proved only that our code agreed with itself while the shipped
|
|
7
|
+
* connector could not read a real payload. A fixture is worth nothing unless
|
|
8
|
+
* you can say where its shape came from, so every fixture below is filed under
|
|
9
|
+
* one of three classes and carries its own provenance.
|
|
10
|
+
*
|
|
11
|
+
* documented Built from the provider's own published example. Carries the
|
|
12
|
+
* documentation URL and the date a human last read it. This is
|
|
13
|
+
* the only class that can prove we match a provider.
|
|
14
|
+
*
|
|
15
|
+
* sanitizedLive Built from a real capture on a real account, with the values
|
|
16
|
+
* scrubbed. Proves the documentation matches reality. A capture
|
|
17
|
+
* that does not exist yet is present as an explicit placeholder
|
|
18
|
+
* that tests skip out loud; it is never invented.
|
|
19
|
+
*
|
|
20
|
+
* malformed Hostile, truncated and edge shaped input. Proves the parser
|
|
21
|
+
* fails closed rather than guessing.
|
|
3
22
|
*
|
|
4
23
|
* Every reset timestamp is derived from a supplied clock instead of a pinned
|
|
5
24
|
* calendar date, so a fixture parsed against the real current time still lands
|
|
@@ -11,59 +30,198 @@ const FIVE_HOURS = 18_000;
|
|
|
11
30
|
const ONE_DAY = 86_400;
|
|
12
31
|
const SEVEN_DAYS = 604_800;
|
|
13
32
|
const THIRTY_ONE_DAYS = 2_678_400;
|
|
33
|
+
/** Docs URL for the one interface a provider publishes for us. */
|
|
34
|
+
export const CLAUDE_STATUSLINE_DOCS_URL = "https://code.claude.com/docs/en/statusline";
|
|
35
|
+
/** Docs URL for the one remote interface with a published response shape. */
|
|
36
|
+
export const OPENROUTER_CREDITS_DOCS_URL = "https://openrouter.ai/docs/api-reference/get-credits";
|
|
37
|
+
/** The day a human last read both pages above against this file. */
|
|
38
|
+
export const FIXTURE_REVIEWED_AT = "2026-08-10";
|
|
14
39
|
function offset(now, seconds) {
|
|
15
40
|
const base = Date.parse(now);
|
|
16
41
|
const anchor = Number.isFinite(base) ? base : Date.parse(FIXTURE_NOW);
|
|
17
42
|
return new Date(anchor + seconds * 1_000).toISOString();
|
|
18
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A reset instant in the encoding Claude Code actually uses.
|
|
46
|
+
*
|
|
47
|
+
* Whole Unix seconds, never milliseconds, because handing a millisecond stamp
|
|
48
|
+
* to a seconds field is the exact mistake this connector's fixtures exist to
|
|
49
|
+
* catch. The instant moves with the supplied clock; the encoding does not.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* A reset instant in the encoding Google's quota summary uses.
|
|
53
|
+
*
|
|
54
|
+
* RFC3339 with an explicit offset, and with the seven fractional digits the
|
|
55
|
+
* Antigravity client actually writes, because a fixture that prints three would
|
|
56
|
+
* never exercise the normalisation the parser has to do.
|
|
57
|
+
*/
|
|
58
|
+
function rfc3339Offset(now, seconds) {
|
|
59
|
+
const base = Date.parse(now);
|
|
60
|
+
const anchor = Number.isFinite(base) ? base : Date.parse(FIXTURE_NOW);
|
|
61
|
+
return new Date(anchor + seconds * 1_000)
|
|
62
|
+
.toISOString()
|
|
63
|
+
.replace(/\.(\d{3})Z$/u, ".$10000Z");
|
|
64
|
+
}
|
|
65
|
+
function epochOffset(now, seconds) {
|
|
66
|
+
const base = Date.parse(now);
|
|
67
|
+
const anchor = Number.isFinite(base) ? base : Date.parse(FIXTURE_NOW);
|
|
68
|
+
return Math.floor(anchor / 1_000) + seconds;
|
|
69
|
+
}
|
|
70
|
+
/* ------------------------------------------------------------------ *
|
|
71
|
+
* Demo builders
|
|
72
|
+
*
|
|
73
|
+
* These are the payloads the CLI demo and the web sample mode render. They
|
|
74
|
+
* are synthetic, and their percentages are chosen so the demo lands one meter
|
|
75
|
+
* in each colour band. Their SHAPES are the documented shapes and nothing
|
|
76
|
+
* else: a demo that renders a shape no provider emits is how the last contract
|
|
77
|
+
* mismatch survived a full test suite.
|
|
78
|
+
* ------------------------------------------------------------------ */
|
|
79
|
+
/**
|
|
80
|
+
* The Claude demo payload, in the documented shape.
|
|
81
|
+
*
|
|
82
|
+
* Forty two and sixty four are invented readings kept from the previous demo so
|
|
83
|
+
* every surface renders the same numbers it did before. The field names and the
|
|
84
|
+
* epoch seconds encoding are the provider's, taken from the documentation cited
|
|
85
|
+
* on parseClaudePayload.
|
|
86
|
+
*/
|
|
19
87
|
export function claudeFixture(now = FIXTURE_NOW) {
|
|
20
88
|
return {
|
|
21
89
|
rate_limits: {
|
|
22
90
|
five_hour: {
|
|
23
|
-
|
|
24
|
-
resets_at:
|
|
91
|
+
used_percentage: 42,
|
|
92
|
+
resets_at: epochOffset(now, FIVE_HOURS)
|
|
25
93
|
},
|
|
26
94
|
seven_day: {
|
|
27
|
-
|
|
28
|
-
resets_at:
|
|
95
|
+
used_percentage: 64,
|
|
96
|
+
resets_at: epochOffset(now, SEVEN_DAYS)
|
|
29
97
|
}
|
|
30
98
|
}
|
|
31
99
|
};
|
|
32
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* A credit plan with real money in it, so the dollar line has something to say.
|
|
103
|
+
*
|
|
104
|
+
* Twelve dollars and change out of twenty is 62.35 percent, which also puts the
|
|
105
|
+
* one credit based provider in the middle pressure band. Both numbers are
|
|
106
|
+
* invented for this file and belong to no account.
|
|
107
|
+
*/
|
|
33
108
|
export function openrouterFixture() {
|
|
34
109
|
return {
|
|
35
110
|
data: {
|
|
36
|
-
total_credits:
|
|
37
|
-
total_usage:
|
|
111
|
+
total_credits: 20,
|
|
112
|
+
total_usage: 12.47
|
|
38
113
|
}
|
|
39
114
|
};
|
|
40
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The one fixture in the orange band.
|
|
118
|
+
*
|
|
119
|
+
* Eighty four percent is deliberate, the same way ninety two is below. The
|
|
120
|
+
* meter colour scale has four bands and a demo that never reaches one of them
|
|
121
|
+
* cannot teach it, so this fixture sits between the engine's NEAR_CAP threshold
|
|
122
|
+
* at 80 and the visual red at 90, which is the band that exists to show the gap
|
|
123
|
+
* between the two.
|
|
124
|
+
*
|
|
125
|
+
* Eighty four also keeps the demo's routing advice where it was. The policy
|
|
126
|
+
* stops recommending a provider at 80, so Codex drops out of the running here,
|
|
127
|
+
* and the lowest reading still under that line is Antigravity at 28. The demo
|
|
128
|
+
* therefore still says PREFER ANTIGRAVITY, exactly as it did when this fixture
|
|
129
|
+
* read 51.
|
|
130
|
+
*/
|
|
41
131
|
export function codexFixture(now = FIXTURE_NOW) {
|
|
42
132
|
return {
|
|
43
|
-
|
|
133
|
+
rate_limit: {
|
|
44
134
|
primary_window: {
|
|
45
|
-
used_percent:
|
|
46
|
-
reset_at:
|
|
135
|
+
used_percent: 84,
|
|
136
|
+
reset_at: epochOffset(now, FIVE_HOURS),
|
|
137
|
+
limit_window_seconds: FIVE_HOURS
|
|
47
138
|
}
|
|
48
139
|
}
|
|
49
140
|
};
|
|
50
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* The Antigravity demo payload, in the observed shape.
|
|
144
|
+
*
|
|
145
|
+
* Two windows on the tracked pool, and a third party pool beside it that the
|
|
146
|
+
* parser must leave alone. The five hour window is the binding one at 28
|
|
147
|
+
* percent, which keeps the demo's routing advice exactly where it was: the
|
|
148
|
+
* policy stops recommending a provider at 80, so Codex at 84 drops out and
|
|
149
|
+
* Antigravity is the lowest reading still in the running.
|
|
150
|
+
*
|
|
151
|
+
* `remainingFraction` is what the provider states, so 0.72 remaining is 28 used.
|
|
152
|
+
*/
|
|
51
153
|
export function antigravityFixture(now = FIXTURE_NOW) {
|
|
52
154
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
155
|
+
groups: [
|
|
156
|
+
{
|
|
157
|
+
displayName: "Gemini models",
|
|
158
|
+
buckets: [
|
|
159
|
+
{
|
|
160
|
+
bucketId: "gemini-pro-5h",
|
|
161
|
+
window: "5h",
|
|
162
|
+
remainingFraction: 0.72,
|
|
163
|
+
resetTime: rfc3339Offset(now, FIVE_HOURS)
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
bucketId: "gemini-pro-weekly",
|
|
167
|
+
window: "weekly",
|
|
168
|
+
remainingFraction: 0.9,
|
|
169
|
+
resetTime: rfc3339Offset(now, SEVEN_DAYS)
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
displayName: "Third party models",
|
|
175
|
+
buckets: [
|
|
176
|
+
{
|
|
177
|
+
bucketId: "3p-claude-5h",
|
|
178
|
+
window: "5h",
|
|
179
|
+
remainingFraction: 0.5,
|
|
180
|
+
resetTime: rfc3339Offset(now, FIVE_HOURS)
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
]
|
|
57
185
|
};
|
|
58
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* The one fixture in the red band.
|
|
189
|
+
*
|
|
190
|
+
* Ninety two percent is deliberate. A demo where nothing is ever in trouble
|
|
191
|
+
* teaches nobody what trouble looks like, so one provider sits above the
|
|
192
|
+
* critical threshold and every surface has to draw it. With Codex at 84 above,
|
|
193
|
+
* the demo set now lands one meter in each of the four bands.
|
|
194
|
+
*/
|
|
59
195
|
export function opencodeFixture(now = FIXTURE_NOW) {
|
|
60
|
-
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
196
|
+
return opencodePage({ percent: 92, resetsIn: "20 hours" }, { percent: 40, resetsIn: "5 days 20 hours" }, { percent: 15, resetsIn: "21 days" }, now);
|
|
197
|
+
}
|
|
198
|
+
/** One window block as the workspace page renders it, hydration markers and all. */
|
|
199
|
+
function opencodeWindowBlock(label, window) {
|
|
200
|
+
const reset = window.resetsIn === null
|
|
201
|
+
? ""
|
|
202
|
+
: `<p class="muted">Resets in<!--/--> <!--$-->${window.resetsIn}<!--/--></p>`;
|
|
203
|
+
return `<section><h3>${label}</h3>` +
|
|
204
|
+
`<div class="bar"><span><!--$-->${String(window.percent)}%<!--/--></span></div>` +
|
|
205
|
+
reset +
|
|
206
|
+
`</section>`;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The OpenCode workspace page, as HTML, because that is the only place these
|
|
210
|
+
* numbers exist.
|
|
211
|
+
*
|
|
212
|
+
* Built rather than pasted so a fixture can move its numbers without anybody
|
|
213
|
+
* hand editing markup, and deliberately carrying the framework's hydration
|
|
214
|
+
* comments: a fixture of clean HTML would pass while the real page failed.
|
|
215
|
+
* The `now` parameter is accepted for symmetry with the other builders; the
|
|
216
|
+
* page states durations rather than instants, so it does not use one.
|
|
217
|
+
*/
|
|
218
|
+
export function opencodePage(rolling, weekly, monthly, now = FIXTURE_NOW) {
|
|
219
|
+
void now;
|
|
220
|
+
return `<!doctype html><html><body><main>` +
|
|
221
|
+
opencodeWindowBlock("Rolling Usage", rolling) +
|
|
222
|
+
opencodeWindowBlock("Weekly Usage", weekly) +
|
|
223
|
+
opencodeWindowBlock("Monthly Usage", monthly) +
|
|
224
|
+
`</main></body></html>`;
|
|
67
225
|
}
|
|
68
226
|
export function manualFixture(now = FIXTURE_NOW) {
|
|
69
227
|
return {
|
|
@@ -80,4 +238,627 @@ export const hostileFixture = {
|
|
|
80
238
|
value: 9e300,
|
|
81
239
|
label: "Ω".repeat(200)
|
|
82
240
|
};
|
|
241
|
+
/**
|
|
242
|
+
* The Claude payload exactly as the documentation prints it.
|
|
243
|
+
*
|
|
244
|
+
* Values 23.5 and 41.2 and the epoch seconds encoding are the published
|
|
245
|
+
* example. Only the instant moves, forward of the supplied clock, because a
|
|
246
|
+
* reset in the past is correctly refused and would test nothing.
|
|
247
|
+
*/
|
|
248
|
+
export function claudeDocumentedFixture(now = FIXTURE_NOW) {
|
|
249
|
+
return {
|
|
250
|
+
rate_limits: {
|
|
251
|
+
five_hour: {
|
|
252
|
+
used_percentage: 23.5,
|
|
253
|
+
resets_at: epochOffset(now, FIVE_HOURS)
|
|
254
|
+
},
|
|
255
|
+
seven_day: {
|
|
256
|
+
used_percentage: 41.2,
|
|
257
|
+
resets_at: epochOffset(now, SEVEN_DAYS)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The documented example with its literal epoch numbers left alone.
|
|
264
|
+
*
|
|
265
|
+
* Frozen, because it is what pins our epoch conversion to a hand computed
|
|
266
|
+
* answer: 1738425600 is 2025-02-01T16:00:00.000Z and 1738857600 is
|
|
267
|
+
* 2025-02-06T16:00:00.000Z.
|
|
268
|
+
*
|
|
269
|
+
* Parsing it needs a clock shortly before the first of those, not merely any
|
|
270
|
+
* earlier clock. A five hour window may only reset within about eleven hours,
|
|
271
|
+
* so a clock a month back would see a five hour meter resetting a month away
|
|
272
|
+
* and refuse it, correctly.
|
|
273
|
+
*/
|
|
274
|
+
export const CLAUDE_DOCS_EXAMPLE_VERBATIM = {
|
|
275
|
+
rate_limits: {
|
|
276
|
+
five_hour: { used_percentage: 23.5, resets_at: 1_738_425_600 },
|
|
277
|
+
seven_day: { used_percentage: 41.2, resets_at: 1_738_857_600 }
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
/** The instants the two numbers above mean, computed by hand, not by code. */
|
|
281
|
+
export const CLAUDE_DOCS_EXAMPLE_RESETS = {
|
|
282
|
+
five_hour: "2025-02-01T16:00:00.000Z",
|
|
283
|
+
seven_day: "2025-02-06T16:00:00.000Z"
|
|
284
|
+
};
|
|
285
|
+
export const documentedFixtures = [
|
|
286
|
+
{
|
|
287
|
+
id: "claude.documented.statusline",
|
|
288
|
+
connector: "claude",
|
|
289
|
+
docsUrl: CLAUDE_STATUSLINE_DOCS_URL,
|
|
290
|
+
reviewedAt: FIXTURE_REVIEWED_AT,
|
|
291
|
+
sourceStatus: "official",
|
|
292
|
+
note: "Published statusline example: used_percentage and Unix epoch seconds.",
|
|
293
|
+
expectedMeters: 2,
|
|
294
|
+
build: (now) => claudeDocumentedFixture(now)
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: "openrouter.documented.credits",
|
|
298
|
+
connector: "openrouter",
|
|
299
|
+
docsUrl: OPENROUTER_CREDITS_DOCS_URL,
|
|
300
|
+
reviewedAt: FIXTURE_REVIEWED_AT,
|
|
301
|
+
sourceStatus: "official",
|
|
302
|
+
note: "Published credits response: data.total_credits and data.total_usage.",
|
|
303
|
+
expectedMeters: 1,
|
|
304
|
+
build: () => openrouterFixture()
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: "codex.provisional.usage",
|
|
308
|
+
connector: "codex",
|
|
309
|
+
docsUrl: null,
|
|
310
|
+
reviewedAt: FIXTURE_REVIEWED_AT,
|
|
311
|
+
sourceStatus: "provisional",
|
|
312
|
+
note: "Shape observed against a real account on 2026-08-07 by the reference " +
|
|
313
|
+
"reader: rate_limit.primary_window, singular, with reset_at in epoch " +
|
|
314
|
+
"seconds. OpenAI publishes nothing, so this is design evidence only.",
|
|
315
|
+
expectedMeters: 1,
|
|
316
|
+
build: (now) => codexFixture(now)
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: "antigravity.provisional.quota",
|
|
320
|
+
connector: "antigravity",
|
|
321
|
+
docsUrl: null,
|
|
322
|
+
reviewedAt: FIXTURE_REVIEWED_AT,
|
|
323
|
+
sourceStatus: "provisional",
|
|
324
|
+
note: "Shape observed against a real Google AI Pro account on 2026-08-07 by " +
|
|
325
|
+
"the reference reader: groups of buckets carrying remainingFraction and " +
|
|
326
|
+
"an RFC3339 resetTime. Google publishes nothing, so this is design " +
|
|
327
|
+
"evidence only.",
|
|
328
|
+
expectedMeters: 1,
|
|
329
|
+
build: (now) => antigravityFixture(now)
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
id: "opencode.provisional.usage",
|
|
333
|
+
connector: "opencode",
|
|
334
|
+
docsUrl: null,
|
|
335
|
+
reviewedAt: FIXTURE_REVIEWED_AT,
|
|
336
|
+
sourceStatus: "provisional",
|
|
337
|
+
note: "The logged in workspace page as observed on 2026-08-03: three labelled " +
|
|
338
|
+
"windows rendered into HTML. OpenCode publishes no usage interface at " +
|
|
339
|
+
"all, so this is design evidence only and stays a scrape.",
|
|
340
|
+
expectedMeters: 1,
|
|
341
|
+
build: (now) => opencodeFixture(now)
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: "manual.documented.plan",
|
|
345
|
+
connector: "manual",
|
|
346
|
+
docsUrl: null,
|
|
347
|
+
reviewedAt: FIXTURE_REVIEWED_AT,
|
|
348
|
+
sourceStatus: "official",
|
|
349
|
+
note: "OpenLimiter owns this format, so our own documentation is the source.",
|
|
350
|
+
expectedMeters: 1,
|
|
351
|
+
build: (now) => manualFixture(now)
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
function captureWindow(value, capturedAtSeconds) {
|
|
355
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
356
|
+
return null;
|
|
357
|
+
const input = value;
|
|
358
|
+
const percent = input["used_percentage"];
|
|
359
|
+
const resets = input["resets_at"];
|
|
360
|
+
if (typeof percent !== "number" || !Number.isFinite(percent))
|
|
361
|
+
return null;
|
|
362
|
+
if (typeof resets !== "number" || !Number.isFinite(resets))
|
|
363
|
+
return null;
|
|
364
|
+
return {
|
|
365
|
+
usedPercentage: Math.round(percent * 10) / 10,
|
|
366
|
+
resetsInSeconds: Math.round(resets - capturedAtSeconds)
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* The capture harness.
|
|
371
|
+
*
|
|
372
|
+
* Run it on a real statusline payload on a machine with a Pro or Max account,
|
|
373
|
+
* print the result, and paste that object into `claudeSanitizedLive` below. It
|
|
374
|
+
* is the only supported way a live Claude fixture enters this repository, and
|
|
375
|
+
* it is deliberately lossy.
|
|
376
|
+
*/
|
|
377
|
+
export function sanitizeClaudeStatusline(payload, capturedAtSeconds) {
|
|
378
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
const root = payload;
|
|
382
|
+
const limits = root["rate_limits"];
|
|
383
|
+
if (typeof limits !== "object" || limits === null || Array.isArray(limits))
|
|
384
|
+
return null;
|
|
385
|
+
const windows = limits;
|
|
386
|
+
const fiveHour = captureWindow(windows["five_hour"], capturedAtSeconds);
|
|
387
|
+
const sevenDay = captureWindow(windows["seven_day"], capturedAtSeconds);
|
|
388
|
+
if (fiveHour === null && sevenDay === null)
|
|
389
|
+
return null;
|
|
390
|
+
const version = root["version"];
|
|
391
|
+
return {
|
|
392
|
+
fiveHour,
|
|
393
|
+
sevenDay,
|
|
394
|
+
claudeCodeVersion: typeof version === "string" && version.length <= 32
|
|
395
|
+
? version
|
|
396
|
+
: null
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
/** Turn a scrubbed capture back into a payload a parser can be run against. */
|
|
400
|
+
export function claudeCapturePayload(capture, now = FIXTURE_NOW) {
|
|
401
|
+
const limits = {};
|
|
402
|
+
if (capture.fiveHour !== null) {
|
|
403
|
+
limits["five_hour"] = {
|
|
404
|
+
used_percentage: capture.fiveHour.usedPercentage,
|
|
405
|
+
resets_at: epochOffset(now, capture.fiveHour.resetsInSeconds)
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
if (capture.sevenDay !== null) {
|
|
409
|
+
limits["seven_day"] = {
|
|
410
|
+
used_percentage: capture.sevenDay.usedPercentage,
|
|
411
|
+
resets_at: epochOffset(now, capture.sevenDay.resetsInSeconds)
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return { rate_limits: limits };
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* PENDING CAPTURE.
|
|
418
|
+
*
|
|
419
|
+
* There is no live Claude capture in this repository. Producing one needs a
|
|
420
|
+
* machine signed into a Pro or Max account, running Claude Code, after the
|
|
421
|
+
* first API response of a session, and no such capture has been taken.
|
|
422
|
+
*
|
|
423
|
+
* Inventing one would rebuild exactly the fault the audit found, so this entry
|
|
424
|
+
* exists to make the gap loud: every test that would use it skips and says why,
|
|
425
|
+
* and the provider stays UNVERIFIED until the capture lands here through
|
|
426
|
+
* `sanitizeClaudeStatusline` above.
|
|
427
|
+
*/
|
|
428
|
+
export const claudeSanitizedLive = {
|
|
429
|
+
id: "claude.live.pending",
|
|
430
|
+
connector: "claude",
|
|
431
|
+
status: "pending_capture",
|
|
432
|
+
capturedAt: null,
|
|
433
|
+
providerVersion: null,
|
|
434
|
+
skipReason: "PENDING CAPTURE: no sanitized live Claude Code statusline payload " +
|
|
435
|
+
"exists yet. Capture one on a Pro or Max account with " +
|
|
436
|
+
"sanitizeClaudeStatusline, paste the result here, then remove this reason.",
|
|
437
|
+
expectedMeters: 0,
|
|
438
|
+
build: () => null
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* PENDING CAPTURE: Codex usage.
|
|
442
|
+
*
|
|
443
|
+
* The REQUEST contract for this reader is known, reproducible and recorded, in
|
|
444
|
+
* `provider_specs/openai/codex.yaml` and in the endpoint constants in
|
|
445
|
+
* `apps/desktop/src-tauri/src/net.rs`: the method, the address, the
|
|
446
|
+
* authentication, the fixed headers and the behaviour of an expired login were
|
|
447
|
+
* all taken from a reader that ran against a real account on 2026-08-07.
|
|
448
|
+
*
|
|
449
|
+
* The RESPONSE is a different question, and it is open. No sanitized response
|
|
450
|
+
* from that account has been committed here, and the shape the shipped parser
|
|
451
|
+
* reads was observed in the original prototype rather than captured through
|
|
452
|
+
* this code. Writing a payload from memory to make this slot look full would
|
|
453
|
+
* rebuild exactly the fault the fixture classes exist to prevent, so the slot
|
|
454
|
+
* stays empty and loud: every test that would use it skips and says why, the
|
|
455
|
+
* provider stays UNVERIFIED, and the registry validator reports the gap on
|
|
456
|
+
* every run and fails outright under --require-captures.
|
|
457
|
+
*/
|
|
458
|
+
export const codexSanitizedLive = {
|
|
459
|
+
id: "codex.sanitized_live.usage",
|
|
460
|
+
connector: "codex",
|
|
461
|
+
status: "pending_capture",
|
|
462
|
+
capturedAt: null,
|
|
463
|
+
providerVersion: null,
|
|
464
|
+
skipReason: "PENDING CAPTURE: no sanitized live Codex usage response exists " +
|
|
465
|
+
"yet. The request contract is recorded; the response is not. Capture one " +
|
|
466
|
+
"on a real account, reduce it to numbers and window lengths only, paste " +
|
|
467
|
+
"the result here, then remove this reason.",
|
|
468
|
+
expectedMeters: 0,
|
|
469
|
+
build: () => null
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* PENDING CAPTURE: Antigravity quota summary.
|
|
473
|
+
*
|
|
474
|
+
* Same standing as the Codex slot above. The request is recorded, including the
|
|
475
|
+
* detail that the endpoint answers 403 to a valid token when the user agent
|
|
476
|
+
* header is missing, which was measured on 2026-08-07. No sanitized response
|
|
477
|
+
* has been committed, so nothing here claims to know the shape of one.
|
|
478
|
+
*/
|
|
479
|
+
export const antigravitySanitizedLive = {
|
|
480
|
+
id: "antigravity.sanitized_live.quota",
|
|
481
|
+
connector: "antigravity",
|
|
482
|
+
status: "pending_capture",
|
|
483
|
+
capturedAt: null,
|
|
484
|
+
providerVersion: null,
|
|
485
|
+
skipReason: "PENDING CAPTURE: no sanitized live Antigravity quota summary " +
|
|
486
|
+
"exists yet. The request contract is recorded; the response is not. " +
|
|
487
|
+
"Capture one on a real account, reduce it to fractions and window " +
|
|
488
|
+
"lengths only, paste the result here, then remove this reason.",
|
|
489
|
+
expectedMeters: 0,
|
|
490
|
+
build: () => null
|
|
491
|
+
};
|
|
492
|
+
/**
|
|
493
|
+
* PENDING CAPTURE: OpenCode workspace usage.
|
|
494
|
+
*
|
|
495
|
+
* The weakest evidence of the three, and permanently so. There is no interface
|
|
496
|
+
* to capture: the meters exist only inside the html of a logged in page, so any
|
|
497
|
+
* capture is a capture of a layout. That is why this provider's labels do not
|
|
498
|
+
* improve when the slot is filled: browser-session, authenticated-scrape,
|
|
499
|
+
* automationRisk high and UNVERIFIED are properties of the method, not of how
|
|
500
|
+
* much evidence has been gathered about it.
|
|
501
|
+
*/
|
|
502
|
+
export const opencodeSanitizedLive = {
|
|
503
|
+
id: "opencode.sanitized_live.usage",
|
|
504
|
+
connector: "opencode",
|
|
505
|
+
status: "pending_capture",
|
|
506
|
+
capturedAt: null,
|
|
507
|
+
providerVersion: null,
|
|
508
|
+
skipReason: "PENDING CAPTURE: no sanitized live OpenCode workspace page " +
|
|
509
|
+
"exists yet. Capture one on a real account, reduce it to the window " +
|
|
510
|
+
"labels, percentages and remaining durations only, paste the result " +
|
|
511
|
+
"here, then remove this reason. The honesty labels do not change when " +
|
|
512
|
+
"it lands.",
|
|
513
|
+
expectedMeters: 0,
|
|
514
|
+
build: () => null
|
|
515
|
+
};
|
|
516
|
+
/* ------------------------------------------------------------------ *
|
|
517
|
+
* Rebuilding a payload from a reduced capture
|
|
518
|
+
*
|
|
519
|
+
* A capture holds numbers. A parser wants the provider's own shape. These turn
|
|
520
|
+
* one into the other, against a supplied clock, so a capture taken months ago
|
|
521
|
+
* still produces a payload whose resets are in the future. They are the only
|
|
522
|
+
* readers of the `capture` field, and they are written to fail closed: a
|
|
523
|
+
* capture they cannot read rebuilds as null, which every parser refuses.
|
|
524
|
+
* ------------------------------------------------------------------ */
|
|
525
|
+
function captureRecord(value) {
|
|
526
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
527
|
+
? value
|
|
528
|
+
: null;
|
|
529
|
+
}
|
|
530
|
+
function captureNumber(value) {
|
|
531
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
532
|
+
}
|
|
533
|
+
export function rebuildCodexCapture(capture, now) {
|
|
534
|
+
const reduced = captureRecord(capture);
|
|
535
|
+
const percent = captureNumber(reduced?.["usedPercent"]);
|
|
536
|
+
const resetsIn = captureNumber(reduced?.["resetsInSeconds"]);
|
|
537
|
+
if (percent === null || resetsIn === null)
|
|
538
|
+
return null;
|
|
539
|
+
const length = captureNumber(reduced?.["limitWindowSeconds"]);
|
|
540
|
+
const primary = {
|
|
541
|
+
used_percent: percent,
|
|
542
|
+
reset_at: epochOffset(now, resetsIn)
|
|
543
|
+
};
|
|
544
|
+
if (length !== null)
|
|
545
|
+
primary["limit_window_seconds"] = length;
|
|
546
|
+
return { rate_limit: { primary_window: primary } };
|
|
547
|
+
}
|
|
548
|
+
export function rebuildAntigravityCapture(capture, now) {
|
|
549
|
+
const reduced = captureRecord(capture);
|
|
550
|
+
const groups = reduced?.["groups"];
|
|
551
|
+
if (!Array.isArray(groups))
|
|
552
|
+
return null;
|
|
553
|
+
const rebuilt = [];
|
|
554
|
+
for (const entry of groups) {
|
|
555
|
+
const group = captureRecord(entry);
|
|
556
|
+
const buckets = group?.["buckets"];
|
|
557
|
+
if (!Array.isArray(buckets))
|
|
558
|
+
return null;
|
|
559
|
+
const rebuiltBuckets = [];
|
|
560
|
+
for (const rawBucket of buckets) {
|
|
561
|
+
const bucket = captureRecord(rawBucket);
|
|
562
|
+
const prefix = bucket?.["poolPrefix"];
|
|
563
|
+
const window = bucket?.["window"];
|
|
564
|
+
const fraction = captureNumber(bucket?.["remainingFraction"]);
|
|
565
|
+
const resetsIn = captureNumber(bucket?.["resetsInSeconds"]);
|
|
566
|
+
if (typeof prefix !== "string" || typeof window !== "string")
|
|
567
|
+
return null;
|
|
568
|
+
if (fraction === null || resetsIn === null)
|
|
569
|
+
return null;
|
|
570
|
+
rebuiltBuckets.push({
|
|
571
|
+
/* The id's tail named a model and a plan and was discarded, so a
|
|
572
|
+
neutral one is synthesised from the prefix the parser matches on. */
|
|
573
|
+
bucketId: prefix + "-captured",
|
|
574
|
+
window,
|
|
575
|
+
remainingFraction: fraction,
|
|
576
|
+
resetTime: rfc3339Offset(now, resetsIn)
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
rebuilt.push({ buckets: rebuiltBuckets });
|
|
580
|
+
}
|
|
581
|
+
return { groups: rebuilt };
|
|
582
|
+
}
|
|
583
|
+
function captureDurationWords(seconds) {
|
|
584
|
+
const days = Math.floor(seconds / 86_400);
|
|
585
|
+
const hours = Math.floor((seconds % 86_400) / 3_600);
|
|
586
|
+
const minutes = Math.floor((seconds % 3_600) / 60);
|
|
587
|
+
const parts = [];
|
|
588
|
+
if (days > 0)
|
|
589
|
+
parts.push(String(days) + (days === 1 ? " day" : " days"));
|
|
590
|
+
if (hours > 0)
|
|
591
|
+
parts.push(String(hours) + (hours === 1 ? " hour" : " hours"));
|
|
592
|
+
if (parts.length === 0 && minutes > 0) {
|
|
593
|
+
parts.push(String(minutes) + (minutes === 1 ? " minute" : " minutes"));
|
|
594
|
+
}
|
|
595
|
+
return parts.join(" ");
|
|
596
|
+
}
|
|
597
|
+
export function rebuildOpencodeCapture(capture, now) {
|
|
598
|
+
const reduced = captureRecord(capture);
|
|
599
|
+
const windows = reduced?.["windows"];
|
|
600
|
+
if (!Array.isArray(windows) || windows.length !== 3)
|
|
601
|
+
return null;
|
|
602
|
+
const byLabel = new Map();
|
|
603
|
+
for (const entry of windows) {
|
|
604
|
+
const window = captureRecord(entry);
|
|
605
|
+
const label = window?.["label"];
|
|
606
|
+
const percent = captureNumber(window?.["percent"]);
|
|
607
|
+
if (typeof label !== "string" || percent === null)
|
|
608
|
+
return null;
|
|
609
|
+
const resetsIn = captureNumber(window?.["resetsInSeconds"]);
|
|
610
|
+
byLabel.set(label, {
|
|
611
|
+
percent,
|
|
612
|
+
resetsIn: resetsIn === null ? null : captureDurationWords(resetsIn)
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
const rolling = byLabel.get("Rolling Usage");
|
|
616
|
+
const weekly = byLabel.get("Weekly Usage");
|
|
617
|
+
const monthly = byLabel.get("Monthly Usage");
|
|
618
|
+
if (rolling === undefined || weekly === undefined || monthly === undefined)
|
|
619
|
+
return null;
|
|
620
|
+
return opencodePage(rolling, weekly, monthly, now);
|
|
621
|
+
}
|
|
622
|
+
export const sanitizedLiveFixtures = [
|
|
623
|
+
claudeSanitizedLive,
|
|
624
|
+
codexSanitizedLive,
|
|
625
|
+
antigravitySanitizedLive,
|
|
626
|
+
opencodeSanitizedLive
|
|
627
|
+
];
|
|
628
|
+
function claudeWindows(five, seven) {
|
|
629
|
+
const limits = {};
|
|
630
|
+
if (five !== undefined)
|
|
631
|
+
limits["five_hour"] = five;
|
|
632
|
+
if (seven !== undefined)
|
|
633
|
+
limits["seven_day"] = seven;
|
|
634
|
+
return { rate_limits: limits };
|
|
635
|
+
}
|
|
636
|
+
function goodFiveHour(now) {
|
|
637
|
+
return { used_percentage: 42, resets_at: epochOffset(now, FIVE_HOURS) };
|
|
638
|
+
}
|
|
639
|
+
function goodSevenDay(now) {
|
|
640
|
+
return { used_percentage: 64, resets_at: epochOffset(now, SEVEN_DAYS) };
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* The Claude epoch edge cases.
|
|
644
|
+
*
|
|
645
|
+
* Every one of these is a way a reset instant can arrive wrong, and each has a
|
|
646
|
+
* single correct answer. The 2038 entry is the odd one out and is expected to
|
|
647
|
+
* PASS: it is here to prove nothing in the conversion truncates to 32 bits.
|
|
648
|
+
*/
|
|
649
|
+
const claudeMalformed = [
|
|
650
|
+
{
|
|
651
|
+
id: "claude.malformed.epoch_milliseconds",
|
|
652
|
+
connector: "claude",
|
|
653
|
+
reason: "resets_at in milliseconds instead of seconds",
|
|
654
|
+
expectedMeters: 0,
|
|
655
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: epochOffset(now, FIVE_HOURS) * 1_000 }, undefined)
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
id: "claude.malformed.epoch_negative",
|
|
659
|
+
connector: "claude",
|
|
660
|
+
reason: "negative resets_at",
|
|
661
|
+
expectedMeters: 0,
|
|
662
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: -1 }, undefined)
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
id: "claude.malformed.epoch_zero",
|
|
666
|
+
connector: "claude",
|
|
667
|
+
reason: "resets_at of zero, which is the epoch itself and long past",
|
|
668
|
+
expectedMeters: 0,
|
|
669
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: 0 }, undefined)
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
id: "claude.malformed.epoch_string",
|
|
673
|
+
connector: "claude",
|
|
674
|
+
reason: "resets_at as a string rather than a number",
|
|
675
|
+
expectedMeters: 0,
|
|
676
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: String(epochOffset(now, FIVE_HOURS)) }, undefined)
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
id: "claude.malformed.epoch_iso_string",
|
|
680
|
+
connector: "claude",
|
|
681
|
+
reason: "resets_at as the ISO string our old invented shape used",
|
|
682
|
+
expectedMeters: 0,
|
|
683
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: offset(now, FIVE_HOURS) }, undefined)
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
id: "claude.malformed.legacy_utilization_field",
|
|
687
|
+
connector: "claude",
|
|
688
|
+
reason: "the invented utilization field, which no release is known to emit",
|
|
689
|
+
expectedMeters: 0,
|
|
690
|
+
build: (now) => claudeWindows({ utilization: 42, resets_at: epochOffset(now, FIVE_HOURS) }, undefined)
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
id: "claude.malformed.epoch_expired",
|
|
694
|
+
connector: "claude",
|
|
695
|
+
reason: "a reset that already happened",
|
|
696
|
+
expectedMeters: 0,
|
|
697
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: epochOffset(now, -FIVE_HOURS) }, undefined)
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
id: "claude.malformed.epoch_year_2038",
|
|
701
|
+
connector: "claude",
|
|
702
|
+
reason: "a five hour window claiming to reset in 2038, which is not a wait " +
|
|
703
|
+
"but a corrupt field",
|
|
704
|
+
expectedMeters: 0,
|
|
705
|
+
build: () => ({
|
|
706
|
+
rate_limits: {
|
|
707
|
+
five_hour: { used_percentage: 42, resets_at: 2_147_483_648 }
|
|
708
|
+
}
|
|
709
|
+
})
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
id: "claude.malformed.epoch_just_past_horizon",
|
|
713
|
+
connector: "claude",
|
|
714
|
+
reason: "a five hour reset one second past the plausible horizon",
|
|
715
|
+
expectedMeters: 0,
|
|
716
|
+
build: (now) => claudeWindows({
|
|
717
|
+
used_percentage: 42,
|
|
718
|
+
resets_at: epochOffset(now, FIVE_HOURS * 2 + 3_600 + 1)
|
|
719
|
+
}, undefined)
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
id: "claude.edge.epoch_at_horizon",
|
|
723
|
+
connector: "claude",
|
|
724
|
+
reason: "a five hour reset exactly at the plausible horizon, which stands",
|
|
725
|
+
expectedMeters: 1,
|
|
726
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: epochOffset(now, FIVE_HOURS * 2 + 3_600) }, undefined)
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
id: "claude.edge.horizon_is_per_window",
|
|
730
|
+
connector: "claude",
|
|
731
|
+
reason: "a reset three days out, implausible for five hours and fine for " +
|
|
732
|
+
"seven days, so exactly one window survives",
|
|
733
|
+
expectedMeters: 1,
|
|
734
|
+
build: (now) => claudeWindows({ used_percentage: 42, resets_at: epochOffset(now, ONE_DAY * 3) }, { used_percentage: 64, resets_at: epochOffset(now, ONE_DAY * 3) })
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
id: "claude.edge.missing_five_hour",
|
|
738
|
+
connector: "claude",
|
|
739
|
+
reason: "only the seven day window present, which is one complete answer",
|
|
740
|
+
expectedMeters: 1,
|
|
741
|
+
build: (now) => claudeWindows(undefined, goodSevenDay(now))
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
id: "claude.edge.missing_seven_day",
|
|
745
|
+
connector: "claude",
|
|
746
|
+
reason: "only the five hour window present, which is one complete answer",
|
|
747
|
+
expectedMeters: 1,
|
|
748
|
+
build: (now) => claudeWindows(goodFiveHour(now), undefined)
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
id: "claude.edge.missing_both_windows",
|
|
752
|
+
connector: "claude",
|
|
753
|
+
reason: "rate_limits present and empty, which is unknown rather than zero",
|
|
754
|
+
expectedMeters: 0,
|
|
755
|
+
build: (now) => claudeWindows(undefined, undefined)
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
id: "claude.edge.rate_limits_absent",
|
|
759
|
+
connector: "claude",
|
|
760
|
+
reason: "no rate_limits at all, the ordinary free account payload",
|
|
761
|
+
expectedMeters: 0,
|
|
762
|
+
build: () => ({ session_id: "synthetic", version: "0.0.0-synthetic" })
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
id: "claude.edge.unknown_window_alongside",
|
|
766
|
+
connector: "claude",
|
|
767
|
+
reason: "an undocumented three_hour window, dropped without disturbing the rest",
|
|
768
|
+
expectedMeters: 2,
|
|
769
|
+
build: (now) => ({
|
|
770
|
+
rate_limits: {
|
|
771
|
+
five_hour: goodFiveHour(now),
|
|
772
|
+
seven_day: goodSevenDay(now),
|
|
773
|
+
three_hour: { used_percentage: 10, resets_at: epochOffset(now, 10_800) }
|
|
774
|
+
}
|
|
775
|
+
})
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
id: "claude.edge.unknown_window_only",
|
|
779
|
+
connector: "claude",
|
|
780
|
+
reason: "nothing but an undocumented window, which is unknown",
|
|
781
|
+
expectedMeters: 0,
|
|
782
|
+
build: (now) => ({
|
|
783
|
+
rate_limits: {
|
|
784
|
+
three_hour: { used_percentage: 10, resets_at: epochOffset(now, 10_800) }
|
|
785
|
+
}
|
|
786
|
+
})
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
id: "claude.malformed.window_as_array",
|
|
790
|
+
connector: "claude",
|
|
791
|
+
reason: "a window that is an array",
|
|
792
|
+
expectedMeters: 0,
|
|
793
|
+
build: (now) => claudeWindows([42], undefined)
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
id: "claude.malformed.rate_limits_as_array",
|
|
797
|
+
connector: "claude",
|
|
798
|
+
reason: "rate_limits that is an array",
|
|
799
|
+
expectedMeters: 0,
|
|
800
|
+
build: () => ({ rate_limits: [] })
|
|
801
|
+
}
|
|
802
|
+
];
|
|
803
|
+
const genericIds = [
|
|
804
|
+
"claude",
|
|
805
|
+
"openrouter",
|
|
806
|
+
"codex",
|
|
807
|
+
"antigravity",
|
|
808
|
+
"opencode",
|
|
809
|
+
"manual"
|
|
810
|
+
];
|
|
811
|
+
/**
|
|
812
|
+
* The shapes every parser must refuse, whatever provider it reads.
|
|
813
|
+
*
|
|
814
|
+
* Generated per connector rather than written out six times, so a new
|
|
815
|
+
* connector cannot be added without inheriting the whole hostile set.
|
|
816
|
+
*/
|
|
817
|
+
const genericMalformed = genericIds.flatMap((connector) => [
|
|
818
|
+
{
|
|
819
|
+
id: connector + ".malformed.undefined",
|
|
820
|
+
connector,
|
|
821
|
+
reason: "no payload at all",
|
|
822
|
+
expectedMeters: 0,
|
|
823
|
+
build: () => undefined
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
id: connector + ".malformed.empty_object",
|
|
827
|
+
connector,
|
|
828
|
+
reason: "an empty object",
|
|
829
|
+
expectedMeters: 0,
|
|
830
|
+
build: () => ({})
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
id: connector + ".malformed.array_root",
|
|
834
|
+
connector,
|
|
835
|
+
reason: "an array where an object belongs",
|
|
836
|
+
expectedMeters: 0,
|
|
837
|
+
build: () => []
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
id: connector + ".malformed.string_root",
|
|
841
|
+
connector,
|
|
842
|
+
reason: "a string, which is what an HTML error page arrives as",
|
|
843
|
+
expectedMeters: 0,
|
|
844
|
+
build: () => "<!doctype html><title>502 Bad Gateway</title>"
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
id: connector + ".malformed.hostile_root",
|
|
848
|
+
connector,
|
|
849
|
+
reason: "prompt injection text and an enormous number at the root",
|
|
850
|
+
expectedMeters: 0,
|
|
851
|
+
build: () => ({ ...hostileFixture })
|
|
852
|
+
}
|
|
853
|
+
]);
|
|
854
|
+
export const malformedFixtures = [
|
|
855
|
+
...claudeMalformed,
|
|
856
|
+
...genericMalformed
|
|
857
|
+
];
|
|
858
|
+
/** Every fixture class in one place, for a test that wants to sweep them all. */
|
|
859
|
+
export const fixtureClasses = {
|
|
860
|
+
documented: documentedFixtures,
|
|
861
|
+
sanitizedLive: sanitizedLiveFixtures,
|
|
862
|
+
malformed: malformedFixtures
|
|
863
|
+
};
|
|
83
864
|
//# sourceMappingURL=fixtures.js.map
|