@papert-code/papert-code 0.3.93 → 0.3.95

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.
@@ -106342,7 +106342,7 @@ var __filename = fileURLToPath(import.meta.url);
106342
106342
  var __dirname2 = path4.dirname(__filename);
106343
106343
  async function getVersion() {
106344
106344
  const pkgJson = await getPackageJson(__dirname2);
106345
- return "0.3.93";
106345
+ return "0.3.95";
106346
106346
  }
106347
106347
  __name(getVersion, "getVersion");
106348
106348
 
@@ -108193,7 +108193,7 @@ __name(recordSubagentExecutionMetrics, "recordSubagentExecutionMetrics");
108193
108193
  init_esbuild_shims();
108194
108194
  var import_https_proxy_agent = __toESM(require_dist(), 1);
108195
108195
  import { Buffer as Buffer2 } from "buffer";
108196
- import * as https from "https";
108196
+ import * as https from "node:https";
108197
108197
 
108198
108198
  // packages/core/dist/src/utils/installationManager.js
108199
108199
  init_esbuild_shims();
@@ -110213,7 +110213,7 @@ function createContentGeneratorConfig(config, authType, generationConfig) {
110213
110213
  }
110214
110214
  __name(createContentGeneratorConfig, "createContentGeneratorConfig");
110215
110215
  async function createContentGenerator(config, gcConfig, isInitialAuth) {
110216
- const version2 = "0.3.93";
110216
+ const version2 = "0.3.95";
110217
110217
  const userAgent = `PapertCode/${version2} (${process.platform}; ${process.arch})`;
110218
110218
  const baseHeaders = {
110219
110219
  "User-Agent": userAgent
@@ -110244,12 +110244,12 @@ async function createContentGenerator(config, gcConfig, isInitialAuth) {
110244
110244
  if (!config.apiKey) {
110245
110245
  throw new Error("OpenAI API key is required");
110246
110246
  }
110247
- const { createOpenAIContentGenerator } = await import("./openaiContentGenerator-RS2GU6IS.js");
110247
+ const { createOpenAIContentGenerator } = await import("./openaiContentGenerator-P6VRBRRB.js");
110248
110248
  return createOpenAIContentGenerator(config, gcConfig);
110249
110249
  }
110250
110250
  if (config.authType === AuthType2.PAPERT_OAUTH) {
110251
110251
  const { getPapertOAuthClient: getPapertOauthClient } = await import("./papertOAuth2-4I4JYPZW.js");
110252
- const { PapertContentGenerator } = await import("./papertContentGenerator-RYRJQVBF.js");
110252
+ const { PapertContentGenerator } = await import("./papertContentGenerator-E64QQV3K.js");
110253
110253
  try {
110254
110254
  const papertClient = await getPapertOauthClient(gcConfig, isInitialAuth ? { requireCachedCredentials: true } : void 0);
110255
110255
  return new PapertContentGenerator(papertClient, config, gcConfig);
@@ -31,7 +31,7 @@ import {
31
31
  logApiError,
32
32
  logApiResponse,
33
33
  tokenLimit
34
- } from "./chunk-TQNFJUNM.js";
34
+ } from "./chunk-KDPC3L34.js";
35
35
  import {
36
36
  __name,
37
37
  init_esbuild_shims
@@ -9924,8 +9924,7 @@ var DefaultRequestTokenizer = class {
9924
9924
  }
9925
9925
  }
9926
9926
  /**
9927
- * Calculate tokens for audio contents
9928
- * TODO: Implement proper audio token calculation
9927
+ * Calculate tokens for audio contents using a conservative data-size heuristic.
9929
9928
  */
9930
9929
  async calculateAudioTokens(audioContents) {
9931
9930
  if (audioContents.length === 0)
@@ -9934,7 +9933,10 @@ var DefaultRequestTokenizer = class {
9934
9933
  for (const audioContent of audioContents) {
9935
9934
  try {
9936
9935
  const dataSize = Math.floor(audioContent.data.length * 0.75);
9937
- totalTokens += Math.max(Math.ceil(dataSize / 100), 10);
9936
+ const mimeType = audioContent.mimeType.toLowerCase();
9937
+ const bytesPerToken = mimeType.includes("wav") || mimeType.includes("wave") ? 80 : 120;
9938
+ const estimatedTokens = Math.ceil(dataSize / bytesPerToken);
9939
+ totalTokens += Math.min(Math.max(estimatedTokens, 10), 16384);
9938
9940
  } catch (error) {
9939
9941
  console.warn("Error calculating audio tokens:", error);
9940
9942
  totalTokens += 10;