@emesoft/tokenhub 0.8.10 → 0.8.11

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
@@ -73,7 +73,10 @@ Prefer not to install? Use `npx @emesoft/tokenhub connect <your tenant name>` in
73
73
  `,` / `.` or a click for effort (hover highlights), and `[` or a click for **1M**: each model shows its context window, and with 1M on, a model whose window is 1M is picked as `<id>[1m]` so Claude Code compacts at 1M instead of 200K (only for models whose window TokenHub knows to be 1M). `/model <id>` and other hosts keep Claude Code's own picker. The list is read from your tenant
74
74
  (`/member/api/models`: the providers your key may use, with a skeleton while it loads); when the pool does not
75
75
  answer within a few seconds it falls back to a built-in list, marked "offline list". The plugin relies on Claude
76
- Code's early-access plugin hooks, which can change between Claude Code releases.
76
+ Code's early-access plugin hooks, which can change between Claude Code releases. Claude Code reports the mouse
77
+ only in its fullscreen layout, so after installing the picker `connect` asks whether to turn that on
78
+ (`"tui": "fullscreen"`, default no); in the classic layout the picker works from the keyboard and says
79
+ `/tui fullscreen` turns the mouse on. `disconnect` leaves `tui` as it is.
77
80
  - Keeps every other setting, and saves the previous file as `settings.json.bak`.
78
81
 
79
82
  Each machine gets its own key, which you can revoke from the pool's **Keys** page. `disconnect` removes exactly these entries (and the model picker's copy) and nothing else.
package/bin/tokenhub.js CHANGED
@@ -16,7 +16,8 @@ Usage:
16
16
  Pair this machine and write ~/.claude/settings.json, including the status line
17
17
  (today's spend under the prompt) unless --no-statusline. Then offers to install the
18
18
  TokenHub model picker (a bare /model in Claude Code lists TokenHub models) unless
19
- --no-model-picker.
19
+ --no-model-picker, and then Claude Code's fullscreen layout, the only one that gives
20
+ the picker the mouse (default no).
20
21
  tenant is your tenant name (acme = https://acme.${TENANT_DOMAIN}) or a full URL;
21
22
  it is asked for when left out
22
23
  tokenhub connect [tenant] --admin
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenhub-models",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "A bare /model opens a TokenHub model picker above the prompt when ANTHROPIC_BASE_URL points at TokenHub",
5
5
  "author": { "name": "Emesoft" },
6
6
  "license": "MIT",
@@ -240,6 +240,8 @@ export const register: Register = on => {
240
240
  </Box>
241
241
  <Client key="picker" module="./picker.tsx"
242
242
  props={{ groups, loading: groups.length === 0, current, cursor, effort, efforts: EFFORTS, use1m: await read($, use1m) }} />
243
+ {/* Claude Code reports the mouse only in its fullscreen layout (#766); say so where it says it is not. */}
244
+ {e.viewport?.isFullscreen === false ? <Text dimColor>Mouse needs Claude Code's fullscreen layout: /tui fullscreen</Text> : ''}
243
245
  </Box>
244
246
  )
245
247
  })
@@ -7,5 +7,7 @@ export function installModelPicker(settingsFile: string, dir: string, source?: s
7
7
  export function uninstallModelPicker(settingsFile: string, dir: string): boolean;
8
8
  export function askYesNo(
9
9
  question: string,
10
- io?: { input?: NodeJS.ReadableStream & { isTTY?: boolean }; output?: NodeJS.WritableStream },
10
+ io?: { input?: NodeJS.ReadableStream & { isTTY?: boolean }; output?: NodeJS.WritableStream; defaultYes?: boolean },
11
11
  ): Promise<boolean>;
12
+ export function enableFullscreen(settingsFile: string): boolean;
13
+ export function layoutUnset(settingsFile: string): boolean;
@@ -106,22 +106,44 @@ export function uninstallModelPicker(settingsFile, dir) {
106
106
  }
107
107
 
108
108
  /**
109
- * Ask a yes/no question on the terminal; Enter alone answers yes.
110
- * @param {string} question The question, without the `(Y/n)` suffix.
111
- * @param {{ input?: NodeJS.ReadableStream & { isTTY?: boolean }, output?: NodeJS.WritableStream }} [io] Streams (tests).
109
+ * Ask a yes/no question on the terminal; Enter alone answers the default (yes unless `defaultYes` is false).
110
+ * @param {string} question The question, without the `(Y/n)` / `(y/N)` suffix.
111
+ * @param {{ input?: NodeJS.ReadableStream & { isTTY?: boolean }, output?: NodeJS.WritableStream, defaultYes?: boolean }} [io] Streams (tests) and the default answer.
112
112
  * @returns {Promise<boolean>} The answer; false when there is no terminal to ask on.
113
113
  */
114
- export async function askYesNo(question, { input = process.stdin, output = process.stdout } = {}) {
114
+ export async function askYesNo(question, { input = process.stdin, output = process.stdout, defaultYes = true } = {}) {
115
115
  if (!input.isTTY) return false;
116
116
  const rl = createInterface({ input, output });
117
117
  try {
118
- const answer = (await rl.question(`${question} (Y/n) `)).trim().toLowerCase();
119
- return answer === "" || answer === "y" || answer === "yes";
118
+ const answer = (await rl.question(`${question} ${defaultYes ? "(Y/n)" : "(y/N)"} `)).trim().toLowerCase();
119
+ return answer === "" ? defaultYes : answer === "y" || answer === "yes";
120
120
  } finally {
121
121
  rl.close();
122
122
  }
123
123
  }
124
124
 
125
+ /**
126
+ * Turn on Claude Code's fullscreen layout (`"tui": "fullscreen"`), the only one that reports the mouse to the picker
127
+ * (#766). A `tui` the user already chose is left alone.
128
+ * @param {string} settingsFile Path of settings.json.
129
+ * @returns {boolean} True when it was written, false when `tui` was already set.
130
+ * @throws {Error} When the existing file is invalid JSON (left untouched).
131
+ */
132
+ export function enableFullscreen(settingsFile) {
133
+ const { settings } = readSettings(settingsFile);
134
+ if (settings.tui !== undefined) return false;
135
+ writeSettings(settingsFile, { ...settings, tui: "fullscreen" });
136
+ return true;
137
+ }
138
+
139
+ /**
140
+ * @param {string} settingsFile Path of settings.json.
141
+ * @returns {boolean} Whether the user has not chosen a Claude Code layout (`tui`) yet.
142
+ */
143
+ export function layoutUnset(settingsFile) {
144
+ return readSettings(settingsFile).settings.tui === undefined;
145
+ }
146
+
125
147
  /**
126
148
  * @param {unknown} value Value to test.
127
149
  * @returns {value is Record<string, any>} True for non-null, non-array objects.
package/lib/pair.d.ts CHANGED
@@ -34,5 +34,5 @@ export function runConnect(options: {
34
34
  /** Where the picker is installed; `modelPickerDir()` by default. */
35
35
  modelPickerDir?: string;
36
36
  /** Yes/no prompt; answers false without a terminal. */
37
- ask?: (question: string) => Promise<boolean>;
37
+ ask?: (question: string, defaultYes?: boolean) => Promise<boolean>;
38
38
  }): Promise<number>;
package/lib/pair.js CHANGED
@@ -3,7 +3,7 @@ import { hostname } from "node:os";
3
3
  import { emitKeypressEvents } from "node:readline";
4
4
  import { createInterface } from "node:readline/promises";
5
5
  import { writeAdminConfig } from "./admin.js";
6
- import { askYesNo, installModelPicker, modelPickerDir } from "./model-picker.js";
6
+ import { askYesNo, enableFullscreen, installModelPicker, layoutUnset, modelPickerDir } from "./model-picker.js";
7
7
  import { connectSettings, normalizeUrl, overridingEnvVars, readSettings } from "./settings.js";
8
8
 
9
9
  const MAX_WAIT_MS = 15 * 60 * 1000;
@@ -230,7 +230,7 @@ async function postJson(url, body, signal) {
230
230
  * @param {string} [options.adminFile] Path from `adminConfigPath`; required with `admin`.
231
231
  * @param {boolean} [options.modelPicker] Offer to install the Claude Code model picker after pairing (default true).
232
232
  * @param {string} [options.modelPickerDir] Where the picker is installed (`modelPickerDir()` by default).
233
- * @param {(question: string) => Promise<boolean>} [options.ask] Yes/no prompt (tests); false without a terminal.
233
+ * @param {(question: string, defaultYes?: boolean) => Promise<boolean>} [options.ask] Yes/no prompt (tests); false without a terminal.
234
234
  * @returns {Promise<number>} Process exit code.
235
235
  */
236
236
  export async function runConnect({
@@ -247,7 +247,7 @@ export async function runConnect({
247
247
  adminFile,
248
248
  modelPicker = true,
249
249
  modelPickerDir: pickerDir = modelPickerDir(),
250
- ask = askYesNo,
250
+ ask = (question, defaultYes = true) => askYesNo(question, { defaultYes }),
251
251
  }) {
252
252
  let pool;
253
253
  try {
@@ -316,6 +316,11 @@ export async function runConnect({
316
316
  try {
317
317
  installModelPicker(settingsFile, pickerDir);
318
318
  log("Model picker installed. Restart Claude Code, then type /model to pick a TokenHub model.");
319
+ // Claude Code reports the mouse only in its fullscreen layout (#766): offer it, never force it.
320
+ if (layoutUnset(settingsFile) && (await ask("Turn on Claude Code's fullscreen layout so the picker takes the mouse?", false))) {
321
+ enableFullscreen(settingsFile);
322
+ log('Fullscreen layout on ("tui": "fullscreen"). Switch back any time with /tui default.');
323
+ }
319
324
  } catch (error) {
320
325
  log(`Model picker not installed: ${error.message}`);
321
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emesoft/tokenhub",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
4
4
  "description": "Connect Claude Code to a TokenHub pool in one command, and track your spend from the terminal",
5
5
  "keywords": [
6
6
  "claude",