<?xml version="1.0" encoding="UTF-16"?>
<!--
  pios Task Scheduler task — Windows auto-start at logon.

  The easy way (no admin needed, generates everything for you):
    npm i -g pios
    pios server install --port 8787 --cwd C:\path\to\project
    pios server status | restart | stop | uninstall

  Manual install with this template (edit the paths below first):
    schtasks /Create /TN "pios" /XML pios-task.xml /F
    schtasks /Run /TN "pios"

  Notes:
    - The task runs the PowerShell launcher the CLI generates at
      %APPDATA%\pios\pios.ps1 with -WindowStyle Hidden, so the
      server runs with no black console window (nothing to accidentally
      close/kill). The ps1 sets PORT/PI_WEB_CWD, cd's to the workspace,
      launches node, and appends output to %USERPROFILE%\pios.log.
      Preview both generated files with: pios server install --print
    - Save this file as UTF-16 LE (schtasks requires it; the CLI does this
      automatically when it writes the task XML).
    - LogonTrigger = starts when you log in, same as a launchd user agent.
      For boot-start without login, configure a dedicated system service.
-->
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Description>pios — web chat for the pi coding agent (auto-start at logon)</Description>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>
      <Enabled>true</Enabled>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT1M</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Command>
      <Arguments>-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File "%APPDATA%\pios\pios.ps1"</Arguments>
      <WorkingDirectory>%USERPROFILE%</WorkingDirectory>
    </Exec>
  </Actions>
</Task>
