pi-freeflow 1.0.8 → 1.1.0

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 (2) hide show
  1. package/extensions/index.ts +21 -14
  2. package/package.json +1 -1
@@ -948,15 +948,20 @@ function normalizeRequestBody(
948
948
  }
949
949
 
950
950
  // 3. Max & Min tokens clamping (OpenCode Zen requires min 16; Vercel relay caps at 64k)
951
- const mt = (body.max_tokens ?? body.maxTokens ?? body.max_output_tokens) as number | undefined;
952
- if (typeof mt === "number") {
953
- let clamped = mt;
954
- if (clamped < 16) clamped = 16;
955
- else if (isRelay && clamped > RELAY_MAX_TOKENS) clamped = RELAY_MAX_TOKENS;
956
-
957
- if (body.max_tokens !== undefined) body.max_tokens = clamped;
958
- if (body.maxTokens !== undefined) body.maxTokens = clamped;
959
- if (body.max_output_tokens !== undefined) body.max_output_tokens = clamped;
951
+ const clampTokens = (val: number): number => {
952
+ if (val < 16) return 16;
953
+ if (isRelay && val > RELAY_MAX_TOKENS) return RELAY_MAX_TOKENS;
954
+ return val;
955
+ };
956
+
957
+ if (typeof body.max_tokens === "number") {
958
+ body.max_tokens = clampTokens(body.max_tokens);
959
+ }
960
+ if (typeof body.maxTokens === "number") {
961
+ body.maxTokens = clampTokens(body.maxTokens);
962
+ }
963
+ if (typeof body.max_output_tokens === "number") {
964
+ body.max_output_tokens = clampTokens(body.max_output_tokens);
960
965
  }
961
966
 
962
967
  return body;
@@ -1659,10 +1664,12 @@ export default async function (pi: ExtensionAPI) {
1659
1664
  );
1660
1665
  });
1661
1666
 
1662
- pi.on("session_shutdown", () => {
1663
- log("info", "shutting down proxy...");
1664
- server.close();
1665
- rateLimitMap.clear();
1666
- log("info", "shutdown complete");
1667
+ pi.on?.("session_shutdown", () => {
1668
+ if (server) {
1669
+ log("info", "shutting down proxy...");
1670
+ server.close();
1671
+ rateLimitMap.clear();
1672
+ log("info", "shutdown complete");
1673
+ }
1667
1674
  });
1668
1675
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-freeflow",
3
3
  "type": "module",
4
- "version": "1.0.8",
4
+ "version": "1.1.0",
5
5
  "description": "Personal multi-cloud rolling fallback relay for OpenCode Zen and KiloCode models in OMP/Pi",
6
6
  "keywords": [
7
7
  "pi-package",