- Added a new script `bundle-openclaw.mjs` to bundle OpenClaw runtime dependencies. - Updated `after-pack.cjs` to copy bundled OpenClaw runtime and its node_modules. - Improved cleanup of unnecessary development files in node_modules. - Adjusted paths for resources in the packaging process. style: update loading indicator styles in ChatHistoryPanel - Changed the border radius and padding for the loading indicator in ChatHistoryPanel. fix: improve ProvidersSection to handle provider account syncing - Added logic to sync model configuration to provider accounts. - Introduced error handling and loading states during the sync process. - Enhanced vendor resolution and account management logic. fix: fallback session handling in chat store - Implemented fallback session logic in loadSessions to ensure a valid session is always available on error.
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { readFile, writeFile } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
import { ensureDir, getOpenClawConfigDir } from './paths';
|
|
|
|
type OpenClawConfig = Record<string, unknown>;
|
|
|
|
const OPENCLAW_CONFIG_FILE_NAME = 'openclaw.json';
|
|
|
|
export function getOpenClawConfigPath(): string {
|
|
return join(getOpenClawConfigDir(), OPENCLAW_CONFIG_FILE_NAME);
|
|
}
|
|
|
|
async function readOpenClawConfig(): Promise<OpenClawConfig> {
|
|
const configPath = getOpenClawConfigPath();
|
|
|
|
try {
|
|
const raw = await readFile(configPath, 'utf-8');
|
|
return JSON.parse(raw) as OpenClawConfig;
|
|
} catch {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
async function writeOpenClawConfig(config: OpenClawConfig): Promise<void> {
|
|
ensureDir(getOpenClawConfigDir());
|
|
await writeFile(getOpenClawConfigPath(), JSON.stringify(config, null, 2), 'utf-8');
|
|
}
|
|
|
|
export async function syncBrowserConfigToOpenClaw(): Promise<void> {
|
|
const config = await readOpenClawConfig();
|
|
const browser = (
|
|
config.browser && typeof config.browser === 'object'
|
|
? { ...(config.browser as Record<string, unknown>) }
|
|
: {}
|
|
) as Record<string, unknown>;
|
|
|
|
let changed = false;
|
|
|
|
if (browser.enabled === undefined) {
|
|
browser.enabled = true;
|
|
changed = true;
|
|
}
|
|
|
|
if (browser.defaultProfile === undefined) {
|
|
browser.defaultProfile = 'openclaw';
|
|
changed = true;
|
|
}
|
|
|
|
if (browser.ssrfPolicy == null) {
|
|
browser.ssrfPolicy = { dangerouslyAllowPrivateNetwork: true };
|
|
changed = true;
|
|
} else if (
|
|
typeof browser.ssrfPolicy === 'object'
|
|
&& (browser.ssrfPolicy as Record<string, unknown>).dangerouslyAllowPrivateNetwork === undefined
|
|
) {
|
|
(browser.ssrfPolicy as Record<string, unknown>).dangerouslyAllowPrivateNetwork = true;
|
|
changed = true;
|
|
}
|
|
|
|
if (!changed) {
|
|
return;
|
|
}
|
|
|
|
config.browser = browser;
|
|
await writeOpenClawConfig(config);
|
|
}
|