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
package/dist/index.cjs CHANGED
@@ -2630,10 +2630,29 @@ async function compressWithTheTokenCompany(input, options) {
2630
2630
  );
2631
2631
  }
2632
2632
  const data = await response.json();
2633
- 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") {
2633
+ const normalized = normalizeTheTokenCompanyCompressResponse(data);
2634
+ if (!normalized) {
2634
2635
  throw new Error("TheTokenCompany compression returned an invalid response payload.");
2635
2636
  }
2636
- return data;
2637
+ return normalized;
2638
+ }
2639
+ function normalizeTheTokenCompanyCompressResponse(data) {
2640
+ if (typeof data.output !== "string" || typeof data.output_tokens !== "number") {
2641
+ return void 0;
2642
+ }
2643
+ const inputTokens = typeof data.input_tokens === "number" ? data.input_tokens : data.original_input_tokens;
2644
+ if (typeof inputTokens !== "number") {
2645
+ return void 0;
2646
+ }
2647
+ const tokensSaved = typeof data.tokens_saved === "number" ? data.tokens_saved : inputTokens - data.output_tokens;
2648
+ const compressionRatio = typeof data.compression_ratio === "number" ? data.compression_ratio : data.output_tokens === 0 ? 0 : inputTokens / data.output_tokens;
2649
+ return {
2650
+ output: data.output,
2651
+ output_tokens: data.output_tokens,
2652
+ input_tokens: inputTokens,
2653
+ tokens_saved: tokensSaved,
2654
+ compression_ratio: compressionRatio
2655
+ };
2637
2656
  }
2638
2657
  function getEnv(name) {
2639
2658
  if (typeof process === "undefined") {