@aliou/pi-neuralwatt 0.11.2 → 0.11.3

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
@@ -8,7 +8,7 @@ A Pi extension that adds [Neuralwatt](https://portal.neuralwatt.com/auth/registe
8
8
 
9
9
  ### Get API Key
10
10
 
11
- Sign up at [neuralwatt.com](https://portal.neuralwatt.com/auth/register?ref=NW-ALIOU-Q7MF) to get an API key.
11
+ Sign up [here](https://portal.neuralwatt.com/auth/register?ref=NW-ALIOU-Q7MF) to get an API key (referral link).
12
12
 
13
13
  ### Configure Credentials
14
14
 
@@ -5,6 +5,10 @@ import type {
5
5
  RefreshModelsContext,
6
6
  } from "@earendil-works/pi-ai";
7
7
  import type { ProviderModelConfig } from "@earendil-works/pi-coding-agent";
8
+ import {
9
+ persistModels,
10
+ readStoredModels,
11
+ } from "../../../src/refresh-store-compat";
8
12
  import {
9
13
  ALIAS_NEURALWATT_MODEL_IDS,
10
14
  buildAliasNeuralwattModels,
@@ -121,11 +125,11 @@ function cachedEarlyAccessModels(
121
125
  .map(toProviderModel);
122
126
  }
123
127
 
124
- async function persistModels(
128
+ function persistCatalog(
125
129
  context: RefreshModelsContext,
126
130
  models: ProviderModelConfig[],
127
- ): Promise<void> {
128
- await context.store.write({
131
+ ): Promise<boolean> {
132
+ return persistModels(context, {
129
133
  models: models.map(toStoredModel),
130
134
  checkedAt: Date.now(),
131
135
  });
@@ -140,10 +144,10 @@ export async function refreshNeuralwattModels(
140
144
  options.includeLegacyModelIds,
141
145
  options.includeAliasedModelIds,
142
146
  );
143
- const stored = await context.store.read();
147
+ const stored = await readStoredModels(context);
144
148
 
145
149
  if (!options.includeEarlyAccessModels) {
146
- await persistModels(context, baseline);
150
+ await persistCatalog(context, baseline);
147
151
  return baseline;
148
152
  }
149
153
 
@@ -179,6 +183,7 @@ export async function refreshNeuralwattModels(
179
183
  options.includeAliasedModelIds,
180
184
  configuredEarlyAccessModels(earlyAccess, baseline),
181
185
  );
182
- await persistModels(context, catalog);
186
+ context.signal?.throwIfAborted();
187
+ await persistCatalog(context, catalog);
183
188
  return catalog;
184
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-neuralwatt",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,
@@ -46,9 +46,9 @@
46
46
  "@aliou/biome-plugins": "^0.11.0",
47
47
  "@biomejs/biome": "^2.4.15",
48
48
  "@changesets/cli": "^2.27.11",
49
- "@earendil-works/pi-ai": "0.80.8",
50
- "@earendil-works/pi-coding-agent": "0.80.8",
51
- "@earendil-works/pi-tui": "0.80.8",
49
+ "@earendil-works/pi-ai": "0.84.0",
50
+ "@earendil-works/pi-coding-agent": "0.84.0",
51
+ "@earendil-works/pi-tui": "0.84.0",
52
52
  "@types/node": "^25.0.10",
53
53
  "husky": "^9.1.7",
54
54
  "ts-json-schema-generator": "^2.4.0",
@@ -0,0 +1,69 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Backward-compat shim for the Pi coding-agent provider refresh context.
3
+ //
4
+ // Pi 0.84 replaced dynamic `context.store` read/write access with the
5
+ // read-only `context.stored` snapshot and the generation-checked
6
+ // `context.publish({ persist })` transaction. This module detects the
7
+ // available API shape at runtime so the extension works on both <0.84 (store)
8
+ // and >=0.84 (publish) hosts.
9
+ //
10
+ // Once the minimum supported @earendil-works/pi-coding-agent version is
11
+ // >=0.84, delete this file and:
12
+ // - replace `readStoredModels(context)` with `context.stored`
13
+ // - replace `persistModels(context, entry)` with
14
+ // `await context.publish({ persist: entry })` (skip when aborted)
15
+ // ---------------------------------------------------------------------------
16
+
17
+ import type {
18
+ ModelsStoreEntry,
19
+ RefreshModelsContext,
20
+ } from "@earendil-works/pi-ai";
21
+
22
+ type LegacyRefreshModelsContext = RefreshModelsContext & {
23
+ store?: {
24
+ read(): Promise<ModelsStoreEntry | undefined>;
25
+ write(entry: ModelsStoreEntry): Promise<unknown>;
26
+ };
27
+ };
28
+
29
+ /**
30
+ * Returns the persisted catalog entry for the current provider, reading from
31
+ * the 0.84+ `context.stored` snapshot when available and falling back to the
32
+ * legacy `context.store.read()` on older hosts.
33
+ */
34
+ export async function readStoredModels(
35
+ context: RefreshModelsContext,
36
+ ): Promise<ModelsStoreEntry | undefined> {
37
+ if (context.stored !== undefined) return context.stored;
38
+ return readLegacyStore(context);
39
+ }
40
+
41
+ function readLegacyStore(
42
+ context: RefreshModelsContext,
43
+ ): Promise<ModelsStoreEntry | undefined> {
44
+ const legacy = context as LegacyRefreshModelsContext;
45
+ return legacy.store ? legacy.store.read() : Promise.resolve(undefined);
46
+ }
47
+
48
+ /**
49
+ * Persists the catalog entry, publishing through
50
+ * `context.publish({ persist: entry })` on 0.84+ hosts and writing through
51
+ * the legacy `context.store.write(entry)` on older hosts.
52
+ *
53
+ * Returns true when the entry was persisted. On 0.84+ hosts a return value of
54
+ * false means a newer refresh superseded this publication (generation check).
55
+ */
56
+ export async function persistModels(
57
+ context: RefreshModelsContext,
58
+ entry: ModelsStoreEntry,
59
+ ): Promise<boolean> {
60
+ if (typeof context.publish === "function") {
61
+ return context.publish({ persist: entry });
62
+ }
63
+ const legacy = context as LegacyRefreshModelsContext;
64
+ if (legacy.store) {
65
+ await legacy.store.write(entry);
66
+ return true;
67
+ }
68
+ return false;
69
+ }