toolcraft 0.0.882 → 0.0.883

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/composition.json CHANGED
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "name": "toolcraft",
141
- "version": "0.0.882",
141
+ "version": "0.0.883",
142
142
  "license": "MIT"
143
143
  },
144
144
  {
@@ -148,7 +148,7 @@
148
148
  },
149
149
  {
150
150
  "name": "toolcraft-schema",
151
- "version": "0.0.882",
151
+ "version": "0.0.883",
152
152
  "license": "MIT"
153
153
  },
154
154
  {
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "name": "toolcraft",
141
- "version": "0.0.882",
141
+ "version": "0.0.883",
142
142
  "license": "MIT"
143
143
  },
144
144
  {
@@ -148,7 +148,7 @@
148
148
  },
149
149
  {
150
150
  "name": "toolcraft-schema",
151
- "version": "0.0.882",
151
+ "version": "0.0.883",
152
152
  "license": "MIT"
153
153
  },
154
154
  {
@@ -20,6 +20,7 @@ export interface ObjectFileAcquireOptions extends FsOptions {
20
20
  }
21
21
  export interface ObjectFileStaging {
22
22
  readPage(index: number, options?: FsOptions): Promise<Uint8Array | undefined>;
23
+ /** Own acknowledged bytes; the caller may reuse its buffer after settlement. */
23
24
  writePage(index: number, bytes: Uint8Array, options?: FsOptions): Promise<void>;
24
25
  truncate(size: number, options?: FsOptions): Promise<void>;
25
26
  close(): Promise<void>;
@@ -296,13 +296,16 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
296
296
  const page = Math.floor(offset / chunkBytes);
297
297
  const within = offset % chunkBytes;
298
298
  const length = Math.min(buffer.byteLength - copied, chunkBytes - within);
299
- let bytes = within === 0 && length === chunkBytes ? undefined : await readStagedPage(page, forwarded);
299
+ const complete = within === 0 && length === chunkBytes;
300
+ // Staging owns acknowledged bytes. Borrow the caller's complete
301
+ // page until writePage settles instead of allocating another copy.
302
+ let bytes = complete ? buffer.subarray(copied, copied + length) : await readStagedPage(page, forwarded);
300
303
  if (!bytes) {
301
304
  bytes = new Uint8Array(chunkBytes);
302
- if (within !== 0 || length !== chunkBytes)
303
- bytes.set(await readBase(page * chunkBytes, chunkBytes, forwarded));
305
+ bytes.set(await readBase(page * chunkBytes, chunkBytes, forwarded));
304
306
  }
305
- bytes.set(buffer.subarray(copied, copied + length), within);
307
+ if (!complete)
308
+ bytes.set(buffer.subarray(copied, copied + length), within);
306
309
  await perform(forwarded, selected => state.staging.writePage(page, bytes, selected));
307
310
  copied += length;
308
311
  }
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.882",
11
+ "version": "0.0.883",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.882",
3
+ "version": "0.0.883",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.882",
3
+ "version": "0.0.883",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -177,7 +177,7 @@
177
177
  "saxes"
178
178
  ],
179
179
  "optionalDependencies": {
180
- "toolcraft-schema": "0.0.882",
180
+ "toolcraft-schema": "0.0.883",
181
181
  "toolcraft-design": "*",
182
182
  "@poe-code/frontmatter": "*",
183
183
  "@poe-code/agent-mcp-config": "*",