llm-switcher 1.3.6 → 1.3.7
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 +4 -0
- package/package.json +1 -1
- package/tests/version.test.mjs +15 -0
- package/version.mjs +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog — LLM Switcher
|
|
2
2
|
|
|
3
|
+
## Release 1.3.7
|
|
4
|
+
|
|
5
|
+
- **Update notice in time:** The gateway kept the npm answer for 12 hours. A release published after the last check did not show an update button until the next day. It now asks npm again after 5 minutes.
|
|
6
|
+
|
|
3
7
|
## Release 1.3.6
|
|
4
8
|
|
|
5
9
|
- **Dashboard from a bookmark:** In 1.3.4 the tab kept the token in `sessionStorage`. A bookmark, a typed URL or a new tab then had no token: every call got HTTP 401, and the dashboard showed no profiles and every route as OFF. The token is now in `localStorage`, so after one `switch ui` every tab of that browser works. The page still does not carry the token.
|
package/package.json
CHANGED
package/tests/version.test.mjs
CHANGED
|
@@ -63,6 +63,21 @@ test('the same version is no update; a stale cache asks the registry again', asy
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
test('a release published after the last check shows within 5 minutes, not after 12 hours', async () => {
|
|
67
|
+
const reg = await registry((req, res) => res.end(JSON.stringify({ version: '99.0.0' })));
|
|
68
|
+
const stateDir = tmpState();
|
|
69
|
+
try {
|
|
70
|
+
const answeredBeforeTheRelease = { checkedAt: Date.now() - 6 * 60 * 1000, latest: CURRENT_VERSION };
|
|
71
|
+
fs.writeFileSync(path.join(stateDir, 'version-check.json'), JSON.stringify(answeredBeforeTheRelease));
|
|
72
|
+
const r = await checkForUpdate({ stateDir, url: reg.url });
|
|
73
|
+
assert.equal(reg.hits(), 1, 'a 6-minute-old answer is asked again');
|
|
74
|
+
assert.equal(r.updateAvailable, true);
|
|
75
|
+
} finally {
|
|
76
|
+
reg.close();
|
|
77
|
+
fs.rmSync(stateDir, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
66
81
|
test('an unreachable or broken registry gives no notice and never throws', async () => {
|
|
67
82
|
const reg = await registry((req, res) => { res.statusCode = 500; res.end('down'); });
|
|
68
83
|
const stateDir = tmpState();
|
package/version.mjs
CHANGED
|
@@ -11,7 +11,8 @@ export const CURRENT_VERSION = (() => {
|
|
|
11
11
|
|
|
12
12
|
const REGISTRY_URL = 'https://registry.npmjs.org/llm-switcher/latest';
|
|
13
13
|
const CACHE_FILE = 'version-check.json';
|
|
14
|
-
|
|
14
|
+
// A release shows on the dashboard within minutes; one small GET per 5 minutes.
|
|
15
|
+
const MAX_AGE_MS = 5 * 60 * 1000;
|
|
15
16
|
|
|
16
17
|
const parse = (v) => {
|
|
17
18
|
const m = /^(\d+)\.(\d+)\.(\d+)$/.exec(String(v ?? ''));
|
|
@@ -30,7 +31,7 @@ export function isNewer(latest, current) {
|
|
|
30
31
|
const updateCommand = () => (fs.existsSync(path.join(ROOT, '.git')) ? `git -C "${ROOT}" pull` : 'npm install -g llm-switcher@latest');
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
* Asks the registry at most once per
|
|
34
|
+
* Asks the registry at most once per 5 minutes; a failed ask also waits, so an offline machine is not
|
|
34
35
|
* slowed on every call. Never throws: without an answer there is simply no notice.
|
|
35
36
|
*/
|
|
36
37
|
export async function checkForUpdate({ stateDir, url = process.env.LLM_SWITCHER_REGISTRY_URL || REGISTRY_URL } = {}) {
|