#!/usr/bin/env sh
set -eu

repo_root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
workspace_root="${HWLAB_WORKSPACE_ROOT:-/workspace}"
agent_session_id="${HWLAB_AGENT_SESSION_ID:-agent_local}"
project_id="${HWLAB_PROJECT_ID:-prj_local}"
skill_commit_id="${HWLAB_SKILL_COMMIT_ID:-}"

mkdir -p "$workspace_root"

echo "HWLAB worker starting"
echo "repo=$repo_root"
echo "workspace=$workspace_root"
echo "agentSessionId=$agent_session_id"
echo "projectId=$project_id"
if [ -n "$skill_commit_id" ]; then
  echo "skillsCommitId=$skill_commit_id"
fi

exec "$@"
