dsh-openrouter-spend 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -5,11 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.1] - 2026-10-05
9
+
10
+ ### Fixed
11
+
12
+ - `credentialRef` rejects a blank reference at activation (schema pattern).
13
+ - README states the real placement of each figure (chip popover vs. Settings), the Management API key path in the OpenRouter dashboard, UTC-day semantics, and `historyDays` range coverage.
14
+
8
15
  ## [0.1.0] - 2026-10-05
9
16
 
10
17
  ### Added
11
18
 
12
- - Spend chip under the composer: today's cost with a 7/30-day popover, per-API-key filter, and per-model table.
13
- - Settings page: daily bar chart, per-key totals, per-model split, prepaid balance, management-key storage, and browser-local refresh interval.
19
+ - Spend chip under the composer with today's cost; popover with 7/30-day ranges, per-API-key filter, per-model table, daily bar chart, prepaid balance, and lifetime spend.
20
+ - Settings page: management-key storage and clear, browser-local refresh interval and per-key filter.
14
21
  - `config` schema (`credentialRef`, `apiBase`, `refreshSeconds`, `historyDays`, `timeoutMs`) validated at activation.
15
22
  - English, Russian, and Chinese display metadata and UI copy.
package/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  <h1 align="center">dsh-openrouter-spend</h1>
6
6
 
7
7
  <p align="center">
8
- Real <a href="https://openrouter.ai">OpenRouter</a> spend inside
8
+ OpenRouter spend inside
9
9
  <a href="https://github.com/deepseek-ai/deepseek-harness">DeepSeek Harness</a> —
10
- billed money from OpenRouter's own analytics, not a token estimate priced from a local table.
10
+ billed USD from OpenRouter's own analytics API, not token estimates priced from a local table.
11
11
  </p>
12
12
 
13
13
  <p align="center">
@@ -16,30 +16,34 @@
16
16
  <img src="https://img.shields.io/badge/DeepSeek%20Harness-plugin-2f6feb?style=flat-square" alt="DeepSeek Harness plugin">
17
17
  </p>
18
18
 
19
- - A live spend chip under the composer: today's cost, with a popover for the last 7 and 30 days.
20
- - A Settings page with the daily bar chart, a per-model table, per-API-key totals, and the remaining prepaid balance.
21
- - One cached poll per refresh window: several open tabs cost one request to OpenRouter.
19
+ ## What you get
20
+
21
+ - **Chip under the composer** — spend for the selected range and API key: today, 7 days, or 30 days.
22
+ - **Chip popover** — range and API-key filters, today's spend per model, a daily bar chart across the window, prepaid balance and lifetime spend.
23
+ - **Settings → OpenRouter spend** — store or clear the management key, set the refresh interval, filter by API key.
24
+
25
+ The host half caches the summary for `refreshSeconds` and coalesces concurrent refreshes, so any number of open tabs cost one OpenRouter query per refresh window. When a refresh fails, the last good figures stay on screen and the reason is shown instead of an empty panel.
22
26
 
23
27
  ## Requirements
24
28
 
25
- - DeepSeek Harness with the web GUI (the plugin is inactive in headless profiles: it needs the `credentials`, `webServer`, and `connection` services).
26
- - An OpenRouter **management API key** — Settings → API keys → Management in the OpenRouter dashboard. A regular inference key cannot read analytics.
29
+ - DeepSeek Harness web profile. The plugin needs the `credentials`, `webServer`, and `connection` services and stays inactive in profiles without them (for example, headless).
30
+ - An OpenRouter **Management API key** — OpenRouter dashboard → Settings → Management API Keys → Create New Key ([OpenRouter docs](https://openrouter.ai/docs/guides/overview/auth/management-api-keys)). A regular inference key is rejected: `403 Only management keys can perform this operation`.
27
31
 
28
32
  ## Install
29
33
 
30
- From npm:
34
+ From npm (`web` is the default web-GUI profile; use your own profile name instead if you run one):
31
35
 
32
36
  ```sh
33
- dsh plugin --profile demo add dsh-openrouter-spend
37
+ dsh plugin --profile web add dsh-openrouter-spend
34
38
  ```
35
39
 
36
- From GitHub (no build step, so no build-script permission is needed):
40
+ From GitHub (plain JavaScript, no build step and no build-script permission):
37
41
 
38
42
  ```sh
39
- dsh plugin --profile demo add github:RyabykinIlya/dsh-openrouter-spend#v0.1.0
43
+ dsh plugin --profile web add github:RyabykinIlya/dsh-openrouter-spend#v0.1.1
40
44
  ```
41
45
 
42
- Then open Settings → OpenRouter spend in the GUI and store the management key. Done — the chip starts filling in.
46
+ Then open Settings → OpenRouter spend and paste the management key.
43
47
 
44
48
  ## Configuration
45
49
 
@@ -53,16 +57,19 @@ Every field can be overridden in the profile's `cordis.patch.yml` row; the schem
53
57
  | `historyDays` | `30` | 2–366, integer | Days of history the summary window covers, today included |
54
58
  | `timeoutMs` | `15000` | 1000–120000, integer | Per-request deadline against OpenRouter |
55
59
 
56
- Viewing preferences (per-key filter, refresh interval override) are browser-local and never leave your machine.
60
+ Viewing preferences (per-key filter, refresh interval override) are browser-local (`localStorage`).
57
61
 
58
- ## How it works
62
+ ## What the numbers are
59
63
 
60
- The host half queries `POST /api/v1/analytics/query` (`total_usage` and `request_count`, split by API key and model, per UTC day) and `GET /api/v1/credits`, caches the summary for `refreshSeconds`, and serves it to the browser half. When a refresh fails, the last good figures stay on screen and the reason is shown instead of an empty panel.
64
+ - Figures are `total_usage` — USD OpenRouter actually billed — from `POST /api/v1/analytics/query`, grouped per UTC day by API key and model.
65
+ - "Today" is the current UTC day.
66
+ - Balance is `total_credits − total_usage` from `GET /api/v1/credits`: what remains of prepaid credits.
67
+ - The 7-day and 30-day ranges cover at most `historyDays` days; keep `historyDays ≥ 30` for full coverage.
61
68
 
62
69
  ## Security
63
70
 
64
71
  - The management key is stored through the Harness credentials service (`credentials.set`), not in this package's files, and is never echoed back to the browser.
65
- - The summary and credential routes are fenced by the connection trust check. Anyone who can pass that check — by default, the browser session on your local Harness port — can read your spend figures. Do not expose the Harness web port publicly without its own authentication.
72
+ - The summary and credential routes are fenced by the connection trust check. Anyone who passes that check — by default, the browser session on your local Harness port — can read your spend figures. Do not expose the Harness web port publicly without its own authentication.
66
73
 
67
74
  ## License
68
75
 
@@ -70,4 +77,4 @@ The host half queries `POST /api/v1/analytics/query` (`total_usage` and `request
70
77
 
71
78
  ## По-русски
72
79
 
73
- Плагин для DeepSeek Harness: под полем ввода показывает реальные расходы аккаунта OpenRouter за сегодня (данные из официальной аналитики OpenRouter), а в настройках — график по дням, разбивку по моделям и API-ключам и остаток предоплаченных кредитов. Установка: `dsh plugin --profile demo add dsh-openrouter-spend`, затем Settings → OpenRouter spend → ввести управляющий ключ (Management API key из кабинета OpenRouter).
80
+ Плагин для DeepSeek Harness показывает реальные списания аккаунта OpenRouter (данные из аналитики OpenRouter, в долларах, по UTC-дням): чип под полем ввода с выбором периода сегодня / 7 дней / 30 дней, в поповере — разбивка по моделям за сегодня, график по дням, фильтр по API-ключам и остаток предоплаченных кредитов. В Settings → OpenRouter spend задаётся управляющий ключ и интервал обновления. Установка: `dsh plugin --profile web add dsh-openrouter-spend`; нужен Management API key из кабинета OpenRouter (Settings → Management API Keys) — обычный ключ модели для аналитики не подходит.
package/index.js CHANGED
@@ -37,7 +37,7 @@ const MAX_ANALYTICS_ROWS = 500
37
37
  * the API, the credential, or the cadence without an edit to this file.
38
38
  */
39
39
  export const Config = Schema.object({
40
- credentialRef: Schema.string().default('OPENROUTER_MGMT_API_KEY')
40
+ credentialRef: Schema.string().pattern(/^\S+$/).default('OPENROUTER_MGMT_API_KEY')
41
41
  .description('Credentials reference holding the OpenRouter management API key.'),
42
42
  apiBase: Schema.string().pattern(/^https:\/\//).default('https://openrouter.ai/api/v1')
43
43
  .description('OpenRouter REST API root; https only.'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-openrouter-spend",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "DeepSeek Harness plugin: shows what the OpenRouter account actually charged today — under the composer and in Settings, split by model and API key.",
5
5
  "keywords": ["dsh", "dsh-plugin", "cordis", "openrouter", "spend", "cost", "analytics"],
6
6
  "license": "MIT",