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
  openaiResponsesAdapter
3
- } from "../chunk-E2AIIPQC.js";
4
- import "../chunk-NS6OTKY2.js";
3
+ } from "../chunk-QHAIOVQ3.js";
4
+ import "../chunk-QZHR2YMK.js";
5
5
  import "../chunk-VOXMOGU5.js";
6
6
  export {
7
7
  openaiResponsesAdapter
@@ -2551,10 +2551,29 @@ async function compressWithTheTokenCompany(input, options) {
2551
2551
  );
2552
2552
  }
2553
2553
  const data = await response.json();
2554
- 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") {
2554
+ const normalized = normalizeTheTokenCompanyCompressResponse(data);
2555
+ if (!normalized) {
2555
2556
  throw new Error("TheTokenCompany compression returned an invalid response payload.");
2556
2557
  }
2557
- return data;
2558
+ return normalized;
2559
+ }
2560
+ function normalizeTheTokenCompanyCompressResponse(data) {
2561
+ if (typeof data.output !== "string" || typeof data.output_tokens !== "number") {
2562
+ return void 0;
2563
+ }
2564
+ const inputTokens = typeof data.input_tokens === "number" ? data.input_tokens : data.original_input_tokens;
2565
+ if (typeof inputTokens !== "number") {
2566
+ return void 0;
2567
+ }
2568
+ const tokensSaved = typeof data.tokens_saved === "number" ? data.tokens_saved : inputTokens - data.output_tokens;
2569
+ const compressionRatio = typeof data.compression_ratio === "number" ? data.compression_ratio : data.output_tokens === 0 ? 0 : inputTokens / data.output_tokens;
2570
+ return {
2571
+ output: data.output,
2572
+ output_tokens: data.output_tokens,
2573
+ input_tokens: inputTokens,
2574
+ tokens_saved: tokensSaved,
2575
+ compression_ratio: compressionRatio
2576
+ };
2558
2577
  }
2559
2578
  function getEnv(name) {
2560
2579
  if (typeof process === "undefined") {