@emesoft/tokenhub 0.8.9 → 0.8.10

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
@@ -69,7 +69,7 @@ Prefer not to install? Use `npx @emesoft/tokenhub connect <your tenant name>` in
69
69
  - Asks whether to install the **TokenHub model picker**, unless you pass `--no-model-picker` or there is no terminal
70
70
  to ask on. On yes it copies a Claude Code plugin to `~/.tokenhub/claude-plugin` and registers it as
71
71
  `extraKnownMarketplaces.tokenhub` and `enabledPlugins["tokenhub-models@tokenhub"]`. After a restart, a bare `/model`
72
- opens a picker of TokenHub models above the prompt: providers side by side, ↑/↓ and Enter, a click or `1`–`9` to pick,
72
+ opens a picker of TokenHub models above the prompt: providers side by side, ↑/↓ and Enter or a click to pick (rows are numbered by position),
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenhub-models",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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",
@@ -107,6 +107,7 @@ const Picker: ClientModule<Props, State> = (props, s) => {
107
107
  </Text>,
108
108
  ])
109
109
  let i = 0
110
+ const numberWidth = String(flat.length).length
110
111
  // Skeleton: three columns of placeholder bars where the providers and their models will be.
111
112
  const skeleton = (
112
113
  <Box flexDirection="row">
@@ -136,12 +137,13 @@ const Picker: ClientModule<Props, State> = (props, s) => {
136
137
  const at = i++
137
138
  const isCursor = at === props.cursor
138
139
  const isCurrent = matches(m.id, props.current)
139
- const digit = at < 9 ? `${at + 1}.` : ' '
140
+ // Every row's position, padded so the names line up; a number is not a key (#751).
141
+ const digit = `${String(at + 1).padStart(numberWidth)}.`
140
142
  const label = windowLabel(m.contextWindow)
141
143
  return (
142
144
  <Text wrap="truncate" color={isCursor ? 'suggestion' : undefined} dimColor={!isCursor && !isCurrent}>
143
145
  {isCursor ? '› ' : ' '}{digit} {m.name}{isCurrent ? ' ✔' : ''}
144
- {label ? <Text dimColor> {label}</Text> : ''}
146
+ {label ? <Text dimColor>{` ${label}`}</Text> : ''}
145
147
  </Text>
146
148
  )
147
149
  })}
@@ -164,7 +166,7 @@ const Picker: ClientModule<Props, State> = (props, s) => {
164
166
  <Text dimColor>{contextNote}</Text>
165
167
  </Text>
166
168
  <Text dimColor>
167
- {props.loading ? 'Loading your TokenHub models…' : `${cursorModel?.id ?? ''}${props.use1m && cursorTakes1m ? '[1m]' : ''} · ↑/↓ or hover · Enter, click or 1-9 picks · type anything to close`}
169
+ {props.loading ? 'Loading your TokenHub models…' : `${cursorModel?.id ?? ''}${props.use1m && cursorTakes1m ? '[1m]' : ''} · ↑/↓ or hover · Enter or click picks · type anything to close`}
168
170
  </Text>
169
171
  </Box>
170
172
  )
@@ -182,7 +182,8 @@ export const register: Register = on => {
182
182
  })
183
183
 
184
184
  // While the picker is open and the prompt is empty, the prompt drives it: up/down move the
185
- // cursor, `,` / `.` step the effort, `[` switches 1M, 1-9 pick a model. Anything else types as usual.
185
+ // cursor, `,` / `.` step the effort, `[` switches 1M (the row numbers are positions, not keys). Anything else typed closes the
186
+ // picker and types as usual.
186
187
  on('prompt.edit', async ($, e, next) => {
187
188
  const arrow = e.key?.key === 'up' || e.key?.key === 'down' ? e.key.key : undefined
188
189
  if (arrow && e.text === '') {
@@ -198,7 +199,12 @@ export const register: Register = on => {
198
199
  return { ...r, text: '', cursor: 0 }
199
200
  }
200
201
  const typed = e.inputText
201
- if (e.text !== '' || !(typed === ',' || typed === '.' || typed === '[' || /^[1-9]$/.test(typed))) return next(e)
202
+ const isPickerKey = e.text === '' && (typed === ',' || typed === '.' || typed === '[')
203
+ if (!isPickerKey) {
204
+ // Anything else typed while the picker is open closes it, as its hint says; the text stays in the prompt.
205
+ if (typed !== '' && (await read($, isOpen).catch(() => false))) await update($, isOpen, () => false).catch(() => undefined)
206
+ return next(e)
207
+ }
202
208
  let open = false
203
209
  try {
204
210
  open = await read($, isOpen)
@@ -208,8 +214,7 @@ export const register: Register = on => {
208
214
  if (!open) return next(e)
209
215
  const r = await next(e)
210
216
  if (typed === ',' || typed === '.') await stepEffort($, typed === '.' ? 1 : -1).catch(() => undefined)
211
- else if (typed === '[') await update($, use1m, isOn => !isOn).catch(() => undefined)
212
- else await pick($, Number(typed) - 1).catch(() => undefined)
217
+ else await update($, use1m, isOn => !isOn).catch(() => undefined)
213
218
  return { ...r, text: '', cursor: 0 }
214
219
  })
215
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emesoft/tokenhub",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
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",