常规归档
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$TaskId,
|
||||
|
||||
[string]$Prompt = "",
|
||||
|
||||
[string]$NotesDir = "Notes",
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$CodexReviewCommand,
|
||||
|
||||
[string]$CondaExe = "",
|
||||
[string]$CondaEnv = "langgraph",
|
||||
[string]$CodexHome = "",
|
||||
[int]$Timeout = 600,
|
||||
[string]$ThreadId = "",
|
||||
[string]$Resume = ""
|
||||
)
|
||||
|
||||
function Resolve-CondaExe {
|
||||
param([string]$ExplicitPath)
|
||||
|
||||
if ($ExplicitPath) {
|
||||
if (-not (Test-Path -LiteralPath $ExplicitPath)) {
|
||||
throw "Conda executable does not exist: $ExplicitPath"
|
||||
}
|
||||
return (Resolve-Path -LiteralPath $ExplicitPath).Path
|
||||
}
|
||||
|
||||
if ($env:CONDA_EXE -and (Test-Path -LiteralPath $env:CONDA_EXE)) {
|
||||
return (Resolve-Path -LiteralPath $env:CONDA_EXE).Path
|
||||
}
|
||||
|
||||
$CondaCommand = Get-Command conda -ErrorAction SilentlyContinue
|
||||
if ($CondaCommand -and $CondaCommand.Source) {
|
||||
return $CondaCommand.Source
|
||||
}
|
||||
|
||||
$UserProfile = [Environment]::GetFolderPath("UserProfile")
|
||||
if ($UserProfile) {
|
||||
$UserFallback = Join-Path $UserProfile "miniconda3\Scripts\conda.exe"
|
||||
if (Test-Path -LiteralPath $UserFallback) {
|
||||
return (Resolve-Path -LiteralPath $UserFallback).Path
|
||||
}
|
||||
}
|
||||
|
||||
$LegacyFallback = "C:\Users\bowei\miniconda3\Scripts\conda.exe"
|
||||
if (Test-Path -LiteralPath $LegacyFallback) {
|
||||
return $LegacyFallback
|
||||
}
|
||||
|
||||
throw "Unable to locate conda. Set -CondaExe or CONDA_EXE, or ensure conda is on PATH."
|
||||
}
|
||||
|
||||
function Resolve-CodexHome {
|
||||
param([string]$ExplicitPath)
|
||||
|
||||
if ($ExplicitPath) {
|
||||
return $ExplicitPath
|
||||
}
|
||||
|
||||
if ($env:CODEX_HOME) {
|
||||
return $env:CODEX_HOME
|
||||
}
|
||||
|
||||
$UserProfile = [Environment]::GetFolderPath("UserProfile")
|
||||
if (-not $UserProfile) {
|
||||
throw "Unable to determine user profile for CODEX_HOME. Set -CodexHome or CODEX_HOME."
|
||||
}
|
||||
|
||||
return (Join-Path $UserProfile ".codex")
|
||||
}
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$LaunchWorkDir = (Get-Location).Path
|
||||
Push-Location $PSScriptRoot
|
||||
# Ensure conda run child processes can encode Unicode (Chinese, etc.) output
|
||||
$env:PYTHONIOENCODING = "utf-8"
|
||||
try {
|
||||
$env:CODEX_HOME = Resolve-CodexHome -ExplicitPath $CodexHome
|
||||
|
||||
$Conda = Resolve-CondaExe -ExplicitPath $CondaExe
|
||||
$ArgsList = @(
|
||||
"run", "-n", $CondaEnv, "python", "run_workflow.py",
|
||||
"--task-id", $TaskId,
|
||||
"--notes-dir", $NotesDir,
|
||||
"--work-dir", $LaunchWorkDir,
|
||||
"--timeout", "$Timeout"
|
||||
)
|
||||
|
||||
if ($Prompt) { $ArgsList += @("--prompt", $Prompt) }
|
||||
$CodexReviewCommandB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($CodexReviewCommand))
|
||||
$ArgsList += @("--codex-review-command-b64", $CodexReviewCommandB64)
|
||||
if ($ThreadId) { $ArgsList += @("--thread-id", $ThreadId) }
|
||||
if ($Resume) {
|
||||
$ResumeB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($Resume))
|
||||
$ArgsList += @("--resume-b64", $ResumeB64)
|
||||
}
|
||||
|
||||
& $Conda @ArgsList
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user