@openlimiter/connectors 0.4.0 → 1.2.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 +6 -5
- package/dist/antigravity.d.ts.map +1 -1
- package/dist/antigravity.js +27 -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 +72 -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/grok.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { boundedNumber, connectorConnection, futureInstantFromRfc3339, plausibleResetHorizon, rawMeter, record, shortExpiry } from "./shared.js";
|
|
2
|
+
export const grokLabels = {
|
|
3
|
+
credentialOrigin: "official-local-tool",
|
|
4
|
+
dataInterfaceStatus: "internal-endpoint",
|
|
5
|
+
automationRisk: "high",
|
|
6
|
+
verification: "UNVERIFIED"
|
|
7
|
+
};
|
|
8
|
+
export const grokEncoding = "json";
|
|
9
|
+
function objectValue(value) {
|
|
10
|
+
const object = record(value);
|
|
11
|
+
if (object === null)
|
|
12
|
+
return null;
|
|
13
|
+
const raw = object["val"];
|
|
14
|
+
const number = typeof raw === "string" ? Number(raw) : raw;
|
|
15
|
+
return typeof number === "number" &&
|
|
16
|
+
Number.isFinite(number) &&
|
|
17
|
+
number >= 0 &&
|
|
18
|
+
number <= 1_000_000_000_000
|
|
19
|
+
? number
|
|
20
|
+
: null;
|
|
21
|
+
}
|
|
22
|
+
function percentage(used, limit) {
|
|
23
|
+
if (limit <= 0 || used > limit)
|
|
24
|
+
return null;
|
|
25
|
+
const value = used / limit * 100;
|
|
26
|
+
return Number.isFinite(value) && value >= 0 && value <= 100 ? value : null;
|
|
27
|
+
}
|
|
28
|
+
function currentPeriod(config, now) {
|
|
29
|
+
const period = record(config["currentPeriod"]);
|
|
30
|
+
if (period === null)
|
|
31
|
+
return null;
|
|
32
|
+
const type = period["type"];
|
|
33
|
+
const weekly = type === "USAGE_PERIOD_TYPE_WEEKLY";
|
|
34
|
+
const monthly = type === "USAGE_PERIOD_TYPE_MONTHLY";
|
|
35
|
+
if (!weekly && !monthly)
|
|
36
|
+
return null;
|
|
37
|
+
const durationSeconds = weekly ? 604_800 : undefined;
|
|
38
|
+
const resetAt = futureInstantFromRfc3339(period["end"], now, plausibleResetHorizon(durationSeconds ?? 2_678_400));
|
|
39
|
+
if (resetAt === null)
|
|
40
|
+
return null;
|
|
41
|
+
return {
|
|
42
|
+
meter: weekly ? "WEEKLY" : "MONTHLY",
|
|
43
|
+
window: durationSeconds === undefined
|
|
44
|
+
? { kind: "fixed" }
|
|
45
|
+
: { kind: "fixed", durationSeconds },
|
|
46
|
+
resetAt
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function parseGrokPayload(payload, now) {
|
|
50
|
+
const root = record(payload);
|
|
51
|
+
const config = record(root?.["config"]);
|
|
52
|
+
const expiresAt = shortExpiry(now);
|
|
53
|
+
if (config === null || expiresAt === null)
|
|
54
|
+
return null;
|
|
55
|
+
const meters = [];
|
|
56
|
+
const stated = boundedNumber(config["creditUsagePercent"]);
|
|
57
|
+
if (stated !== null) {
|
|
58
|
+
const period = currentPeriod(config, now);
|
|
59
|
+
if (period === null)
|
|
60
|
+
return null;
|
|
61
|
+
meters.push(rawMeter({
|
|
62
|
+
provider: "GROK",
|
|
63
|
+
meter: period.meter,
|
|
64
|
+
value: stated,
|
|
65
|
+
window: period.window,
|
|
66
|
+
resetAt: period.resetAt,
|
|
67
|
+
source: "internal_payload",
|
|
68
|
+
precision: "estimated",
|
|
69
|
+
observedAt: now,
|
|
70
|
+
expiresAt,
|
|
71
|
+
labels: grokLabels
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const limit = objectValue(config["monthlyLimit"]);
|
|
76
|
+
const used = objectValue(config["used"]);
|
|
77
|
+
if (limit === null || used === null)
|
|
78
|
+
return null;
|
|
79
|
+
const value = percentage(used, limit);
|
|
80
|
+
if (value === null)
|
|
81
|
+
return null;
|
|
82
|
+
const resetAt = config["billingPeriodEnd"] === undefined
|
|
83
|
+
? null
|
|
84
|
+
: futureInstantFromRfc3339(config["billingPeriodEnd"], now, plausibleResetHorizon(2_678_400));
|
|
85
|
+
if (config["billingPeriodEnd"] !== undefined && resetAt === null)
|
|
86
|
+
return null;
|
|
87
|
+
meters.push(rawMeter({
|
|
88
|
+
provider: "GROK",
|
|
89
|
+
meter: "MONTHLY",
|
|
90
|
+
value,
|
|
91
|
+
window: { kind: "fixed" },
|
|
92
|
+
resetAt,
|
|
93
|
+
source: "internal_payload",
|
|
94
|
+
precision: "estimated",
|
|
95
|
+
observedAt: now,
|
|
96
|
+
expiresAt,
|
|
97
|
+
labels: grokLabels
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
const cap = objectValue(config["onDemandCap"]);
|
|
101
|
+
const used = objectValue(config["onDemandUsed"]);
|
|
102
|
+
if (cap === null && used === null)
|
|
103
|
+
return meters;
|
|
104
|
+
if (cap === 0 && used === 0)
|
|
105
|
+
return meters;
|
|
106
|
+
if (cap === null || used === null)
|
|
107
|
+
return null;
|
|
108
|
+
const value = percentage(used, cap);
|
|
109
|
+
if (value === null)
|
|
110
|
+
return null;
|
|
111
|
+
meters.push(rawMeter({
|
|
112
|
+
provider: "GROK",
|
|
113
|
+
meter: "ON_DEMAND_MONTHLY",
|
|
114
|
+
value,
|
|
115
|
+
window: { kind: "fixed" },
|
|
116
|
+
resetAt: null,
|
|
117
|
+
source: "internal_payload",
|
|
118
|
+
precision: "estimated",
|
|
119
|
+
observedAt: now,
|
|
120
|
+
expiresAt,
|
|
121
|
+
labels: grokLabels
|
|
122
|
+
}));
|
|
123
|
+
return meters;
|
|
124
|
+
}
|
|
125
|
+
/** The local application that owns this credential. */
|
|
126
|
+
export const GROK_TOOL = "Grok Build";
|
|
127
|
+
export const grokConnector = {
|
|
128
|
+
id: "grok",
|
|
129
|
+
displayName: "Grok Build",
|
|
130
|
+
encoding: grokEncoding,
|
|
131
|
+
labels: grokLabels,
|
|
132
|
+
detect(environment) {
|
|
133
|
+
return environment["GROK_USAGE_PAYLOAD"] === "1";
|
|
134
|
+
},
|
|
135
|
+
async read(context) {
|
|
136
|
+
const meters = parseGrokPayload(context.payload, context.now);
|
|
137
|
+
const connection = connectorConnection(meters !== null, context.payload, GROK_TOOL);
|
|
138
|
+
return meters === null
|
|
139
|
+
? { ok: false, reason: "unknown", connection }
|
|
140
|
+
: { ok: true, meters, connection };
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=grok.js.map
|
package/dist/grok.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grok.js","sourceRoot":"","sources":["../src/grok.ts"],"names":[],"mappings":"AASA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,QAAQ,EACR,MAAM,EACN,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,gBAAgB,EAAE,qBAAqB;IACvC,mBAAmB,EAAE,mBAAmB;IACxC,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,YAAY;CACQ,CAAC;AAErC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAe,CAAC;AAE5C,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,OAAO,OAAO,MAAM,KAAK,QAAQ;QAC/B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QACvB,MAAM,IAAI,CAAC;QACX,MAAM,IAAI,iBAAiB;QAC3B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,KAAa;IAC7C,IAAI,KAAK,IAAI,CAAC,I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1B,KAAK;QACL,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QACzB,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,kBAAkB;QAC1B,SAAS,EAAE,WAAW;QACtB,UAAU,EAAE,GAAG;QACf,SAAS;QACT,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC,CAAC;IACJ,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,SAAS,GAAmB,YAAY,CAAC;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,EAAE,EAAE,MAAM;IACV,WAAW,EAAE,YAAY;IACzB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,CAAC,WAAW;QAChB,OAAO,WAAW,CAAC,oBAAoB,CAAC,KAAK,GAAG,CAAC;IACnD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAO;QAChB,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,mBAAmB,CACpC,MAAM,KAAK,IAAI,EACf,OAAO,CAAC,OAAO,EACf,SAAS,CACV,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/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * from "./antigravity.js";
|
|
2
2
|
export * from "./claude.js";
|
|
3
3
|
export * from "./codex.js";
|
|
4
|
+
export * from "./contract-gate.js";
|
|
4
5
|
export * from "./fixtures.js";
|
|
6
|
+
export * from "./gemini-cli.js";
|
|
7
|
+
export * from "./grok.js";
|
|
8
|
+
export * from "./kimi.js";
|
|
5
9
|
export * from "./manual.js";
|
|
6
10
|
export * from "./opencode.js";
|
|
7
11
|
export * from "./openrouter.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAW3D,eAAO,MAAM,UAAU,EAAE,SAAS,iBAAiB,EAUlD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
export * from "./antigravity.js";
|
|
2
2
|
export * from "./claude.js";
|
|
3
3
|
export * from "./codex.js";
|
|
4
|
+
export * from "./contract-gate.js";
|
|
4
5
|
export * from "./fixtures.js";
|
|
6
|
+
export * from "./gemini-cli.js";
|
|
7
|
+
export * from "./grok.js";
|
|
8
|
+
export * from "./kimi.js";
|
|
5
9
|
export * from "./manual.js";
|
|
6
10
|
export * from "./opencode.js";
|
|
7
11
|
export * from "./openrouter.js";
|
|
8
12
|
import { antigravityConnector } from "./antigravity.js";
|
|
9
13
|
import { claudeConnector } from "./claude.js";
|
|
10
14
|
import { codexConnector } from "./codex.js";
|
|
15
|
+
import { geminiCliConnector } from "./gemini-cli.js";
|
|
16
|
+
import { grokConnector } from "./grok.js";
|
|
17
|
+
import { kimiConnector } from "./kimi.js";
|
|
11
18
|
import { manualConnector } from "./manual.js";
|
|
12
19
|
import { opencodeConnector } from "./opencode.js";
|
|
13
20
|
import { openrouterConnector } from "./openrouter.js";
|
|
@@ -16,7 +23,10 @@ export const connectors = [
|
|
|
16
23
|
openrouterConnector,
|
|
17
24
|
codexConnector,
|
|
18
25
|
antigravityConnector,
|
|
26
|
+
geminiCliConnector,
|
|
19
27
|
opencodeConnector,
|
|
28
|
+
grokConnector,
|
|
29
|
+
kimiConnector,
|
|
20
30
|
manualConnector
|
|
21
31
|
];
|
|
22
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAiC;IACtD,eAAe;IACf,mBAAmB;IACnB,cAAc;IACd,oBAAoB;IACpB,iBAAiB;IACjB,eAAe;CAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAiC;IACtD,eAAe;IACf,mBAAmB;IACnB,cAAc;IACd,oBAAoB;IACpB,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,eAAe;CAChB,CAAC"}
|
package/dist/kimi.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ConnectionTool, ConnectorContract, RawMeter } from "@openlimiter/core";
|
|
2
|
+
export declare const kimiLabels: {
|
|
3
|
+
readonly credentialOrigin: "official-local-tool";
|
|
4
|
+
readonly dataInterfaceStatus: "internal-endpoint";
|
|
5
|
+
readonly automationRisk: "high";
|
|
6
|
+
readonly verification: "UNVERIFIED";
|
|
7
|
+
};
|
|
8
|
+
export declare const kimiEncoding: "json";
|
|
9
|
+
export declare function parseKimiPayload(payload: unknown, now: string): RawMeter[] | null;
|
|
10
|
+
/** The local application that owns this credential. */
|
|
11
|
+
export declare const KIMI_TOOL: ConnectionTool;
|
|
12
|
+
export declare const kimiConnector: ConnectorContract;
|
|
13
|
+
//# sourceMappingURL=kimi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi.d.ts","sourceRoot":"","sources":["../src/kimi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAU3B,eAAO,MAAM,UAAU;;;;;CAKa,CAAC;AAErC,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AA+D5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAkDjF;AAED,uDAAuD;AACvD,eAAO,MAAM,SAAS,EAAE,cAA2B,CAAC;AAEpD,eAAO,MAAM,aAAa,EAAE,iBAmB3B,CAAC"}
|
package/dist/kimi.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { connectorConnection, futureInstantFromRfc3339, plausibleResetHorizon, rawMeter, record, shortExpiry } from "./shared.js";
|
|
2
|
+
export const kimiLabels = {
|
|
3
|
+
credentialOrigin: "official-local-tool",
|
|
4
|
+
dataInterfaceStatus: "internal-endpoint",
|
|
5
|
+
automationRisk: "high",
|
|
6
|
+
verification: "UNVERIFIED"
|
|
7
|
+
};
|
|
8
|
+
export const kimiEncoding = "json";
|
|
9
|
+
function numeric(value) {
|
|
10
|
+
const parsed = typeof value === "string" ? Number(value) : value;
|
|
11
|
+
return typeof parsed === "number" &&
|
|
12
|
+
Number.isFinite(parsed) &&
|
|
13
|
+
parsed >= 0 &&
|
|
14
|
+
parsed <= 1_000_000_000_000
|
|
15
|
+
? parsed
|
|
16
|
+
: null;
|
|
17
|
+
}
|
|
18
|
+
function quota(value, now, horizon) {
|
|
19
|
+
const detail = record(value);
|
|
20
|
+
if (detail === null)
|
|
21
|
+
return null;
|
|
22
|
+
const used = numeric(detail["used"]);
|
|
23
|
+
const limit = numeric(detail["limit"]);
|
|
24
|
+
if (used === null || limit === null || limit <= 0 || used > limit)
|
|
25
|
+
return null;
|
|
26
|
+
const resetAt = futureInstantFromRfc3339(detail["resetTime"], now, plausibleResetHorizon(horizon));
|
|
27
|
+
if (resetAt === null)
|
|
28
|
+
return null;
|
|
29
|
+
return { percent: used / limit * 100, resetAt };
|
|
30
|
+
}
|
|
31
|
+
function durationSeconds(value) {
|
|
32
|
+
const window = record(value);
|
|
33
|
+
if (window === null)
|
|
34
|
+
return null;
|
|
35
|
+
const duration = window["duration"];
|
|
36
|
+
if (typeof duration !== "number" || !Number.isInteger(duration) || duration <= 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const multiplier = {
|
|
40
|
+
TIME_UNIT_MINUTE: 60,
|
|
41
|
+
TIME_UNIT_HOUR: 3_600,
|
|
42
|
+
TIME_UNIT_DAY: 86_400,
|
|
43
|
+
TIME_UNIT_WEEK: 604_800
|
|
44
|
+
}[String(window["timeUnit"] ?? "")];
|
|
45
|
+
if (multiplier === undefined)
|
|
46
|
+
return null;
|
|
47
|
+
const seconds = duration * multiplier;
|
|
48
|
+
return Number.isSafeInteger(seconds) && seconds <= 31_536_000 ? seconds : null;
|
|
49
|
+
}
|
|
50
|
+
function meterName(seconds, ordinal) {
|
|
51
|
+
const base = seconds === 300
|
|
52
|
+
? "FIVE_MINUTE"
|
|
53
|
+
: seconds === 18_000
|
|
54
|
+
? "FIVE_HOUR"
|
|
55
|
+
: seconds === 86_400
|
|
56
|
+
? "DAILY"
|
|
57
|
+
: seconds === 604_800
|
|
58
|
+
? "SEVEN_DAY"
|
|
59
|
+
: `WINDOW_${seconds}`;
|
|
60
|
+
const meter = ordinal === 1 ? base : `${base}_${ordinal}`;
|
|
61
|
+
return /^[A-Z][A-Z0-9_]{0,31}$/u.test(meter) ? meter : null;
|
|
62
|
+
}
|
|
63
|
+
export function parseKimiPayload(payload, now) {
|
|
64
|
+
const root = record(payload);
|
|
65
|
+
const expiresAt = shortExpiry(now);
|
|
66
|
+
if (root === null || expiresAt === null)
|
|
67
|
+
return null;
|
|
68
|
+
const weekly = quota(root["usage"], now, 604_800);
|
|
69
|
+
if (weekly === null)
|
|
70
|
+
return null;
|
|
71
|
+
const meters = [rawMeter({
|
|
72
|
+
provider: "KIMI",
|
|
73
|
+
meter: "WEEKLY",
|
|
74
|
+
value: weekly.percent,
|
|
75
|
+
window: { kind: "rolling", durationSeconds: 604_800 },
|
|
76
|
+
resetAt: weekly.resetAt,
|
|
77
|
+
source: "internal_payload",
|
|
78
|
+
precision: "estimated",
|
|
79
|
+
observedAt: now,
|
|
80
|
+
expiresAt,
|
|
81
|
+
labels: kimiLabels
|
|
82
|
+
})];
|
|
83
|
+
const limits = root["limits"];
|
|
84
|
+
if (limits !== undefined && !Array.isArray(limits))
|
|
85
|
+
return null;
|
|
86
|
+
const ordinals = new Map();
|
|
87
|
+
for (const entryValue of Array.isArray(limits) ? limits : []) {
|
|
88
|
+
const entry = record(entryValue);
|
|
89
|
+
if (entry === null)
|
|
90
|
+
return null;
|
|
91
|
+
const detail = record(entry["detail"]);
|
|
92
|
+
if (detail === null)
|
|
93
|
+
continue;
|
|
94
|
+
const hasQuota = ["used", "limit", "resetTime"].some((field) => field in detail);
|
|
95
|
+
if (!hasQuota)
|
|
96
|
+
continue;
|
|
97
|
+
const seconds = durationSeconds(entry["window"]);
|
|
98
|
+
if (seconds === null)
|
|
99
|
+
return null;
|
|
100
|
+
const reading = quota(detail, now, seconds);
|
|
101
|
+
if (reading === null)
|
|
102
|
+
return null;
|
|
103
|
+
const ordinal = (ordinals.get(seconds) ?? 0) + 1;
|
|
104
|
+
ordinals.set(seconds, ordinal);
|
|
105
|
+
const meter = meterName(seconds, ordinal);
|
|
106
|
+
if (meter === null)
|
|
107
|
+
return null;
|
|
108
|
+
meters.push(rawMeter({
|
|
109
|
+
provider: "KIMI",
|
|
110
|
+
meter,
|
|
111
|
+
value: reading.percent,
|
|
112
|
+
window: { kind: "rolling", durationSeconds: seconds },
|
|
113
|
+
resetAt: reading.resetAt,
|
|
114
|
+
source: "internal_payload",
|
|
115
|
+
precision: "estimated",
|
|
116
|
+
observedAt: now,
|
|
117
|
+
expiresAt,
|
|
118
|
+
labels: kimiLabels
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
return meters;
|
|
122
|
+
}
|
|
123
|
+
/** The local application that owns this credential. */
|
|
124
|
+
export const KIMI_TOOL = "Kimi CLI";
|
|
125
|
+
export const kimiConnector = {
|
|
126
|
+
id: "kimi",
|
|
127
|
+
displayName: "Kimi",
|
|
128
|
+
encoding: kimiEncoding,
|
|
129
|
+
labels: kimiLabels,
|
|
130
|
+
detect(environment) {
|
|
131
|
+
return environment["KIMI_USAGE_PAYLOAD"] === "1";
|
|
132
|
+
},
|
|
133
|
+
async read(context) {
|
|
134
|
+
const meters = parseKimiPayload(context.payload, context.now);
|
|
135
|
+
const connection = connectorConnection(meters !== null, context.payload, KIMI_TOOL);
|
|
136
|
+
return meters === null
|
|
137
|
+
? { ok: false, reason: "unknown", connection }
|
|
138
|
+
: { ok: true, meters, connection };
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=kimi.js.map
|
package/dist/kimi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi.js","sourceRoot":"","sources":["../src/kimi.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,E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AAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,kBAAkB;YAC1B,SAAS,EAAE,WAAW;YACtB,UAAU,EAAE,GAAG;YACf,SAAS;YACT,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,SAAS,GAAmB,UAAU,CAAC;AAEpD,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,EAAE,EAAE,MAAM;IACV,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,CAAC,WAAW;QAChB,OAAO,WAAW,CAAC,oBAAoB,CAAC,KAAK,GAAG,CAAC;IACnD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAO;QAChB,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,mBAAmB,CACpC,MAAM,KAAK,IAAI,EACf,OAAO,CAAC,OAAO,EACf,SAAS,CACV,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/manual.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 manualLabels: {
|
|
3
3
|
readonly credentialOrigin: "user-entered";
|
|
4
4
|
readonly dataInterfaceStatus: "manual";
|
|
@@ -29,5 +29,7 @@ export declare const manualInput: {
|
|
|
29
29
|
* a document where nothing survives returns null. Nothing is repaired.
|
|
30
30
|
*/
|
|
31
31
|
export declare function parseManualPayload(payload: unknown, now: string): RawMeter[] | null;
|
|
32
|
+
/** A person maintains this document, so no tool is named. */
|
|
33
|
+
export declare const MANUAL_TOOL: ConnectionTool;
|
|
32
34
|
export declare const manualConnector: ConnectorContract;
|
|
33
35
|
//# sourceMappingURL=manual.d.ts.map
|
package/dist/manual.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../src/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../src/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAGjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAU3B,eAAO,MAAM,YAAY;;;;;CAKW,CAAC;AAErC,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAE5D,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAKX;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CA+BnF;AAED,6DAA6D;AAC7D,eAAO,MAAM,WAAW,EAAE,cAAqB,CAAC;AAEhD,eAAO,MAAM,eAAe,EAAE,iBAmB7B,CAAC"}
|
package/dist/manual.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { boundedNumber, futureInstant, rawMeter, record, shortExpiry } from "./shared.js";
|
|
1
|
+
import { boundedNumber, connectorConnection, futureInstant, rawMeter, record, shortExpiry } from "./shared.js";
|
|
2
2
|
export const manualLabels = {
|
|
3
3
|
credentialOrigin: "user-entered",
|
|
4
4
|
dataInterfaceStatus: "manual",
|
|
@@ -62,6 +62,8 @@ export function parseManualPayload(payload, now) {
|
|
|
62
62
|
}
|
|
63
63
|
return meters.length === 0 ? null : meters;
|
|
64
64
|
}
|
|
65
|
+
/** A person maintains this document, so no tool is named. */
|
|
66
|
+
export const MANUAL_TOOL = null;
|
|
65
67
|
export const manualConnector = {
|
|
66
68
|
id: "manual",
|
|
67
69
|
encoding: "json",
|
|
@@ -72,9 +74,10 @@ export const manualConnector = {
|
|
|
72
74
|
},
|
|
73
75
|
async read(context) {
|
|
74
76
|
const meters = parseManualPayload(context.payload, context.now);
|
|
77
|
+
const connection = connectorConnection(meters !== null, context.payload, MANUAL_TOOL);
|
|
75
78
|
return meters === null
|
|
76
|
-
? { ok: false, reason: "unknown" }
|
|
77
|
-
: { ok: true, meters };
|
|
79
|
+
? { ok: false, reason: "unknown", connection }
|
|
80
|
+
: { ok: true, meters, connection };
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
//# sourceMappingURL=manual.js.map
|
package/dist/manual.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual.js","sourceRoot":"","sources":["../src/manual.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manual.js","sourceRoot":"","sources":["../src/manual.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,gBAAgB,EAAE,cAAc;IAChC,mBAAmB,EAAE,QAAQ;IAC7B,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,YAAY;CACQ,CAAC;AAErC,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAk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Status, ConnectionTool, ConnectorContract, RawMeter } from "@openlimiter/core";
|
|
2
2
|
/**
|
|
3
3
|
* The OpenCode usage reader, and the least trustworthy one in the product.
|
|
4
4
|
*
|
|
@@ -26,11 +26,23 @@ export declare const opencodeLabels: {
|
|
|
26
26
|
readonly verification: "UNVERIFIED";
|
|
27
27
|
};
|
|
28
28
|
export declare const opencodeHonesty: "UNVERIFIED_AUTHENTICATED_SCRAPE_HIGH_RISK";
|
|
29
|
+
/**
|
|
30
|
+
* BETA, and stated rather than implied.
|
|
31
|
+
*
|
|
32
|
+
* Every other reader in this package reads an interface: documented, private,
|
|
33
|
+
* or declared in a vendor's own client source, but an interface. This one reads
|
|
34
|
+
* a page that was designed for a person's eyes, whose wording nobody promised
|
|
35
|
+
* and which has already been renamed once underneath it. That is a different
|
|
36
|
+
* class of thing, and a surface that shows it beside the others has to be able
|
|
37
|
+
* to say so.
|
|
38
|
+
*/
|
|
39
|
+
export declare const opencodeMaturity: "beta";
|
|
29
40
|
export declare const opencodeInput: {
|
|
30
41
|
readonly kind: "authenticated_page_payload";
|
|
31
42
|
readonly pathTemplate: "{browserSession}/usage";
|
|
32
43
|
readonly readMode: "read_only";
|
|
33
44
|
readonly honesty: "UNVERIFIED_AUTHENTICATED_SCRAPE_HIGH_RISK";
|
|
45
|
+
readonly maturity: "beta";
|
|
34
46
|
};
|
|
35
47
|
/**
|
|
36
48
|
* What this reader reads: text, not JSON.
|
|
@@ -59,21 +71,49 @@ export declare const OPENCODE_MAX_SEGMENT_CHARS = 2000;
|
|
|
59
71
|
* limit still cannot make the label scan expensive.
|
|
60
72
|
*/
|
|
61
73
|
export declare const OPENCODE_MAX_PAGE_CHARS = 1048576;
|
|
74
|
+
export type OpencodeMeter = "FIVE_HOUR" | "SEVEN_DAY" | "MONTHLY";
|
|
62
75
|
/**
|
|
63
|
-
* The
|
|
76
|
+
* The cadences the workspace page renders, and how each one is recognised.
|
|
77
|
+
*
|
|
78
|
+
* This used to be three exact phrases, all three required, and the page renamed
|
|
79
|
+
* them. Three exact strings is the most brittle possible way to read a document
|
|
80
|
+
* whose wording nobody promised us, and the failure was total: one renamed
|
|
81
|
+
* heading and the whole reader went dark on a page still rendering all three
|
|
82
|
+
* figures.
|
|
64
83
|
*
|
|
65
|
-
*
|
|
84
|
+
* So a cadence is now recognised by the WORD that names it, case insensitively,
|
|
85
|
+
* with the wordings seen so far and the obvious neighbours of each. Structure
|
|
86
|
+
* still does the real work: a match only produces a reading if it sits in a
|
|
87
|
+
* container that holds a percentage and names no other cadence, which is the
|
|
88
|
+
* guard that stops a heading from borrowing the figure beside it.
|
|
66
89
|
*/
|
|
67
90
|
export declare const OPENCODE_WINDOWS: readonly {
|
|
68
|
-
readonly
|
|
91
|
+
readonly meter: OpencodeMeter;
|
|
69
92
|
readonly seconds: number;
|
|
93
|
+
/** Every wording this cadence has been seen under, matched case blind. */
|
|
94
|
+
readonly pattern: RegExp;
|
|
70
95
|
}[];
|
|
71
96
|
/**
|
|
72
|
-
*
|
|
97
|
+
* Every provider window, including the monthly quota.
|
|
73
98
|
*
|
|
74
|
-
* The
|
|
75
|
-
*
|
|
99
|
+
* The shared policy still derives the binding window by choosing the highest
|
|
100
|
+
* percentage. Keeping the three source windows lets every surface state which
|
|
101
|
+
* cadence a number belongs to instead of hiding the monthly value inside one
|
|
102
|
+
* synthetic primary meter.
|
|
76
103
|
*/
|
|
77
104
|
export declare function parseOpencodePayload(payload: unknown, now: string): RawMeter[] | null;
|
|
105
|
+
/** The local application that owns this browser session. */
|
|
106
|
+
export declare const OPENCODE_TOOL: ConnectionTool;
|
|
107
|
+
/**
|
|
108
|
+
* The connection this reader reports, which is not the generic one.
|
|
109
|
+
*
|
|
110
|
+
* A page it cannot read has two very different causes, and they need two
|
|
111
|
+
* different sentences. A logged out workspace renders a sign in form, and the
|
|
112
|
+
* fix is one click in a window the person already has open. Anything else is a
|
|
113
|
+
* layout this build no longer understands, which is ours to fix, and the honest
|
|
114
|
+
* instruction is to reconnect and tell us if it keeps happening. Neither one
|
|
115
|
+
* throws, and neither one is silence.
|
|
116
|
+
*/
|
|
117
|
+
export declare function opencodeConnection(parsed: boolean, payload: unknown): ConnectionStatus;
|
|
78
118
|
export declare const opencodeConnector: ConnectorContract;
|
|
79
119
|
//# sourceMappingURL=opencode.d.ts.map
|
package/dist/opencode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../src/opencode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../src/opencode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAIjB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAQ3B;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,cAAc;;;;;CAKS,CAAC;AAErC,eAAO,MAAM,eAAe,EAAG,2CAAoD,CAAC;AAEpF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,QAA8C,CAAC;AAE5E,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAG,MAAe,CAAC;AAEhD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AA6ChD;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,UAAY,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,EAgBA,CAAC;AAqPF;;;;;;;GAOG;AACH,wBAAgB,oB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