#!/bin/sh
# Mock agent for cryochamber integration tests.
# Uses cryo-agent CLI commands to communicate with the daemon.
# CRYO_AGENT_BIN must be set to the path of the cryo-agent binary.

# Optionally echo something to stdout (still the agent's output, just not parsed by daemon)
echo "${MOCK_AGENT_OUTPUT:-Agent running}"

# Leave a note if requested
if [ -n "$MOCK_AGENT_NOTE" ]; then
    "$CRYO_AGENT_BIN" note "$MOCK_AGENT_NOTE" 2>/dev/null || true
fi

# Default: send a human-visible message, then hibernate --complete.
"$CRYO_AGENT_BIN" send "${MOCK_AGENT_REPLY:-Mock agent completed this session.}" 2>/dev/null || true

if [ "$MOCK_AGENT_COMPLETE" = "false" ] && [ -n "$MOCK_AGENT_WAKE" ]; then
    # Add a TODO with the wake time, then hibernate (not complete)
    "$CRYO_AGENT_BIN" todo add "scheduled wake" --at "$MOCK_AGENT_WAKE" 2>/dev/null || true
    "$CRYO_AGENT_BIN" hibernate --summary "${MOCK_AGENT_SUMMARY:-continuing}" 2>/dev/null || true
else
    "$CRYO_AGENT_BIN" hibernate --complete --summary "${MOCK_AGENT_SUMMARY:-mock done}" 2>/dev/null || true
fi
