SesioWorker.psm1

. $PSScriptRoot\Functions\Sesio.ps1

# Initialize .env file during module import
$sesioFolder = Join-Path $env:USERPROFILE ".sesio"
$envFile = Join-Path $sesioFolder ".env"

if (-not (Test-Path $sesioFolder)) {
    New-Item -ItemType Directory -Path $sesioFolder -Force | Out-Null
}

if (-not (Test-Path $envFile)) {
    $initialContent = @"
url=
environment=development
api_version=2023-07-31
model_id=prebuilt-layout
AZURE_SUBSCRIPTION_ID=
AZURE_TENANT_ID=
AZURE_RESOURCE_GROUP=
AZURE_LOCATION=
pwsh-key=
"@

    $initialContent | Set-Content $envFile -Force
    Write-Host "Created initial .env file at: $envFile"
}

# Copy the template.aarc file to the sesio folder
Copy-Item -Path "$PSScriptRoot\template.aarc" -Destination "$sesioFolder\template.aarc" -Force