@paradigma-inc/flywheel 0.1.111 → 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 (628) hide show
  1. package/README.md +79 -13
  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/getting-started/flywheel-tutorial-overview.md +1 -1
  8. package/skills/flywheel/references/INTERFACES.md +2 -2
  9. package/skills/flywheel/references/experiment-design-protocol.md +32 -25
  10. package/skills/flywheel/references/flywheel-cli-tool-map.md +120 -76
  11. package/skills/flywheel/references/flywheel-mcp-tool-map.md +42 -32
  12. package/skills/flywheel/setting-up-flywheel/claude-code-cli-installation.md +1 -1
  13. package/skills/flywheel/setting-up-flywheel/codex-cli-installation.md +1 -1
  14. package/skills/flywheel/setting-up-flywheel/how-can-i-get-an-authorized-client_id-for-the-oauth-flow.md +12 -4
  15. package/skills/flywheel/setting-up-flywheel/installation-overview.md +2 -6
  16. package/skills/flywheel/setting-up-flywheel/other-hosts-installation.md +53 -26
  17. package/skills/flywheel/setting-up-flywheel/updating-flywheel-mcp.md +34 -11
  18. package/skills/flywheel-auto/SKILL.md +40 -23
  19. package/skills/flywheel-auto/evals/evals.json +1 -1
  20. package/skills/flywheel-auto/references/INTERFACES.md +2 -2
  21. package/skills/flywheel-auto/references/experiment-design-protocol.md +31 -23
  22. package/skills/flywheel-auto/references/flywheel-cli-tool-map.md +172 -127
  23. package/skills/flywheel-auto/references/flywheel-mcp-tool-map.md +22 -24
  24. package/skills/flywheel-lookahead/SKILL.md +47 -28
  25. package/skills/flywheel-lookahead/agents/openai.yaml +1 -1
  26. package/skills/flywheel-lookahead/evals/evals.json +6 -6
  27. package/skills/flywheel-lookahead/references/INTERFACES.md +2 -2
  28. package/skills/flywheel-lookahead/references/flywheel-cli-tool-map.md +172 -127
  29. package/skills/flywheel-lookahead/references/flywheel-mcp-tool-map.md +22 -24
  30. package/skills/flywheel-prove/SKILL.md +2 -2
  31. package/skills/flywheel-prove/references/workflow.md +21 -2
  32. package/skills/flywheel-reproduce/SKILL.md +39 -19
  33. package/skills/flywheel-reproduce/evals/evals.json +1 -1
  34. package/skills/flywheel-reproduce/references/INTERFACES.md +2 -2
  35. package/skills/flywheel-reproduce/references/experiment-design-protocol.md +31 -23
  36. package/skills/flywheel-reproduce/references/flywheel-cli-tool-map.md +172 -127
  37. package/skills/flywheel-reproduce/references/flywheel-mcp-tool-map.md +22 -24
  38. package/skills/flywheel-to-graph/SKILL.md +37 -17
  39. package/skills/flywheel-to-graph/references/INTERFACES.md +2 -2
  40. package/skills/flywheel-to-graph/references/flywheel-cli-tool-map.md +172 -127
  41. package/skills/flywheel-to-graph/references/flywheel-mcp-tool-map.md +22 -24
  42. package/skills/flywheel-tree/references/workflow.md +6 -37
  43. package/src/cli.mjs +1145 -1141
  44. package/src/mcp-writer.mjs +413 -435
  45. package/src/public-command-metadata.mjs +28 -5
  46. package/src/runtime/delegate.mjs +2 -19
  47. package/src/runtime/required-runtime-commands.json +83 -28
  48. package/src/runtime/runtime-config.mjs +39 -60
  49. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js +330 -0
  50. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js.map +1 -0
  51. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js +90 -139
  52. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js.map +1 -1
  53. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js +1 -1
  54. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js.map +1 -1
  55. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js +116 -0
  56. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js.map +1 -0
  57. package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.js +36 -14
  58. package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.js.map +1 -1
  59. package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.js +15 -6
  60. package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.js.map +1 -1
  61. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js +256 -0
  62. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js.map +1 -0
  63. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-delete.js +11 -0
  64. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-delete.js.map +1 -0
  65. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js +84 -0
  66. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js.map +1 -0
  67. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js +17 -0
  68. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js.map +1 -0
  69. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js +3 -7
  70. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js.map +1 -1
  71. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js +12 -0
  72. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js.map +1 -0
  73. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js +29 -0
  74. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js.map +1 -0
  75. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js +12 -0
  76. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js.map +1 -1
  77. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js +46 -10
  78. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js.map +1 -1
  79. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js +17 -40
  80. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js.map +1 -1
  81. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js +305 -0
  82. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js.map +1 -0
  83. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js +72 -0
  84. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js.map +1 -0
  85. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js +286 -0
  86. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js.map +1 -0
  87. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js +30 -5
  88. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js.map +1 -1
  89. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js +27 -12
  90. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js.map +1 -1
  91. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js +284 -0
  92. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js.map +1 -0
  93. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js +169 -0
  94. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js.map +1 -0
  95. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js +13 -0
  96. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js.map +1 -0
  97. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js +227 -0
  98. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js.map +1 -0
  99. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js +239 -263
  100. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js.map +1 -1
  101. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js +25 -0
  102. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js.map +1 -0
  103. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js +11 -9
  104. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js.map +1 -1
  105. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js +38 -45
  106. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js.map +1 -1
  107. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js +14 -17
  108. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js.map +1 -1
  109. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js +13 -8
  110. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js.map +1 -1
  111. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js +237 -66
  112. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js.map +1 -1
  113. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js +9 -9
  114. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js.map +1 -1
  115. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js +76 -0
  116. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js.map +1 -0
  117. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js +4 -138
  118. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js.map +1 -1
  119. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js +8 -13
  120. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js.map +1 -1
  121. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +362 -0
  122. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -0
  123. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js +45 -183
  124. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js.map +1 -1
  125. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js +47 -0
  126. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js.map +1 -0
  127. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js +181 -0
  128. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js.map +1 -0
  129. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +163 -0
  130. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -0
  131. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js +79 -0
  132. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js.map +1 -0
  133. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js +80 -0
  134. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js.map +1 -0
  135. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js +78 -0
  136. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js.map +1 -0
  137. package/src/runtime/vendor/flywheel-cli-dist/commands/types.js.map +1 -1
  138. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js +3 -2
  139. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js.map +1 -1
  140. package/src/runtime/vendor/flywheel-cli-dist/config/index.js +5 -0
  141. package/src/runtime/vendor/flywheel-cli-dist/config/index.js.map +1 -0
  142. package/src/runtime/vendor/flywheel-cli-dist/config/io.js +139 -0
  143. package/src/runtime/vendor/flywheel-cli-dist/config/io.js.map +1 -0
  144. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js +299 -0
  145. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js.map +1 -0
  146. package/src/runtime/vendor/flywheel-cli-dist/config/model.js +214 -0
  147. package/src/runtime/vendor/flywheel-cli-dist/config/model.js.map +1 -0
  148. package/src/runtime/vendor/flywheel-cli-dist/config/path.js +30 -0
  149. package/src/runtime/vendor/flywheel-cli-dist/config/path.js.map +1 -0
  150. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js +29 -0
  151. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js.map +1 -0
  152. package/src/runtime/vendor/flywheel-cli-dist/errors.js +1 -16
  153. package/src/runtime/vendor/flywheel-cli-dist/errors.js.map +1 -1
  154. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js +3 -3
  155. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js.map +1 -1
  156. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js +19 -9
  157. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js.map +1 -1
  158. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js +33 -4
  159. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js.map +1 -1
  160. package/src/runtime/vendor/flywheel-cli-dist/http/client.js +322 -302
  161. package/src/runtime/vendor/flywheel-cli-dist/http/client.js.map +1 -1
  162. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js +1 -21
  163. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js.map +1 -1
  164. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js +1 -0
  165. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js.map +1 -1
  166. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js +244 -0
  167. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js.map +1 -0
  168. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js +7 -0
  169. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js.map +1 -0
  170. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js +35 -0
  171. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js.map +1 -0
  172. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js +42 -0
  173. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js.map +1 -0
  174. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js +179 -0
  175. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js.map +1 -0
  176. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js +152 -0
  177. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js.map +1 -0
  178. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js +71 -0
  179. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js.map +1 -0
  180. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js +73 -0
  181. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js.map +1 -0
  182. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js +82 -0
  183. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js.map +1 -0
  184. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js +345 -0
  185. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js.map +1 -0
  186. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +57 -0
  187. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -0
  188. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +149 -0
  189. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -0
  190. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js +115 -0
  191. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js.map +1 -0
  192. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js +44 -0
  193. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js.map +1 -0
  194. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +159 -0
  195. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -0
  196. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +346 -0
  197. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -0
  198. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +37 -0
  199. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -0
  200. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js +203 -0
  201. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js.map +1 -0
  202. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js +207 -0
  203. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js.map +1 -0
  204. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js +109 -0
  205. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js.map +1 -0
  206. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js +61 -0
  207. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js.map +1 -0
  208. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js +46 -0
  209. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js.map +1 -0
  210. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js +203 -0
  211. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js.map +1 -0
  212. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js +44 -0
  213. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js.map +1 -0
  214. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js +188 -0
  215. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js.map +1 -0
  216. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js +54 -0
  217. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js.map +1 -0
  218. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js +25 -0
  219. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js.map +1 -0
  220. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js +2 -0
  221. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js.map +1 -0
  222. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js +7 -0
  223. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js.map +1 -0
  224. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js +129 -0
  225. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js.map +1 -0
  226. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js +277 -0
  227. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js.map +1 -0
  228. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js +183 -0
  229. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js.map +1 -0
  230. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js +2 -0
  231. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js.map +1 -0
  232. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js +121 -0
  233. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js.map +1 -0
  234. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js +16 -0
  235. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js.map +1 -0
  236. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js +72 -0
  237. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js.map +1 -0
  238. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +59 -0
  239. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -0
  240. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js +125 -0
  241. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js.map +1 -0
  242. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js +129 -0
  243. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js.map +1 -0
  244. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js +31 -0
  245. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js.map +1 -0
  246. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js +49 -0
  247. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js.map +1 -0
  248. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js +30 -0
  249. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js.map +1 -0
  250. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js +12 -0
  251. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js.map +1 -0
  252. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js +18 -0
  253. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js.map +1 -0
  254. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js +125 -0
  255. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js.map +1 -0
  256. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js +37 -0
  257. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js.map +1 -0
  258. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js +44 -0
  259. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js.map +1 -0
  260. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js +58 -0
  261. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js.map +1 -0
  262. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js +118 -0
  263. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js.map +1 -0
  264. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js +277 -0
  265. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js.map +1 -0
  266. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js +132 -0
  267. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js.map +1 -0
  268. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js +372 -0
  269. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js.map +1 -0
  270. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js +210 -0
  271. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js.map +1 -0
  272. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js +278 -0
  273. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js.map +1 -0
  274. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js +192 -0
  275. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js.map +1 -0
  276. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js +114 -0
  277. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js.map +1 -0
  278. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js +65 -0
  279. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js.map +1 -0
  280. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js +145 -0
  281. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js.map +1 -0
  282. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js +218 -0
  283. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js.map +1 -0
  284. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js +71 -0
  285. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js.map +1 -0
  286. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js +298 -0
  287. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js.map +1 -0
  288. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js +121 -0
  289. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js.map +1 -0
  290. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js +69 -0
  291. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js.map +1 -0
  292. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js +49 -0
  293. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js.map +1 -0
  294. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js +424 -0
  295. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js.map +1 -0
  296. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js +10 -0
  297. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js.map +1 -0
  298. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/001_initial.sql +319 -0
  299. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/002_staged_latest_values.sql +8 -0
  300. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/003_remove_cli_editing_lease.sql +21 -0
  301. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/004_hosted_association.sql +7 -0
  302. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/005_artifact_properties.sql +68 -0
  303. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js +12 -0
  304. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js.map +1 -0
  305. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js +410 -0
  306. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js.map +1 -0
  307. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js +77 -0
  308. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js.map +1 -0
  309. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +240 -0
  310. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -0
  311. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js +127 -0
  312. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js.map +1 -0
  313. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js +107 -0
  314. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js.map +1 -0
  315. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js +80 -0
  316. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js.map +1 -0
  317. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +219 -0
  318. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -0
  319. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js +164 -0
  320. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js.map +1 -0
  321. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js +20 -0
  322. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js.map +1 -0
  323. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js +41 -0
  324. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js.map +1 -0
  325. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js +22 -0
  326. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js.map +1 -0
  327. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js +188 -0
  328. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js.map +1 -0
  329. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js +5 -0
  330. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js.map +1 -0
  331. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js +214 -0
  332. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js.map +1 -0
  333. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js +4 -0
  334. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js.map +1 -0
  335. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js +44 -0
  336. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js.map +1 -0
  337. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js +38 -0
  338. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js.map +1 -0
  339. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js +284 -0
  340. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js.map +1 -0
  341. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js +133 -0
  342. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js.map +1 -0
  343. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js +98 -0
  344. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js.map +1 -0
  345. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js +161 -0
  346. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js.map +1 -0
  347. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js +97 -0
  348. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js.map +1 -0
  349. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js +69 -0
  350. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js.map +1 -0
  351. package/src/runtime/vendor/flywheel-cli-dist/main.js +651 -376
  352. package/src/runtime/vendor/flywheel-cli-dist/main.js.map +1 -1
  353. package/src/runtime/vendor/flywheel-cli-dist/output/format.js +18 -11
  354. package/src/runtime/vendor/flywheel-cli-dist/output/format.js.map +1 -1
  355. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
  356. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
  357. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
  358. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.musl.node +0 -0
  359. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  360. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.musl.node +0 -0
  361. package/src/runtime/vendor/manifest.json +252 -254
  362. package/src/setup/command.mjs +5 -0
  363. package/src/setup/io/patchers/json.mjs +1 -1
  364. package/src/setup/io/patchers/toml.mjs +3 -1
  365. package/src/setup/io/patchers/yaml.mjs +1 -1
  366. package/src/setup/modes/cli.mjs +76 -7
  367. package/src/setup/modes/mcp-command.mjs +802 -793
  368. package/src/setup/modes/mcp.mjs +7 -3
  369. package/src/setup/shared/prior-mode-detect.mjs +18 -21
  370. package/src/setup/test-seams.mjs +25 -0
  371. package/src/setup-auth.mjs +76 -10
  372. package/src/toml-lines.mjs +52 -0
  373. package/src/unified-cli.mjs +31 -16
  374. package/skills/flywheel-llm-proof-paper/scripts/__pycache__/check_paper.cpython-312.pyc +0 -0
  375. package/src/runtime/vendor/flywheel-cli-dist/auth/active-key-id.d.ts +0 -1
  376. package/src/runtime/vendor/flywheel-cli-dist/auth/baseurl.d.ts +0 -35
  377. package/src/runtime/vendor/flywheel-cli-dist/auth/config.d.ts +0 -34
  378. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js +0 -92
  379. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js.map +0 -1
  380. package/src/runtime/vendor/flywheel-cli-dist/auth/fingerprint.d.ts +0 -5
  381. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.d.ts +0 -4
  382. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js +0 -31
  383. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js.map +0 -1
  384. package/src/runtime/vendor/flywheel-cli-dist/auth/login.d.ts +0 -24
  385. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.d.ts +0 -15
  386. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js +0 -150
  387. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js.map +0 -1
  388. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.d.ts +0 -27
  389. package/src/runtime/vendor/flywheel-cli-dist/commands/_admin-auth.d.ts +0 -27
  390. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.d.ts +0 -32
  391. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js +0 -213
  392. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js.map +0 -1
  393. package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.d.ts +0 -21
  394. package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.d.ts +0 -2
  395. package/src/runtime/vendor/flywheel-cli-dist/commands/_secret-param.d.ts +0 -7
  396. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-file-out.d.ts +0 -39
  397. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-writer.d.ts +0 -34
  398. package/src/runtime/vendor/flywheel-cli-dist/commands/_wait-polling.d.ts +0 -50
  399. package/src/runtime/vendor/flywheel-cli-dist/commands/account-detach.d.ts +0 -2
  400. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-add.d.ts +0 -2
  401. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-remove.d.ts +0 -2
  402. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-set-primary.d.ts +0 -2
  403. package/src/runtime/vendor/flywheel-cli-dist/commands/account-get.d.ts +0 -2
  404. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-preview.d.ts +0 -2
  405. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-proof.d.ts +0 -2
  406. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge.d.ts +0 -2
  407. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-get.d.ts +0 -2
  408. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-set.d.ts +0 -2
  409. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export-stream.d.ts +0 -2
  410. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export.d.ts +0 -2
  411. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-list.d.ts +0 -4
  412. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-nodes-audit-list.d.ts +0 -2
  413. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.d.ts +0 -13
  414. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-create.d.ts +0 -2
  415. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-delete.d.ts +0 -2
  416. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-list.d.ts +0 -18
  417. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-rotate.d.ts +0 -2
  418. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-expire.d.ts +0 -2
  419. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-heartbeat.d.ts +0 -2
  420. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-list.d.ts +0 -2
  421. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.d.ts +0 -2
  422. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js +0 -22
  423. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js.map +0 -1
  424. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.d.ts +0 -2
  425. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js +0 -8
  426. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js.map +0 -1
  427. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-get.d.ts +0 -2
  428. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-list.d.ts +0 -2
  429. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.d.ts +0 -2
  430. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js +0 -9
  431. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js.map +0 -1
  432. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.d.ts +0 -2
  433. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js +0 -7
  434. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js.map +0 -1
  435. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.d.ts +0 -2
  436. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js +0 -15
  437. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js.map +0 -1
  438. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.d.ts +0 -2
  439. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js +0 -5
  440. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js.map +0 -1
  441. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.d.ts +0 -2
  442. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js +0 -8
  443. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js.map +0 -1
  444. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.d.ts +0 -2
  445. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js +0 -30
  446. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js.map +0 -1
  447. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.d.ts +0 -2
  448. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-mode.d.ts +0 -4
  449. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.d.ts +0 -2
  450. package/src/runtime/vendor/flywheel-cli-dist/commands/blobs-get.d.ts +0 -2
  451. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-create.d.ts +0 -2
  452. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-list.d.ts +0 -1
  453. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-revoke.d.ts +0 -1
  454. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-update.d.ts +0 -2
  455. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-snapshot.d.ts +0 -1
  456. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-acquire.d.ts +0 -2
  457. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-budgets.d.ts +0 -2
  458. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-connection.d.ts +0 -2
  459. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-funding.d.ts +0 -2
  460. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-list.d.ts +0 -2
  461. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-request-approval.d.ts +0 -2
  462. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-options.d.ts +0 -2
  463. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release-all.d.ts +0 -2
  464. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release.d.ts +0 -2
  465. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-status.d.ts +0 -2
  466. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-balance.d.ts +0 -1
  467. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-billing-portal.d.ts +0 -2
  468. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-purchase.d.ts +0 -2
  469. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral-claim.d.ts +0 -2
  470. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral.d.ts +0 -1
  471. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscribe.d.ts +0 -2
  472. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscription.d.ts +0 -1
  473. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-transactions.d.ts +0 -2
  474. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-usage.d.ts +0 -2
  475. package/src/runtime/vendor/flywheel-cli-dist/commands/destructive-confirmation.d.ts +0 -2
  476. package/src/runtime/vendor/flywheel-cli-dist/commands/enums.d.ts +0 -22
  477. package/src/runtime/vendor/flywheel-cli-dist/commands/env.d.ts +0 -8
  478. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-launch.d.ts +0 -2
  479. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-list.d.ts +0 -1
  480. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-terminate.d.ts +0 -2
  481. package/src/runtime/vendor/flywheel-cli-dist/commands/export-history.d.ts +0 -2
  482. package/src/runtime/vendor/flywheel-cli-dist/commands/export-subgraph.d.ts +0 -2
  483. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-pdf.d.ts +0 -2
  484. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-render-pdf.d.ts +0 -2
  485. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-stream.d.ts +0 -2
  486. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary.d.ts +0 -2
  487. package/src/runtime/vendor/flywheel-cli-dist/commands/feedback-create.d.ts +0 -2
  488. package/src/runtime/vendor/flywheel-cli-dist/commands/files-list.d.ts +0 -2
  489. package/src/runtime/vendor/flywheel-cli-dist/commands/github-disconnect.d.ts +0 -1
  490. package/src/runtime/vendor/flywheel-cli-dist/commands/github-link.d.ts +0 -2
  491. package/src/runtime/vendor/flywheel-cli-dist/commands/github-refresh-repos.d.ts +0 -1
  492. package/src/runtime/vendor/flywheel-cli-dist/commands/github-status.d.ts +0 -1
  493. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-get.d.ts +0 -2
  494. package/src/runtime/vendor/flywheel-cli-dist/commands/handler-factory.d.ts +0 -22
  495. package/src/runtime/vendor/flywheel-cli-dist/commands/help-format.d.ts +0 -31
  496. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.d.ts +0 -36
  497. package/src/runtime/vendor/flywheel-cli-dist/commands/help.d.ts +0 -17
  498. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-create.d.ts +0 -2
  499. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-delete.d.ts +0 -1
  500. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-list.d.ts +0 -2
  501. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-runs-list.d.ts +0 -2
  502. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-create.d.ts +0 -2
  503. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-delete.d.ts +0 -1
  504. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-list.d.ts +0 -1
  505. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-update.d.ts +0 -2
  506. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-set-enabled.d.ts +0 -2
  507. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-update.d.ts +0 -2
  508. package/src/runtime/vendor/flywheel-cli-dist/commands/import-subgraph.d.ts +0 -2
  509. package/src/runtime/vendor/flywheel-cli-dist/commands/index.d.ts +0 -23
  510. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-remove.d.ts +0 -1
  511. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-set.d.ts +0 -2
  512. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-status.d.ts +0 -1
  513. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-remove.d.ts +0 -1
  514. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-set.d.ts +0 -2
  515. package/src/runtime/vendor/flywheel-cli-dist/commands/machines-list.d.ts +0 -1
  516. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.d.ts +0 -2
  517. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js +0 -15
  518. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js.map +0 -1
  519. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.d.ts +0 -2
  520. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js +0 -10
  521. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js.map +0 -1
  522. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.d.ts +0 -2
  523. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js +0 -8
  524. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js.map +0 -1
  525. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.d.ts +0 -2
  526. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js +0 -6
  527. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js.map +0 -1
  528. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.d.ts +0 -2
  529. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js +0 -7
  530. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js.map +0 -1
  531. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.d.ts +0 -2
  532. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js +0 -6
  533. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js.map +0 -1
  534. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.d.ts +0 -2
  535. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js +0 -16
  536. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js.map +0 -1
  537. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.d.ts +0 -2
  538. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js +0 -11
  539. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js.map +0 -1
  540. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-files.d.ts +0 -1
  541. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-get.d.ts +0 -2
  542. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-list.d.ts +0 -2
  543. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.d.ts +0 -2
  544. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js +0 -33
  545. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js.map +0 -1
  546. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.d.ts +0 -2
  547. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js +0 -8
  548. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js.map +0 -1
  549. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.d.ts +0 -2
  550. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js +0 -15
  551. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js.map +0 -1
  552. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-ancestry.d.ts +0 -2
  553. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-summary.d.ts +0 -2
  554. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-tree.d.ts +0 -2
  555. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-resolve-slug.d.ts +0 -2
  556. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-get.d.ts +0 -1
  557. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set-bulk.d.ts +0 -2
  558. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set.d.ts +0 -2
  559. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-summaries.d.ts +0 -2
  560. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-acquire.d.ts +0 -2
  561. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-heartbeat.d.ts +0 -2
  562. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-release.d.ts +0 -2
  563. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.d.ts +0 -2
  564. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.d.ts +0 -2
  565. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.d.ts +0 -2
  566. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.d.ts +0 -2
  567. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/account.d.ts +0 -2
  568. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.d.ts +0 -8
  569. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/api-keys.d.ts +0 -2
  570. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/approval.d.ts +0 -2
  571. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.d.ts +0 -2
  572. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js +0 -140
  573. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js.map +0 -1
  574. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.d.ts +0 -2
  575. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/budgets.d.ts +0 -2
  576. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/compute.d.ts +0 -2
  577. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/credits.d.ts +0 -2
  578. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/env.d.ts +0 -2
  579. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/executions.d.ts +0 -2
  580. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/export.d.ts +0 -2
  581. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/github.d.ts +0 -2
  582. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/graph.d.ts +0 -2
  583. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hooks.d.ts +0 -2
  584. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/integrations.d.ts +0 -2
  585. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.d.ts +0 -2
  586. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.d.ts +0 -2
  587. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/resources.d.ts +0 -2
  588. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/sharing.d.ts +0 -2
  589. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.d.ts +0 -2
  590. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js +0 -98
  591. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js.map +0 -1
  592. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/updates.d.ts +0 -2
  593. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.d.ts +0 -27
  594. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-refresh.d.ts +0 -2
  595. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-resolve.d.ts +0 -2
  596. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.d.ts +0 -2
  597. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js +0 -25
  598. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js.map +0 -1
  599. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.d.ts +0 -2
  600. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js +0 -25
  601. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js.map +0 -1
  602. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.d.ts +0 -2
  603. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js +0 -11
  604. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js.map +0 -1
  605. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.d.ts +0 -2
  606. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js +0 -28
  607. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js.map +0 -1
  608. package/src/runtime/vendor/flywheel-cli-dist/commands/types.d.ts +0 -30
  609. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide-all-active.d.ts +0 -1
  610. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide.d.ts +0 -2
  611. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-list.d.ts +0 -2
  612. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.d.ts +0 -6
  613. package/src/runtime/vendor/flywheel-cli-dist/commands/utils.d.ts +0 -11
  614. package/src/runtime/vendor/flywheel-cli-dist/errors.d.ts +0 -86
  615. package/src/runtime/vendor/flywheel-cli-dist/exit-codes.d.ts +0 -8
  616. package/src/runtime/vendor/flywheel-cli-dist/generatedFeedbackContract.d.ts +0 -41
  617. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.d.ts +0 -13
  618. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.d.ts +0 -26
  619. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.d.ts +0 -17
  620. package/src/runtime/vendor/flywheel-cli-dist/http/client.d.ts +0 -91
  621. package/src/runtime/vendor/flywheel-cli-dist/http/debug.d.ts +0 -5
  622. package/src/runtime/vendor/flywheel-cli-dist/http/poll.d.ts +0 -18
  623. package/src/runtime/vendor/flywheel-cli-dist/http/retry.d.ts +0 -30
  624. package/src/runtime/vendor/flywheel-cli-dist/main.d.ts +0 -33
  625. package/src/runtime/vendor/flywheel-cli-dist/output/format.d.ts +0 -9
  626. package/src/runtime/vendor/flywheel-cli-dist/runtime-entry.d.ts +0 -1
  627. package/src/runtime/vendor/flywheel-cli-dist/version.d.ts +0 -3
  628. package/src/secure-write.mjs +0 -43
@@ -0,0 +1,284 @@
1
+ import { createHash } from "node:crypto";
2
+ import { applyOrdinaryAtomic } from "../apply.js";
3
+ import { commitLatestValues, listCommitsIn, loadCommitByOperationId, workspaceHeadIn } from "../commits.js";
4
+ import { rootedObjectDigestsIn, reachableObjectDigestsIn, assertObjectBytesAvailable } from "../gc.js";
5
+ import { snapshotBytesFromConnection, snapshotTablesFromConnection } from "../snapshot/read.js";
6
+ import { replaceSnapshotTables } from "../snapshot/replace.js";
7
+ import { canonicalSnapshotBytes, snapshotRequiredObjectDigests, snapshotTables } from "../snapshot/validate.js";
8
+ import { applySyncAtomic } from "../sync.js";
9
+ import { applyWorkspaceAtomicIn } from "../workspace.js";
10
+ import { workspaceStateIn } from "../workspace-state.js";
11
+ import { withReadConnection, withWriteConnection } from "./connection.js";
12
+ import { RepositoryStoreError } from "./errors.js";
13
+ import { initializeRepository } from "./schema.js";
14
+ import { getRow, runSql } from "./rows.js";
15
+ import { verifyFormat } from "./verify.js";
16
+ const MAX_OBJECT_BYTES = 10 * 1024 * 1024;
17
+ const canonicalDigest = /^sha256:[0-9a-f]{64}$/;
18
+ function timestamp() {
19
+ return new Date().toISOString().replace(/\.(\d{3})Z$/, ".$1000Z");
20
+ }
21
+ function requireRepositoryRecord(repositoryId, clientId) {
22
+ if (typeof clientId !== "string")
23
+ throw new RepositoryStoreError("repository identity is missing");
24
+ return { repositoryId, clientId };
25
+ }
26
+ function projectionDigest(bytes) {
27
+ return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
28
+ }
29
+ function assertSnapshotMatches(repositoryId, expectedHead, snapshot) {
30
+ if (snapshot.repositoryId !== repositoryId || snapshot.headCommitId !== expectedHead) {
31
+ throw new RepositoryStoreError("projection replacement does not match head");
32
+ }
33
+ }
34
+ /** Local v1 SQLite store scoped to the command's already-retained repository state. */
35
+ export class SQLiteRepositoryStore {
36
+ #state;
37
+ #objects;
38
+ constructor(state, objectStorage = null) {
39
+ this.#state = state;
40
+ this.#objects = objectStorage;
41
+ }
42
+ initialize(repositoryId, clientId) {
43
+ initializeRepository(this.#state, repositoryId, clientId);
44
+ }
45
+ async loadRepository(repositoryId) {
46
+ return withReadConnection(this.#state, database => {
47
+ verifyFormat(database, repositoryId);
48
+ const row = getRow(database.prepare("SELECT client_id FROM repository_metadata WHERE repository_id = ?"), repositoryId);
49
+ return requireRepositoryRecord(repositoryId, row?.client_id);
50
+ });
51
+ }
52
+ async loadHead(repositoryId) {
53
+ return withReadConnection(this.#state, database => {
54
+ verifyFormat(database, repositoryId);
55
+ return { repositoryId, commitId: workspaceHeadIn(database, repositoryId) };
56
+ });
57
+ }
58
+ async loadReachableObjectDigests(repositoryId, atHead) {
59
+ const digests = withReadConnection(this.#state, database => {
60
+ verifyFormat(database, repositoryId);
61
+ if (workspaceHeadIn(database, repositoryId) !== atHead)
62
+ throw new RepositoryStoreError("repository snapshot changed");
63
+ return reachableObjectDigestsIn(database, repositoryId);
64
+ });
65
+ await assertObjectBytesAvailable(this.#objects, digests, "repository reachable object is unavailable");
66
+ withReadConnection(this.#state, database => {
67
+ verifyFormat(database, repositoryId);
68
+ if (workspaceHeadIn(database, repositoryId) !== atHead)
69
+ throw new RepositoryStoreError("repository snapshot changed");
70
+ });
71
+ return digests.map(digest => digest.slice("sha256:".length));
72
+ }
73
+ async loadCommitByOperationId(repositoryId, operationId) {
74
+ return withReadConnection(this.#state, database => {
75
+ verifyFormat(database, repositoryId);
76
+ return loadCommitByOperationId(database, repositoryId, operationId);
77
+ });
78
+ }
79
+ async listCommits(repositoryId, atHead, afterCommitId, limit) {
80
+ return withReadConnection(this.#state, database => {
81
+ verifyFormat(database, repositoryId);
82
+ return listCommitsIn(database, repositoryId, atHead, afterCommitId, limit);
83
+ });
84
+ }
85
+ async loadCommitLatestValues(repositoryId, commitId) {
86
+ return withReadConnection(this.#state, database => {
87
+ verifyFormat(database, repositoryId);
88
+ const row = getRow(database.prepare("SELECT latest_values_bytes FROM repository_commits WHERE repository_id = ? AND commit_id = ?"), repositoryId, commitId);
89
+ if (!row)
90
+ throw new RepositoryStoreError("repository commit is unavailable");
91
+ return commitLatestValues(row.latest_values_bytes).map(write => write.canonicalBytes);
92
+ });
93
+ }
94
+ async loadSnapshot(repositoryId, atHead) {
95
+ const snapshot = withReadConnection(this.#state, database => {
96
+ verifyFormat(database, repositoryId);
97
+ const head = workspaceHeadIn(database, repositoryId);
98
+ if (head !== atHead)
99
+ throw new RepositoryStoreError("repository snapshot changed");
100
+ const tables = snapshotTablesFromConnection(database, repositoryId);
101
+ return { repositoryId, headCommitId: head, canonicalBytes: canonicalSnapshotBytes(repositoryId, head, tables), tables };
102
+ });
103
+ await assertObjectBytesAvailable(this.#objects, snapshotRequiredObjectDigests(snapshot.tables), "snapshot object is unavailable");
104
+ return { repositoryId, headCommitId: snapshot.headCommitId, canonicalBytes: snapshot.canonicalBytes };
105
+ }
106
+ async loadReceipt(repositoryId, _actorId, _requestId) {
107
+ void _actorId;
108
+ void _requestId;
109
+ withReadConnection(this.#state, database => verifyFormat(database, repositoryId));
110
+ return null;
111
+ }
112
+ async installObject(repositoryId, digest, data) {
113
+ if (!canonicalDigest.test(digest))
114
+ throw new RepositoryStoreError("object digest must be canonical sha256");
115
+ if (projectionDigest(data) !== digest)
116
+ throw new RepositoryStoreError("object bytes do not match digest");
117
+ if (this.#objects === null)
118
+ throw new RepositoryStoreError("repository object storage is not configured");
119
+ withReadConnection(this.#state, database => verifyFormat(database, repositoryId));
120
+ await this.#objects.upload(digest, data, "application/octet-stream");
121
+ }
122
+ async loadObjectBytes(repositoryId, digest) {
123
+ if (this.#objects === null)
124
+ throw new RepositoryStoreError("repository object storage is not configured");
125
+ withReadConnection(this.#state, database => verifyFormat(database, repositoryId));
126
+ let data;
127
+ try {
128
+ data = await this.#objects.download(digest);
129
+ }
130
+ catch (error) {
131
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
132
+ throw new RepositoryStoreError("repository object is unavailable", { cause: error });
133
+ }
134
+ throw error;
135
+ }
136
+ if (data.byteLength > MAX_OBJECT_BYTES || projectionDigest(data) !== digest) {
137
+ throw new RepositoryStoreError("repository object is corrupt");
138
+ }
139
+ return data;
140
+ }
141
+ async collectLocalObjects(repositoryId, options) {
142
+ if (!(options.now instanceof Date) || Number.isNaN(options.now.valueOf()) || this.#objects === null) {
143
+ throw new RepositoryStoreError("local object garbage collection is unavailable");
144
+ }
145
+ const reachable = withReadConnection(this.#state, database => {
146
+ verifyFormat(database, repositoryId);
147
+ return rootedObjectDigestsIn(database, repositoryId);
148
+ });
149
+ const collection = await this.#objects.collectRepositoryGarbage(new Set(reachable), {
150
+ dryRun: options.dryRun,
151
+ now: options.now,
152
+ retentionSeconds: 14 * 24 * 60 * 60,
153
+ });
154
+ return { repositoryId, dryRun: options.dryRun, reachable, candidates: collection.candidates, deleted: collection.deleted };
155
+ }
156
+ async applyAtomic(batch) {
157
+ return batch.syncState === null
158
+ ? applyOrdinaryAtomic(this.#state, batch, this.#objects)
159
+ : applySyncAtomic(this.#state, batch, batch.syncState, this.#objects);
160
+ }
161
+ async replaceProjection(repositoryId, expectedHead, snapshot) {
162
+ assertSnapshotMatches(repositoryId, expectedHead, snapshot);
163
+ const tables = snapshotTables(snapshot);
164
+ await assertObjectBytesAvailable(this.#objects, snapshotRequiredObjectDigests(tables), "snapshot object is unavailable");
165
+ const digest = projectionDigest(snapshot.canonicalBytes);
166
+ return withWriteConnection(this.#state, database => {
167
+ verifyFormat(database, repositoryId);
168
+ database.exec("BEGIN IMMEDIATE");
169
+ try {
170
+ if (workspaceHeadIn(database, repositoryId) !== expectedHead)
171
+ throw new RepositoryStoreError("stale repository head");
172
+ replaceSnapshotTables(database, repositoryId, tables);
173
+ if (!snapshotBytesFromConnection(database, repositoryId).equals(snapshot.canonicalBytes)) {
174
+ throw new RepositoryStoreError("snapshot canonical bytes changed during projection replacement");
175
+ }
176
+ if (expectedHead === null) {
177
+ runSql(database.prepare("DELETE FROM repository_projection_checkpoints WHERE repository_id = ? AND projection_name = 'current'"), repositoryId);
178
+ }
179
+ else {
180
+ runSql(database.prepare(`INSERT INTO repository_projection_checkpoints (repository_id, projection_name, at_commit_id, projection_digest)
181
+ VALUES (?, 'current', ?, ?) ON CONFLICT(repository_id, projection_name) DO UPDATE SET
182
+ at_commit_id = excluded.at_commit_id, projection_digest = excluded.projection_digest`), repositoryId, expectedHead, digest);
183
+ }
184
+ database.exec("COMMIT");
185
+ }
186
+ catch (error) {
187
+ database.exec("ROLLBACK");
188
+ if (error instanceof RepositoryStoreError)
189
+ throw error;
190
+ throw new RepositoryStoreError("snapshot projection replacement failed", { cause: error });
191
+ }
192
+ return { digest };
193
+ });
194
+ }
195
+ async loadObjectMode(repositoryId) {
196
+ return withReadConnection(this.#state, database => {
197
+ verifyFormat(database, repositoryId);
198
+ const row = getRow(database.prepare("SELECT object_mode FROM repository_sync_state WHERE repository_id = ?"), repositoryId);
199
+ if (row?.object_mode !== "lazy" && row?.object_mode !== "all")
200
+ throw new RepositoryStoreError("repository object mode is invalid");
201
+ return row.object_mode;
202
+ });
203
+ }
204
+ async setObjectMode(repositoryId, objectMode) {
205
+ if (objectMode !== "lazy" && objectMode !== "all")
206
+ throw new RepositoryStoreError("repository object mode is invalid");
207
+ withWriteConnection(this.#state, database => {
208
+ verifyFormat(database, repositoryId);
209
+ if (runSql(database.prepare("UPDATE repository_sync_state SET object_mode = ?, updated_at = ? WHERE repository_id = ?"), objectMode, timestamp(), repositoryId).changes !== 1) {
210
+ throw new RepositoryStoreError("repository sync state is missing");
211
+ }
212
+ });
213
+ }
214
+ async recordPushResult(repositoryId, expectedRemoteHead, publishedHead, publishedSequence) {
215
+ withWriteConnection(this.#state, database => {
216
+ verifyFormat(database, repositoryId);
217
+ database.exec("BEGIN IMMEDIATE");
218
+ try {
219
+ const workspace = workspaceStateIn(database, repositoryId);
220
+ if (workspace.remoteTrackingHeadCommitId !== expectedRemoteHead || workspace.localHeadCommitId !== publishedHead ||
221
+ typeof publishedSequence !== "bigint" || publishedSequence < workspace.lastPublishedSequence) {
222
+ throw new RepositoryStoreError("repository push precondition changed");
223
+ }
224
+ const updatedAt = timestamp();
225
+ const heads = runSql(database.prepare("UPDATE repository_heads SET remote_tracking_commit_id = ?, updated_at = ? WHERE repository_id = ?"), publishedHead, updatedAt, repositoryId);
226
+ const sync = runSql(database.prepare("UPDATE repository_sync_state SET last_published_sequence = ?, updated_at = ? WHERE repository_id = ?"), publishedSequence, updatedAt, repositoryId);
227
+ if (heads.changes !== 1 || sync.changes !== 1)
228
+ throw new RepositoryStoreError("repository push state is missing");
229
+ database.exec("COMMIT");
230
+ }
231
+ catch (error) {
232
+ database.exec("ROLLBACK");
233
+ throw error;
234
+ }
235
+ });
236
+ }
237
+ async loadWorkspace(repositoryId) {
238
+ return withReadConnection(this.#state, database => {
239
+ verifyFormat(database, repositoryId);
240
+ return workspaceStateIn(database, repositoryId);
241
+ });
242
+ }
243
+ async applyWorkspaceAtomic(batch) {
244
+ return withWriteConnection(this.#state, database => {
245
+ verifyFormat(database, batch.repositoryId);
246
+ return applyWorkspaceAtomicIn(database, batch, timestamp());
247
+ });
248
+ }
249
+ async loadHostedAssociation(repositoryId) {
250
+ return withReadConnection(this.#state, database => {
251
+ verifyFormat(database, repositoryId);
252
+ const row = getRow(database.prepare("SELECT service_url, profile_name FROM repository_hosted_associations WHERE repository_id = ?"), repositoryId);
253
+ if (!row)
254
+ return null;
255
+ if (typeof row.service_url !== "string" || !row.service_url || typeof row.profile_name !== "string" || !row.profile_name) {
256
+ throw new RepositoryStoreError("repository hosted association is corrupt");
257
+ }
258
+ return [row.service_url, row.profile_name];
259
+ });
260
+ }
261
+ async attachHostedAssociation(repositoryId, serviceUrl, profileName) {
262
+ if (!serviceUrl || !profileName)
263
+ throw new RepositoryStoreError("repository hosted association is invalid");
264
+ withWriteConnection(this.#state, database => {
265
+ verifyFormat(database, repositoryId);
266
+ database.exec("BEGIN IMMEDIATE");
267
+ try {
268
+ const row = getRow(database.prepare("SELECT service_url, profile_name FROM repository_hosted_associations WHERE repository_id = ?"), repositoryId);
269
+ if (!row) {
270
+ runSql(database.prepare("INSERT INTO repository_hosted_associations (repository_id, service_url, profile_name, attached_at) VALUES (?, ?, ?, ?)"), repositoryId, serviceUrl, profileName, timestamp());
271
+ }
272
+ else if (row.service_url !== serviceUrl || row.profile_name !== profileName) {
273
+ throw new RepositoryStoreError("repository hosted association already exists");
274
+ }
275
+ database.exec("COMMIT");
276
+ }
277
+ catch (error) {
278
+ database.exec("ROLLBACK");
279
+ throw error;
280
+ }
281
+ });
282
+ }
283
+ }
284
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/local/store/sqlite/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAiB5G,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEvG,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAChH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEhD,SAAS,SAAS;IAChB,OAAO,IAAI,IAAI,EAA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WAAW,EAAE,GAAG,CAAC,YAAY,CAAU,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,YAAoB,EAAE,UAAkB,EAAE,WAAmB;QACzF,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,oBAAoB,CAAC,0CAA0C,CAAC,CAAC;QAC5G,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;YAC1C,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACjC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,8FAA8F,CAAC,EAAE,YAAY,CAAC,CAAC;gBACnJ,IAAI,CAAC,GAAG,EAAE,CAAC;oBACT,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,wHAAwH,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;gBACzM,CAAC;qBAAM,IAAI,GAAG,CAAC,WAAW,KAAK,UAAU,IAAI,GAAG,CAAC,YAAY,KAAK,WAAW,EAAE,CAAC;oBAC9E,MAAM,IAAI,oBAAoB,CAAC,8CAA8C,CAAC,CAAC;gBACjF,CAAC;gBACD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC1B,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,133 @@
1
+ import { DatabaseSync } from "node:sqlite";
2
+ import { RepositoryStoreError } from "./errors.js";
3
+ import { CURRENT_REPOSITORY_USER_VERSION } from "../migration/versions.js";
4
+ export const APPLICATION_ID = 0x46574442;
5
+ const FORMAT_ID = "flywheel.repository.v1";
6
+ const CONFLICT_COLUMNS = ["repository_id", "conflict_id", "rebase_id", "state", "canonical_bytes"];
7
+ const ARTIFACT_COLUMNS = ["repository_id", "artifact_id", "object_digest", "properties", "properties_digest", "created_by_commit_id"];
8
+ function openReadDatabase(path) {
9
+ return new DatabaseSync(path, { allowExtension: false, defensive: true, readOnly: true });
10
+ }
11
+ function pragmaValue(database, pragma) {
12
+ const row = database.prepare(`PRAGMA ${pragma}`).get();
13
+ if (row === null || typeof row !== "object")
14
+ return undefined;
15
+ return Object.values(row)[0];
16
+ }
17
+ function readString(row, name) {
18
+ const value = row?.[name];
19
+ return typeof value === "string" ? value : undefined;
20
+ }
21
+ function readNumber(row, name) {
22
+ const value = row?.[name];
23
+ return typeof value === "number" ? value : undefined;
24
+ }
25
+ function hasSupportedConflictSchema(database) {
26
+ const columns = database.prepare("PRAGMA table_info(repository_conflicts)").all()
27
+ .map((row) => readString(row, "name"));
28
+ if (columns.length !== CONFLICT_COLUMNS.length || columns.some((column, index) => column !== CONFLICT_COLUMNS[index])) {
29
+ return false;
30
+ }
31
+ const foreignKeys = new Map();
32
+ for (const row of database.prepare("PRAGMA foreign_key_list(repository_conflicts)").all()) {
33
+ const id = readNumber(row, "id");
34
+ const sequence = readNumber(row, "seq");
35
+ const table = readString(row, "table");
36
+ const from = readString(row, "from");
37
+ const to = readString(row, "to");
38
+ if (id === undefined || sequence === undefined || table === undefined || from === undefined || to === undefined)
39
+ return false;
40
+ const group = foreignKeys.get(id) ?? { table, columns: [] };
41
+ if (group.table !== table)
42
+ return false;
43
+ group.columns.push([sequence, from, to]);
44
+ foreignKeys.set(id, group);
45
+ }
46
+ if (foreignKeys.size !== 2)
47
+ return false;
48
+ const normalized = [...foreignKeys.values()].map(({ table, columns }) => [
49
+ table,
50
+ columns.sort(([left], [right]) => left - right).map(([, from, to]) => [from, to]),
51
+ ]).sort(([left], [right]) => left.localeCompare(right));
52
+ return JSON.stringify(normalized) === JSON.stringify([
53
+ ["repository_metadata", [["repository_id", "repository_id"]]],
54
+ ["repository_rebase_state", [["repository_id", "repository_id"], ["rebase_id", "rebase_id"]]],
55
+ ]);
56
+ }
57
+ function hasCurrentArtifactSchema(database) {
58
+ const columns = database.prepare("PRAGMA table_info(repository_artifacts)").all()
59
+ .map((row) => readString(row, "name"));
60
+ return columns.length === ARTIFACT_COLUMNS.length && columns.every((column, index) => column === ARTIFACT_COLUMNS[index]);
61
+ }
62
+ export function validateRepositoryDatabase(path) {
63
+ let database;
64
+ try {
65
+ database = openReadDatabase(path);
66
+ const integrityRows = database.prepare("PRAGMA integrity_check").all();
67
+ const foreignKeyRows = database.prepare("PRAGMA foreign_key_check").all();
68
+ if (JSON.stringify(integrityRows) !== JSON.stringify([{ integrity_check: "ok" }]) || foreignKeyRows.length !== 0) {
69
+ throw new RepositoryStoreError("repository database integrity is invalid");
70
+ }
71
+ }
72
+ catch (error) {
73
+ if (error instanceof RepositoryStoreError)
74
+ throw error;
75
+ throw new RepositoryStoreError("repository database integrity is invalid", { cause: error });
76
+ }
77
+ finally {
78
+ database?.close();
79
+ }
80
+ }
81
+ export function verifyFormat(database, repositoryId) {
82
+ if (pragmaValue(database, "application_id") !== APPLICATION_ID
83
+ || pragmaValue(database, "user_version") !== CURRENT_REPOSITORY_USER_VERSION
84
+ || !hasSupportedConflictSchema(database)
85
+ || !hasCurrentArtifactSchema(database)) {
86
+ throw new RepositoryStoreError("unsupported or corrupt repository schema");
87
+ }
88
+ if (database.prepare("SELECT 1 FROM repository_metadata WHERE repository_id = ?").get(repositoryId) === undefined) {
89
+ throw new RepositoryStoreError("repository identity is missing");
90
+ }
91
+ }
92
+ export function validateRepositoryIdentity(path, repositoryId) {
93
+ validateRepositoryDatabase(path);
94
+ let database;
95
+ try {
96
+ database = openReadDatabase(path);
97
+ const formatRow = database.prepare("SELECT format_id FROM repository_metadata WHERE repository_id = ?").get(repositoryId);
98
+ if (pragmaValue(database, "application_id") !== APPLICATION_ID
99
+ || pragmaValue(database, "user_version") !== CURRENT_REPOSITORY_USER_VERSION
100
+ || readString(formatRow, "format_id") !== FORMAT_ID
101
+ || !hasSupportedConflictSchema(database)
102
+ || !hasCurrentArtifactSchema(database)) {
103
+ throw new RepositoryStoreError("repository database identity is invalid");
104
+ }
105
+ }
106
+ catch (error) {
107
+ if (error instanceof RepositoryStoreError)
108
+ throw error;
109
+ throw new RepositoryStoreError("repository database identity is invalid", { cause: error });
110
+ }
111
+ finally {
112
+ database?.close();
113
+ }
114
+ }
115
+ export function loadRepositoryUserVersion(path) {
116
+ let database;
117
+ try {
118
+ database = openReadDatabase(path);
119
+ const userVersion = pragmaValue(database, "user_version");
120
+ if (typeof userVersion !== "number")
121
+ throw new RepositoryStoreError("repository database identity is invalid");
122
+ return userVersion;
123
+ }
124
+ catch (error) {
125
+ if (error instanceof RepositoryStoreError)
126
+ throw error;
127
+ throw new RepositoryStoreError("repository database identity is invalid", { cause: error });
128
+ }
129
+ finally {
130
+ database?.close();
131
+ }
132
+ }
133
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../../src/local/store/sqlite/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAE3E,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAC3C,MAAM,gBAAgB,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACnG,MAAM,gBAAgB,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;AAGtI,SAAS,gBAA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AAC;QACf,IAAI,KAAK,YAAY,oBAAoB;YAAE,MAAM,KAAK,CAAC;QACvD,MAAM,IAAI,oBAAoB,CAAC,yCAAyC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9F,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,KAAK,EAAE,CAAC;IACpB,CAAC;AACH,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { valueDigest } from "../domain/models/encoding.js";
2
+ import { canonicalLatestGroup, commitLatestValues, persistCommit } from "./commits.js";
3
+ import { LatestValueWrite } from "./contract.js";
4
+ import { SNAPSHOT_TABLES } from "./snapshot/schema.js";
5
+ import { snapshotTables } from "./snapshot/validate.js";
6
+ import { RepositoryStoreError } from "./sqlite/errors.js";
7
+ import { getRow, runSql } from "./sqlite/rows.js";
8
+ export function insertSyncCommits(database, repositoryId, commits, latestGroups) {
9
+ if (commits.length !== latestGroups.length)
10
+ throw new RepositoryStoreError("repository sync latest-value groups are invalid");
11
+ for (const [index, commit] of commits.entries()) {
12
+ if (commit.repositoryId !== repositoryId)
13
+ throw new RepositoryStoreError("repository sync commit is foreign");
14
+ const raw = latestGroups[index];
15
+ const latest = canonicalLatestGroup(raw);
16
+ const existing = getRow(database.prepare("SELECT canonical_bytes, latest_values_bytes FROM repository_commits WHERE repository_id = ? AND commit_id = ?"), repositoryId, commit.commitId);
17
+ if (existing) {
18
+ if (!(existing.canonical_bytes instanceof Uint8Array) || !commit.canonicalBytes.equals(existing.canonical_bytes))
19
+ throw new RepositoryStoreError("repository sync commit is corrupt");
20
+ if (raw.length > 0 && (!(existing.latest_values_bytes instanceof Uint8Array) || !latest.equals(existing.latest_values_bytes))) {
21
+ if (!(existing.latest_values_bytes instanceof Uint8Array) || Buffer.from(existing.latest_values_bytes).toString("utf8") !== "[]") {
22
+ throw new RepositoryStoreError("repository sync commit latest values are corrupt");
23
+ }
24
+ runSql(database.prepare("UPDATE repository_commits SET latest_values_bytes = ? WHERE repository_id = ? AND commit_id = ?"), latest, repositoryId, commit.commitId);
25
+ }
26
+ continue;
27
+ }
28
+ persistCommit(database, commit, raw, commit.authoredAt);
29
+ }
30
+ }
31
+ export function deriveSyncLatestValues(database, commit, localSnapshot, manualValues) {
32
+ let tables;
33
+ let originalWrites;
34
+ const writes = [];
35
+ for (const operation of commit.operations) {
36
+ const payload = operation.payload;
37
+ let ownerType;
38
+ let ownerId;
39
+ let field;
40
+ switch (operation.type) {
41
+ case "node.field.set.v1":
42
+ ownerType = "node";
43
+ ownerId = payload.node_id;
44
+ field = payload.field;
45
+ break;
46
+ case "edge.field.set.v1":
47
+ ownerType = "edge";
48
+ ownerId = payload.edge_id;
49
+ field = "content";
50
+ break;
51
+ case "artifact.metadata.set.v1":
52
+ ownerType = "artifact";
53
+ ownerId = payload.artifact_id;
54
+ field = payload.field;
55
+ break;
56
+ case "artifact.properties.set.v1":
57
+ ownerType = "artifact";
58
+ ownerId = payload.artifact_id;
59
+ field = "properties";
60
+ break;
61
+ default: continue;
62
+ }
63
+ const digest = payload.new_digest;
64
+ let value = manualValues[operation.operationId];
65
+ if (value !== undefined) {
66
+ if (typeof value !== "string" || valueDigest(value) !== digest)
67
+ throw new RepositoryStoreError("manual rebase value digest is invalid");
68
+ }
69
+ else {
70
+ if (originalWrites === undefined) {
71
+ const original = getRow(database.prepare("SELECT latest_values_bytes FROM repository_commits WHERE repository_id = ? AND commit_id = ?"), commit.repositoryId, commit.rebasedFrom);
72
+ if (original === undefined)
73
+ throw new RepositoryStoreError("local rebase source commit is unavailable");
74
+ originalWrites = commitLatestValues(original.latest_values_bytes);
75
+ }
76
+ const original = originalWrites.find(write => write.ownerType === ownerType && write.ownerId === ownerId && write.field === field && write.valueDigest === digest);
77
+ if (original !== undefined) {
78
+ value = original.value;
79
+ }
80
+ else {
81
+ // Predecessor commits can lack sideband values; retain their pinned-snapshot recovery.
82
+ tables ??= snapshotTables(localSnapshot);
83
+ const tableName = ownerType === "node" ? "repository_node_latest_values" : ownerType === "edge" ? "repository_semantic_edges" : "repository_artifacts";
84
+ const columns = SNAPSHOT_TABLES.find(([name]) => name === tableName)[1];
85
+ const idIndex = columns.indexOf(`${ownerType}_id`);
86
+ const fieldIndex = columns.indexOf(String(field));
87
+ const digestIndex = columns.indexOf(`${String(field)}_digest`);
88
+ const row = tables[tableName].find(row => row[idIndex] === ownerId && row[digestIndex] === digest);
89
+ if (!row)
90
+ throw new RepositoryStoreError("local rebase latest value is unavailable");
91
+ value = row[fieldIndex];
92
+ }
93
+ }
94
+ writes.push(LatestValueWrite.fromMapping({ owner_type: ownerType, owner_id: ownerId, field, value, value_digest: digest }).canonicalBytes);
95
+ }
96
+ return writes;
97
+ }
98
+ //# sourceMappingURL=sync-commits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-commits.js","sourceRoot":"","sources":["../../../src/local/store/sync-commits.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAA2B,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,UAAU,iBAAiB,CAAC,QAAsB,EAAE,YAAoB,EAAE,OAAoC,EAAE,YAAgD;IACpK,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;QAAE,MAAM,IAAI,oBAAoB,CAAC,iDAAiD,CAAC,CAAC;IAC9H,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAChD,IA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