Vendor OpenClaw source as Adolf fork baseline
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
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
This commit is contained in:
314
ui/vite.config.ts
Normal file
314
ui/vite.config.ts
Normal file
@@ -0,0 +1,314 @@
|
||||
// Control UI config module wires vite behavior.
|
||||
import { execFileSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { Plugin, UserConfig } from "vite";
|
||||
import { controlUiManualChunk } from "./config/control-ui-chunking.ts";
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = path.resolve(here, "..");
|
||||
const outDir = path.resolve(here, "../dist/control-ui");
|
||||
const require = createRequire(import.meta.url);
|
||||
const json5EsmPath = require.resolve("json5/dist/index.mjs");
|
||||
type ControlUiViteAlias = {
|
||||
find: string | RegExp;
|
||||
replacement: string;
|
||||
};
|
||||
const commonJsOptimizeDeps = [
|
||||
"highlight.js/lib/core",
|
||||
"highlight.js/lib/languages/bash",
|
||||
"highlight.js/lib/languages/cpp",
|
||||
"highlight.js/lib/languages/css",
|
||||
"highlight.js/lib/languages/diff",
|
||||
"highlight.js/lib/languages/go",
|
||||
"highlight.js/lib/languages/java",
|
||||
"highlight.js/lib/languages/javascript",
|
||||
"highlight.js/lib/languages/json",
|
||||
"highlight.js/lib/languages/markdown",
|
||||
"highlight.js/lib/languages/python",
|
||||
"highlight.js/lib/languages/rust",
|
||||
"highlight.js/lib/languages/typescript",
|
||||
"highlight.js/lib/languages/xml",
|
||||
"highlight.js/lib/languages/yaml",
|
||||
] as const;
|
||||
|
||||
function normalizeBase(input: string): string {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) {
|
||||
return "/";
|
||||
}
|
||||
if (trimmed === "./") {
|
||||
return "./";
|
||||
}
|
||||
if (trimmed.endsWith("/")) {
|
||||
return trimmed;
|
||||
}
|
||||
return `${trimmed}/`;
|
||||
}
|
||||
|
||||
function normalizeBuildId(input: string): string {
|
||||
const normalized = input.trim().replace(/[^a-zA-Z0-9._-]+/g, "-");
|
||||
return normalized.slice(0, 96) || "dev";
|
||||
}
|
||||
|
||||
function readPackageVersion(): string {
|
||||
try {
|
||||
const raw = fs.readFileSync(path.join(repoRoot, "package.json"), "utf8");
|
||||
const parsed = JSON.parse(raw) as { version?: unknown };
|
||||
return typeof parsed.version === "string" && parsed.version.trim()
|
||||
? parsed.version.trim()
|
||||
: "dev";
|
||||
} catch {
|
||||
return "dev";
|
||||
}
|
||||
}
|
||||
|
||||
function readGitShortSha(): string | null {
|
||||
try {
|
||||
const raw = execFileSync("git", ["-C", repoRoot, "rev-parse", "--short=12", "HEAD"], {
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
return raw.trim() || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveControlUiBuildId(): string {
|
||||
const explicit =
|
||||
process.env.OPENCLAW_CONTROL_UI_BUILD_ID?.trim() || process.env.OPENCLAW_VERSION?.trim();
|
||||
if (explicit) {
|
||||
return normalizeBuildId(explicit);
|
||||
}
|
||||
const version = readPackageVersion();
|
||||
const gitSha = readGitShortSha();
|
||||
return normalizeBuildId(gitSha ? `${version}-${gitSha}` : version);
|
||||
}
|
||||
|
||||
function escapeRegExp(input: string): string {
|
||||
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
function sortTsconfigPathEntries(entries: Array<[string, unknown]>): Array<[string, unknown]> {
|
||||
return entries.toSorted(([left], [right]) => {
|
||||
const leftPrefixLength = left.includes("*") ? left.indexOf("*") : left.length;
|
||||
const rightPrefixLength = right.includes("*") ? right.indexOf("*") : right.length;
|
||||
if (leftPrefixLength !== rightPrefixLength) {
|
||||
return rightPrefixLength - leftPrefixLength;
|
||||
}
|
||||
return right.length - left.length || left.localeCompare(right);
|
||||
});
|
||||
}
|
||||
|
||||
function resolveTsconfigTargetPath(target: string): string {
|
||||
return path.resolve(repoRoot, target.replace(/^\.\//, ""));
|
||||
}
|
||||
|
||||
function resolveTsconfigPathAlias(key: string, target: string): ControlUiViteAlias | null {
|
||||
const keyWildcardIndex = key.indexOf("*");
|
||||
const targetWildcardIndex = target.indexOf("*");
|
||||
if (keyWildcardIndex === -1 || targetWildcardIndex === -1) {
|
||||
if (keyWildcardIndex !== -1 || targetWildcardIndex !== -1) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
find: key,
|
||||
replacement: resolveTsconfigTargetPath(target),
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
key.slice(keyWildcardIndex + 1).includes("*") ||
|
||||
target.slice(targetWildcardIndex + 1).includes("*")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const prefix = key.slice(0, keyWildcardIndex);
|
||||
const suffix = key.slice(keyWildcardIndex + 1);
|
||||
return {
|
||||
find: new RegExp(`^${escapeRegExp(prefix)}(.+)${escapeRegExp(suffix)}$`),
|
||||
replacement: resolveTsconfigTargetPath(target).replace("*", "$1"),
|
||||
};
|
||||
}
|
||||
|
||||
function sourcePackageAlias(packageId: string, subpath?: string): ControlUiViteAlias {
|
||||
return {
|
||||
find: `@openclaw/${packageId}${subpath ? `/${subpath}` : ""}`,
|
||||
replacement: path.join(
|
||||
repoRoot,
|
||||
"packages",
|
||||
packageId,
|
||||
"src",
|
||||
...(subpath ? subpath.split("/") : ["index"]).map((part, index, parts) =>
|
||||
index === parts.length - 1 ? `${part}.ts` : part,
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveSourcePackageAliasesForVite(): ControlUiViteAlias[] {
|
||||
return [
|
||||
sourcePackageAlias("normalization-core", "number-coercion"),
|
||||
sourcePackageAlias("normalization-core", "record-coerce"),
|
||||
sourcePackageAlias("normalization-core", "string-coerce"),
|
||||
sourcePackageAlias("normalization-core", "string-normalization"),
|
||||
sourcePackageAlias("normalization-core", "utf16-slice"),
|
||||
sourcePackageAlias("normalization-core"),
|
||||
];
|
||||
}
|
||||
|
||||
export function resolveExternalPackageAliasesForVite(): ControlUiViteAlias[] {
|
||||
return [
|
||||
{
|
||||
find: "@openclaw/libterminal/browser",
|
||||
replacement: path.join(
|
||||
repoRoot,
|
||||
"node_modules",
|
||||
"@openclaw",
|
||||
"libterminal",
|
||||
"dist",
|
||||
"browser.js",
|
||||
),
|
||||
},
|
||||
{
|
||||
find: "@openclaw/uirouter",
|
||||
replacement: path.join(repoRoot, "node_modules", "@openclaw", "uirouter", "dist", "index.js"),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function resolveTsconfigPathAliasesForVite(): ControlUiViteAlias[] {
|
||||
const raw = fs.readFileSync(path.join(repoRoot, "tsconfig.json"), "utf8");
|
||||
const parsed = JSON.parse(raw) as {
|
||||
compilerOptions?: { paths?: Record<string, unknown> };
|
||||
};
|
||||
const paths = parsed.compilerOptions?.paths;
|
||||
if (!paths) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return sortTsconfigPathEntries(Object.entries(paths)).flatMap(([key, targets]) => {
|
||||
if (!Array.isArray(targets) || typeof targets[0] !== "string") {
|
||||
return [];
|
||||
}
|
||||
const alias = resolveTsconfigPathAlias(key, targets[0]);
|
||||
return alias ? [alias] : [];
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeViteImporterPath(importer: string): string {
|
||||
return path.normalize(importer.replace(/[?#].*$/u, ""));
|
||||
}
|
||||
|
||||
export function controlUiBrowserOnlySharedModuleAliases(): Plugin {
|
||||
const browserRedactPath = path.join(here, "src/lib/browser-redact.ts");
|
||||
const sharedRedactImporters = new Set([
|
||||
path.join(repoRoot, "src/agents/tool-display-common.ts"),
|
||||
path.join(repoRoot, "src/agents/tool-display-exec.ts"),
|
||||
path.join(repoRoot, "src/agents/tool-display.ts"),
|
||||
]);
|
||||
return {
|
||||
name: "control-ui-browser-only-shared-module-aliases",
|
||||
enforce: "pre",
|
||||
resolveId(source, importer) {
|
||||
if (
|
||||
source === "../logging/redact.js" &&
|
||||
importer &&
|
||||
sharedRedactImporters.has(normalizeViteImporterPath(importer))
|
||||
) {
|
||||
return browserRedactPath;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function controlUiServiceWorkerBuildIdPlugin(buildId: string): Plugin {
|
||||
return {
|
||||
name: "control-ui-service-worker-build-id",
|
||||
apply: "build",
|
||||
closeBundle() {
|
||||
const swPath = path.join(outDir, "sw.js");
|
||||
const publicSwPath = path.join(here, "public/sw.js");
|
||||
const source = fs.readFileSync(publicSwPath, "utf8");
|
||||
const placeholder = '"__OPENCLAW_CONTROL_UI_BUILD_ID__"';
|
||||
const updated = source.replace(placeholder, JSON.stringify(buildId));
|
||||
if (updated === source) {
|
||||
throw new Error(`Control UI service worker build id placeholder missing in ${swPath}`);
|
||||
}
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
fs.writeFileSync(swPath, updated);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default function controlUiViteConfig(): UserConfig {
|
||||
const envBase = process.env.OPENCLAW_CONTROL_UI_BASE_PATH?.trim();
|
||||
const base = envBase ? normalizeBase(envBase) : "./";
|
||||
const bootstrapConfigPath =
|
||||
base === "./" ? "/control-ui-config.json" : `${base}control-ui-config.json`;
|
||||
const controlUiBuildId = resolveControlUiBuildId();
|
||||
return {
|
||||
base,
|
||||
define: {
|
||||
OPENCLAW_CONTROL_UI_BUILD_ID: JSON.stringify(controlUiBuildId),
|
||||
},
|
||||
publicDir: path.resolve(here, "public"),
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
"ipaddr.js",
|
||||
"lit/directives/repeat.js",
|
||||
"markdown-it-task-lists",
|
||||
...commonJsOptimizeDeps,
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
alias: [
|
||||
{ find: "json5", replacement: json5EsmPath },
|
||||
...resolveExternalPackageAliasesForVite(),
|
||||
...resolveSourcePackageAliasesForVite(),
|
||||
...resolveTsconfigPathAliasesForVite(),
|
||||
],
|
||||
},
|
||||
build: {
|
||||
outDir,
|
||||
emptyOutDir: true,
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: controlUiManualChunk,
|
||||
},
|
||||
},
|
||||
// Keep CI/onboard logs clean; the app chunk is split into stable runtime buckets above.
|
||||
chunkSizeWarningLimit: 1024,
|
||||
},
|
||||
server: {
|
||||
host: true,
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
},
|
||||
plugins: [
|
||||
controlUiBrowserOnlySharedModuleAliases(),
|
||||
controlUiServiceWorkerBuildIdPlugin(controlUiBuildId),
|
||||
{
|
||||
name: "control-ui-dev-stubs",
|
||||
configureServer(server) {
|
||||
server.middlewares.use(bootstrapConfigPath, (_req, res) => {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
basePath: "/",
|
||||
assistantName: "",
|
||||
assistantAvatar: "",
|
||||
}),
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user