lumiverse-spindle-types 0.4.29 → 0.4.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.4.29",
3
+ "version": "0.4.30",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/api.ts CHANGED
@@ -1031,16 +1031,22 @@ export interface GenerationObserver {
1031
1031
 
1032
1032
  // ─── Token Count DTOs ───────────────────────────────────────────────────
1033
1033
 
1034
- /** Which configured model should be used for server-side token counting. */
1035
- export type TokenModelSourceDTO = "main" | "sidecar";
1034
+ /** Where the model used for server-side token counting came from. */
1035
+ export type TokenModelSourceDTO = "main" | "sidecar" | "explicit";
1036
1036
 
1037
1037
  /** Optional settings for Spindle token count helpers. */
1038
1038
  export interface TokenCountOptionsDTO {
1039
+ /**
1040
+ * Explicit model ID to resolve the tokenizer against.
1041
+ *
1042
+ * When provided, this takes precedence over `modelSource`.
1043
+ */
1044
+ model?: string;
1039
1045
  /**
1040
1046
  * Which configured model to use when resolving the tokenizer.
1041
1047
  *
1042
- * - `"main"` → the user's default main connection profile model
1043
- * - `"sidecar"` → the user's selected sidecar model (or its backing connection model)
1048
+ * - `"main"` → the user's default main connection profile model
1049
+ * - `"sidecar"` → the user's selected sidecar model (or its backing connection model)
1044
1050
  *
1045
1051
  * Defaults to `"main"`.
1046
1052
  */
@@ -1054,7 +1060,7 @@ export interface TokenCountResultDTO {
1054
1060
  total_tokens: number;
1055
1061
  /** Model ID that was actually used to resolve the tokenizer. */
1056
1062
  model: string;
1057
- /** Whether the model came from the main connection or the sidecar selection. */
1063
+ /** Whether the model came from the main connection, sidecar selection, or an explicit override. */
1058
1064
  modelSource: TokenModelSourceDTO;
1059
1065
  /** Null when no exact tokenizer match was found and an approximate fallback was used. */
1060
1066
  tokenizer_id: string | null;
@@ -1360,6 +1366,7 @@ export type WorkerToHost =
1360
1366
  type: "tokens_count_text";
1361
1367
  requestId: string;
1362
1368
  text: string;
1369
+ model?: string;
1363
1370
  modelSource?: TokenModelSourceDTO;
1364
1371
  userId?: string;
1365
1372
  }
@@ -1367,6 +1374,7 @@ export type WorkerToHost =
1367
1374
  type: "tokens_count_messages";
1368
1375
  requestId: string;
1369
1376
  messages: Array<Pick<LlmMessageDTO, "role" | "content">>;
1377
+ model?: string;
1370
1378
  modelSource?: TokenModelSourceDTO;
1371
1379
  userId?: string;
1372
1380
  }
@@ -1374,6 +1382,7 @@ export type WorkerToHost =
1374
1382
  type: "tokens_count_chat";
1375
1383
  requestId: string;
1376
1384
  chatId: string;
1385
+ model?: string;
1377
1386
  modelSource?: TokenModelSourceDTO;
1378
1387
  userId?: string;
1379
1388
  };
@@ -469,20 +469,20 @@ export interface SpindleAPI {
469
469
 
470
470
  /** Server-side token counting helpers (free tier). */
471
471
  tokens: {
472
- /** Count tokens for an arbitrary text string. */
472
+ /** Count tokens for an arbitrary text string. `options.model` overrides `options.modelSource`. */
473
473
  countText(text: string, options?: TokenCountOptionsDTO): Promise<TokenCountResultDTO>;
474
474
  /**
475
475
  * Count tokens for an array of chat-style messages.
476
476
  *
477
477
  * This accepts any array whose items expose `{ role, content }`, so the
478
478
  * normalized output of `spindle.chat.getMessages(chatId)` can be passed
479
- * directly without reshaping.
479
+ * directly without reshaping. `options.model` overrides `options.modelSource`.
480
480
  */
481
481
  countMessages(
482
482
  messages: Array<Pick<LlmMessageDTO, "role" | "content">>,
483
483
  options?: TokenCountOptionsDTO
484
484
  ): Promise<TokenCountResultDTO>;
485
- /** Count tokens for a live stored chat by ID. */
485
+ /** Count tokens for a live stored chat by ID. `options.model` overrides `options.modelSource`. */
486
486
  countChat(chatId: string, options?: TokenCountOptionsDTO): Promise<TokenCountResultDTO>;
487
487
  };
488
488