hyperray 0.0.1__py3-none-any.whl

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 (788) hide show
  1. hyperdrone/__init__.py +53 -0
  2. hyperdrone/_cuda/__init__.py +76 -0
  3. hyperdrone/_dlpack.py +30 -0
  4. hyperdrone/_jit/__init__.py +131 -0
  5. hyperdrone/_jit/_build.py +113 -0
  6. hyperdrone/_jit/_lock.py +23 -0
  7. hyperdrone/_jit/_patches.py +99 -0
  8. hyperdrone/_jit/_toolchain.py +17 -0
  9. hyperdrone/_jit/_workspace.py +94 -0
  10. hyperdrone/_native/cmake/hyperdrone_jit.cmake +65 -0
  11. hyperdrone/_native/common/bindings.h +39 -0
  12. hyperdrone/_native/common/cuda_staging.h +80 -0
  13. hyperdrone/_native/common/jit_host.h +69 -0
  14. hyperdrone/_native/common/models.h +24 -0
  15. hyperdrone/_native/common/verbosity.h +52 -0
  16. hyperdrone/_native/dynamics/CMakeLists.txt +63 -0
  17. hyperdrone/_native/dynamics/host.cpp +188 -0
  18. hyperdrone/_native/dynamics/iface.h +71 -0
  19. hyperdrone/_native/dynamics/impl.cpp +638 -0
  20. hyperdrone/_native/env/CMakeLists.txt +98 -0
  21. hyperdrone/_native/env/environment.cpp +190 -0
  22. hyperdrone/_native/env/environment.h +282 -0
  23. hyperdrone/_native/env/impl.cpp +779 -0
  24. hyperdrone/_native/env/rotorcraft_bindings.cpp +53 -0
  25. hyperdrone/_native/render/CMakeLists.txt +96 -0
  26. hyperdrone/_native/render/renderer.cpp +973 -0
  27. hyperdrone/_native/render/rig_bindings.h +152 -0
  28. hyperdrone/_native/render/scene_bindings.cpp +515 -0
  29. hyperdrone/_outputs.py +32 -0
  30. hyperdrone/_parameters.py +36 -0
  31. hyperdrone/_vendor/rl-tools/CMakeLists.txt +207 -0
  32. hyperdrone/_vendor/rl-tools/LICENSE +21 -0
  33. hyperdrone/_vendor/rl-tools/cmake/autodetect/all.cmake +34 -0
  34. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-diff.cmake +100 -0
  35. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-hash.cmake +24 -0
  36. hyperdrone/_vendor/rl-tools/cmake/autodetect/summary.cmake +65 -0
  37. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier0-compiler.cmake +18 -0
  38. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier1-blas.cmake +51 -0
  39. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier2-json-hdf5-zlib.cmake +82 -0
  40. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier3-tensorboard.cmake +25 -0
  41. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier4-cuda.cmake +42 -0
  42. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier5-cli11.cmake +24 -0
  43. hyperdrone/_vendor/rl-tools/cmake/dependencies/assimp.cmake +19 -0
  44. hyperdrone/_vendor/rl-tools/cmake/legacy_flags.cmake +33 -0
  45. hyperdrone/_vendor/rl-tools/cmake/optional/assimp.cmake +30 -0
  46. hyperdrone/_vendor/rl-tools/cmake/optional/googletest.cmake +20 -0
  47. hyperdrone/_vendor/rl-tools/cmake/optional/metal.cmake +25 -0
  48. hyperdrone/_vendor/rl-tools/cmake/optional/mujoco.cmake +89 -0
  49. hyperdrone/_vendor/rl-tools/cmake/optional/optix.cmake +25 -0
  50. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing.cmake +105 -0
  51. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing_generic.cmake +2 -0
  52. hyperdrone/_vendor/rl-tools/cmake/optional/vulkan.cmake +4 -0
  53. hyperdrone/_vendor/rl-tools/cmake/optional/webgpu.cmake +24 -0
  54. hyperdrone/_vendor/rl-tools/cmake/scripts/embed_text.cmake +7 -0
  55. hyperdrone/_vendor/rl-tools/cmake/scripts/generate-git-snapshot.cmake +138 -0
  56. hyperdrone/_vendor/rl-tools/include/conta/conta.h +1480 -0
  57. hyperdrone/_vendor/rl-tools/include/metra/metra.h +381 -0
  58. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/matrix.h +143 -0
  59. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_arm.h +33 -0
  60. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu.h +314 -0
  61. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_accelerate.h +37 -0
  62. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_blas.h +67 -0
  63. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_mkl.h +38 -0
  64. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_openblas.h +34 -0
  65. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cuda.h +289 -0
  66. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_dummy.h +20 -0
  67. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_esp32.h +29 -0
  68. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_generic.h +944 -0
  69. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_wasm32.h +13 -0
  70. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/persist_code.h +136 -0
  71. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_arm.h +1 -0
  72. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu.h +94 -0
  73. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_accelerate.h +25 -0
  74. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_blas.h +115 -0
  75. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_mkl.h +25 -0
  76. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_openblas.h +25 -0
  77. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cuda.h +713 -0
  78. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_generic.h +1356 -0
  79. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/persist_code.h +130 -0
  80. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/tensor.h +490 -0
  81. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/arm.h +91 -0
  82. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu.h +210 -0
  83. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_accelerate.h +23 -0
  84. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_blas.h +21 -0
  85. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_emscripten.h +20 -0
  86. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_mkl.h +45 -0
  87. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_openblas.h +56 -0
  88. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_tensorboard.h +34 -0
  89. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda.h +464 -0
  90. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda_streams.h +23 -0
  91. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/devices.h +105 -0
  92. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/dummy.h +55 -0
  93. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/esp32.h +85 -0
  94. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/generic.h +0 -0
  95. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/wasm32.h +59 -0
  96. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/model.h +218 -0
  97. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/operations_generic.h +769 -0
  98. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/persist.h +278 -0
  99. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter.h +100 -0
  100. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter_persist.h +52 -0
  101. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/tensor_operations_generic.h +55 -0
  102. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_backend.h +117 -0
  103. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_interface.h +36 -0
  104. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/l2f.h +98 -0
  105. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_dyn.h +18 -0
  106. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_generic.h +268 -0
  107. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_backend.h +31 -0
  108. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_interface.h +12 -0
  109. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_backend.h +98 -0
  110. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_interface.h +50 -0
  111. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/executor.h +133 -0
  112. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/helper.h +109 -0
  113. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/operations_generic.h +219 -0
  114. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arduino.h +117 -0
  115. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arm.h +56 -0
  116. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu.h +57 -0
  117. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu_tensorboard.h +151 -0
  118. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cuda.h +65 -0
  119. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_dummy.h +45 -0
  120. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_wasm32.h +56 -0
  121. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_arm.h +98 -0
  122. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cpu.h +138 -0
  123. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cuda.h +380 -0
  124. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_dummy.h +93 -0
  125. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_esp32.h +92 -0
  126. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_generic.h +295 -0
  127. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_wasm32.h +230 -0
  128. hyperdrone/_vendor/rl-tools/include/rl_tools/mode/mode.h +98 -0
  129. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/activation_functions.h +113 -0
  130. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/capability.h +61 -0
  131. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/persist_code.h +31 -0
  132. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/group.h +99 -0
  133. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/layer.h +122 -0
  134. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_cuda.h +64 -0
  135. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_generic.h +186 -0
  136. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/persist.h +33 -0
  137. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/layer.h +300 -0
  138. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cpu_mkl.h +590 -0
  139. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cuda.h +809 -0
  140. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_generic.h +1219 -0
  141. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist.h +99 -0
  142. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist_code.h +170 -0
  143. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/layer.h +145 -0
  144. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/dsp.h +63 -0
  145. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/opt.h +173 -0
  146. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu.h +13 -0
  147. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_accelerate.h +66 -0
  148. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_blas.h +282 -0
  149. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_mkl.h +66 -0
  150. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_openblas.h +65 -0
  151. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cuda.h +519 -0
  152. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_dummy.h +8 -0
  153. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/dsp.h +58 -0
  154. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/opt.h +167 -0
  155. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_generic.h +429 -0
  156. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist.h +62 -0
  157. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_code.h +178 -0
  158. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_common.h +59 -0
  159. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/layer.h +188 -0
  160. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_cuda.h +356 -0
  161. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_generic.h +536 -0
  162. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/persist.h +32 -0
  163. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/layer.h +119 -0
  164. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/operations_generic.h +223 -0
  165. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/persist.h +46 -0
  166. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/layer.h +121 -0
  167. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/operations_generic.h +154 -0
  168. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist.h +44 -0
  169. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist_code.h +106 -0
  170. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_cuda.h +602 -0
  171. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_generic.h +251 -0
  172. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/layer.h +206 -0
  173. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/operations_generic.h +889 -0
  174. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist.h +75 -0
  175. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist_code.h +199 -0
  176. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/layers.h +3 -0
  177. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/layer.h +143 -0
  178. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_cuda.h +80 -0
  179. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_generic.h +216 -0
  180. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/persist.h +39 -0
  181. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu.h +1 -0
  182. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_accelerate.h +1 -0
  183. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_blas.h +1 -0
  184. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_mkl.h +3 -0
  185. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_openblas.h +1 -0
  186. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cuda.h +9 -0
  187. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_dummy.h +1 -0
  188. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_generic.h +3 -0
  189. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/layer.h +223 -0
  190. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_cuda.h +138 -0
  191. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_generic.h +446 -0
  192. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/persist.h +70 -0
  193. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/layer.h +154 -0
  194. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_cuda.h +119 -0
  195. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_generic.h +502 -0
  196. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist.h +50 -0
  197. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist_code.h +173 -0
  198. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/layer.h +116 -0
  199. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_cuda.h +156 -0
  200. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_generic.h +295 -0
  201. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist.h +83 -0
  202. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist_code.h +163 -0
  203. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/layer.h +123 -0
  204. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/operations_generic.h +272 -0
  205. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist.h +17 -0
  206. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist_code.h +164 -0
  207. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/layer.h +122 -0
  208. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_cuda.h +55 -0
  209. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_generic.h +160 -0
  210. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist.h +47 -0
  211. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist_code.h +106 -0
  212. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/layer.h +132 -0
  213. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_cuda.h +141 -0
  214. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_generic.h +230 -0
  215. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/categorical_cross_entropy/operations_generic.h +102 -0
  216. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_cuda.h +97 -0
  217. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_generic.h +101 -0
  218. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/operations_generic.h +2 -0
  219. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/nn.h +14 -0
  220. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu.h +1 -0
  221. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_accelerate.h +1 -0
  222. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_blas.h +1 -0
  223. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mkl.h +1 -0
  224. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mux.h +16 -0
  225. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_openblas.h +1 -0
  226. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cuda.h +2 -0
  227. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_dummy.h +1 -0
  228. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_generic.h +15 -0
  229. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/adam.h +121 -0
  230. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_cuda.h +98 -0
  231. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_generic.h +150 -0
  232. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist.h +39 -0
  233. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist_code.h +80 -0
  234. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_cuda.h +85 -0
  235. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_generic.h +109 -0
  236. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/persist.h +25 -0
  237. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/instance/operations_generic.h +107 -0
  238. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/lamb.h +40 -0
  239. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/operations_generic.h +68 -0
  240. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/optimizers.h +3 -0
  241. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_cuda.h +85 -0
  242. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_generic.h +140 -0
  243. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist.h +37 -0
  244. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist_code.h +72 -0
  245. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_cuda.h +49 -0
  246. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_generic.h +50 -0
  247. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/sgd.h +92 -0
  248. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/update.h +54 -0
  249. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_cuda.h +0 -0
  250. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_generic.h +98 -0
  251. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/parameters.h +79 -0
  252. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist.h +34 -0
  253. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist_code.h +136 -0
  254. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist.h +2 -0
  255. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist_code.h +27 -0
  256. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/behaviors/skip_parameter_gradients.h +65 -0
  257. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/README.md +107 -0
  258. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/model.h +19 -0
  259. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/persist_code.h +77 -0
  260. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/network.h +174 -0
  261. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_cuda.h +10 -0
  262. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_dummy.h +8 -0
  263. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_generic.h +407 -0
  264. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist.h +56 -0
  265. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist_code.h +137 -0
  266. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/network.h +55 -0
  267. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/operations_generic.h +86 -0
  268. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist.h +43 -0
  269. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist_code.h +142 -0
  270. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/models.h +3 -0
  271. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/model.h +148 -0
  272. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/operations_generic.h +288 -0
  273. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist.h +25 -0
  274. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist_code.h +71 -0
  275. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cpu.h +0 -0
  276. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cuda.h +1 -0
  277. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_dummy.h +1 -0
  278. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_generic.h +4 -0
  279. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/model.h +290 -0
  280. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_cuda.h +174 -0
  281. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_generic.h +623 -0
  282. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist.h +80 -0
  283. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist_code.h +200 -0
  284. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist.h +1 -0
  285. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist_code.h +1 -0
  286. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/model.h +43 -0
  287. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/operations_generic.h +73 -0
  288. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/resnet/resnet.h +97 -0
  289. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/model.h +270 -0
  290. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/operations_generic.h +625 -0
  291. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist.h +99 -0
  292. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist_code.h +115 -0
  293. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/bf16.h +28 -0
  294. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/categories.h +22 -0
  295. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/persist_code.h +54 -0
  296. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/policy.h +48 -0
  297. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_1.h +18 -0
  298. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_2.h +14 -0
  299. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_3.h +14 -0
  300. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm.h +19 -0
  301. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_1.h +17 -0
  302. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_2.h +12 -0
  303. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_3.h +15 -0
  304. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu.h +19 -0
  305. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_1.h +16 -0
  306. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_2.h +12 -0
  307. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_3.h +15 -0
  308. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate.h +19 -0
  309. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_1.h +17 -0
  310. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_2.h +12 -0
  311. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_3.h +15 -0
  312. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl.h +18 -0
  313. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mux.h +158 -0
  314. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_1.h +16 -0
  315. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_2.h +12 -0
  316. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_3.h +15 -0
  317. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas.h +18 -0
  318. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_1.h +16 -0
  319. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_2.h +12 -0
  320. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_3.h +15 -0
  321. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard.h +19 -0
  322. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_1.h +18 -0
  323. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_2.h +12 -0
  324. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_3.h +12 -0
  325. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda.h +19 -0
  326. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_1.h +15 -0
  327. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_2.h +12 -0
  328. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_3.h +12 -0
  329. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy.h +19 -0
  330. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_1.h +16 -0
  331. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_2.h +12 -0
  332. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_3.h +13 -0
  333. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32.h +19 -0
  334. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_1.h +15 -0
  335. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_2.h +12 -0
  336. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_3.h +12 -0
  337. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32.h +19 -0
  338. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/hdf5.h +54 -0
  339. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/operations_cpu.h +419 -0
  340. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/io.h +55 -0
  341. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_cpu.h +58 -0
  342. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_generic.h +620 -0
  343. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_posix.h +63 -0
  344. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/tar.h +74 -0
  345. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/code.h +38 -0
  346. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_arm.h +39 -0
  347. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cpu.h +81 -0
  348. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cuda.h +172 -0
  349. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_dummy.h +72 -0
  350. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_esp32.h +45 -0
  351. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic.h +133 -0
  352. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic_array.h +73 -0
  353. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_wasm32.h +57 -0
  354. hyperdrone/_vendor/rl-tools/include/rl_tools/random/persist.h +77 -0
  355. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/camera.h +105 -0
  356. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/cache.h +26 -0
  357. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/free_space.h +60 -0
  358. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/operations_cpu.h +411 -0
  359. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/glb.h +25 -0
  360. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/operations_cpu.h +1288 -0
  361. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/operations_cpu.h +136 -0
  362. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/catalog.h +232 -0
  363. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/conversion.h +33 -0
  364. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/operations_cpu.h +123 -0
  365. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/procthor.h +39 -0
  366. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_cpu.h +717 -0
  367. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_generic.h +1283 -0
  368. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/context.h +193 -0
  369. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/device_source.h +17 -0
  370. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/operations_cpu.h +1123 -0
  371. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device.h +207 -0
  372. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device_impl.h +1043 -0
  373. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/operations_cuda.h +1747 -0
  374. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/overlay_accel.h +64 -0
  375. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/specialization.h +37 -0
  376. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/context.h +251 -0
  377. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/device_source.h +48 -0
  378. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/operations_cpu.h +2067 -0
  379. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/bvh_sah.h +182 -0
  380. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/context.h +280 -0
  381. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/device_source.h +17 -0
  382. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/operations_cpu.h +1405 -0
  383. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_common.h +948 -0
  384. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_mux.h +32 -0
  385. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_post.h +96 -0
  386. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/renderer.h +484 -0
  387. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/save_cpu.h +314 -0
  388. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/scene.h +44 -0
  389. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/transforms_generic.h +25 -0
  390. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/types.h +45 -0
  391. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_cpu.h +119 -0
  392. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_generic.h +121 -0
  393. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/rig.h +70 -0
  394. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/scene.h +132 -0
  395. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/segmentation_cpu.h +145 -0
  396. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/transforms.h +204 -0
  397. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/types.h +76 -0
  398. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/algorithms.h +6 -0
  399. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu.h +1 -0
  400. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu_mkl.h +1 -0
  401. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_generic.h +1 -0
  402. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/config.h +243 -0
  403. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_cuda.h +9 -0
  404. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_generic.h +205 -0
  405. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/persist.h +109 -0
  406. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/state.h +51 -0
  407. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/mixed_imitation.h +63 -0
  408. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_cuda.h +190 -0
  409. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic.h +332 -0
  410. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic_mixed_imitation.h +81 -0
  411. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/persist.h +28 -0
  412. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/ppo.h +105 -0
  413. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_gru.h +84 -0
  414. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_mlp.h +61 -0
  415. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/config.h +106 -0
  416. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/operations_generic.h +193 -0
  417. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/state.h +52 -0
  418. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu.h +9 -0
  419. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_accelerate.h +2 -0
  420. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mkl.h +2 -0
  421. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mux.h +9 -0
  422. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cuda.h +131 -0
  423. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_generic.h +580 -0
  424. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/sac.h +151 -0
  425. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_gru.h +72 -0
  426. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_mlp.h +54 -0
  427. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/config.h +107 -0
  428. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/operations_generic.h +174 -0
  429. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/state.h +46 -0
  430. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu.h +9 -0
  431. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_accelerate.h +2 -0
  432. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mkl.h +2 -0
  433. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mux.h +9 -0
  434. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cuda.h +117 -0
  435. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_generic.h +359 -0
  436. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/td3.h +141 -0
  437. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/components.h +4 -0
  438. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/off_policy_runner.h +225 -0
  439. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu.h +95 -0
  440. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_accelerate.h +21 -0
  441. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_mkl.h +21 -0
  442. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cuda.h +237 -0
  443. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic.h +498 -0
  444. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic_per_env.h +112 -0
  445. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/collection.h +57 -0
  446. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/on_policy_runner.h +122 -0
  447. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu.h +2 -0
  448. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_accelerate.h +8 -0
  449. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mkl.h +8 -0
  450. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mux.h +12 -0
  451. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cuda.h +183 -0
  452. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic.h +366 -0
  453. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic_common.h +74 -0
  454. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/persist.h +47 -0
  455. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu.h +2 -0
  456. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_accelerate.h +1 -0
  457. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_mkl.h +1 -0
  458. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_generic.h +2 -0
  459. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_cpu.h +9 -0
  460. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_generic.h +123 -0
  461. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/persist.h +57 -0
  462. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/replay_buffer.h +93 -0
  463. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/operations_generic.h +76 -0
  464. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/persist.h +31 -0
  465. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/running_normalizer.h +33 -0
  466. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/operations_generic.h +58 -0
  467. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/operations_generic.h +28 -0
  468. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/wrapper.h +26 -0
  469. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/wrappers.h +29 -0
  470. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/acrobot.h +88 -0
  471. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_cpu.h +152 -0
  472. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_generic.h +202 -0
  473. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/environment.h +40 -0
  474. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_cuda.h +204 -0
  475. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic.h +106 -0
  476. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic_common.h +26 -0
  477. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/persist.h +33 -0
  478. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/car.h +119 -0
  479. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_cpu.h +110 -0
  480. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_generic.h +206 -0
  481. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_json.h +59 -0
  482. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/track.h +23 -0
  483. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/ui.h +189 -0
  484. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/environments.h +28 -0
  485. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/environment.h +87 -0
  486. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_cpu.h +212 -0
  487. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_generic.h +215 -0
  488. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/observation.h +75 -0
  489. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cpu.h +1063 -0
  490. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cuda.h +564 -0
  491. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/pose.h +253 -0
  492. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/presets.h +154 -0
  493. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_cpu.h +26 -0
  494. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_generic.h +91 -0
  495. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/raptor.h +71 -0
  496. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_cpu.h +190 -0
  497. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_generic.h +32 -0
  498. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/rig.h +25 -0
  499. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cpu.h +86 -0
  500. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cuda.h +69 -0
  501. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_optix.h +163 -0
  502. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu.h +223 -0
  503. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu_spectator.h +194 -0
  504. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda.h +1 -0
  505. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda_spectator.h +109 -0
  506. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spectator.h +82 -0
  507. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spy.h +107 -0
  508. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/ui.h +30 -0
  509. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/moving_gate.h +103 -0
  510. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cpu.h +279 -0
  511. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cuda.h +242 -0
  512. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cpu.h +322 -0
  513. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cuda.h +312 -0
  514. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_generic_position_hold.h +128 -0
  515. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/position_hold.h +22 -0
  516. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/target_frame.h +92 -0
  517. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/baseline.h +46 -0
  518. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/calibration.h +62 -0
  519. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/metrics.h +101 -0
  520. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/operations_cpu.h +374 -0
  521. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/visual_inertial_localization.h +126 -0
  522. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/world.h +333 -0
  523. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/inertial_velocity.h +27 -0
  524. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/metrics.h +266 -0
  525. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/multirotor.h +1138 -0
  526. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_cpu.h +2252 -0
  527. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/05_state_is_nan.h +148 -0
  528. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/10_sample_initial_parameters.h +228 -0
  529. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/20_initial_state.h +208 -0
  530. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/30_sample_initial_state.h +300 -0
  531. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/35_get_desired_state.h +63 -0
  532. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/40_observe.h +637 -0
  533. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/50_state_algebra.h +57 -0
  534. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/60_dynamics.h +134 -0
  535. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/70_post_integration.h +368 -0
  536. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/80_abs_diff.h +312 -0
  537. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic.h +367 -0
  538. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic_inertial_velocity.h +44 -0
  539. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_helper_generic.h +43 -0
  540. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic.h +70 -0
  541. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic_forward.h +24 -0
  542. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/default.h +209 -0
  543. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/arpl.h +112 -0
  544. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie.h +127 -0
  545. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie_openmv.h +119 -0
  546. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/flightmare.h +111 -0
  547. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/fs.h +113 -0
  548. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/mrs.h +110 -0
  549. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft.h +117 -0
  550. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft_rigid.h +118 -0
  551. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500.h +88 -0
  552. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_real.h +88 -0
  553. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_sim.h +114 -0
  554. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/init/default.h +56 -0
  555. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/registry.h +96 -0
  556. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/default.h +64 -0
  557. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/reward_functions.h +1 -0
  558. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/operations_generic.h +202 -0
  559. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/squared.h +52 -0
  560. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/termination/default.h +33 -0
  561. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/lissajous.h +72 -0
  562. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/trajectory.h +78 -0
  563. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist.h +21 -0
  564. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist_code.h +53 -0
  565. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/quaternion_helper.h +103 -0
  566. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/ui.h +180 -0
  567. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/environment.h +69 -0
  568. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_cpu.h +46 -0
  569. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_generic.h +78 -0
  570. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/README.MD +5 -0
  571. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ant.h +77 -0
  572. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/model.h +415 -0
  573. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/operations_cpu.h +162 -0
  574. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/persist.h +86 -0
  575. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ui.h +141 -0
  576. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/mujoco.h +1 -0
  577. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/bottleneck.h +113 -0
  578. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_cpu.h +289 -0
  579. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_generic.h +495 -0
  580. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/environments.h +16 -0
  581. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/observation.h +37 -0
  582. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_cpu.h +2 -0
  583. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_generic.h +33 -0
  584. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_cpu.h +146 -0
  585. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_generic.h +262 -0
  586. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/pendulum.h +197 -0
  587. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui.h +97 -0
  588. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui_xeus.h +124 -0
  589. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_cpu.h +426 -0
  590. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_generic.h +424 -0
  591. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/reacher.h +137 -0
  592. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/loop.h +15 -0
  593. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/config.h +28 -0
  594. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/operations_cpu.h +233 -0
  595. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/persist.h +30 -0
  596. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/state.h +21 -0
  597. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/config.h +25 -0
  598. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/operations_generic.h +47 -0
  599. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/persist.h +20 -0
  600. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/state.h +17 -0
  601. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/config.h +47 -0
  602. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/operations_generic.h +106 -0
  603. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/persist.h +40 -0
  604. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/state.h +36 -0
  605. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/config.h +22 -0
  606. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/operations_cpu.h +44 -0
  607. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/persist.h +20 -0
  608. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/state.h +26 -0
  609. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/config.h +37 -0
  610. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/operations_cpu.h +113 -0
  611. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/persist.h +20 -0
  612. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/state.h +24 -0
  613. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/config.h +43 -0
  614. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/operations_cpu.h +190 -0
  615. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/persist.h +30 -0
  616. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/state.h +37 -0
  617. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/steps.h +4 -0
  618. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/config.h +27 -0
  619. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/operations_cpu.h +52 -0
  620. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/persist.h +20 -0
  621. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/state.h +25 -0
  622. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/operations_generic.h +3 -0
  623. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/rl.h +5 -0
  624. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/evaluation.h +106 -0
  625. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_cpu.h +48 -0
  626. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_generic.h +275 -0
  627. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation.h +269 -0
  628. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation_analysis.h +85 -0
  629. hyperdrone/_vendor/rl-tools/include/rl_tools/rl_tools.h +80 -0
  630. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/client.h +50 -0
  631. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_boost.h +92 -0
  632. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_cpu.h +174 -0
  633. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_websocket.h +208 -0
  634. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/server.h +448 -0
  635. hyperdrone/_vendor/rl-tools/include/rl_tools/universe.h +4 -0
  636. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu.h +13 -0
  637. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu_emscripten.h +15 -0
  638. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_arm.h +29 -0
  639. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu.h +24 -0
  640. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu_emscripten.h +28 -0
  641. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cuda.h +33 -0
  642. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_dummy.h +18 -0
  643. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_esp32.h +20 -0
  644. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_generic.h +19 -0
  645. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_wasm32.h +18 -0
  646. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_cpu.h +16 -0
  647. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_generic.h +14 -0
  648. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/extrack.h +129 -0
  649. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/operations_cpu.h +588 -0
  650. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/integrators.h +103 -0
  651. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/memcpy.h +16 -0
  652. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/operations_generic.h +48 -0
  653. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/tuple.h +147 -0
  654. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/typing.h +122 -0
  655. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/vector_operations.h +172 -0
  656. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_cuda.h +53 -0
  657. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_generic.h +93 -0
  658. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/string/operations_generic.h +201 -0
  659. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/zlib/operations_cpu.h +45 -0
  660. hyperdrone/_vendor/rl-tools/include/rl_tools/version.h +28 -0
  661. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/CMakeLists.txt +15 -0
  662. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/README.md +214 -0
  663. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/CMakeLists.txt +11 -0
  664. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/CMakeLists.txt +17 -0
  665. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/freestanding_check.cpp +134 -0
  666. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/CMakeLists.txt +31 -0
  667. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/device.metal +912 -0
  668. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/metal_cpp_impl.cpp +6 -0
  669. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/CMakeLists.txt +51 -0
  670. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/device.cu +1 -0
  671. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/overlay_accel.cu +308 -0
  672. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/CMakeLists.txt +37 -0
  673. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device.comp +970 -0
  674. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device_spirv.cpp +44 -0
  675. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/CMakeLists.txt +31 -0
  676. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/device.wgsl +1381 -0
  677. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/CMakeLists.txt +129 -0
  678. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/README.md +131 -0
  679. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark.cpp +180 -0
  680. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark_dynamic.cpp +491 -0
  681. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/download_paper_scene.py +74 -0
  682. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/CMakeLists.txt +104 -0
  683. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Info.plist +36 -0
  684. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Sources/BenchmarkApp.swift +172 -0
  685. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.h +10 -0
  686. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.mm +46 -0
  687. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/build.sh +17 -0
  688. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/rig.cpp +119 -0
  689. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.cpp +1382 -0
  690. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.h +5 -0
  691. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_config.h.in +25 -0
  692. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_identity.cmake +11 -0
  693. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_main.cpp +5 -0
  694. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.cu +125 -0
  695. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.h +58 -0
  696. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_contract.h +179 -0
  697. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_cpu.cpp +77 -0
  698. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/camera_orbit.h +51 -0
  699. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/CMakeLists.txt +199 -0
  700. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/antialiasing.cpp +214 -0
  701. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone.cpp +320 -0
  702. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone_device.cu +359 -0
  703. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/environment.h +96 -0
  704. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/operations_cpu.h +263 -0
  705. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/example.cpp +273 -0
  706. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/fixed_pose.cpp +221 -0
  707. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/flow.cpp +120 -0
  708. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/interactive.cpp +1015 -0
  709. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/make_drone_glb.py +172 -0
  710. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal.cpp +82 -0
  711. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal_overlay.cpp +137 -0
  712. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/motion_blur.cpp +232 -0
  713. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace.cpp +1829 -0
  714. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace_motion_blur.cpp +647 -0
  715. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/CMakeLists.txt +147 -0
  716. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/README.md +15 -0
  717. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/job.sbatch +28 -0
  718. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model.h +260 -0
  719. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_config.h +24 -0
  720. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_forward_cuda.h +397 -0
  721. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_operations.h +418 -0
  722. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_persist.h +45 -0
  723. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_student.h +70 -0
  724. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.cpp +222 -0
  725. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.h +68 -0
  726. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/.gitignore +4 -0
  727. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/CMakeLists.txt +4 -0
  728. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info.plist +24 -0
  729. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info_ios.plist +36 -0
  730. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/CameraManager.swift +120 -0
  731. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/ContentView.swift +703 -0
  732. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/DatasetRecorder.swift +285 -0
  733. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/YawPredictorApp.swift +25 -0
  734. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/YawPredictor.entitlements +8 -0
  735. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build.sh +66 -0
  736. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build_ios.sh +133 -0
  737. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/generate.sh +6 -0
  738. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/h5_to_tar.cpp +82 -0
  739. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.cpp +166 -0
  740. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.h +26 -0
  741. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/project.yml +30 -0
  742. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/test_tar_vs_hdf5.cpp +173 -0
  743. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_cuda.cu +699 -0
  744. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_dataset_overlay.cpp +475 -0
  745. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_distill_cuda.cu +995 -0
  746. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_eval.cu +457 -0
  747. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_real_world_eval.cpp +660 -0
  748. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_viewer.cu +443 -0
  749. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/CMakeLists.txt +63 -0
  750. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/example.cpp +101 -0
  751. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/ui.cpp +380 -0
  752. hyperdrone/dynamics/__init__.py +5 -0
  753. hyperdrone/dynamics/_component.py +31 -0
  754. hyperdrone/dynamics/_config.py +46 -0
  755. hyperdrone/dynamics/_sim.py +166 -0
  756. hyperdrone/env/__init__.py +23 -0
  757. hyperdrone/env/_multi_environment.py +566 -0
  758. hyperdrone/env/_rotorcraft.py +29 -0
  759. hyperdrone/env/_spy.py +39 -0
  760. hyperdrone/examples/.gitignore +3 -0
  761. hyperdrone/examples/Benchmark.ipynb +113 -0
  762. hyperdrone/examples/HyperDrone.ipynb +589 -0
  763. hyperdrone/examples/Orbiter.ipynb +496 -0
  764. hyperdrone/examples/Renderer.ipynb +218 -0
  765. hyperdrone/examples/__init__.py +16 -0
  766. hyperdrone/examples/articulation.py +55 -0
  767. hyperdrone/examples/benchmark.py +236 -0
  768. hyperdrone/examples/benchmark_minimal.py +65 -0
  769. hyperdrone/examples/data.py +71 -0
  770. hyperdrone/examples/drone_flythrough.py +169 -0
  771. hyperdrone/examples/hyperdrone_videos/my_world_preview.h +17 -0
  772. hyperdrone/examples/my_world.h +17 -0
  773. hyperdrone/examples/render_procthor.py +40 -0
  774. hyperdrone/examples/shots.py +108 -0
  775. hyperdrone/examples/spy.py +40 -0
  776. hyperdrone/examples/visual_inertial_localization.py +158 -0
  777. hyperdrone/gym/__init__.py +67 -0
  778. hyperdrone/render/__init__.py +57 -0
  779. hyperdrone/render/_component.py +51 -0
  780. hyperdrone/render/_config.py +76 -0
  781. hyperdrone/render/_renderer.py +498 -0
  782. hyperdrone/render/_rig.py +136 -0
  783. hyperdrone/render/_sampling.py +69 -0
  784. hyperdrone/render/_scene.py +38 -0
  785. hyperdrone/render/datasets.py +15 -0
  786. hyperray-0.0.1.dist-info/METADATA +519 -0
  787. hyperray-0.0.1.dist-info/RECORD +788 -0
  788. hyperray-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,1480 @@
1
+ #ifndef CONTA_CONTA_H
2
+ #define CONTA_CONTA_H
3
+ // conta: client for the sha1 content-addressed asset store; index contract: https://github.com/rl-tools/conta-index (format 1)
4
+ // C++17, optional zlib for gzip decoding; downloads via the curl CLI.
5
+ // A sha1 resolves from <cache>/<sha1>, then the cached index, then the index entry points; downloads are verified against the sha1 and the sha256 the index lists.
6
+ // CONTA_ROOT: read-only store (<root>/data/<sha1>), disables the network. CONTA_URL: fetch <url>/<sha1> directly, without the index. CONTA_CACHE: writable cache directory.
7
+
8
+ #include <algorithm>
9
+ #include <csignal>
10
+ #include <cstdint>
11
+ #include <cstdio>
12
+ #include <cstdlib>
13
+ #include <cstring>
14
+ #include <filesystem>
15
+ #include <fstream>
16
+ #include <iostream>
17
+ #include <iterator>
18
+ #include <map>
19
+ #include <random>
20
+ #include <set>
21
+ #include <string>
22
+ #include <system_error>
23
+ #include <vector>
24
+ #if defined(__APPLE__)
25
+ #include <TargetConditionals.h>
26
+ #endif
27
+ #if defined(RL_TOOLS_ENABLE_ZLIB) || defined(CONTA_ENABLE_ZLIB)
28
+ #include <zlib.h>
29
+ #endif
30
+ #if defined(_WIN32)
31
+ #include <process.h>
32
+ #else
33
+ #include <sys/wait.h>
34
+ #include <unistd.h>
35
+ #endif
36
+
37
+ namespace conta{
38
+ constexpr const char* CACHED_INDEX_NAME = "index-1.json";
39
+ inline std::vector<std::string> default_entry_points(){
40
+ return {
41
+ "https://conta.rl.tools/version/1/meta.json",
42
+ "https://raw.githubusercontent.com/rl-tools/conta-index/main/version/1/meta.json",
43
+ "https://huggingface.co/datasets/rl-tools/conta-index/resolve/main/version/1/meta.json",
44
+ };
45
+ }
46
+ struct Config{
47
+ std::string root;
48
+ std::string cache;
49
+ std::string url_base;
50
+ std::vector<std::string> entry_points = default_entry_points();
51
+ bool compressed_cache = true;
52
+ };
53
+ namespace detail{
54
+ template <std::size_t T_WORDS>
55
+ std::string hex_words(const std::uint32_t (&words)[T_WORDS]){
56
+ std::string hex;
57
+ hex.reserve(T_WORDS * 8);
58
+ for(std::size_t word_i = 0; word_i < T_WORDS; word_i++){
59
+ for(int shift = 28; shift >= 0; shift -= 4){
60
+ hex += "0123456789abcdef"[(words[word_i] >> unsigned(shift)) & 0xFu];
61
+ }
62
+ }
63
+ return hex;
64
+ }
65
+ inline std::uint32_t big_endian_word(const unsigned char* bytes){
66
+ return (std::uint32_t(bytes[0]) << 24u) | (std::uint32_t(bytes[1]) << 16u) | (std::uint32_t(bytes[2]) << 8u) | std::uint32_t(bytes[3]);
67
+ }
68
+ struct Sha1Compression{
69
+ std::uint32_t state[5] = {0x67452301u, 0xEFCDAB89u, 0x98BADCFEu, 0x10325476u, 0xC3D2E1F0u};
70
+ static std::uint32_t rotate_left(std::uint32_t value, unsigned bits){
71
+ return (value << bits) | (value >> (32u - bits));
72
+ }
73
+ void process_block(const unsigned char* block){
74
+ std::uint32_t schedule[80];
75
+ for(unsigned i = 0; i < 16; i++){
76
+ schedule[i] = big_endian_word(block + 4 * i);
77
+ }
78
+ for(unsigned i = 16; i < 80; i++){
79
+ schedule[i] = rotate_left(schedule[i - 3] ^ schedule[i - 8] ^ schedule[i - 14] ^ schedule[i - 16], 1);
80
+ }
81
+ std::uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4];
82
+ for(unsigned i = 0; i < 80; i++){
83
+ std::uint32_t f, k;
84
+ if(i < 20){
85
+ f = (b & c) | (~b & d);
86
+ k = 0x5A827999u;
87
+ }
88
+ else if(i < 40){
89
+ f = b ^ c ^ d;
90
+ k = 0x6ED9EBA1u;
91
+ }
92
+ else if(i < 60){
93
+ f = (b & c) | (b & d) | (c & d);
94
+ k = 0x8F1BBCDCu;
95
+ }
96
+ else{
97
+ f = b ^ c ^ d;
98
+ k = 0xCA62C1D6u;
99
+ }
100
+ std::uint32_t temporary = rotate_left(a, 5) + f + e + k + schedule[i];
101
+ e = d;
102
+ d = c;
103
+ c = rotate_left(b, 30);
104
+ b = a;
105
+ a = temporary;
106
+ }
107
+ state[0] += a;
108
+ state[1] += b;
109
+ state[2] += c;
110
+ state[3] += d;
111
+ state[4] += e;
112
+ }
113
+ };
114
+ struct Sha256Compression{
115
+ std::uint32_t state[8] = {0x6A09E667u, 0xBB67AE85u, 0x3C6EF372u, 0xA54FF53Au, 0x510E527Fu, 0x9B05688Cu, 0x1F83D9ABu, 0x5BE0CD19u};
116
+ static std::uint32_t rotate_right(std::uint32_t value, unsigned bits){
117
+ return (value >> bits) | (value << (32u - bits));
118
+ }
119
+ void process_block(const unsigned char* block){
120
+ static constexpr std::uint32_t ROUND_CONSTANTS[64] = {
121
+ 0x428A2F98u, 0x71374491u, 0xB5C0FBCFu, 0xE9B5DBA5u, 0x3956C25Bu, 0x59F111F1u, 0x923F82A4u, 0xAB1C5ED5u,
122
+ 0xD807AA98u, 0x12835B01u, 0x243185BEu, 0x550C7DC3u, 0x72BE5D74u, 0x80DEB1FEu, 0x9BDC06A7u, 0xC19BF174u,
123
+ 0xE49B69C1u, 0xEFBE4786u, 0x0FC19DC6u, 0x240CA1CCu, 0x2DE92C6Fu, 0x4A7484AAu, 0x5CB0A9DCu, 0x76F988DAu,
124
+ 0x983E5152u, 0xA831C66Du, 0xB00327C8u, 0xBF597FC7u, 0xC6E00BF3u, 0xD5A79147u, 0x06CA6351u, 0x14292967u,
125
+ 0x27B70A85u, 0x2E1B2138u, 0x4D2C6DFCu, 0x53380D13u, 0x650A7354u, 0x766A0ABBu, 0x81C2C92Eu, 0x92722C85u,
126
+ 0xA2BFE8A1u, 0xA81A664Bu, 0xC24B8B70u, 0xC76C51A3u, 0xD192E819u, 0xD6990624u, 0xF40E3585u, 0x106AA070u,
127
+ 0x19A4C116u, 0x1E376C08u, 0x2748774Cu, 0x34B0BCB5u, 0x391C0CB3u, 0x4ED8AA4Au, 0x5B9CCA4Fu, 0x682E6FF3u,
128
+ 0x748F82EEu, 0x78A5636Fu, 0x84C87814u, 0x8CC70208u, 0x90BEFFFAu, 0xA4506CEBu, 0xBEF9A3F7u, 0xC67178F2u};
129
+ std::uint32_t schedule[64];
130
+ for(unsigned i = 0; i < 16; i++){
131
+ schedule[i] = big_endian_word(block + 4 * i);
132
+ }
133
+ for(unsigned i = 16; i < 64; i++){
134
+ std::uint32_t sigma0 = rotate_right(schedule[i - 15], 7) ^ rotate_right(schedule[i - 15], 18) ^ (schedule[i - 15] >> 3u);
135
+ std::uint32_t sigma1 = rotate_right(schedule[i - 2], 17) ^ rotate_right(schedule[i - 2], 19) ^ (schedule[i - 2] >> 10u);
136
+ schedule[i] = schedule[i - 16] + sigma0 + schedule[i - 7] + sigma1;
137
+ }
138
+ std::uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4], f = state[5], g = state[6], h = state[7];
139
+ for(unsigned i = 0; i < 64; i++){
140
+ std::uint32_t sum1 = rotate_right(e, 6) ^ rotate_right(e, 11) ^ rotate_right(e, 25);
141
+ std::uint32_t choice = (e & f) ^ (~e & g);
142
+ std::uint32_t temporary1 = h + sum1 + choice + ROUND_CONSTANTS[i] + schedule[i];
143
+ std::uint32_t sum0 = rotate_right(a, 2) ^ rotate_right(a, 13) ^ rotate_right(a, 22);
144
+ std::uint32_t majority = (a & b) ^ (a & c) ^ (b & c);
145
+ std::uint32_t temporary2 = sum0 + majority;
146
+ h = g;
147
+ g = f;
148
+ f = e;
149
+ e = d + temporary1;
150
+ d = c;
151
+ c = b;
152
+ b = a;
153
+ a = temporary1 + temporary2;
154
+ }
155
+ state[0] += a;
156
+ state[1] += b;
157
+ state[2] += c;
158
+ state[3] += d;
159
+ state[4] += e;
160
+ state[5] += f;
161
+ state[6] += g;
162
+ state[7] += h;
163
+ }
164
+ };
165
+ template <typename T_COMPRESSION>
166
+ struct Hash{
167
+ T_COMPRESSION compression;
168
+ std::uint64_t message_length_bits = 0;
169
+ unsigned char buffer[64];
170
+ std::size_t buffer_size = 0;
171
+ void update(const unsigned char* data, std::size_t size){
172
+ message_length_bits += std::uint64_t(size) * 8u;
173
+ while(size > 0){
174
+ std::size_t take = std::min(size, std::size_t(64) - buffer_size);
175
+ std::memcpy(buffer + buffer_size, data, take);
176
+ buffer_size += take;
177
+ data += take;
178
+ size -= take;
179
+ if(buffer_size == 64){
180
+ compression.process_block(buffer);
181
+ buffer_size = 0;
182
+ }
183
+ }
184
+ }
185
+ std::string finalize(){
186
+ std::uint64_t final_length_bits = message_length_bits; // update() below keeps counting, so the length is captured first
187
+ unsigned char padding = 0x80;
188
+ update(&padding, 1);
189
+ unsigned char zero = 0x00;
190
+ while(buffer_size != 56){
191
+ update(&zero, 1);
192
+ }
193
+ unsigned char length_bytes[8];
194
+ for(unsigned i = 0; i < 8; i++){
195
+ length_bytes[i] = static_cast<unsigned char>((final_length_bits >> (56u - 8u * i)) & 0xFFu);
196
+ }
197
+ update(length_bytes, 8);
198
+ return hex_words(compression.state);
199
+ }
200
+ };
201
+ using Sha1 = Hash<Sha1Compression>;
202
+ using Sha256 = Hash<Sha256Compression>;
203
+ template <typename T_CONSUMER>
204
+ bool read_file_chunks(const std::filesystem::path& path, T_CONSUMER&& consumer){
205
+ std::ifstream file(path, std::ios::binary);
206
+ if(!file.is_open()){
207
+ return false;
208
+ }
209
+ std::vector<char> chunk(64 * 1024);
210
+ while(file){
211
+ file.read(chunk.data(), std::streamsize(chunk.size()));
212
+ std::streamsize count = file.gcount();
213
+ if(count > 0){
214
+ consumer(reinterpret_cast<const unsigned char*>(chunk.data()), std::size_t(count));
215
+ }
216
+ }
217
+ return !file.bad();
218
+ }
219
+ inline bool sha1_file(const std::filesystem::path& path, std::string& hex_output){
220
+ Sha1 sha1;
221
+ if(!read_file_chunks(path, [&](const unsigned char* data, std::size_t size){ sha1.update(data, size); })){
222
+ return false;
223
+ }
224
+ hex_output = sha1.finalize();
225
+ return true;
226
+ }
227
+ inline bool digests_file(const std::filesystem::path& path, std::string& sha1_output, std::string& sha256_output){
228
+ Sha1 sha1;
229
+ Sha256 sha256;
230
+ bool read = read_file_chunks(path, [&](const unsigned char* data, std::size_t size){
231
+ sha1.update(data, size);
232
+ sha256.update(data, size);
233
+ });
234
+ if(!read){
235
+ return false;
236
+ }
237
+ sha1_output = sha1.finalize();
238
+ sha256_output = sha256.finalize();
239
+ return true;
240
+ }
241
+ inline std::string sha256_text(const std::string& text){
242
+ Sha256 sha256;
243
+ sha256.update(reinterpret_cast<const unsigned char*>(text.data()), text.size());
244
+ return sha256.finalize();
245
+ }
246
+ inline bool read_file(const std::filesystem::path& path, std::string& output){
247
+ std::ifstream file(path, std::ios::binary);
248
+ if(!file.is_open()){
249
+ return false;
250
+ }
251
+ output.assign(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
252
+ return !file.bad();
253
+ }
254
+ inline bool normalize_hex(std::string& text, std::size_t length){
255
+ if(text.size() != length){
256
+ return false;
257
+ }
258
+ for(char& character: text){
259
+ if(character >= 'A' && character <= 'F'){
260
+ character = char(character - 'A' + 'a');
261
+ }
262
+ bool valid = (character >= '0' && character <= '9') || (character >= 'a' && character <= 'f');
263
+ if(!valid){
264
+ return false;
265
+ }
266
+ }
267
+ return true;
268
+ }
269
+ inline bool normalize_hash(std::string& hash){
270
+ return normalize_hex(hash, 40);
271
+ }
272
+ inline bool is_lowercase_hex(const std::string& text, std::size_t length){
273
+ std::string normalized = text;
274
+ return normalize_hex(normalized, length) && normalized == text;
275
+ }
276
+ inline bool normalize_reference(const std::string& reference, std::string& sha1_output, std::string& error_output){
277
+ std::string hash = reference.rfind("conta:", 0) == 0 ? reference.substr(6) : reference;
278
+ std::string as_sha256 = hash;
279
+ if(normalize_hash(hash)){
280
+ sha1_output = hash;
281
+ return true;
282
+ }
283
+ if(normalize_hex(as_sha256, 64)){
284
+ error_output = "conta: \"" + reference + "\" is a sha256, but conta references are sha1 (40 hexadecimal characters); the sha256 in the index only verifies downloads";
285
+ return false;
286
+ }
287
+ error_output = "conta: invalid hash \"" + reference + "\": expected a sha1 (40 hexadecimal characters)";
288
+ return false;
289
+ }
290
+ inline bool is_lfs_pointer(const std::filesystem::path& path){
291
+ std::error_code error_code;
292
+ std::uintmax_t size = std::filesystem::file_size(path, error_code);
293
+ if(error_code || size >= 1024){
294
+ return false;
295
+ }
296
+ constexpr char PREFIX[] = "version https://git-lfs";
297
+ constexpr std::size_t PREFIX_LENGTH = sizeof(PREFIX) - 1;
298
+ char head[PREFIX_LENGTH];
299
+ std::ifstream file(path, std::ios::binary);
300
+ if(!file.read(head, PREFIX_LENGTH)){
301
+ return false;
302
+ }
303
+ return std::memcmp(head, PREFIX, PREFIX_LENGTH) == 0;
304
+ }
305
+ struct JsonReader{
306
+ static constexpr int MAXIMUM_DEPTH = 64;
307
+ const std::string& text;
308
+ std::size_t position = 0;
309
+ explicit JsonReader(const std::string& text_input): text(text_input){}
310
+ void skip_whitespace(){
311
+ while(position < text.size() && (text[position] == ' ' || text[position] == '\t' || text[position] == '\n' || text[position] == '\r')){
312
+ position++;
313
+ }
314
+ }
315
+ bool next_is(char character){
316
+ skip_whitespace();
317
+ return position < text.size() && text[position] == character;
318
+ }
319
+ bool consume(char character){
320
+ if(!next_is(character)){
321
+ return false;
322
+ }
323
+ position++;
324
+ return true;
325
+ }
326
+ bool at_end(){
327
+ skip_whitespace();
328
+ return position == text.size();
329
+ }
330
+ bool digit_at(std::size_t index) const{
331
+ return index < text.size() && text[index] >= '0' && text[index] <= '9';
332
+ }
333
+ bool consume_literal(const char* literal){
334
+ std::size_t length = std::strlen(literal);
335
+ if(text.compare(position, length, literal) != 0){
336
+ return false;
337
+ }
338
+ position += length;
339
+ return true;
340
+ }
341
+ bool read_code_unit(std::uint32_t& value){
342
+ if(position + 4 > text.size()){
343
+ return false;
344
+ }
345
+ value = 0;
346
+ for(int digit_i = 0; digit_i < 4; digit_i++){
347
+ char character = text[position++];
348
+ value <<= 4u;
349
+ if(character >= '0' && character <= '9'){
350
+ value |= std::uint32_t(character - '0');
351
+ }
352
+ else if(character >= 'a' && character <= 'f'){
353
+ value |= std::uint32_t(character - 'a' + 10);
354
+ }
355
+ else if(character >= 'A' && character <= 'F'){
356
+ value |= std::uint32_t(character - 'A' + 10);
357
+ }
358
+ else{
359
+ return false;
360
+ }
361
+ }
362
+ return true;
363
+ }
364
+ static void append_utf8(std::string& output, std::uint32_t code_point){
365
+ if(code_point < 0x80u){
366
+ output += char(code_point);
367
+ }
368
+ else if(code_point < 0x800u){
369
+ output += char(0xC0u | (code_point >> 6u));
370
+ output += char(0x80u | (code_point & 0x3Fu));
371
+ }
372
+ else if(code_point < 0x10000u){
373
+ output += char(0xE0u | (code_point >> 12u));
374
+ output += char(0x80u | ((code_point >> 6u) & 0x3Fu));
375
+ output += char(0x80u | (code_point & 0x3Fu));
376
+ }
377
+ else{
378
+ output += char(0xF0u | (code_point >> 18u));
379
+ output += char(0x80u | ((code_point >> 12u) & 0x3Fu));
380
+ output += char(0x80u | ((code_point >> 6u) & 0x3Fu));
381
+ output += char(0x80u | (code_point & 0x3Fu));
382
+ }
383
+ }
384
+ bool parse_string(std::string& output){
385
+ if(!consume('"')){
386
+ return false;
387
+ }
388
+ output.clear();
389
+ while(position < text.size()){
390
+ unsigned char character = static_cast<unsigned char>(text[position++]);
391
+ if(character == '"'){
392
+ return true;
393
+ }
394
+ if(character < 0x20u){
395
+ return false;
396
+ }
397
+ if(character != '\\'){
398
+ output += char(character);
399
+ continue;
400
+ }
401
+ if(position >= text.size()){
402
+ return false;
403
+ }
404
+ char escape = text[position++];
405
+ switch(escape){
406
+ case '"': output += '"'; break;
407
+ case '\\': output += '\\'; break;
408
+ case '/': output += '/'; break;
409
+ case 'b': output += '\b'; break;
410
+ case 'f': output += '\f'; break;
411
+ case 'n': output += '\n'; break;
412
+ case 'r': output += '\r'; break;
413
+ case 't': output += '\t'; break;
414
+ case 'u': {
415
+ std::uint32_t code_point;
416
+ if(!read_code_unit(code_point)){
417
+ return false;
418
+ }
419
+ if(code_point >= 0xD800u && code_point <= 0xDBFFu){
420
+ std::size_t high_end = position;
421
+ std::uint32_t low = 0;
422
+ if(text.compare(position, 2, "\\u") == 0){
423
+ position += 2;
424
+ }
425
+ if(position != high_end && read_code_unit(low) && low >= 0xDC00u && low <= 0xDFFFu){
426
+ code_point = 0x10000u + ((code_point - 0xD800u) << 10u) + (low - 0xDC00u);
427
+ }
428
+ else{
429
+ position = high_end;
430
+ code_point = 0xFFFDu;
431
+ }
432
+ }
433
+ else if(code_point >= 0xDC00u && code_point <= 0xDFFFu){
434
+ code_point = 0xFFFDu;
435
+ }
436
+ append_utf8(output, code_point);
437
+ break;
438
+ }
439
+ default: return false;
440
+ }
441
+ }
442
+ return false;
443
+ }
444
+ bool parse_number(std::string& token){
445
+ skip_whitespace();
446
+ std::size_t start = position;
447
+ if(position < text.size() && text[position] == '-'){
448
+ position++;
449
+ }
450
+ if(position < text.size() && text[position] == '0'){
451
+ position++;
452
+ }
453
+ else if(digit_at(position)){
454
+ while(digit_at(position)){
455
+ position++;
456
+ }
457
+ }
458
+ else{
459
+ return false;
460
+ }
461
+ if(position < text.size() && text[position] == '.'){
462
+ position++;
463
+ if(!digit_at(position)){
464
+ return false;
465
+ }
466
+ while(digit_at(position)){
467
+ position++;
468
+ }
469
+ }
470
+ if(position < text.size() && (text[position] == 'e' || text[position] == 'E')){
471
+ position++;
472
+ if(position < text.size() && (text[position] == '+' || text[position] == '-')){
473
+ position++;
474
+ }
475
+ if(!digit_at(position)){
476
+ return false;
477
+ }
478
+ while(digit_at(position)){
479
+ position++;
480
+ }
481
+ }
482
+ token = text.substr(start, position - start);
483
+ return true;
484
+ }
485
+ template <typename T_CALLBACK>
486
+ bool parse_object(int depth, T_CALLBACK&& callback){
487
+ if(depth > MAXIMUM_DEPTH || !consume('{')){
488
+ return false;
489
+ }
490
+ if(consume('}')){
491
+ return true;
492
+ }
493
+ do{
494
+ std::string key;
495
+ if(!parse_string(key) || !consume(':') || !callback(key)){
496
+ return false;
497
+ }
498
+ } while(consume(','));
499
+ return consume('}');
500
+ }
501
+ template <typename T_CALLBACK>
502
+ bool parse_array(int depth, T_CALLBACK&& callback){
503
+ if(depth > MAXIMUM_DEPTH || !consume('[')){
504
+ return false;
505
+ }
506
+ if(consume(']')){
507
+ return true;
508
+ }
509
+ do{
510
+ if(!callback()){
511
+ return false;
512
+ }
513
+ } while(consume(','));
514
+ return consume(']');
515
+ }
516
+ bool skip_value(int depth){
517
+ if(depth > MAXIMUM_DEPTH){
518
+ return false;
519
+ }
520
+ skip_whitespace();
521
+ if(position >= text.size()){
522
+ return false;
523
+ }
524
+ char character = text[position];
525
+ if(character == '{'){
526
+ return parse_object(depth, [&](const std::string&){ return skip_value(depth + 1); });
527
+ }
528
+ if(character == '['){
529
+ return parse_array(depth, [&](){ return skip_value(depth + 1); });
530
+ }
531
+ if(character == '"'){
532
+ std::string ignored;
533
+ return parse_string(ignored);
534
+ }
535
+ if(character == 't'){
536
+ return consume_literal("true");
537
+ }
538
+ if(character == 'f'){
539
+ return consume_literal("false");
540
+ }
541
+ if(character == 'n'){
542
+ return consume_literal("null");
543
+ }
544
+ std::string ignored;
545
+ return parse_number(ignored);
546
+ }
547
+ bool parse_string_or_skip(std::string& output, int depth){
548
+ if(next_is('"')){
549
+ return parse_string(output);
550
+ }
551
+ output.clear();
552
+ return skip_value(depth);
553
+ }
554
+ bool parse_number_or_skip(std::string& token, int depth){
555
+ skip_whitespace();
556
+ if(position < text.size() && (text[position] == '-' || digit_at(position))){
557
+ return parse_number(token);
558
+ }
559
+ token.clear();
560
+ return skip_value(depth);
561
+ }
562
+ };
563
+ struct Meta{
564
+ bool format_supported = false;
565
+ std::string location;
566
+ std::string sha256;
567
+ };
568
+ struct ShardLocation{
569
+ std::string id;
570
+ std::vector<std::string> compressed;
571
+ };
572
+ struct Entry{
573
+ std::string sha256;
574
+ std::vector<ShardLocation> shards;
575
+ std::string description;
576
+ std::string notice;
577
+ };
578
+ struct Index{
579
+ std::string source;
580
+ std::string sha256;
581
+ std::size_t entry_count = 0;
582
+ std::map<std::string, std::string> shard_urls;
583
+ std::map<std::string, Entry> entries;
584
+ };
585
+ inline bool parse_meta(const std::string& text, Meta& meta){
586
+ JsonReader reader(text);
587
+ bool parsed = reader.parse_object(0, [&](const std::string& key){
588
+ if(key == "format"){
589
+ std::string token;
590
+ if(!reader.parse_number_or_skip(token, 1)){
591
+ return false;
592
+ }
593
+ meta.format_supported = token == "1";
594
+ return true;
595
+ }
596
+ if(key == "index" && reader.next_is('{')){
597
+ return reader.parse_object(1, [&](const std::string& index_key){
598
+ if(index_key == "location"){
599
+ return reader.parse_string_or_skip(meta.location, 2);
600
+ }
601
+ if(index_key == "sha256"){
602
+ return reader.parse_string_or_skip(meta.sha256, 2);
603
+ }
604
+ return reader.skip_value(2);
605
+ });
606
+ }
607
+ return reader.skip_value(1);
608
+ });
609
+ return parsed && reader.at_end();
610
+ }
611
+ inline bool parse_index(const std::string& text, const std::set<std::string>& wanted, Index& index){
612
+ JsonReader reader(text);
613
+ bool has_shards = false;
614
+ bool has_entries = false;
615
+ bool parsed = reader.parse_object(0, [&](const std::string& key){
616
+ if(key == "shards" && reader.next_is('{')){
617
+ has_shards = true;
618
+ return reader.parse_object(1, [&](const std::string& shard){
619
+ if(!reader.next_is('{')){
620
+ return reader.skip_value(2);
621
+ }
622
+ std::string url;
623
+ bool shard_parsed = reader.parse_object(2, [&](const std::string& shard_key){
624
+ if(shard_key == "url"){
625
+ return reader.parse_string_or_skip(url, 3);
626
+ }
627
+ return reader.skip_value(3);
628
+ });
629
+ if(shard_parsed && !url.empty()){
630
+ index.shard_urls[shard] = url;
631
+ }
632
+ return shard_parsed;
633
+ });
634
+ }
635
+ if(key == "entries" && reader.next_is('[')){
636
+ has_entries = true;
637
+ return reader.parse_array(1, [&](){
638
+ if(!reader.next_is('{')){
639
+ return reader.skip_value(2);
640
+ }
641
+ std::string sha1;
642
+ Entry entry;
643
+ bool entry_parsed = reader.parse_object(2, [&](const std::string& entry_key){
644
+ if(entry_key == "sha1"){
645
+ return reader.parse_string_or_skip(sha1, 3);
646
+ }
647
+ if(entry_key == "sha256"){
648
+ return reader.parse_string_or_skip(entry.sha256, 3);
649
+ }
650
+ if(entry_key == "description"){
651
+ return reader.parse_string_or_skip(entry.description, 3);
652
+ }
653
+ if(entry_key == "notice"){
654
+ return reader.parse_string_or_skip(entry.notice, 3);
655
+ }
656
+ if(entry_key == "shards" && reader.next_is('[')){
657
+ entry.shards.clear();
658
+ return reader.parse_array(3, [&](){
659
+ if(!reader.next_is('{')){
660
+ return reader.skip_value(4);
661
+ }
662
+ ShardLocation shard;
663
+ bool shard_parsed = reader.parse_object(4, [&](const std::string& shard_key){
664
+ if(shard_key == "id"){
665
+ return reader.parse_string_or_skip(shard.id, 5);
666
+ }
667
+ if(shard_key == "compressed" && reader.next_is('[')){
668
+ return reader.parse_array(5, [&](){
669
+ std::string compression;
670
+ if(!reader.parse_string_or_skip(compression, 6)){
671
+ return false;
672
+ }
673
+ if(!compression.empty()){
674
+ shard.compressed.push_back(compression);
675
+ }
676
+ return true;
677
+ });
678
+ }
679
+ return reader.skip_value(5);
680
+ });
681
+ if(!shard_parsed){
682
+ return false;
683
+ }
684
+ if(!shard.id.empty()){
685
+ entry.shards.push_back(std::move(shard));
686
+ }
687
+ return true;
688
+ });
689
+ }
690
+ return reader.skip_value(3);
691
+ });
692
+ if(!entry_parsed){
693
+ return false;
694
+ }
695
+ if(is_lowercase_hex(sha1, 40) && is_lowercase_hex(entry.sha256, 64)){
696
+ index.entry_count++;
697
+ if(wanted.count(sha1) > 0 && index.entries.count(sha1) == 0){
698
+ index.entries.emplace(sha1, std::move(entry));
699
+ }
700
+ }
701
+ return true;
702
+ });
703
+ }
704
+ return reader.skip_value(1);
705
+ });
706
+ return parsed && reader.at_end() && has_shards && has_entries;
707
+ }
708
+ inline bool is_alphanumeric(char character){
709
+ return (character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z') || (character >= '0' && character <= '9');
710
+ }
711
+ inline bool is_document_url(const std::string& url){
712
+ std::size_t start;
713
+ if(url.rfind("https://", 0) == 0){
714
+ start = 8;
715
+ }
716
+ else if(url.rfind("http://", 0) == 0){
717
+ start = 7;
718
+ }
719
+ else if(url.rfind("file:///", 0) == 0){
720
+ start = 8;
721
+ }
722
+ else{
723
+ return false;
724
+ }
725
+ if(start >= url.size() || !is_alphanumeric(url[start])){
726
+ return false;
727
+ }
728
+ for(std::size_t character_i = start; character_i < url.size(); character_i++){
729
+ char character = url[character_i];
730
+ if(!is_alphanumeric(character) && (character == '\0' || std::strchr("._~:/?&#=+,;@-", character) == nullptr)){
731
+ return false;
732
+ }
733
+ }
734
+ return true;
735
+ }
736
+ inline bool resolve_location(const std::string& entry_point, const std::string& location, std::string& url_output){
737
+ if(location.find("://") != std::string::npos){
738
+ if(!is_document_url(location)){
739
+ return false;
740
+ }
741
+ url_output = location;
742
+ return true;
743
+ }
744
+ if(location.empty() || location[0] == '/' || location.find("..") != std::string::npos){
745
+ return false;
746
+ }
747
+ for(char character: location){
748
+ if(!is_alphanumeric(character) && character != '.' && character != '_' && character != '~' && character != '-' && character != '/'){
749
+ return false;
750
+ }
751
+ }
752
+ std::size_t slash = entry_point.rfind('/');
753
+ if(slash == std::string::npos){
754
+ return false;
755
+ }
756
+ url_output = entry_point.substr(0, slash + 1) + location;
757
+ return true;
758
+ }
759
+ inline void replace_all(std::string& text, const std::string& pattern, const std::string& replacement){
760
+ for(std::size_t position = text.find(pattern); position != std::string::npos; position = text.find(pattern, position + replacement.size())){
761
+ text.replace(position, pattern.size(), replacement);
762
+ }
763
+ }
764
+ inline bool shard_location(const std::string& url_template, const std::string& sha1, const std::string& sha256, std::string& url_output){
765
+ std::string url = url_template;
766
+ replace_all(url, "{sha1}", sha1);
767
+ replace_all(url, "{sha256}", sha256);
768
+ if(url.find_first_of("{}") != std::string::npos || !is_document_url(url)){
769
+ return false;
770
+ }
771
+ url_output = url;
772
+ return true;
773
+ }
774
+ inline std::string printable(const std::string& text){
775
+ std::string output;
776
+ for(char character: text.substr(0, 4096)){
777
+ unsigned char byte = static_cast<unsigned char>(character);
778
+ output += byte >= 0x20u && byte <= 0x7Eu ? character : '?';
779
+ }
780
+ return output;
781
+ }
782
+ inline bool shell_quote(const std::string& input, std::string& output){
783
+ #if defined(_WIN32)
784
+ if(input.find_first_of("\"%!") != std::string::npos){
785
+ return false;
786
+ }
787
+ output = "\"" + input + "\"";
788
+ #else
789
+ if(input.find('\'') != std::string::npos){
790
+ return false;
791
+ }
792
+ output = "'" + input + "'";
793
+ #endif
794
+ return true;
795
+ }
796
+ inline long process_id(){
797
+ #if defined(_WIN32)
798
+ return _getpid();
799
+ #else
800
+ return long(getpid());
801
+ #endif
802
+ }
803
+ inline std::string unique_suffix(){
804
+ std::random_device device;
805
+ char random_hex[9];
806
+ std::snprintf(random_hex, sizeof(random_hex), "%08x", static_cast<unsigned int>(device()));
807
+ return std::to_string(process_id()) + "-" + random_hex;
808
+ }
809
+ inline int command_exit_code(int status){
810
+ #if defined(_WIN32)
811
+ return status;
812
+ #else
813
+ if(status != -1 && WIFSIGNALED(status)){
814
+ int signal_number = WTERMSIG(status);
815
+ if(signal_number == SIGINT || signal_number == SIGQUIT){ // std::system ignores both in the caller, so a Ctrl-C that killed curl is re-raised here
816
+ std::raise(signal_number);
817
+ }
818
+ return 128 + signal_number;
819
+ }
820
+ if(status == -1 || !WIFEXITED(status)){
821
+ return -1;
822
+ }
823
+ return WEXITSTATUS(status);
824
+ #endif
825
+ }
826
+ inline std::string curl_failure(int code){
827
+ std::string described = "curl exit status " + std::to_string(code);
828
+ if(code == 127 || code == 9009){
829
+ return described + ": is curl installed and on the PATH?";
830
+ }
831
+ if(code == 22){
832
+ return described + ": HTTP error, the host does not serve it";
833
+ }
834
+ if(code == 37){
835
+ return described + ": file not found";
836
+ }
837
+ if(code == 6 || code == 7 || code == 28){
838
+ return described + ": host unreachable or transfer stalled";
839
+ }
840
+ if(code == 35 || code == 51 || code == 53 || code == 58 || code == 59 || code == 60 || code == 77 || code == 83 || code == 90 || code == 91){
841
+ return described + ": TLS failed; in an old environment point CURL_CA_BUNDLE or SSL_CERT_FILE at a current CA bundle";
842
+ }
843
+ return described;
844
+ }
845
+ inline bool run_curl(const std::string& url, const std::filesystem::path& output, bool quiet, std::string& failure_output){
846
+ #if defined(__APPLE__) && TARGET_OS_IOS
847
+ failure_output = "downloads are unavailable on iOS; bundle the asset in CONTA_ROOT";
848
+ return false;
849
+ #else
850
+ std::string quoted_url, quoted_output;
851
+ if(!shell_quote(url, quoted_url)){
852
+ failure_output = "unsupported character in the URL";
853
+ return false;
854
+ }
855
+ if(!shell_quote(output.string(), quoted_output)){
856
+ failure_output = "unsupported character in the path " + output.string();
857
+ return false;
858
+ }
859
+ std::string command = std::string("curl -f -L -g ") + (quiet ? "-sS " : "") + "--retry 3 --connect-timeout 15 --speed-limit 1024 --speed-time 60 -o " + quoted_output + " " + quoted_url;
860
+ int code = command_exit_code(std::system(command.c_str()));
861
+ if(code != 0){
862
+ failure_output = curl_failure(code);
863
+ return false;
864
+ }
865
+ return true;
866
+ #endif
867
+ }
868
+ constexpr bool gzip_supported(){
869
+ #if defined(RL_TOOLS_ENABLE_ZLIB) || defined(CONTA_ENABLE_ZLIB)
870
+ return true;
871
+ #else
872
+ return false;
873
+ #endif
874
+ }
875
+ inline bool verify_digests(const std::string& actual_sha1, const std::string& actual_sha256, const std::string& sha1, const std::string& sha256, std::string& failure_output){
876
+ if(actual_sha1 != sha1){
877
+ failure_output = "hash mismatch: the content hashes to " + actual_sha1 + ", not caching";
878
+ return false;
879
+ }
880
+ if(!sha256.empty() && actual_sha256 != sha256){
881
+ failure_output = "sha256 mismatch: the index lists " + sha256 + " but the content hashes to " + actual_sha256 + ", not caching";
882
+ return false;
883
+ }
884
+ return true;
885
+ }
886
+ inline bool same_file_contents(const std::filesystem::path& left, const std::filesystem::path& right){
887
+ std::error_code error_code;
888
+ if(!std::filesystem::is_regular_file(right, error_code)){
889
+ return false;
890
+ }
891
+ std::uintmax_t left_size = std::filesystem::file_size(left, error_code);
892
+ if(error_code){
893
+ return false;
894
+ }
895
+ std::uintmax_t right_size = std::filesystem::file_size(right, error_code);
896
+ if(error_code || left_size != right_size){
897
+ return false;
898
+ }
899
+ std::ifstream left_file(left, std::ios::binary), right_file(right, std::ios::binary);
900
+ if(!left_file.is_open() || !right_file.is_open()){
901
+ return false;
902
+ }
903
+ std::vector<char> left_chunk(64 * 1024), right_chunk(64 * 1024);
904
+ while(left_file && right_file){
905
+ left_file.read(left_chunk.data(), std::streamsize(left_chunk.size()));
906
+ right_file.read(right_chunk.data(), std::streamsize(right_chunk.size()));
907
+ if(left_file.gcount() != right_file.gcount() || !std::equal(left_chunk.begin(), left_chunk.begin() + left_file.gcount(), right_chunk.begin())){
908
+ return false;
909
+ }
910
+ }
911
+ return left_file.eof() && right_file.eof() && !left_file.bad() && !right_file.bad();
912
+ }
913
+ inline bool publish_file(const std::filesystem::path& temporary, const std::filesystem::path& target, std::string& failure_output){
914
+ std::error_code error_code;
915
+ std::filesystem::rename(temporary, target, error_code);
916
+ if(error_code){
917
+ if(same_file_contents(temporary, target)){
918
+ std::filesystem::remove(temporary, error_code);
919
+ return true;
920
+ }
921
+ failure_output = "failed to move " + temporary.string() + " to " + target.string() + ": " + error_code.message();
922
+ std::filesystem::remove(temporary, error_code);
923
+ return false;
924
+ }
925
+ return true;
926
+ }
927
+ template <typename T_CONSUMER>
928
+ bool read_gzip_chunks(const std::filesystem::path& path, T_CONSUMER&& consumer, std::string& failure_output){
929
+ #if defined(RL_TOOLS_ENABLE_ZLIB) || defined(CONTA_ENABLE_ZLIB)
930
+ std::ifstream file(path, std::ios::binary);
931
+ if(!file.is_open()){
932
+ failure_output = "the gzip file is unreadable";
933
+ return false;
934
+ }
935
+ struct Inflater{
936
+ z_stream stream{};
937
+ bool initialized = false;
938
+ ~Inflater(){
939
+ if(initialized){
940
+ inflateEnd(&stream);
941
+ }
942
+ }
943
+ } inflater;
944
+ z_stream& stream = inflater.stream;
945
+ if(inflateInit2(&stream, 16 + MAX_WBITS) != Z_OK){
946
+ failure_output = "failed to initialize gzip decoding";
947
+ return false;
948
+ }
949
+ inflater.initialized = true;
950
+ std::vector<unsigned char> input(64 * 1024), output(64 * 1024);
951
+ bool member_end = false;
952
+ while(true){
953
+ if(stream.avail_in == 0 && !file.eof()){
954
+ file.read(reinterpret_cast<char*>(input.data()), std::streamsize(input.size()));
955
+ if(file.bad()){
956
+ failure_output = "failed to read the gzip file";
957
+ return false;
958
+ }
959
+ stream.next_in = input.data();
960
+ stream.avail_in = uInt(file.gcount());
961
+ }
962
+ if(member_end){
963
+ while(stream.avail_in > 0 && *stream.next_in == 0){
964
+ stream.next_in++;
965
+ stream.avail_in--;
966
+ }
967
+ if(stream.avail_in == 0){
968
+ if(file.eof()){
969
+ return true;
970
+ }
971
+ continue;
972
+ }
973
+ Bytef* next_in = stream.next_in;
974
+ uInt available = stream.avail_in;
975
+ if(inflateReset2(&stream, 16 + MAX_WBITS) != Z_OK){
976
+ failure_output = "failed to reset gzip decoding";
977
+ return false;
978
+ }
979
+ stream.next_in = next_in;
980
+ stream.avail_in = available;
981
+ member_end = false;
982
+ }
983
+ stream.next_out = output.data();
984
+ stream.avail_out = uInt(output.size());
985
+ int status = inflate(&stream, Z_NO_FLUSH);
986
+ if(status != Z_OK && status != Z_STREAM_END){
987
+ failure_output = status == Z_BUF_ERROR ? "truncated gzip file" : "invalid gzip file";
988
+ if(stream.msg != nullptr){
989
+ failure_output += ": " + std::string(stream.msg);
990
+ }
991
+ return false;
992
+ }
993
+ std::size_t count = output.size() - stream.avail_out;
994
+ if(count > 0 && !consumer(output.data(), count)){
995
+ failure_output = "failed to write the decompressed content";
996
+ return false;
997
+ }
998
+ member_end = status == Z_STREAM_END;
999
+ }
1000
+ #else
1001
+ (void)path;
1002
+ (void)consumer;
1003
+ failure_output = "gzip decoding is unavailable; build with CONTA_ENABLE_ZLIB and link zlib, or provide the plain blob";
1004
+ return false;
1005
+ #endif
1006
+ }
1007
+ inline bool decode_gzip(const std::filesystem::path& source, const std::string& sha1, const std::string& sha256, const std::filesystem::path& target, std::vector<std::uint8_t>* bytes_output, std::string& failure_output){
1008
+ std::filesystem::path temporary;
1009
+ std::ofstream file;
1010
+ std::vector<std::uint8_t> bytes;
1011
+ if(bytes_output == nullptr){
1012
+ temporary = target;
1013
+ temporary += ".partial." + unique_suffix();
1014
+ file.open(temporary, std::ios::binary);
1015
+ if(!file.is_open()){
1016
+ failure_output = "failed to create " + temporary.string();
1017
+ return false;
1018
+ }
1019
+ }
1020
+ Sha1 actual_sha1;
1021
+ Sha256 actual_sha256;
1022
+ bool decoded = read_gzip_chunks(source, [&](const unsigned char* data, std::size_t size){
1023
+ actual_sha1.update(data, size);
1024
+ actual_sha256.update(data, size);
1025
+ if(bytes_output != nullptr){
1026
+ bytes.insert(bytes.end(), data, data + size);
1027
+ return true;
1028
+ }
1029
+ file.write(reinterpret_cast<const char*>(data), std::streamsize(size));
1030
+ return bool(file);
1031
+ }, failure_output);
1032
+ if(decoded){
1033
+ decoded = verify_digests(actual_sha1.finalize(), actual_sha256.finalize(), sha1, sha256, failure_output);
1034
+ }
1035
+ if(bytes_output == nullptr){
1036
+ file.close();
1037
+ if(decoded && !file){
1038
+ failure_output = "failed to close " + temporary.string();
1039
+ decoded = false;
1040
+ }
1041
+ if(decoded){
1042
+ return publish_file(temporary, target, failure_output);
1043
+ }
1044
+ std::error_code error_code;
1045
+ std::filesystem::remove(temporary, error_code);
1046
+ }
1047
+ else if(decoded){
1048
+ bytes_output->swap(bytes);
1049
+ }
1050
+ return decoded;
1051
+ }
1052
+ inline std::string compressed_location(const std::string& url){
1053
+ std::size_t query = url.find_first_of("?#");
1054
+ return url.substr(0, query) + ".gz" + (query == std::string::npos ? std::string() : url.substr(query));
1055
+ }
1056
+ inline bool fetch_gzip(const std::string& url, const std::string& sha1, const std::string& sha256, const std::string& description, const std::filesystem::path& target, std::vector<std::uint8_t>* bytes_output, std::string& failure_output){
1057
+ std::filesystem::path gzip_target = target;
1058
+ gzip_target += ".gz";
1059
+ std::filesystem::path temporary = gzip_target;
1060
+ temporary += ".partial." + unique_suffix();
1061
+ std::cerr << "conta: downloading " << sha1 << (description.empty() ? std::string() : " (" + printable(description) + ")") << " from " << url << std::endl;
1062
+ bool fetched = run_curl(url, temporary, false, failure_output) && decode_gzip(temporary, sha1, sha256, target, bytes_output, failure_output);
1063
+ if(fetched && bytes_output != nullptr){
1064
+ fetched = publish_file(temporary, gzip_target, failure_output);
1065
+ if(!fetched){
1066
+ bytes_output->clear();
1067
+ }
1068
+ }
1069
+ std::error_code error_code;
1070
+ std::filesystem::remove(temporary, error_code);
1071
+ return fetched;
1072
+ }
1073
+ inline bool fetch_blob(const std::string& url, const std::string& sha1, const std::string& sha256, const std::string& description, const std::filesystem::path& target, std::string& failure_output){
1074
+ std::filesystem::path temporary = target;
1075
+ temporary += ".partial." + unique_suffix();
1076
+ std::cerr << "conta: downloading " << sha1 << (description.empty() ? std::string() : " (" + printable(description) + ")") << " from " << url << std::endl;
1077
+ std::error_code error_code;
1078
+ if(!run_curl(url, temporary, false, failure_output)){
1079
+ std::filesystem::remove(temporary, error_code);
1080
+ return false;
1081
+ }
1082
+ std::string actual_sha1, actual_sha256;
1083
+ if(!digests_file(temporary, actual_sha1, actual_sha256)){
1084
+ std::filesystem::remove(temporary, error_code);
1085
+ failure_output = "the downloaded file is unreadable";
1086
+ return false;
1087
+ }
1088
+ if(!verify_digests(actual_sha1, actual_sha256, sha1, sha256, failure_output)){
1089
+ std::filesystem::remove(temporary, error_code);
1090
+ return false;
1091
+ }
1092
+ return publish_file(temporary, target, failure_output);
1093
+ }
1094
+ inline bool read_blob(const std::filesystem::path& path, std::vector<std::uint8_t>* bytes_output, std::string& failure_output){
1095
+ if(bytes_output == nullptr){
1096
+ return true;
1097
+ }
1098
+ std::vector<std::uint8_t> bytes;
1099
+ if(!read_file_chunks(path, [&](const unsigned char* data, std::size_t size){ bytes.insert(bytes.end(), data, data + size); })){
1100
+ failure_output = "conta: cannot read " + path.string();
1101
+ return false;
1102
+ }
1103
+ bytes_output->swap(bytes);
1104
+ return true;
1105
+ }
1106
+ struct Session{
1107
+ std::set<std::string> wanted;
1108
+ std::vector<Index> indexes;
1109
+ std::set<std::string> attempted_urls;
1110
+ std::size_t next_entry_point = 0;
1111
+ bool cached_index_loaded = false;
1112
+ std::string cached_index_sha256;
1113
+ std::size_t cached_index_entry_count = 0;
1114
+ };
1115
+ inline const Entry* find_entry(const Session& session, const std::string& sha1){
1116
+ for(const Index& index: session.indexes){
1117
+ auto entry = index.entries.find(sha1);
1118
+ if(entry != index.entries.end()){
1119
+ return &entry->second;
1120
+ }
1121
+ }
1122
+ return nullptr;
1123
+ }
1124
+ inline bool try_index(Session& session, const Index& index, const std::string& sha1, const std::filesystem::path& target, std::vector<std::uint8_t>* bytes_output, std::vector<std::string>& report){
1125
+ auto found = index.entries.find(sha1);
1126
+ if(found == index.entries.end()){
1127
+ report.push_back(index.source + ": does not list it");
1128
+ return false;
1129
+ }
1130
+ const Entry& entry = found->second;
1131
+ if(entry.shards.empty()){
1132
+ report.push_back(index.source + ": lists no location");
1133
+ }
1134
+ for(const ShardLocation& shard: entry.shards){
1135
+ auto url_template = index.shard_urls.find(shard.id);
1136
+ if(url_template == index.shard_urls.end()){
1137
+ report.push_back(index.source + ": shard " + shard.id + " is not in its shard table");
1138
+ continue;
1139
+ }
1140
+ std::string url;
1141
+ if(!shard_location(url_template->second, sha1, entry.sha256, url)){
1142
+ report.push_back(index.source + ": skipped shard " + shard.id + ", unsupported url " + url_template->second);
1143
+ continue;
1144
+ }
1145
+ std::string failure;
1146
+ if(gzip_supported() && std::find(shard.compressed.begin(), shard.compressed.end(), "gz") != shard.compressed.end()){
1147
+ std::string gzip_url = compressed_location(url);
1148
+ if(session.attempted_urls.insert(gzip_url).second){
1149
+ if(fetch_gzip(gzip_url, sha1, entry.sha256, entry.description, target, bytes_output, failure)){
1150
+ return true;
1151
+ }
1152
+ report.push_back(gzip_url + ": " + failure);
1153
+ }
1154
+ }
1155
+ if(!session.attempted_urls.insert(url).second){
1156
+ continue;
1157
+ }
1158
+ if(fetch_blob(url, sha1, entry.sha256, entry.description, target, failure) && read_blob(target, bytes_output, failure)){
1159
+ return true;
1160
+ }
1161
+ report.push_back(url + ": " + failure);
1162
+ }
1163
+ return false;
1164
+ }
1165
+ inline void load_cached_index(const Config& config, Session& session){
1166
+ session.cached_index_loaded = true;
1167
+ std::filesystem::path path = std::filesystem::path(config.cache) / CACHED_INDEX_NAME;
1168
+ std::string text;
1169
+ if(!read_file(path, text)){
1170
+ return;
1171
+ }
1172
+ Index index;
1173
+ index.source = path.string();
1174
+ index.sha256 = sha256_text(text);
1175
+ if(!parse_index(text, session.wanted, index)){
1176
+ return;
1177
+ }
1178
+ session.cached_index_sha256 = index.sha256;
1179
+ session.cached_index_entry_count = index.entry_count;
1180
+ session.indexes.push_back(std::move(index));
1181
+ }
1182
+ inline bool fetch_text(const Config& config, const std::string& url, const std::string& name, std::string& text_output, std::string& failure_output){
1183
+ std::filesystem::path temporary = std::filesystem::path(config.cache) / (name + ".partial." + unique_suffix());
1184
+ std::error_code error_code;
1185
+ bool fetched = run_curl(url, temporary, true, failure_output);
1186
+ if(fetched && !read_file(temporary, text_output)){
1187
+ failure_output = "the downloaded file is unreadable";
1188
+ fetched = false;
1189
+ }
1190
+ std::filesystem::remove(temporary, error_code);
1191
+ return fetched;
1192
+ }
1193
+ inline bool visit_entry_point(const Config& config, Session& session, const std::string& sha1, const std::filesystem::path& target, std::vector<std::uint8_t>* bytes_output, std::vector<std::string>& report){
1194
+ const std::string& entry_point = config.entry_points[session.next_entry_point++];
1195
+ std::cerr << "conta: refreshing the index from " << entry_point << std::endl;
1196
+ std::string meta_text, failure;
1197
+ if(!fetch_text(config, entry_point, "meta.json", meta_text, failure)){
1198
+ report.push_back(entry_point + ": " + failure);
1199
+ return false;
1200
+ }
1201
+ Meta meta;
1202
+ if(!parse_meta(meta_text, meta) || !meta.format_supported || !is_lowercase_hex(meta.sha256, 64)){
1203
+ report.push_back(entry_point + ": not a format 1 meta.json");
1204
+ return false;
1205
+ }
1206
+ for(const Index& index: session.indexes){
1207
+ if(index.sha256 == meta.sha256){
1208
+ report.push_back(entry_point + ": serves the index already searched");
1209
+ return false;
1210
+ }
1211
+ }
1212
+ std::string index_url;
1213
+ if(!resolve_location(entry_point, meta.location, index_url)){
1214
+ report.push_back(entry_point + ": unsupported index.location " + meta.location);
1215
+ return false;
1216
+ }
1217
+ std::string text;
1218
+ if(!fetch_text(config, index_url, CACHED_INDEX_NAME, text, failure)){
1219
+ report.push_back(index_url + ": " + failure);
1220
+ return false;
1221
+ }
1222
+ Index index;
1223
+ index.source = index_url;
1224
+ index.sha256 = sha256_text(text);
1225
+ if(!parse_index(text, session.wanted, index)){
1226
+ report.push_back(index_url + ": not a format 1 index");
1227
+ return false;
1228
+ }
1229
+ if(index.sha256 != meta.sha256){
1230
+ report.push_back(index_url + ": differs from the sha256 in meta.json (a publish may still be propagating), used for this call only");
1231
+ }
1232
+ else if(session.cached_index_sha256.empty() || index.entry_count >= session.cached_index_entry_count){ // entries are never removed, so a smaller index is older and must not replace the cached one
1233
+ std::filesystem::path temporary = std::filesystem::path(config.cache) / (std::string(CACHED_INDEX_NAME) + ".partial." + unique_suffix());
1234
+ std::error_code error_code;
1235
+ {
1236
+ std::ofstream file(temporary, std::ios::binary);
1237
+ file.write(text.data(), std::streamsize(text.size()));
1238
+ }
1239
+ std::filesystem::rename(temporary, std::filesystem::path(config.cache) / CACHED_INDEX_NAME, error_code);
1240
+ if(error_code){
1241
+ std::filesystem::remove(temporary, error_code);
1242
+ }
1243
+ else{
1244
+ session.cached_index_sha256 = index.sha256;
1245
+ session.cached_index_entry_count = index.entry_count;
1246
+ }
1247
+ }
1248
+ session.indexes.push_back(std::move(index));
1249
+ return try_index(session, session.indexes.back(), sha1, target, bytes_output, report);
1250
+ }
1251
+ inline std::string failure_message(const Session& session, const std::string& sha1, const std::vector<std::string>& report){
1252
+ std::string message = "conta: cannot resolve " + sha1;
1253
+ const Entry* entry = find_entry(session, sha1);
1254
+ if(entry == nullptr){
1255
+ message += ", which no reachable index lists";
1256
+ }
1257
+ else if(!entry->description.empty()){
1258
+ message += " (" + printable(entry->description) + ")";
1259
+ }
1260
+ if(entry != nullptr && !entry->notice.empty()){
1261
+ message += "\nnotice: " + printable(entry->notice);
1262
+ }
1263
+ for(const std::string& line: report){
1264
+ message += "\n " + printable(line);
1265
+ }
1266
+ message += "\nA copy you already have works with CONTA_URL=file:///<directory>/ holding it as " + sha1 + " (verified), or with CONTA_ROOT=<directory> holding it as data/" + sha1 + " (no network).";
1267
+ return message;
1268
+ }
1269
+ #if defined(_WIN32)
1270
+ constexpr const char* CACHE_DIRECTORY_VARIABLES = "CONTA_CACHE or LOCALAPPDATA";
1271
+ #else
1272
+ constexpr const char* CACHE_DIRECTORY_VARIABLES = "CONTA_CACHE, XDG_CACHE_HOME, or HOME";
1273
+ #endif
1274
+ inline bool prepare_cache(const Config& config, std::string& error_output){
1275
+ if(config.cache.empty()){
1276
+ error_output = std::string("conta: cannot determine cache directory: set ") + CACHE_DIRECTORY_VARIABLES;
1277
+ return false;
1278
+ }
1279
+ std::error_code error_code;
1280
+ std::filesystem::create_directories(config.cache, error_code);
1281
+ if(error_code){
1282
+ error_output = "conta: failed to create cache directory " + config.cache + ": " + error_code.message();
1283
+ return false;
1284
+ }
1285
+ return true;
1286
+ }
1287
+ inline bool resolve_one(const Config& config, Session& session, const std::string& reference, std::string& path_output, std::string& error_output, std::vector<std::uint8_t>* bytes_output = nullptr){
1288
+ std::string sha1;
1289
+ if(!normalize_reference(reference, sha1, error_output)){
1290
+ return false;
1291
+ }
1292
+ if(!config.root.empty()){
1293
+ std::filesystem::path path = std::filesystem::path(config.root) / "data" / sha1;
1294
+ if(std::filesystem::exists(path)){
1295
+ if(is_lfs_pointer(path)){
1296
+ error_output = "conta: " + path.string() + " is a git-lfs pointer file, not the blob. Run \"git lfs pull\" in " + config.root + ".";
1297
+ return false;
1298
+ }
1299
+ path_output = path.string();
1300
+ return read_blob(path, bytes_output, error_output);
1301
+ }
1302
+ std::filesystem::path gzip_path = path;
1303
+ gzip_path += ".gz";
1304
+ if(!std::filesystem::exists(gzip_path)){
1305
+ error_output = "conta: " + sha1 + " not found at " + path.string() + " or " + gzip_path.string() + ". CONTA_ROOT points to a read-only store, so downloading is disabled; populate the store or unset CONTA_ROOT to enable the download cache.";
1306
+ return false;
1307
+ }
1308
+ if(is_lfs_pointer(gzip_path)){
1309
+ error_output = "conta: " + gzip_path.string() + " is a git-lfs pointer file, not the blob. Run \"git lfs pull\" in " + config.root + ".";
1310
+ return false;
1311
+ }
1312
+ std::filesystem::path target = std::filesystem::path(config.cache) / sha1;
1313
+ if(!config.cache.empty() && std::filesystem::exists(target)){
1314
+ path_output = target.string();
1315
+ return read_blob(target, bytes_output, error_output);
1316
+ }
1317
+ if(!gzip_supported()){
1318
+ error_output = "conta: " + gzip_path.string() + " requires gzip decoding; build with CONTA_ENABLE_ZLIB and link zlib, or provide the plain blob in CONTA_ROOT";
1319
+ return false;
1320
+ }
1321
+ if(bytes_output == nullptr && !prepare_cache(config, error_output)){
1322
+ return false;
1323
+ }
1324
+ std::string failure;
1325
+ if(!decode_gzip(gzip_path, sha1, "", target, bytes_output, failure)){
1326
+ error_output = "conta: cannot decode " + gzip_path.string() + ": " + failure;
1327
+ return false;
1328
+ }
1329
+ path_output = target.string();
1330
+ return true;
1331
+ }
1332
+ if(config.cache.empty()){
1333
+ error_output = std::string("conta: cannot determine cache directory: set ") + CACHE_DIRECTORY_VARIABLES;
1334
+ return false;
1335
+ }
1336
+ std::filesystem::path target = std::filesystem::path(config.cache) / sha1;
1337
+ if(std::filesystem::exists(target)){
1338
+ path_output = target.string();
1339
+ return read_blob(target, bytes_output, error_output);
1340
+ }
1341
+ if(!prepare_cache(config, error_output)){
1342
+ return false;
1343
+ }
1344
+ std::vector<std::string> report;
1345
+ std::filesystem::path gzip_path = target;
1346
+ gzip_path += ".gz";
1347
+ if(std::filesystem::exists(gzip_path)){
1348
+ if(config.url_base.empty() && !session.cached_index_loaded){
1349
+ load_cached_index(config, session);
1350
+ }
1351
+ const Entry* entry = find_entry(session, sha1);
1352
+ std::string failure;
1353
+ if(decode_gzip(gzip_path, sha1, entry == nullptr ? "" : entry->sha256, target, bytes_output, failure)){
1354
+ path_output = target.string();
1355
+ return true;
1356
+ }
1357
+ report.push_back(gzip_path.string() + ": " + failure);
1358
+ }
1359
+ if(!config.url_base.empty()){
1360
+ std::string url = config.url_base + sha1;
1361
+ std::string failure;
1362
+ if(!fetch_blob(url, sha1, "", "", target, failure) || !read_blob(target, bytes_output, failure)){
1363
+ error_output = "conta: download of " + sha1 + " from " + url + " failed: " + failure;
1364
+ for(const std::string& line: report){
1365
+ error_output += "\n " + line;
1366
+ }
1367
+ return false;
1368
+ }
1369
+ path_output = target.string();
1370
+ return true;
1371
+ }
1372
+ if(!session.cached_index_loaded){
1373
+ load_cached_index(config, session);
1374
+ }
1375
+ for(const Index& index: session.indexes){
1376
+ if(try_index(session, index, sha1, target, bytes_output, report)){
1377
+ path_output = target.string();
1378
+ return true;
1379
+ }
1380
+ }
1381
+ while(session.next_entry_point < config.entry_points.size()){
1382
+ if(visit_entry_point(config, session, sha1, target, bytes_output, report)){
1383
+ path_output = target.string();
1384
+ return true;
1385
+ }
1386
+ }
1387
+ error_output = failure_message(session, sha1, report);
1388
+ return false;
1389
+ }
1390
+ }
1391
+ inline bool resolve(const Config& config, const std::string& hash, std::string& path_output, std::string& error_output){
1392
+ detail::Session session;
1393
+ std::string sha1, ignored;
1394
+ if(detail::normalize_reference(hash, sha1, ignored)){
1395
+ session.wanted.insert(sha1);
1396
+ }
1397
+ return detail::resolve_one(config, session, hash, path_output, error_output);
1398
+ }
1399
+ inline bool load(const Config& config, const std::string& hash, std::vector<std::uint8_t>& bytes_output, std::string& error_output){
1400
+ bytes_output.clear();
1401
+ std::string path;
1402
+ if(!config.compressed_cache){
1403
+ return resolve(config, hash, path, error_output) && detail::read_blob(path, &bytes_output, error_output);
1404
+ }
1405
+ detail::Session session;
1406
+ std::string sha1, ignored;
1407
+ if(detail::normalize_reference(hash, sha1, ignored)){
1408
+ session.wanted.insert(sha1);
1409
+ }
1410
+ return detail::resolve_one(config, session, hash, path, error_output, &bytes_output);
1411
+ }
1412
+ inline bool resolve(const Config& config, const std::vector<std::string>& hashes, std::vector<std::string>& paths_output, std::string& error_output){
1413
+ paths_output.clear();
1414
+ detail::Session session;
1415
+ for(const std::string& hash: hashes){
1416
+ std::string sha1, ignored;
1417
+ if(detail::normalize_reference(hash, sha1, ignored)){
1418
+ session.wanted.insert(sha1);
1419
+ }
1420
+ }
1421
+ for(const std::string& hash: hashes){
1422
+ std::string path;
1423
+ if(!detail::resolve_one(config, session, hash, path, error_output)){
1424
+ paths_output.clear();
1425
+ return false;
1426
+ }
1427
+ paths_output.push_back(path);
1428
+ }
1429
+ return true;
1430
+ }
1431
+ inline Config config_from_environment(){
1432
+ Config config;
1433
+ const char* compressed_cache = std::getenv("CONTA_COMPRESSED_CACHE");
1434
+ config.compressed_cache = compressed_cache == nullptr || std::string(compressed_cache) != "0";
1435
+ const char* root = std::getenv("CONTA_ROOT");
1436
+ if(root != nullptr && root[0] != '\0'){
1437
+ config.root = root;
1438
+ }
1439
+ const char* cache = std::getenv("CONTA_CACHE");
1440
+ if(cache != nullptr && cache[0] != '\0'){
1441
+ config.cache = cache;
1442
+ }
1443
+ else{
1444
+ #if defined(_WIN32)
1445
+ const char* local_app_data = std::getenv("LOCALAPPDATA");
1446
+ if(local_app_data != nullptr && local_app_data[0] != '\0'){
1447
+ config.cache = (std::filesystem::path(local_app_data) / "conta").string();
1448
+ }
1449
+ #else
1450
+ const char* xdg_cache_home = std::getenv("XDG_CACHE_HOME");
1451
+ const char* home = std::getenv("HOME");
1452
+ if(xdg_cache_home != nullptr && xdg_cache_home[0] != '\0'){
1453
+ config.cache = (std::filesystem::path(xdg_cache_home) / "conta").string();
1454
+ }
1455
+ else if(home != nullptr && home[0] != '\0'){
1456
+ config.cache = (std::filesystem::path(home) / ".cache" / "conta").string();
1457
+ }
1458
+ #endif
1459
+ }
1460
+ const char* url_base = std::getenv("CONTA_URL");
1461
+ if(url_base != nullptr && url_base[0] != '\0'){
1462
+ config.url_base = url_base;
1463
+ if(config.url_base.back() != '/'){
1464
+ config.url_base += '/';
1465
+ }
1466
+ }
1467
+ return config;
1468
+ }
1469
+ inline bool resolve(const std::string& hash, std::string& path_output, std::string& error_output){
1470
+ return resolve(config_from_environment(), hash, path_output, error_output);
1471
+ }
1472
+ inline bool load(const std::string& hash, std::vector<std::uint8_t>& bytes_output, std::string& error_output){
1473
+ return load(config_from_environment(), hash, bytes_output, error_output);
1474
+ }
1475
+ inline bool resolve(const std::vector<std::string>& hashes, std::vector<std::string>& paths_output, std::string& error_output){
1476
+ return resolve(config_from_environment(), hashes, paths_output, error_output);
1477
+ }
1478
+ }
1479
+
1480
+ #endif