Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
184 lines
5.7 KiB
JavaScript
184 lines
5.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Keeps the native OpenClawKit Canvas A2UI resources in sync with the plugin-owned bundle.
|
|
import { spawnSync } from "node:child_process";
|
|
import fs from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const REQUIRED_RESOURCE_FILES = ["a2ui.bundle.js", "index.html"];
|
|
|
|
export function getNativeA2uiResourcePaths(repoRoot = rootDir) {
|
|
return {
|
|
sourceDir: path.join(repoRoot, "extensions", "canvas", "src", "host", "a2ui"),
|
|
nativeDir: path.join(
|
|
repoRoot,
|
|
"apps",
|
|
"shared",
|
|
"OpenClawKit",
|
|
"Sources",
|
|
"OpenClawKit",
|
|
"Resources",
|
|
"CanvasA2UI",
|
|
),
|
|
};
|
|
}
|
|
|
|
function normalizeRelativePath(filePath) {
|
|
return filePath.split(path.sep).join("/");
|
|
}
|
|
|
|
async function listRelativeFiles(dir, baseDir = dir) {
|
|
let entries;
|
|
try {
|
|
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
} catch (error) {
|
|
if (error?.code === "ENOENT") {
|
|
return [];
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
const files = [];
|
|
for (const entry of entries) {
|
|
const entryPath = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
files.push(...(await listRelativeFiles(entryPath, baseDir)));
|
|
continue;
|
|
}
|
|
files.push(normalizeRelativePath(path.relative(baseDir, entryPath)));
|
|
}
|
|
return files.toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
|
|
function formatList(values) {
|
|
return values.length === 0 ? "(none)" : values.map((value) => `- ${value}`).join("\n");
|
|
}
|
|
|
|
async function assertSourceResourcesExist(sourceDir) {
|
|
const missing = [];
|
|
for (const fileName of REQUIRED_RESOURCE_FILES) {
|
|
try {
|
|
await fs.stat(path.join(sourceDir, fileName));
|
|
} catch (error) {
|
|
if (error?.code === "ENOENT") {
|
|
missing.push(fileName);
|
|
continue;
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
if (missing.length > 0) {
|
|
throw new Error(
|
|
`Missing generated A2UI resources. Run "pnpm canvas:a2ui:bundle".\nMissing:\n${formatList(missing)}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function syncNativeA2uiResources({ sourceDir, nativeDir }) {
|
|
await assertSourceResourcesExist(sourceDir);
|
|
await fs.rm(nativeDir, { recursive: true, force: true });
|
|
await fs.mkdir(nativeDir, { recursive: true });
|
|
for (const fileName of REQUIRED_RESOURCE_FILES) {
|
|
await fs.copyFile(path.join(sourceDir, fileName), path.join(nativeDir, fileName));
|
|
}
|
|
}
|
|
|
|
export async function checkNativeA2uiResources({ sourceDir, nativeDir }) {
|
|
await assertSourceResourcesExist(sourceDir);
|
|
const actualFiles = await listRelativeFiles(nativeDir);
|
|
const expectedFiles = [...REQUIRED_RESOURCE_FILES].toSorted((left, right) =>
|
|
left.localeCompare(right),
|
|
);
|
|
const missing = expectedFiles.filter((fileName) => !actualFiles.includes(fileName));
|
|
const unexpected = actualFiles.filter((fileName) => !expectedFiles.includes(fileName));
|
|
if (missing.length > 0 || unexpected.length > 0) {
|
|
throw new Error(
|
|
[
|
|
'Native A2UI resource tree is stale. Run "pnpm canvas:a2ui:native:sync".',
|
|
`Missing:\n${formatList(missing)}`,
|
|
`Unexpected:\n${formatList(unexpected)}`,
|
|
].join("\n"),
|
|
);
|
|
}
|
|
|
|
const mismatched = [];
|
|
for (const fileName of expectedFiles) {
|
|
const [source, native] = await Promise.all([
|
|
fs.readFile(path.join(sourceDir, fileName)),
|
|
fs.readFile(path.join(nativeDir, fileName)),
|
|
]);
|
|
if (!source.equals(native)) {
|
|
mismatched.push(fileName);
|
|
}
|
|
}
|
|
if (mismatched.length > 0) {
|
|
throw new Error(
|
|
`Native A2UI resources differ from generated source. Run "pnpm canvas:a2ui:native:sync".\nMismatched:\n${formatList(mismatched)}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
function parseMode(argv) {
|
|
const check = argv.includes("--check");
|
|
const write = argv.includes("--write");
|
|
if (check === write) {
|
|
throw new Error("Usage: node scripts/sync-native-a2ui.mjs --check|--write");
|
|
}
|
|
return write ? "write" : "check";
|
|
}
|
|
|
|
function bundleA2ui(repoRoot = rootDir, env = process.env) {
|
|
const result = spawnSync(process.execPath, ["scripts/bundle-a2ui.mjs"], {
|
|
cwd: repoRoot,
|
|
env,
|
|
stdio: "inherit",
|
|
});
|
|
if (result.status !== 0) {
|
|
throw new Error("A2UI bundling failed before native resource sync.");
|
|
}
|
|
}
|
|
|
|
async function withFreshBundleCheckSource(sourceDir, run) {
|
|
const tempDir = await fs.mkdtemp(path.join(tmpdir(), "openclaw-a2ui-native-check-"));
|
|
try {
|
|
const checkSourceDir = path.join(tempDir, "a2ui");
|
|
await fs.mkdir(checkSourceDir, { recursive: true });
|
|
await fs.copyFile(path.join(sourceDir, "index.html"), path.join(checkSourceDir, "index.html"));
|
|
bundleA2ui(rootDir, {
|
|
...process.env,
|
|
OPENCLAW_A2UI_BUNDLE_OUT: path.join(checkSourceDir, "a2ui.bundle.js"),
|
|
OPENCLAW_A2UI_BUNDLE_HASH_FILE: path.join(tempDir, ".bundle.hash"),
|
|
});
|
|
await run(checkSourceDir);
|
|
} finally {
|
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const mode = parseMode(process.argv.slice(2));
|
|
const paths = getNativeA2uiResourcePaths();
|
|
if (mode === "write") {
|
|
bundleA2ui();
|
|
await syncNativeA2uiResources(paths);
|
|
console.log("[canvas] native A2UI resources synced.");
|
|
return;
|
|
}
|
|
await withFreshBundleCheckSource(paths.sourceDir, async (sourceDir) => {
|
|
await checkNativeA2uiResources({ sourceDir, nativeDir: paths.nativeDir });
|
|
});
|
|
console.log("[canvas] native A2UI resources up to date.");
|
|
}
|
|
|
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
await main().catch(
|
|
/** @param {unknown} error */ (error) => {
|
|
console.error(error instanceof Error ? error.message : String(error));
|
|
process.exit(1);
|
|
},
|
|
);
|
|
}
|