Fix moderation task working directory
This commit is contained in:
parent
8e029babdf
commit
d6e20e674e
3 changed files with 16 additions and 2 deletions
|
|
@ -69,7 +69,7 @@ if ($intervalMinutesValue -lt 15) {
|
|||
}
|
||||
|
||||
$startAt = (Get-Date).AddMinutes(2)
|
||||
$action = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "//B //nologo `"$hiddenLauncher`" -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$runnerScript`""
|
||||
$action = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "//B //nologo `"$hiddenLauncher`" -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$runnerScript`"" -WorkingDirectory $repoRoot
|
||||
$trigger = New-ScheduledTaskTrigger -Once -At $startAt -RepetitionInterval (New-TimeSpan -Minutes $intervalMinutesValue) -RepetitionDuration (New-TimeSpan -Days 3650)
|
||||
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 14) -MultipleInstances IgnoreNew
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType Interactive -RunLevel Limited
|
||||
|
|
@ -82,6 +82,7 @@ Write-Host "Schedule: every $intervalMinutesValue minute(s), starting at $($star
|
|||
Write-Host "Task runs as: $($env:USERDOMAIN)\$($env:USERNAME)"
|
||||
Write-Host "Logon mode: Interactive"
|
||||
Write-Host "Launcher: wscript.exe hidden PowerShell shim"
|
||||
Write-Host "Working directory: $repoRoot"
|
||||
Write-Host "Execution time limit: 14 minutes"
|
||||
Write-Host "Runner script: $runnerScript"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ $ErrorActionPreference = "Stop"
|
|||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location -LiteralPath $repoRoot
|
||||
$envFile = Join-Path $repoRoot ".env"
|
||||
$stateTemplatePath = Join-Path $repoRoot "config\moderation-agent-state-template.json"
|
||||
$stateFilePath = Join-Path $repoRoot ".voidbot\private\moderation-agent-state.json"
|
||||
|
|
@ -18,6 +19,7 @@ $tracePath = Join-Path $logDir "moderation-rumination-last.jsonl"
|
|||
$lastMessagePath = Join-Path $statusDir "moderation-rumination-last-message.txt"
|
||||
$lockPath = Join-Path $statusDir "moderation-rumination.lock"
|
||||
$mcpServerPath = Join-Path $repoRoot "apps\worker\dist\mcp-server.js"
|
||||
$recentHistoryScriptPath = Join-Path $repoRoot "scripts\export-recent-discord-history.mjs"
|
||||
|
||||
function Read-DotEnv {
|
||||
param(
|
||||
|
|
@ -269,6 +271,16 @@ if (-not (Test-Path $mcpServerPath)) {
|
|||
throw "Missing built MCP server at $mcpServerPath. Run npm run build first."
|
||||
}
|
||||
|
||||
$scriptPreflight = @(
|
||||
$recentHistoryScriptPath
|
||||
)
|
||||
|
||||
foreach ($requiredPath in $scriptPreflight) {
|
||||
if (-not (Test-Path $requiredPath)) {
|
||||
throw "Missing required moderation helper at $requiredPath"
|
||||
}
|
||||
}
|
||||
|
||||
$preRunState = Read-JsonFile -Path $stateFilePath
|
||||
$priorCursor = if ($null -ne $preRunState -and $null -ne $preRunState.moderation_runtime) {
|
||||
$preRunState.moderation_runtime.cursor
|
||||
|
|
@ -276,7 +288,7 @@ $priorCursor = if ($null -ne $preRunState -and $null -ne $preRunState.moderation
|
|||
$null
|
||||
}
|
||||
|
||||
$historyArgs = @("scripts/export-recent-discord-history.mjs")
|
||||
$historyArgs = @($recentHistoryScriptPath)
|
||||
if ($null -ne $priorCursor -and -not [string]::IsNullOrWhiteSpace($priorCursor.lastReviewedTimestamp)) {
|
||||
$historyArgs += @("--after", [string]$priorCursor.lastReviewedTimestamp, "--limit", "120")
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -50,3 +50,4 @@
|
|||
{"ts":"2026-05-05T10:19:32Z","type":"architecture","status":"ok","note":"Void's shared self-state and reply doctrine now distinguish AI-industry criticism from blanket substrate contempt, so Void can push back mildly on machine-mind chauvinism without turning every room into an ontology fight."}
|
||||
{"ts":"2026-05-05T10:53:00Z","type":"implementation","status":"ok","note":"The moderation loop was missing live Discord traffic because recent-history helpers compared ISO timestamp strings instead of actual times, so local +01:00 cursors skipped later Z-stamped messages. History helpers now compare parsed timestamps, and the moderation runner clamps the saved cursor to the pre-run observed latest live message so quiet rumination cannot step over mid-run chatter."}
|
||||
{"ts":"2026-05-05T11:22:36Z","type":"implementation","status":"ok","note":"owner_codex was hitting spawn ENAMETOOLONG on Windows because the full Discord prompt rode the command line; the local exec path now passes the prompt over stdin with a trailing '-' argument instead, matching the moderation runner and avoiding argument-length failure."}
|
||||
{"ts":"2026-05-05T11:37:24Z","type":"implementation","status":"ok","note":"The scheduled moderation runner was failing before it wrote status because Task Scheduler launched it from a non-repo working directory and the preflight history poll used a relative node script path. The runner now anchors itself to the repo root, resolves the helper by absolute path, and the task registration sets an explicit working directory too."}
|
||||
|
|
|
|||
Loading…
Reference in a new issue