@alwaysai/device-agent 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/lib/application-control/config.d.ts.map +1 -1
  2. package/lib/application-control/config.js +10 -5
  3. package/lib/application-control/config.js.map +1 -1
  4. package/lib/application-control/environment-variables.d.ts +1 -5
  5. package/lib/application-control/environment-variables.d.ts.map +1 -1
  6. package/lib/application-control/environment-variables.js +9 -26
  7. package/lib/application-control/environment-variables.js.map +1 -1
  8. package/lib/application-control/environment-variables.test.js +27 -7
  9. package/lib/application-control/environment-variables.test.js.map +1 -1
  10. package/lib/application-control/index.d.ts +4 -4
  11. package/lib/application-control/index.d.ts.map +1 -1
  12. package/lib/application-control/index.js +1 -4
  13. package/lib/application-control/index.js.map +1 -1
  14. package/lib/application-control/install.d.ts.map +1 -1
  15. package/lib/application-control/install.js +9 -7
  16. package/lib/application-control/install.js.map +1 -1
  17. package/lib/application-control/models.d.ts +5 -11
  18. package/lib/application-control/models.d.ts.map +1 -1
  19. package/lib/application-control/models.js +27 -64
  20. package/lib/application-control/models.js.map +1 -1
  21. package/lib/application-control/status.d.ts.map +1 -1
  22. package/lib/application-control/status.js +10 -12
  23. package/lib/application-control/status.js.map +1 -1
  24. package/lib/application-control/utils.d.ts +0 -4
  25. package/lib/application-control/utils.d.ts.map +1 -1
  26. package/lib/application-control/utils.js +3 -26
  27. package/lib/application-control/utils.js.map +1 -1
  28. package/lib/cloud-connection/bootstrap-provision.js +3 -2
  29. package/lib/cloud-connection/bootstrap-provision.js.map +1 -1
  30. package/lib/cloud-connection/device-agent-cloud-connection.d.ts +11 -16
  31. package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
  32. package/lib/cloud-connection/device-agent-cloud-connection.js +295 -246
  33. package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
  34. package/lib/cloud-connection/device-agent.d.ts.map +1 -1
  35. package/lib/cloud-connection/device-agent.js +11 -9
  36. package/lib/cloud-connection/device-agent.js.map +1 -1
  37. package/lib/cloud-connection/live-updates-handler.d.ts +18 -27
  38. package/lib/cloud-connection/live-updates-handler.d.ts.map +1 -1
  39. package/lib/cloud-connection/live-updates-handler.js +58 -170
  40. package/lib/cloud-connection/live-updates-handler.js.map +1 -1
  41. package/lib/cloud-connection/live-updates-handler.test.js +76 -54
  42. package/lib/cloud-connection/live-updates-handler.test.js.map +1 -1
  43. package/lib/cloud-connection/passthrough-handler.d.ts +9 -4
  44. package/lib/cloud-connection/passthrough-handler.d.ts.map +1 -1
  45. package/lib/cloud-connection/passthrough-handler.js +95 -62
  46. package/lib/cloud-connection/passthrough-handler.js.map +1 -1
  47. package/lib/cloud-connection/shadow-handler.d.ts +5 -1
  48. package/lib/cloud-connection/shadow-handler.d.ts.map +1 -1
  49. package/lib/cloud-connection/shadow-handler.js +63 -31
  50. package/lib/cloud-connection/shadow-handler.js.map +1 -1
  51. package/lib/cloud-connection/shadow-handler.test.js +45 -57
  52. package/lib/cloud-connection/shadow-handler.test.js.map +1 -1
  53. package/lib/cloud-connection/shadow.d.ts.map +1 -1
  54. package/lib/cloud-connection/shadow.js +2 -1
  55. package/lib/cloud-connection/shadow.js.map +1 -1
  56. package/lib/cloud-connection/transaction-manager.d.ts +7 -2
  57. package/lib/cloud-connection/transaction-manager.d.ts.map +1 -1
  58. package/lib/cloud-connection/transaction-manager.js +29 -29
  59. package/lib/cloud-connection/transaction-manager.js.map +1 -1
  60. package/lib/cloud-connection/transaction-manager.test.js +105 -3
  61. package/lib/cloud-connection/transaction-manager.test.js.map +1 -1
  62. package/lib/device-control/device-control.d.ts +14 -6
  63. package/lib/device-control/device-control.d.ts.map +1 -1
  64. package/lib/device-control/device-control.js +172 -72
  65. package/lib/device-control/device-control.js.map +1 -1
  66. package/lib/docker/docker-compose.d.ts +14 -0
  67. package/lib/docker/docker-compose.d.ts.map +1 -0
  68. package/lib/docker/docker-compose.js +57 -0
  69. package/lib/docker/docker-compose.js.map +1 -0
  70. package/lib/index.js +2 -5
  71. package/lib/index.js.map +1 -1
  72. package/lib/infrastructure/agent-config.d.ts +46 -14
  73. package/lib/infrastructure/agent-config.d.ts.map +1 -1
  74. package/lib/infrastructure/agent-config.js +36 -21
  75. package/lib/infrastructure/agent-config.js.map +1 -1
  76. package/lib/infrastructure/agent-config.test.js +6 -1
  77. package/lib/infrastructure/agent-config.test.js.map +1 -1
  78. package/lib/infrastructure/config-check-utility.d.ts +6 -0
  79. package/lib/infrastructure/config-check-utility.d.ts.map +1 -0
  80. package/lib/infrastructure/config-check-utility.js +67 -0
  81. package/lib/infrastructure/config-check-utility.js.map +1 -0
  82. package/lib/infrastructure/config-check-utility.test.d.ts +2 -0
  83. package/lib/infrastructure/config-check-utility.test.d.ts.map +1 -0
  84. package/lib/infrastructure/config-check-utility.test.js +109 -0
  85. package/lib/infrastructure/config-check-utility.test.js.map +1 -0
  86. package/lib/infrastructure/device-certificate.d.ts +10 -0
  87. package/lib/infrastructure/device-certificate.d.ts.map +1 -0
  88. package/lib/infrastructure/device-certificate.js +47 -0
  89. package/lib/infrastructure/device-certificate.js.map +1 -0
  90. package/lib/infrastructure/device-certificate.test.d.ts +2 -0
  91. package/lib/infrastructure/device-certificate.test.d.ts.map +1 -0
  92. package/lib/infrastructure/device-certificate.test.js +24 -0
  93. package/lib/infrastructure/device-certificate.test.js.map +1 -0
  94. package/lib/infrastructure/legacy-migration/legacy-file.test.d.ts +2 -0
  95. package/lib/infrastructure/legacy-migration/legacy-file.test.d.ts.map +1 -0
  96. package/lib/infrastructure/legacy-migration/legacy-file.test.js +61 -0
  97. package/lib/infrastructure/legacy-migration/legacy-file.test.js.map +1 -0
  98. package/lib/infrastructure/legacy-migration/legacy-files.d.ts +75 -0
  99. package/lib/infrastructure/legacy-migration/legacy-files.d.ts.map +1 -0
  100. package/lib/infrastructure/legacy-migration/legacy-files.js +75 -0
  101. package/lib/infrastructure/legacy-migration/legacy-files.js.map +1 -0
  102. package/lib/infrastructure/legacy-migration/legacy-migration.d.ts +6 -0
  103. package/lib/infrastructure/legacy-migration/legacy-migration.d.ts.map +1 -0
  104. package/lib/infrastructure/legacy-migration/legacy-migration.js +149 -0
  105. package/lib/infrastructure/legacy-migration/legacy-migration.js.map +1 -0
  106. package/lib/infrastructure/legacy-migration/legacy-migration.test.d.ts +2 -0
  107. package/lib/infrastructure/legacy-migration/legacy-migration.test.d.ts.map +1 -0
  108. package/lib/infrastructure/legacy-migration/legacy-migration.test.js +226 -0
  109. package/lib/infrastructure/legacy-migration/legacy-migration.test.js.map +1 -0
  110. package/lib/infrastructure/require-files-present-ready.test.d.ts +2 -0
  111. package/lib/infrastructure/require-files-present-ready.test.d.ts.map +1 -0
  112. package/lib/infrastructure/require-files-present-ready.test.js +44 -0
  113. package/lib/infrastructure/require-files-present-ready.test.js.map +1 -0
  114. package/lib/infrastructure/required-config-checks.d.ts +2 -0
  115. package/lib/infrastructure/required-config-checks.d.ts.map +1 -0
  116. package/lib/infrastructure/required-config-checks.js +30 -0
  117. package/lib/infrastructure/required-config-checks.js.map +1 -0
  118. package/lib/infrastructure/tokens-and-device-cfg.d.ts.map +1 -1
  119. package/lib/infrastructure/tokens-and-device-cfg.js +11 -8
  120. package/lib/infrastructure/tokens-and-device-cfg.js.map +1 -1
  121. package/lib/local-connection/rabbitmq-connection.d.ts.map +1 -1
  122. package/lib/local-connection/rabbitmq-connection.js +21 -21
  123. package/lib/local-connection/rabbitmq-connection.js.map +1 -1
  124. package/lib/secure-tunneling/secure-tunneling.d.ts +15 -23
  125. package/lib/secure-tunneling/secure-tunneling.d.ts.map +1 -1
  126. package/lib/secure-tunneling/secure-tunneling.js +52 -47
  127. package/lib/secure-tunneling/secure-tunneling.js.map +1 -1
  128. package/lib/secure-tunneling/secure-tunneling.test.js +29 -31
  129. package/lib/secure-tunneling/secure-tunneling.test.js.map +1 -1
  130. package/lib/subcommands/app/analytics.d.ts.map +1 -1
  131. package/lib/subcommands/app/analytics.js +1 -2
  132. package/lib/subcommands/app/analytics.js.map +1 -1
  133. package/lib/subcommands/app/env-vars.d.ts +4 -0
  134. package/lib/subcommands/app/env-vars.d.ts.map +1 -1
  135. package/lib/subcommands/app/env-vars.js +52 -6
  136. package/lib/subcommands/app/env-vars.js.map +1 -1
  137. package/lib/subcommands/app/index.d.ts.map +1 -1
  138. package/lib/subcommands/app/index.js +1 -3
  139. package/lib/subcommands/app/index.js.map +1 -1
  140. package/lib/subcommands/app/models.d.ts +0 -11
  141. package/lib/subcommands/app/models.d.ts.map +1 -1
  142. package/lib/subcommands/app/models.js +2 -58
  143. package/lib/subcommands/app/models.js.map +1 -1
  144. package/lib/subcommands/app/shadow.d.ts.map +1 -1
  145. package/lib/subcommands/app/shadow.js +6 -5
  146. package/lib/subcommands/app/shadow.js.map +1 -1
  147. package/lib/subcommands/app/version.d.ts.map +1 -1
  148. package/lib/subcommands/app/version.js +2 -4
  149. package/lib/subcommands/app/version.js.map +1 -1
  150. package/lib/subcommands/config.d.ts +2 -0
  151. package/lib/subcommands/config.d.ts.map +1 -0
  152. package/lib/subcommands/config.js +39 -0
  153. package/lib/subcommands/config.js.map +1 -0
  154. package/lib/subcommands/device/clean.d.ts +1 -1
  155. package/lib/subcommands/device/clean.d.ts.map +1 -1
  156. package/lib/subcommands/device/clean.js +25 -15
  157. package/lib/subcommands/device/clean.js.map +1 -1
  158. package/lib/subcommands/device/get-info.d.ts +2 -0
  159. package/lib/subcommands/device/get-info.d.ts.map +1 -0
  160. package/lib/subcommands/device/get-info.js +36 -0
  161. package/lib/subcommands/device/get-info.js.map +1 -0
  162. package/lib/subcommands/device/index.d.ts.map +1 -1
  163. package/lib/subcommands/device/index.js +13 -2
  164. package/lib/subcommands/device/index.js.map +1 -1
  165. package/lib/subcommands/device/init.d.ts +5 -0
  166. package/lib/subcommands/device/init.d.ts.map +1 -0
  167. package/lib/subcommands/device/{device.js → init.js} +10 -49
  168. package/lib/subcommands/device/init.js.map +1 -0
  169. package/lib/subcommands/device/migrate.d.ts +2 -0
  170. package/lib/subcommands/device/migrate.d.ts.map +1 -0
  171. package/lib/subcommands/device/migrate.js +24 -0
  172. package/lib/subcommands/device/migrate.js.map +1 -0
  173. package/lib/subcommands/device/refresh.d.ts +2 -0
  174. package/lib/subcommands/device/refresh.d.ts.map +1 -0
  175. package/lib/subcommands/device/refresh.js +25 -0
  176. package/lib/subcommands/device/refresh.js.map +1 -0
  177. package/lib/subcommands/device/restart.d.ts +2 -0
  178. package/lib/subcommands/device/restart.d.ts.map +1 -0
  179. package/lib/subcommands/device/restart.js +14 -0
  180. package/lib/subcommands/device/restart.js.map +1 -0
  181. package/lib/subcommands/index.d.ts +1 -1
  182. package/lib/subcommands/index.d.ts.map +1 -1
  183. package/lib/subcommands/index.js +3 -1
  184. package/lib/subcommands/index.js.map +1 -1
  185. package/lib/subcommands/rabbitmq-connection.d.ts +1 -1
  186. package/lib/subcommands/rabbitmq-connection.d.ts.map +1 -1
  187. package/lib/util/aai-error.d.ts +12 -0
  188. package/lib/util/aai-error.d.ts.map +1 -0
  189. package/lib/util/aai-error.js +11 -0
  190. package/lib/util/aai-error.js.map +1 -0
  191. package/lib/util/aws-regions.d.ts +2 -0
  192. package/lib/util/aws-regions.d.ts.map +1 -0
  193. package/lib/util/{cloud-mode-ready.js → aws-regions.js} +2 -20
  194. package/lib/util/aws-regions.js.map +1 -0
  195. package/lib/util/check-for-updates.d.ts +3 -0
  196. package/lib/util/check-for-updates.d.ts.map +1 -0
  197. package/lib/util/check-for-updates.js +46 -0
  198. package/lib/util/check-for-updates.js.map +1 -0
  199. package/lib/util/clean-certs.d.ts.map +1 -1
  200. package/lib/util/clean-certs.js +5 -4
  201. package/lib/util/clean-certs.js.map +1 -1
  202. package/lib/util/directories.d.ts +4 -18
  203. package/lib/util/directories.d.ts.map +1 -1
  204. package/lib/util/directories.js +18 -32
  205. package/lib/util/directories.js.map +1 -1
  206. package/lib/util/file.d.ts +11 -0
  207. package/lib/util/file.d.ts.map +1 -0
  208. package/lib/util/file.js +127 -0
  209. package/lib/util/file.js.map +1 -0
  210. package/lib/util/file.test.d.ts +2 -0
  211. package/lib/util/file.test.d.ts.map +1 -0
  212. package/lib/util/file.test.js +87 -0
  213. package/lib/util/file.test.js.map +1 -0
  214. package/lib/util/get-device-id.d.ts.map +1 -1
  215. package/lib/util/get-device-id.js +7 -1
  216. package/lib/util/get-device-id.js.map +1 -1
  217. package/lib/util/http-client.js +3 -3
  218. package/lib/util/http-client.js.map +1 -1
  219. package/package.json +22 -19
  220. package/readme.md +15 -35
  221. package/src/application-control/config.ts +10 -13
  222. package/src/application-control/environment-variables.test.ts +28 -7
  223. package/src/application-control/environment-variables.ts +13 -40
  224. package/src/application-control/index.ts +3 -16
  225. package/src/application-control/install.ts +16 -10
  226. package/src/application-control/models.ts +40 -98
  227. package/src/application-control/status.ts +9 -7
  228. package/src/application-control/utils.ts +1 -29
  229. package/src/cloud-connection/bootstrap-provision.ts +7 -7
  230. package/src/cloud-connection/device-agent-cloud-connection.ts +647 -509
  231. package/src/cloud-connection/device-agent.ts +16 -7
  232. package/src/cloud-connection/live-updates-handler.test.ts +137 -64
  233. package/src/cloud-connection/live-updates-handler.ts +103 -234
  234. package/src/cloud-connection/passthrough-handler.ts +134 -75
  235. package/src/cloud-connection/shadow-handler.test.ts +45 -57
  236. package/src/cloud-connection/shadow-handler.ts +114 -56
  237. package/src/cloud-connection/shadow.ts +4 -1
  238. package/src/cloud-connection/transaction-manager.test.ts +127 -3
  239. package/src/cloud-connection/transaction-manager.ts +68 -39
  240. package/src/device-control/device-control.ts +179 -72
  241. package/src/docker/docker-compose.ts +61 -0
  242. package/src/index.ts +2 -6
  243. package/src/infrastructure/agent-config.test.ts +9 -2
  244. package/src/infrastructure/agent-config.ts +45 -46
  245. package/src/infrastructure/config-check-utility.test.ts +154 -0
  246. package/src/infrastructure/config-check-utility.ts +77 -0
  247. package/src/infrastructure/device-certificate.test.ts +40 -0
  248. package/src/infrastructure/device-certificate.ts +58 -0
  249. package/src/infrastructure/legacy-migration/legacy-file.test.ts +88 -0
  250. package/src/infrastructure/legacy-migration/legacy-files.ts +101 -0
  251. package/src/infrastructure/legacy-migration/legacy-migration.test.ts +396 -0
  252. package/src/infrastructure/legacy-migration/legacy-migration.ts +229 -0
  253. package/src/infrastructure/require-files-present-ready.test.ts +53 -0
  254. package/src/infrastructure/required-config-checks.ts +33 -0
  255. package/src/infrastructure/tokens-and-device-cfg.ts +12 -10
  256. package/src/local-connection/rabbitmq-connection.ts +28 -23
  257. package/src/secure-tunneling/secure-tunneling.test.ts +37 -39
  258. package/src/secure-tunneling/secure-tunneling.ts +74 -69
  259. package/src/subcommands/app/analytics.ts +2 -4
  260. package/src/subcommands/app/env-vars.ts +72 -9
  261. package/src/subcommands/app/index.ts +3 -11
  262. package/src/subcommands/app/models.ts +5 -81
  263. package/src/subcommands/app/shadow.ts +6 -5
  264. package/src/subcommands/app/version.ts +3 -4
  265. package/src/subcommands/config.ts +42 -0
  266. package/src/subcommands/device/clean.ts +32 -18
  267. package/src/subcommands/device/get-info.ts +49 -0
  268. package/src/subcommands/device/index.ts +13 -2
  269. package/src/subcommands/device/{device.ts → init.ts} +11 -69
  270. package/src/subcommands/device/migrate.ts +20 -0
  271. package/src/subcommands/device/refresh.ts +23 -0
  272. package/src/subcommands/device/restart.ts +11 -0
  273. package/src/subcommands/index.ts +3 -1
  274. package/src/util/aai-error.ts +20 -0
  275. package/src/util/{cloud-mode-ready.ts → aws-regions.ts} +0 -24
  276. package/src/util/check-for-updates.ts +53 -0
  277. package/src/util/clean-certs.ts +8 -4
  278. package/src/util/directories.ts +23 -67
  279. package/src/util/file.test.ts +90 -0
  280. package/src/util/file.ts +156 -0
  281. package/src/util/get-device-id.ts +7 -7
  282. package/src/util/http-client.ts +2 -2
  283. package/lib/docker/docker-compose-cmd.d.ts +0 -5
  284. package/lib/docker/docker-compose-cmd.d.ts.map +0 -1
  285. package/lib/docker/docker-compose-cmd.js +0 -16
  286. package/lib/docker/docker-compose-cmd.js.map +0 -1
  287. package/lib/subcommands/device/device.d.ts +0 -7
  288. package/lib/subcommands/device/device.d.ts.map +0 -1
  289. package/lib/subcommands/device/device.js.map +0 -1
  290. package/lib/util/cloud-mode-ready.d.ts +0 -3
  291. package/lib/util/cloud-mode-ready.d.ts.map +0 -1
  292. package/lib/util/cloud-mode-ready.js.map +0 -1
  293. package/lib/util/download-file.d.ts +0 -6
  294. package/lib/util/download-file.d.ts.map +0 -1
  295. package/lib/util/download-file.js +0 -25
  296. package/lib/util/download-file.js.map +0 -1
  297. package/lib/util/fetch-with-timeout.d.ts +0 -4
  298. package/lib/util/fetch-with-timeout.d.ts.map +0 -1
  299. package/lib/util/fetch-with-timeout.js +0 -30
  300. package/lib/util/fetch-with-timeout.js.map +0 -1
  301. package/lib/util/parsing.d.ts +0 -2
  302. package/lib/util/parsing.d.ts.map +0 -1
  303. package/lib/util/parsing.js +0 -17
  304. package/lib/util/parsing.js.map +0 -1
  305. package/lib/util/safe-rimraf.d.ts +0 -2
  306. package/lib/util/safe-rimraf.d.ts.map +0 -1
  307. package/lib/util/safe-rimraf.js +0 -16
  308. package/lib/util/safe-rimraf.js.map +0 -1
  309. package/src/docker/docker-compose-cmd.ts +0 -15
  310. package/src/util/download-file.ts +0 -25
  311. package/src/util/fetch-with-timeout.ts +0 -35
  312. package/src/util/parsing.ts +0 -11
  313. package/src/util/safe-rimraf.ts +0 -14
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.test.js","sourceRoot":"","sources":["../../src/util/file.test.ts"],"names":[],"mappings":";;AAAA,8CAA+C;AAC/C,0CAA2D;AAE3D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE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AAG,MAAM,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAElE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,kBAAO,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,CAAC,eAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,kCAAkC;QACzE,MAAM,CAAC,iBAAM,CAAC,CAAC,oBAAoB,CAAC,GAAG,QAAQ,YAAY,CAAC,CAAC;QAC7D,MAAM,CAAC,iBAAM,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,UAAU,YAAY,CAAC,CAAC;QACnE,MAAM,CAAC,gBAAK,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-device-id.d.ts","sourceRoot":"","sources":["../../src/util/get-device-id.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,WAiB5B"}
1
+ {"version":3,"file":"get-device-id.d.ts","sourceRoot":"","sources":["../../src/util/get-device-id.ts"],"names":[],"mappings":"AAKA,wBAAgB,aAAa,WAc5B"}
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDeviceUuid = void 0;
4
4
  const device_1 = require("alwaysai/lib/core/device");
5
+ const logger_1 = require("./logger");
6
+ const util_1 = require("alwaysai/lib/util");
7
+ const aai_error_1 = require("./aai-error");
5
8
  function getDeviceUuid() {
6
9
  const deviceCfgFile = (0, device_1.DeviceConfigFile)();
7
10
  if (!deviceCfgFile.exists()) {
@@ -12,7 +15,10 @@ function getDeviceUuid() {
12
15
  return cfg.deviceUuid;
13
16
  }
14
17
  catch (e) {
15
- throw new Error(`Failed to read device configuration: ${JSON.stringify(deviceCfgFile.getErrors(), null, 2)}`);
18
+ logger_1.logger.error(`Failed to read device configuration!\n${(0, util_1.stringifyError)(e)}`);
19
+ throw new aai_error_1.default('Failed to read device configuration', {
20
+ cause: deviceCfgFile.getErrors()
21
+ });
16
22
  }
17
23
  }
18
24
  exports.getDeviceUuid = getDeviceUuid;
@@ -1 +1 @@
1
- {"version":3,"file":"get-device-id.js","sourceRoot":"","sources":["../../src/util/get-device-id.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE5D,SAAgB,aAAa;IAC3B,MAAM,aAAa,GAAG,IAAA,yBAAgB,GAAE,CAAC;IACzC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACpD;IACD,IAAI;QACF,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC,UAAU,CAAC;KACvB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,SAAS,CACpD,aAAa,CAAC,SAAS,EAAE,EACzB,IAAI,EACJ,CAAC,CACF,EAAE,CACJ,CAAC;KACH;AACH,CAAC;AAjBD,sCAiBC"}
1
+ {"version":3,"file":"get-device-id.js","sourceRoot":"","sources":["../../src/util/get-device-id.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAC5D,qCAAkC;AAClC,4CAAmD;AACnD,2CAAmC;AAEnC,SAAgB,aAAa;IAC3B,MAAM,aAAa,GAAG,IAAA,yBAAgB,GAAE,CAAC;IACzC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACpD;IACD,IAAI;QACF,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC,UAAU,CAAC;KACvB;IAAC,OAAO,CAAC,EAAE;QACV,eAAM,CAAC,KAAK,CAAC,yCAAyC,IAAA,qBAAc,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3E,MAAM,IAAI,mBAAQ,CAAC,qCAAqC,EAAE;YACxD,KAAK,EAAE,aAAa,CAAC,SAAS,EAAE;SACjC,CAAC,CAAC;KACJ;AACH,CAAC;AAdD,sCAcC"}
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.microServiceHttpClient = exports.httpClient = void 0;
4
- const node_fetch_1 = require("node-fetch");
5
4
  const endpoints_1 = require("../endpoints");
6
5
  const infrastructure_1 = require("alwaysai/lib/infrastructure");
7
6
  const logger_1 = require("../util/logger");
7
+ const util_1 = require("alwaysai/lib/util");
8
8
  async function httpClient(url, method, headers, data) {
9
9
  const options = Object.assign({ method }, (data ? { body: data, headers } : { headers }));
10
10
  try {
11
- const response = await (0, node_fetch_1.default)(url, options);
11
+ const response = await fetch(url, options);
12
12
  const contentType = response.headers.get('content-type');
13
13
  if (contentType === 'application/json') {
14
14
  return await response.json();
@@ -18,7 +18,7 @@ async function httpClient(url, method, headers, data) {
18
18
  }
19
19
  }
20
20
  catch (e) {
21
- logger_1.logger.error(`HTTP Client error for ${url}: ${e.message}`);
21
+ logger_1.logger.error(`HTTP Client error for ${url}:\n${(0, util_1.stringifyError)(e)}`);
22
22
  }
23
23
  }
24
24
  exports.httpClient = httpClient;
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/util/http-client.ts"],"names":[],"mappings":";;;AAAA,2CAA+B;AAC/B,4CAAsD;AACtD,gEAAsE;AACtE,2CAAwC;AAEjC,KAAK,UAAU,UAAU,CAC9B,GAAW,EACX,MAAc,EACd,OAAY,EACZ,IAAa;IAEb,MAAM,OAAO,mBACX,MAAM,IACH,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,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AAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAClD,CAAC;IACF,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,WAAW,KAAK,kBAAkB,EAAE;YACtC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC9B;QACD,IAAI,WAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YACvC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC9B;KACF;IAAC,OAAO,CAAC,EAAE;QACV,eAAM,CAAC,KAAK,CAAC,yBAAyB,GAAG,MAAM,IAAA,qBAAc,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KACrE;AACH,CAAC;AAtBD,gCAsBC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,OAAe,EACf,IAAY,EACZ,MAAc,EACd,IAAa;IAEb,MAAM,QAAQ,GAAG,IAAA,kCAAsB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,EAAE,wBAAwB,EAAE,GAAG,IAAA,wCAAuB,GAAE,CAAC;IAC/D,MAAM,mBAAmB,GAAG,MAAM,wBAAwB,EAAE,CAAC;IAC7D,OAAO,MAAM,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAC;AACvE,CAAC;AAVD,wDAUC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alwaysai/device-agent",
3
3
  "description": "The alwaysAI Device Agent",
4
- "version": "1.4.0",
4
+ "version": "2.0.0",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "publishConfig": {
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "engines": {
15
15
  "npm": ">=7.0.0",
16
- "node": ">=16.0.0"
16
+ "node": ">=18.0.0"
17
17
  },
18
18
  "scripts": {
19
19
  "build": "tsc --project tsconfig.build.json",
@@ -34,43 +34,46 @@
34
34
  "publish-provisioning:prod": "node ./scripts/publish-provisioning-scripts.js prod"
35
35
  },
36
36
  "dependencies": {
37
- "@alwaysai/alwayscli": "0.3.2",
38
- "@alwaysai/app-configuration-schemas": "0.1.0",
39
- "@alwaysai/config-nodejs": "0.3.0",
40
- "@alwaysai/device-agent-schemas": "2.3.1",
37
+ "@alwaysai/alwayscli": "0.3.3",
38
+ "@alwaysai/app-configuration-schemas": "0.2.0",
39
+ "@alwaysai/config-nodejs": "0.3.3",
40
+ "@alwaysai/device-agent-schemas": "3.1.0",
41
41
  "@carnesen/coded-error": "0.4.0",
42
42
  "ajv": "8.11.0",
43
- "alwaysai": "2.2.0",
43
+ "alwaysai": "2.6.1",
44
44
  "amqplib": "0.10.3",
45
- "aws-iot-device-sdk": "2.2.12",
46
- "docker-compose": "0.23.17",
45
+ "aws-iot-device-sdk": "2.2.15",
46
+ "docker-compose": "0.24.8",
47
47
  "lodash": "4.17.21",
48
- "node-fetch": "2.6.1",
49
48
  "node-os-utils": "1.3.7",
50
49
  "rimraf": "4.4.0",
50
+ "serialize-error": "8.1.0",
51
51
  "systeminformation": "5.21.13",
52
52
  "uuid": "9.0.0",
53
- "winston": "3.8.2",
54
- "winston-daily-rotate-file": "4.7.1",
55
- "yaml": "2.2.1"
53
+ "winston": "3.13.0",
54
+ "winston-daily-rotate-file": "5.0.0",
55
+ "yaml": "2.5.0"
56
56
  },
57
57
  "devDependencies": {
58
+ "@alwaysai/eslint-config": "0.1.3",
58
59
  "@alwaysai/tsconfig": "0.0.1",
59
- "@alwaysai/eslint-config": "0.1.0",
60
+ "@types/amqplib": "0.10.5",
60
61
  "@types/destroy": "1.0.0",
61
- "@types/jest": "28.1.2",
62
- "@types/node": "16.11.12",
62
+ "@types/jest": "29.1.2",
63
+ "@types/node": "18.11.9",
63
64
  "@types/node-os-utils": "^1.3.4",
65
+ "@types/rimraf": "3.0.2",
64
66
  "@types/sinon": "10.0.6",
67
+ "@types/tar": "6.1.2",
65
68
  "@typescript-eslint/eslint-plugin": "^5.48.0",
66
69
  "@typescript-eslint/parser": "^5.48.0",
67
- "aws-sdk": "^2.1046.0",
70
+ "aws-sdk": "^2.1663.0",
68
71
  "cp-cli": "2.0.0",
69
72
  "get-stream": "6.0.1",
70
- "jest": "28.1.1",
73
+ "jest": "29.7.0",
71
74
  "sinon": "12.0.1",
72
75
  "tempy": "0.7.1",
73
- "ts-jest": "28.0.5",
76
+ "ts-jest": "29.2.3",
74
77
  "ts-mock-imports": "1.3.8",
75
78
  "ts-node": "10.8.1",
76
79
  "typescript": "4.6.4"
package/readme.md CHANGED
@@ -28,7 +28,6 @@ change.
28
28
  - [Control the application](#control-the-application)
29
29
  - [Manage application models](#manage-application-models)
30
30
  - [Update models to new version of the same model ID](#update-models-to-new-version-of-the-same-model-id)
31
- - [Replace models for an application for new ID](#replace-models-for-an-application-for-new-id)
32
31
  - [Manually download a model package](#manually-download-a-model-package)
33
32
  - [Set and update environment variables](#set-and-update-environment-variables)
34
33
  - [Device Cleaning and Uninstalling](#device-cleaning-and-uninstalling)
@@ -42,13 +41,13 @@ change.
42
41
 
43
42
  * Supported OS:
44
43
  * Debian Bookworm, Bullseye
45
- * Ubuntu 23.10, 22.04, 20.04, 18.04
46
- * NVIDIA Jetpack 5.1, 4.6.x
44
+ * Ubuntu 24.04, 23.10, 22.04, 20.04
45
+ * NVIDIA JetPack 5.1.1, 5.1
47
46
  * Supported target architecture
48
47
  * amd64
49
48
  * aarch64
50
49
  * `docker` >= 19.03
51
- * `docker-compose` >= 1.29.0; < 2.0.0
50
+ * `docker-compose` >= 1.29.0
52
51
  * `curl` installed (required to download provisioning scripts)
53
52
  * Passwordless `sudo` for `npm` if using `pm2`
54
53
  * Passwordless `sudo` for `/sbin/shutdown` for device restart functionality
@@ -86,15 +85,18 @@ Provisioning the device performs the following:
86
85
  Run the following command on the target device to provision it:
87
86
 
88
87
  ```bash
89
- $ curl -fsSL https://artifacts.alwaysai.co/device-agent/provision.sh | bash -s -- --email <email> --password <password> [--device-name <device_name>]
88
+ $ curl -fsSL https://artifacts.alwaysai.co/device-agent/provision.sh | bash -s -- --email <email> --password <password> [--device-name <device_name>] [--pm2-overwrite] [--agent-tag <agent_tag>]
90
89
  ```
91
90
 
92
- Where:
93
- * `email` is the email associated with your alwaysAI account.
94
- * `password` is the password for your alwaysAI account.
95
- * `device_name` is an optional device name, which will be displayed on the
96
- devices page of the alwaysAI Dashboard. If a device name is not provided, one
97
- will be generated for you and logged to the console for reference.
91
+
92
+ | Options | Details |
93
+ |:----------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
94
+ | --email | [REQUIRED] The email associated with your alwaysAI account. |
95
+ | --password | [REQUIRED] The password associated with your alwaysAI account |
96
+ | --device-name | [OPTIONAL] A device name to be associated with this device. It will be displayed on the devices page of the alwaysAI Dashboard. If a device name is not provided, one will be generated for you and logged to the console for reference. |
97
+ | --pm2-overwrite | [OPTIONAL] Overwrite any existing pm2 configuration with the latest provided by the script. The default behavior is to leave existing pm2 configurations as-is. |
98
+ | --agent-tag | [OPTIONAL] Select a specific release tag for the alwaysAI Device Agent. The default option is latest, which tracks the latest production release from alwaysAI. |
99
+
98
100
 
99
101
  **Important note**: If your password contains one or more special characters and you receive an error message that your password does not match your username but you are sure that it is correctly entered, please try preceding every special character in your password with a backslash, and re-running the provisioning command. You can also reset your password at https://console.alwaysai.co/dashboard by logging out, navigating to the sign in page, and clicking '`Forgot Password?`'.
100
102
 
@@ -303,7 +305,6 @@ Subcommands:
303
305
  app uninstall : Remove an alwaysAI app
304
306
  app show-models : Show the application models
305
307
  app add-model : Add a model to an alwaysAI app
306
- app remove-model : Remove a model from an alwaysAI app
307
308
  app get-all-envs : Get environment variables for an application
308
309
  app set-env : Set environment variables for a service
309
310
  app get-analytics-cfg : Get analytics configuration for an application
@@ -362,32 +363,11 @@ There are several ways to manage the models for your application.
362
363
  #### Update models to new version of the same model ID
363
364
 
364
365
  If a new version of a model is published for an existing model ID, and an
365
- application is already configured to be using that model ID, updating to the
366
+ application is already configured to be using that model ID, updating the
366
367
  new model can simply be done with:
367
368
 
368
369
  ```bash
369
- $ aai-agent app stop --project <project_id>
370
- $ aai-agent app update-models --project <project_id>
371
- $ aai-agent app start --project <project_id>
372
- ```
373
-
374
- #### Replace models for an application for new ID
375
-
376
- If you'd like to install an entirely new model to an application, replacing the
377
- model the app was originally configured with, run the following command:
378
-
379
- ```bash
380
- $ aai-agent app stop --project <project_id>
381
- $ aai-agent app replace-models --project <project_id> --models <model_id_1> [<model_id_2> ...]
382
- $ aai-agent app start --project <project_id>
383
- ```
384
-
385
- If you plan on using this method, you can make your application source model ID
386
- agnostic by providing the model ID to edgeIQ in the following way:
387
-
388
- Select the first model in the config list:
389
- ```python
390
- obj_detect = edgeiq.ObjectDetection(edgeiq._globals.MODEL_ID_LIST[0])
370
+ $ aai-agent app add-model --project <ProjectID> --model <ModelID> --version <ModelVersion>
391
371
  ```
392
372
 
393
373
  #### Manually download a model package
@@ -6,13 +6,14 @@ import {
6
6
  requireAppInstalled,
7
7
  requireAppReady
8
8
  } from './utils';
9
- import { JsSpawner } from 'alwaysai/lib/util';
10
- import compose from 'docker-compose';
9
+ import { JsSpawner, stringifyError } from 'alwaysai/lib/util';
10
+ import { compose } from '../docker/docker-compose';
11
11
  import { assign, merge } from 'lodash';
12
12
  import { AppJsonFile } from 'alwaysai/lib/core/app';
13
13
  import { AppConfig } from '@alwaysai/app-configuration-schemas';
14
14
  import { isAppStarted, restartApp } from './status';
15
15
  import { logger } from '../util/logger';
16
+ import AaiError from '../util/aai-error';
16
17
 
17
18
  export async function readAppCfgFile(props: {
18
19
  projectId: string;
@@ -27,11 +28,9 @@ export async function readAppCfgFile(props: {
27
28
  try {
28
29
  return appJson.read();
29
30
  } catch (e) {
30
- throw new Error(
31
- `Error reading app config for ${projectId}:\n${
32
- e.message
33
- }\n${appJson.getErrors()}`
34
- );
31
+ throw new AaiError(`Error reading app config for ${projectId}`, {
32
+ cause: appJson.getErrors()
33
+ });
35
34
  }
36
35
  }
37
36
 
@@ -45,11 +44,9 @@ export async function writeAppCfgFile(props: {
45
44
  try {
46
45
  appJson.write(appCfg);
47
46
  } catch (e) {
48
- throw new Error(
49
- `Error writing app config for ${projectId}:\n${
50
- e.message
51
- }\n${appJson.getErrors()}`
52
- );
47
+ throw new AaiError(`Error writing app config for ${projectId}`, {
48
+ cause: appJson.getErrors()
49
+ });
53
50
  }
54
51
  }
55
52
 
@@ -124,7 +121,7 @@ export async function writeDockerCompose(props: {
124
121
  try {
125
122
  await compose.config({ cwd: appDir, configAsString: composeOutput });
126
123
  } catch (e) {
127
- logger.error(JSON.stringify(e));
124
+ logger.error(stringifyError(e));
128
125
  }
129
126
  await spawner.writeFile('docker-compose.yaml', composeOutput);
130
127
  }
@@ -91,6 +91,24 @@ describe('Test environment variable get and set', () => {
91
91
  edgeiq: { TEST3: '5', TEST4: '6' }
92
92
  });
93
93
  });
94
+ test('get all envs with one service and one cleared env', async () => {
95
+ const compose = {
96
+ services: {
97
+ alwaysai: {
98
+ environment: ['TEST=', 'TEST2=2']
99
+ }
100
+ }
101
+ };
102
+ jest.mocked(readDockerCompose).mockResolvedValue(compose);
103
+
104
+ const envVars = await getAllEnvs({ projectId: projectId1 });
105
+ expect(jest.mocked(readDockerCompose)).toBeCalledWith({
106
+ projectId: projectId1
107
+ });
108
+ expect(envVars).toEqual({
109
+ alwaysai: { TEST: '', TEST2: '2' }
110
+ });
111
+ });
94
112
  });
95
113
  describe('Test setEnv()', () => {
96
114
  test('Set one env', async () => {
@@ -126,7 +144,7 @@ describe('Test environment variable get and set', () => {
126
144
  };
127
145
  jest.mocked(readDockerCompose).mockResolvedValue(compose);
128
146
 
129
- const envVars = { alwaysai: { TEST1: '2' } };
147
+ const envVars = { alwaysai: { TEST1: '2', TEST2: '2' } };
130
148
  await setEnv({ projectId: projectId1, envVars });
131
149
  expect(jest.mocked(readDockerCompose)).toBeCalledWith({
132
150
  projectId: projectId1
@@ -152,7 +170,10 @@ describe('Test environment variable get and set', () => {
152
170
  };
153
171
  jest.mocked(readDockerCompose).mockResolvedValue(compose);
154
172
 
155
- const envVars = { alwaysai: { TEST1: '2' } };
173
+ const envVars = {
174
+ alwaysai: { TEST1: '2', TEST2: '4' },
175
+ other: { OTHER_TEST: '1' }
176
+ };
156
177
  await setEnv({ projectId: projectId1, envVars });
157
178
  expect(jest.mocked(readDockerCompose)).toBeCalledWith({
158
179
  projectId: projectId1
@@ -171,7 +192,7 @@ describe('Test environment variable get and set', () => {
171
192
  }
172
193
  });
173
194
  });
174
- test('Remove one env', async () => {
195
+ test('Unset an envvar', async () => {
175
196
  const environment = ['TEST1=1', 'TEST2=2'];
176
197
  const compose = {
177
198
  services: {
@@ -180,7 +201,7 @@ describe('Test environment variable get and set', () => {
180
201
  };
181
202
  jest.mocked(readDockerCompose).mockResolvedValue(compose);
182
203
 
183
- const envVars = { alwaysai: { TEST1: null } };
204
+ const envVars = { alwaysai: { TEST1: '', TEST2: '2' } };
184
205
  await setEnv({ projectId: projectId1, envVars });
185
206
  expect(jest.mocked(readDockerCompose)).toBeCalledWith({
186
207
  projectId: projectId1
@@ -190,7 +211,7 @@ describe('Test environment variable get and set', () => {
190
211
  dockerCompose: {
191
212
  services: {
192
213
  alwaysai: {
193
- environment: ['TEST2=2']
214
+ environment: ['TEST1=', 'TEST2=2']
194
215
  }
195
216
  }
196
217
  }
@@ -199,12 +220,12 @@ describe('Test environment variable get and set', () => {
199
220
  });
200
221
  describe('Test helpers', () => {
201
222
  test('convertStringEnvsToKeyVal', () => {
202
- const stringEnvs: string[] = ['TEST1=', 'TEST2=test2', 'TEST3=null'];
223
+ const stringEnvs: string[] = ['TEST1=', 'TEST2=test2', 'TEST3='];
203
224
  const envVars = convertStringEnvsToKeyVal(stringEnvs);
204
225
  expect(envVars).toEqual({
205
226
  TEST1: '',
206
227
  TEST2: 'test2',
207
- TEST3: 'null'
228
+ TEST3: ''
208
229
  });
209
230
  });
210
231
  });
@@ -4,13 +4,7 @@ import { buildApp, getAppDir, requireAppReady } from './utils';
4
4
  import { logger } from '../util/logger';
5
5
  import { AgentConfigFile } from '../infrastructure/agent-config';
6
6
  import { isAppStarted, restartApp } from './status';
7
- import { replaceFalseyWithNull } from '../util/parsing';
8
-
9
- export interface EnvVars {
10
- [service: string]: {
11
- [name: string]: string | null;
12
- };
13
- }
7
+ import { EnvVars } from '@alwaysai/device-agent-schemas';
14
8
 
15
9
  export async function setEnv(props: { projectId: string; envVars: EnvVars }) {
16
10
  const { projectId, envVars } = props;
@@ -28,44 +22,27 @@ export async function setEnv(props: { projectId: string; envVars: EnvVars }) {
28
22
  throw new Error(`Docker compose file for ${projectId} has no services!`);
29
23
  }
30
24
  const services: string[] = Object.keys(envVars);
31
- for (const s of services) {
32
- if (!Object.keys(composeParsed['services']).includes(s)) {
25
+ const composeServices = composeParsed['services'];
26
+
27
+ services.forEach((s) => {
28
+ if (!Object.keys(composeServices).includes(s)) {
33
29
  throw new Error(
34
- `Service ${s} not found in ${JSON.stringify(
35
- composeParsed['services'],
36
- null,
37
- 2
38
- )}`
30
+ `Service ${s} not found in ${JSON.stringify(composeServices, null, 2)}`
39
31
  );
40
32
  }
41
33
 
42
- const service = composeParsed['services'][s];
43
- const oldEnv: string[] | undefined = service['environment'];
34
+ const service = composeServices[s];
44
35
  const envVarsForService = envVars[s];
45
36
 
46
- const newEnvVarsObj = {};
47
- oldEnv?.forEach((envVarStr: string) => {
48
- const envVarSplit = envVarStr.split('=');
49
- const key = envVarSplit[0];
50
- const value = envVarSplit[1];
51
- if (envVarsForService[key] !== null) {
52
- newEnvVarsObj[key] = value;
37
+ const envVarList: string[] = Object.keys(envVarsForService).map(
38
+ (envVar) => {
39
+ const value = envVarsForService[envVar];
40
+ return `${envVar}=${value}`;
53
41
  }
54
- });
55
-
56
- for (const envVar of Object.keys(envVarsForService)) {
57
- if (envVarsForService[envVar] !== null) {
58
- newEnvVarsObj[envVar] = envVarsForService[envVar];
59
- }
60
- }
61
-
62
- const envVarList: string[] = [];
63
- for (const envVar of Object.keys(newEnvVarsObj)) {
64
- envVarList.push(`${envVar}=${newEnvVarsObj[envVar]}`);
65
- }
42
+ );
66
43
 
67
44
  service['environment'] = envVarList;
68
- }
45
+ });
69
46
 
70
47
  await writeDockerCompose({ projectId, dockerCompose: composeParsed });
71
48
 
@@ -138,9 +115,5 @@ export async function getAllEnvs(props: {
138
115
  }
139
116
  }
140
117
  }
141
-
142
- // Device shadow needs null to delete
143
- replaceFalseyWithNull(envVars, true);
144
-
145
118
  return envVars;
146
119
  }
@@ -9,7 +9,7 @@ import {
9
9
  restartApp
10
10
  } from './status';
11
11
  import { ModelDetails } from './types';
12
- import { EnvVars, getAllEnvs, setEnv } from './environment-variables';
12
+ import { getAllEnvs, setEnv } from './environment-variables';
13
13
 
14
14
  export {
15
15
  readAppCfgFile,
@@ -23,24 +23,11 @@ export {
23
23
  stopApp,
24
24
  restartApp,
25
25
  ModelDetails,
26
- EnvVars,
27
26
  getAllEnvs,
28
27
  setEnv
29
28
  };
30
29
 
31
30
  // CLI-mode only
32
- import {
33
- getAppModels,
34
- removeModel,
35
- replaceModels,
36
- updateModels,
37
- updateModelsWithPresignedUrls
38
- } from './models';
31
+ import { getAppModels, updateModelsWithPresignedUrls } from './models';
39
32
 
40
- export {
41
- getAppModels,
42
- removeModel,
43
- replaceModels,
44
- updateModels,
45
- updateModelsWithPresignedUrls
46
- };
33
+ export { getAppModels, updateModelsWithPresignedUrls };
@@ -2,8 +2,8 @@ import { rimraf } from 'rimraf';
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  import { buildDockerImage } from 'alwaysai/lib/util/docker';
5
- import { JsSpawner, Spawner } from 'alwaysai/lib/util';
6
- import { getAppDir, downloadPackageUsingPresignedUrl, buildApp } from './utils';
5
+ import { JsSpawner, Spawner, stringifyError } from 'alwaysai/lib/util';
6
+ import { getAppDir, buildApp } from './utils';
7
7
  import { AppDetails } from '@alwaysai/device-agent-schemas';
8
8
  import { BACKUP_EXT } from './backup';
9
9
  import { startApp, stopApp, isAppStarted } from './status';
@@ -15,7 +15,7 @@ import {
15
15
  TargetJsonFile,
16
16
  appCleanDocker,
17
17
  getPythonVenvPaths,
18
- installPythonVenv,
18
+ createPythonVenv,
19
19
  installPythonReqs
20
20
  } from 'alwaysai/lib/core/app';
21
21
  import { DOCKER_IMAGE_ID_INITIAL_VALUE } from 'alwaysai/lib/constants';
@@ -29,6 +29,7 @@ import {
29
29
  LOCAL_CONNECTION_ROUTING_KEY
30
30
  } from '../local-connection/constants';
31
31
  import { DOCKERFILE, PYTHON_REQUIREMENTS_FILE_NAME } from 'alwaysai/lib/paths';
32
+ import { downloadToFile } from '../util/file';
32
33
 
33
34
  type SignedUrlPayloadType = {
34
35
  appInstallPayload: {
@@ -72,9 +73,11 @@ export async function installApp(props: {
72
73
  logger.info('Application currently running. Stopping...');
73
74
  try {
74
75
  await stopApp({ projectId });
75
- } catch (error) {
76
+ } catch (e) {
76
77
  logger.error(
77
- 'Could not stop the application. Old container might still be present after installation.'
78
+ `Could not stop the application. Old container might still be present after installation.\n${stringifyError(
79
+ e
80
+ )}`
78
81
  );
79
82
  }
80
83
  }
@@ -96,9 +99,9 @@ export async function installApp(props: {
96
99
  // download app package
97
100
  const localDest = path.join(appDir, `${path.basename(appReleaseHash)}.tgz`);
98
101
  const { appSignedUrl } = signedUrlsPayload.appInstallPayload;
99
- await downloadPackageUsingPresignedUrl({
100
- localDest,
101
- presignedUrl: appSignedUrl
102
+ await downloadToFile({
103
+ path: localDest,
104
+ url: appSignedUrl
102
105
  });
103
106
 
104
107
  // Unpack app package and remove tar file
@@ -176,7 +179,7 @@ async function installAppBuildReqs(props: { appDir: string }) {
176
179
 
177
180
  const targetSpawner = targetJsonFile.readContainerSpawner();
178
181
  const pythonVenvPaths = await getPythonVenvPaths({ targetCfg });
179
- await installPythonVenv({ targetSpawner, pythonVenvPaths, logger });
182
+ await createPythonVenv({ targetSpawner, pythonVenvPaths, logger });
180
183
  if (await hostSpawner.exists(PYTHON_REQUIREMENTS_FILE_NAME)) {
181
184
  await installPythonReqs({
182
185
  reqFilePath: PYTHON_REQUIREMENTS_FILE_NAME,
@@ -231,11 +234,14 @@ export async function uninstallApp(props: {
231
234
  logger.info(`Application ${projectId} not installed`);
232
235
  return;
233
236
  }
237
+ await AgentConfigFile().setAppUninstalling({ projectId });
234
238
  try {
235
239
  await stopApp({ projectId });
236
240
  } catch (e) {
237
241
  logger.warn(
238
- `Failed to stop ${projectId}, may be left running...\n${e.message}`
242
+ `Failed to stop ${projectId}, may be left running...\n${stringifyError(
243
+ e
244
+ )}`
239
245
  );
240
246
  }
241
247
  await AgentConfigFile().setAppUninstalled({ projectId });