@murphai/hosted-execution 0.1.15 → 0.1.17

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 (656) hide show
  1. package/LICENSE +201 -674
  2. package/README.md +15 -14
  3. package/dist/auth.d.ts +11 -25
  4. package/dist/auth.d.ts.map +1 -1
  5. package/dist/auth.js +32 -76
  6. package/dist/auth.js.map +1 -1
  7. package/dist/builders.d.ts +3 -4
  8. package/dist/builders.d.ts.map +1 -1
  9. package/dist/builders.js +24 -24
  10. package/dist/builders.js.map +1 -1
  11. package/dist/bundles.d.ts +3 -13
  12. package/dist/bundles.d.ts.map +1 -1
  13. package/dist/bundles.js +1 -16
  14. package/dist/bundles.js.map +1 -1
  15. package/dist/client.d.ts +2 -26
  16. package/dist/client.d.ts.map +1 -1
  17. package/dist/client.js +38 -212
  18. package/dist/client.js.map +1 -1
  19. package/dist/contracts.d.ts +49 -118
  20. package/dist/contracts.d.ts.map +1 -1
  21. package/dist/contracts.js +15 -58
  22. package/dist/contracts.js.map +1 -1
  23. package/dist/dispatch-ref.d.ts +1 -2
  24. package/dist/dispatch-ref.d.ts.map +1 -1
  25. package/dist/dispatch-ref.js +16 -30
  26. package/dist/dispatch-ref.js.map +1 -1
  27. package/dist/env.d.ts +0 -38
  28. package/dist/env.d.ts.map +1 -1
  29. package/dist/env.js +1 -87
  30. package/dist/env.js.map +1 -1
  31. package/dist/index.d.ts +0 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +0 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/observability.d.ts +3 -1
  36. package/dist/observability.d.ts.map +1 -1
  37. package/dist/observability.js +76 -53
  38. package/dist/observability.js.map +1 -1
  39. package/dist/outbox-payload.d.ts +7 -5
  40. package/dist/outbox-payload.d.ts.map +1 -1
  41. package/dist/outbox-payload.js +75 -38
  42. package/dist/outbox-payload.js.map +1 -1
  43. package/dist/parsers.d.ts +10 -10
  44. package/dist/parsers.d.ts.map +1 -1
  45. package/dist/parsers.js +192 -139
  46. package/dist/parsers.js.map +1 -1
  47. package/dist/routes.d.ts +4 -9
  48. package/dist/routes.d.ts.map +1 -1
  49. package/dist/routes.js +7 -18
  50. package/dist/routes.js.map +1 -1
  51. package/node_modules/@murphai/core/README.md +3 -0
  52. package/node_modules/@murphai/core/dist/assessment/index.d.ts +5 -0
  53. package/node_modules/@murphai/core/dist/assessment/index.d.ts.map +1 -0
  54. package/node_modules/@murphai/core/dist/assessment/index.js +4 -0
  55. package/node_modules/@murphai/core/dist/assessment/index.js.map +1 -0
  56. package/node_modules/@murphai/core/dist/assessment/project.d.ts +9 -0
  57. package/node_modules/@murphai/core/dist/assessment/project.d.ts.map +1 -0
  58. package/node_modules/@murphai/core/dist/assessment/project.js +353 -0
  59. package/node_modules/@murphai/core/dist/assessment/project.js.map +1 -0
  60. package/node_modules/@murphai/core/dist/assessment/storage.d.ts +13 -0
  61. package/node_modules/@murphai/core/dist/assessment/storage.d.ts.map +1 -0
  62. package/node_modules/@murphai/core/dist/assessment/storage.js +202 -0
  63. package/node_modules/@murphai/core/dist/assessment/storage.js.map +1 -0
  64. package/node_modules/@murphai/core/dist/assessment/types.d.ts +112 -0
  65. package/node_modules/@murphai/core/dist/assessment/types.d.ts.map +1 -0
  66. package/node_modules/@murphai/core/dist/assessment/types.js +5 -0
  67. package/node_modules/@murphai/core/dist/assessment/types.js.map +1 -0
  68. package/node_modules/@murphai/core/dist/atomic-write.d.ts +5 -0
  69. package/node_modules/@murphai/core/dist/atomic-write.d.ts.map +1 -0
  70. package/node_modules/@murphai/core/dist/atomic-write.js +120 -0
  71. package/node_modules/@murphai/core/dist/atomic-write.js.map +1 -0
  72. package/node_modules/@murphai/core/dist/audit.d.ts +27 -0
  73. package/node_modules/@murphai/core/dist/audit.d.ts.map +1 -0
  74. package/node_modules/@murphai/core/dist/audit.js +94 -0
  75. package/node_modules/@murphai/core/dist/audit.js.map +1 -0
  76. package/node_modules/@murphai/core/dist/automation.d.ts +55 -0
  77. package/node_modules/@murphai/core/dist/automation.d.ts.map +1 -0
  78. package/node_modules/@murphai/core/dist/automation.js +411 -0
  79. package/node_modules/@murphai/core/dist/automation.js.map +1 -0
  80. package/node_modules/@murphai/core/dist/bank/allergies.d.ts +5 -0
  81. package/node_modules/@murphai/core/dist/bank/allergies.d.ts.map +1 -0
  82. package/node_modules/@murphai/core/dist/bank/allergies.js +209 -0
  83. package/node_modules/@murphai/core/dist/bank/allergies.js.map +1 -0
  84. package/node_modules/@murphai/core/dist/bank/conditions.d.ts +5 -0
  85. package/node_modules/@murphai/core/dist/bank/conditions.d.ts.map +1 -0
  86. package/node_modules/@murphai/core/dist/bank/conditions.js +249 -0
  87. package/node_modules/@murphai/core/dist/bank/conditions.js.map +1 -0
  88. package/node_modules/@murphai/core/dist/bank/foods.d.ts +8 -0
  89. package/node_modules/@murphai/core/dist/bank/foods.d.ts.map +1 -0
  90. package/node_modules/@murphai/core/dist/bank/foods.js +255 -0
  91. package/node_modules/@murphai/core/dist/bank/foods.js.map +1 -0
  92. package/node_modules/@murphai/core/dist/bank/goals.d.ts +5 -0
  93. package/node_modules/@murphai/core/dist/bank/goals.d.ts.map +1 -0
  94. package/node_modules/@murphai/core/dist/bank/goals.js +289 -0
  95. package/node_modules/@murphai/core/dist/bank/goals.js.map +1 -0
  96. package/node_modules/@murphai/core/dist/bank/index.d.ts +10 -0
  97. package/node_modules/@murphai/core/dist/bank/index.d.ts.map +1 -0
  98. package/node_modules/@murphai/core/dist/bank/index.js +10 -0
  99. package/node_modules/@murphai/core/dist/bank/index.js.map +1 -0
  100. package/node_modules/@murphai/core/dist/bank/protocols.d.ts +8 -0
  101. package/node_modules/@murphai/core/dist/bank/protocols.d.ts.map +1 -0
  102. package/node_modules/@murphai/core/dist/bank/protocols.js +466 -0
  103. package/node_modules/@murphai/core/dist/bank/protocols.js.map +1 -0
  104. package/node_modules/@murphai/core/dist/bank/providers.d.ts +46 -0
  105. package/node_modules/@murphai/core/dist/bank/providers.d.ts.map +1 -0
  106. package/node_modules/@murphai/core/dist/bank/providers.js +160 -0
  107. package/node_modules/@murphai/core/dist/bank/providers.js.map +1 -0
  108. package/node_modules/@murphai/core/dist/bank/recipes.d.ts +8 -0
  109. package/node_modules/@murphai/core/dist/bank/recipes.d.ts.map +1 -0
  110. package/node_modules/@murphai/core/dist/bank/recipes.js +287 -0
  111. package/node_modules/@murphai/core/dist/bank/recipes.js.map +1 -0
  112. package/node_modules/@murphai/core/dist/bank/shared.d.ts +39 -0
  113. package/node_modules/@murphai/core/dist/bank/shared.d.ts.map +1 -0
  114. package/node_modules/@murphai/core/dist/bank/shared.js +150 -0
  115. package/node_modules/@murphai/core/dist/bank/shared.js.map +1 -0
  116. package/node_modules/@murphai/core/dist/bank/types.d.ts +469 -0
  117. package/node_modules/@murphai/core/dist/bank/types.d.ts.map +1 -0
  118. package/node_modules/@murphai/core/dist/bank/types.js +35 -0
  119. package/node_modules/@murphai/core/dist/bank/types.js.map +1 -0
  120. package/node_modules/@murphai/core/dist/bank/workout-formats.d.ts +5 -0
  121. package/node_modules/@murphai/core/dist/bank/workout-formats.d.ts.map +1 -0
  122. package/node_modules/@murphai/core/dist/bank/workout-formats.js +204 -0
  123. package/node_modules/@murphai/core/dist/bank/workout-formats.js.map +1 -0
  124. package/node_modules/@murphai/core/dist/canonical-mutations.d.ts +54 -0
  125. package/node_modules/@murphai/core/dist/canonical-mutations.d.ts.map +1 -0
  126. package/node_modules/@murphai/core/dist/canonical-mutations.js +196 -0
  127. package/node_modules/@murphai/core/dist/canonical-mutations.js.map +1 -0
  128. package/node_modules/@murphai/core/dist/constants.d.ts +125 -0
  129. package/node_modules/@murphai/core/dist/constants.d.ts.map +1 -0
  130. package/node_modules/@murphai/core/dist/constants.js +132 -0
  131. package/node_modules/@murphai/core/dist/constants.js.map +1 -0
  132. package/node_modules/@murphai/core/dist/domains/events.d.ts +100 -0
  133. package/node_modules/@murphai/core/dist/domains/events.d.ts.map +1 -0
  134. package/node_modules/@murphai/core/dist/domains/events.js +593 -0
  135. package/node_modules/@murphai/core/dist/domains/events.js.map +1 -0
  136. package/node_modules/@murphai/core/dist/domains/experiments.d.ts +71 -0
  137. package/node_modules/@murphai/core/dist/domains/experiments.d.ts.map +1 -0
  138. package/node_modules/@murphai/core/dist/domains/experiments.js +275 -0
  139. package/node_modules/@murphai/core/dist/domains/experiments.js.map +1 -0
  140. package/node_modules/@murphai/core/dist/domains/journal.d.ts +52 -0
  141. package/node_modules/@murphai/core/dist/domains/journal.d.ts.map +1 -0
  142. package/node_modules/@murphai/core/dist/domains/journal.js +173 -0
  143. package/node_modules/@murphai/core/dist/domains/journal.js.map +1 -0
  144. package/node_modules/@murphai/core/dist/domains/shared.d.ts +37 -0
  145. package/node_modules/@murphai/core/dist/domains/shared.d.ts.map +1 -0
  146. package/node_modules/@murphai/core/dist/domains/shared.js +101 -0
  147. package/node_modules/@murphai/core/dist/domains/shared.js.map +1 -0
  148. package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts +15 -0
  149. package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts.map +1 -0
  150. package/node_modules/@murphai/core/dist/domains/vault-summary.js +58 -0
  151. package/node_modules/@murphai/core/dist/domains/vault-summary.js.map +1 -0
  152. package/node_modules/@murphai/core/dist/errors.d.ts +8 -0
  153. package/node_modules/@murphai/core/dist/errors.d.ts.map +1 -0
  154. package/node_modules/@murphai/core/dist/errors.js +14 -0
  155. package/node_modules/@murphai/core/dist/errors.js.map +1 -0
  156. package/node_modules/@murphai/core/dist/event-attachments.d.ts +69 -0
  157. package/node_modules/@murphai/core/dist/event-attachments.d.ts.map +1 -0
  158. package/node_modules/@murphai/core/dist/event-attachments.js +202 -0
  159. package/node_modules/@murphai/core/dist/event-attachments.js.map +1 -0
  160. package/node_modules/@murphai/core/dist/event-links.d.ts +15 -0
  161. package/node_modules/@murphai/core/dist/event-links.d.ts.map +1 -0
  162. package/node_modules/@murphai/core/dist/event-links.js +54 -0
  163. package/node_modules/@murphai/core/dist/event-links.js.map +1 -0
  164. package/node_modules/@murphai/core/dist/family/api.d.ts +5 -0
  165. package/node_modules/@murphai/core/dist/family/api.d.ts.map +1 -0
  166. package/node_modules/@murphai/core/dist/family/api.js +221 -0
  167. package/node_modules/@murphai/core/dist/family/api.js.map +1 -0
  168. package/node_modules/@murphai/core/dist/family/index.d.ts +3 -0
  169. package/node_modules/@murphai/core/dist/family/index.d.ts.map +1 -0
  170. package/node_modules/@murphai/core/dist/family/index.js +3 -0
  171. package/node_modules/@murphai/core/dist/family/index.js.map +1 -0
  172. package/node_modules/@murphai/core/dist/family/types.d.ts +34 -0
  173. package/node_modules/@murphai/core/dist/family/types.d.ts.map +1 -0
  174. package/node_modules/@murphai/core/dist/family/types.js +2 -0
  175. package/node_modules/@murphai/core/dist/family/types.js.map +1 -0
  176. package/node_modules/@murphai/core/dist/frontmatter.d.ts +4 -0
  177. package/node_modules/@murphai/core/dist/frontmatter.d.ts.map +1 -0
  178. package/node_modules/@murphai/core/dist/frontmatter.js +99 -0
  179. package/node_modules/@murphai/core/dist/frontmatter.js.map +1 -0
  180. package/node_modules/@murphai/core/dist/fs.d.ts +22 -0
  181. package/node_modules/@murphai/core/dist/fs.d.ts.map +1 -0
  182. package/node_modules/@murphai/core/dist/fs.js +172 -0
  183. package/node_modules/@murphai/core/dist/fs.js.map +1 -0
  184. package/node_modules/@murphai/core/dist/genetics/api.d.ts +5 -0
  185. package/node_modules/@murphai/core/dist/genetics/api.d.ts.map +1 -0
  186. package/node_modules/@murphai/core/dist/genetics/api.js +226 -0
  187. package/node_modules/@murphai/core/dist/genetics/api.js.map +1 -0
  188. package/node_modules/@murphai/core/dist/genetics/index.d.ts +3 -0
  189. package/node_modules/@murphai/core/dist/genetics/index.d.ts.map +1 -0
  190. package/node_modules/@murphai/core/dist/genetics/index.js +3 -0
  191. package/node_modules/@murphai/core/dist/genetics/index.js.map +1 -0
  192. package/node_modules/@murphai/core/dist/genetics/types.d.ts +40 -0
  193. package/node_modules/@murphai/core/dist/genetics/types.d.ts.map +1 -0
  194. package/node_modules/@murphai/core/dist/genetics/types.js +4 -0
  195. package/node_modules/@murphai/core/dist/genetics/types.js.map +1 -0
  196. package/node_modules/@murphai/core/dist/history/api.d.ts +7 -0
  197. package/node_modules/@murphai/core/dist/history/api.d.ts.map +1 -0
  198. package/node_modules/@murphai/core/dist/history/api.js +473 -0
  199. package/node_modules/@murphai/core/dist/history/api.js.map +1 -0
  200. package/node_modules/@murphai/core/dist/history/event-spine.d.ts +41 -0
  201. package/node_modules/@murphai/core/dist/history/event-spine.d.ts.map +1 -0
  202. package/node_modules/@murphai/core/dist/history/event-spine.js +111 -0
  203. package/node_modules/@murphai/core/dist/history/event-spine.js.map +1 -0
  204. package/node_modules/@murphai/core/dist/history/index.d.ts +3 -0
  205. package/node_modules/@murphai/core/dist/history/index.d.ts.map +1 -0
  206. package/node_modules/@murphai/core/dist/history/index.js +3 -0
  207. package/node_modules/@murphai/core/dist/history/index.js.map +1 -0
  208. package/node_modules/@murphai/core/dist/history/shared.d.ts +25 -0
  209. package/node_modules/@murphai/core/dist/history/shared.d.ts.map +1 -0
  210. package/node_modules/@murphai/core/dist/history/shared.js +144 -0
  211. package/node_modules/@murphai/core/dist/history/shared.js.map +1 -0
  212. package/node_modules/@murphai/core/dist/history/types.d.ts +127 -0
  213. package/node_modules/@murphai/core/dist/history/types.d.ts.map +1 -0
  214. package/node_modules/@murphai/core/dist/history/types.js +8 -0
  215. package/node_modules/@murphai/core/dist/history/types.js.map +1 -0
  216. package/node_modules/@murphai/core/dist/ids.d.ts +3 -0
  217. package/node_modules/@murphai/core/dist/ids.d.ts.map +1 -0
  218. package/node_modules/@murphai/core/dist/ids.js +20 -0
  219. package/node_modules/@murphai/core/dist/ids.js.map +1 -0
  220. package/node_modules/@murphai/core/dist/index.d.ts +30 -0
  221. package/node_modules/@murphai/core/dist/index.d.ts.map +1 -0
  222. package/node_modules/@murphai/core/dist/index.js +23 -0
  223. package/node_modules/@murphai/core/dist/index.js.map +1 -0
  224. package/node_modules/@murphai/core/dist/jsonl.d.ts +12 -0
  225. package/node_modules/@murphai/core/dist/jsonl.d.ts.map +1 -0
  226. package/node_modules/@murphai/core/dist/jsonl.js +40 -0
  227. package/node_modules/@murphai/core/dist/jsonl.js.map +1 -0
  228. package/node_modules/@murphai/core/dist/memory.d.ts +17 -0
  229. package/node_modules/@murphai/core/dist/memory.d.ts.map +1 -0
  230. package/node_modules/@murphai/core/dist/memory.js +72 -0
  231. package/node_modules/@murphai/core/dist/memory.js.map +1 -0
  232. package/node_modules/@murphai/core/dist/mutations.d.ts +150 -0
  233. package/node_modules/@murphai/core/dist/mutations.d.ts.map +1 -0
  234. package/node_modules/@murphai/core/dist/mutations.js +1109 -0
  235. package/node_modules/@murphai/core/dist/mutations.js.map +1 -0
  236. package/node_modules/@murphai/core/dist/operations/canonical-write-lock.d.ts +29 -0
  237. package/node_modules/@murphai/core/dist/operations/canonical-write-lock.d.ts.map +1 -0
  238. package/node_modules/@murphai/core/dist/operations/canonical-write-lock.js +164 -0
  239. package/node_modules/@murphai/core/dist/operations/canonical-write-lock.js.map +1 -0
  240. package/node_modules/@murphai/core/dist/operations/index.d.ts +5 -0
  241. package/node_modules/@murphai/core/dist/operations/index.d.ts.map +1 -0
  242. package/node_modules/@murphai/core/dist/operations/index.js +3 -0
  243. package/node_modules/@murphai/core/dist/operations/index.js.map +1 -0
  244. package/node_modules/@murphai/core/dist/operations/raw-manifests.d.ts +33 -0
  245. package/node_modules/@murphai/core/dist/operations/raw-manifests.d.ts.map +1 -0
  246. package/node_modules/@murphai/core/dist/operations/raw-manifests.js +105 -0
  247. package/node_modules/@murphai/core/dist/operations/raw-manifests.js.map +1 -0
  248. package/node_modules/@murphai/core/dist/operations/write-batch.d.ts +166 -0
  249. package/node_modules/@murphai/core/dist/operations/write-batch.d.ts.map +1 -0
  250. package/node_modules/@murphai/core/dist/operations/write-batch.js +886 -0
  251. package/node_modules/@murphai/core/dist/operations/write-batch.js.map +1 -0
  252. package/node_modules/@murphai/core/dist/path-safety.d.ts +19 -0
  253. package/node_modules/@murphai/core/dist/path-safety.d.ts.map +1 -0
  254. package/node_modules/@murphai/core/dist/path-safety.js +193 -0
  255. package/node_modules/@murphai/core/dist/path-safety.js.map +1 -0
  256. package/node_modules/@murphai/core/dist/profile/index.d.ts +4 -0
  257. package/node_modules/@murphai/core/dist/profile/index.d.ts.map +1 -0
  258. package/node_modules/@murphai/core/dist/profile/index.js +3 -0
  259. package/node_modules/@murphai/core/dist/profile/index.js.map +1 -0
  260. package/node_modules/@murphai/core/dist/profile/storage.d.ts +41 -0
  261. package/node_modules/@murphai/core/dist/profile/storage.d.ts.map +1 -0
  262. package/node_modules/@murphai/core/dist/profile/storage.js +225 -0
  263. package/node_modules/@murphai/core/dist/profile/storage.js.map +1 -0
  264. package/node_modules/@murphai/core/dist/profile/types.d.ts +29 -0
  265. package/node_modules/@murphai/core/dist/profile/types.d.ts.map +1 -0
  266. package/node_modules/@murphai/core/dist/profile/types.js +8 -0
  267. package/node_modules/@murphai/core/dist/profile/types.js.map +1 -0
  268. package/node_modules/@murphai/core/dist/public-mutations.d.ts +120 -0
  269. package/node_modules/@murphai/core/dist/public-mutations.d.ts.map +1 -0
  270. package/node_modules/@murphai/core/dist/public-mutations.js +275 -0
  271. package/node_modules/@murphai/core/dist/public-mutations.js.map +1 -0
  272. package/node_modules/@murphai/core/dist/raw.d.ts +28 -0
  273. package/node_modules/@murphai/core/dist/raw.d.ts.map +1 -0
  274. package/node_modules/@murphai/core/dist/raw.js +107 -0
  275. package/node_modules/@murphai/core/dist/raw.js.map +1 -0
  276. package/node_modules/@murphai/core/dist/registry/api.d.ts +80 -0
  277. package/node_modules/@murphai/core/dist/registry/api.d.ts.map +1 -0
  278. package/node_modules/@murphai/core/dist/registry/api.js +113 -0
  279. package/node_modules/@murphai/core/dist/registry/api.js.map +1 -0
  280. package/node_modules/@murphai/core/dist/registry/id-or-slug.d.ts +15 -0
  281. package/node_modules/@murphai/core/dist/registry/id-or-slug.d.ts.map +1 -0
  282. package/node_modules/@murphai/core/dist/registry/id-or-slug.js +9 -0
  283. package/node_modules/@murphai/core/dist/registry/id-or-slug.js.map +1 -0
  284. package/node_modules/@murphai/core/dist/registry/markdown.d.ts +101 -0
  285. package/node_modules/@murphai/core/dist/registry/markdown.d.ts.map +1 -0
  286. package/node_modules/@murphai/core/dist/registry/markdown.js +136 -0
  287. package/node_modules/@murphai/core/dist/registry/markdown.js.map +1 -0
  288. package/node_modules/@murphai/core/dist/shares.d.ts +36 -0
  289. package/node_modules/@murphai/core/dist/shares.d.ts.map +1 -0
  290. package/node_modules/@murphai/core/dist/shares.js +333 -0
  291. package/node_modules/@murphai/core/dist/shares.js.map +1 -0
  292. package/node_modules/@murphai/core/dist/storage-spine.d.ts +3 -0
  293. package/node_modules/@murphai/core/dist/storage-spine.d.ts.map +1 -0
  294. package/node_modules/@murphai/core/dist/storage-spine.js +3 -0
  295. package/node_modules/@murphai/core/dist/storage-spine.js.map +1 -0
  296. package/node_modules/@murphai/core/dist/time.d.ts +11 -0
  297. package/node_modules/@murphai/core/dist/time.d.ts.map +1 -0
  298. package/node_modules/@murphai/core/dist/time.js +72 -0
  299. package/node_modules/@murphai/core/dist/time.js.map +1 -0
  300. package/node_modules/@murphai/core/dist/types.d.ts +18 -0
  301. package/node_modules/@murphai/core/dist/types.d.ts.map +1 -0
  302. package/node_modules/@murphai/core/dist/types.js +7 -0
  303. package/node_modules/@murphai/core/dist/types.js.map +1 -0
  304. package/node_modules/@murphai/core/dist/vault-core-document.d.ts +8 -0
  305. package/node_modules/@murphai/core/dist/vault-core-document.d.ts.map +1 -0
  306. package/node_modules/@murphai/core/dist/vault-core-document.js +16 -0
  307. package/node_modules/@murphai/core/dist/vault-core-document.js.map +1 -0
  308. package/node_modules/@murphai/core/dist/vault-metadata.d.ts +17 -0
  309. package/node_modules/@murphai/core/dist/vault-metadata.d.ts.map +1 -0
  310. package/node_modules/@murphai/core/dist/vault-metadata.js +44 -0
  311. package/node_modules/@murphai/core/dist/vault-metadata.js.map +1 -0
  312. package/node_modules/@murphai/core/dist/vault-upgrade.d.ts +24 -0
  313. package/node_modules/@murphai/core/dist/vault-upgrade.d.ts.map +1 -0
  314. package/node_modules/@murphai/core/dist/vault-upgrade.js +44 -0
  315. package/node_modules/@murphai/core/dist/vault-upgrade.js.map +1 -0
  316. package/node_modules/@murphai/core/dist/vault.d.ts +40 -0
  317. package/node_modules/@murphai/core/dist/vault.d.ts.map +1 -0
  318. package/node_modules/@murphai/core/dist/vault.js +649 -0
  319. package/node_modules/@murphai/core/dist/vault.js.map +1 -0
  320. package/node_modules/@murphai/core/dist/write-policy.d.ts +63 -0
  321. package/node_modules/@murphai/core/dist/write-policy.d.ts.map +1 -0
  322. package/node_modules/@murphai/core/dist/write-policy.js +146 -0
  323. package/node_modules/@murphai/core/dist/write-policy.js.map +1 -0
  324. package/node_modules/@murphai/core/package.json +27 -0
  325. package/node_modules/@murphai/device-syncd/README.md +123 -0
  326. package/node_modules/@murphai/device-syncd/dist/bin.d.ts +2 -0
  327. package/node_modules/@murphai/device-syncd/dist/bin.d.ts.map +1 -0
  328. package/node_modules/@murphai/device-syncd/dist/bin.js +29 -0
  329. package/node_modules/@murphai/device-syncd/dist/bin.js.map +1 -0
  330. package/node_modules/@murphai/device-syncd/dist/client.d.ts +124 -0
  331. package/node_modules/@murphai/device-syncd/dist/client.d.ts.map +1 -0
  332. package/node_modules/@murphai/device-syncd/dist/client.js +199 -0
  333. package/node_modules/@murphai/device-syncd/dist/client.js.map +1 -0
  334. package/node_modules/@murphai/device-syncd/dist/config.d.ts +18 -0
  335. package/node_modules/@murphai/device-syncd/dist/config.d.ts.map +1 -0
  336. package/node_modules/@murphai/device-syncd/dist/config.js +279 -0
  337. package/node_modules/@murphai/device-syncd/dist/config.js.map +1 -0
  338. package/node_modules/@murphai/device-syncd/dist/crypto.d.ts +6 -0
  339. package/node_modules/@murphai/device-syncd/dist/crypto.d.ts.map +1 -0
  340. package/node_modules/@murphai/device-syncd/dist/crypto.js +27 -0
  341. package/node_modules/@murphai/device-syncd/dist/crypto.js.map +1 -0
  342. package/node_modules/@murphai/device-syncd/dist/errors.d.ts +21 -0
  343. package/node_modules/@murphai/device-syncd/dist/errors.d.ts.map +1 -0
  344. package/node_modules/@murphai/device-syncd/dist/errors.js +32 -0
  345. package/node_modules/@murphai/device-syncd/dist/errors.js.map +1 -0
  346. package/node_modules/@murphai/device-syncd/dist/hosted-hints.d.ts +3 -0
  347. package/node_modules/@murphai/device-syncd/dist/hosted-hints.d.ts.map +1 -0
  348. package/node_modules/@murphai/device-syncd/dist/hosted-hints.js +110 -0
  349. package/node_modules/@murphai/device-syncd/dist/hosted-hints.js.map +1 -0
  350. package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts +139 -0
  351. package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts.map +1 -0
  352. package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js +336 -0
  353. package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js.map +1 -0
  354. package/node_modules/@murphai/device-syncd/dist/http.d.ts +34 -0
  355. package/node_modules/@murphai/device-syncd/dist/http.d.ts.map +1 -0
  356. package/node_modules/@murphai/device-syncd/dist/http.js +644 -0
  357. package/node_modules/@murphai/device-syncd/dist/http.js.map +1 -0
  358. package/node_modules/@murphai/device-syncd/dist/index.d.ts +23 -0
  359. package/node_modules/@murphai/device-syncd/dist/index.d.ts.map +1 -0
  360. package/node_modules/@murphai/device-syncd/dist/index.js +15 -0
  361. package/node_modules/@murphai/device-syncd/dist/index.js.map +1 -0
  362. package/node_modules/@murphai/device-syncd/dist/providers/garmin.d.ts +15 -0
  363. package/node_modules/@murphai/device-syncd/dist/providers/garmin.d.ts.map +1 -0
  364. package/node_modules/@murphai/device-syncd/dist/providers/garmin.js +485 -0
  365. package/node_modules/@murphai/device-syncd/dist/providers/garmin.js.map +1 -0
  366. package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.d.ts +49 -0
  367. package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.d.ts.map +1 -0
  368. package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.js +401 -0
  369. package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.js.map +1 -0
  370. package/node_modules/@murphai/device-syncd/dist/providers/oura.d.ts +20 -0
  371. package/node_modules/@murphai/device-syncd/dist/providers/oura.d.ts.map +1 -0
  372. package/node_modules/@murphai/device-syncd/dist/providers/oura.js +804 -0
  373. package/node_modules/@murphai/device-syncd/dist/providers/oura.js.map +1 -0
  374. package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.d.ts +104 -0
  375. package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.d.ts.map +1 -0
  376. package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.js +214 -0
  377. package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.js.map +1 -0
  378. package/node_modules/@murphai/device-syncd/dist/providers/whoop.d.ts +15 -0
  379. package/node_modules/@murphai/device-syncd/dist/providers/whoop.d.ts.map +1 -0
  380. package/node_modules/@murphai/device-syncd/dist/providers/whoop.js +551 -0
  381. package/node_modules/@murphai/device-syncd/dist/providers/whoop.js.map +1 -0
  382. package/node_modules/@murphai/device-syncd/dist/public-account.d.ts +4 -0
  383. package/node_modules/@murphai/device-syncd/dist/public-account.d.ts.map +1 -0
  384. package/node_modules/@murphai/device-syncd/dist/public-account.js +13 -0
  385. package/node_modules/@murphai/device-syncd/dist/public-account.js.map +1 -0
  386. package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts +43 -0
  387. package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts.map +1 -0
  388. package/node_modules/@murphai/device-syncd/dist/public-ingress.js +353 -0
  389. package/node_modules/@murphai/device-syncd/dist/public-ingress.js.map +1 -0
  390. package/node_modules/@murphai/device-syncd/dist/registry.d.ts +3 -0
  391. package/node_modules/@murphai/device-syncd/dist/registry.d.ts.map +1 -0
  392. package/node_modules/@murphai/device-syncd/dist/registry.js +5 -0
  393. package/node_modules/@murphai/device-syncd/dist/registry.js.map +1 -0
  394. package/node_modules/@murphai/device-syncd/dist/service.d.ts +61 -0
  395. package/node_modules/@murphai/device-syncd/dist/service.d.ts.map +1 -0
  396. package/node_modules/@murphai/device-syncd/dist/service.js +496 -0
  397. package/node_modules/@murphai/device-syncd/dist/service.js.map +1 -0
  398. package/node_modules/@murphai/device-syncd/dist/shared.d.ts +26 -0
  399. package/node_modules/@murphai/device-syncd/dist/shared.d.ts.map +1 -0
  400. package/node_modules/@murphai/device-syncd/dist/shared.js +182 -0
  401. package/node_modules/@murphai/device-syncd/dist/shared.js.map +1 -0
  402. package/node_modules/@murphai/device-syncd/dist/store.d.ts +105 -0
  403. package/node_modules/@murphai/device-syncd/dist/store.d.ts.map +1 -0
  404. package/node_modules/@murphai/device-syncd/dist/store.js +965 -0
  405. package/node_modules/@murphai/device-syncd/dist/store.js.map +1 -0
  406. package/node_modules/@murphai/device-syncd/dist/types.d.ts +287 -0
  407. package/node_modules/@murphai/device-syncd/dist/types.d.ts.map +1 -0
  408. package/node_modules/@murphai/device-syncd/dist/types.js +2 -0
  409. package/node_modules/@murphai/device-syncd/dist/types.js.map +1 -0
  410. package/node_modules/@murphai/device-syncd/dist/webhook-verification.d.ts +14 -0
  411. package/node_modules/@murphai/device-syncd/dist/webhook-verification.d.ts.map +1 -0
  412. package/node_modules/@murphai/device-syncd/dist/webhook-verification.js +16 -0
  413. package/node_modules/@murphai/device-syncd/dist/webhook-verification.js.map +1 -0
  414. package/node_modules/@murphai/device-syncd/package.json +85 -0
  415. package/node_modules/@murphai/importers/README.md +34 -0
  416. package/node_modules/@murphai/importers/dist/assessment/core-port.d.ts +13 -0
  417. package/node_modules/@murphai/importers/dist/assessment/core-port.d.ts.map +1 -0
  418. package/node_modules/@murphai/importers/dist/assessment/core-port.js +13 -0
  419. package/node_modules/@murphai/importers/dist/assessment/core-port.js.map +1 -0
  420. package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.d.ts +15 -0
  421. package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.d.ts.map +1 -0
  422. package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.js +32 -0
  423. package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.js.map +1 -0
  424. package/node_modules/@murphai/importers/dist/assessment/index.d.ts +4 -0
  425. package/node_modules/@murphai/importers/dist/assessment/index.d.ts.map +1 -0
  426. package/node_modules/@murphai/importers/dist/assessment/index.js +2 -0
  427. package/node_modules/@murphai/importers/dist/assessment/index.js.map +1 -0
  428. package/node_modules/@murphai/importers/dist/core-port.d.ts +119 -0
  429. package/node_modules/@murphai/importers/dist/core-port.d.ts.map +1 -0
  430. package/node_modules/@murphai/importers/dist/core-port.js +22 -0
  431. package/node_modules/@murphai/importers/dist/core-port.js.map +1 -0
  432. package/node_modules/@murphai/importers/dist/create-importers.d.ts +17 -0
  433. package/node_modules/@murphai/importers/dist/create-importers.d.ts.map +1 -0
  434. package/node_modules/@murphai/importers/dist/create-importers.js +68 -0
  435. package/node_modules/@murphai/importers/dist/create-importers.js.map +1 -0
  436. package/node_modules/@murphai/importers/dist/csv-sample-importer.d.ts +22 -0
  437. package/node_modules/@murphai/importers/dist/csv-sample-importer.d.ts.map +1 -0
  438. package/node_modules/@murphai/importers/dist/csv-sample-importer.js +153 -0
  439. package/node_modules/@murphai/importers/dist/csv-sample-importer.js.map +1 -0
  440. package/node_modules/@murphai/importers/dist/device-providers/defaults.d.ts +5 -0
  441. package/node_modules/@murphai/importers/dist/device-providers/defaults.d.ts.map +1 -0
  442. package/node_modules/@murphai/importers/dist/device-providers/defaults.js +11 -0
  443. package/node_modules/@murphai/importers/dist/device-providers/defaults.js.map +1 -0
  444. package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.d.ts +9 -0
  445. package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.d.ts.map +1 -0
  446. package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.js +172 -0
  447. package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.js.map +1 -0
  448. package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.d.ts +12 -0
  449. package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.d.ts.map +1 -0
  450. package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.js +619 -0
  451. package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.js.map +1 -0
  452. package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.d.ts +40 -0
  453. package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.d.ts.map +1 -0
  454. package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.js +295 -0
  455. package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.js.map +1 -0
  456. package/node_modules/@murphai/importers/dist/device-providers/garmin.d.ts +19 -0
  457. package/node_modules/@murphai/importers/dist/device-providers/garmin.d.ts.map +1 -0
  458. package/node_modules/@murphai/importers/dist/device-providers/garmin.js +150 -0
  459. package/node_modules/@murphai/importers/dist/device-providers/garmin.js.map +1 -0
  460. package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.d.ts +14 -0
  461. package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.d.ts.map +1 -0
  462. package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.js +37 -0
  463. package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.js.map +1 -0
  464. package/node_modules/@murphai/importers/dist/device-providers/index.d.ts +10 -0
  465. package/node_modules/@murphai/importers/dist/device-providers/index.d.ts.map +1 -0
  466. package/node_modules/@murphai/importers/dist/device-providers/index.js +8 -0
  467. package/node_modules/@murphai/importers/dist/device-providers/index.js.map +1 -0
  468. package/node_modules/@murphai/importers/dist/device-providers/oura.d.ts +20 -0
  469. package/node_modules/@murphai/importers/dist/device-providers/oura.d.ts.map +1 -0
  470. package/node_modules/@murphai/importers/dist/device-providers/oura.js +602 -0
  471. package/node_modules/@murphai/importers/dist/device-providers/oura.js.map +1 -0
  472. package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.d.ts +491 -0
  473. package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.d.ts.map +1 -0
  474. package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.js +326 -0
  475. package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.js.map +1 -0
  476. package/node_modules/@murphai/importers/dist/device-providers/registry.d.ts +9 -0
  477. package/node_modules/@murphai/importers/dist/device-providers/registry.d.ts.map +1 -0
  478. package/node_modules/@murphai/importers/dist/device-providers/registry.js +5 -0
  479. package/node_modules/@murphai/importers/dist/device-providers/registry.js.map +1 -0
  480. package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.d.ts +81 -0
  481. package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.d.ts.map +1 -0
  482. package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.js +215 -0
  483. package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.js.map +1 -0
  484. package/node_modules/@murphai/importers/dist/device-providers/types.d.ts +12 -0
  485. package/node_modules/@murphai/importers/dist/device-providers/types.d.ts.map +1 -0
  486. package/node_modules/@murphai/importers/dist/device-providers/types.js +2 -0
  487. package/node_modules/@murphai/importers/dist/device-providers/types.js.map +1 -0
  488. package/node_modules/@murphai/importers/dist/device-providers/whoop.d.ts +16 -0
  489. package/node_modules/@murphai/importers/dist/device-providers/whoop.d.ts.map +1 -0
  490. package/node_modules/@murphai/importers/dist/device-providers/whoop.js +410 -0
  491. package/node_modules/@murphai/importers/dist/device-providers/whoop.js.map +1 -0
  492. package/node_modules/@murphai/importers/dist/document-importer.d.ts +15 -0
  493. package/node_modules/@murphai/importers/dist/document-importer.d.ts.map +1 -0
  494. package/node_modules/@murphai/importers/dist/document-importer.js +31 -0
  495. package/node_modules/@murphai/importers/dist/document-importer.js.map +1 -0
  496. package/node_modules/@murphai/importers/dist/index.d.ts +10 -0
  497. package/node_modules/@murphai/importers/dist/index.d.ts.map +1 -0
  498. package/node_modules/@murphai/importers/dist/index.js +9 -0
  499. package/node_modules/@murphai/importers/dist/index.js.map +1 -0
  500. package/node_modules/@murphai/importers/dist/meal-importer.d.ts +15 -0
  501. package/node_modules/@murphai/importers/dist/meal-importer.d.ts.map +1 -0
  502. package/node_modules/@murphai/importers/dist/meal-importer.js +39 -0
  503. package/node_modules/@murphai/importers/dist/meal-importer.js.map +1 -0
  504. package/node_modules/@murphai/importers/dist/preset-registry.d.ts +31 -0
  505. package/node_modules/@murphai/importers/dist/preset-registry.d.ts.map +1 -0
  506. package/node_modules/@murphai/importers/dist/preset-registry.js +96 -0
  507. package/node_modules/@murphai/importers/dist/preset-registry.js.map +1 -0
  508. package/node_modules/@murphai/importers/dist/shared.d.ts +31 -0
  509. package/node_modules/@murphai/importers/dist/shared.d.ts.map +1 -0
  510. package/node_modules/@murphai/importers/dist/shared.js +154 -0
  511. package/node_modules/@murphai/importers/dist/shared.js.map +1 -0
  512. package/node_modules/@murphai/importers/package.json +36 -0
  513. package/node_modules/@murphai/runtime-state/README.md +37 -0
  514. package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.d.ts +3 -0
  515. package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.d.ts.map +1 -0
  516. package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.js +80 -0
  517. package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.js.map +1 -0
  518. package/node_modules/@murphai/runtime-state/dist/assistant-state-security.d.ts +29 -0
  519. package/node_modules/@murphai/runtime-state/dist/assistant-state-security.d.ts.map +1 -0
  520. package/node_modules/@murphai/runtime-state/dist/assistant-state-security.js +159 -0
  521. package/node_modules/@murphai/runtime-state/dist/assistant-state-security.js.map +1 -0
  522. package/node_modules/@murphai/runtime-state/dist/assistant-state.d.ts +33 -0
  523. package/node_modules/@murphai/runtime-state/dist/assistant-state.d.ts.map +1 -0
  524. package/node_modules/@murphai/runtime-state/dist/assistant-state.js +47 -0
  525. package/node_modules/@murphai/runtime-state/dist/assistant-state.js.map +1 -0
  526. package/node_modules/@murphai/runtime-state/dist/assistant-usage.d.ts +56 -0
  527. package/node_modules/@murphai/runtime-state/dist/assistant-usage.d.ts.map +1 -0
  528. package/node_modules/@murphai/runtime-state/dist/assistant-usage.js +189 -0
  529. package/node_modules/@murphai/runtime-state/dist/assistant-usage.js.map +1 -0
  530. package/node_modules/@murphai/runtime-state/dist/atomic-write.d.ts +7 -0
  531. package/node_modules/@murphai/runtime-state/dist/atomic-write.d.ts.map +1 -0
  532. package/node_modules/@murphai/runtime-state/dist/atomic-write.js +27 -0
  533. package/node_modules/@murphai/runtime-state/dist/atomic-write.js.map +1 -0
  534. package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.d.ts +3 -0
  535. package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.d.ts.map +1 -0
  536. package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.js +12 -0
  537. package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.js.map +1 -0
  538. package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.d.ts +3 -0
  539. package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.d.ts.map +1 -0
  540. package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.js +13 -0
  541. package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.js.map +1 -0
  542. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.d.ts +43 -0
  543. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.d.ts.map +1 -0
  544. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.js +203 -0
  545. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.js.map +1 -0
  546. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.d.ts +13 -0
  547. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.d.ts.map +1 -0
  548. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.js +46 -0
  549. package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.js.map +1 -0
  550. package/node_modules/@murphai/runtime-state/dist/hosted-bundle.d.ts +67 -0
  551. package/node_modules/@murphai/runtime-state/dist/hosted-bundle.d.ts.map +1 -0
  552. package/node_modules/@murphai/runtime-state/dist/hosted-bundle.js +261 -0
  553. package/node_modules/@murphai/runtime-state/dist/hosted-bundle.js.map +1 -0
  554. package/node_modules/@murphai/runtime-state/dist/hosted-bundles.d.ts +31 -0
  555. package/node_modules/@murphai/runtime-state/dist/hosted-bundles.d.ts.map +1 -0
  556. package/node_modules/@murphai/runtime-state/dist/hosted-bundles.js +211 -0
  557. package/node_modules/@murphai/runtime-state/dist/hosted-bundles.js.map +1 -0
  558. package/node_modules/@murphai/runtime-state/dist/hosted-email.d.ts +50 -0
  559. package/node_modules/@murphai/runtime-state/dist/hosted-email.d.ts.map +1 -0
  560. package/node_modules/@murphai/runtime-state/dist/hosted-email.js +191 -0
  561. package/node_modules/@murphai/runtime-state/dist/hosted-email.js.map +1 -0
  562. package/node_modules/@murphai/runtime-state/dist/hosted-user-env.d.ts +14 -0
  563. package/node_modules/@murphai/runtime-state/dist/hosted-user-env.d.ts.map +1 -0
  564. package/node_modules/@murphai/runtime-state/dist/hosted-user-env.js +59 -0
  565. package/node_modules/@murphai/runtime-state/dist/hosted-user-env.js.map +1 -0
  566. package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.d.ts +83 -0
  567. package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.d.ts.map +1 -0
  568. package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.js +308 -0
  569. package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.js.map +1 -0
  570. package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.d.ts +3 -0
  571. package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.d.ts.map +1 -0
  572. package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.js +18 -0
  573. package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.js.map +1 -0
  574. package/node_modules/@murphai/runtime-state/dist/index.d.ts +7 -0
  575. package/node_modules/@murphai/runtime-state/dist/index.d.ts.map +1 -0
  576. package/node_modules/@murphai/runtime-state/dist/index.js +7 -0
  577. package/node_modules/@murphai/runtime-state/dist/index.js.map +1 -0
  578. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.d.ts +31 -0
  579. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.d.ts.map +1 -0
  580. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.js +120 -0
  581. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.js.map +1 -0
  582. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.d.ts +3 -0
  583. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.d.ts.map +1 -0
  584. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.js +17 -0
  585. package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.js.map +1 -0
  586. package/node_modules/@murphai/runtime-state/dist/local-state-files.d.ts +10 -0
  587. package/node_modules/@murphai/runtime-state/dist/local-state-files.d.ts.map +1 -0
  588. package/node_modules/@murphai/runtime-state/dist/local-state-files.js +27 -0
  589. package/node_modules/@murphai/runtime-state/dist/local-state-files.js.map +1 -0
  590. package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.d.ts +29 -0
  591. package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.d.ts.map +1 -0
  592. package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.js +82 -0
  593. package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.js.map +1 -0
  594. package/node_modules/@murphai/runtime-state/dist/locks.d.ts +46 -0
  595. package/node_modules/@murphai/runtime-state/dist/locks.d.ts.map +1 -0
  596. package/node_modules/@murphai/runtime-state/dist/locks.js +187 -0
  597. package/node_modules/@murphai/runtime-state/dist/locks.js.map +1 -0
  598. package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.d.ts +4 -0
  599. package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.d.ts.map +1 -0
  600. package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.js +35 -0
  601. package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.js.map +1 -0
  602. package/node_modules/@murphai/runtime-state/dist/node/index.d.ts +22 -0
  603. package/node_modules/@murphai/runtime-state/dist/node/index.d.ts.map +1 -0
  604. package/node_modules/@murphai/runtime-state/dist/node/index.js +22 -0
  605. package/node_modules/@murphai/runtime-state/dist/node/index.js.map +1 -0
  606. package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.d.ts +3 -0
  607. package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.d.ts.map +1 -0
  608. package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.js +12 -0
  609. package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.js.map +1 -0
  610. package/node_modules/@murphai/runtime-state/dist/process-env.d.ts +4 -0
  611. package/node_modules/@murphai/runtime-state/dist/process-env.d.ts.map +1 -0
  612. package/node_modules/@murphai/runtime-state/dist/process-env.js +124 -0
  613. package/node_modules/@murphai/runtime-state/dist/process-env.js.map +1 -0
  614. package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.d.ts +3 -0
  615. package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.d.ts.map +1 -0
  616. package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.js +13 -0
  617. package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.js.map +1 -0
  618. package/node_modules/@murphai/runtime-state/dist/runtime-paths.d.ts +48 -0
  619. package/node_modules/@murphai/runtime-state/dist/runtime-paths.d.ts.map +1 -0
  620. package/node_modules/@murphai/runtime-state/dist/runtime-paths.js +93 -0
  621. package/node_modules/@murphai/runtime-state/dist/runtime-paths.js.map +1 -0
  622. package/node_modules/@murphai/runtime-state/dist/shared.d.ts +14 -0
  623. package/node_modules/@murphai/runtime-state/dist/shared.d.ts.map +1 -0
  624. package/node_modules/@murphai/runtime-state/dist/shared.js +46 -0
  625. package/node_modules/@murphai/runtime-state/dist/shared.js.map +1 -0
  626. package/node_modules/@murphai/runtime-state/dist/sqlite.d.ts +26 -0
  627. package/node_modules/@murphai/runtime-state/dist/sqlite.d.ts.map +1 -0
  628. package/node_modules/@murphai/runtime-state/dist/sqlite.js +110 -0
  629. package/node_modules/@murphai/runtime-state/dist/sqlite.js.map +1 -0
  630. package/node_modules/@murphai/runtime-state/dist/ulid.d.ts +5 -0
  631. package/node_modules/@murphai/runtime-state/dist/ulid.d.ts.map +1 -0
  632. package/node_modules/@murphai/runtime-state/dist/ulid.js +31 -0
  633. package/node_modules/@murphai/runtime-state/dist/ulid.js.map +1 -0
  634. package/node_modules/@murphai/runtime-state/dist/versioned-json-files.d.ts +24 -0
  635. package/node_modules/@murphai/runtime-state/dist/versioned-json-files.d.ts.map +1 -0
  636. package/node_modules/@murphai/runtime-state/dist/versioned-json-files.js +30 -0
  637. package/node_modules/@murphai/runtime-state/dist/versioned-json-files.js.map +1 -0
  638. package/node_modules/@murphai/runtime-state/dist/versioned-json-state.d.ts +18 -0
  639. package/node_modules/@murphai/runtime-state/dist/versioned-json-state.d.ts.map +1 -0
  640. package/node_modules/@murphai/runtime-state/dist/versioned-json-state.js +25 -0
  641. package/node_modules/@murphai/runtime-state/dist/versioned-json-state.js.map +1 -0
  642. package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.d.ts +3 -0
  643. package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.d.ts.map +1 -0
  644. package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.js +12 -0
  645. package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.js.map +1 -0
  646. package/node_modules/@murphai/runtime-state/package.json +30 -0
  647. package/package.json +45 -11
  648. package/dist/.tsbuildinfo +0 -1
  649. package/dist/callback-hosts.d.ts +0 -19
  650. package/dist/callback-hosts.d.ts.map +0 -1
  651. package/dist/callback-hosts.js +0 -19
  652. package/dist/callback-hosts.js.map +0 -1
  653. package/dist/web-control-plane.d.ts +0 -105
  654. package/dist/web-control-plane.d.ts.map +0 -1
  655. package/dist/web-control-plane.js +0 -358
  656. package/dist/web-control-plane.js.map +0 -1
@@ -0,0 +1,965 @@
1
+ import { applySqliteRuntimeMigrations, openSqliteRuntimeDatabase, tableExists, withImmediateTransaction, } from "@murphai/runtime-state/node";
2
+ import { generatePrefixedId, maybeParseJsonObject, sanitizeStoredDeviceSyncMetadata, stringifyJson, toIsoTimestamp, } from "./shared.js";
3
+ const DEVICE_SYNC_STORE_SQLITE_SCHEMA_VERSION = 2;
4
+ const MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON = stringifyJson({});
5
+ function mapAccountRow(row) {
6
+ if (!row) {
7
+ return null;
8
+ }
9
+ return {
10
+ id: row.id,
11
+ provider: row.provider,
12
+ externalAccountId: row.external_account_id,
13
+ displayName: row.display_name,
14
+ status: row.status,
15
+ scopes: JSON.parse(row.scopes_json ?? "[]"),
16
+ disconnectGeneration: row.disconnect_generation,
17
+ accessTokenEncrypted: row.access_token_encrypted,
18
+ hostedObservedTokenVersion: row.hosted_observed_token_version,
19
+ hostedObservedUpdatedAt: row.hosted_observed_updated_at,
20
+ refreshTokenEncrypted: row.refresh_token_encrypted,
21
+ accessTokenExpiresAt: row.access_token_expires_at,
22
+ metadata: sanitizeStoredDeviceSyncMetadata(maybeParseJsonObject(row.metadata_json)),
23
+ connectedAt: row.connected_at,
24
+ lastWebhookAt: row.last_webhook_at,
25
+ lastSyncStartedAt: row.last_sync_started_at,
26
+ lastSyncCompletedAt: row.last_sync_completed_at,
27
+ lastSyncErrorAt: row.last_sync_error_at,
28
+ lastErrorCode: row.last_error_code,
29
+ lastErrorMessage: row.last_error_message,
30
+ nextReconcileAt: row.next_reconcile_at,
31
+ createdAt: row.created_at,
32
+ updatedAt: row.updated_at ?? row.created_at,
33
+ };
34
+ }
35
+ function mapJobRow(row) {
36
+ if (!row) {
37
+ return null;
38
+ }
39
+ return {
40
+ id: row.id,
41
+ provider: row.provider,
42
+ accountId: row.account_id,
43
+ kind: row.kind,
44
+ payload: maybeParseJsonObject(row.payload_json),
45
+ priority: row.priority,
46
+ availableAt: row.available_at,
47
+ attempts: row.attempts,
48
+ maxAttempts: row.max_attempts,
49
+ dedupeKey: row.dedupe_key,
50
+ status: row.status,
51
+ leaseOwner: row.lease_owner,
52
+ leaseExpiresAt: row.lease_expires_at,
53
+ lastErrorCode: row.last_error_code,
54
+ lastErrorMessage: row.last_error_message,
55
+ createdAt: row.created_at,
56
+ updatedAt: row.updated_at,
57
+ startedAt: row.started_at,
58
+ finishedAt: row.finished_at,
59
+ };
60
+ }
61
+ function mapOAuthStateRow(row) {
62
+ if (!row) {
63
+ return null;
64
+ }
65
+ return {
66
+ state: row.state,
67
+ provider: row.provider,
68
+ returnTo: row.return_to,
69
+ metadata: maybeParseJsonObject(row.metadata_json),
70
+ createdAt: row.created_at,
71
+ expiresAt: row.expires_at,
72
+ };
73
+ }
74
+ function resolveHydratedHostedAccountTokens(input) {
75
+ if (input.inputTokens) {
76
+ return {
77
+ accessTokenEncrypted: input.inputTokens.accessTokenEncrypted,
78
+ refreshTokenEncrypted: input.inputTokens.refreshTokenEncrypted ?? null,
79
+ accessTokenExpiresAt: input.inputTokens.accessTokenExpiresAt ?? null,
80
+ };
81
+ }
82
+ if (input.shouldClearTokens) {
83
+ return {
84
+ accessTokenEncrypted: "",
85
+ refreshTokenEncrypted: null,
86
+ accessTokenExpiresAt: null,
87
+ };
88
+ }
89
+ return {
90
+ accessTokenEncrypted: input.existing?.accessTokenEncrypted ?? "",
91
+ refreshTokenEncrypted: input.existing?.refreshTokenEncrypted ?? null,
92
+ accessTokenExpiresAt: input.existing?.accessTokenExpiresAt ?? null,
93
+ };
94
+ }
95
+ function assertNoLegacyDeviceSyncStore(database) {
96
+ if (!tableExists(database, "device_account")) {
97
+ return;
98
+ }
99
+ throw new Error("Unsupported legacy device-sync runtime schema detected. Remove the local device-sync database and reconnect devices.");
100
+ }
101
+ function ensureDeviceSyncStoreSchema(database) {
102
+ database.exec(`
103
+ create table if not exists oauth_state (
104
+ state text primary key,
105
+ provider text not null,
106
+ return_to text,
107
+ metadata_json text not null,
108
+ created_at text not null,
109
+ expires_at text not null
110
+ );
111
+
112
+ create index if not exists oauth_state_expires_idx
113
+ on oauth_state (expires_at);
114
+
115
+ create table if not exists device_connection (
116
+ id text primary key,
117
+ provider text not null,
118
+ external_account_id text not null,
119
+ display_name text,
120
+ status text not null,
121
+ scopes_json text not null,
122
+ disconnect_generation integer not null default 0,
123
+ metadata_json text not null,
124
+ connected_at text not null,
125
+ created_at text not null,
126
+ updated_at text not null,
127
+ unique (provider, external_account_id)
128
+ );
129
+
130
+ create index if not exists device_connection_provider_idx
131
+ on device_connection (provider, updated_at desc);
132
+
133
+ create table if not exists device_credential_state (
134
+ account_id text primary key references device_connection(id) on delete cascade,
135
+ access_token_encrypted text not null,
136
+ refresh_token_encrypted text,
137
+ access_token_expires_at text,
138
+ created_at text not null,
139
+ updated_at text not null
140
+ );
141
+
142
+ create table if not exists device_observation_state (
143
+ account_id text primary key references device_connection(id) on delete cascade,
144
+ hosted_observed_updated_at text,
145
+ hosted_observed_token_version integer,
146
+ last_webhook_at text,
147
+ last_sync_started_at text,
148
+ last_sync_completed_at text,
149
+ last_sync_error_at text,
150
+ last_error_code text,
151
+ last_error_message text,
152
+ next_reconcile_at text,
153
+ created_at text not null,
154
+ updated_at text not null
155
+ );
156
+
157
+ create table if not exists device_job (
158
+ id text primary key,
159
+ provider text not null,
160
+ account_id text not null references device_connection(id) on delete cascade,
161
+ kind text not null,
162
+ payload_json text not null,
163
+ priority integer not null default 0,
164
+ available_at text not null,
165
+ attempts integer not null default 0,
166
+ max_attempts integer not null default 5,
167
+ dedupe_key text,
168
+ status text not null,
169
+ lease_owner text,
170
+ lease_expires_at text,
171
+ last_error_code text,
172
+ last_error_message text,
173
+ created_at text not null,
174
+ updated_at text not null,
175
+ started_at text,
176
+ finished_at text
177
+ );
178
+
179
+ create index if not exists device_job_claim_idx
180
+ on device_job (status, available_at asc, priority desc, created_at asc);
181
+
182
+ create index if not exists device_job_account_idx
183
+ on device_job (account_id, status, created_at desc);
184
+
185
+ create index if not exists device_job_account_running_idx
186
+ on device_job (account_id, status, lease_expires_at);
187
+
188
+ create table if not exists webhook_trace (
189
+ provider text not null,
190
+ trace_id text not null,
191
+ external_account_id text not null,
192
+ event_type text not null,
193
+ received_at text not null,
194
+ payload_json text not null,
195
+ status text not null default 'processed',
196
+ processing_expires_at text,
197
+ primary key (provider, trace_id)
198
+ );
199
+
200
+ create index if not exists webhook_trace_received_idx
201
+ on webhook_trace (received_at desc);
202
+ `);
203
+ }
204
+ function latestIsoTimestamp(left, right) {
205
+ if (!left) {
206
+ return right;
207
+ }
208
+ if (!right) {
209
+ return left;
210
+ }
211
+ return Date.parse(left) >= Date.parse(right) ? left : right;
212
+ }
213
+ const ACCOUNT_ROW_SELECT = `
214
+ select
215
+ connection.id as id,
216
+ connection.provider as provider,
217
+ connection.external_account_id as external_account_id,
218
+ connection.display_name as display_name,
219
+ connection.status as status,
220
+ connection.scopes_json as scopes_json,
221
+ connection.disconnect_generation as disconnect_generation,
222
+ credential.access_token_encrypted as access_token_encrypted,
223
+ credential.refresh_token_encrypted as refresh_token_encrypted,
224
+ credential.access_token_expires_at as access_token_expires_at,
225
+ observation.hosted_observed_updated_at as hosted_observed_updated_at,
226
+ observation.hosted_observed_token_version as hosted_observed_token_version,
227
+ connection.metadata_json as metadata_json,
228
+ connection.connected_at as connected_at,
229
+ observation.last_webhook_at as last_webhook_at,
230
+ observation.last_sync_started_at as last_sync_started_at,
231
+ observation.last_sync_completed_at as last_sync_completed_at,
232
+ observation.last_sync_error_at as last_sync_error_at,
233
+ observation.last_error_code as last_error_code,
234
+ observation.last_error_message as last_error_message,
235
+ observation.next_reconcile_at as next_reconcile_at,
236
+ connection.created_at as created_at,
237
+ max(connection.updated_at, credential.updated_at, observation.updated_at) as updated_at
238
+ from device_connection as connection
239
+ join device_credential_state as credential
240
+ on credential.account_id = connection.id
241
+ join device_observation_state as observation
242
+ on observation.account_id = connection.id
243
+ `;
244
+ export class SqliteDeviceSyncStore {
245
+ databasePath;
246
+ database;
247
+ constructor(databasePath) {
248
+ this.databasePath = databasePath;
249
+ const database = openSqliteRuntimeDatabase(databasePath);
250
+ this.database = database;
251
+ try {
252
+ assertNoLegacyDeviceSyncStore(database);
253
+ applySqliteRuntimeMigrations(database, {
254
+ migrations: [
255
+ {
256
+ version: DEVICE_SYNC_STORE_SQLITE_SCHEMA_VERSION,
257
+ migrate(candidateDatabase) {
258
+ ensureDeviceSyncStoreSchema(candidateDatabase);
259
+ },
260
+ },
261
+ ],
262
+ schemaVersion: DEVICE_SYNC_STORE_SQLITE_SCHEMA_VERSION,
263
+ storeName: "device sync runtime",
264
+ });
265
+ }
266
+ catch (error) {
267
+ database.close();
268
+ throw error;
269
+ }
270
+ }
271
+ close() {
272
+ this.database.close();
273
+ }
274
+ summarize() {
275
+ const row = this.database.prepare(`
276
+ select
277
+ (select count(*) from device_connection) as accounts_total,
278
+ (select count(*) from device_connection where status = 'active') as accounts_active,
279
+ (select count(*) from device_job where status = 'queued') as jobs_queued,
280
+ (select count(*) from device_job where status = 'running') as jobs_running,
281
+ (select count(*) from device_job where status = 'dead') as jobs_dead,
282
+ (select count(*) from oauth_state) as oauth_states,
283
+ (select count(*) from webhook_trace) as webhook_traces
284
+ `).get();
285
+ return {
286
+ accountsTotal: row.accounts_total,
287
+ accountsActive: row.accounts_active,
288
+ jobsQueued: row.jobs_queued,
289
+ jobsRunning: row.jobs_running,
290
+ jobsDead: row.jobs_dead,
291
+ oauthStates: row.oauth_states,
292
+ webhookTraces: row.webhook_traces,
293
+ };
294
+ }
295
+ createOAuthState(input) {
296
+ this.database.prepare(`
297
+ insert into oauth_state (state, provider, return_to, metadata_json, created_at, expires_at)
298
+ values (?, ?, ?, ?, ?, ?)
299
+ `).run(input.state, input.provider, input.returnTo, stringifyJson(input.metadata ?? {}), input.createdAt, input.expiresAt);
300
+ return input;
301
+ }
302
+ deleteExpiredOAuthStates(now) {
303
+ const result = this.database.prepare("delete from oauth_state where expires_at <= ?").run(now);
304
+ return result.changes ?? 0;
305
+ }
306
+ consumeOAuthState(state, now) {
307
+ return withImmediateTransaction(this.database, () => {
308
+ const row = this.database.prepare(`
309
+ select state, provider, return_to, metadata_json, created_at, expires_at
310
+ from oauth_state
311
+ where state = ?
312
+ `).get(state);
313
+ if (!row || Date.parse(row.expires_at) <= Date.parse(now)) {
314
+ this.database.prepare("delete from oauth_state where state = ?").run(state);
315
+ return null;
316
+ }
317
+ this.database.prepare("delete from oauth_state where state = ?").run(state);
318
+ return mapOAuthStateRow(row);
319
+ });
320
+ }
321
+ listAccounts(provider) {
322
+ const rows = (provider
323
+ ? this.database.prepare(`
324
+ ${ACCOUNT_ROW_SELECT}
325
+ where connection.provider = ?
326
+ order by updated_at desc, connection.id desc
327
+ `).all(provider)
328
+ : this.database.prepare(`
329
+ ${ACCOUNT_ROW_SELECT}
330
+ order by updated_at desc, connection.id desc
331
+ `).all());
332
+ return rows.map((row) => mapAccountRow(row)).filter(Boolean);
333
+ }
334
+ getAccountById(accountId) {
335
+ const row = this.database.prepare(`
336
+ ${ACCOUNT_ROW_SELECT}
337
+ where connection.id = ?
338
+ `).get(accountId);
339
+ return mapAccountRow(row);
340
+ }
341
+ getAccountByExternalAccount(provider, externalAccountId) {
342
+ const row = this.database.prepare(`
343
+ ${ACCOUNT_ROW_SELECT}
344
+ where connection.provider = ? and connection.external_account_id = ?
345
+ `).get(provider, externalAccountId);
346
+ return mapAccountRow(row);
347
+ }
348
+ upsertAccount(input) {
349
+ return withImmediateTransaction(this.database, () => {
350
+ const existing = this.getAccountByExternalAccount(input.provider, input.externalAccountId);
351
+ const now = input.connectedAt;
352
+ const status = input.status ?? "active";
353
+ const scopesJson = stringifyJson(input.scopes ?? []);
354
+ const metadataJson = stringifyJson(sanitizeStoredDeviceSyncMetadata(input.metadata ?? {}));
355
+ if (existing) {
356
+ this.database.prepare(`
357
+ update device_connection
358
+ set display_name = ?,
359
+ status = ?,
360
+ scopes_json = ?,
361
+ metadata_json = ?,
362
+ connected_at = ?,
363
+ updated_at = ?
364
+ where id = ?
365
+ `).run(input.displayName ?? null, status, scopesJson, metadataJson, input.connectedAt, now, existing.id);
366
+ this.database.prepare(`
367
+ update device_credential_state
368
+ set access_token_encrypted = ?,
369
+ refresh_token_encrypted = ?,
370
+ access_token_expires_at = ?,
371
+ updated_at = ?
372
+ where account_id = ?
373
+ `).run(input.tokens.accessTokenEncrypted, input.tokens.refreshTokenEncrypted ?? null, input.tokens.accessTokenExpiresAt ?? null, now, existing.id);
374
+ this.database.prepare(`
375
+ update device_observation_state
376
+ set next_reconcile_at = ?,
377
+ last_sync_error_at = null,
378
+ last_error_code = null,
379
+ last_error_message = null,
380
+ updated_at = ?
381
+ where account_id = ?
382
+ `).run(input.nextReconcileAt ?? null, now, existing.id);
383
+ return this.getAccountById(existing.id);
384
+ }
385
+ const id = generatePrefixedId("dsa");
386
+ this.database.prepare(`
387
+ insert into device_connection (
388
+ id,
389
+ provider,
390
+ external_account_id,
391
+ display_name,
392
+ status,
393
+ scopes_json,
394
+ metadata_json,
395
+ connected_at,
396
+ created_at,
397
+ updated_at
398
+ ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
399
+ `).run(id, input.provider, input.externalAccountId, input.displayName ?? null, status, scopesJson, metadataJson, input.connectedAt, now, now);
400
+ this.database.prepare(`
401
+ insert into device_credential_state (
402
+ account_id,
403
+ access_token_encrypted,
404
+ refresh_token_encrypted,
405
+ access_token_expires_at,
406
+ created_at,
407
+ updated_at
408
+ ) values (?, ?, ?, ?, ?, ?)
409
+ `).run(id, input.tokens.accessTokenEncrypted, input.tokens.refreshTokenEncrypted ?? null, input.tokens.accessTokenExpiresAt ?? null, now, now);
410
+ this.database.prepare(`
411
+ insert into device_observation_state (
412
+ account_id,
413
+ hosted_observed_updated_at,
414
+ hosted_observed_token_version,
415
+ last_webhook_at,
416
+ last_sync_started_at,
417
+ last_sync_completed_at,
418
+ last_sync_error_at,
419
+ last_error_code,
420
+ last_error_message,
421
+ next_reconcile_at,
422
+ created_at,
423
+ updated_at
424
+ ) values (?, null, null, null, null, null, null, null, null, ?, ?, ?)
425
+ `).run(id, input.nextReconcileAt ?? null, now, now);
426
+ return this.getAccountById(id);
427
+ });
428
+ }
429
+ patchAccount(accountId, patch) {
430
+ return withImmediateTransaction(this.database, () => {
431
+ const existing = this.getAccountById(accountId);
432
+ if (!existing) {
433
+ throw new TypeError(`Unknown account ${accountId}`);
434
+ }
435
+ const now = toIsoTimestamp(new Date());
436
+ const metadata = sanitizeStoredDeviceSyncMetadata(patch.metadata ? { ...existing.metadata, ...patch.metadata } : existing.metadata);
437
+ const nextReconcileAt = Object.prototype.hasOwnProperty.call(patch, "nextReconcileAt")
438
+ ? patch.nextReconcileAt ?? null
439
+ : existing.nextReconcileAt;
440
+ const displayName = Object.prototype.hasOwnProperty.call(patch, "displayName")
441
+ ? patch.displayName ?? null
442
+ : existing.displayName;
443
+ const scopes = Object.prototype.hasOwnProperty.call(patch, "scopes")
444
+ ? patch.scopes ?? []
445
+ : existing.scopes;
446
+ this.database.prepare(`
447
+ update device_connection
448
+ set display_name = ?,
449
+ status = ?,
450
+ scopes_json = ?,
451
+ metadata_json = ?,
452
+ updated_at = ?
453
+ where id = ?
454
+ `).run(displayName, patch.status ?? existing.status, stringifyJson(scopes), stringifyJson(metadata), now, existing.id);
455
+ this.database.prepare(`
456
+ update device_observation_state
457
+ set next_reconcile_at = ?,
458
+ last_sync_error_at = ?,
459
+ last_error_code = ?,
460
+ last_error_message = ?,
461
+ updated_at = ?
462
+ where account_id = ?
463
+ `).run(nextReconcileAt, patch.clearErrors ? null : existing.lastSyncErrorAt, patch.clearErrors ? null : existing.lastErrorCode, patch.clearErrors ? null : existing.lastErrorMessage, now, existing.id);
464
+ return this.getAccountById(existing.id);
465
+ });
466
+ }
467
+ updateAccountTokens(accountId, tokens, disconnectGeneration) {
468
+ const now = toIsoTimestamp(new Date());
469
+ const result = this.database.prepare(`
470
+ update device_credential_state
471
+ set access_token_encrypted = ?,
472
+ refresh_token_encrypted = ?,
473
+ access_token_expires_at = ?,
474
+ updated_at = ?
475
+ where account_id = ?
476
+ and (? is null or exists (
477
+ select 1
478
+ from device_connection
479
+ where device_connection.id = device_credential_state.account_id
480
+ and device_connection.disconnect_generation = ?
481
+ and device_connection.status = 'active'
482
+ ))
483
+ `).run(tokens.accessTokenEncrypted, tokens.refreshTokenEncrypted ?? null, tokens.accessTokenExpiresAt ?? null, now, accountId, disconnectGeneration ?? null, disconnectGeneration ?? null);
484
+ if ((result.changes ?? 0) === 0) {
485
+ return null;
486
+ }
487
+ return this.getAccountById(accountId);
488
+ }
489
+ hydrateHostedAccount(input) {
490
+ return withImmediateTransaction(this.database, () => {
491
+ const existing = this.getAccountByExternalAccount(input.connection.provider, input.connection.externalAccountId);
492
+ if (!existing && input.tokens === undefined) {
493
+ return null;
494
+ }
495
+ const shouldClearTokens = input.clearTokens === true
496
+ || (input.connection.status === "disconnected" && input.tokens === undefined);
497
+ const rowUpdatedAt = latestIsoTimestamp(existing?.updatedAt ?? null, input.connection.updatedAt)
498
+ ?? input.connection.updatedAt;
499
+ const { accessTokenEncrypted, refreshTokenEncrypted, accessTokenExpiresAt } = resolveHydratedHostedAccountTokens({
500
+ existing,
501
+ inputTokens: input.tokens,
502
+ shouldClearTokens,
503
+ });
504
+ const hostedObservedUpdatedAt = input.hostedObservedUpdatedAt ?? existing?.hostedObservedUpdatedAt ?? null;
505
+ const hostedObservedTokenVersion = input.hostedObservedTokenVersion ?? existing?.hostedObservedTokenVersion ?? null;
506
+ const metadata = sanitizeStoredDeviceSyncMetadata(input.connection.metadata);
507
+ const disconnectGeneration = existing
508
+ ? input.connection.status === "disconnected" && existing.status !== "disconnected"
509
+ ? existing.disconnectGeneration + 1
510
+ : existing.disconnectGeneration
511
+ : input.connection.status === "disconnected"
512
+ ? 1
513
+ : 0;
514
+ if (existing) {
515
+ this.database.prepare(`
516
+ update device_connection
517
+ set display_name = ?,
518
+ status = ?,
519
+ scopes_json = ?,
520
+ disconnect_generation = ?,
521
+ metadata_json = ?,
522
+ connected_at = ?,
523
+ updated_at = ?
524
+ where id = ?
525
+ `).run(input.connection.displayName, input.connection.status, stringifyJson(input.connection.scopes), disconnectGeneration, stringifyJson(metadata), input.connection.connectedAt, rowUpdatedAt, existing.id);
526
+ this.database.prepare(`
527
+ update device_credential_state
528
+ set access_token_encrypted = ?,
529
+ refresh_token_encrypted = ?,
530
+ access_token_expires_at = ?,
531
+ updated_at = ?
532
+ where account_id = ?
533
+ `).run(accessTokenEncrypted, refreshTokenEncrypted, accessTokenExpiresAt, rowUpdatedAt, existing.id);
534
+ this.database.prepare(`
535
+ update device_observation_state
536
+ set hosted_observed_updated_at = ?,
537
+ hosted_observed_token_version = ?,
538
+ last_webhook_at = ?,
539
+ last_sync_started_at = ?,
540
+ last_sync_completed_at = ?,
541
+ last_sync_error_at = ?,
542
+ last_error_code = ?,
543
+ last_error_message = ?,
544
+ next_reconcile_at = ?,
545
+ updated_at = ?
546
+ where account_id = ?
547
+ `).run(hostedObservedUpdatedAt, hostedObservedTokenVersion, input.localState.lastWebhookAt, input.localState.lastSyncStartedAt, input.localState.lastSyncCompletedAt, input.localState.lastSyncErrorAt, input.localState.lastErrorCode, input.localState.lastErrorMessage, input.localState.nextReconcileAt, rowUpdatedAt, existing.id);
548
+ return this.getAccountById(existing.id);
549
+ }
550
+ const id = generatePrefixedId("dsa");
551
+ this.database.prepare(`
552
+ insert into device_connection (
553
+ id,
554
+ provider,
555
+ external_account_id,
556
+ display_name,
557
+ status,
558
+ scopes_json,
559
+ disconnect_generation,
560
+ metadata_json,
561
+ connected_at,
562
+ created_at,
563
+ updated_at
564
+ ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
565
+ `).run(id, input.connection.provider, input.connection.externalAccountId, input.connection.displayName, input.connection.status, stringifyJson(input.connection.scopes), disconnectGeneration, stringifyJson(metadata), input.connection.connectedAt, input.connection.updatedAt, rowUpdatedAt);
566
+ this.database.prepare(`
567
+ insert into device_credential_state (
568
+ account_id,
569
+ access_token_encrypted,
570
+ refresh_token_encrypted,
571
+ access_token_expires_at,
572
+ created_at,
573
+ updated_at
574
+ ) values (?, ?, ?, ?, ?, ?)
575
+ `).run(id, accessTokenEncrypted, refreshTokenEncrypted, accessTokenExpiresAt, input.connection.updatedAt, rowUpdatedAt);
576
+ this.database.prepare(`
577
+ insert into device_observation_state (
578
+ account_id,
579
+ hosted_observed_updated_at,
580
+ hosted_observed_token_version,
581
+ last_webhook_at,
582
+ last_sync_started_at,
583
+ last_sync_completed_at,
584
+ last_sync_error_at,
585
+ last_error_code,
586
+ last_error_message,
587
+ next_reconcile_at,
588
+ created_at,
589
+ updated_at
590
+ ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
591
+ `).run(id, hostedObservedUpdatedAt, hostedObservedTokenVersion, input.localState.lastWebhookAt, input.localState.lastSyncStartedAt, input.localState.lastSyncCompletedAt, input.localState.lastSyncErrorAt, input.localState.lastErrorCode, input.localState.lastErrorMessage, input.localState.nextReconcileAt, input.connection.updatedAt, rowUpdatedAt);
592
+ return this.getAccountById(id);
593
+ });
594
+ }
595
+ disconnectAccount(accountId, now) {
596
+ withImmediateTransaction(this.database, () => {
597
+ this.database.prepare(`
598
+ update device_connection
599
+ set status = 'disconnected',
600
+ disconnect_generation = disconnect_generation + 1,
601
+ updated_at = ?
602
+ where id = ?
603
+ `).run(now, accountId);
604
+ this.database.prepare(`
605
+ update device_credential_state
606
+ set access_token_encrypted = '',
607
+ refresh_token_encrypted = null,
608
+ access_token_expires_at = null,
609
+ updated_at = ?
610
+ where account_id = ?
611
+ `).run(now, accountId);
612
+ this.database.prepare(`
613
+ update device_observation_state
614
+ set last_sync_error_at = null,
615
+ last_error_code = null,
616
+ last_error_message = null,
617
+ next_reconcile_at = null,
618
+ updated_at = ?
619
+ where account_id = ?
620
+ `).run(now, accountId);
621
+ });
622
+ return this.getAccountById(accountId);
623
+ }
624
+ markWebhookReceived(accountId, now) {
625
+ this.database.prepare(`
626
+ update device_observation_state
627
+ set last_webhook_at = ?, updated_at = ?
628
+ where account_id = ?
629
+ `).run(now, now, accountId);
630
+ }
631
+ markSyncStarted(accountId, now) {
632
+ this.database.prepare(`
633
+ update device_observation_state
634
+ set last_sync_started_at = ?, updated_at = ?
635
+ where account_id = ?
636
+ `).run(now, now, accountId);
637
+ }
638
+ markSyncSucceeded(accountId, now, disconnectGeneration = null, options = {}) {
639
+ const existing = this.getAccountById(accountId);
640
+ if (!existing) {
641
+ return false;
642
+ }
643
+ const metadata = sanitizeStoredDeviceSyncMetadata(options.metadataPatch ? { ...existing.metadata, ...options.metadataPatch } : existing.metadata);
644
+ const nextReconcileAt = Object.prototype.hasOwnProperty.call(options, "nextReconcileAt")
645
+ ? options.nextReconcileAt ?? null
646
+ : existing.nextReconcileAt;
647
+ return withImmediateTransaction(this.database, () => {
648
+ const connectionResult = this.database.prepare(`
649
+ update device_connection
650
+ set status = case when status = 'disconnected' then status else 'active' end,
651
+ metadata_json = ?,
652
+ updated_at = ?
653
+ where id = ?
654
+ and (? is null or (disconnect_generation = ? and status = 'active'))
655
+ `).run(stringifyJson(metadata), now, accountId, disconnectGeneration ?? null, disconnectGeneration ?? null);
656
+ if ((connectionResult.changes ?? 0) === 0) {
657
+ return false;
658
+ }
659
+ this.database.prepare(`
660
+ update device_observation_state
661
+ set next_reconcile_at = ?,
662
+ last_sync_completed_at = ?,
663
+ last_sync_error_at = null,
664
+ last_error_code = null,
665
+ last_error_message = null,
666
+ updated_at = ?
667
+ where account_id = ?
668
+ `).run(nextReconcileAt, now, now, accountId);
669
+ return true;
670
+ });
671
+ }
672
+ markSyncFailed(accountId, now, code, message, status) {
673
+ withImmediateTransaction(this.database, () => {
674
+ this.database.prepare(`
675
+ update device_connection
676
+ set status = ?,
677
+ updated_at = ?
678
+ where id = ?
679
+ `).run(status ?? this.getAccountById(accountId)?.status ?? "active", now, accountId);
680
+ this.database.prepare(`
681
+ update device_observation_state
682
+ set last_sync_error_at = ?,
683
+ last_error_code = ?,
684
+ last_error_message = ?,
685
+ updated_at = ?
686
+ where account_id = ?
687
+ `).run(now, code, message, now, accountId);
688
+ });
689
+ }
690
+ enqueueJob(input) {
691
+ return withImmediateTransaction(this.database, () => this.enqueueJobInTransaction(input));
692
+ }
693
+ enqueueJobsAndCompleteWebhookTrace(input) {
694
+ return withImmediateTransaction(this.database, () => {
695
+ const queuedJobs = input.jobs.map((job) => this.enqueueJobInTransaction({
696
+ provider: input.provider,
697
+ accountId: input.accountId,
698
+ kind: job.kind,
699
+ payload: job.payload ?? {},
700
+ priority: job.priority ?? 0,
701
+ availableAt: job.availableAt,
702
+ maxAttempts: job.maxAttempts,
703
+ dedupeKey: job.dedupeKey,
704
+ }));
705
+ this.completeWebhookTrace(input.provider, input.traceId);
706
+ return queuedJobs;
707
+ });
708
+ }
709
+ getJobById(jobId) {
710
+ const row = this.database.prepare(`select * from device_job where id = ?`).get(jobId);
711
+ return mapJobRow(row);
712
+ }
713
+ readNextActiveReconcileAt() {
714
+ const row = this.database.prepare(`
715
+ select observation.next_reconcile_at
716
+ from device_observation_state as observation
717
+ join device_connection as connection
718
+ on connection.id = observation.account_id
719
+ where connection.status = 'active'
720
+ and observation.next_reconcile_at is not null
721
+ order by observation.next_reconcile_at asc, observation.updated_at asc, connection.id asc
722
+ limit 1
723
+ `).get();
724
+ return row?.next_reconcile_at ?? null;
725
+ }
726
+ readNextJobWakeAt() {
727
+ const row = this.database.prepare(`
728
+ select wake_at
729
+ from (
730
+ select available_at as wake_at
731
+ from device_job
732
+ where status = 'queued'
733
+ union all
734
+ select lease_expires_at as wake_at
735
+ from device_job
736
+ where status = 'running'
737
+ and lease_expires_at is not null
738
+ and attempts < max_attempts
739
+ )
740
+ order by wake_at asc
741
+ limit 1
742
+ `).get();
743
+ return row?.wake_at ?? null;
744
+ }
745
+ claimDueJob(workerId, now, leaseMs) {
746
+ return withImmediateTransaction(this.database, () => {
747
+ const row = this.database.prepare(`
748
+ select *
749
+ from device_job as candidate
750
+ where (
751
+ (
752
+ candidate.status = 'queued' and candidate.available_at <= ?
753
+ ) or (
754
+ candidate.status = 'running'
755
+ and candidate.lease_expires_at is not null
756
+ and candidate.lease_expires_at <= ?
757
+ and candidate.attempts < candidate.max_attempts
758
+ )
759
+ )
760
+ and not exists (
761
+ select 1
762
+ from device_job as blocking
763
+ where blocking.account_id = candidate.account_id
764
+ and blocking.id != candidate.id
765
+ and blocking.status = 'running'
766
+ and blocking.lease_expires_at is not null
767
+ and blocking.lease_expires_at > ?
768
+ )
769
+ order by candidate.priority desc, candidate.available_at asc, candidate.created_at asc, candidate.id asc
770
+ limit 1
771
+ `).get(now, now, now);
772
+ if (!row) {
773
+ return null;
774
+ }
775
+ const leaseExpiresAt = new Date(Date.parse(now) + leaseMs).toISOString();
776
+ this.database.prepare(`
777
+ update device_job
778
+ set status = 'running',
779
+ lease_owner = ?,
780
+ lease_expires_at = ?,
781
+ attempts = attempts + 1,
782
+ started_at = coalesce(started_at, ?),
783
+ updated_at = ?
784
+ where id = ?
785
+ `).run(workerId, leaseExpiresAt, now, now, row.id);
786
+ return this.getJobById(row.id);
787
+ });
788
+ }
789
+ completeJob(jobId, now) {
790
+ this.database.prepare(`
791
+ update device_job
792
+ set status = 'succeeded',
793
+ lease_owner = null,
794
+ lease_expires_at = null,
795
+ finished_at = ?,
796
+ updated_at = ?
797
+ where id = ?
798
+ `).run(now, now, jobId);
799
+ }
800
+ completeJobIfOwned(jobId, workerId, now) {
801
+ const result = this.database.prepare(`
802
+ update device_job
803
+ set status = 'succeeded',
804
+ lease_owner = null,
805
+ lease_expires_at = null,
806
+ finished_at = ?,
807
+ updated_at = ?
808
+ where id = ?
809
+ and status = 'running'
810
+ and lease_owner = ?
811
+ `).run(now, now, jobId, workerId);
812
+ return (result.changes ?? 0) > 0;
813
+ }
814
+ failJob(jobId, now, code, message, retryAt, retryable) {
815
+ const job = this.getJobById(jobId);
816
+ if (!job) {
817
+ return;
818
+ }
819
+ if (job.status !== "queued" && job.status !== "running") {
820
+ return;
821
+ }
822
+ if (retryable && job.attempts < job.maxAttempts) {
823
+ this.database.prepare(`
824
+ update device_job
825
+ set status = 'queued',
826
+ available_at = ?,
827
+ lease_owner = null,
828
+ lease_expires_at = null,
829
+ last_error_code = ?,
830
+ last_error_message = ?,
831
+ updated_at = ?
832
+ where id = ?
833
+ `).run(retryAt ?? now, code, message, now, jobId);
834
+ return;
835
+ }
836
+ this.database.prepare(`
837
+ update device_job
838
+ set status = 'dead',
839
+ lease_owner = null,
840
+ lease_expires_at = null,
841
+ last_error_code = ?,
842
+ last_error_message = ?,
843
+ finished_at = ?,
844
+ updated_at = ?
845
+ where id = ?
846
+ `).run(code, message, now, now, jobId);
847
+ }
848
+ markPendingJobsDeadForAccount(accountId, now, code, message) {
849
+ const result = this.database.prepare(`
850
+ update device_job
851
+ set status = 'dead',
852
+ lease_owner = null,
853
+ lease_expires_at = null,
854
+ last_error_code = ?,
855
+ last_error_message = ?,
856
+ finished_at = ?,
857
+ updated_at = ?
858
+ where account_id = ? and status in ('queued', 'running')
859
+ `).run(code, message, now, now, accountId);
860
+ return result.changes ?? 0;
861
+ }
862
+ claimWebhookTrace(input) {
863
+ return withImmediateTransaction(this.database, () => {
864
+ const existing = this.database.prepare(`
865
+ select provider, trace_id, status, processing_expires_at
866
+ from webhook_trace
867
+ where provider = ?
868
+ and trace_id = ?
869
+ `).get(input.provider, input.traceId);
870
+ if (!existing) {
871
+ this.database.prepare(`
872
+ insert into webhook_trace (
873
+ provider,
874
+ trace_id,
875
+ external_account_id,
876
+ event_type,
877
+ received_at,
878
+ payload_json,
879
+ status,
880
+ processing_expires_at
881
+ ) values (?, ?, ?, ?, ?, ?, 'processing', ?)
882
+ `).run(input.provider, input.traceId, input.externalAccountId, input.eventType, input.receivedAt, MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON, input.processingExpiresAt);
883
+ return "claimed";
884
+ }
885
+ if ((existing.status ?? "processed") === "processed") {
886
+ return "processed";
887
+ }
888
+ if (existing.processing_expires_at
889
+ && Date.parse(existing.processing_expires_at) > Date.parse(input.receivedAt)) {
890
+ return "processing";
891
+ }
892
+ const result = this.database.prepare(`
893
+ update webhook_trace
894
+ set external_account_id = ?,
895
+ event_type = ?,
896
+ received_at = ?,
897
+ payload_json = ?,
898
+ status = 'processing',
899
+ processing_expires_at = ?
900
+ where provider = ?
901
+ and trace_id = ?
902
+ and coalesce(status, 'processed') = 'processing'
903
+ and (
904
+ processing_expires_at is null
905
+ or processing_expires_at <= ?
906
+ )
907
+ `).run(input.externalAccountId, input.eventType, input.receivedAt, MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON, input.processingExpiresAt, input.provider, input.traceId, input.receivedAt);
908
+ return (result.changes ?? 0) > 0 ? "claimed" : "processing";
909
+ });
910
+ }
911
+ completeWebhookTrace(provider, traceId) {
912
+ this.database.prepare(`
913
+ update webhook_trace
914
+ set payload_json = ?,
915
+ status = 'processed',
916
+ processing_expires_at = null
917
+ where provider = ?
918
+ and trace_id = ?
919
+ and coalesce(status, 'processed') = 'processing'
920
+ `).run(MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON, provider, traceId);
921
+ }
922
+ releaseWebhookTrace(provider, traceId) {
923
+ this.database.prepare(`
924
+ delete from webhook_trace
925
+ where provider = ?
926
+ and trace_id = ?
927
+ and coalesce(status, 'processed') = 'processing'
928
+ `).run(provider, traceId);
929
+ }
930
+ enqueueJobInTransaction(input) {
931
+ if (input.dedupeKey) {
932
+ const existing = this.database.prepare(`
933
+ select *
934
+ from device_job
935
+ where account_id = ? and provider = ? and dedupe_key = ? and status in ('queued', 'running')
936
+ order by created_at desc, id desc
937
+ limit 1
938
+ `).get(input.accountId, input.provider, input.dedupeKey);
939
+ if (existing) {
940
+ return mapJobRow(existing);
941
+ }
942
+ }
943
+ const now = toIsoTimestamp(new Date());
944
+ const id = generatePrefixedId("dsj");
945
+ this.database.prepare(`
946
+ insert into device_job (
947
+ id,
948
+ provider,
949
+ account_id,
950
+ kind,
951
+ payload_json,
952
+ priority,
953
+ available_at,
954
+ attempts,
955
+ max_attempts,
956
+ dedupe_key,
957
+ status,
958
+ created_at,
959
+ updated_at
960
+ ) values (?, ?, ?, ?, ?, ?, ?, 0, ?, ?, 'queued', ?, ?)
961
+ `).run(id, input.provider, input.accountId, input.kind, stringifyJson(input.payload ?? {}), input.priority ?? 0, input.availableAt ?? now, input.maxAttempts ?? 5, input.dedupeKey ?? null, now, now);
962
+ return this.getJobById(id);
963
+ }
964
+ }
965
+ //# sourceMappingURL=store.js.map