# ImageAnywhere Agent Field Package

Package: ImageAnywhereAgent-0.0.0-20260705-003302-6eb5072

This ZIP is an optional field package for IAUWP.Agent. It can ship beside the ImageAnywhere sideload/appinstaller package, but it does not install, start, or persist the agent by default.

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.
- Starts the agent only when scripts\Start-Agent.ps1 is run.
- Stops the agent with scripts\Stop-Agent.ps1.
- Reports status with scripts\Status-Agent.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 does not add a Run key or silent startup behavior.
- 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
`

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.
