当时让它建立的恢复的脚本,我点击恢复后还是不行…下面是这个脚本改的内容:
$ErrorActionPreference = “Stop”
$liveRoot = “C:\Users\admin.codex”
$configPath = Join-Path $liveRoot “config.toml”
$dbPath = Join-Path $liveRoot “state_5.sqlite”
$sqlite = “D:\Miniconda3\Library\bin\sqlite3.exe”
$backupRoot = Join-Path $PSScriptRoot “thread_namespace_sync_history”
if (-not (Test-Path -LiteralPath $configPath)) {
throw “Missing config.toml: $configPath”
}
if (-not (Test-Path -LiteralPath $dbPath)) {
throw “Missing state_5.sqlite: $dbPath”
}
if (-not (Test-Path -LiteralPath $sqlite)) {
throw “sqlite3.exe not found: $sqlite”
}
running = Get-Process | Where-Object { .ProcessName -like "codex" -or $.ProcessName -like “OpenAI.Codex” }
if ($running) {
throw “Codex Desktop is still running. Fully close Codex before syncing the left sidebar thread namespace.”
}
$configText = Get-Content -LiteralPath $configPath -Raw
$providerMatch = [regex]::Match($configText, ‘(?m)^model_provider\s*=\s*“([^”]+)"’)
$targetProvider = if ($providerMatch.Success) { $providerMatch.Groups[1].Value.Trim() } else { “openai” }
$sharedProviders = @(“sub2”, “openai”, “OpenAI”)
if ($sharedProviders -notcontains $targetProvider) {
$sharedProviders += $targetProvider
}
New-Item -ItemType Directory -Path $backupRoot -Force | Out-Null
$ts = Get-Date -Format “yyyyMMdd-HHmmss”
$runRoot = Join-Path $backupRoot (“sync-” + $ts)
New-Item -ItemType Directory -Path $runRoot -Force | Out-Null
foreach ($name in @(“config.toml”, “state_5.sqlite”, “state_5.sqlite-shm”, “state_5.sqlite-wal”)) {
$src = Join-Path $liveRoot $name
if (Test-Path -LiteralPath $src) {
Copy-Item -LiteralPath $src -Destination (Join-Path $runRoot $name) -Force
}
}
$providersSql = (sharedProviders | ForEach-Object { "'" + _.Replace(“'”, “‘’”) + “'” }) -join “, "
$escapedTargetProvider = $targetProvider.Replace(”‘", "’'“)
$updateSql = @”
BEGIN IMMEDIATE;
UPDATE threads
SET model_provider = ‘$escapedTargetProvider’
WHERE model_provider IN ($providersSql);
COMMIT;
"@
& $sqlite $dbPath $updateSql | Out-Null
$counts = & $sqlite -header -column $dbPath “select model_provider, count(*) cnt from threads group by model_provider order by cnt desc;”
Set-Content -LiteralPath (Join-Path $runRoot “sync.meta.txt”) -Value @(
“timestamp=$ts”,
“target_provider=$targetProvider”,
“shared_providers=$($sharedProviders -join ‘,’)”
) -Encoding Ascii
Write-Host “Left sidebar thread namespace sync completed.”
Write-Host “Target provider:” $targetProvider
Write-Host “Backup folder:” $runRoot
Write-Host “”
Write-Host $counts