chore: stabilize Zhinian pilot delivery

This commit is contained in:
inman
2026-05-12 19:44:44 +08:00
parent 45389855e1
commit 20b5aff4ad
174 changed files with 41428 additions and 784 deletions

View File

@@ -15,6 +15,16 @@ function fsPath(filePath: string): string {
}
return `\\\\?\\${windowsPath}`;
}
function buildNodePathEnv(baseEnv: Record<string, string | undefined>, entries: string[]): string | undefined {
const existing = baseEnv.NODE_PATH?.split(path.delimiter).filter(Boolean) ?? [];
const candidates = entries
.map((entry) => entry.trim())
.filter(Boolean)
.filter((entry) => existsSync(fsPath(entry)));
const merged = [...new Set([...candidates, ...existing])];
return merged.length > 0 ? merged.join(path.delimiter) : undefined;
}
import { getAllSettings } from '../utils/store';
import { getApiKey, getDefaultProvider, getProvider } from '../utils/secure-storage';
import { getProviderEnvVar, getKeyableProviderTypes } from '../utils/provider-registry';
@@ -26,6 +36,7 @@ import { buildProxyEnv, resolveProxySettings } from '../utils/proxy';
import { syncProxyConfigToOpenClaw } from '../utils/openclaw-proxy';
import { logger } from '../utils/logger';
import { prependPathEntry } from '../utils/env-path';
import { buildDotnetEnv } from '../utils/dotnet-runtime';
import { copyPluginFromNodeModules, ensureCloudSyncPluginInstalled, fixupPluginManifest, cpSyncSafe } from '../utils/plugin-install';
import { stripSystemdSupervisorEnv } from './config-sync-env';
import { ensureYinianModelRuntimeConfigured } from '../utils/model-diagnostics';
@@ -528,6 +539,12 @@ export async function prepareGatewayLaunchContext(port: number): Promise<Gateway
const { skipChannels, channelStartupSummary } = await resolveChannelStartupPolicy();
const uvEnv = await getUvMirrorEnv();
const proxyEnv = buildProxyEnv(appSettings);
const emptyBundledSkillsDir = join(homedir(), '.openclaw', '.yinian-empty-bundled-skills');
try {
mkdirSync(emptyBundledSkillsDir, { recursive: true });
} catch {
// Best effort. If this fails OpenClaw will fall back to its own defaults.
}
const resolvedProxy = resolveProxySettings(appSettings);
const proxySummary = appSettings.proxyEnabled
? `http=${resolvedProxy.httpProxy || '-'}, https=${resolvedProxy.httpsProxy || '-'}, all=${resolvedProxy.allProxy || '-'}`
@@ -538,16 +555,28 @@ export async function prepareGatewayLaunchContext(port: number): Promise<Gateway
const baseEnvPatched = binPathExists
? prependPathEntry(baseEnvRecord, binPath).env
: baseEnvRecord;
const baseEnvWithDotnet = buildDotnetEnv(baseEnvPatched);
const nodePath = buildNodePathEnv(baseEnvPatched, [
join(process.cwd(), 'node_modules'),
join(app.getAppPath(), 'node_modules'),
join(openclawDir, 'node_modules'),
app.isPackaged ? join(process.resourcesPath, 'openclaw', 'node_modules') : '',
]);
const forkEnv: Record<string, string | undefined> = {
...stripSystemdSupervisorEnv(baseEnvPatched),
...stripSystemdSupervisorEnv(baseEnvWithDotnet),
...providerEnv,
...uvEnv,
...proxyEnv,
...bundledPackageManagerEnv,
...(nodePath ? { NODE_PATH: nodePath } : {}),
OPENCLAW_GATEWAY_TOKEN: appSettings.gatewayToken,
OPENCLAW_SKIP_CHANNELS: skipChannels ? '1' : '',
CLAWDBOT_SKIP_CHANNELS: skipChannels ? '1' : '',
OPENCLAW_NO_RESPAWN: '1',
OPENCLAW_DISABLE_AGENTS_SKILLS: '1',
OPENCLAW_DISABLE_MAIN_SESSION_RESTART_RECOVERY: '1',
YINIAN_OPENCLAW_STUCK_ACTIVE_ABORT_MS: process.env.YINIAN_OPENCLAW_STUCK_ACTIVE_ABORT_MS || String(15 * 60_000),
OPENCLAW_BUNDLED_SKILLS_DIR: emptyBundledSkillsDir,
};
// Ensure extension-specific packages (e.g. grammy from the telegram