toolcraft 0.0.882 → 0.0.884
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 +2 -2
- package/dist/composition.json +2 -2
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +24 -19
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +2 -2
package/composition.json
CHANGED
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"name": "toolcraft",
|
|
141
|
-
"version": "0.0.
|
|
141
|
+
"version": "0.0.884",
|
|
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.
|
|
151
|
+
"version": "0.0.884",
|
|
152
152
|
"license": "MIT"
|
|
153
153
|
},
|
|
154
154
|
{
|
package/dist/composition.json
CHANGED
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"name": "toolcraft",
|
|
141
|
-
"version": "0.0.
|
|
141
|
+
"version": "0.0.884",
|
|
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.
|
|
151
|
+
"version": "0.0.884",
|
|
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>;
|
|
@@ -28,16 +28,12 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
|
|
|
28
28
|
while (stagedBytes + chunkBytes > maxStagedBytes || stagedBytes / chunkBytes >= maxStagedPages) {
|
|
29
29
|
forwarded.signal?.throwIfAborted();
|
|
30
30
|
await new Promise((resolve, reject) => {
|
|
31
|
-
const
|
|
31
|
+
const cleanup = () => {
|
|
32
32
|
stagingWaiters.delete(wake);
|
|
33
33
|
forwarded.signal?.removeEventListener("abort", abort);
|
|
34
|
-
resolve();
|
|
35
|
-
};
|
|
36
|
-
const abort = () => {
|
|
37
|
-
stagingWaiters.delete(wake);
|
|
38
|
-
forwarded.signal?.removeEventListener("abort", abort);
|
|
39
|
-
reject(forwarded.signal?.reason);
|
|
40
34
|
};
|
|
35
|
+
const wake = () => { cleanup(); resolve(); };
|
|
36
|
+
const abort = () => { cleanup(); reject(forwarded.signal?.reason); };
|
|
41
37
|
stagingWaiters.add(wake);
|
|
42
38
|
forwarded.signal?.addEventListener("abort", abort, { once: true });
|
|
43
39
|
if (forwarded.signal?.aborted)
|
|
@@ -87,9 +83,13 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
|
|
|
87
83
|
if (state.failure)
|
|
88
84
|
throw state.failure.reason;
|
|
89
85
|
};
|
|
86
|
+
const requirePublication = (writable = true) => {
|
|
87
|
+
if (!store.publish || !writable)
|
|
88
|
+
throw new FsError("ENOTSUP", { path, message: "Object writes require authoritative conditional publication" });
|
|
89
|
+
};
|
|
90
90
|
const perform = async (forwarded, action) => {
|
|
91
91
|
check(forwarded);
|
|
92
|
-
const scope = composeAbortSignals([
|
|
92
|
+
const scope = composeAbortSignals([acquiring && admitted.signal, forwarded.signal].filter((signal) => !!signal));
|
|
93
93
|
try {
|
|
94
94
|
const result = await action({ signal: scope.signal });
|
|
95
95
|
scope.signal.throwIfAborted();
|
|
@@ -163,8 +163,7 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
|
|
|
163
163
|
check(forwarded);
|
|
164
164
|
if (!state.dirty)
|
|
165
165
|
return;
|
|
166
|
-
|
|
167
|
-
throw new FsError("ENOTSUP", { path, message: "Object writes require authoritative conditional publication" });
|
|
166
|
+
requirePublication();
|
|
168
167
|
const expected = state.head?.revision ?? null;
|
|
169
168
|
let emitted = 0;
|
|
170
169
|
let active = true;
|
|
@@ -174,7 +173,8 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
|
|
|
174
173
|
let streamScope;
|
|
175
174
|
try {
|
|
176
175
|
await perform(forwarded, async (selected) => {
|
|
177
|
-
|
|
176
|
+
// perform always supplies its composed signal.
|
|
177
|
+
streamScope = composeAbortSignals([selected.signal, streamAbort.signal]);
|
|
178
178
|
const bodyOptions = { signal: streamScope.signal };
|
|
179
179
|
source = (async function* () {
|
|
180
180
|
for (let position = 0; position < state.size; position += chunkBytes) {
|
|
@@ -230,8 +230,8 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
|
|
|
230
230
|
const mutating = admitted.access !== "read" || admitted.creation !== "never" || admitted.truncate;
|
|
231
231
|
if (mutating && capabilities.readOnly === true)
|
|
232
232
|
throw new FsError("EROFS", { path });
|
|
233
|
-
if (mutating
|
|
234
|
-
|
|
233
|
+
if (mutating)
|
|
234
|
+
requirePublication(capabilities.write !== false);
|
|
235
235
|
if (admitted.access !== "write" && capabilities.read === false)
|
|
236
236
|
throw new FsError("EACCES", { path });
|
|
237
237
|
const acquired = await store.acquire(path, { access: admitted.access, ...(admitted.noFollow ? { noFollow: true } : {}), ...(admitted.signal ? { signal: admitted.signal } : {}) });
|
|
@@ -296,13 +296,18 @@ 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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
299
|
+
// Staging owns acknowledged bytes. Borrow complete pages until
|
|
300
|
+
// settlement; only partial writes need read/modify/write storage.
|
|
301
|
+
let bytes = buffer.subarray(copied, copied + length);
|
|
302
|
+
if (within || length !== chunkBytes) {
|
|
303
|
+
let previous = await readStagedPage(page, forwarded);
|
|
304
|
+
if (!previous) {
|
|
305
|
+
previous = new Uint8Array(chunkBytes);
|
|
306
|
+
previous.set(await readBase(page * chunkBytes, chunkBytes, forwarded));
|
|
307
|
+
}
|
|
308
|
+
previous.set(bytes, within);
|
|
309
|
+
bytes = previous;
|
|
304
310
|
}
|
|
305
|
-
bytes.set(buffer.subarray(copied, copied + length), within);
|
|
306
311
|
await perform(forwarded, selected => state.staging.writePage(page, bytes, selected));
|
|
307
312
|
copied += length;
|
|
308
313
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.884",
|
|
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.
|
|
180
|
+
"toolcraft-schema": "0.0.884",
|
|
181
181
|
"toolcraft-design": "*",
|
|
182
182
|
"@poe-code/frontmatter": "*",
|
|
183
183
|
"@poe-code/agent-mcp-config": "*",
|