@crewx/sdk 0.9.0-rc.22 → 0.9.0-rc.221

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 (446) hide show
  1. package/README.md +1 -1
  2. package/dist/account/auth-client.d.ts +61 -0
  3. package/dist/account/auth-json-v2.d.ts +1 -0
  4. package/dist/account/auth-json.d.ts +30 -0
  5. package/dist/account/config.d.ts +37 -0
  6. package/dist/account/env-bootstrap.d.ts +11 -0
  7. package/dist/account/errors.d.ts +24 -0
  8. package/dist/account/index.d.ts +12 -0
  9. package/dist/account/index.js +2 -0
  10. package/dist/account/session-manager.d.ts +47 -0
  11. package/dist/activity-log/builder.d.ts +59 -6
  12. package/dist/agent/agent-list-view.d.ts +19 -0
  13. package/dist/agent-interceptor/chain.d.ts +25 -0
  14. package/dist/agent-interceptor/index.d.ts +6 -0
  15. package/dist/agent-interceptor/model-runner.d.ts +19 -0
  16. package/dist/agent-interceptor/program-runner.d.ts +13 -0
  17. package/dist/agent-interceptor/protocol.d.ts +68 -0
  18. package/dist/agent-interceptor/run-stop.d.ts +3 -0
  19. package/dist/agent-interceptor/schema.d.ts +267 -0
  20. package/dist/agent-interceptor/types.d.ts +88 -0
  21. package/dist/app/app-files/args.d.ts +12 -0
  22. package/dist/app/app-files/errors.d.ts +6 -0
  23. package/dist/app/app-files/index.d.ts +35 -0
  24. package/dist/app/app-files/lock.d.ts +26 -0
  25. package/dist/app/app-files/root.d.ts +22 -0
  26. package/dist/app/app-files/store.d.ts +48 -0
  27. package/dist/app/app-files/write.child.d.ts +1 -0
  28. package/dist/app/app.d.ts +168 -0
  29. package/dist/app/backend-env.d.ts +3 -0
  30. package/dist/app/content-media-types.d.ts +2 -0
  31. package/dist/app/context.d.ts +2 -0
  32. package/dist/app/entry.d.ts +9 -0
  33. package/dist/app/frame.d.ts +55 -0
  34. package/dist/app/index.d.ts +20 -0
  35. package/dist/app/index.js +13 -0
  36. package/dist/app/job-bridge.child.d.ts +1 -0
  37. package/dist/app/job-bridge.d.ts +67 -0
  38. package/dist/app/job-bridge.drain.child.d.ts +1 -0
  39. package/dist/app/job-bridge.example.d.ts +11 -0
  40. package/dist/app/job-contract.d.ts +40 -0
  41. package/dist/app/job-wire.d.ts +149 -0
  42. package/dist/app/protocol.d.ts +9 -0
  43. package/dist/app/runtime.d.ts +23 -0
  44. package/dist/app/schedule-contract.d.ts +59 -0
  45. package/dist/app/tool-mode.d.ts +3 -0
  46. package/dist/app-artifact-policy/check.d.ts +2 -0
  47. package/dist/app-artifact-policy/contract.d.ts +54 -0
  48. package/dist/app-artifact-policy/helper.d.ts +15 -0
  49. package/dist/app-artifact-policy/index.d.ts +3 -0
  50. package/dist/app-artifact-policy/index.js +18 -0
  51. package/dist/app-artifact-policy/paths.d.ts +24 -0
  52. package/dist/app-artifact-policy/scan.d.ts +47 -0
  53. package/dist/app-sync/continuation.d.ts +67 -0
  54. package/dist/app-sync/coordinator.d.ts +92 -0
  55. package/dist/app-sync/create-ledger.d.ts +27 -0
  56. package/dist/app-sync/index.d.ts +9 -0
  57. package/dist/app-sync/index.js +390 -0
  58. package/dist/app-sync/scope.d.ts +35 -0
  59. package/dist/app-sync/session-fence.d.ts +26 -0
  60. package/dist/app-sync/sqlite-store.d.ts +237 -0
  61. package/dist/app-sync/types.d.ts +855 -0
  62. package/dist/app-ui/index.d.ts +95 -0
  63. package/dist/app-ui/index.js +1 -0
  64. package/dist/attachment-receive/index.d.ts +76 -0
  65. package/dist/attachment-receive/index.js +2 -0
  66. package/dist/boxing/box.types.d.ts +4 -0
  67. package/dist/config/canonicalize-agent-options.d.ts +2 -0
  68. package/dist/config/default-agent-models.d.ts +11 -0
  69. package/dist/config/global-settings.d.ts +33 -0
  70. package/dist/config/migrate-grok-mode.d.ts +6 -0
  71. package/dist/config/model-compat.d.ts +31 -0
  72. package/dist/config/models.generated.d.ts +38 -0
  73. package/dist/config/models.remote.d.ts +1 -0
  74. package/dist/config/overdrive.d.ts +7 -0
  75. package/dist/config/pricing.d.ts +6 -3
  76. package/dist/config/pricing.generated.d.ts +4 -0
  77. package/dist/config/pricing.types.d.ts +4 -0
  78. package/dist/config/timeout.config.d.ts +4 -0
  79. package/dist/config/wi-boards.d.ts +19 -0
  80. package/dist/context/GoalLoader.d.ts +6 -0
  81. package/dist/context-budget/continuity.d.ts +64 -0
  82. package/dist/context-budget/fixed-slot-shrink.d.ts +97 -0
  83. package/dist/context-budget/index.d.ts +168 -0
  84. package/dist/conversation/index.d.ts +1 -1
  85. package/dist/conversation/sqlite-provider.d.ts +6 -3
  86. package/dist/conversation/to-template-messages.d.ts +9 -0
  87. package/dist/conversation/types.d.ts +86 -1
  88. package/dist/desktop/command-runner.d.ts +4 -0
  89. package/dist/desktop/default-adapters.d.ts +4 -0
  90. package/dist/desktop/global-install.d.ts +19 -0
  91. package/dist/desktop/index.d.ts +3 -0
  92. package/dist/desktop/index.js +3 -0
  93. package/dist/desktop/install.d.ts +5 -0
  94. package/dist/desktop/lnk.d.ts +22 -0
  95. package/dist/desktop/manifest.d.ts +21 -0
  96. package/dist/desktop/types.d.ts +67 -0
  97. package/dist/desktop/version.d.ts +1 -0
  98. package/dist/desktop/windows-paths.d.ts +21 -0
  99. package/dist/desktop/wrapper.d.ts +18 -0
  100. package/dist/esm/account/index.js +2 -0
  101. package/dist/esm/app/index.js +13 -0
  102. package/dist/esm/app-artifact-policy/index.js +18 -0
  103. package/dist/esm/app-sync/index.js +390 -0
  104. package/dist/esm/attachment-receive/index.js +2 -0
  105. package/dist/esm/desktop/index.js +3 -0
  106. package/dist/esm/history-snapshot/index.js +16 -0
  107. package/dist/esm/index.js +1394 -224
  108. package/dist/esm/node/index.js +2 -0
  109. package/dist/esm/plugins/index.js +569 -219
  110. package/dist/esm/process/index.js +1 -0
  111. package/dist/esm/publish/index.js +2 -0
  112. package/dist/esm/repository/index.js +828 -211
  113. package/dist/esm/skills/index.js +2 -0
  114. package/dist/esm/testing/index.js +1 -1
  115. package/dist/events/types.d.ts +44 -0
  116. package/dist/facade/Crewx.d.ts +107 -5
  117. package/dist/facade/task-ticket.d.ts +14 -0
  118. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  119. package/dist/highlight/thread-highlighter.d.ts +326 -0
  120. package/dist/history-snapshot/index.d.ts +83 -0
  121. package/dist/history-snapshot/index.js +16 -0
  122. package/dist/index.browser.d.ts +26 -1
  123. package/dist/index.browser.js +6 -2
  124. package/dist/index.d.ts +169 -19
  125. package/dist/index.js +1394 -224
  126. package/dist/internal/console-decoder.d.ts +38 -0
  127. package/dist/internal/windows-spawn.d.ts +10 -0
  128. package/dist/layout/types.d.ts +18 -1
  129. package/dist/lifecycle/process-lease.d.ts +80 -0
  130. package/dist/lifecycle/process-owner.d.ts +20 -0
  131. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  132. package/dist/lifecycle/task-stop.d.ts +112 -0
  133. package/dist/lifecycle/update-admission.d.ts +45 -0
  134. package/dist/local-server/base-url.d.ts +18 -0
  135. package/dist/local-server/index.d.ts +8 -0
  136. package/dist/local-server/opencode.d.ts +8 -0
  137. package/dist/local-server/probe.d.ts +3 -0
  138. package/dist/local-server/runtime.d.ts +26 -0
  139. package/dist/local-server/types.d.ts +43 -0
  140. package/dist/mcp-app/agent-access.d.ts +33 -0
  141. package/dist/mcp-app/app-handoff.d.ts +109 -0
  142. package/dist/mcp-app/app-icon-read.d.ts +7 -0
  143. package/dist/mcp-app/app-job-bridge.d.ts +30 -0
  144. package/dist/mcp-app/app-job-bridge.example.d.ts +36 -0
  145. package/dist/mcp-app/app-job.d.ts +168 -0
  146. package/dist/mcp-app/app-schedule.d.ts +85 -0
  147. package/dist/mcp-app/apps-context.d.ts +32 -0
  148. package/dist/mcp-app/bundle-provenance.d.ts +3 -0
  149. package/dist/mcp-app/candidate-registration.d.ts +4 -0
  150. package/dist/mcp-app/card-handler.d.ts +7 -0
  151. package/dist/mcp-app/catalog.d.ts +7 -0
  152. package/dist/mcp-app/content-channel.d.ts +86 -0
  153. package/dist/mcp-app/content-declarations.d.ts +31 -0
  154. package/dist/mcp-app/dev-checks.d.ts +31 -0
  155. package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
  156. package/dist/mcp-app/discovery.d.ts +164 -0
  157. package/dist/mcp-app/errors.d.ts +7 -0
  158. package/dist/mcp-app/index.d.ts +46 -0
  159. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  160. package/dist/mcp-app/model-context.d.ts +29 -0
  161. package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
  162. package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
  163. package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
  164. package/dist/mcp-app/projection.d.ts +14 -0
  165. package/dist/mcp-app/prompt-cards.d.ts +28 -0
  166. package/dist/mcp-app/registry.d.ts +28 -0
  167. package/dist/mcp-app/skill-backend.d.ts +141 -0
  168. package/dist/mcp-app/state-set.d.ts +9 -0
  169. package/dist/mcp-app/types.d.ts +501 -0
  170. package/dist/mcp-app/view-call.d.ts +7 -0
  171. package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
  172. package/dist/mcp-app/workspace-app-scan-cache.d.ts +27 -0
  173. package/dist/mcp-app/workspace-snapshot.d.ts +81 -0
  174. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  175. package/dist/migrations/0012_blue_turbo.sql +23 -0
  176. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  177. package/dist/migrations/0014_organic_mongu.sql +73 -0
  178. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  179. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  180. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  181. package/dist/migrations/0018_bored_jackal.sql +33 -0
  182. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  183. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  184. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  185. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  186. package/dist/migrations/0023_red_payback.sql +1 -0
  187. package/dist/migrations/0024_storage_metadata.sql +262 -0
  188. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  189. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  190. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  191. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  192. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  193. package/dist/migrations/0029_nice_rhino.sql +1 -0
  194. package/dist/migrations/0031_petite_arclight.sql +6 -0
  195. package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
  196. package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
  197. package/dist/migrations/0034_keen_fallen_one.sql +36 -0
  198. package/dist/migrations/0035_request_log_daily.sql +11 -0
  199. package/dist/migrations/0036_ui_definition_archive.sql +8 -0
  200. package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
  201. package/dist/migrations/0038_task_rating.sql +3 -0
  202. package/dist/migrations/0039_aspiring_purifiers.sql +9 -0
  203. package/dist/migrations/0040_task_provider_inputs.sql +53 -0
  204. package/dist/migrations/0041_tranquil_vivisector.sql +54 -0
  205. package/dist/migrations/0042_breezy_blue_shield.sql +31 -0
  206. package/dist/migrations/0043_nervous_darkstar.sql +1 -0
  207. package/dist/migrations/0044_military_galactus.sql +8 -0
  208. package/dist/migrations/0045_task_pid_started_at.sql +1 -0
  209. package/dist/migrations/0046_acoustic_karnak.sql +49 -0
  210. package/dist/migrations/0047_doc_sync_connect_requests.sql +18 -0
  211. package/dist/migrations/0048_smart_gertrude_yorkes.sql +47 -0
  212. package/dist/migrations/0049_blue_sleepwalker.sql +25 -0
  213. package/dist/migrations/0050_rapid_black_cat.sql +89 -0
  214. package/dist/migrations/0051_lying_sinister_six.sql +1 -0
  215. package/dist/migrations/0052_lying_gambit.sql +33 -0
  216. package/dist/migrations/0053_smart_shriek.sql +172 -0
  217. package/dist/migrations/0054_lying_surge.sql +63 -0
  218. package/dist/migrations/0055_curious_talkback.sql +92 -0
  219. package/dist/migrations/0056_stale_menace.sql +14 -0
  220. package/dist/migrations/0057_eager_captain_flint.sql +18 -0
  221. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  222. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  223. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  224. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  225. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  226. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  227. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  228. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  229. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  230. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  231. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  232. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  233. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  234. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  235. package/dist/migrations/meta/0034_snapshot.json +3473 -0
  236. package/dist/migrations/meta/0035_snapshot.json +3547 -0
  237. package/dist/migrations/meta/0036_snapshot.json +3591 -0
  238. package/dist/migrations/meta/0037_snapshot.json +3598 -0
  239. package/dist/migrations/meta/0038_snapshot.json +3626 -0
  240. package/dist/migrations/meta/0039_snapshot.json +3684 -0
  241. package/dist/migrations/meta/0040_snapshot.json +3759 -0
  242. package/dist/migrations/meta/0041_snapshot.json +4156 -0
  243. package/dist/migrations/meta/0042_snapshot.json +4383 -0
  244. package/dist/migrations/meta/0043_snapshot.json +4390 -0
  245. package/dist/migrations/meta/0044_snapshot.json +4435 -0
  246. package/dist/migrations/meta/0045_snapshot.json +4442 -0
  247. package/dist/migrations/meta/0046_snapshot.json +4733 -0
  248. package/dist/migrations/meta/0047_snapshot.json +4832 -0
  249. package/dist/migrations/meta/0048_snapshot.json +5128 -0
  250. package/dist/migrations/meta/0049_snapshot.json +5165 -0
  251. package/dist/migrations/meta/0050_snapshot.json +5717 -0
  252. package/dist/migrations/meta/0051_snapshot.json +5725 -0
  253. package/dist/migrations/meta/0052_snapshot.json +5930 -0
  254. package/dist/migrations/meta/0053_snapshot.json +6780 -0
  255. package/dist/migrations/meta/0054_snapshot.json +6784 -0
  256. package/dist/migrations/meta/0055_snapshot.json +6896 -0
  257. package/dist/migrations/meta/0056_snapshot.json +6971 -0
  258. package/dist/migrations/meta/0057_snapshot.json +6971 -0
  259. package/dist/migrations/meta/_journal.json +329 -0
  260. package/dist/node/index.d.ts +1 -0
  261. package/dist/node/index.js +2 -0
  262. package/dist/paths.d.ts +1 -0
  263. package/dist/plugin/types.d.ts +1 -0
  264. package/dist/plugins/index.d.ts +1 -1
  265. package/dist/plugins/index.js +569 -219
  266. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  267. package/dist/process/index.d.ts +2 -0
  268. package/dist/process/index.js +1 -0
  269. package/dist/process/process-control.d.ts +74 -0
  270. package/dist/prompt/tag-names.d.ts +22 -0
  271. package/dist/provider/acp/adapter.d.ts +37 -2
  272. package/dist/provider/acp/adapters/antigravity-account.d.ts +4 -0
  273. package/dist/provider/acp/completion-observer.d.ts +24 -0
  274. package/dist/provider/acp/connection.d.ts +69 -3
  275. package/dist/provider/acp/index.d.ts +3 -3
  276. package/dist/provider/acp/meta.d.ts +11 -0
  277. package/dist/provider/acp/register.d.ts +1 -0
  278. package/dist/provider/acp/runtime.d.ts +1 -0
  279. package/dist/provider/acp/types.d.ts +31 -4
  280. package/dist/provider/bridge.browser.d.ts +3 -0
  281. package/dist/provider/bridge.d.ts +28 -4
  282. package/dist/provider/classify-task-error.d.ts +2 -0
  283. package/dist/provider/claude-agent-env.d.ts +1 -0
  284. package/dist/provider/cli/adapter.types.d.ts +35 -7
  285. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  286. package/dist/provider/cli/adapters/antigravity-stream.d.ts +27 -0
  287. package/dist/provider/cli/adapters/antigravity.d.ts +1 -0
  288. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  289. package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
  290. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  291. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  292. package/dist/provider/cli/adapters/index.d.ts +5 -0
  293. package/dist/provider/cli/adapters/opencode-data-dir.d.ts +17 -0
  294. package/dist/provider/cli/adapters/opencode.d.ts +1 -0
  295. package/dist/provider/cli/builtin-allow.d.ts +6 -0
  296. package/dist/provider/cli/index.d.ts +3 -2
  297. package/dist/provider/cli/meta.d.ts +18 -1
  298. package/dist/provider/cli/protocol-envelope.d.ts +3 -0
  299. package/dist/provider/errors.d.ts +11 -1
  300. package/dist/provider/idle-watchdog.d.ts +19 -0
  301. package/dist/provider/model-ladder.d.ts +8 -0
  302. package/dist/provider/models.d.ts +17 -12
  303. package/dist/provider/order.d.ts +1 -1
  304. package/dist/provider/parse-usage.d.ts +6 -0
  305. package/dist/provider/provider-selection.d.ts +8 -0
  306. package/dist/provider/redact-technical-message.d.ts +1 -0
  307. package/dist/provider/safe-opencode-text.d.ts +2 -0
  308. package/dist/provider/task-error.types.d.ts +20 -0
  309. package/dist/provider-account/accounts.d.ts +15 -0
  310. package/dist/provider-account/antigravity-acp/auth.d.ts +29 -0
  311. package/dist/provider-account/antigravity-acp/browser.d.ts +4 -0
  312. package/dist/provider-account/antigravity-acp/install.d.ts +42 -0
  313. package/dist/provider-account/antigravity-acp/lease.d.ts +23 -0
  314. package/dist/provider-account/antigravity-acp/lifecycle.d.ts +76 -0
  315. package/dist/provider-account/antigravity-acp/manifest.d.ts +76 -0
  316. package/dist/provider-account/antigravity-acp/profile.d.ts +4 -0
  317. package/dist/provider-account/capabilities.d.ts +6 -0
  318. package/dist/provider-account/index.d.ts +13 -0
  319. package/dist/provider-account/registry.d.ts +30 -0
  320. package/dist/provider-account/types.d.ts +47 -0
  321. package/dist/publish/constants.d.ts +6 -0
  322. package/dist/publish/errors.d.ts +7 -0
  323. package/dist/publish/index.d.ts +55 -0
  324. package/dist/publish/index.js +2 -0
  325. package/dist/publish/manifest.d.ts +47 -0
  326. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  327. package/dist/publish/pack.d.ts +6 -0
  328. package/dist/publish/scan.d.ts +10 -0
  329. package/dist/publish/secrets.d.ts +6 -0
  330. package/dist/publish/upload.d.ts +19 -0
  331. package/dist/remote/execution-profile.d.ts +9 -0
  332. package/dist/remote/index.d.ts +1 -0
  333. package/dist/remote/types.d.ts +28 -0
  334. package/dist/repository/agent-send-history.repository.d.ts +23 -0
  335. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  336. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  337. package/dist/repository/common-code.repository.d.ts +45 -0
  338. package/dist/repository/db.d.ts +13 -1
  339. package/dist/repository/index.d.ts +62 -6
  340. package/dist/repository/index.js +828 -211
  341. package/dist/repository/logs-db.d.ts +12 -0
  342. package/dist/repository/notification.repository.d.ts +58 -0
  343. package/dist/repository/project.repository.d.ts +90 -0
  344. package/dist/repository/public-task-answer.d.ts +24 -0
  345. package/dist/repository/request-log-mover.d.ts +70 -0
  346. package/dist/repository/request-log.repository.d.ts +7 -3
  347. package/dist/repository/run-columns.d.ts +10 -0
  348. package/dist/repository/run-history.repository.d.ts +112 -0
  349. package/dist/repository/schedule-run.repository.d.ts +103 -0
  350. package/dist/repository/sidebar-tab.repository.d.ts +86 -0
  351. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  352. package/dist/repository/task-log-migration.d.ts +74 -0
  353. package/dist/repository/task-log.repository.d.ts +47 -0
  354. package/dist/repository/task-status.d.ts +21 -0
  355. package/dist/repository/task.repository.d.ts +329 -8
  356. package/dist/repository/thread-history.repository.d.ts +193 -0
  357. package/dist/repository/thread-origin-verdict.d.ts +27 -0
  358. package/dist/repository/thread-title.types.d.ts +29 -0
  359. package/dist/repository/thread.repository.d.ts +134 -5
  360. package/dist/repository/usage-backfill.d.ts +62 -0
  361. package/dist/repository/usage-from-logs.d.ts +22 -0
  362. package/dist/repository/workflow-anchor-kinds.d.ts +4 -0
  363. package/dist/repository/workspace.repository.d.ts +3 -0
  364. package/dist/route/decide.d.ts +56 -0
  365. package/dist/route/eligibility.d.ts +11 -0
  366. package/dist/route/errors.d.ts +11 -0
  367. package/dist/route/index.d.ts +14 -0
  368. package/dist/route/runner.d.ts +15 -0
  369. package/dist/route/sqlite-store.d.ts +18 -0
  370. package/dist/route/store.d.ts +48 -0
  371. package/dist/route/strategies.d.ts +4 -0
  372. package/dist/route/types.d.ts +325 -0
  373. package/dist/schema/agent-send-history.d.ts +85 -0
  374. package/dist/schema/agent-suggestions.d.ts +199 -0
  375. package/dist/schema/app-sync.d.ts +2533 -0
  376. package/dist/schema/common-codes.d.ts +216 -0
  377. package/dist/schema/doc-create-dispatches.d.ts +101 -0
  378. package/dist/schema/doc-sync-connect-requests.d.ts +140 -0
  379. package/dist/schema/doc-sync-links.d.ts +556 -0
  380. package/dist/schema/index.d.ts +23 -0
  381. package/dist/schema/model-routes.d.ts +638 -0
  382. package/dist/schema/notifications.d.ts +303 -0
  383. package/dist/schema/projects.d.ts +610 -0
  384. package/dist/schema/request-log-daily.d.ts +151 -0
  385. package/dist/schema/run-column-backfill.d.ts +81 -0
  386. package/dist/schema/schedule-runs.d.ts +451 -0
  387. package/dist/schema/sidebar-tabs.d.ts +466 -0
  388. package/dist/schema/storage-metadata.d.ts +181 -0
  389. package/dist/schema/task-log-events.d.ts +119 -0
  390. package/dist/schema/task-provider-inputs.d.ts +100 -0
  391. package/dist/schema/tasks.d.ts +1172 -1
  392. package/dist/schema/thread-creator-unverified.d.ts +45 -0
  393. package/dist/schema/thread-history.d.ts +734 -0
  394. package/dist/schema/threads.d.ts +59 -0
  395. package/dist/schema/ui-action-receipts.d.ts +358 -0
  396. package/dist/schema/ui-definition-archive.d.ts +63 -0
  397. package/dist/schema/ui-instance-repins.d.ts +222 -0
  398. package/dist/schema/ui-instances.d.ts +324 -0
  399. package/dist/schema/workspaces.d.ts +17 -0
  400. package/dist/skills/index.d.ts +15 -0
  401. package/dist/skills/index.js +2 -0
  402. package/dist/skills/types.d.ts +18 -0
  403. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  404. package/dist/task-log/delegation-trailer.d.ts +34 -0
  405. package/dist/template/engine.d.ts +2 -2
  406. package/dist/template/helpers/exec.browser.d.ts +4 -3
  407. package/dist/template/helpers/exec.d.ts +4 -3
  408. package/dist/template/helpers/format-conversation.d.ts +1 -0
  409. package/dist/template/types.d.ts +20 -0
  410. package/dist/testing/index.js +1 -1
  411. package/dist/types/index.d.ts +3285 -84
  412. package/dist/types/task-log.types.d.ts +6 -1
  413. package/dist/ui-card/index.d.ts +2 -0
  414. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  415. package/dist/ui-instance/definition.d.ts +6 -0
  416. package/dist/ui-instance/errors.d.ts +18 -0
  417. package/dist/ui-instance/index.d.ts +11 -0
  418. package/dist/ui-instance/json.d.ts +19 -0
  419. package/dist/ui-instance/lineage.d.ts +24 -0
  420. package/dist/ui-instance/runtime.d.ts +19 -0
  421. package/dist/ui-instance/store.d.ts +216 -0
  422. package/dist/ui-instance/types.d.ts +384 -0
  423. package/dist/ui-plugin/app-icon.d.ts +50 -0
  424. package/dist/ui-plugin/app-manifest.d.ts +64 -0
  425. package/dist/ui-plugin/csp.d.ts +28 -0
  426. package/dist/ui-plugin/index.d.ts +8 -0
  427. package/dist/ui-plugin/limits.d.ts +27 -0
  428. package/dist/ui-plugin/manifest.d.ts +3 -0
  429. package/dist/ui-plugin/types.d.ts +220 -0
  430. package/dist/ui-plugin/validator.d.ts +18 -0
  431. package/dist/utils/crewx-executable.d.ts +76 -0
  432. package/dist/utils/crewx-home.d.ts +1 -0
  433. package/dist/utils/env-defaults.d.ts +3 -0
  434. package/dist/utils/id.d.ts +1 -1
  435. package/dist/utils/local-identity.d.ts +2 -0
  436. package/dist/utils/runner-env.d.ts +3 -0
  437. package/dist/utils/timestamp.d.ts +1 -0
  438. package/dist/utils/workspace.d.ts +1 -0
  439. package/dist/wi/create.d.ts +48 -0
  440. package/dist/wi/select.d.ts +20 -0
  441. package/package.json +90 -3
  442. package/templates/agents/default.yaml +311 -128
  443. package/templates/documents/crewx-manual.md +138 -138
  444. package/templates/documents/crewx-quick-guide.md +8 -7
  445. package/templates/workflows/wi-default-flow.yaml +65 -0
  446. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -0,0 +1,49 @@
1
+ CREATE TABLE IF NOT EXISTS `doc_sync_links` (
2
+ `doc_id` text PRIMARY KEY NOT NULL,
3
+ `account_key` text NOT NULL,
4
+ `workspace_id` text NOT NULL,
5
+ `app_id` text NOT NULL,
6
+ `root_segments` text NOT NULL,
7
+ `ref` text NOT NULL,
8
+ `cloud_ref` text NOT NULL,
9
+ `origin` text DEFAULT 'own' NOT NULL,
10
+ `sync_state` text DEFAULT 'ok' NOT NULL,
11
+ `end_reason` text,
12
+ `file_state` text DEFAULT 'present' NOT NULL,
13
+ `synced_revision` integer NOT NULL,
14
+ `synced_hash` text NOT NULL,
15
+ `synced_at` integer NOT NULL,
16
+ `file_dev_ino` text,
17
+ `conflict_revision` integer,
18
+ `conflict_hash` text,
19
+ `conflict_at` integer,
20
+ `remote_revision` integer,
21
+ `remote_checked_at` integer,
22
+ `published_revision` integer,
23
+ `bundle_sha256` text,
24
+ `missing_since` integer,
25
+ `connected_at` integer NOT NULL,
26
+ `created_at` integer NOT NULL,
27
+ `updated_at` integer NOT NULL,
28
+ CONSTRAINT "doc_sync_links_doc_id_ck" CHECK(length("doc_sync_links"."doc_id") BETWEEN 1 AND 128),
29
+ CONSTRAINT "doc_sync_links_account_key_ck" CHECK(length("doc_sync_links"."account_key") = 64 AND "doc_sync_links"."account_key" NOT GLOB '*[^0-9a-f]*'),
30
+ CONSTRAINT "doc_sync_links_workspace_id_ck" CHECK(length("doc_sync_links"."workspace_id") BETWEEN 1 AND 256),
31
+ CONSTRAINT "doc_sync_links_app_id_ck" CHECK(length("doc_sync_links"."app_id") BETWEEN 1 AND 128),
32
+ CONSTRAINT "doc_sync_links_root_segments_ck" CHECK(json_valid("doc_sync_links"."root_segments") AND json_type("doc_sync_links"."root_segments") = 'array'),
33
+ CONSTRAINT "doc_sync_links_ref_ck" CHECK(length("doc_sync_links"."ref") BETWEEN 1 AND 256),
34
+ CONSTRAINT "doc_sync_links_cloud_ref_ck" CHECK(length("doc_sync_links"."cloud_ref") BETWEEN 1 AND 256),
35
+ CONSTRAINT "doc_sync_links_origin_ck" CHECK("doc_sync_links"."origin" IN ('own', 'received')),
36
+ CONSTRAINT "doc_sync_links_sync_state_ck" CHECK("doc_sync_links"."sync_state" IN ('ok', 'conflict', 'ended')),
37
+ CONSTRAINT "doc_sync_links_end_reason_ck" CHECK("doc_sync_links"."end_reason" IS NULL OR "doc_sync_links"."end_reason" IN ('disconnected', 'cloud_deleted')),
38
+ CONSTRAINT "doc_sync_links_ended_reason_ck" CHECK(("doc_sync_links"."sync_state" = 'ended') = ("doc_sync_links"."end_reason" IS NOT NULL)),
39
+ CONSTRAINT "doc_sync_links_file_state_ck" CHECK("doc_sync_links"."file_state" IN ('present', 'missing', 'root_unavailable')),
40
+ CONSTRAINT "doc_sync_links_synced_revision_ck" CHECK("doc_sync_links"."synced_revision" >= 0),
41
+ CONSTRAINT "doc_sync_links_synced_hash_ck" CHECK(length("doc_sync_links"."synced_hash") = 71 AND substr("doc_sync_links"."synced_hash", 1, 7) = 'sha256:' AND substr("doc_sync_links"."synced_hash", 8) NOT GLOB '*[^0-9a-f]*'),
42
+ CONSTRAINT "doc_sync_links_connected_at_ck" CHECK("doc_sync_links"."connected_at" >= 0),
43
+ CONSTRAINT "doc_sync_links_created_at_ck" CHECK("doc_sync_links"."created_at" >= 0),
44
+ CONSTRAINT "doc_sync_links_updated_at_ck" CHECK("doc_sync_links"."updated_at" >= "doc_sync_links"."created_at")
45
+ );
46
+ --> statement-breakpoint
47
+ CREATE UNIQUE INDEX IF NOT EXISTS `doc_sync_links_live_ref_uq` ON `doc_sync_links` (`workspace_id`,`app_id`,`ref`) WHERE "doc_sync_links"."sync_state" <> 'ended';--> statement-breakpoint
48
+ CREATE INDEX IF NOT EXISTS `doc_sync_links_account_state_idx` ON `doc_sync_links` (`account_key`,`sync_state`);--> statement-breakpoint
49
+ CREATE INDEX IF NOT EXISTS `doc_sync_links_workspace_app_idx` ON `doc_sync_links` (`workspace_id`,`app_id`);
@@ -0,0 +1,18 @@
1
+ CREATE TABLE IF NOT EXISTS `doc_sync_connect_requests` (
2
+ `request_id` text PRIMARY KEY NOT NULL,
3
+ `account_key` text NOT NULL,
4
+ `workspace_id` text NOT NULL,
5
+ `app_id` text NOT NULL,
6
+ `ref` text NOT NULL,
7
+ `sent_hash` text NOT NULL,
8
+ `created_at` integer NOT NULL,
9
+ CONSTRAINT "doc_sync_connect_requests_request_id_ck" CHECK(length("doc_sync_connect_requests"."request_id") = 36),
10
+ CONSTRAINT "doc_sync_connect_requests_account_key_ck" CHECK(length("doc_sync_connect_requests"."account_key") = 64 AND "doc_sync_connect_requests"."account_key" NOT GLOB '*[^0-9a-f]*'),
11
+ CONSTRAINT "doc_sync_connect_requests_workspace_id_ck" CHECK(length("doc_sync_connect_requests"."workspace_id") BETWEEN 1 AND 256),
12
+ CONSTRAINT "doc_sync_connect_requests_app_id_ck" CHECK(length("doc_sync_connect_requests"."app_id") BETWEEN 1 AND 128),
13
+ CONSTRAINT "doc_sync_connect_requests_ref_ck" CHECK(length("doc_sync_connect_requests"."ref") BETWEEN 1 AND 256),
14
+ CONSTRAINT "doc_sync_connect_requests_sent_hash_ck" CHECK(length("doc_sync_connect_requests"."sent_hash") = 71 AND substr("doc_sync_connect_requests"."sent_hash", 1, 7) = 'sha256:' AND substr("doc_sync_connect_requests"."sent_hash", 8) NOT GLOB '*[^0-9a-f]*'),
15
+ CONSTRAINT "doc_sync_connect_requests_created_at_ck" CHECK("doc_sync_connect_requests"."created_at" >= 0)
16
+ );
17
+ --> statement-breakpoint
18
+ CREATE UNIQUE INDEX IF NOT EXISTS `doc_sync_connect_requests_connect_uq` ON `doc_sync_connect_requests` (`account_key`,`workspace_id`,`app_id`,`ref`);
@@ -0,0 +1,47 @@
1
+ CREATE TABLE IF NOT EXISTS `route_decisions` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `route_id` text NOT NULL,
4
+ `task_id` text NOT NULL,
5
+ `config_revision` text NOT NULL,
6
+ `candidate_id` text NOT NULL,
7
+ `provider` text NOT NULL,
8
+ `model` text NOT NULL,
9
+ `reason` text NOT NULL,
10
+ `eligible_ids` text NOT NULL,
11
+ `blocked_causes` text NOT NULL,
12
+ `link_errors` text NOT NULL,
13
+ `created_at` text NOT NULL
14
+ );
15
+ --> statement-breakpoint
16
+ CREATE UNIQUE INDEX IF NOT EXISTS `uniq_route_task_decision` ON `route_decisions` (`route_id`,`task_id`);--> statement-breakpoint
17
+ CREATE INDEX IF NOT EXISTS `idx_route_decisions_created` ON `route_decisions` (`created_at`);--> statement-breakpoint
18
+ CREATE TABLE IF NOT EXISTS `route_quota_observations` (
19
+ `id` text PRIMARY KEY NOT NULL,
20
+ `provider` text NOT NULL,
21
+ `account_ref` text DEFAULT 'default' NOT NULL,
22
+ `model` text,
23
+ `status` text NOT NULL,
24
+ `source` text NOT NULL,
25
+ `reset_at` text,
26
+ `observed_at` text NOT NULL
27
+ );
28
+ --> statement-breakpoint
29
+ CREATE UNIQUE INDEX IF NOT EXISTS `uniq_route_quota_observation` ON `route_quota_observations` (`provider`,`account_ref`,`model`,`source`);--> statement-breakpoint
30
+ CREATE INDEX IF NOT EXISTS `idx_route_quota_observations_reset` ON `route_quota_observations` (`reset_at`);--> statement-breakpoint
31
+ CREATE TABLE IF NOT EXISTS `route_states` (
32
+ `route_id` text PRIMARY KEY NOT NULL,
33
+ `config_revision` text NOT NULL,
34
+ `state_json` text NOT NULL,
35
+ `revision` integer DEFAULT 0 NOT NULL,
36
+ `updated_at` text NOT NULL
37
+ );
38
+ --> statement-breakpoint
39
+ CREATE TABLE IF NOT EXISTS `route_sticky_bindings` (
40
+ `route_id` text NOT NULL,
41
+ `thread_id` text NOT NULL,
42
+ `candidate_id` text NOT NULL,
43
+ `updated_at` text NOT NULL
44
+ );
45
+ --> statement-breakpoint
46
+ CREATE UNIQUE INDEX IF NOT EXISTS `uniq_route_sticky_thread` ON `route_sticky_bindings` (`route_id`,`thread_id`);--> statement-breakpoint
47
+ CREATE INDEX IF NOT EXISTS `idx_route_sticky_candidate` ON `route_sticky_bindings` (`route_id`,`candidate_id`);
@@ -0,0 +1,25 @@
1
+ DROP INDEX `idx_route_decisions_created`;--> statement-breakpoint
2
+ DROP INDEX `uniq_route_task_decision`;--> statement-breakpoint
3
+ ALTER TABLE `route_decisions` ADD `workspace_key` text DEFAULT 'legacy' NOT NULL;--> statement-breakpoint
4
+ CREATE INDEX IF NOT EXISTS `idx_route_decisions_workspace_created` ON `route_decisions` (`workspace_key`,`route_id`,`created_at`);--> statement-breakpoint
5
+ CREATE UNIQUE INDEX IF NOT EXISTS `uniq_route_task_decision` ON `route_decisions` (`workspace_key`,`route_id`,`task_id`);--> statement-breakpoint
6
+ DROP INDEX `uniq_route_sticky_thread`;--> statement-breakpoint
7
+ DROP INDEX `idx_route_sticky_candidate`;--> statement-breakpoint
8
+ ALTER TABLE `route_sticky_bindings` ADD `workspace_key` text DEFAULT 'legacy' NOT NULL;--> statement-breakpoint
9
+ CREATE UNIQUE INDEX IF NOT EXISTS `uniq_route_sticky_thread` ON `route_sticky_bindings` (`workspace_key`,`route_id`,`thread_id`);--> statement-breakpoint
10
+ CREATE INDEX IF NOT EXISTS `idx_route_sticky_candidate` ON `route_sticky_bindings` (`workspace_key`,`route_id`,`candidate_id`);--> statement-breakpoint
11
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
12
+ CREATE TABLE IF NOT EXISTS `__new_route_states` (
13
+ `workspace_key` text DEFAULT 'legacy' NOT NULL,
14
+ `route_id` text NOT NULL,
15
+ `config_revision` text NOT NULL,
16
+ `state_json` text NOT NULL,
17
+ `revision` integer DEFAULT 0 NOT NULL,
18
+ `updated_at` text NOT NULL,
19
+ PRIMARY KEY(`workspace_key`, `route_id`)
20
+ );
21
+ --> statement-breakpoint
22
+ INSERT INTO `__new_route_states`("workspace_key", "route_id", "config_revision", "state_json", "revision", "updated_at") SELECT 'legacy', "route_id", "config_revision", "state_json", "revision", "updated_at" FROM `route_states`;--> statement-breakpoint
23
+ DROP TABLE `route_states`;--> statement-breakpoint
24
+ ALTER TABLE `__new_route_states` RENAME TO `route_states`;--> statement-breakpoint
25
+ PRAGMA foreign_keys=ON;
@@ -0,0 +1,89 @@
1
+ CREATE TABLE IF NOT EXISTS `app_sync_bindings` (
2
+ `binding_id` text PRIMARY KEY NOT NULL,
3
+ `account_key` text NOT NULL,
4
+ `workspace_id` text NOT NULL,
5
+ `app_id` text NOT NULL,
6
+ `root_segments` text NOT NULL,
7
+ `grant_id` text,
8
+ `grant_generation` integer,
9
+ `scope_version` text,
10
+ `status` text DEFAULT 'local_only' NOT NULL,
11
+ `created_at` integer NOT NULL,
12
+ `updated_at` integer NOT NULL,
13
+ CONSTRAINT "app_sync_bindings_binding_id_ck" CHECK(length("app_sync_bindings"."binding_id") BETWEEN 1 AND 128),
14
+ CONSTRAINT "app_sync_bindings_account_key_ck" CHECK(length("app_sync_bindings"."account_key") = 64 AND "app_sync_bindings"."account_key" NOT GLOB '*[^0-9a-f]*'),
15
+ CONSTRAINT "app_sync_bindings_workspace_id_ck" CHECK(length("app_sync_bindings"."workspace_id") BETWEEN 1 AND 256),
16
+ CONSTRAINT "app_sync_bindings_app_id_ck" CHECK("app_sync_bindings"."app_id" = 'workout-log'),
17
+ CONSTRAINT "app_sync_bindings_root_segments_ck" CHECK(json_valid("app_sync_bindings"."root_segments") AND json_type("app_sync_bindings"."root_segments") = 'array'),
18
+ CONSTRAINT "app_sync_bindings_generation_ck" CHECK("app_sync_bindings"."grant_generation" IS NULL OR "app_sync_bindings"."grant_generation" >= 1),
19
+ CONSTRAINT "app_sync_bindings_status_ck" CHECK("app_sync_bindings"."status" IN ('local_only', 'consent_required', 'checking', 'syncing', 'synced', 'partial', 'offline', 'revoked', 'unavailable', 'stopping')),
20
+ CONSTRAINT "app_sync_bindings_timestamps_ck" CHECK("app_sync_bindings"."updated_at" >= "app_sync_bindings"."created_at")
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_bindings_owner_app_uq` ON `app_sync_bindings` (`account_key`,`app_id`);--> statement-breakpoint
24
+ CREATE TABLE IF NOT EXISTS `app_sync_creation_jobs` (
25
+ `job_id` text PRIMARY KEY NOT NULL,
26
+ `binding_id` text NOT NULL,
27
+ `account_key` text NOT NULL,
28
+ `grant_id` text NOT NULL,
29
+ `grant_generation` integer NOT NULL,
30
+ `ref` text NOT NULL,
31
+ `request_id` text NOT NULL,
32
+ `fingerprint` text NOT NULL,
33
+ `status` text DEFAULT 'waiting' NOT NULL,
34
+ `attempts` integer DEFAULT 0 NOT NULL,
35
+ `next_attempt_at` integer DEFAULT 0 NOT NULL,
36
+ `created_at` integer NOT NULL,
37
+ `updated_at` integer NOT NULL,
38
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
39
+ CONSTRAINT "app_sync_creation_jobs_job_id_ck" CHECK(length("app_sync_creation_jobs"."job_id") BETWEEN 1 AND 128),
40
+ CONSTRAINT "app_sync_creation_jobs_account_key_ck" CHECK(length("app_sync_creation_jobs"."account_key") = 64 AND "app_sync_creation_jobs"."account_key" NOT GLOB '*[^0-9a-f]*'),
41
+ CONSTRAINT "app_sync_creation_jobs_generation_ck" CHECK("app_sync_creation_jobs"."grant_generation" >= 1),
42
+ CONSTRAINT "app_sync_creation_jobs_ref_ck" CHECK(length("app_sync_creation_jobs"."ref") BETWEEN 1 AND 256),
43
+ CONSTRAINT "app_sync_creation_jobs_fingerprint_ck" CHECK(length("app_sync_creation_jobs"."fingerprint") = 71 AND substr("app_sync_creation_jobs"."fingerprint", 1, 7) = 'sha256:' AND substr("app_sync_creation_jobs"."fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
44
+ CONSTRAINT "app_sync_creation_jobs_status_ck" CHECK("app_sync_creation_jobs"."status" IN ('waiting', 'processing', 'completed', 'failed', 'conflict', 'blocked', 'invalidated', 'deleted')),
45
+ CONSTRAINT "app_sync_creation_jobs_attempts_ck" CHECK("app_sync_creation_jobs"."attempts" >= 0),
46
+ CONSTRAINT "app_sync_creation_jobs_timestamps_ck" CHECK("app_sync_creation_jobs"."updated_at" >= "app_sync_creation_jobs"."created_at")
47
+ );
48
+ --> statement-breakpoint
49
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_creation_jobs_request_id_uq` ON `app_sync_creation_jobs` (`request_id`);--> statement-breakpoint
50
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_creation_jobs_active_identity_uq` ON `app_sync_creation_jobs` (`binding_id`,`grant_id`,`grant_generation`,`ref`,`fingerprint`) WHERE "app_sync_creation_jobs"."status" IN ('waiting', 'processing');--> statement-breakpoint
51
+ CREATE INDEX IF NOT EXISTS `app_sync_creation_jobs_runnable_idx` ON `app_sync_creation_jobs` (`binding_id`,`status`,`next_attempt_at`);--> statement-breakpoint
52
+ CREATE INDEX IF NOT EXISTS `app_sync_creation_jobs_account_idx` ON `app_sync_creation_jobs` (`account_key`,`status`);--> statement-breakpoint
53
+ CREATE TABLE IF NOT EXISTS `app_sync_deleted_refs` (
54
+ `account_key` text NOT NULL,
55
+ `app_id` text NOT NULL,
56
+ `ref_sha256` text NOT NULL,
57
+ `created_at` integer NOT NULL,
58
+ CONSTRAINT "app_sync_deleted_refs_account_key_ck" CHECK(length("app_sync_deleted_refs"."account_key") = 64 AND "app_sync_deleted_refs"."account_key" NOT GLOB '*[^0-9a-f]*'),
59
+ CONSTRAINT "app_sync_deleted_refs_app_id_ck" CHECK("app_sync_deleted_refs"."app_id" = 'workout-log'),
60
+ CONSTRAINT "app_sync_deleted_refs_hash_ck" CHECK(length("app_sync_deleted_refs"."ref_sha256") = 64 AND "app_sync_deleted_refs"."ref_sha256" NOT GLOB '*[^0-9a-f]*')
61
+ );
62
+ --> statement-breakpoint
63
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_deleted_refs_identity_uq` ON `app_sync_deleted_refs` (`account_key`,`app_id`,`ref_sha256`);--> statement-breakpoint
64
+ CREATE TABLE IF NOT EXISTS `app_sync_results` (
65
+ `binding_id` text NOT NULL,
66
+ `account_key` text NOT NULL,
67
+ `ref` text NOT NULL,
68
+ `grant_id` text NOT NULL,
69
+ `grant_generation` integer NOT NULL,
70
+ `source_fingerprint` text,
71
+ `synced_fingerprint` text,
72
+ `document_id` text,
73
+ `status` text NOT NULL,
74
+ `error_code` text,
75
+ `updated_at` integer NOT NULL,
76
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
77
+ CONSTRAINT "app_sync_results_account_key_ck" CHECK(length("app_sync_results"."account_key") = 64 AND "app_sync_results"."account_key" NOT GLOB '*[^0-9a-f]*'),
78
+ CONSTRAINT "app_sync_results_ref_ck" CHECK(length("app_sync_results"."ref") BETWEEN 1 AND 256),
79
+ CONSTRAINT "app_sync_results_generation_ck" CHECK("app_sync_results"."grant_generation" >= 1),
80
+ CONSTRAINT "app_sync_results_status_ck" CHECK("app_sync_results"."status" IN ('waiting', 'processing', 'synced', 'failed', 'conflict', 'blocked', 'excluded', 'deleted'))
81
+ );
82
+ --> statement-breakpoint
83
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_results_binding_ref_uq` ON `app_sync_results` (`binding_id`,`ref`);--> statement-breakpoint
84
+ CREATE INDEX IF NOT EXISTS `app_sync_results_account_status_idx` ON `app_sync_results` (`account_key`,`status`);--> statement-breakpoint
85
+ ALTER TABLE `doc_sync_links` ADD `connection_kind` text DEFAULT 'document' NOT NULL;--> statement-breakpoint
86
+ ALTER TABLE `doc_sync_links` ADD `app_grant_id` text;--> statement-breakpoint
87
+ ALTER TABLE `doc_sync_links` ADD `app_grant_generation` integer;--> statement-breakpoint
88
+ ALTER TABLE `doc_sync_links` ADD `app_scope_version` text;--> statement-breakpoint
89
+ CREATE INDEX IF NOT EXISTS `doc_sync_links_connection_account_idx` ON `doc_sync_links` (`account_key`,`connection_kind`,`app_id`);
@@ -0,0 +1 @@
1
+ ALTER TABLE `app_sync_results` ADD `next_attempt_at` integer DEFAULT 0 NOT NULL;
@@ -0,0 +1,33 @@
1
+ CREATE TABLE IF NOT EXISTS `app_sync_control_requests` (
2
+ `request_id` text PRIMARY KEY NOT NULL,
3
+ `binding_id` text NOT NULL,
4
+ `account_key` text NOT NULL,
5
+ `app_id` text NOT NULL,
6
+ `workspace_id` text NOT NULL,
7
+ `root_fingerprint` text NOT NULL,
8
+ `kind` text NOT NULL,
9
+ `state` text DEFAULT 'pending' NOT NULL,
10
+ `grant_id` text,
11
+ `generation` integer,
12
+ `created_at` integer NOT NULL,
13
+ `updated_at` integer NOT NULL,
14
+ `resolved_at` integer,
15
+ `resolution` text,
16
+ `resolution_id` text,
17
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
18
+ CONSTRAINT "app_sync_control_requests_request_id_ck" CHECK(length("app_sync_control_requests"."request_id") BETWEEN 1 AND 128),
19
+ CONSTRAINT "app_sync_control_requests_account_key_ck" CHECK(length("app_sync_control_requests"."account_key") = 64 AND "app_sync_control_requests"."account_key" NOT GLOB '*[^0-9a-f]*'),
20
+ CONSTRAINT "app_sync_control_requests_app_id_ck" CHECK("app_sync_control_requests"."app_id" = 'workout-log'),
21
+ CONSTRAINT "app_sync_control_requests_workspace_id_ck" CHECK(length("app_sync_control_requests"."workspace_id") BETWEEN 1 AND 256),
22
+ CONSTRAINT "app_sync_control_requests_root_fingerprint_ck" CHECK(length("app_sync_control_requests"."root_fingerprint") = 64 AND "app_sync_control_requests"."root_fingerprint" NOT GLOB '*[^0-9a-f]*'),
23
+ CONSTRAINT "app_sync_control_requests_kind_ck" CHECK("app_sync_control_requests"."kind" IN ('connect', 'revoke')),
24
+ CONSTRAINT "app_sync_control_requests_state_ck" CHECK("app_sync_control_requests"."state" IN ('pending', 'unknown', 'confirmed', 'failed')),
25
+ CONSTRAINT "app_sync_control_requests_revoke_grant_ck" CHECK("app_sync_control_requests"."kind" != 'revoke' OR ("app_sync_control_requests"."grant_id" IS NOT NULL AND "app_sync_control_requests"."generation" >= 1)),
26
+ CONSTRAINT "app_sync_control_requests_resolution_ck" CHECK(("app_sync_control_requests"."state" IN ('pending', 'unknown') AND "app_sync_control_requests"."resolved_at" IS NULL AND "app_sync_control_requests"."resolution" IS NULL AND "app_sync_control_requests"."resolution_id" IS NULL) OR ("app_sync_control_requests"."state" IN ('confirmed', 'failed') AND "app_sync_control_requests"."resolved_at" IS NOT NULL AND "app_sync_control_requests"."resolution" IN ('remote', 'human') AND length("app_sync_control_requests"."resolution_id") BETWEEN 1 AND 128)),
27
+ CONSTRAINT "app_sync_control_requests_generation_ck" CHECK("app_sync_control_requests"."generation" IS NULL OR "app_sync_control_requests"."generation" >= 1),
28
+ CONSTRAINT "app_sync_control_requests_timestamps_ck" CHECK("app_sync_control_requests"."updated_at" >= "app_sync_control_requests"."created_at")
29
+ );
30
+ --> statement-breakpoint
31
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_control_requests_one_pending_uq` ON `app_sync_control_requests` (`binding_id`) WHERE "app_sync_control_requests"."state" IN ('pending', 'unknown');--> statement-breakpoint
32
+ CREATE INDEX IF NOT EXISTS `app_sync_control_requests_account_idx` ON `app_sync_control_requests` (`account_key`,`app_id`,`state`);--> statement-breakpoint
33
+ ALTER TABLE `app_sync_results` ADD `attempts` integer DEFAULT 0 NOT NULL;
@@ -0,0 +1,172 @@
1
+ CREATE TABLE IF NOT EXISTS `app_sync_conflict_resolutions` (
2
+ `request_id` text PRIMARY KEY NOT NULL,
3
+ `conflict_id` text NOT NULL,
4
+ `account_key` text NOT NULL,
5
+ `human_identity` text NOT NULL,
6
+ `choice` text NOT NULL,
7
+ `expected_local_version` text NOT NULL,
8
+ `expected_remote_revision` integer NOT NULL,
9
+ `expected_remote_fingerprint` text NOT NULL,
10
+ `state` text DEFAULT 'pending' NOT NULL,
11
+ `error_code` text,
12
+ `created_at` integer NOT NULL,
13
+ `updated_at` integer NOT NULL,
14
+ FOREIGN KEY (`conflict_id`) REFERENCES `app_sync_conflicts`(`conflict_id`) ON UPDATE no action ON DELETE cascade,
15
+ CONSTRAINT "app_sync_conflict_resolutions_request_id_ck" CHECK(length("app_sync_conflict_resolutions"."request_id") BETWEEN 1 AND 128),
16
+ CONSTRAINT "app_sync_conflict_resolutions_account_key_ck" CHECK(length("app_sync_conflict_resolutions"."account_key") = 64 AND "app_sync_conflict_resolutions"."account_key" NOT GLOB '*[^0-9a-f]*'),
17
+ CONSTRAINT "app_sync_conflict_resolutions_human_identity_ck" CHECK(length("app_sync_conflict_resolutions"."human_identity") = 64 AND "app_sync_conflict_resolutions"."human_identity" NOT GLOB '*[^0-9a-f]*'),
18
+ CONSTRAINT "app_sync_conflict_resolutions_choice_ck" CHECK("app_sync_conflict_resolutions"."choice" IN ('keep_local', 'use_cloud', 'keep_both')),
19
+ CONSTRAINT "app_sync_conflict_resolutions_local_version_ck" CHECK(length("app_sync_conflict_resolutions"."expected_local_version") BETWEEN 1 AND 256 AND instr("app_sync_conflict_resolutions"."expected_local_version", '/') = 0 AND instr("app_sync_conflict_resolutions"."expected_local_version", char(92)) = 0),
20
+ CONSTRAINT "app_sync_conflict_resolutions_remote_ck" CHECK("app_sync_conflict_resolutions"."expected_remote_revision" >= 0 AND length("app_sync_conflict_resolutions"."expected_remote_fingerprint") = 71 AND substr("app_sync_conflict_resolutions"."expected_remote_fingerprint", 1, 7) = 'sha256:' AND substr("app_sync_conflict_resolutions"."expected_remote_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
21
+ CONSTRAINT "app_sync_conflict_resolutions_state_ck" CHECK("app_sync_conflict_resolutions"."state" IN ('pending', 'unknown', 'resolved', 'stale', 'failed')),
22
+ CONSTRAINT "app_sync_conflict_resolutions_time_ck" CHECK("app_sync_conflict_resolutions"."updated_at" >= "app_sync_conflict_resolutions"."created_at")
23
+ );
24
+ --> statement-breakpoint
25
+ CREATE INDEX IF NOT EXISTS `app_sync_conflict_resolutions_conflict_idx` ON `app_sync_conflict_resolutions` (`conflict_id`,`created_at`);--> statement-breakpoint
26
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_conflict_resolutions_one_active_uq` ON `app_sync_conflict_resolutions` (`conflict_id`) WHERE "app_sync_conflict_resolutions"."state" IN ('pending', 'unknown');--> statement-breakpoint
27
+ CREATE TABLE IF NOT EXISTS `app_sync_conflicts` (
28
+ `conflict_id` text PRIMARY KEY NOT NULL,
29
+ `binding_id` text NOT NULL,
30
+ `account_key` text NOT NULL,
31
+ `workspace_id` text NOT NULL,
32
+ `root_fingerprint` text NOT NULL,
33
+ `grant_id` text NOT NULL,
34
+ `grant_generation` integer NOT NULL,
35
+ `scope_version` text NOT NULL,
36
+ `ref` text NOT NULL,
37
+ `doc_id` text NOT NULL,
38
+ `local_version` text NOT NULL,
39
+ `local_fingerprint` text NOT NULL,
40
+ `baseline_revision` integer,
41
+ `baseline_fingerprint` text,
42
+ `remote_revision` integer NOT NULL,
43
+ `remote_fingerprint` text NOT NULL,
44
+ `needs_reattach` integer DEFAULT 0 NOT NULL,
45
+ `vault_handle` text,
46
+ `preservation_status` text DEFAULT 'pending' NOT NULL,
47
+ `state` text DEFAULT 'open' NOT NULL,
48
+ `resolution_request_id` text,
49
+ `resolution_choice` text,
50
+ `cleanup_pending` integer DEFAULT 0 NOT NULL,
51
+ `created_at` integer NOT NULL,
52
+ `updated_at` integer NOT NULL,
53
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
54
+ CONSTRAINT "app_sync_conflicts_id_ck" CHECK(length("app_sync_conflicts"."conflict_id") BETWEEN 1 AND 128),
55
+ CONSTRAINT "app_sync_conflicts_account_key_ck" CHECK(length("app_sync_conflicts"."account_key") = 64 AND "app_sync_conflicts"."account_key" NOT GLOB '*[^0-9a-f]*'),
56
+ CONSTRAINT "app_sync_conflicts_root_fingerprint_ck" CHECK(length("app_sync_conflicts"."root_fingerprint") = 64 AND "app_sync_conflicts"."root_fingerprint" NOT GLOB '*[^0-9a-f]*'),
57
+ CONSTRAINT "app_sync_conflicts_generation_ck" CHECK("app_sync_conflicts"."grant_generation" >= 1),
58
+ CONSTRAINT "app_sync_conflicts_scope_ck" CHECK("app_sync_conflicts"."scope_version" = 'workout-log.records.v1'),
59
+ CONSTRAINT "app_sync_conflicts_ref_ck" CHECK(length("app_sync_conflicts"."ref") BETWEEN 1 AND 256),
60
+ CONSTRAINT "app_sync_conflicts_doc_id_ck" CHECK(length("app_sync_conflicts"."doc_id") BETWEEN 1 AND 128),
61
+ CONSTRAINT "app_sync_conflicts_local_version_ck" CHECK(length("app_sync_conflicts"."local_version") BETWEEN 1 AND 256 AND instr("app_sync_conflicts"."local_version", '/') = 0 AND instr("app_sync_conflicts"."local_version", char(92)) = 0),
62
+ CONSTRAINT "app_sync_conflicts_local_fingerprint_ck" CHECK(length("app_sync_conflicts"."local_fingerprint") = 71 AND substr("app_sync_conflicts"."local_fingerprint", 1, 7) = 'sha256:' AND substr("app_sync_conflicts"."local_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
63
+ CONSTRAINT "app_sync_conflicts_baseline_ck" CHECK(("app_sync_conflicts"."baseline_revision" IS NULL) = ("app_sync_conflicts"."baseline_fingerprint" IS NULL) AND ("app_sync_conflicts"."baseline_revision" IS NULL OR ("app_sync_conflicts"."baseline_revision" >= 0 AND length("app_sync_conflicts"."baseline_fingerprint") = 71 AND substr("app_sync_conflicts"."baseline_fingerprint", 1, 7) = 'sha256:' AND substr("app_sync_conflicts"."baseline_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'))),
64
+ CONSTRAINT "app_sync_conflicts_remote_ck" CHECK("app_sync_conflicts"."remote_revision" >= 0 AND length("app_sync_conflicts"."remote_fingerprint") = 71 AND substr("app_sync_conflicts"."remote_fingerprint", 1, 7) = 'sha256:' AND substr("app_sync_conflicts"."remote_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
65
+ CONSTRAINT "app_sync_conflicts_flags_ck" CHECK("app_sync_conflicts"."needs_reattach" IN (0, 1) AND "app_sync_conflicts"."cleanup_pending" IN (0, 1)),
66
+ CONSTRAINT "app_sync_conflicts_handle_ck" CHECK("app_sync_conflicts"."vault_handle" IS NULL OR (length("app_sync_conflicts"."vault_handle") BETWEEN 1 AND 256 AND instr("app_sync_conflicts"."vault_handle", '/') = 0 AND instr("app_sync_conflicts"."vault_handle", char(92)) = 0)),
67
+ CONSTRAINT "app_sync_conflicts_preservation_ck" CHECK("app_sync_conflicts"."preservation_status" IN ('pending', 'ready', 'failed')),
68
+ CONSTRAINT "app_sync_conflicts_state_ck" CHECK("app_sync_conflicts"."state" IN ('open', 'resolving', 'resolved', 'kept_both')),
69
+ CONSTRAINT "app_sync_conflicts_resolution_ck" CHECK(("app_sync_conflicts"."resolution_request_id" IS NULL AND "app_sync_conflicts"."resolution_choice" IS NULL) OR (length("app_sync_conflicts"."resolution_request_id") BETWEEN 1 AND 128 AND "app_sync_conflicts"."resolution_choice" IN ('keep_local', 'use_cloud', 'keep_both'))),
70
+ CONSTRAINT "app_sync_conflicts_time_ck" CHECK("app_sync_conflicts"."updated_at" >= "app_sync_conflicts"."created_at")
71
+ );
72
+ --> statement-breakpoint
73
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_conflicts_identity_uq` ON `app_sync_conflicts` (`binding_id`,`grant_id`,`grant_generation`,`ref`,`local_version`,`remote_revision`,`remote_fingerprint`);--> statement-breakpoint
74
+ CREATE INDEX IF NOT EXISTS `app_sync_conflicts_lookup_idx` ON `app_sync_conflicts` (`account_key`,`binding_id`,`state`,`updated_at`);--> statement-breakpoint
75
+ CREATE TABLE IF NOT EXISTS `app_sync_discovery_checkpoints` (
76
+ `binding_id` text PRIMARY KEY NOT NULL,
77
+ `account_key` text NOT NULL,
78
+ `workspace_id` text NOT NULL,
79
+ `root_fingerprint` text NOT NULL,
80
+ `grant_id` text NOT NULL,
81
+ `grant_generation` integer NOT NULL,
82
+ `scope_version` text NOT NULL,
83
+ `last_cycle_started_at` integer,
84
+ `cycle_started_at` integer,
85
+ `docs_cursor` text,
86
+ `docs_complete` integer DEFAULT 0 NOT NULL,
87
+ `deleted_cursor` text,
88
+ `deleted_complete` integer DEFAULT 0 NOT NULL,
89
+ `updated_at` integer NOT NULL,
90
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
91
+ CONSTRAINT "app_sync_discovery_checkpoints_account_key_ck" CHECK(length("app_sync_discovery_checkpoints"."account_key") = 64 AND "app_sync_discovery_checkpoints"."account_key" NOT GLOB '*[^0-9a-f]*'),
92
+ CONSTRAINT "app_sync_discovery_checkpoints_root_fingerprint_ck" CHECK(length("app_sync_discovery_checkpoints"."root_fingerprint") = 64 AND "app_sync_discovery_checkpoints"."root_fingerprint" NOT GLOB '*[^0-9a-f]*'),
93
+ CONSTRAINT "app_sync_discovery_checkpoints_generation_ck" CHECK("app_sync_discovery_checkpoints"."grant_generation" >= 1),
94
+ CONSTRAINT "app_sync_discovery_checkpoints_scope_ck" CHECK("app_sync_discovery_checkpoints"."scope_version" = 'workout-log.records.v1'),
95
+ CONSTRAINT "app_sync_discovery_checkpoints_docs_complete_ck" CHECK("app_sync_discovery_checkpoints"."docs_complete" IN (0, 1)),
96
+ CONSTRAINT "app_sync_discovery_checkpoints_deleted_complete_ck" CHECK("app_sync_discovery_checkpoints"."deleted_complete" IN (0, 1)),
97
+ CONSTRAINT "app_sync_discovery_checkpoints_time_ck" CHECK("app_sync_discovery_checkpoints"."updated_at" >= 0 AND ("app_sync_discovery_checkpoints"."last_cycle_started_at" IS NULL OR "app_sync_discovery_checkpoints"."last_cycle_started_at" >= 0) AND ("app_sync_discovery_checkpoints"."cycle_started_at" IS NULL OR "app_sync_discovery_checkpoints"."cycle_started_at" >= 0))
98
+ );
99
+ --> statement-breakpoint
100
+ CREATE INDEX IF NOT EXISTS `app_sync_discovery_checkpoints_account_idx` ON `app_sync_discovery_checkpoints` (`account_key`,`grant_id`,`grant_generation`);--> statement-breakpoint
101
+ CREATE TABLE IF NOT EXISTS `app_sync_pending_discoveries` (
102
+ `binding_id` text NOT NULL,
103
+ `account_key` text NOT NULL,
104
+ `grant_id` text NOT NULL,
105
+ `grant_generation` integer NOT NULL,
106
+ `ref` text NOT NULL,
107
+ `doc_id` text NOT NULL,
108
+ `listed_revision` integer NOT NULL,
109
+ `listed_fingerprint` text NOT NULL,
110
+ `app_grant_generation` integer NOT NULL,
111
+ `needs_reattach` integer DEFAULT 0 NOT NULL,
112
+ `needs_reconcile` integer DEFAULT 0 NOT NULL,
113
+ `status` text DEFAULT 'waiting' NOT NULL,
114
+ `error_code` text,
115
+ `attempts` integer DEFAULT 0 NOT NULL,
116
+ `updated_at` integer NOT NULL,
117
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
118
+ CONSTRAINT "app_sync_pending_discoveries_account_key_ck" CHECK(length("app_sync_pending_discoveries"."account_key") = 64 AND "app_sync_pending_discoveries"."account_key" NOT GLOB '*[^0-9a-f]*'),
119
+ CONSTRAINT "app_sync_pending_discoveries_ref_ck" CHECK(length("app_sync_pending_discoveries"."ref") BETWEEN 1 AND 256),
120
+ CONSTRAINT "app_sync_pending_discoveries_doc_id_ck" CHECK(length("app_sync_pending_discoveries"."doc_id") BETWEEN 1 AND 128),
121
+ CONSTRAINT "app_sync_pending_discoveries_revision_ck" CHECK("app_sync_pending_discoveries"."listed_revision" >= 0),
122
+ CONSTRAINT "app_sync_pending_discoveries_fingerprint_ck" CHECK(length("app_sync_pending_discoveries"."listed_fingerprint") = 71 AND substr("app_sync_pending_discoveries"."listed_fingerprint", 1, 7) = 'sha256:' AND substr("app_sync_pending_discoveries"."listed_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
123
+ CONSTRAINT "app_sync_pending_discoveries_generation_ck" CHECK("app_sync_pending_discoveries"."grant_generation" >= 1 AND "app_sync_pending_discoveries"."app_grant_generation" >= 1),
124
+ CONSTRAINT "app_sync_pending_discoveries_flags_ck" CHECK("app_sync_pending_discoveries"."needs_reattach" IN (0, 1) AND "app_sync_pending_discoveries"."needs_reconcile" IN (0, 1)),
125
+ CONSTRAINT "app_sync_pending_discoveries_status_ck" CHECK("app_sync_pending_discoveries"."status" IN ('waiting', 'processing', 'failed', 'invalidated')),
126
+ CONSTRAINT "app_sync_pending_discoveries_attempts_ck" CHECK("app_sync_pending_discoveries"."attempts" >= 0 AND "app_sync_pending_discoveries"."updated_at" >= 0)
127
+ );
128
+ --> statement-breakpoint
129
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_pending_discoveries_identity_uq` ON `app_sync_pending_discoveries` (`binding_id`,`grant_id`,`grant_generation`,`ref`);--> statement-breakpoint
130
+ CREATE INDEX IF NOT EXISTS `app_sync_pending_discoveries_runnable_idx` ON `app_sync_pending_discoveries` (`binding_id`,`grant_id`,`grant_generation`,`status`,`ref`);--> statement-breakpoint
131
+ DROP INDEX `doc_sync_links_live_ref_uq`;--> statement-breakpoint
132
+ CREATE UNIQUE INDEX IF NOT EXISTS `doc_sync_links_document_live_ref_uq` ON `doc_sync_links` (`workspace_id`,`app_id`,`ref`) WHERE "doc_sync_links"."sync_state" <> 'ended' AND "doc_sync_links"."connection_kind" = 'document';--> statement-breakpoint
133
+ CREATE UNIQUE INDEX IF NOT EXISTS `doc_sync_links_app_grant_live_ref_uq` ON `doc_sync_links` (`account_key`,`workspace_id`,`root_segments`,`app_id`,`ref`) WHERE "doc_sync_links"."sync_state" <> 'ended' AND "doc_sync_links"."connection_kind" = 'app_grant';--> statement-breakpoint
134
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
135
+ CREATE TABLE IF NOT EXISTS `__new_app_sync_creation_jobs` (
136
+ `job_id` text PRIMARY KEY NOT NULL,
137
+ `binding_id` text NOT NULL,
138
+ `account_key` text NOT NULL,
139
+ `grant_id` text NOT NULL,
140
+ `grant_generation` integer NOT NULL,
141
+ `ref` text NOT NULL,
142
+ `request_id` text NOT NULL,
143
+ `fingerprint` text NOT NULL,
144
+ `operation_kind` text DEFAULT 'create' NOT NULL,
145
+ `document_id` text,
146
+ `status` text DEFAULT 'waiting' NOT NULL,
147
+ `attempts` integer DEFAULT 0 NOT NULL,
148
+ `next_attempt_at` integer DEFAULT 0 NOT NULL,
149
+ `created_at` integer NOT NULL,
150
+ `updated_at` integer NOT NULL,
151
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
152
+ CONSTRAINT "app_sync_creation_jobs_job_id_ck" CHECK(length("__new_app_sync_creation_jobs"."job_id") BETWEEN 1 AND 128),
153
+ CONSTRAINT "app_sync_creation_jobs_account_key_ck" CHECK(length("__new_app_sync_creation_jobs"."account_key") = 64 AND "__new_app_sync_creation_jobs"."account_key" NOT GLOB '*[^0-9a-f]*'),
154
+ CONSTRAINT "app_sync_creation_jobs_generation_ck" CHECK("__new_app_sync_creation_jobs"."grant_generation" >= 1),
155
+ CONSTRAINT "app_sync_creation_jobs_ref_ck" CHECK(length("__new_app_sync_creation_jobs"."ref") BETWEEN 1 AND 256),
156
+ CONSTRAINT "app_sync_creation_jobs_document_id_ck" CHECK("__new_app_sync_creation_jobs"."document_id" IS NULL OR length("__new_app_sync_creation_jobs"."document_id") BETWEEN 1 AND 128),
157
+ CONSTRAINT "app_sync_creation_jobs_operation_kind_ck" CHECK("__new_app_sync_creation_jobs"."operation_kind" IN ('create', 'reattach')),
158
+ CONSTRAINT "app_sync_creation_jobs_reattach_document_ck" CHECK("__new_app_sync_creation_jobs"."operation_kind" != 'reattach' OR "__new_app_sync_creation_jobs"."document_id" IS NOT NULL),
159
+ CONSTRAINT "app_sync_creation_jobs_fingerprint_ck" CHECK(length("__new_app_sync_creation_jobs"."fingerprint") = 71 AND substr("__new_app_sync_creation_jobs"."fingerprint", 1, 7) = 'sha256:' AND substr("__new_app_sync_creation_jobs"."fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
160
+ CONSTRAINT "app_sync_creation_jobs_status_ck" CHECK("__new_app_sync_creation_jobs"."status" IN ('waiting', 'processing', 'completed', 'failed', 'conflict', 'blocked', 'invalidated', 'deleted')),
161
+ CONSTRAINT "app_sync_creation_jobs_attempts_ck" CHECK("__new_app_sync_creation_jobs"."attempts" >= 0),
162
+ CONSTRAINT "app_sync_creation_jobs_timestamps_ck" CHECK("__new_app_sync_creation_jobs"."updated_at" >= "__new_app_sync_creation_jobs"."created_at")
163
+ );
164
+ --> statement-breakpoint
165
+ INSERT INTO `__new_app_sync_creation_jobs`("job_id", "binding_id", "account_key", "grant_id", "grant_generation", "ref", "request_id", "fingerprint", "operation_kind", "document_id", "status", "attempts", "next_attempt_at", "created_at", "updated_at") SELECT "job_id", "binding_id", "account_key", "grant_id", "grant_generation", "ref", "request_id", "fingerprint", 'create', NULL, "status", "attempts", "next_attempt_at", "created_at", "updated_at" FROM `app_sync_creation_jobs`;--> statement-breakpoint
166
+ DROP TABLE `app_sync_creation_jobs`;--> statement-breakpoint
167
+ ALTER TABLE `__new_app_sync_creation_jobs` RENAME TO `app_sync_creation_jobs`;--> statement-breakpoint
168
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
169
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_creation_jobs_request_id_uq` ON `app_sync_creation_jobs` (`request_id`);--> statement-breakpoint
170
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_creation_jobs_active_identity_uq` ON `app_sync_creation_jobs` (`binding_id`,`grant_id`,`grant_generation`,`ref`,`fingerprint`,`operation_kind`) WHERE "app_sync_creation_jobs"."status" IN ('waiting', 'processing');--> statement-breakpoint
171
+ CREATE INDEX IF NOT EXISTS `app_sync_creation_jobs_runnable_idx` ON `app_sync_creation_jobs` (`binding_id`,`status`,`next_attempt_at`);--> statement-breakpoint
172
+ CREATE INDEX IF NOT EXISTS `app_sync_creation_jobs_account_idx` ON `app_sync_creation_jobs` (`account_key`,`status`);
@@ -0,0 +1,63 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE IF NOT EXISTS `__new_app_sync_conflicts` (
3
+ `conflict_id` text PRIMARY KEY NOT NULL,
4
+ `binding_id` text NOT NULL,
5
+ `account_key` text NOT NULL,
6
+ `workspace_id` text NOT NULL,
7
+ `root_fingerprint` text NOT NULL,
8
+ `grant_id` text NOT NULL,
9
+ `grant_generation` integer NOT NULL,
10
+ `scope_version` text NOT NULL,
11
+ `ref` text NOT NULL,
12
+ `doc_id` text NOT NULL,
13
+ `local_version` text NOT NULL,
14
+ `local_fingerprint` text NOT NULL,
15
+ `baseline_revision` integer,
16
+ `baseline_fingerprint` text,
17
+ `remote_revision` integer NOT NULL,
18
+ `remote_fingerprint` text NOT NULL,
19
+ `needs_reattach` integer DEFAULT 0 NOT NULL,
20
+ `vault_handle` text,
21
+ `preservation_status` text DEFAULT 'pending' NOT NULL,
22
+ `state` text DEFAULT 'open' NOT NULL,
23
+ `resolution_request_id` text,
24
+ `resolution_choice` text,
25
+ `cleanup_pending` integer DEFAULT 0 NOT NULL,
26
+ `created_at` integer NOT NULL,
27
+ `updated_at` integer NOT NULL,
28
+ FOREIGN KEY (`binding_id`) REFERENCES `app_sync_bindings`(`binding_id`) ON UPDATE no action ON DELETE cascade,
29
+ CONSTRAINT "app_sync_conflicts_id_ck" CHECK(length("__new_app_sync_conflicts"."conflict_id") BETWEEN 1 AND 128),
30
+ CONSTRAINT "app_sync_conflicts_account_key_ck" CHECK(length("__new_app_sync_conflicts"."account_key") = 64 AND "__new_app_sync_conflicts"."account_key" NOT GLOB '*[^0-9a-f]*'),
31
+ CONSTRAINT "app_sync_conflicts_root_fingerprint_ck" CHECK(length("__new_app_sync_conflicts"."root_fingerprint") = 64 AND "__new_app_sync_conflicts"."root_fingerprint" NOT GLOB '*[^0-9a-f]*'),
32
+ CONSTRAINT "app_sync_conflicts_generation_ck" CHECK("__new_app_sync_conflicts"."grant_generation" >= 1),
33
+ CONSTRAINT "app_sync_conflicts_scope_ck" CHECK("__new_app_sync_conflicts"."scope_version" = 'workout-log.records.v1'),
34
+ CONSTRAINT "app_sync_conflicts_ref_ck" CHECK(length("__new_app_sync_conflicts"."ref") BETWEEN 1 AND 256),
35
+ CONSTRAINT "app_sync_conflicts_doc_id_ck" CHECK(length("__new_app_sync_conflicts"."doc_id") BETWEEN 1 AND 128),
36
+ CONSTRAINT "app_sync_conflicts_local_version_ck" CHECK(length("__new_app_sync_conflicts"."local_version") BETWEEN 1 AND 256 AND instr("__new_app_sync_conflicts"."local_version", '/') = 0 AND instr("__new_app_sync_conflicts"."local_version", char(92)) = 0),
37
+ CONSTRAINT "app_sync_conflicts_local_fingerprint_ck" CHECK(length("__new_app_sync_conflicts"."local_fingerprint") = 71 AND substr("__new_app_sync_conflicts"."local_fingerprint", 1, 7) = 'sha256:' AND substr("__new_app_sync_conflicts"."local_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
38
+ CONSTRAINT "app_sync_conflicts_baseline_ck" CHECK(("__new_app_sync_conflicts"."baseline_revision" IS NULL) = ("__new_app_sync_conflicts"."baseline_fingerprint" IS NULL) AND ("__new_app_sync_conflicts"."baseline_revision" IS NULL OR ("__new_app_sync_conflicts"."baseline_revision" >= 0 AND length("__new_app_sync_conflicts"."baseline_fingerprint") = 71 AND substr("__new_app_sync_conflicts"."baseline_fingerprint", 1, 7) = 'sha256:' AND substr("__new_app_sync_conflicts"."baseline_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'))),
39
+ CONSTRAINT "app_sync_conflicts_remote_ck" CHECK("__new_app_sync_conflicts"."remote_revision" >= 0 AND length("__new_app_sync_conflicts"."remote_fingerprint") = 71 AND substr("__new_app_sync_conflicts"."remote_fingerprint", 1, 7) = 'sha256:' AND substr("__new_app_sync_conflicts"."remote_fingerprint", 8) NOT GLOB '*[^0-9a-f]*'),
40
+ CONSTRAINT "app_sync_conflicts_flags_ck" CHECK("__new_app_sync_conflicts"."needs_reattach" IN (0, 1) AND "__new_app_sync_conflicts"."cleanup_pending" IN (0, 1)),
41
+ CONSTRAINT "app_sync_conflicts_handle_ck" CHECK("__new_app_sync_conflicts"."vault_handle" IS NULL OR (length("__new_app_sync_conflicts"."vault_handle") BETWEEN 1 AND 256 AND instr("__new_app_sync_conflicts"."vault_handle", '/') = 0 AND instr("__new_app_sync_conflicts"."vault_handle", char(92)) = 0)),
42
+ CONSTRAINT "app_sync_conflicts_preservation_ck" CHECK("__new_app_sync_conflicts"."preservation_status" IN ('pending', 'ready', 'failed')),
43
+ CONSTRAINT "app_sync_conflicts_state_ck" CHECK("__new_app_sync_conflicts"."state" IN ('open', 'resolving', 'resolved', 'kept_both')),
44
+ CONSTRAINT "app_sync_conflicts_archive_lifecycle_ck" CHECK((
45
+ ("__new_app_sync_conflicts"."preservation_status" IN ('pending', 'failed') AND "__new_app_sync_conflicts"."vault_handle" IS NULL
46
+ AND "__new_app_sync_conflicts"."state" = 'open' AND "__new_app_sync_conflicts"."cleanup_pending" = 0)
47
+ OR ("__new_app_sync_conflicts"."preservation_status" = 'ready' AND (
48
+ ("__new_app_sync_conflicts"."state" IN ('open', 'resolving') AND "__new_app_sync_conflicts"."vault_handle" IS NOT NULL AND "__new_app_sync_conflicts"."cleanup_pending" = 0)
49
+ OR ("__new_app_sync_conflicts"."state" IN ('resolved', 'kept_both') AND "__new_app_sync_conflicts"."resolution_request_id" IS NOT NULL
50
+ AND (("__new_app_sync_conflicts"."cleanup_pending" = 1 AND "__new_app_sync_conflicts"."vault_handle" IS NOT NULL)
51
+ OR ("__new_app_sync_conflicts"."cleanup_pending" = 0 AND "__new_app_sync_conflicts"."vault_handle" IS NULL)))
52
+ ))
53
+ )),
54
+ CONSTRAINT "app_sync_conflicts_resolution_ck" CHECK(("__new_app_sync_conflicts"."resolution_request_id" IS NULL AND "__new_app_sync_conflicts"."resolution_choice" IS NULL) OR (length("__new_app_sync_conflicts"."resolution_request_id") BETWEEN 1 AND 128 AND "__new_app_sync_conflicts"."resolution_choice" IN ('keep_local', 'use_cloud', 'keep_both'))),
55
+ CONSTRAINT "app_sync_conflicts_time_ck" CHECK("__new_app_sync_conflicts"."updated_at" >= "__new_app_sync_conflicts"."created_at")
56
+ );
57
+ --> statement-breakpoint
58
+ INSERT INTO `__new_app_sync_conflicts`("conflict_id", "binding_id", "account_key", "workspace_id", "root_fingerprint", "grant_id", "grant_generation", "scope_version", "ref", "doc_id", "local_version", "local_fingerprint", "baseline_revision", "baseline_fingerprint", "remote_revision", "remote_fingerprint", "needs_reattach", "vault_handle", "preservation_status", "state", "resolution_request_id", "resolution_choice", "cleanup_pending", "created_at", "updated_at") SELECT "conflict_id", "binding_id", "account_key", "workspace_id", "root_fingerprint", "grant_id", "grant_generation", "scope_version", "ref", "doc_id", "local_version", "local_fingerprint", "baseline_revision", "baseline_fingerprint", "remote_revision", "remote_fingerprint", "needs_reattach", "vault_handle", "preservation_status", "state", "resolution_request_id", "resolution_choice", "cleanup_pending", "created_at", "updated_at" FROM `app_sync_conflicts`;--> statement-breakpoint
59
+ DROP TABLE `app_sync_conflicts`;--> statement-breakpoint
60
+ ALTER TABLE `__new_app_sync_conflicts` RENAME TO `app_sync_conflicts`;--> statement-breakpoint
61
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
62
+ CREATE UNIQUE INDEX IF NOT EXISTS `app_sync_conflicts_identity_uq` ON `app_sync_conflicts` (`binding_id`,`grant_id`,`grant_generation`,`ref`,`local_version`,`remote_revision`,`remote_fingerprint`);--> statement-breakpoint
63
+ CREATE INDEX IF NOT EXISTS `app_sync_conflicts_lookup_idx` ON `app_sync_conflicts` (`account_key`,`binding_id`,`state`,`updated_at`);