# ImageAnywhere Agent Field Package

Package: ImageAnywhereAgent-2.0.6.1-20260729-154406-2af8722

This ZIP is an optional field package for IAUWP.Agent. It can ship beside the ImageAnywhere sideload/appinstaller package. Since 2.0.6.0, running the install script registers per-user logon startup by DEFAULT (owner-approved 2026-07-28, after unregistered agents silently died on every reboot); pass -NoStartupRegistration for a lab/temporary install.

The package is best described as a paired current-user companion agent. Pairing secrets are stored by the agent under the current Windows user profile, protected by current-user DPAPI, so do not move this into a machine-wide service account without proving the pairing/token access model for that exact account.

## What This Package Does

- Installs the current agent executable and dependencies into a per-user folder when scripts\Install-Agent.ps1 is run, and (by default) registers a per-user logon Run entry so the agent starts at sign-in. Opt out with -NoStartupRegistration; manage later with scripts\Register-Startup.ps1 / scripts\Unregister-Startup.ps1.
- Starts the agent for the current session only when scripts\Start-Agent.ps1 is run (-IgnoreAlreadyRunning makes an already-running agent a success, used by the logon entry).
- Stops the agent with scripts\Stop-Agent.ps1.
- Reports status with scripts\Status-Agent.ps1.
- Reports shadow/safety state with scripts\Status-ClientSupervision.ps1.
- Pauses/resumes supervision with explicit support commands; pause defaults to two hours unless another duration or indefinite is supplied.
- Resets the persistent launch circuit only with scripts\Reset-ClientSupervisionCircuit.ps1.
- Removes the installed package with scripts\Remove-Agent.ps1.

## What This Package Does Not Do

- It does not create a Windows service.
- It does not create a scheduled task.
- It adds a per-user logon Run entry ONLY via the install script's default (or Register-Startup.ps1) â€” never machine-wide, never elevated, removed by Unregister-Startup.ps1 and Remove-Agent.ps1.
- It does not enable the DICOM listener unless the agent settings file is changed to opt in.
- It does not change ImageAnywhere app UI, DICOM settings, upload behavior, or patient/gallery workflows.

## Runtime

- Runtime mode: self-contained
- Requirement: No separate .NET runtime install expected for this win-x64 package.
- Entrypoint: $Entrypoint

## Install

From an extracted ZIP:

`powershell
powershell -ExecutionPolicy Bypass -File .\scripts\Install-Agent.ps1
`

Default install location:

`	ext
%LOCALAPPDATA%\Programs\ImageAnywhereAgent
`

Use -InstallDirectory for a support-managed location. Use -Force to replace package files in an existing install folder.

## Start And Stop

`powershell
powershell -ExecutionPolicy Bypass -File .\scripts\Start-Agent.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\Status-Agent.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\Stop-Agent.ps1
`

Client supervision remains disabled/shadow by default. These support commands change only the agent's local supervision state; they do not install persistence, launch ImageAnywhere, terminate a process, or alter UWP LocalState:

`powershell
powershell -ExecutionPolicy Bypass -File .\scripts\Status-ClientSupervision.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\Pause-ClientSupervision.ps1 -Duration 2h
powershell -ExecutionPolicy Bypass -File .\scripts\Resume-ClientSupervision.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\Reset-ClientSupervisionCircuit.ps1
`

The start script launches the console agent as a hidden user-session process. It does not survive sign-out or reboot. The agent also records its own PID under 
un\agent.pid at startup, so the PID file stays accurate for every launch path; the stop script prefers that PID file but falls back to stopping any IAUWP.Agent process running from this install's executable. The agent additionally holds a per-session single-instance mutex, so a second launch exits with an "already running" message instead of double-running.

## Pairing And Settings

The agent creates its data root at:

`	ext
%LOCALAPPDATA%\ImageAnywhere\agent
`

The settings file is:

`	ext
%LOCALAPPDATA%\ImageAnywhere\agent\agent-settings.json
`

Important opt-in settings:

- WatchFolderPath: empty means watch-folder ingest is disabled.
- DicomListenerEnabled: alse by default.
- DicomListenerPort: default 11113, intentionally separate from the app's typical 11112.
- DicomListenerAeTitle: default IA-AGENT.
- DicomRequireCallingAeAllowlist: alse by default.
- PairingPollSeconds: default 15. While waiting for the next heartbeat the running agent probes for a new app pairing handoff this often and imports it within seconds of Pair agent being clicked. Set  to disable the poll (pairing then imports only on start or heartbeat, default every 5 minutes).

Pairing normally comes from the ImageAnywhere app's Pair agent handoff. The package also preserves the agent's existing diagnostic commands such as --auth-status, --status-json, --unpair, and the selftest commands for support use.

## Remove

`powershell
powershell -ExecutionPolicy Bypass -File .\scripts\Remove-Agent.ps1
`

By default removal preserves %LOCALAPPDATA%\ImageAnywhere\agent so settings, diagnostics, and pairing state are not deleted by accident. Use -RemoveAgentData only when a support/admin operator intentionally wants to delete that local agent state.
