@bike4mind/cli 0.2.33 → 0.2.34-feat-tokenizer-request-logger-context.19947

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.
@@ -7,7 +7,7 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-5T3QXFEQ.js";
10
+ } from "./chunk-EDBDHBFK.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-5T3QXFEQ.js";
5
+ } from "./chunk-EDBDHBFK.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -12245,11 +12245,11 @@ var TiktokenTokenizer = class {
12245
12245
  * @param modelId - Model ID to determine encoding (optional)
12246
12246
  * @returns Promise<number> - Token count
12247
12247
  */
12248
- async countTokens(text, modelId) {
12248
+ async countTokens(text, modelId, logger) {
12249
12249
  if (this.isShuttingDown) {
12250
12250
  throw new Error("TiktokenTokenizer is shutting down");
12251
12251
  }
12252
- const encoder = await this.getEncoder(modelId);
12252
+ const encoder = await this.getEncoder(modelId, logger);
12253
12253
  const texts = Array.isArray(text) ? text : [text];
12254
12254
  return texts.reduce((sum, t) => sum + encoder.encode(t).length, 0);
12255
12255
  }
@@ -12259,18 +12259,30 @@ var TiktokenTokenizer = class {
12259
12259
  * @param modelId - Model ID to determine encoding (optional)
12260
12260
  * @returns Promise<number[]> - Array of token IDs
12261
12261
  */
12262
- async encodeTokens(text, modelId) {
12262
+ async encodeTokens(text, modelId, logger) {
12263
12263
  if (this.isShuttingDown) {
12264
12264
  throw new Error("TiktokenTokenizer is shutting down");
12265
12265
  }
12266
- const encoder = await this.getEncoder(modelId);
12266
+ const encoder = await this.getEncoder(modelId, logger);
12267
12267
  return Array.from(encoder.encode(text));
12268
12268
  }
12269
+ /**
12270
+ * Returns a lightweight ITokenizer proxy that delegates WASM encoder operations
12271
+ * to this instance (preserving the shared encoder cache) but routes log output
12272
+ * through the provided logger. Useful for attaching per-request context (e.g.
12273
+ * requestId, userId) to tokenizer logs without sacrificing the singleton benefit.
12274
+ */
12275
+ withLogger(logger) {
12276
+ return {
12277
+ countTokens: (text, modelId) => this.countTokens(text, modelId, logger),
12278
+ encodeTokens: (text, modelId) => this.encodeTokens(text, modelId, logger)
12279
+ };
12280
+ }
12269
12281
  /**
12270
12282
  * Get or create an encoder for the given model
12271
12283
  * @private
12272
12284
  */
12273
- async getEncoder(modelId) {
12285
+ async getEncoder(modelId, logger = this.logger) {
12274
12286
  const { encoding_for_model, get_encoding } = await import("tiktoken");
12275
12287
  const cacheKey = modelId || this.fallbackEncoding;
12276
12288
  if (this.enableCaching && this.encoderCache.has(cacheKey)) {
@@ -12280,16 +12292,16 @@ var TiktokenTokenizer = class {
12280
12292
  try {
12281
12293
  if (modelId) {
12282
12294
  encoder = encoding_for_model(modelId);
12283
- this.logger.debug(`Created tiktoken encoder for model: ${modelId}`);
12295
+ logger.debug(`Created tiktoken encoder for model: ${modelId}`);
12284
12296
  } else {
12285
12297
  encoder = get_encoding(this.fallbackEncoding);
12286
- this.logger.debug(`Created tiktoken encoder with ${this.fallbackEncoding} encoding`);
12298
+ logger.debug(`Created tiktoken encoder with ${this.fallbackEncoding} encoding`);
12287
12299
  }
12288
12300
  if (this.enableCaching) {
12289
12301
  this.encoderCache.set(cacheKey, encoder);
12290
12302
  }
12291
12303
  } catch (error) {
12292
- this.logger.warn(`Failed to create encoder for model ${modelId}, falling back to ${this.fallbackEncoding}:`, error);
12304
+ logger.warn(`Failed to create encoder for model ${modelId}, falling back to ${this.fallbackEncoding}:`, error);
12293
12305
  encoder = get_encoding(this.fallbackEncoding);
12294
12306
  if (this.enableCaching) {
12295
12307
  this.encoderCache.set(this.fallbackEncoding, encoder);
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@bike4mind/cli",
6
- version: "0.2.33",
6
+ version: "0.2.34-feat-tokenizer-request-logger-context.19947+5fb63440b",
7
7
  type: "module",
8
8
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
9
9
  license: "UNLICENSED",
@@ -114,10 +114,10 @@ var package_default = {
114
114
  },
115
115
  devDependencies: {
116
116
  "@bike4mind/agents": "0.1.0",
117
- "@bike4mind/common": "2.55.0",
118
- "@bike4mind/mcp": "1.32.2",
119
- "@bike4mind/services": "2.52.0",
120
- "@bike4mind/utils": "2.9.0",
117
+ "@bike4mind/common": "2.55.1-feat-tokenizer-request-logger-context.19947+5fb63440b",
118
+ "@bike4mind/mcp": "1.32.3-feat-tokenizer-request-logger-context.19947+5fb63440b",
119
+ "@bike4mind/services": "2.52.1-feat-tokenizer-request-logger-context.19947+5fb63440b",
120
+ "@bike4mind/utils": "2.9.1-feat-tokenizer-request-logger-context.19947+5fb63440b",
121
121
  "@types/better-sqlite3": "^7.6.13",
122
122
  "@types/diff": "^5.0.9",
123
123
  "@types/jsonwebtoken": "^9.0.4",
@@ -138,7 +138,7 @@ var package_default = {
138
138
  optionalDependencies: {
139
139
  "@vscode/ripgrep": "^1.17.0"
140
140
  },
141
- gitHead: "3e24edb92fd0bf0cb7d00fc893d33caf4715243e"
141
+ gitHead: "5fb63440bb63190e2e6af89f54a7904f70082a1f"
142
142
  };
143
143
 
144
144
  // src/utils/updateChecker.ts
@@ -6,7 +6,7 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-5T3QXFEQ.js";
9
+ } from "./chunk-EDBDHBFK.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
@@ -3,7 +3,7 @@ import {
3
3
  fetchLatestVersion,
4
4
  forceCheckForUpdate,
5
5
  package_default
6
- } from "../chunk-ZDUDUW2Z.js";
6
+ } from "../chunk-PW7WH4H2.js";
7
7
 
8
8
  // src/commands/doctorCommand.ts
9
9
  import { execSync } from "child_process";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  forceCheckForUpdate,
4
4
  package_default
5
- } from "../chunk-ZDUDUW2Z.js";
5
+ } from "../chunk-PW7WH4H2.js";
6
6
 
7
7
  // src/commands/updateCommand.ts
8
8
  import { execSync } from "child_process";
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-YVYGYSOW.js";
6
- import "./chunk-5T3QXFEQ.js";
5
+ } from "./chunk-4WVX6KBG.js";
6
+ import "./chunk-EDBDHBFK.js";
7
7
  import "./chunk-OS37CKKC.js";
8
8
  import "./chunk-PFBYGCOW.js";
9
9
  export {
package/dist/index.js CHANGED
@@ -4,10 +4,10 @@ import {
4
4
  getOpenWeatherKey,
5
5
  getSerperKey,
6
6
  getWolframAlphaKey
7
- } from "./chunk-X3UIP4R3.js";
7
+ } from "./chunk-R7OTXEGV.js";
8
8
  import "./chunk-GQGOWACU.js";
9
- import "./chunk-IKM2PF4K.js";
10
- import "./chunk-YVYGYSOW.js";
9
+ import "./chunk-CLVFA6GQ.js";
10
+ import "./chunk-4WVX6KBG.js";
11
11
  import {
12
12
  BFLImageService,
13
13
  BaseStorage,
@@ -19,7 +19,7 @@ import {
19
19
  OpenAIBackend,
20
20
  OpenAIImageService,
21
21
  XAIImageService
22
- } from "./chunk-5T3QXFEQ.js";
22
+ } from "./chunk-EDBDHBFK.js";
23
23
  import "./chunk-BPFEGDC7.js";
24
24
  import "./chunk-BDQBOLYG.js";
25
25
  import {
@@ -29,7 +29,7 @@ import {
29
29
  import {
30
30
  checkForUpdate,
31
31
  package_default
32
- } from "./chunk-ZDUDUW2Z.js";
32
+ } from "./chunk-PW7WH4H2.js";
33
33
  import {
34
34
  selectActiveBackgroundAgents,
35
35
  useCliStore
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  findMostSimilarMemento,
4
4
  getRelevantMementos
5
- } from "./chunk-X3UIP4R3.js";
6
- import "./chunk-5T3QXFEQ.js";
5
+ } from "./chunk-R7OTXEGV.js";
6
+ import "./chunk-EDBDHBFK.js";
7
7
  import "./chunk-OS37CKKC.js";
8
8
  import "./chunk-PFBYGCOW.js";
9
9
  export {
@@ -139,7 +139,7 @@ import {
139
139
  validateUrlForFetch,
140
140
  warmUpSettingsCache,
141
141
  withRetry
142
- } from "./chunk-5T3QXFEQ.js";
142
+ } from "./chunk-EDBDHBFK.js";
143
143
  import {
144
144
  buildRateLimitLogEntry,
145
145
  isNearLimit,
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  SubtractCreditsSchema,
4
4
  subtractCredits
5
- } from "./chunk-IKM2PF4K.js";
6
- import "./chunk-5T3QXFEQ.js";
5
+ } from "./chunk-CLVFA6GQ.js";
6
+ import "./chunk-EDBDHBFK.js";
7
7
  import "./chunk-OS37CKKC.js";
8
8
  import "./chunk-PFBYGCOW.js";
9
9
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.33",
3
+ "version": "0.2.34-feat-tokenizer-request-logger-context.19947+5fb63440b",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -111,10 +111,10 @@
111
111
  },
112
112
  "devDependencies": {
113
113
  "@bike4mind/agents": "0.1.0",
114
- "@bike4mind/common": "2.55.0",
115
- "@bike4mind/mcp": "1.32.2",
116
- "@bike4mind/services": "2.52.0",
117
- "@bike4mind/utils": "2.9.0",
114
+ "@bike4mind/common": "2.55.1-feat-tokenizer-request-logger-context.19947+5fb63440b",
115
+ "@bike4mind/mcp": "1.32.3-feat-tokenizer-request-logger-context.19947+5fb63440b",
116
+ "@bike4mind/services": "2.52.1-feat-tokenizer-request-logger-context.19947+5fb63440b",
117
+ "@bike4mind/utils": "2.9.1-feat-tokenizer-request-logger-context.19947+5fb63440b",
118
118
  "@types/better-sqlite3": "^7.6.13",
119
119
  "@types/diff": "^5.0.9",
120
120
  "@types/jsonwebtoken": "^9.0.4",
@@ -135,5 +135,5 @@
135
135
  "optionalDependencies": {
136
136
  "@vscode/ripgrep": "^1.17.0"
137
137
  },
138
- "gitHead": "3e24edb92fd0bf0cb7d00fc893d33caf4715243e"
138
+ "gitHead": "5fb63440bb63190e2e6af89f54a7904f70082a1f"
139
139
  }