vargai 0.4.0-alpha76 → 0.4.0-alpha77

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.
package/package.json CHANGED
@@ -71,7 +71,7 @@
71
71
  "zod": "^4.2.1"
72
72
  },
73
73
  "sideEffects": false,
74
- "version": "0.4.0-alpha76",
74
+ "version": "0.4.0-alpha77",
75
75
  "exports": {
76
76
  ".": "./src/index.ts",
77
77
  "./ai": "./src/ai-sdk/index.ts",
@@ -85,7 +85,13 @@ function serializeValue(v: unknown): string {
85
85
  return v;
86
86
  }
87
87
  if (v instanceof Uint8Array) {
88
- return Buffer.from(v).toString("base64");
88
+ // Hash binary data instead of base64-encoding to keep cache keys small.
89
+ // Raw base64 can produce 65-110KB strings for audio segments, exceeding
90
+ // Upstash Redis' 32KB key size limit.
91
+ return `uint8:${v.byteLength}:${Bun.hash(v).toString(16)}`;
92
+ }
93
+ if (isVargElement(v)) {
94
+ return `element:${computeCacheKey(v).join(":")}`;
89
95
  }
90
96
  if (Array.isArray(v)) {
91
97
  return `[${v.map(serializeValue).join(",")}]`;
@@ -128,7 +134,7 @@ export function computeCacheKey(element: VargElement): CacheKeyPart[] {
128
134
  } else if (v === null || v === undefined) {
129
135
  key.push(k, v);
130
136
  } else if (v instanceof Uint8Array) {
131
- key.push(k, Buffer.from(v).toString("base64"));
137
+ key.push(k, `uint8:${v.byteLength}:${Bun.hash(v).toString(16)}`);
132
138
  } else if (isVargElement(v)) {
133
139
  key.push(k, ...computeCacheKey(v));
134
140
  } else if (Array.isArray(v) || typeof v === "object") {