@aliou/pi-neuralwatt 0.18.0 → 0.18.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/README.md CHANGED
@@ -41,20 +41,20 @@ pi -e ./extensions/provider/index.ts
41
41
 
42
42
  ## Usage
43
43
 
44
- Once installed, select `neuralwatt` as your provider and choose from available models:
44
+ Once installed, select `neuralwatt` as your provider and pick a model:
45
45
 
46
46
  ```
47
- /model neuralwatt meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8
47
+ /model neuralwatt kimi-k3
48
48
  ```
49
49
 
50
50
  ### API surface
51
51
 
52
- Neuralwatt serves every model on two APIs. Pick one via `/neuralwatt:settings` → **API** (or set `provider.api` in the extension config):
52
+ Neuralwatt serves every model on two APIs. Pick one in `/neuralwatt:settings` → **API** (or set `provider.api` in the extension config):
53
53
 
54
- - `openai-completions` (default) — the OpenAI-compatible `chat/completions` endpoint;
55
- - `anthropic-messages` — the Anthropic-compatible `POST /v1/messages` endpoint (vLLM-backed), which streams native tool use and thinking blocks.
54
+ - `openai-completions` (default): the OpenAI-compatible `chat/completions` endpoint.
55
+ - `anthropic-messages`: the Anthropic-compatible `POST /v1/messages` endpoint, which streams native tool use and thinking blocks.
56
56
 
57
- The setting swaps the whole provider (same model ids on both sides) and applies on `/reload`. Usage/cost accounting and quota tracking work on both surfaces: per-request quota headers only exist on chat-completions responses, while `/v1/messages` streams carry the same data as `: energy` / `: cost` SSE comments.
57
+ Both use the same model ids. The setting applies on `/reload`. Cost, energy, and quota tracking work on both.
58
58
 
59
59
  ### Quota Command
60
60
 
@@ -65,82 +65,48 @@ Check your API usage at a glance:
65
65
  ```
66
66
 
67
67
  The quota command shows three tabs:
68
- - **Subscription** (when subscribed) — plan details, energy quota with progress bar, billing period
69
- - **Credits** — credit balance with progress bar, accounting method
70
- - **Usage & Key** — monthly usage (cost, requests, tokens, energy), API key info, key allowance, rate limits
68
+ - **Subscription** (when subscribed): plan details, energy quota with progress bar, billing period
69
+ - **Credits**: credit balance with progress bar, accounting method
70
+ - **Usage & Key**: monthly usage (cost, requests, tokens, energy), API key info, key allowance, rate limits
71
71
 
72
72
  https://github.com/user-attachments/assets/a8994940-c467-4744-a0f2-833cb63923ff
73
73
 
74
74
  ### Quota Warnings
75
75
 
76
- When enabled, the extension notifies you when credits or energy are running low. When you have an active subscription, only energy warnings fire (credits are on-demand top-up only). Warnings use escalation on severity transitions and have a cooldown for `warning` level.
76
+ When enabled, the extension notifies you when credits or energy are running low. With an active subscription, only energy warnings fire (credits are on-demand top-up only).
77
77
 
78
78
  ## Settings
79
79
 
80
80
  Configure features with `/neuralwatt:settings`:
81
81
 
82
82
  - **API** — Choose between `openai-completions` (default) and `anthropic-messages`; applies on `/reload`
83
+ - **API base URL** — Send requests to a different base URL, such as a gateway; empty uses the Neuralwatt API
83
84
  - **Quota command** — Show/hide `/neuralwatt:quota`
84
85
  - **Quota warnings** — Enable/disable low quota notifications
85
86
 
86
87
  The provider itself cannot be disabled — it is always loaded.
87
88
 
88
- Configuration uses nested per-feature sections. Existing flat config files are migrated automatically, with a backup written next to the migrated config.
89
+ ## Model list
89
90
 
90
- ### Model Refresh
91
-
92
- Neuralwatt registers its public models without network access. Opening `/model` refreshes the catalog from the API in the background (authenticated when an API key is configured). `pi update --models` forces an immediate refresh.
93
-
94
- Pi stores the complete effective Neuralwatt catalog in `~/.pi/agent/models-store.json` for offline startup. Current hardcoded public definitions remain authoritative when cached models are restored.
95
-
96
- ## Adding or Updating Models
97
-
98
- Public models are hardcoded in `extensions/provider/models/public-models.ts` and validated against the live API. To update:
99
-
100
- 1. Run `pnpm test` — it fetches `/v1/models` and compares against hardcoded definitions
101
- 2. Fix any discrepancies (missing models, changed context windows)
102
- 3. Re-run `pnpm test` to confirm
91
+ The extension ships a built-in model list, so it works offline on first start. Pi refreshes the catalog from the Neuralwatt API in the background (authenticated when an API key is configured, so key-scoped models appear too) and caches it in `~/.pi/agent/models-store.json`. `pi update --models` forces a refresh.
103
92
 
104
93
  ## Development
105
94
 
106
- ### Setup
107
-
108
95
  ```bash
109
96
  git clone https://github.com/aliou/pi-neuralwatt.git
110
97
  cd pi-neuralwatt
111
-
112
- # Install dependencies (sets up pre-commit hooks)
113
- pnpm install && pnpm prepare
114
- ```
115
-
116
- Pre-commit hooks run on every commit:
117
- - TypeScript type checking
118
- - Biome linting
119
- - Biome formatting with auto-fix
120
-
121
- ### Commands
122
-
123
- ```bash
124
- # Type check
98
+ pnpm install
125
99
  pnpm run typecheck
126
-
127
- # Lint
128
100
  pnpm run lint
129
-
130
- # Format
131
- pnpm run format
132
-
133
- # Test
134
101
  pnpm run test
102
+ pnpm run check:models # compare the built-in model list with the live API
135
103
  ```
136
104
 
137
- ## Release
138
-
139
- This repository uses [Changesets](https://github.com/changesets/changesets) for versioning.
105
+ The pre-commit hook runs typecheck, lint, the lockfile check, and the changeset check. Releases use [Changesets](https://github.com/changesets/changesets).
140
106
 
141
107
  ## Requirements
142
108
 
143
- - Pi coding agent v0.80.8+
109
+ - Pi coding agent 1.4 or later
144
110
  - Neuralwatt API key (configured in `~/.pi/agent/auth.json` or via `NEURALWATT_API_KEY`)
145
111
 
146
112
  ## Links
@@ -12,10 +12,14 @@ function missingAuthMessage(): string {
12
12
  return `Neuralwatt quota requires an API key. Add credentials to ${authPath} or set the NEURALWATT_API_KEY environment variable.`;
13
13
  }
14
14
 
15
- export function registerQuotasCommand(pi: ExtensionAPI): void {
15
+ export function registerQuotasCommand(
16
+ pi: ExtensionAPI,
17
+ isEnabled: () => boolean,
18
+ ): void {
16
19
  pi.registerCommand("neuralwatt:quota", {
17
20
  description: "Display Neuralwatt API usage and quota",
18
21
  handler: async (_args, ctx) => {
22
+ if (!isEnabled()) return;
19
23
  const apiKey = await getNeuralwattApiKey(ctx.modelRegistry);
20
24
  if (!apiKey) {
21
25
  ctx.ui.notify(missingAuthMessage(), "warning");
@@ -1,19 +1,29 @@
1
+ import { bindProjectConfig } from "@aliou/pi-utils-settings";
1
2
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
3
  import { configLoader } from "../../src/config";
3
4
  import {
5
+ NEURALWATT_CONFIG_UPDATED_EVENT,
4
6
  NEURALWATT_EXTENSIONS_REGISTER_EVENT,
5
7
  NEURALWATT_EXTENSIONS_REQUEST_EVENT,
8
+ type NeuralwattConfigUpdatedPayload,
6
9
  } from "../../src/events";
7
10
  import { registerQuotasCommand } from "./command";
8
11
 
9
12
  export default async function (pi: ExtensionAPI) {
10
13
  await configLoader.load();
14
+ bindProjectConfig(pi, configLoader);
11
15
 
12
- const config = configLoader.getConfig();
16
+ let enabled = configLoader.getConfig().quotaCommand.enabled;
17
+ registerQuotasCommand(pi, () => enabled);
13
18
 
14
- if (config.quotaCommand.enabled) {
15
- registerQuotasCommand(pi);
16
- }
19
+ pi.on("session_start", () => {
20
+ enabled = configLoader.getConfig().quotaCommand.enabled;
21
+ });
22
+
23
+ pi.events.on(NEURALWATT_CONFIG_UPDATED_EVENT, (data: unknown) => {
24
+ enabled = (data as NeuralwattConfigUpdatedPayload).config.quotaCommand
25
+ .enabled;
26
+ });
17
27
 
18
28
  pi.events.on(NEURALWATT_EXTENSIONS_REQUEST_EVENT, () => {
19
29
  pi.events.emit(NEURALWATT_EXTENSIONS_REGISTER_EVENT, {
@@ -1,3 +1,4 @@
1
+ import { bindProjectConfig } from "@aliou/pi-utils-settings";
1
2
  import { getApiProvider } from "@earendil-works/pi-ai/compat";
2
3
  import type {
3
4
  ExtensionAPI,
@@ -88,6 +89,7 @@ function registerNeuralwattProvider(
88
89
 
89
90
  export default async function (pi: ExtensionAPI) {
90
91
  await configLoader.load();
92
+ bindProjectConfig(pi, configLoader);
91
93
 
92
94
  let latestQuotas: NeuralwattQuotas | undefined;
93
95
 
@@ -109,12 +111,14 @@ export default async function (pi: ExtensionAPI) {
109
111
  // text with actionable details from Neuralwatt's response headers.
110
112
  let pendingRateLimitInfo: NeuralwattRateLimitInfo | undefined;
111
113
 
112
- registerNeuralwattProvider(pi, {
114
+ const streamCallbacks: NeuralwattStreamCallbacks = {
113
115
  onSseQuota: handleSseQuota,
114
116
  onRateLimit: (info) => {
115
117
  pendingRateLimitInfo = info;
116
118
  },
117
- });
119
+ };
120
+ let registeredApi = configLoader.getConfig().provider.api;
121
+ registerNeuralwattProvider(pi, streamCallbacks);
118
122
 
119
123
  const loadedFeatures = new Set<NeuralwattFeatureId>();
120
124
 
@@ -233,6 +237,11 @@ export default async function (pi: ExtensionAPI) {
233
237
  });
234
238
 
235
239
  pi.on("session_start", async (_event, ctx) => {
240
+ const api = configLoader.getConfig().provider.api;
241
+ if (api !== registeredApi) {
242
+ registerNeuralwattProvider(pi, streamCallbacks);
243
+ registeredApi = api;
244
+ }
236
245
  currentModelRegistry = ctx.modelRegistry;
237
246
  pendingRateLimitInfo = undefined;
238
247
  const messages = [...new Set(configLoader.drainMessages())];
@@ -16,23 +16,6 @@ import {
16
16
  // unsupported levels through the aliases. See `models.test.ts` for the drift
17
17
  // check against the live catalog.
18
18
 
19
- // DeepSeek V4 Flash: efforts max/high/none, not mandatory.
20
- // https://api-docs.deepseek.com/guides/thinking_mode/
21
- const DEEPSEEK_V4_FLASH: NeuralwattModelFamily = {
22
- cost: { input: 0.14, output: 0.28, cacheRead: 0.028 },
23
- vision: false,
24
- reasoningMetadata: {
25
- supported_efforts: ["max", "high", "none"],
26
- mandatory: false,
27
- effort_aliases: {
28
- xhigh: "max",
29
- medium: "high",
30
- low: "high",
31
- minimal: "high",
32
- },
33
- },
34
- };
35
-
36
19
  // DeepSeek. V4.1 Flash is vision-capable, unlike V4 Flash, and admits
37
20
  // reasoning levels up to `xhigh`. Not mandatory (off defaults).
38
21
  const DEEPSEEK_V4_1_FLASH: NeuralwattModelFamily = {
@@ -192,33 +175,6 @@ const QWEN_3_8_27B: NeuralwattModelFamily = {
192
175
  };
193
176
 
194
177
  const FAMILIES: [NeuralwattModelFamily, NeuralwattVariantSpec[]][] = [
195
- [
196
- DEEPSEEK_V4_FLASH,
197
- [
198
- {
199
- id: "deepseek-v4-flash",
200
- name: "DeepSeek V4 Flash",
201
- contextWindow: 1048560,
202
- maxOutputTokens: 393216,
203
- reasoning: true,
204
- },
205
- {
206
- id: "deepseek-v4-flash-flex",
207
- name: "DeepSeek V4 Flash (flex)",
208
- contextWindow: 1048560,
209
- maxOutputTokens: 393216,
210
- reasoning: true,
211
- costMultiplier: 0.65,
212
- },
213
- {
214
- id: "deepseek-v4-flash-speed",
215
- name: "DeepSeek V4 Flash (Speed)",
216
- contextWindow: 1048560,
217
- maxOutputTokens: 393216,
218
- reasoning: true,
219
- },
220
- ],
221
- ],
222
178
  [
223
179
  DEEPSEEK_V4_1_FLASH,
224
180
  [
@@ -1,3 +1,4 @@
1
+ import { bindProjectConfig } from "@aliou/pi-utils-settings";
1
2
  import type {
2
3
  ExtensionAPI,
3
4
  ExtensionContext,
@@ -15,6 +16,7 @@ import { checkQuotas, clearAlertState } from "./notifier";
15
16
 
16
17
  export default async function (pi: ExtensionAPI) {
17
18
  await configLoader.load();
19
+ bindProjectConfig(pi, configLoader);
18
20
 
19
21
  let enabled = configLoader.getConfig().quotaWarnings.enabled;
20
22
  let currentProvider: string | undefined;
@@ -46,6 +48,7 @@ export default async function (pi: ExtensionAPI) {
46
48
  }
47
49
 
48
50
  pi.on("session_start", async (_event, ctx) => {
51
+ enabled = configLoader.getConfig().quotaWarnings.enabled;
49
52
  unsubscribeQuotas?.();
50
53
  currentProvider = ctx.model?.provider;
51
54
  unsubscribeQuotas = pi.events.on(NEURALWATT_QUOTAS_UPDATED_EVENT, (data) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-neuralwatt",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,
@@ -33,21 +33,21 @@
33
33
  "!extensions/**/*.test.ts"
34
34
  ],
35
35
  "dependencies": {
36
- "@aliou/pi-utils-settings": "^0.19.1",
36
+ "@aliou/pi-utils-settings": "^0.24.0",
37
37
  "@aliou/pi-utils-ui": "^0.5.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@earendil-works/pi-ai": ">=1.0.0",
41
- "@earendil-works/pi-coding-agent": ">=1.0.0",
41
+ "@earendil-works/pi-coding-agent": ">=1.4.0",
42
42
  "@earendil-works/pi-tui": "*"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@aliou/biome-plugins": "^0.11.0",
46
46
  "@biomejs/biome": "^2.4.15",
47
47
  "@changesets/cli": "^2.27.11",
48
- "@earendil-works/pi-ai": "1.1.0",
49
- "@earendil-works/pi-coding-agent": "1.1.0",
50
- "@earendil-works/pi-tui": "1.1.0",
48
+ "@earendil-works/pi-ai": "1.4.0",
49
+ "@earendil-works/pi-coding-agent": "1.4.0",
50
+ "@earendil-works/pi-tui": "1.4.0",
51
51
  "@types/node": "^25.0.10",
52
52
  "husky": "^9.1.7",
53
53
  "ts-json-schema-generator": "^2.4.0",
@@ -56,12 +56,6 @@
56
56
  "typescript": "^5.9.3",
57
57
  "vitest": "^4.0.18"
58
58
  },
59
- "pnpm": {
60
- "overrides": {
61
- "@earendil-works/pi-ai": "$@earendil-works/pi-coding-agent",
62
- "@earendil-works/pi-tui": "$@earendil-works/pi-coding-agent"
63
- }
64
- },
65
59
  "scripts": {
66
60
  "typecheck": "tsc --noEmit",
67
61
  "lint": "biome check",
@@ -78,7 +72,7 @@
78
72
  "version": "changeset version",
79
73
  "release": "pnpm changeset publish"
80
74
  },
81
- "packageManager": "pnpm@10.26.1",
75
+ "packageManager": "pnpm@11.27.0",
82
76
  "peerDependenciesMeta": {
83
77
  "@earendil-works/pi-ai": {
84
78
  "optional": true