pi-telegram-notifier 0.1.5 → 0.1.6
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/README.md +1 -0
- package/docs/providers.md +1 -0
- package/package.json +40 -10
- package/src/quota.ts +4 -2
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ The **quota/credit** field supports these Pi provider IDs (using the credential
|
|
|
41
41
|
| --- | --- | --- | --- |
|
|
42
42
|
| `openai-codex` | Subscription | ChatGPT OAuth | Remaining 5h / 7d usage-window percentages; [official Codex client endpoint](https://github.com/openai/codex/blob/main/codex-rs/backend-client/src/client/rate_limit_resets.rs). |
|
|
43
43
|
| `anthropic` | Subscription | Claude OAuth | Remaining 5h / 7d usage-window percentages; [private OAuth endpoint](https://github.com/openclaw/openclaw/blob/main/src/infra/provider-usage.fetch.claude.ts). |
|
|
44
|
+
| `claude-bridge` ([pi-claude-bridge](https://www.npmjs.com/package/pi-claude-bridge)) | Subscription | Pi's Claude OAuth (`/login` → Anthropic) | Same 5h / 7d windows as `anthropic`: the bridge has no credential of its own, so the matching `anthropic` model's OAuth login is used. Log Pi and Claude Code into the **same** Anthropic account, otherwise Pi's account quota is shown. Without the login, `Quota unavailable`. |
|
|
44
45
|
| `xai` | Subscription | Grok OAuth | Remaining weekly shared Grok credits percentage, **not** prepaid API credit; [official Grok client endpoint](https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-shell/src/extensions/billing.rs). |
|
|
45
46
|
| `zai` | Subscription (Coding Plan) | Z.ai Coding Plan key | Remaining 5h **model** quota percentage; [Z.ai usage plugin endpoint](https://github.com/zai-org/zai-coding-plugins/blob/main/plugins/glm-plan-usage/skills/usage-query-skill/scripts/query-usage.mjs). Not the separate MCP tool quota. |
|
|
46
47
|
| `zai-coding-cn` | Subscription (Coding Plan) | China Coding Plan key | Same model quota on `open.bigmodel.cn`. |
|
package/docs/providers.md
CHANGED
|
@@ -12,6 +12,7 @@ Inventory of the 41 built-in provider IDs in the installed Pi model catalog (`@e
|
|
|
12
12
|
| `zai` | Remaining 5-hour Coding Plan model quota from `100 - percentage` for `TOKENS_LIMIT` only; pay-as-you-go keys or unknown plan data show unavailable. | [Official Z.ai usage query script](https://github.com/zai-org/zai-coding-plugins/blob/main/plugins/glm-plan-usage/skills/usage-query-skill/scripts/query-usage.mjs), `GET https://api.z.ai/api/monitor/usage/quota/limit` (not a stable public API) |
|
|
13
13
|
| `zai-coding-cn` | Same Coding Plan model quota for the China host; not the MCP tool quota. | [Official Z.ai usage query script](https://github.com/zai-org/zai-coding-plugins/blob/main/plugins/glm-plan-usage/skills/usage-query-skill/scripts/query-usage.mjs), `GET https://open.bigmodel.cn/api/monitor/usage/quota/limit` (not a stable public API) |
|
|
14
14
|
| `anthropic` | Remaining 5h and/or 7d Claude **subscription** allowance with Pi OAuth only; regular API keys show unavailable. | [OAuth usage client](https://github.com/openclaw/openclaw/blob/main/src/infra/provider-usage.fetch.claude.ts), `GET https://api.anthropic.com/api/oauth/usage` (private endpoint) |
|
|
15
|
+
| `claude-bridge` (extension provider from [pi-claude-bridge](https://github.com/elidickinson/pi-claude-bridge)) | Same Claude subscription windows as `anthropic`. The bridge registers a placeholder key and runs Claude Code with its own login, so the quota is read with Pi's `anthropic` OAuth credential for the same model ID; without that login it shows unavailable. Claude Code's own credential store is deliberately not read, so the quota belongs to Pi's Anthropic account: it matches the bridge turn only when Pi and Claude Code are logged into the same account (the usage response does not identify the account). | Same endpoint as `anthropic` |
|
|
15
16
|
| `xai` | Remaining **weekly Grok subscription** credits with Pi OAuth only. The per-product percentages are not the shared pool; xAI API prepaid credit is a different quantity requiring a management key. | [Official Grok billing client](https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-shell/src/extensions/billing.rs), `GET https://cli-chat-proxy.grok.com/v1/billing?format=credits` (private endpoint); [API management billing](https://docs.x.ai/developers/rest-api-reference/management/billing) |
|
|
16
17
|
| `amazon-bedrock`, `azure-openai-responses`, `cloudflare-ai-gateway`, `cloudflare-workers-ai`, `google-vertex`, `radius`, `vercel-ai-gateway` | Cloud/gateway billing belongs to separate accounts/credentials; no verified remaining plan balance endpoint with Pi's inference credential. | Provider-specific cloud billing tools, not Pi model API keys. |
|
|
17
18
|
| `openai`, `github-copilot` | Subscription balance not exposed through a verified quota endpoint accessible with Pi's resolved inference credential. Admin usage/spending APIs are **not** plan remainder. | [OpenAI organization costs](https://platform.openai.com/docs/api-reference/organization/costs) |
|
package/package.json
CHANGED
|
@@ -1,16 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-telegram-notifier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Telegram notifications for final Pi agent responses and provider balances",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"engines": {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.19.0"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"pi-package",
|
|
12
|
+
"pi",
|
|
13
|
+
"telegram",
|
|
14
|
+
"notifications"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"extensions",
|
|
18
|
+
"src",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"docs/providers.md"
|
|
22
|
+
],
|
|
23
|
+
"imports": {
|
|
24
|
+
"#src/*": "./src/*.ts"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "node --test",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"pi": {
|
|
31
|
+
"extensions": [
|
|
32
|
+
"./extensions/index.ts"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "22.20.4",
|
|
40
|
+
"typescript": "5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/Gybra/pi-telegram-notifier.git"
|
|
45
|
+
}
|
|
16
46
|
}
|
package/src/quota.ts
CHANGED
|
@@ -20,9 +20,11 @@ function remainingPercent(used: unknown): number | undefined {
|
|
|
20
20
|
return typeof used === 'number' && Number.isFinite(used) && used >= 0 && used <= 100 ? 100 - used : undefined;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export async function getQuota(model: Model | undefined, modelRegistry: Pick<ModelRegistry, 'getApiKeyAndHeaders' | 'isUsingOAuth'> | undefined, fetchImpl: typeof fetch = fetch): Promise<string> {
|
|
23
|
+
export async function getQuota(model: Model | undefined, modelRegistry: Pick<ModelRegistry, 'find' | 'getApiKeyAndHeaders' | 'isUsingOAuth'> | undefined, fetchImpl: typeof fetch = fetch): Promise<string> {
|
|
24
|
+
// pi-claude-bridge has no credential of its own; it draws on the same Claude subscription as Pi's Anthropic OAuth login.
|
|
25
|
+
if (model?.provider === 'claude-bridge') model = modelRegistry?.find('anthropic', model.id);
|
|
24
26
|
const provider = model && providers[model.provider];
|
|
25
|
-
if (!provider) return UNAVAILABLE;
|
|
27
|
+
if (!model || !provider) return UNAVAILABLE;
|
|
26
28
|
try {
|
|
27
29
|
if (new URL(model.baseUrl).origin !== provider.origin) return UNAVAILABLE;
|
|
28
30
|
if (['anthropic', 'xai'].includes(model.provider) && !modelRegistry?.isUsingOAuth(model)) return UNAVAILABLE;
|