openclaw/scripts/verify-mac-node-worker-fs.mjs
Peter Steinberger 75bcd267f5
feat(skills): add personal libraries for shared Gateways (#134068)
* feat(skills): add personal libraries for shared Gateways

* fix(skills): validate ZIP imports with fs-safe 0.7.0

Use the published platform-package boundary and remove copied native assets.
Keep CLI bootstrap imports lazy, preserve sealed-worker defaults, and align
archive fixtures and current-main contracts with the stricter dependency.

* fix: own partial output staging before publication

* docs(skills): clarify Claude library delivery

* docs: leave skills release notes to release automation

* fix(skills): simplify library dispatch and preserve resource identity

Share the Workshop schema and descriptor across local and worker paths, remove redundant adapters and UI/import/CLI duplication, and preserve lossless directory identities in remote skill transfer. The cleanup removes 114 production lines; a child-process regression proves adjacent large file indexes cannot share authority.

* fix(skills): preserve declaration and compiled worker boundaries

Keep the exact protocol fragment types named during declaration emission to avoid TS7056 without changing runtime schemas. Observe resolved subprocess entry URLs in generation tests and derive full-tree audit roots from the canonical worker build registry.

Cold real Gateway and node-worker E2E: 2 passed. Protocol checks and package declarations passed. Fresh P0-scoped Codex autoreview returned no findings. Local artifact tests and hosted CI continue before landing.

* test(auth): type the optional stdin fixture property honestly

The ReadStream intersection kept isTTY required, so deleting an originally absent own property failed TS2790. Use the optional property surface the fixture actually owns, without a cast. The auth-login integration test and exact CI type-check stripe 4/5 pass; fresh P0-scoped Codex review is clean.

* fix(gateway): keep health discovery out of credential migration

Passive post-connect health synchronously loaded dormant Matrix credential checkers and blocked the Gateway event loop for 6.5 seconds on clean Linux. Keep loaded and configured channel inventory while leaving persisted-only discovery to setup and migration. Real resolver regression fails before and passes after; original Linux guard cases pass at unchanged deadlines. Health and inventory coverage: 49 passing tests.

* test(node): synchronize worker prewarm cancellation by readiness

Replace competing readiness and completion timers with a held HTTP request from the real child. Require peer close, cancellation rejection, and queued install completion, then join owned operations on every exit. The full installer suite passes all 27 cases; Windows hosted proof remains pending.
2026-09-01 13:15:37 -07:00

51 lines
2.1 KiB
JavaScript
Executable file

#!/usr/bin/env node
import assert from "node:assert/strict";
import fs from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";
import { pathToFileURL } from "node:url";
const [packageArg, home] = process.argv.slice(2);
if (!packageArg || !home) {
throw new Error("Usage: verify-mac-node-worker-fs.mjs <package-root> <proof-home>");
}
assert.equal(process.env.HOME, home);
assert.equal(process.env.TMPDIR, home);
assert.equal(process.env.FS_SAFE_NATIVE_MODE, "require");
const packageRoot = fs.realpathSync(packageArg);
const { root } = await import(
pathToFileURL(path.join(packageRoot, "dist/plugin-sdk/memory-core-host-engine-fs.js")).href
);
const scoped = await root(home);
const written = "bundled worker write proof\n";
const created = "bundled worker create proof\n";
fs.writeFileSync(path.join(home, "native-write-proof"), "before replacement\n");
await scoped.write("native-write-proof", written);
await scoped.create("native-create-proof", created);
assert.deepEqual(fs.readFileSync(path.join(home, "native-write-proof")), Buffer.from(written));
assert.deepEqual(fs.readFileSync(path.join(home, "native-create-proof")), Buffer.from(created));
// Resolve from fs-safe's dependency scope, including pnpm's nested install layout.
const requireFromPackage = createRequire(path.join(packageRoot, "package.json"));
const requireFromFsSafe = createRequire(
requireFromPackage.resolve("@openclaw/fs-safe/package.json"),
);
const nativeModule = requireFromFsSafe.resolve(
`@openclaw/fs-safe-${process.platform}-${process.arch}`,
);
assert(
nativeModule.startsWith(packageRoot + path.sep),
"fs-safe native package is outside the worker payload",
);
const loaded = Object.keys(createRequire(import.meta.url).cache).filter(
(file) => path.basename(file) === "fs-safe-native.node",
);
assert.deepEqual(loaded, [nativeModule], "Installed fs-safe native module path mismatch");
console.log(
JSON.stringify({
architecture: process.arch,
nativeModule,
writeBytes: Buffer.byteLength(written),
createBytes: Buffer.byteLength(created),
}),
);