{
  "id": "install KH Agent",
  "working_dir": "/tmp/KHAgent",
  "options": {
    "timeoutms": 20000
  },
  "files": [],
  "shell": {
    "command": "ssh",
    "args": [
      "-o",
      "StrictHostKeyChecking=no",
      "-o",
      "PreferredAuthentications=keyboard-interactive,password",
      "${USER}@${HOST}"
    ],
    "onConnect": {
      "timeoutms": 10000,
      "responses": {
        "[Pp]assword:": "${PASSWORD}"
      },
      "waitForPrompt": "[#$]",
      "errorConditions": [
        "timed out",
        "denied"
      ]
    },
    "onExit": {
      "command": "exit\r\n"
    }
  },
  "script": {
    "env": {
      "USER": "",
      "PASSWORD": "",
      "HOST": "",
      "AGENT_ID": "",
      "AGENT_DIR": "/tmp/${AGENT_ID}"
    },
    "commands": [
      {
        "command": "mkdir -p ${AGENT_DIR}"
      },
      {
        "command": "cd ${AGENT_DIR}"
      },
      {
        "command": "type startKHAgent >/dev/null 2>&1 || echo \"KHAgent is not installed\"; GLOBAL_INSTALL=\"false\""
      },
      {
        "command": "if [ -d \"knowhow-agent\" ]; then LOCAL_INSTALL=\"true\"; fi"
      },
      {
        "command": "if [ \"${GLOBAL_INSTALL}\" == \"false\" -a -n \"${LOCAL_INSTALL}\" ]; then npm install knowhow-agent; fi"
      }
    ]
  }
}