




















@@ -9,6 +9,84 @@ interface PluginIsolationOptions {
99nodeCommand?: string;
1010}
111112+export function posixCodexPlatformPackageRepairFunction(): string {
13+return `repair_missing_codex_platform_package() {
14+ output_file="$1"
15+ grep -F 'Missing optional dependency @openai/codex-' "$output_file" >/dev/null 2>&1 || return 1
16+ state_home="\${OPENCLAW_PARALLELS_HOME:-\${HOME:-}}"
17+ codex_manifest=""
18+ for candidate in "$state_home"/.openclaw/npm/projects/*/node_modules/@openclaw/codex/package.json; do
19+ [ -f "$candidate" ] || continue
20+ codex_manifest="$candidate"
21+ break
22+ done
23+ if [ -z "$codex_manifest" ]; then
24+ echo "codex-platform-repair: managed Codex project not found" >&2
25+ return 1
26+ fi
27+ project_root="\${codex_manifest%/node_modules/@openclaw/codex/package.json}"
28+ cache_dir="$(mktemp -d "\${TMPDIR:-/tmp}/openclaw-npm-cache.XXXXXX")"
29+ echo "codex-platform-repair: retrying managed npm install once with a fresh cache" >&2
30+ repair_rc=0
31+ (
32+ cd "$project_root"
33+ NPM_CONFIG_CACHE="$cache_dir" npm_config_cache="$cache_dir" npm install --omit=dev --omit=peer --legacy-peer-deps --ignore-scripts --no-audit --no-fund
34+ ) || repair_rc=$?
35+ rm -rf "$cache_dir"
36+ if [ "$repair_rc" -ne 0 ]; then
37+ echo "codex-platform-repair: npm install failed with exit code $repair_rc" >&2
38+ return "$repair_rc"
39+ fi
40+ echo "codex-platform-repair: managed npm install completed" >&2
41+}`;
42+}
43+44+export function windowsCodexPlatformPackageRepairFunction(): string {
45+return String.raw`function Repair-MissingCodexPlatformPackage {
46+ param([object[]] $Output)
47+ $outputText = $Output | Out-String
48+ if ($outputText -notmatch [regex]::Escape('Missing optional dependency @openai/codex-')) {
49+ return $false
50+ }
51+ $projectsRoot = Join-Path $env:USERPROFILE '.openclaw\npm\projects'
52+ $codexManifest = Get-ChildItem -Path $projectsRoot -Filter package.json -File -Recurse -ErrorAction SilentlyContinue |
53+ Where-Object { $_.FullName -match 'node_modules[\\/]@openclaw[\\/]codex[\\/]package\.json$' } |
54+ Select-Object -First 1
55+ if (-not $codexManifest) {
56+ Write-Warning 'codex-platform-repair: managed Codex project not found'
57+ return $false
58+ }
59+ $projectRoot = $codexManifest.Directory.Parent.Parent.Parent.FullName
60+ $cacheDir = Join-Path ([System.IO.Path]::GetTempPath()) ('openclaw-npm-cache-' + [guid]::NewGuid().ToString('N'))
61+ $oldUpperCache = [Environment]::GetEnvironmentVariable('NPM_CONFIG_CACHE', 'Process')
62+ $oldLowerCache = [Environment]::GetEnvironmentVariable('npm_config_cache', 'Process')
63+ $pushedLocation = $false
64+ $repairExit = 1
65+ try {
66+ New-Item -ItemType Directory -Path $cacheDir -Force | Out-Null
67+ [Environment]::SetEnvironmentVariable('NPM_CONFIG_CACHE', $cacheDir, 'Process')
68+ [Environment]::SetEnvironmentVariable('npm_config_cache', $cacheDir, 'Process')
69+ Push-Location $projectRoot
70+ $pushedLocation = $true
71+ Write-Host 'codex-platform-repair: retrying managed npm install once with a fresh cache'
72+ $repairOutput = & npm.cmd install --omit=dev --omit=peer --legacy-peer-deps --ignore-scripts --no-audit --no-fund 2>&1
73+ $repairExit = $LASTEXITCODE
74+ if ($null -ne $repairOutput) { $repairOutput | ForEach-Object { Write-Host $_ } }
75+ } finally {
76+ if ($pushedLocation) { Pop-Location }
77+ [Environment]::SetEnvironmentVariable('NPM_CONFIG_CACHE', $oldUpperCache, 'Process')
78+ [Environment]::SetEnvironmentVariable('npm_config_cache', $oldLowerCache, 'Process')
79+ Remove-Item $cacheDir -Force -Recurse -ErrorAction SilentlyContinue
80+ }
81+ if ($repairExit -ne 0) {
82+ Write-Warning "codex-platform-repair: npm install failed with exit code $repairExit"
83+ return $false
84+ }
85+ Write-Host 'codex-platform-repair: managed npm install completed'
86+ return $true
87+}`;
88+}
89+1290export function providerOnlyPluginId(modelId: string, fallbackPluginId: string): string {
1391return providerIdFromModelId(modelId) || fallbackPluginId;
1492}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。