// Runs Watcher in a dev container using the host machine's sign-in.
// https://watcher-docs.apolloresearch.ai/client/devcontainer
{
	"name": "Watcher dev container",
	"image": "mcr.microsoft.com/devcontainers/base:bookworm",

	// Uncomment on Apple Silicon because the Linux client is x86_64 only.
	// "runArgs": ["--platform=linux/amd64"],

	"containerEnv": {
		// Must match the URL the host machine is signed in to.
		"WATCHER_API_URL": "https://watcher.example.com",
		// Leave empty for the newest release.
		"WATCHER_CLIENT_VERSION": ""
	},

	// Create the bind-mount source as the host user, not root.
	"initializeCommand": "mkdir -p \"${localEnv:HOME}/.apollo_monitor/credentials\"",

	"mounts": [
		// Keep non-credential state private to this container.
		"source=watcher-state-${devcontainerId},target=/home/vscode/.apollo_monitor,type=volume",

		// Share the live sign-in so one file stays true for host and container.
		"source=${localEnv:HOME}/.apollo_monitor/credentials,target=/home/vscode/.apollo_monitor/credentials,type=bind",

		// Keep agent config container-local because hooks contain absolute paths.
		"source=claude-config-${devcontainerId},target=/home/vscode/.claude,type=volume",
		"source=codex-config-${devcontainerId},target=/home/vscode/.codex,type=volume"
	],

	// The editor chooses a free host port when the host Watcher already uses 8228.
	"forwardPorts": [8228],

	// Dev containers usually have neither launchd nor systemd user services.
	"postCreateCommand": "bash .devcontainer/watcher-devcontainer.sh",
	"postStartCommand": "bash .devcontainer/watcher-devcontainer.sh"
}
