@emesoft/tokenhub 0.8.12 → 0.8.14
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/bin/tokenhub.js +2 -2
- package/lib/desktop-connect.js +4 -4
- package/lib/desktop.d.ts +2 -1
- package/lib/desktop.js +18 -5
- package/package.json +1 -1
package/bin/tokenhub.js
CHANGED
|
@@ -6,7 +6,7 @@ import { parseDashboardArgs, runDashboard } from "../lib/dashboard.js";
|
|
|
6
6
|
import { runDesktop } from "../lib/desktop-connect.js";
|
|
7
7
|
import { modelPickerDir, uninstallModelPicker } from "../lib/model-picker.js";
|
|
8
8
|
import { runOverlayInstall } from "../lib/overlay.js";
|
|
9
|
-
import { promptTenant, runConnect, TENANT_DOMAIN } from "../lib/pair.js";
|
|
9
|
+
import { openBrowser, promptTenant, runConnect, TENANT_DOMAIN } from "../lib/pair.js";
|
|
10
10
|
import { disconnectSettings, readSettings, settingsPath } from "../lib/settings.js";
|
|
11
11
|
import { fetchUsage, formatUsage, resolveCredentials } from "../lib/usage.js";
|
|
12
12
|
|
|
@@ -99,7 +99,7 @@ async function main(argv) {
|
|
|
99
99
|
return 1;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
return runDesktop({ poolUrl, signal: controller.signal });
|
|
102
|
+
return runDesktop({ poolUrl, open: openBrowser, signal: controller.signal });
|
|
103
103
|
}
|
|
104
104
|
if (command === "overlay") {
|
|
105
105
|
return runOverlayInstall({ poolUrl: arg });
|
package/lib/desktop-connect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hostname } from "node:os";
|
|
2
|
-
import { appDataDir, fetchModels, isInstalled, writeDesktopConfig } from "./desktop.js";
|
|
3
|
-
import { pairDevice, resolvePoolUrl } from "./pair.js";
|
|
2
|
+
import { appDataCacheDir, appDataDir, fetchModels, isInstalled, writeDesktopConfig } from "./desktop.js";
|
|
3
|
+
import { openBrowser, pairDevice, resolvePoolUrl } from "./pair.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Pair this machine and configure Claude Desktop's third-party inference so the app points at the pool: the models
|
|
@@ -22,7 +22,7 @@ import { pairDevice, resolvePoolUrl } from "./pair.js";
|
|
|
22
22
|
export async function runDesktop({
|
|
23
23
|
poolUrl,
|
|
24
24
|
log = console.log,
|
|
25
|
-
open,
|
|
25
|
+
open = openBrowser,
|
|
26
26
|
signal,
|
|
27
27
|
deviceName = hostname(),
|
|
28
28
|
intervalOverrideMs,
|
|
@@ -37,7 +37,7 @@ export async function runDesktop({
|
|
|
37
37
|
return 1;
|
|
38
38
|
}
|
|
39
39
|
// Judged before the write, which creates the folder.
|
|
40
|
-
const installed = isInstalled(dir);
|
|
40
|
+
const installed = isInstalled(dir, platform === "win32" ? appDataCacheDir(env, home) : null);
|
|
41
41
|
let pool;
|
|
42
42
|
try {
|
|
43
43
|
pool = resolvePoolUrl(poolUrl);
|
package/lib/desktop.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const APP_FOLDER: string;
|
|
2
2
|
export const CONFIG_NAME: string;
|
|
3
3
|
export function appDataDir(platform?: string, env?: Record<string, string | undefined>, home?: string): string | null;
|
|
4
|
+
export function appDataCacheDir(env?: Record<string, string | undefined>, home?: string): string | null;
|
|
4
5
|
export function configLibraryDir(base: string): string;
|
|
5
6
|
export function configId(dir: string): string;
|
|
6
7
|
export function modelEntry(row: { id: string; display_name?: string; anthropic_family_tier?: string; max_input_tokens?: number }): Record<string, unknown>;
|
|
@@ -20,7 +21,7 @@ export function writeDesktopConfig(options: {
|
|
|
20
21
|
models: Array<{ id: string; display_name?: string; anthropic_family_tier?: string; max_input_tokens?: number }>;
|
|
21
22
|
effort?: string;
|
|
22
23
|
}): { configPath: string; metaPath: string; desktopConfigPath: string; models: number };
|
|
23
|
-
export function isInstalled(dir: string | null): boolean;
|
|
24
|
+
export function isInstalled(dir: string | null, cacheDir?: string | null): boolean;
|
|
24
25
|
export function fetchModels(
|
|
25
26
|
baseUrl: string,
|
|
26
27
|
key: string,
|
package/lib/desktop.js
CHANGED
|
@@ -160,12 +160,25 @@ export function writeDesktopConfig({ dir, baseUrl, key, models, effort }) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* @
|
|
163
|
+
* Where Claude Desktop keeps its caches, storage and logs on Windows, beside the folder `appDataDir` returns: Desktop
|
|
164
|
+
* splits its app data across Roaming (config) and Local (everything else), and either can exist first.
|
|
165
|
+
* @param {Record<string, string | undefined>} [env] Environment to read LOCALAPPDATA from.
|
|
166
|
+
* @param {string} [home] Home directory used when the variable is unset.
|
|
167
|
+
* @returns {string | null} Absolute folder, or null on a platform Desktop does not split.
|
|
168
|
+
*/
|
|
169
|
+
export function appDataCacheDir(env = process.env, home = homedir()) {
|
|
170
|
+
return join(env.LOCALAPPDATA || join(home, "AppData", "Local"), APP_FOLDER);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Whether Desktop is installed here, judged by its app-data folders: the one it reads config from, or the one it keeps
|
|
175
|
+
* caches in. Desktop creates one before the other, so either proves an install (#790).
|
|
176
|
+
* @param {string | null} dir Config folder from `appDataDir`.
|
|
177
|
+
* @param {string | null} [cacheDir] Cache folder from `appDataCacheDir`.
|
|
178
|
+
* @returns {boolean} True when either exists.
|
|
166
179
|
*/
|
|
167
|
-
export function isInstalled(dir) {
|
|
168
|
-
return Boolean(
|
|
180
|
+
export function isInstalled(dir, cacheDir = null) {
|
|
181
|
+
return [dir, cacheDir].some((folder) => Boolean(folder) && existsSync(folder));
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
/**
|