@paradigma-inc/flywheel 0.1.115 → 0.1.134

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 (623) hide show
  1. package/README.md +67 -10
  2. package/package.json +14 -6
  3. package/skills/flywheel/SKILL.md +9 -6
  4. package/skills/flywheel/example-workflows/organizing-exploring-and-iterating-on-a-research-topic.md +38 -46
  5. package/skills/flywheel/example-workflows/reproducing-papers-on-a-budget.md +34 -36
  6. package/skills/flywheel/getting-started/flywheel-quickstart.md +2 -5
  7. package/skills/flywheel/references/INTERFACES.md +2 -2
  8. package/skills/flywheel/references/experiment-design-protocol.md +32 -25
  9. package/skills/flywheel/references/flywheel-cli-tool-map.md +120 -76
  10. package/skills/flywheel/references/flywheel-mcp-tool-map.md +42 -32
  11. package/skills/flywheel/setting-up-flywheel/claude-code-cli-installation.md +1 -1
  12. package/skills/flywheel/setting-up-flywheel/codex-cli-installation.md +1 -1
  13. package/skills/flywheel/setting-up-flywheel/installation-overview.md +2 -6
  14. package/skills/flywheel/setting-up-flywheel/other-hosts-installation.md +45 -25
  15. package/skills/flywheel/setting-up-flywheel/updating-flywheel-mcp.md +34 -11
  16. package/skills/flywheel-auto/SKILL.md +40 -23
  17. package/skills/flywheel-auto/evals/evals.json +1 -1
  18. package/skills/flywheel-auto/references/INTERFACES.md +2 -2
  19. package/skills/flywheel-auto/references/experiment-design-protocol.md +31 -23
  20. package/skills/flywheel-auto/references/flywheel-cli-tool-map.md +172 -127
  21. package/skills/flywheel-auto/references/flywheel-mcp-tool-map.md +22 -24
  22. package/skills/flywheel-lookahead/SKILL.md +47 -28
  23. package/skills/flywheel-lookahead/agents/openai.yaml +1 -1
  24. package/skills/flywheel-lookahead/evals/evals.json +6 -6
  25. package/skills/flywheel-lookahead/references/INTERFACES.md +2 -2
  26. package/skills/flywheel-lookahead/references/flywheel-cli-tool-map.md +172 -127
  27. package/skills/flywheel-lookahead/references/flywheel-mcp-tool-map.md +22 -24
  28. package/skills/flywheel-prove/SKILL.md +2 -2
  29. package/skills/flywheel-prove/references/workflow.md +21 -2
  30. package/skills/flywheel-reproduce/SKILL.md +39 -19
  31. package/skills/flywheel-reproduce/evals/evals.json +1 -1
  32. package/skills/flywheel-reproduce/references/INTERFACES.md +2 -2
  33. package/skills/flywheel-reproduce/references/experiment-design-protocol.md +31 -23
  34. package/skills/flywheel-reproduce/references/flywheel-cli-tool-map.md +172 -127
  35. package/skills/flywheel-reproduce/references/flywheel-mcp-tool-map.md +22 -24
  36. package/skills/flywheel-to-graph/SKILL.md +37 -17
  37. package/skills/flywheel-to-graph/references/INTERFACES.md +2 -2
  38. package/skills/flywheel-to-graph/references/flywheel-cli-tool-map.md +172 -127
  39. package/skills/flywheel-to-graph/references/flywheel-mcp-tool-map.md +22 -24
  40. package/skills/flywheel-tree/references/workflow.md +6 -37
  41. package/src/cli.mjs +1145 -1141
  42. package/src/mcp-writer.mjs +413 -435
  43. package/src/public-command-metadata.mjs +28 -5
  44. package/src/runtime/delegate.mjs +2 -19
  45. package/src/runtime/required-runtime-commands.json +80 -28
  46. package/src/runtime/runtime-config.mjs +39 -60
  47. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js +330 -0
  48. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js.map +1 -0
  49. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js +90 -139
  50. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js.map +1 -1
  51. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js +1 -1
  52. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js.map +1 -1
  53. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js +116 -0
  54. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js.map +1 -0
  55. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js +248 -1
  56. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js.map +1 -1
  57. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js +65 -1
  58. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js.map +1 -1
  59. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js +17 -0
  60. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js.map +1 -0
  61. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js +3 -7
  62. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js.map +1 -1
  63. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js +12 -0
  64. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js.map +1 -0
  65. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js +29 -0
  66. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js.map +1 -0
  67. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js +12 -0
  68. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js.map +1 -1
  69. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js +46 -10
  70. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js.map +1 -1
  71. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js +17 -40
  72. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js.map +1 -1
  73. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js +305 -0
  74. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js.map +1 -0
  75. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js +72 -0
  76. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js.map +1 -0
  77. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js +286 -0
  78. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js.map +1 -0
  79. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js +30 -5
  80. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js.map +1 -1
  81. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js +27 -12
  82. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js.map +1 -1
  83. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js +284 -0
  84. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js.map +1 -0
  85. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js +169 -0
  86. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js.map +1 -0
  87. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js +13 -0
  88. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js.map +1 -0
  89. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js +227 -0
  90. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js.map +1 -0
  91. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js +21 -51
  92. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js.map +1 -1
  93. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js +25 -0
  94. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js.map +1 -0
  95. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js +11 -9
  96. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js.map +1 -1
  97. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js +38 -45
  98. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js.map +1 -1
  99. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js +14 -17
  100. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js.map +1 -1
  101. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js +13 -8
  102. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js.map +1 -1
  103. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js +34 -3
  104. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js.map +1 -1
  105. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js +9 -9
  106. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js.map +1 -1
  107. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js +76 -0
  108. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js.map +1 -0
  109. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js +4 -138
  110. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js.map +1 -1
  111. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js +8 -13
  112. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js.map +1 -1
  113. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +362 -0
  114. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -0
  115. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js +45 -183
  116. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js.map +1 -1
  117. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js +47 -0
  118. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js.map +1 -0
  119. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js +181 -0
  120. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js.map +1 -0
  121. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +163 -0
  122. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -0
  123. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js +79 -0
  124. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js.map +1 -0
  125. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js +80 -0
  126. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js.map +1 -0
  127. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js +78 -0
  128. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js.map +1 -0
  129. package/src/runtime/vendor/flywheel-cli-dist/commands/types.js.map +1 -1
  130. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js +3 -2
  131. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js.map +1 -1
  132. package/src/runtime/vendor/flywheel-cli-dist/config/index.js +5 -0
  133. package/src/runtime/vendor/flywheel-cli-dist/config/index.js.map +1 -0
  134. package/src/runtime/vendor/flywheel-cli-dist/config/io.js +139 -0
  135. package/src/runtime/vendor/flywheel-cli-dist/config/io.js.map +1 -0
  136. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js +299 -0
  137. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js.map +1 -0
  138. package/src/runtime/vendor/flywheel-cli-dist/config/model.js +214 -0
  139. package/src/runtime/vendor/flywheel-cli-dist/config/model.js.map +1 -0
  140. package/src/runtime/vendor/flywheel-cli-dist/config/path.js +30 -0
  141. package/src/runtime/vendor/flywheel-cli-dist/config/path.js.map +1 -0
  142. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js +29 -0
  143. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js.map +1 -0
  144. package/src/runtime/vendor/flywheel-cli-dist/errors.js +1 -16
  145. package/src/runtime/vendor/flywheel-cli-dist/errors.js.map +1 -1
  146. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js +3 -3
  147. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js.map +1 -1
  148. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js +19 -9
  149. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js.map +1 -1
  150. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js +33 -4
  151. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js.map +1 -1
  152. package/src/runtime/vendor/flywheel-cli-dist/http/client.js +322 -304
  153. package/src/runtime/vendor/flywheel-cli-dist/http/client.js.map +1 -1
  154. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js +1 -21
  155. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js.map +1 -1
  156. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js +1 -0
  157. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js.map +1 -1
  158. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js +244 -0
  159. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js.map +1 -0
  160. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js +7 -0
  161. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js.map +1 -0
  162. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js +35 -0
  163. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js.map +1 -0
  164. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js +42 -0
  165. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js.map +1 -0
  166. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js +179 -0
  167. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js.map +1 -0
  168. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js +152 -0
  169. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js.map +1 -0
  170. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js +71 -0
  171. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js.map +1 -0
  172. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js +73 -0
  173. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js.map +1 -0
  174. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js +82 -0
  175. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js.map +1 -0
  176. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js +345 -0
  177. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js.map +1 -0
  178. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +57 -0
  179. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -0
  180. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +149 -0
  181. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -0
  182. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js +115 -0
  183. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js.map +1 -0
  184. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js +44 -0
  185. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js.map +1 -0
  186. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +159 -0
  187. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -0
  188. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +346 -0
  189. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -0
  190. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +37 -0
  191. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -0
  192. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js +203 -0
  193. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js.map +1 -0
  194. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js +207 -0
  195. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js.map +1 -0
  196. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js +109 -0
  197. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js.map +1 -0
  198. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js +61 -0
  199. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js.map +1 -0
  200. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js +46 -0
  201. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js.map +1 -0
  202. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js +203 -0
  203. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js.map +1 -0
  204. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js +44 -0
  205. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js.map +1 -0
  206. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js +188 -0
  207. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js.map +1 -0
  208. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js +54 -0
  209. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js.map +1 -0
  210. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js +25 -0
  211. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js.map +1 -0
  212. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js +2 -0
  213. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js.map +1 -0
  214. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js +7 -0
  215. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js.map +1 -0
  216. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js +129 -0
  217. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js.map +1 -0
  218. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js +277 -0
  219. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js.map +1 -0
  220. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js +183 -0
  221. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js.map +1 -0
  222. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js +2 -0
  223. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js.map +1 -0
  224. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js +121 -0
  225. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js.map +1 -0
  226. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js +16 -0
  227. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js.map +1 -0
  228. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js +72 -0
  229. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js.map +1 -0
  230. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +59 -0
  231. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -0
  232. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js +125 -0
  233. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js.map +1 -0
  234. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js +129 -0
  235. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js.map +1 -0
  236. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js +31 -0
  237. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js.map +1 -0
  238. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js +49 -0
  239. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js.map +1 -0
  240. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js +30 -0
  241. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js.map +1 -0
  242. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js +12 -0
  243. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js.map +1 -0
  244. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js +18 -0
  245. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js.map +1 -0
  246. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js +125 -0
  247. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js.map +1 -0
  248. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js +37 -0
  249. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js.map +1 -0
  250. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js +44 -0
  251. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js.map +1 -0
  252. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js +58 -0
  253. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js.map +1 -0
  254. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js +118 -0
  255. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js.map +1 -0
  256. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js +277 -0
  257. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js.map +1 -0
  258. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js +132 -0
  259. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js.map +1 -0
  260. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js +372 -0
  261. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js.map +1 -0
  262. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js +210 -0
  263. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js.map +1 -0
  264. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js +278 -0
  265. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js.map +1 -0
  266. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js +192 -0
  267. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js.map +1 -0
  268. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js +114 -0
  269. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js.map +1 -0
  270. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js +65 -0
  271. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js.map +1 -0
  272. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js +145 -0
  273. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js.map +1 -0
  274. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js +218 -0
  275. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js.map +1 -0
  276. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js +71 -0
  277. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js.map +1 -0
  278. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js +298 -0
  279. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js.map +1 -0
  280. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js +121 -0
  281. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js.map +1 -0
  282. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js +69 -0
  283. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js.map +1 -0
  284. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js +49 -0
  285. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js.map +1 -0
  286. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js +424 -0
  287. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js.map +1 -0
  288. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js +10 -0
  289. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js.map +1 -0
  290. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/001_initial.sql +319 -0
  291. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/002_staged_latest_values.sql +8 -0
  292. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/003_remove_cli_editing_lease.sql +21 -0
  293. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/004_hosted_association.sql +7 -0
  294. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/005_artifact_properties.sql +68 -0
  295. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js +12 -0
  296. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js.map +1 -0
  297. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js +410 -0
  298. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js.map +1 -0
  299. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js +77 -0
  300. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js.map +1 -0
  301. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +240 -0
  302. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -0
  303. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js +127 -0
  304. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js.map +1 -0
  305. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js +107 -0
  306. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js.map +1 -0
  307. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js +80 -0
  308. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js.map +1 -0
  309. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +219 -0
  310. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -0
  311. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js +164 -0
  312. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js.map +1 -0
  313. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js +20 -0
  314. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js.map +1 -0
  315. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js +41 -0
  316. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js.map +1 -0
  317. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js +22 -0
  318. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js.map +1 -0
  319. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js +188 -0
  320. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js.map +1 -0
  321. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js +5 -0
  322. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js.map +1 -0
  323. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js +214 -0
  324. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js.map +1 -0
  325. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js +4 -0
  326. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js.map +1 -0
  327. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js +44 -0
  328. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js.map +1 -0
  329. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js +38 -0
  330. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js.map +1 -0
  331. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js +284 -0
  332. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js.map +1 -0
  333. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js +133 -0
  334. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js.map +1 -0
  335. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js +98 -0
  336. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js.map +1 -0
  337. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js +161 -0
  338. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js.map +1 -0
  339. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js +97 -0
  340. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js.map +1 -0
  341. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js +69 -0
  342. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js.map +1 -0
  343. package/src/runtime/vendor/flywheel-cli-dist/main.js +651 -376
  344. package/src/runtime/vendor/flywheel-cli-dist/main.js.map +1 -1
  345. package/src/runtime/vendor/flywheel-cli-dist/output/format.js +18 -11
  346. package/src/runtime/vendor/flywheel-cli-dist/output/format.js.map +1 -1
  347. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
  348. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
  349. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
  350. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.musl.node +0 -0
  351. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  352. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.musl.node +0 -0
  353. package/src/runtime/vendor/manifest.json +246 -257
  354. package/src/setup/command.mjs +5 -0
  355. package/src/setup/io/patchers/json.mjs +1 -1
  356. package/src/setup/io/patchers/toml.mjs +3 -1
  357. package/src/setup/io/patchers/yaml.mjs +1 -1
  358. package/src/setup/modes/cli.mjs +76 -7
  359. package/src/setup/modes/mcp-command.mjs +802 -793
  360. package/src/setup/modes/mcp.mjs +7 -3
  361. package/src/setup/shared/prior-mode-detect.mjs +18 -21
  362. package/src/setup/test-seams.mjs +25 -0
  363. package/src/setup-auth.mjs +76 -10
  364. package/src/toml-lines.mjs +52 -0
  365. package/src/unified-cli.mjs +31 -16
  366. package/skills/flywheel-llm-proof-paper/scripts/__pycache__/check_paper.cpython-312.pyc +0 -0
  367. package/src/runtime/vendor/flywheel-cli-dist/auth/active-key-id.d.ts +0 -1
  368. package/src/runtime/vendor/flywheel-cli-dist/auth/baseurl.d.ts +0 -35
  369. package/src/runtime/vendor/flywheel-cli-dist/auth/config.d.ts +0 -34
  370. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js +0 -92
  371. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js.map +0 -1
  372. package/src/runtime/vendor/flywheel-cli-dist/auth/fingerprint.d.ts +0 -5
  373. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.d.ts +0 -4
  374. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js +0 -31
  375. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js.map +0 -1
  376. package/src/runtime/vendor/flywheel-cli-dist/auth/login.d.ts +0 -24
  377. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.d.ts +0 -15
  378. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js +0 -150
  379. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js.map +0 -1
  380. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.d.ts +0 -27
  381. package/src/runtime/vendor/flywheel-cli-dist/commands/_admin-auth.d.ts +0 -27
  382. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.d.ts +0 -32
  383. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js +0 -213
  384. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js.map +0 -1
  385. package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.d.ts +0 -35
  386. package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.d.ts +0 -2
  387. package/src/runtime/vendor/flywheel-cli-dist/commands/_secret-param.d.ts +0 -7
  388. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-file-out.d.ts +0 -39
  389. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-writer.d.ts +0 -34
  390. package/src/runtime/vendor/flywheel-cli-dist/commands/_wait-polling.d.ts +0 -50
  391. package/src/runtime/vendor/flywheel-cli-dist/commands/account-detach.d.ts +0 -2
  392. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-add.d.ts +0 -2
  393. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-remove.d.ts +0 -2
  394. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-set-primary.d.ts +0 -2
  395. package/src/runtime/vendor/flywheel-cli-dist/commands/account-get.d.ts +0 -2
  396. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-preview.d.ts +0 -2
  397. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-proof.d.ts +0 -2
  398. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge.d.ts +0 -2
  399. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-get.d.ts +0 -2
  400. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-set.d.ts +0 -2
  401. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export-stream.d.ts +0 -2
  402. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export.d.ts +0 -2
  403. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-list.d.ts +0 -4
  404. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-nodes-audit-list.d.ts +0 -2
  405. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.d.ts +0 -2
  406. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-delete.d.ts +0 -2
  407. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.d.ts +0 -2
  408. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.d.ts +0 -13
  409. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-create.d.ts +0 -2
  410. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-delete.d.ts +0 -2
  411. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-list.d.ts +0 -18
  412. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-rotate.d.ts +0 -2
  413. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-expire.d.ts +0 -2
  414. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-heartbeat.d.ts +0 -2
  415. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-list.d.ts +0 -2
  416. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.d.ts +0 -2
  417. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js +0 -22
  418. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js.map +0 -1
  419. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.d.ts +0 -2
  420. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js +0 -8
  421. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js.map +0 -1
  422. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-get.d.ts +0 -2
  423. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-list.d.ts +0 -2
  424. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.d.ts +0 -2
  425. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js +0 -9
  426. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js.map +0 -1
  427. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.d.ts +0 -2
  428. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js +0 -7
  429. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js.map +0 -1
  430. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.d.ts +0 -2
  431. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js +0 -15
  432. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js.map +0 -1
  433. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.d.ts +0 -2
  434. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js +0 -5
  435. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js.map +0 -1
  436. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.d.ts +0 -2
  437. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js +0 -8
  438. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js.map +0 -1
  439. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.d.ts +0 -2
  440. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js +0 -30
  441. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js.map +0 -1
  442. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.d.ts +0 -2
  443. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-mode.d.ts +0 -4
  444. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.d.ts +0 -2
  445. package/src/runtime/vendor/flywheel-cli-dist/commands/blobs-get.d.ts +0 -2
  446. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-create.d.ts +0 -2
  447. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-list.d.ts +0 -1
  448. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-revoke.d.ts +0 -1
  449. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-update.d.ts +0 -2
  450. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-snapshot.d.ts +0 -1
  451. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-acquire.d.ts +0 -2
  452. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-budgets.d.ts +0 -2
  453. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-connection.d.ts +0 -2
  454. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-funding.d.ts +0 -2
  455. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-list.d.ts +0 -2
  456. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-request-approval.d.ts +0 -2
  457. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-options.d.ts +0 -2
  458. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release-all.d.ts +0 -2
  459. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release.d.ts +0 -2
  460. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-status.d.ts +0 -2
  461. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-balance.d.ts +0 -1
  462. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-billing-portal.d.ts +0 -2
  463. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-purchase.d.ts +0 -2
  464. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral-claim.d.ts +0 -2
  465. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral.d.ts +0 -1
  466. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscribe.d.ts +0 -2
  467. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscription.d.ts +0 -1
  468. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-transactions.d.ts +0 -2
  469. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-usage.d.ts +0 -2
  470. package/src/runtime/vendor/flywheel-cli-dist/commands/destructive-confirmation.d.ts +0 -2
  471. package/src/runtime/vendor/flywheel-cli-dist/commands/enums.d.ts +0 -22
  472. package/src/runtime/vendor/flywheel-cli-dist/commands/env.d.ts +0 -8
  473. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-launch.d.ts +0 -2
  474. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-list.d.ts +0 -1
  475. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-terminate.d.ts +0 -2
  476. package/src/runtime/vendor/flywheel-cli-dist/commands/export-history.d.ts +0 -2
  477. package/src/runtime/vendor/flywheel-cli-dist/commands/export-subgraph.d.ts +0 -2
  478. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-pdf.d.ts +0 -2
  479. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-render-pdf.d.ts +0 -2
  480. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-stream.d.ts +0 -2
  481. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary.d.ts +0 -2
  482. package/src/runtime/vendor/flywheel-cli-dist/commands/feedback-create.d.ts +0 -2
  483. package/src/runtime/vendor/flywheel-cli-dist/commands/files-list.d.ts +0 -2
  484. package/src/runtime/vendor/flywheel-cli-dist/commands/github-disconnect.d.ts +0 -1
  485. package/src/runtime/vendor/flywheel-cli-dist/commands/github-link.d.ts +0 -2
  486. package/src/runtime/vendor/flywheel-cli-dist/commands/github-refresh-repos.d.ts +0 -1
  487. package/src/runtime/vendor/flywheel-cli-dist/commands/github-status.d.ts +0 -1
  488. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-get.d.ts +0 -2
  489. package/src/runtime/vendor/flywheel-cli-dist/commands/handler-factory.d.ts +0 -22
  490. package/src/runtime/vendor/flywheel-cli-dist/commands/help-format.d.ts +0 -31
  491. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.d.ts +0 -36
  492. package/src/runtime/vendor/flywheel-cli-dist/commands/help.d.ts +0 -17
  493. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-create.d.ts +0 -2
  494. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-delete.d.ts +0 -1
  495. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-list.d.ts +0 -2
  496. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-runs-list.d.ts +0 -2
  497. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-create.d.ts +0 -2
  498. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-delete.d.ts +0 -1
  499. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-list.d.ts +0 -1
  500. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-update.d.ts +0 -2
  501. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-set-enabled.d.ts +0 -2
  502. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-update.d.ts +0 -2
  503. package/src/runtime/vendor/flywheel-cli-dist/commands/import-subgraph.d.ts +0 -2
  504. package/src/runtime/vendor/flywheel-cli-dist/commands/index.d.ts +0 -23
  505. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-remove.d.ts +0 -1
  506. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-set.d.ts +0 -2
  507. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-status.d.ts +0 -1
  508. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-remove.d.ts +0 -1
  509. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-set.d.ts +0 -2
  510. package/src/runtime/vendor/flywheel-cli-dist/commands/machines-list.d.ts +0 -1
  511. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.d.ts +0 -2
  512. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js +0 -15
  513. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js.map +0 -1
  514. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.d.ts +0 -2
  515. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js +0 -10
  516. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js.map +0 -1
  517. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.d.ts +0 -2
  518. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js +0 -8
  519. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js.map +0 -1
  520. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.d.ts +0 -2
  521. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js +0 -6
  522. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js.map +0 -1
  523. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.d.ts +0 -2
  524. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js +0 -7
  525. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js.map +0 -1
  526. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.d.ts +0 -2
  527. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js +0 -6
  528. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js.map +0 -1
  529. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.d.ts +0 -2
  530. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js +0 -16
  531. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js.map +0 -1
  532. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.d.ts +0 -2
  533. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js +0 -11
  534. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js.map +0 -1
  535. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-files.d.ts +0 -1
  536. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-get.d.ts +0 -2
  537. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-list.d.ts +0 -2
  538. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.d.ts +0 -2
  539. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js +0 -33
  540. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js.map +0 -1
  541. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.d.ts +0 -2
  542. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js +0 -8
  543. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js.map +0 -1
  544. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.d.ts +0 -2
  545. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js +0 -15
  546. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js.map +0 -1
  547. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-ancestry.d.ts +0 -2
  548. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-summary.d.ts +0 -2
  549. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-tree.d.ts +0 -2
  550. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-resolve-slug.d.ts +0 -2
  551. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-get.d.ts +0 -1
  552. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set-bulk.d.ts +0 -2
  553. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set.d.ts +0 -2
  554. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-summaries.d.ts +0 -2
  555. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-acquire.d.ts +0 -2
  556. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-heartbeat.d.ts +0 -2
  557. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-release.d.ts +0 -2
  558. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.d.ts +0 -2
  559. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.d.ts +0 -2
  560. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.d.ts +0 -2
  561. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.d.ts +0 -2
  562. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/account.d.ts +0 -2
  563. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.d.ts +0 -8
  564. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/api-keys.d.ts +0 -2
  565. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/approval.d.ts +0 -2
  566. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.d.ts +0 -2
  567. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js +0 -140
  568. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js.map +0 -1
  569. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.d.ts +0 -2
  570. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/budgets.d.ts +0 -2
  571. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/compute.d.ts +0 -2
  572. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/credits.d.ts +0 -2
  573. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/env.d.ts +0 -2
  574. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/executions.d.ts +0 -2
  575. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/export.d.ts +0 -2
  576. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/github.d.ts +0 -2
  577. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/graph.d.ts +0 -2
  578. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hooks.d.ts +0 -2
  579. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/integrations.d.ts +0 -2
  580. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.d.ts +0 -2
  581. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.d.ts +0 -2
  582. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/resources.d.ts +0 -2
  583. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/sharing.d.ts +0 -2
  584. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.d.ts +0 -2
  585. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js +0 -98
  586. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js.map +0 -1
  587. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/updates.d.ts +0 -2
  588. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.d.ts +0 -27
  589. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-refresh.d.ts +0 -2
  590. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-resolve.d.ts +0 -2
  591. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.d.ts +0 -2
  592. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js +0 -25
  593. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js.map +0 -1
  594. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.d.ts +0 -2
  595. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js +0 -25
  596. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js.map +0 -1
  597. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.d.ts +0 -2
  598. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js +0 -11
  599. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js.map +0 -1
  600. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.d.ts +0 -2
  601. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js +0 -28
  602. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js.map +0 -1
  603. package/src/runtime/vendor/flywheel-cli-dist/commands/types.d.ts +0 -30
  604. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide-all-active.d.ts +0 -1
  605. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide.d.ts +0 -2
  606. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-list.d.ts +0 -2
  607. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.d.ts +0 -6
  608. package/src/runtime/vendor/flywheel-cli-dist/commands/utils.d.ts +0 -11
  609. package/src/runtime/vendor/flywheel-cli-dist/errors.d.ts +0 -86
  610. package/src/runtime/vendor/flywheel-cli-dist/exit-codes.d.ts +0 -8
  611. package/src/runtime/vendor/flywheel-cli-dist/generatedFeedbackContract.d.ts +0 -41
  612. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.d.ts +0 -13
  613. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.d.ts +0 -26
  614. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.d.ts +0 -17
  615. package/src/runtime/vendor/flywheel-cli-dist/http/client.d.ts +0 -91
  616. package/src/runtime/vendor/flywheel-cli-dist/http/debug.d.ts +0 -5
  617. package/src/runtime/vendor/flywheel-cli-dist/http/poll.d.ts +0 -18
  618. package/src/runtime/vendor/flywheel-cli-dist/http/retry.d.ts +0 -30
  619. package/src/runtime/vendor/flywheel-cli-dist/main.d.ts +0 -33
  620. package/src/runtime/vendor/flywheel-cli-dist/output/format.d.ts +0 -9
  621. package/src/runtime/vendor/flywheel-cli-dist/runtime-entry.d.ts +0 -1
  622. package/src/runtime/vendor/flywheel-cli-dist/version.d.ts +0 -3
  623. package/src/secure-write.mjs +0 -43
@@ -0,0 +1,372 @@
1
+ import { createHash } from "node:crypto";
2
+ import { createWriteStream, writeSync } from "node:fs";
3
+ import { pipeline } from "node:stream/promises";
4
+ import { TextDecoder } from "node:util";
5
+ import { crc32 } from "node:zlib";
6
+ import yauzl from "yauzl";
7
+ import yazl from "yazl";
8
+ import { close, createFileExclusiveAt, fchmod, fstat, fsync, mkdirAt, openDirectory, openDirectoryAt, statAt, } from "../../fs/native.js";
9
+ import { isRecord } from "../../domain/models/constants.js";
10
+ const DATABASE_MEMBER = "db.sqlite";
11
+ const MANIFEST_MEMBER = "manifest.json";
12
+ const OBJECT_PREFIX = "objects/sha256/";
13
+ const MAX_MEMBERS = 100_002;
14
+ const MAX_DATABASE_BYTES = 10 * 1024 ** 3;
15
+ const MAX_OBJECT_BYTES = 10 * 1024 ** 2;
16
+ const MAX_OBJECT_TOTAL_BYTES = 50 * 1024 ** 3;
17
+ const MAX_TOTAL_BYTES = 64 * 1024 ** 3;
18
+ const MAX_MANIFEST_BYTES = 16 * 1024 ** 2;
19
+ const DIRECTORY_TYPE = 0o040000;
20
+ const SYMLINK_TYPE = 0o120000;
21
+ const FILE_TYPE_MASK = 0o170000;
22
+ const PRIVATE_DIRECTORY_MODE = 0o700;
23
+ const PRIVATE_FILE_MODE = 0o600;
24
+ const UTF8 = new TextDecoder("utf-8", { fatal: true });
25
+ export class RepositoryBackupError extends Error {
26
+ code;
27
+ constructor(code, options) {
28
+ super(code, options);
29
+ this.name = "RepositoryBackupError";
30
+ this.code = code;
31
+ }
32
+ }
33
+ function restoreError(code, cause) {
34
+ return new RepositoryBackupError(code, cause === undefined ? undefined : { cause });
35
+ }
36
+ function isDigest(value) {
37
+ return typeof value === "string" && /^[0-9a-f]{64}$/.test(value);
38
+ }
39
+ function isUuid4(value) {
40
+ return typeof value === "string"
41
+ && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value);
42
+ }
43
+ function isEntry(value) {
44
+ return isRecord(value)
45
+ && Object.keys(value).length === 2
46
+ && Object.hasOwn(value, "sha256")
47
+ && Object.hasOwn(value, "size")
48
+ && isDigest(value.sha256)
49
+ && typeof value.size === "number"
50
+ && Number.isSafeInteger(value.size)
51
+ && value.size >= 0;
52
+ }
53
+ function objectEntry(value) {
54
+ if (!isRecord(value) || !isDigest(value.digest))
55
+ return undefined;
56
+ const entry = { ...value };
57
+ delete entry.digest;
58
+ if (!isEntry(entry) || entry.sha256 !== value.digest)
59
+ return undefined;
60
+ return { digest: value.digest, sha256: entry.sha256, size: entry.size };
61
+ }
62
+ function canonicalJson(value) {
63
+ const sort = (item) => {
64
+ if (Array.isArray(item))
65
+ return item.map(sort);
66
+ if (!isRecord(item))
67
+ return item;
68
+ return Object.fromEntries(Object.keys(item).sort().map((key) => [key, sort(item[key])]));
69
+ };
70
+ const encoded = JSON.stringify(sort(value));
71
+ if (encoded === undefined)
72
+ throw new TypeError("archive JSON must be serializable");
73
+ // Python's json.dumps default ensure_ascii=True escapes UTF-16 code units.
74
+ return Buffer.from(encoded.replace(/[\u0080-\uffff]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`));
75
+ }
76
+ function manifestJson(manifest) {
77
+ return canonicalJson({
78
+ format: manifest.format,
79
+ version: manifest.version,
80
+ repository_id: manifest.repositoryId,
81
+ repository_format: manifest.repositoryFormat,
82
+ repository_user_version: manifest.repositoryUserVersion,
83
+ runtime_python_version: manifest.runtimePythonVersion,
84
+ sqlite_version: manifest.sqliteVersion,
85
+ database: manifest.database,
86
+ objects: manifest.objects,
87
+ });
88
+ }
89
+ function parseManifest(raw) {
90
+ let parsed;
91
+ try {
92
+ parsed = JSON.parse(UTF8.decode(raw));
93
+ }
94
+ catch (error) {
95
+ throw restoreError("repository_restore_manifest_invalid", error);
96
+ }
97
+ if (!isRecord(parsed)
98
+ || parsed.format !== "flywheel.backup.v1"
99
+ || parsed.version !== 1
100
+ || !isUuid4(parsed.repository_id)
101
+ || parsed.repository_format !== "flywheel.repository.v1"
102
+ || ![1, 2, 3, 4, 5].includes(parsed.repository_user_version)
103
+ || typeof parsed.runtime_python_version !== "string"
104
+ || typeof parsed.sqlite_version !== "string"
105
+ || !isEntry(parsed.database)
106
+ || !Array.isArray(parsed.objects)) {
107
+ throw restoreError("repository_restore_manifest_invalid");
108
+ }
109
+ const objects = parsed.objects.map(objectEntry);
110
+ if (objects.some((entry) => entry === undefined))
111
+ throw restoreError("repository_restore_manifest_invalid");
112
+ return {
113
+ format: "flywheel.backup.v1",
114
+ version: 1,
115
+ repositoryId: parsed.repository_id,
116
+ repositoryFormat: "flywheel.repository.v1",
117
+ repositoryUserVersion: parsed.repository_user_version,
118
+ runtimePythonVersion: parsed.runtime_python_version,
119
+ sqliteVersion: parsed.sqlite_version,
120
+ database: parsed.database,
121
+ objects: objects,
122
+ };
123
+ }
124
+ function expectedEntries(manifest) {
125
+ const entries = new Map([[DATABASE_MEMBER, manifest.database]]);
126
+ for (const object of manifest.objects) {
127
+ if (!isDigest(object.digest) || !isEntry({ sha256: object.sha256, size: object.size }) || object.sha256 !== object.digest) {
128
+ throw restoreError("repository_restore_manifest_invalid");
129
+ }
130
+ entries.set(`${OBJECT_PREFIX}${object.digest}`, { sha256: object.sha256, size: object.size });
131
+ }
132
+ if (entries.size !== manifest.objects.length + 1)
133
+ throw restoreError("repository_restore_manifest_invalid");
134
+ return entries;
135
+ }
136
+ function memberName(entry) {
137
+ try {
138
+ return UTF8.decode(entry.fileNameRaw);
139
+ }
140
+ catch (error) {
141
+ throw restoreError("repository_restore_member_invalid", error);
142
+ }
143
+ }
144
+ function validateMember(name, entry) {
145
+ if (name.length === 0 || name.startsWith("/") || name.includes("\0") || name.split("/").includes("..") || name.endsWith("/")) {
146
+ throw restoreError("repository_restore_member_invalid");
147
+ }
148
+ if ((entry.externalFileAttributes >>> 16 & FILE_TYPE_MASK) === SYMLINK_TYPE) {
149
+ throw restoreError("repository_restore_member_invalid");
150
+ }
151
+ if (name === MANIFEST_MEMBER && entry.uncompressedSize > MAX_MANIFEST_BYTES) {
152
+ throw restoreError("repository_restore_limit_exceeded");
153
+ }
154
+ if (name === DATABASE_MEMBER && entry.uncompressedSize > MAX_DATABASE_BYTES) {
155
+ throw restoreError("repository_restore_limit_exceeded");
156
+ }
157
+ if (name.startsWith(OBJECT_PREFIX)) {
158
+ if (!isDigest(name.slice(OBJECT_PREFIX.length)))
159
+ throw restoreError("repository_restore_member_invalid");
160
+ if (entry.uncompressedSize > MAX_OBJECT_BYTES)
161
+ throw restoreError("repository_restore_limit_exceeded");
162
+ }
163
+ }
164
+ async function streamEntry(zip, entry, limit, collect) {
165
+ const hash = createHash("sha256");
166
+ let crc = 0;
167
+ let size = 0;
168
+ const chunks = [];
169
+ const stream = await zip.openReadStreamPromise(entry);
170
+ for await (const chunk of stream) {
171
+ const bytes = Buffer.from(chunk);
172
+ size += bytes.byteLength;
173
+ if (size > limit)
174
+ throw restoreError("repository_restore_limit_exceeded");
175
+ crc = crc32(bytes, crc);
176
+ hash.update(bytes);
177
+ if (collect)
178
+ chunks.push(bytes);
179
+ }
180
+ if ((crc >>> 0) !== (entry.crc32 >>> 0))
181
+ throw restoreError("repository_restore_archive_invalid");
182
+ return { bytes: collect ? Buffer.concat(chunks) : undefined, size, sha256: hash.digest("hex") };
183
+ }
184
+ async function inspectArchive(path) {
185
+ let zip;
186
+ try {
187
+ zip = await yauzl.openPromise(path, {
188
+ autoClose: false,
189
+ lazyEntries: true,
190
+ decodeStrings: false,
191
+ validateEntrySizes: false,
192
+ });
193
+ if (zip.entryCount > MAX_MEMBERS)
194
+ throw restoreError("repository_restore_limit_exceeded");
195
+ const entries = new Map();
196
+ for await (const entry of zip.eachEntry()) {
197
+ const name = memberName(entry);
198
+ if (entries.has(name))
199
+ throw restoreError("repository_restore_member_invalid");
200
+ validateMember(name, entry);
201
+ entries.set(name, entry);
202
+ if (entries.size > MAX_MEMBERS)
203
+ throw restoreError("repository_restore_limit_exceeded");
204
+ }
205
+ if (!entries.has(MANIFEST_MEMBER) || !entries.has(DATABASE_MEMBER)
206
+ || [...entries.keys()].some((name) => name !== MANIFEST_MEMBER && name !== DATABASE_MEMBER && !name.startsWith(OBJECT_PREFIX))) {
207
+ throw restoreError("repository_restore_member_invalid");
208
+ }
209
+ const manifestEntry = entries.get(MANIFEST_MEMBER);
210
+ const manifestBytes = await streamEntry(zip, manifestEntry, MAX_MANIFEST_BYTES, true);
211
+ const manifest = parseManifest(manifestBytes.bytes);
212
+ const expected = expectedEntries(manifest);
213
+ const actual = new Map([...entries].filter(([name]) => name !== MANIFEST_MEMBER));
214
+ if (actual.size !== expected.size || [...actual.keys()].some((name) => !expected.has(name))) {
215
+ throw restoreError("repository_restore_member_invalid");
216
+ }
217
+ let total = 0;
218
+ let objectsTotal = 0;
219
+ for (const [name, entry] of actual) {
220
+ const expectedEntry = expected.get(name);
221
+ if (entry.uncompressedSize !== expectedEntry.size)
222
+ throw restoreError("repository_restore_digest_mismatch");
223
+ total += entry.uncompressedSize;
224
+ if (name.startsWith(OBJECT_PREFIX))
225
+ objectsTotal += entry.uncompressedSize;
226
+ }
227
+ if (total > MAX_TOTAL_BYTES || objectsTotal > MAX_OBJECT_TOTAL_BYTES)
228
+ throw restoreError("repository_restore_limit_exceeded");
229
+ for (const [name, expectedEntry] of expected) {
230
+ const verified = await streamEntry(zip, actual.get(name), expectedEntry.size, false);
231
+ if (verified.size !== expectedEntry.size || verified.sha256 !== expectedEntry.sha256) {
232
+ throw restoreError("repository_restore_digest_mismatch");
233
+ }
234
+ }
235
+ return { manifest, entries };
236
+ }
237
+ catch (error) {
238
+ if (error instanceof RepositoryBackupError)
239
+ throw error;
240
+ throw restoreError("repository_restore_archive_invalid", error);
241
+ }
242
+ finally {
243
+ if (zip !== undefined)
244
+ zip.close();
245
+ }
246
+ }
247
+ function sameManifest(left, right) {
248
+ return manifestJson(left).equals(manifestJson(right));
249
+ }
250
+ function sameIdentity(left, right) {
251
+ return left.dev === right.dev && left.ino === right.ino;
252
+ }
253
+ function assertDirectory(parentFd, name, directoryFd, identity) {
254
+ const current = statAt(parentFd, name);
255
+ if ((current.mode & FILE_TYPE_MASK) !== DIRECTORY_TYPE || !sameIdentity(current, identity)) {
256
+ throw restoreError("repository_restore_archive_invalid");
257
+ }
258
+ const open = fstat(directoryFd);
259
+ if ((open.mode & FILE_TYPE_MASK) !== DIRECTORY_TYPE || !sameIdentity(open, identity)) {
260
+ throw restoreError("repository_restore_archive_invalid");
261
+ }
262
+ }
263
+ function openDirectoryAtOrCreate(parentFd, name) {
264
+ try {
265
+ mkdirAt(parentFd, name, PRIVATE_DIRECTORY_MODE);
266
+ }
267
+ catch (error) {
268
+ if (!(typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST"))
269
+ throw error;
270
+ }
271
+ const fd = openDirectoryAt(parentFd, name);
272
+ try {
273
+ const identity = fstat(fd);
274
+ assertDirectory(parentFd, name, fd, identity);
275
+ return { fd, identity };
276
+ }
277
+ catch (error) {
278
+ close(fd);
279
+ throw error;
280
+ }
281
+ }
282
+ async function extractMember(zip, entry, expected, parentFd, name) {
283
+ const fd = createFileExclusiveAt(parentFd, name, PRIVATE_FILE_MODE);
284
+ try {
285
+ const hash = createHash("sha256");
286
+ let crc = 0;
287
+ let size = 0;
288
+ const stream = await zip.openReadStreamPromise(entry);
289
+ for await (const chunk of stream) {
290
+ const bytes = Buffer.from(chunk);
291
+ size += bytes.byteLength;
292
+ if (size > expected.size)
293
+ throw restoreError("repository_restore_limit_exceeded");
294
+ crc = crc32(bytes, crc);
295
+ hash.update(bytes);
296
+ let offset = 0;
297
+ while (offset < bytes.byteLength)
298
+ offset += writeSync(fd, bytes, offset, bytes.byteLength - offset);
299
+ }
300
+ fsync(fd);
301
+ fchmod(fd, PRIVATE_FILE_MODE);
302
+ if (size !== expected.size || hash.digest("hex") !== expected.sha256 || (crc >>> 0) !== (entry.crc32 >>> 0)) {
303
+ throw restoreError("repository_restore_digest_mismatch");
304
+ }
305
+ }
306
+ finally {
307
+ close(fd);
308
+ }
309
+ }
310
+ export async function writeArchive(path, manifest, databasePath, objectPaths) {
311
+ const output = createWriteStream(path, { flags: "wx", mode: PRIVATE_FILE_MODE, flush: true });
312
+ const bundle = new yazl.ZipFile();
313
+ bundle.on("error", (error) => output.destroy(error));
314
+ bundle.addBuffer(manifestJson(manifest), MANIFEST_MEMBER, { compress: true });
315
+ bundle.addFile(databasePath, DATABASE_MEMBER, { compress: true });
316
+ for (const object of objectPaths)
317
+ bundle.addFile(object.path, `${OBJECT_PREFIX}${object.digest}`, { compress: false });
318
+ const written = pipeline(bundle.outputStream, output);
319
+ bundle.end();
320
+ await written;
321
+ }
322
+ export async function verifyArchive(archivePath) {
323
+ return (await inspectArchive(archivePath)).manifest;
324
+ }
325
+ export async function extractArchive(archivePath, extractionPath, manifest) {
326
+ const inspected = await inspectArchive(archivePath);
327
+ if (!sameManifest(inspected.manifest, manifest))
328
+ throw restoreError("repository_restore_manifest_invalid");
329
+ const expected = expectedEntries(inspected.manifest);
330
+ let extractionFd = -1;
331
+ let objectsFd = -1;
332
+ let sha256Fd = -1;
333
+ let zip;
334
+ try {
335
+ extractionFd = openDirectory(extractionPath);
336
+ const objects = openDirectoryAtOrCreate(extractionFd, "objects");
337
+ objectsFd = objects.fd;
338
+ const sha256 = openDirectoryAtOrCreate(objectsFd, "sha256");
339
+ sha256Fd = sha256.fd;
340
+ zip = await yauzl.openPromise(archivePath, {
341
+ autoClose: false,
342
+ lazyEntries: true,
343
+ decodeStrings: false,
344
+ validateEntrySizes: false,
345
+ });
346
+ for (const [name, expectedEntry] of expected) {
347
+ const entry = inspected.entries.get(name);
348
+ if (name === DATABASE_MEMBER) {
349
+ await extractMember(zip, entry, expectedEntry, extractionFd, DATABASE_MEMBER);
350
+ }
351
+ else {
352
+ assertDirectory(extractionFd, "objects", objectsFd, objects.identity);
353
+ assertDirectory(objectsFd, "sha256", sha256Fd, sha256.identity);
354
+ await extractMember(zip, entry, expectedEntry, sha256Fd, name.slice(OBJECT_PREFIX.length));
355
+ }
356
+ }
357
+ fsync(sha256Fd);
358
+ fsync(objectsFd);
359
+ fsync(extractionFd);
360
+ }
361
+ finally {
362
+ if (zip !== undefined)
363
+ zip.close();
364
+ if (sha256Fd >= 0)
365
+ close(sha256Fd);
366
+ if (objectsFd >= 0)
367
+ close(objectsFd);
368
+ if (extractionFd >= 0)
369
+ close(extractionFd);
370
+ }
371
+ }
372
+ //# sourceMappingURL=archive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../../../src/local/store/backup/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;A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,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;YAChF,CAAC;iBAAM,CAAC;gBACN,eAAe,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACtE,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChE,MAAM,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,KAAK,CAAC,YAAY,CAAC,CAAC;IACtB,CAAC;YAAS,CAAC;QACT,IAAI,GAAG,KAAK,SAAS;YAAE,GAAG,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,QAAQ,IAAI,CAAC;YAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,SAAS,IAAI,CAAC;YAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,YAAY,IAAI,CAAC;YAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,210 @@
1
+ import { createHash } from "node:crypto";
2
+ import { createReadStream, existsSync, lstatSync, mkdirSync, readFileSync } from "node:fs";
3
+ import { backup as sqliteBackup, DatabaseSync } from "node:sqlite";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fsync, linkAt, renameReplaceAt, statAt, unlinkAt } from "../../fs/native.js";
6
+ import { validateCanonicalHistoryIn } from "../history-validation.js";
7
+ import { withWriteConnectionAsync } from "../sqlite/connection.js";
8
+ import { loadRepositoryUserVersion } from "../sqlite/verify.js";
9
+ import { RepositoryBackupError, verifyArchive, writeArchive } from "./archive.js";
10
+ import { destinationName, RetainedPrivateDirectory } from "./retained-directory.js";
11
+ const FILE_TYPE_MASK = 0o170000;
12
+ const REGULAR_FILE_TYPE = 0o100000;
13
+ const MAX_OBJECT_BYTES = 10 * 1024 ** 2;
14
+ const MAX_OBJECT_TOTAL_BYTES = 50 * 1024 ** 3;
15
+ const MAX_DATABASE_BYTES = 10 * 1024 ** 3;
16
+ const MAX_TOTAL_BYTES = 64 * 1024 ** 3;
17
+ const MAX_MANIFEST_BYTES = 16 * 1024 ** 2;
18
+ function backupError(code, cause) {
19
+ return new RepositoryBackupError(code, cause === undefined ? undefined : { cause });
20
+ }
21
+ function sameIdentity(left, right) {
22
+ return left.dev === right.dev && left.ino === right.ino;
23
+ }
24
+ function regularEntry(parentFd, name) {
25
+ const stat = statAt(parentFd, name);
26
+ if ((stat.mode & FILE_TYPE_MASK) !== REGULAR_FILE_TYPE)
27
+ throw backupError("repository_backup_archive_invalid");
28
+ return stat;
29
+ }
30
+ async function fileEntry(path, maximumSize, unavailableCode) {
31
+ try {
32
+ const stat = lstatSync(path);
33
+ if (!stat.isFile() || stat.isSymbolicLink())
34
+ throw backupError(unavailableCode);
35
+ if (stat.size > maximumSize)
36
+ throw backupError("repository_backup_size_limit");
37
+ const hash = createHash("sha256");
38
+ for await (const chunk of createReadStream(path))
39
+ hash.update(chunk);
40
+ return { sha256: hash.digest("hex"), size: stat.size };
41
+ }
42
+ catch (error) {
43
+ if (error instanceof RepositoryBackupError)
44
+ throw error;
45
+ throw backupError(unavailableCode, error);
46
+ }
47
+ }
48
+ function validateSnapshot(path, repositoryId, loadAggregate) {
49
+ let database;
50
+ try {
51
+ database = new DatabaseSync(path, { allowExtension: false, defensive: true, readOnly: true });
52
+ validateCanonicalHistoryIn(database, repositoryId, loadAggregate);
53
+ }
54
+ catch (error) {
55
+ throw backupError("repository_backup_database_invalid", error);
56
+ }
57
+ finally {
58
+ database?.close();
59
+ }
60
+ }
61
+ async function manifestFor(repositoryId, snapshotPath, objects, snapshotValidator) {
62
+ if (repositoryId.length === 0)
63
+ throw backupError("repository_backup_repository_invalid");
64
+ const objectPaths = new Map(objects.map(object => [`sha256:${object.digest}`, object.path]));
65
+ snapshotValidator(snapshotPath, repositoryId, aggregateDigest => {
66
+ const path = objectPaths.get(aggregateDigest);
67
+ return path === undefined ? undefined : readFileSync(path);
68
+ });
69
+ const database = await fileEntry(snapshotPath, MAX_DATABASE_BYTES, "repository_backup_database_invalid");
70
+ const entries = [];
71
+ for (const { digest, path } of objects) {
72
+ const entry = await fileEntry(path, MAX_OBJECT_BYTES, "repository_backup_object_unavailable");
73
+ if (entry.sha256 !== digest)
74
+ throw backupError("repository_backup_object_unavailable");
75
+ entries.push({ digest, ...entry });
76
+ }
77
+ const objectsSize = entries.reduce((total, entry) => total + entry.size, 0);
78
+ if (objectsSize > MAX_OBJECT_TOTAL_BYTES || database.size + objectsSize > MAX_TOTAL_BYTES) {
79
+ throw backupError("repository_backup_size_limit");
80
+ }
81
+ const userVersion = loadRepositoryUserVersion(snapshotPath);
82
+ if (userVersion !== 1 && userVersion !== 2 && userVersion !== 3 && userVersion !== 4 && userVersion !== 5) {
83
+ throw backupError("repository_backup_database_invalid");
84
+ }
85
+ let databaseConnection;
86
+ let sqliteVersion;
87
+ try {
88
+ databaseConnection = new DatabaseSync(snapshotPath, { allowExtension: false, defensive: true, readOnly: true });
89
+ const row = databaseConnection.prepare("SELECT sqlite_version() AS version").get();
90
+ if (row === undefined || row === null || typeof row !== "object" || typeof row.version !== "string") {
91
+ throw backupError("repository_backup_database_invalid");
92
+ }
93
+ sqliteVersion = row.version;
94
+ }
95
+ catch (error) {
96
+ if (error instanceof RepositoryBackupError)
97
+ throw error;
98
+ throw backupError("repository_backup_database_invalid", error);
99
+ }
100
+ finally {
101
+ databaseConnection?.close();
102
+ }
103
+ const manifest = {
104
+ format: "flywheel.backup.v1",
105
+ version: 1,
106
+ repositoryId,
107
+ repositoryFormat: "flywheel.repository.v1",
108
+ repositoryUserVersion: userVersion,
109
+ runtimePythonVersion: `node:${process.versions.node}`,
110
+ sqliteVersion,
111
+ database,
112
+ objects: entries,
113
+ };
114
+ const manifestBytes = Buffer.from(JSON.stringify({
115
+ database: manifest.database,
116
+ format: manifest.format,
117
+ objects: manifest.objects,
118
+ repository_format: manifest.repositoryFormat,
119
+ repository_id: manifest.repositoryId,
120
+ repository_user_version: manifest.repositoryUserVersion,
121
+ runtime_python_version: manifest.runtimePythonVersion,
122
+ sqlite_version: manifest.sqliteVersion,
123
+ version: manifest.version,
124
+ }));
125
+ if (manifestBytes.byteLength > MAX_MANIFEST_BYTES)
126
+ throw backupError("repository_backup_size_limit");
127
+ return manifest;
128
+ }
129
+ function objectPaths(state, digests) {
130
+ const objects = join(state.statePath, "objects", "sha256");
131
+ const unique = [...new Set(digests)].sort();
132
+ return unique.map(digest => {
133
+ if (!/^[0-9a-f]{64}$/.test(digest))
134
+ throw backupError("repository_backup_object_unavailable");
135
+ return { digest, path: join(objects, digest) };
136
+ });
137
+ }
138
+ /** Creates a verifiable archive while the caller-owned retained state remains live. */
139
+ export async function backupRepository({ state, repositoryId, reachableObjectDigests, validateSnapshot: snapshotValidator = validateSnapshot, }, destination, backupOptions = {}) {
140
+ const absoluteDestination = resolve(destination);
141
+ const parentPath = dirname(absoluteDestination);
142
+ const name = destinationName(absoluteDestination);
143
+ if (existsSync(absoluteDestination) && !backupOptions.force)
144
+ throw backupError("repository_backup_exists");
145
+ try {
146
+ mkdirSync(parentPath, { recursive: true, mode: 0o700 });
147
+ if (lstatSync(parentPath).isSymbolicLink() || (existsSync(absoluteDestination) && lstatSync(absoluteDestination).isSymbolicLink())) {
148
+ throw backupError("repository_backup_location_unsupported");
149
+ }
150
+ }
151
+ catch (error) {
152
+ if (error instanceof RepositoryBackupError)
153
+ throw error;
154
+ throw backupError("repository_backup_location_unsupported", error);
155
+ }
156
+ const staging = RetainedPrivateDirectory.create(parentPath, ".flywheel-backup-");
157
+ try {
158
+ return await withWriteConnectionAsync(state, async (source) => {
159
+ const snapshotPath = join(staging.path, "db.sqlite");
160
+ const archivePath = join(staging.path, name);
161
+ try {
162
+ await sqliteBackup(source, snapshotPath, { rate: 100 });
163
+ const digests = await reachableObjectDigests();
164
+ const objects = objectPaths(state, digests);
165
+ const manifest = await manifestFor(repositoryId, snapshotPath, objects, snapshotValidator);
166
+ await writeArchive(archivePath, manifest, snapshotPath, objects);
167
+ fsync(staging.fd);
168
+ const archiveIdentity = regularEntry(staging.fd, name);
169
+ const verified = await verifyArchive(archivePath);
170
+ if (JSON.stringify(verified) !== JSON.stringify(manifest))
171
+ throw backupError("repository_backup_archive_invalid");
172
+ staging.assertCurrent("repository_backup_archive_replaced");
173
+ if (backupOptions.force) {
174
+ renameReplaceAt(staging.fd, name, staging.parentFd, name);
175
+ }
176
+ else {
177
+ try {
178
+ linkAt(staging.fd, name, staging.parentFd, name);
179
+ }
180
+ catch (error) {
181
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST") {
182
+ throw backupError("repository_backup_exists", error);
183
+ }
184
+ throw error;
185
+ }
186
+ unlinkAt(staging.fd, name);
187
+ }
188
+ fsync(staging.parentFd);
189
+ if (!sameIdentity(regularEntry(staging.parentFd, name), archiveIdentity)) {
190
+ throw backupError("repository_backup_location_replaced");
191
+ }
192
+ staging.assertParentCurrent("repository_backup_location_replaced");
193
+ return {
194
+ archiveDigest: `sha256:${(await fileEntry(absoluteDestination, MAX_TOTAL_BYTES, "repository_backup_archive_invalid")).sha256}`,
195
+ repositoryId,
196
+ verified: true,
197
+ };
198
+ }
199
+ catch (error) {
200
+ if (error instanceof RepositoryBackupError)
201
+ throw error;
202
+ throw backupError("repository_backup_archive_write_failed", error);
203
+ }
204
+ });
205
+ }
206
+ finally {
207
+ staging.finish();
208
+ }
209
+ }
210
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../../../src/local/store/backup/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA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