@kunkun.sh/kuota 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +130 -2
- package/bin/kuota.mjs +3 -0
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +1303 -0
- package/dist/dist-CIjerpSd.mjs +576 -0
- package/dist/history-G4o4HVvW.d.mts +36 -0
- package/dist/history-oOXsjdWR.mjs +236 -0
- package/dist/history.d.mts +3 -0
- package/dist/history.mjs +3 -0
- package/dist/index-2k6FkhpT.d.mts +81 -0
- package/dist/index-NHzh2TGn.d.mts +168 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +7 -0
- package/dist/main-B-hZbKK1.mjs +340 -0
- package/dist/metrics-Bzmrfgn-.mjs +307 -0
- package/dist/metrics-D7oNul_9.d.mts +30 -0
- package/dist/metrics.d.mts +3 -0
- package/dist/metrics.mjs +3 -0
- package/dist/parsers.d.mts +13 -0
- package/dist/parsers.mjs +19 -0
- package/dist/providers.d.mts +2 -0
- package/dist/providers.mjs +1 -0
- package/dist/src-C48Ew_L9.mjs +707 -0
- package/dist/src-y_QKmTyj.mjs +309 -0
- package/dist/web/assets/index-ihoe7C_u.js +27 -0
- package/dist/web/index.html +30 -0
- package/dist/web-server-DkdA5Ixj.mjs +154 -0
- package/package.json +73 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Huakun Shen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kunkun.sh/kuota
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Truthful multi-provider AI subscription & quota suite: reusable TypeScript library, interactive TUI, headless CLI, and embedded loopback Web Workbench.
|
|
4
|
+
|
|
5
|
+
Supports **OpenAI Codex**, **Anthropic Claude Code**, and **Google Antigravity**.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🚀 CLI & Multi-Surface Usage
|
|
10
|
+
|
|
11
|
+
Run directly with zero installation via `npx`:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# 1. Interactive terminal TUI (full-screen UniView dashboard with % left & pace markers)
|
|
15
|
+
npx @kunkun.sh/kuota
|
|
16
|
+
npx @kunkun.sh/kuota tui
|
|
17
|
+
|
|
18
|
+
# 2. Web Workbench (embedded HTTP server + React 19 UI with 3D activity terrain & Dynamic Island)
|
|
19
|
+
npx @kunkun.sh/kuota web
|
|
20
|
+
npx @kunkun.sh/kuota web --port 5173 --no-open
|
|
21
|
+
|
|
22
|
+
# 3. Headless CLI commands (human readable or JSON)
|
|
23
|
+
npx @kunkun.sh/kuota status
|
|
24
|
+
npx @kunkun.sh/kuota status --json
|
|
25
|
+
npx @kunkun.sh/kuota doctor
|
|
26
|
+
npx @kunkun.sh/kuota pace
|
|
27
|
+
npx @kunkun.sh/kuota forecast
|
|
28
|
+
npx @kunkun.sh/kuota providers
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 📦 Library Usage
|
|
34
|
+
|
|
35
|
+
Install as a dependency in your application, server, or Kunkun extension:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @kunkun.sh/kuota
|
|
39
|
+
# or
|
|
40
|
+
bun add @kunkun.sh/kuota
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 1. Unified AI Quota Parsers
|
|
44
|
+
|
|
45
|
+
Parse raw JSON / RPC payloads received from vendor CLIs or APIs into normalized, typed `QuotaSnapshot` structures:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import {
|
|
49
|
+
parseProviderQuota,
|
|
50
|
+
parseCodexRateLimits,
|
|
51
|
+
parseClaudeOAuthUsage,
|
|
52
|
+
parseAntigravityUsageReport,
|
|
53
|
+
type QuotaSnapshot,
|
|
54
|
+
} from "@kunkun.sh/kuota";
|
|
55
|
+
|
|
56
|
+
// Universal dispatcher:
|
|
57
|
+
const snapshot: QuotaSnapshot = parseProviderQuota("codex", rawVendorData);
|
|
58
|
+
|
|
59
|
+
// Or direct modular imports (browser & edge friendly):
|
|
60
|
+
import { parseCodexRateLimits } from "@kunkun.sh/kuota/parsers";
|
|
61
|
+
const codexSnapshot = parseCodexRateLimits(rawAppServerResponse);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 2. Time Budget & Ideal Pace Calculation
|
|
65
|
+
|
|
66
|
+
Calculate linear time-budget pace without guessing:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { calculatePace, windowProfile } from "@kunkun.sh/kuota";
|
|
70
|
+
|
|
71
|
+
// Determine window cadence (e.g. 5h vs 7-day weekly)
|
|
72
|
+
const profile = windowProfile("codex", "primary", snapshot.windows[0].resetAt);
|
|
73
|
+
|
|
74
|
+
const pace = calculatePace({
|
|
75
|
+
now: new Date(),
|
|
76
|
+
startAt: new Date(Date.now() - 2 * 86_400_000),
|
|
77
|
+
resetAt: new Date(snapshot.windows[0].resetAt!),
|
|
78
|
+
usedPercent: snapshot.windows[0].usedPercent,
|
|
79
|
+
semantics: profile.semantics,
|
|
80
|
+
startSource: "provider",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (pace) {
|
|
84
|
+
console.log(`Ideal balance: ${pace.idealRemainingPercent}% remaining`);
|
|
85
|
+
console.log(`Actual balance: ${100 - pace.actualUsedPercent}% remaining`);
|
|
86
|
+
console.log(`Pace delta: ${pace.paceDeltaPoints > 0 ? "Ahead" : "Behind"} of pace`);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3. Live Provider Execution & Subprocess Service
|
|
91
|
+
|
|
92
|
+
Read quota directly from local installed developer tools (`codex`, `claude`, `agy`):
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { readAll, readCodex, createQuotaService } from "@kunkun.sh/kuota";
|
|
96
|
+
import { Effect } from "effect";
|
|
97
|
+
|
|
98
|
+
// Execute all detected providers via Effect TS
|
|
99
|
+
const program = readAll(["codex", "antigravity"]);
|
|
100
|
+
const snapshots = await Effect.runPromise(program);
|
|
101
|
+
|
|
102
|
+
// Or create a managed cached service
|
|
103
|
+
const service = createQuotaService();
|
|
104
|
+
const cachedCodex = await service.read("codex");
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🧩 Subpath Exports
|
|
110
|
+
|
|
111
|
+
| Import Path | Description |
|
|
112
|
+
| ----------- | ----------- |
|
|
113
|
+
| `@kunkun.sh/kuota` | Full library (Parsers, Metrics, History, Providers, Schemas) |
|
|
114
|
+
| `@kunkun.sh/kuota/parsers` | Pure data parsers (zero platform dependencies, Node & Browser safe) |
|
|
115
|
+
| `@kunkun.sh/kuota/metrics` | Linear pacing algorithms and forecasting models |
|
|
116
|
+
| `@kunkun.sh/kuota/history` | Append-only local JSONL journal and query engine |
|
|
117
|
+
| `@kunkun.sh/kuota/providers` | Subprocess adapters for Codex, Claude, and Antigravity |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🔒 Security and Data Honesty
|
|
122
|
+
|
|
123
|
+
- **Zero credential leaks**: API keys, tokens, session cookies, and private prompts are never stored, logged, or serialized.
|
|
124
|
+
- **Fail-safe status**: Unavailable or unauthenticated accounts are reported as `"unauthenticated"` or `"unavailable"` with honest error codes, never fabricated as `0% left`.
|
|
125
|
+
- **Shared peer dependencies**: Core dependencies like `effect` and `react` are not bundled into an opaque monolith, avoiding dual-package hazard in consumer apps.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 📄 License
|
|
130
|
+
|
|
131
|
+
MIT © [Huakun Shen](https://github.com/HuakunShen)
|
package/bin/kuota.mjs
ADDED
package/dist/bin.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|