- MCP Server with audio fallback, sample management - Song generator with bus routing - Reference listener and audio resampler - Vector-based sample search - Master chain with limiter and calibration - Fix: Audio fallback now works without M4L - Fix: Full song detection in sample loader Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
142 lines
5.0 KiB
PowerShell
142 lines
5.0 KiB
PowerShell
param(
|
|
[string]$QueueFile = (Join-Path $PSScriptRoot "task_queue.json"),
|
|
[string]$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path,
|
|
[string]$GlmModel = "glm-5",
|
|
[string]$GlmBaseUrl = $(if ($env:ANTHROPIC_BASE_URL) { $env:ANTHROPIC_BASE_URL } else { "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic" }),
|
|
[string]$GlmAuthToken = $env:ANTHROPIC_AUTH_TOKEN,
|
|
[string]$GlmAgentsFile = (Join-Path $PSScriptRoot "glm_agents.team.json"),
|
|
[string]$CodexModel = "",
|
|
[string]$TelegramBotToken = $env:TELEGRAM_BOT_TOKEN,
|
|
[string]$TelegramChatId = $env:TELEGRAM_CHAT_ID,
|
|
[string]$TelegramConfigPath = (Join-Path $PSScriptRoot "telegram.local.json"),
|
|
[int]$PollSeconds = 30,
|
|
[switch]$Watch,
|
|
[switch]$ContinueOnError
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Resolve-RepoPath([string]$BasePath, [string]$TargetPath) {
|
|
if ([System.IO.Path]::IsPathRooted($TargetPath)) {
|
|
return [System.IO.Path]::GetFullPath($TargetPath)
|
|
}
|
|
return [System.IO.Path]::GetFullPath((Join-Path $BasePath $TargetPath))
|
|
}
|
|
|
|
function Load-Queue([string]$PathValue) {
|
|
return Get-Content -LiteralPath $PathValue -Raw | ConvertFrom-Json -Depth 20
|
|
}
|
|
|
|
function Save-Queue([string]$PathValue, $QueueObject) {
|
|
$QueueObject | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath $PathValue -Encoding UTF8
|
|
}
|
|
|
|
function Resolve-TelegramSettings() {
|
|
if (([string]::IsNullOrWhiteSpace($TelegramBotToken) -or [string]::IsNullOrWhiteSpace($TelegramChatId)) -and (Test-Path -LiteralPath $TelegramConfigPath)) {
|
|
$config = Get-Content -LiteralPath $TelegramConfigPath -Raw | ConvertFrom-Json
|
|
if ([string]::IsNullOrWhiteSpace($TelegramBotToken)) {
|
|
$script:TelegramBotToken = $config.bot_token
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($TelegramChatId)) {
|
|
$script:TelegramChatId = $config.chat_id
|
|
}
|
|
}
|
|
}
|
|
|
|
function Send-QueueNotification([string]$Message) {
|
|
Resolve-TelegramSettings
|
|
if ([string]::IsNullOrWhiteSpace($TelegramBotToken) -or [string]::IsNullOrWhiteSpace($TelegramChatId)) {
|
|
return
|
|
}
|
|
|
|
$notifier = Join-Path $PSScriptRoot "send_telegram_notification.ps1"
|
|
try {
|
|
& $notifier -Message $Message -BotToken $TelegramBotToken -ChatId $TelegramChatId -ConfigPath $TelegramConfigPath
|
|
}
|
|
catch {
|
|
Write-Warning ("Telegram notification failed: " + $_.Exception.Message)
|
|
}
|
|
}
|
|
|
|
function Find-NextTask($QueueObject) {
|
|
foreach ($task in $QueueObject.tasks) {
|
|
if ($task.enabled -and $task.status -eq "pending") {
|
|
return $task
|
|
}
|
|
}
|
|
return $null
|
|
}
|
|
|
|
$projectPath = (Resolve-Path -LiteralPath $ProjectRoot).Path
|
|
$queuePath = Resolve-RepoPath $projectPath $QueueFile
|
|
$loopRunner = Join-Path $PSScriptRoot "run_glm_codex_loop.ps1"
|
|
$historyDir = Join-Path $projectPath "automation\\runs\\queue"
|
|
New-Item -ItemType Directory -Force -Path $historyDir | Out-Null
|
|
|
|
Send-QueueNotification("AbletonMCP_AI queue runner started on $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'). Watching=$Watch ContinueOnError=$ContinueOnError")
|
|
|
|
do {
|
|
$queue = Load-Queue $queuePath
|
|
$task = Find-NextTask $queue
|
|
|
|
if ($null -eq $task) {
|
|
if ($Watch) {
|
|
Start-Sleep -Seconds $PollSeconds
|
|
continue
|
|
}
|
|
break
|
|
}
|
|
|
|
$taskPath = Resolve-RepoPath $projectPath $task.task_file
|
|
$reportPath = Resolve-RepoPath $projectPath $task.report_file
|
|
|
|
$task.status = "running"
|
|
$task.started_at = (Get-Date).ToString("s")
|
|
Save-Queue $queuePath $queue
|
|
Send-QueueNotification("Queue task started: [$($task.id)] $($task.title)")
|
|
|
|
try {
|
|
& $loopRunner `
|
|
-TaskFile $taskPath `
|
|
-ReportFile $reportPath `
|
|
-ProjectRoot $projectPath `
|
|
-GlmModel $GlmModel `
|
|
-GlmBaseUrl $GlmBaseUrl `
|
|
-GlmAuthToken $GlmAuthToken `
|
|
-GlmAgentsFile $GlmAgentsFile `
|
|
-CodexModel $CodexModel `
|
|
-TelegramBotToken $TelegramBotToken `
|
|
-TelegramChatId $TelegramChatId `
|
|
-TelegramConfigPath $TelegramConfigPath
|
|
|
|
$queue = Load-Queue $queuePath
|
|
foreach ($item in $queue.tasks) {
|
|
if ($item.id -eq $task.id) {
|
|
$item.status = "completed"
|
|
$item.completed_at = (Get-Date).ToString("s")
|
|
break
|
|
}
|
|
}
|
|
Save-Queue $queuePath $queue
|
|
Send-QueueNotification("Queue task completed: [$($task.id)] $($task.title)")
|
|
}
|
|
catch {
|
|
$queue = Load-Queue $queuePath
|
|
foreach ($item in $queue.tasks) {
|
|
if ($item.id -eq $task.id) {
|
|
$item.status = "failed"
|
|
$item.failed_at = (Get-Date).ToString("s")
|
|
$item.error = $_.Exception.Message
|
|
break
|
|
}
|
|
}
|
|
Save-Queue $queuePath $queue
|
|
Send-QueueNotification("Queue task failed: [$($task.id)] $($task.title)`n$($_.Exception.Message)")
|
|
|
|
if (-not $ContinueOnError) {
|
|
throw
|
|
}
|
|
}
|
|
}
|
|
while ($true)
|