mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 04:41:40 +00:00
fix(ui): fix web UI after tsdown migration and typing changes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import path from "node:path";
|
||||
import type { CanvasHostServer } from "../canvas-host/server.js";
|
||||
import type { PluginServicesHandle } from "../plugins/services.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import type { ControlUiRootState } from "./control-ui.js";
|
||||
import type { startBrowserControlServerIfEnabled } from "./server-browser.js";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import { registerSkillsChangeListener } from "../agents/skills/refresh.js";
|
||||
@@ -18,6 +20,11 @@ import {
|
||||
} from "../config/config.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { clearAgentRunContext, onAgentEvent } from "../infra/agent-events.js";
|
||||
import {
|
||||
ensureControlUiAssetsBuilt,
|
||||
resolveControlUiRootOverrideSync,
|
||||
resolveControlUiRootSync,
|
||||
} from "../infra/control-ui-assets.js";
|
||||
import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js";
|
||||
import { logAcceptedEnvOption } from "../infra/env.js";
|
||||
import { createExecApprovalForwarder } from "../infra/exec-approval-forwarder.js";
|
||||
@@ -87,6 +94,7 @@ const logReload = log.child("reload");
|
||||
const logHooks = log.child("hooks");
|
||||
const logPlugins = log.child("plugins");
|
||||
const logWsControl = log.child("ws");
|
||||
const gatewayRuntime = runtimeForLogger(log);
|
||||
const canvasRuntime = runtimeForLogger(logCanvas);
|
||||
|
||||
export type GatewayServer = {
|
||||
@@ -253,6 +261,7 @@ export async function startGatewayServer(
|
||||
openResponsesEnabled,
|
||||
openResponsesConfig,
|
||||
controlUiBasePath,
|
||||
controlUiRoot: controlUiRootOverride,
|
||||
resolvedAuth,
|
||||
tailscaleConfig,
|
||||
tailscaleMode,
|
||||
@@ -260,6 +269,38 @@ export async function startGatewayServer(
|
||||
let hooksConfig = runtimeConfig.hooksConfig;
|
||||
const canvasHostEnabled = runtimeConfig.canvasHostEnabled;
|
||||
|
||||
let controlUiRootState: ControlUiRootState | undefined;
|
||||
if (controlUiRootOverride) {
|
||||
const resolvedOverride = resolveControlUiRootOverrideSync(controlUiRootOverride);
|
||||
const resolvedOverridePath = path.resolve(controlUiRootOverride);
|
||||
controlUiRootState = resolvedOverride
|
||||
? { kind: "resolved", path: resolvedOverride }
|
||||
: { kind: "invalid", path: resolvedOverridePath };
|
||||
if (!resolvedOverride) {
|
||||
log.warn(`gateway: controlUi.root not found at ${resolvedOverridePath}`);
|
||||
}
|
||||
} else if (controlUiEnabled) {
|
||||
let resolvedRoot = resolveControlUiRootSync({
|
||||
moduleUrl: import.meta.url,
|
||||
argv1: process.argv[1],
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
if (!resolvedRoot) {
|
||||
const ensureResult = await ensureControlUiAssetsBuilt(gatewayRuntime);
|
||||
if (!ensureResult.ok && ensureResult.message) {
|
||||
log.warn(`gateway: ${ensureResult.message}`);
|
||||
}
|
||||
resolvedRoot = resolveControlUiRootSync({
|
||||
moduleUrl: import.meta.url,
|
||||
argv1: process.argv[1],
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
}
|
||||
controlUiRootState = resolvedRoot
|
||||
? { kind: "resolved", path: resolvedRoot }
|
||||
: { kind: "missing" };
|
||||
}
|
||||
|
||||
const wizardRunner = opts.wizardRunner ?? runOnboardingWizard;
|
||||
const { wizardSessions, findRunningWizard, purgeWizardSession } = createWizardSessionTracker();
|
||||
|
||||
@@ -291,6 +332,7 @@ export async function startGatewayServer(
|
||||
port,
|
||||
controlUiEnabled,
|
||||
controlUiBasePath,
|
||||
controlUiRoot: controlUiRootState,
|
||||
openAiChatCompletionsEnabled,
|
||||
openResponsesEnabled,
|
||||
openResponsesConfig,
|
||||
|
||||
Reference in New Issue
Block a user