@xynogen/pix-skills 0.10.4 → 0.10.6

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/package.json +2 -2
  2. package/src/remote.ts +18 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-skills",
3
- "version": "0.10.4",
3
+ "version": "0.10.6",
4
4
  "description": "Pi extension \u2014 agent skill loader (skill tool + skills bundle)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -49,6 +49,6 @@
49
49
  "dependencies": {
50
50
  "@xynogen/pix-gate": "^0.4.0",
51
51
  "@xynogen/pix-pretty": "^1.32.0",
52
- "@xynogen/pix-runtime": "^0.15.0"
52
+ "@xynogen/pix-runtime": "^0.16.0"
53
53
  }
54
54
  }
package/src/remote.ts CHANGED
@@ -156,9 +156,24 @@ async function fetchBytes(
156
156
  if (!response.ok) throw new Error(`Remote request failed (${response.status}): ${url}`);
157
157
  const declared = Number(response.headers.get("content-length") ?? "0");
158
158
  if (declared > maxBytes) throw new Error(`Remote file exceeds ${maxBytes} byte limit`);
159
- const bytes = Buffer.from(await response.arrayBuffer());
160
- if (bytes.byteLength > maxBytes) throw new Error(`Remote file exceeds ${maxBytes} byte limit`);
161
- return bytes;
159
+ // Stream with a running cap: content-length can be absent or wrong, and
160
+ // arrayBuffer() would buffer an unbounded body before any check.
161
+ if (!response.body) return Buffer.alloc(0);
162
+ const chunks: Uint8Array[] = [];
163
+ let total = 0;
164
+ const reader = response.body.getReader();
165
+ try {
166
+ for (;;) {
167
+ const { done, value } = await reader.read();
168
+ if (done) break;
169
+ total += value.byteLength;
170
+ if (total > maxBytes) throw new Error(`Remote file exceeds ${maxBytes} byte limit`);
171
+ chunks.push(value);
172
+ }
173
+ } finally {
174
+ reader.cancel().catch(() => {});
175
+ }
176
+ return Buffer.concat(chunks);
162
177
  }
163
178
 
164
179
  async function fetchText(