added
This commit is contained in:
commit
8313c5c6b5
84 files changed
+4337
No files matched your search
@@ -0,0 +1,38 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$FixedSender,
|
||||
[string]$DatabasePath,
|
||||
[switch]$EnablePostmarkSend,
|
||||
[switch]$ConfirmExternalSend,
|
||||
[string]$SupervisedTransactionId,
|
||||
[string]$SupervisedRequester,
|
||||
[string]$SupervisedOwner
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($EnablePostmarkSend -and -not $ConfirmExternalSend) { throw "External sending requires -ConfirmExternalSend." }
|
||||
if ($EnablePostmarkSend -and [string]::IsNullOrWhiteSpace($env:POSTMARK_SERVER_TOKEN)) { throw "Set POSTMARK_SERVER_TOKEN using your approved secret manager." }
|
||||
$priorPostmarkEnable = $env:SCHEDULING_POSTMARK_ENABLE
|
||||
$priorSupervisedScope = $env:SCHEDULING_SUPERVISED_SEND_SCOPE
|
||||
Remove-Item Env:\SCHEDULING_POSTMARK_ENABLE,Env:\SCHEDULING_SUPERVISED_SEND_SCOPE -ErrorAction SilentlyContinue
|
||||
if ($SupervisedTransactionId -or $SupervisedRequester -or $SupervisedOwner) {
|
||||
if (-not $EnablePostmarkSend -or -not $SupervisedTransactionId -or -not $SupervisedRequester -or -not $SupervisedOwner) { throw "Supervised send requires explicit enablement, transaction, requester, and owner." }
|
||||
$env:SCHEDULING_SUPERVISED_SEND_SCOPE = @{ transaction_id=$SupervisedTransactionId; requester=$SupervisedRequester; owner=$SupervisedOwner } | ConvertTo-Json -Compress
|
||||
}
|
||||
$scriptRoot = Split-Path -Parent $PSCommandPath
|
||||
$projectRoot = (Resolve-Path (Join-Path $scriptRoot "..")).Path
|
||||
if (-not $DatabasePath) { $DatabasePath = Join-Path $projectRoot "state\scheduling-ledger.sqlite3" }
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
$env:SCHEDULING_DB = $DatabasePath
|
||||
$env:SCHEDULING_MCP_ENABLE = "1"
|
||||
$env:SCHEDULING_FIXED_SENDER = $FixedSender
|
||||
if ($EnablePostmarkSend) { $env:SCHEDULING_POSTMARK_ENABLE = "1" }
|
||||
try { & $pythonCommand.Source -m scheduling_core.mcp_stdio } finally {
|
||||
if ($null -ne $priorPostmarkEnable) { $env:SCHEDULING_POSTMARK_ENABLE = $priorPostmarkEnable }
|
||||
else { Remove-Item Env:\SCHEDULING_POSTMARK_ENABLE -ErrorAction SilentlyContinue }
|
||||
if ($null -ne $priorSupervisedScope) { $env:SCHEDULING_SUPERVISED_SEND_SCOPE = $priorSupervisedScope }
|
||||
else { Remove-Item Env:\SCHEDULING_SUPERVISED_SEND_SCOPE -ErrorAction SilentlyContinue }
|
||||
Remove-Item Env:\SCHEDULING_DB,Env:\SCHEDULING_MCP_ENABLE,Env:\SCHEDULING_FIXED_SENDER,Env:\PYTHONPATH -ErrorAction SilentlyContinue
|
||||
}
|
||||
Reference in new issue
Block a user