promptopskit 0.9.0 → 0.9.1

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.
Files changed (37) hide show
  1. package/README.md +18 -5
  2. package/dist/{chunk-W6XHGSPJ.js → chunk-7GMCNHXJ.js} +3 -3
  3. package/dist/{chunk-SVNQNMMV.js → chunk-C5HHTLZX.js} +2 -2
  4. package/dist/{chunk-Q67E2GGD.js → chunk-D23T3X4V.js} +2 -2
  5. package/dist/{chunk-AAQNCAVA.js → chunk-EDHPVR2F.js} +3 -3
  6. package/dist/{chunk-FJ3D76IV.js → chunk-O3SRIDTH.js} +2 -2
  7. package/dist/{chunk-E2AIIPQC.js → chunk-QHAIOVQ3.js} +2 -2
  8. package/dist/{chunk-NS6OTKY2.js → chunk-QZHR2YMK.js} +22 -3
  9. package/dist/{chunk-NS6OTKY2.js.map → chunk-QZHR2YMK.js.map} +1 -1
  10. package/dist/index.cjs +21 -2
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +7 -7
  13. package/dist/providers/anthropic.cjs +21 -2
  14. package/dist/providers/anthropic.cjs.map +1 -1
  15. package/dist/providers/anthropic.js +2 -2
  16. package/dist/providers/gemini.cjs +21 -2
  17. package/dist/providers/gemini.cjs.map +1 -1
  18. package/dist/providers/gemini.js +2 -2
  19. package/dist/providers/llmasaservice.cjs +21 -2
  20. package/dist/providers/llmasaservice.cjs.map +1 -1
  21. package/dist/providers/llmasaservice.js +3 -3
  22. package/dist/providers/openai-responses.cjs +21 -2
  23. package/dist/providers/openai-responses.cjs.map +1 -1
  24. package/dist/providers/openai-responses.js +2 -2
  25. package/dist/providers/openai.cjs +21 -2
  26. package/dist/providers/openai.cjs.map +1 -1
  27. package/dist/providers/openai.js +2 -2
  28. package/dist/providers/openrouter.cjs +21 -2
  29. package/dist/providers/openrouter.cjs.map +1 -1
  30. package/dist/providers/openrouter.js +3 -3
  31. package/package.json +1 -1
  32. /package/dist/{chunk-W6XHGSPJ.js.map → chunk-7GMCNHXJ.js.map} +0 -0
  33. /package/dist/{chunk-SVNQNMMV.js.map → chunk-C5HHTLZX.js.map} +0 -0
  34. /package/dist/{chunk-Q67E2GGD.js.map → chunk-D23T3X4V.js.map} +0 -0
  35. /package/dist/{chunk-AAQNCAVA.js.map → chunk-EDHPVR2F.js.map} +0 -0
  36. /package/dist/{chunk-FJ3D76IV.js.map → chunk-O3SRIDTH.js.map} +0 -0
  37. /package/dist/{chunk-E2AIIPQC.js.map → chunk-QHAIOVQ3.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  geminiAdapter
3
- } from "../chunk-FJ3D76IV.js";
4
- import "../chunk-NS6OTKY2.js";
3
+ } from "../chunk-O3SRIDTH.js";
4
+ import "../chunk-QZHR2YMK.js";
5
5
  import "../chunk-VOXMOGU5.js";
6
6
  export {
7
7
  geminiAdapter
@@ -2556,10 +2556,29 @@ async function compressWithTheTokenCompany(input, options) {
2556
2556
  );
2557
2557
  }
2558
2558
  const data = await response.json();
2559
- if (typeof data.output !== "string" || typeof data.output_tokens !== "number" || typeof data.input_tokens !== "number" || typeof data.tokens_saved !== "number" || typeof data.compression_ratio !== "number") {
2559
+ const normalized = normalizeTheTokenCompanyCompressResponse(data);
2560
+ if (!normalized) {
2560
2561
  throw new Error("TheTokenCompany compression returned an invalid response payload.");
2561
2562
  }
2562
- return data;
2563
+ return normalized;
2564
+ }
2565
+ function normalizeTheTokenCompanyCompressResponse(data) {
2566
+ if (typeof data.output !== "string" || typeof data.output_tokens !== "number") {
2567
+ return void 0;
2568
+ }
2569
+ const inputTokens = typeof data.input_tokens === "number" ? data.input_tokens : data.original_input_tokens;
2570
+ if (typeof inputTokens !== "number") {
2571
+ return void 0;
2572
+ }
2573
+ const tokensSaved = typeof data.tokens_saved === "number" ? data.tokens_saved : inputTokens - data.output_tokens;
2574
+ const compressionRatio = typeof data.compression_ratio === "number" ? data.compression_ratio : data.output_tokens === 0 ? 0 : inputTokens / data.output_tokens;
2575
+ return {
2576
+ output: data.output,
2577
+ output_tokens: data.output_tokens,
2578
+ input_tokens: inputTokens,
2579
+ tokens_saved: tokensSaved,
2580
+ compression_ratio: compressionRatio
2581
+ };
2563
2582
  }
2564
2583
  function getEnv(name) {
2565
2584
  if (typeof process === "undefined") {