@taskforcehq/taskforce 0.3.324 → 0.3.327

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 (1361) hide show
  1. package/LICENSE.md +68 -0
  2. package/README.md +19 -0
  3. package/dist/Taskforce.module.css +2191 -540
  4. package/dist/TaskforceCore.d.ts +1 -0
  5. package/dist/TaskforceCore.js +65 -22
  6. package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.d.ts +1 -0
  7. package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.js +3 -2
  8. package/dist/annotatedAttachments/commandService.d.ts +68 -0
  9. package/dist/annotatedAttachments/commandService.js +348 -0
  10. package/dist/annotatedAttachments/service.d.ts +2 -0
  11. package/dist/annotatedAttachments/service.js +13 -12
  12. package/dist/cli.js +158 -9
  13. package/dist/cliOpenPort.d.ts +1 -0
  14. package/dist/cliOpenPort.js +4 -0
  15. package/dist/compat/taskforceAgentDefinitionCompat.d.ts +12 -0
  16. package/dist/compat/taskforceAgentDefinitionCompat.js +25 -0
  17. package/dist/compat/workspaceSyncCompat.js +6 -2
  18. package/dist/compat/workspaceSyncV3CombinedCoverageCompat.d.ts +6 -0
  19. package/dist/compat/workspaceSyncV3CombinedCoverageCompat.js +22 -0
  20. package/dist/compat/workspaceSyncV3OperationCompat.d.ts +7 -0
  21. package/dist/compat/workspaceSyncV3OperationCompat.js +30 -0
  22. package/dist/components/activity/EntityActivityTimeline.d.ts +10 -2
  23. package/dist/components/activity/EntityActivityTimeline.js +73 -35
  24. package/dist/components/context/AttachmentPreviewHost.d.ts +6 -0
  25. package/dist/components/context/AttachmentPreviewHost.js +222 -0
  26. package/dist/components/context/ContextAttachmentManager.d.ts +4 -0
  27. package/dist/components/context/ContextAttachmentManager.js +418 -208
  28. package/dist/components/features/AiProfilesModule.d.ts +24 -0
  29. package/dist/components/features/AiProfilesModule.js +744 -0
  30. package/dist/components/features/AnnotatedAttachmentWorkspace.d.ts +4 -1
  31. package/dist/components/features/AnnotatedAttachmentWorkspace.js +351 -79
  32. package/dist/components/features/DocumentGenerateModal.js +23 -5
  33. package/dist/components/features/DocumentIndex.d.ts +19 -1
  34. package/dist/components/features/DocumentIndex.js +104 -15
  35. package/dist/components/features/DocumentViewer.d.ts +9 -1
  36. package/dist/components/features/DocumentViewer.js +721 -100
  37. package/dist/components/features/DocumentWorkspace.d.ts +37 -2
  38. package/dist/components/features/DocumentWorkspace.js +21 -6
  39. package/dist/components/features/TaskSettings.d.ts +6 -27
  40. package/dist/components/features/TaskSettings.js +257 -151
  41. package/dist/components/features/TaskforceAgentsModule.d.ts +36 -0
  42. package/dist/components/features/TaskforceAgentsModule.js +1782 -0
  43. package/dist/components/features/agentBehavior/AgentBehaviorManagerShared.d.ts +94 -0
  44. package/dist/components/features/agentBehavior/AgentBehaviorManagerShared.js +70 -0
  45. package/dist/components/features/agentCapabilities/AgentCapabilitiesPrototype.d.ts +65 -0
  46. package/dist/components/features/agentCapabilities/AgentCapabilitiesPrototype.js +115 -0
  47. package/dist/components/features/agentRoles/RoleManagerPanel.d.ts +4 -0
  48. package/dist/components/features/agentRoles/RoleManagerPanel.js +382 -0
  49. package/dist/components/features/agentSkills/SkillManagerPanel.d.ts +5 -0
  50. package/dist/components/features/agentSkills/SkillManagerPanel.js +355 -0
  51. package/dist/components/features/documentWorkspaceModel.d.ts +16 -4
  52. package/dist/components/features/documentWorkspaceModel.js +30 -5
  53. package/dist/components/features/planning/PlanningArchiveConfirmation.d.ts +9 -0
  54. package/dist/components/features/planning/PlanningArchiveConfirmation.js +19 -0
  55. package/dist/components/features/planning/PlanningCardIdentity.d.ts +12 -0
  56. package/dist/components/features/planning/PlanningCardIdentity.js +44 -0
  57. package/dist/components/features/planning/PlanningEntityDetails.d.ts +36 -0
  58. package/dist/components/features/planning/PlanningEntityDetails.js +131 -0
  59. package/dist/components/features/planning/PlanningEntitySummary.d.ts +44 -0
  60. package/dist/components/features/planning/PlanningEntitySummary.js +97 -0
  61. package/dist/components/features/planning/PlanningLinkPicker.d.ts +9 -0
  62. package/dist/components/features/planning/PlanningLinkPicker.js +26 -0
  63. package/dist/components/features/planning/PlanningModule.d.ts +6 -0
  64. package/dist/components/features/planning/PlanningModule.js +571 -0
  65. package/dist/components/features/planning/PlanningOwnerDropdown.d.ts +27 -0
  66. package/dist/components/features/planning/PlanningOwnerDropdown.js +80 -0
  67. package/dist/components/features/planning/PlanningTaskArrangeControl.d.ts +5 -0
  68. package/dist/components/features/planning/PlanningTaskArrangeControl.js +11 -0
  69. package/dist/components/features/planning/PlanningTaskCard.d.ts +20 -0
  70. package/dist/components/features/planning/PlanningTaskCard.js +26 -0
  71. package/dist/components/features/planning/PlanningTaskOrderList.d.ts +10 -0
  72. package/dist/components/features/planning/PlanningTaskOrderList.js +52 -0
  73. package/dist/components/features/planning/PlanningUnlinkConfirmation.d.ts +15 -0
  74. package/dist/components/features/planning/PlanningUnlinkConfirmation.js +7 -0
  75. package/dist/components/features/planning/planningCreateIntent.d.ts +10 -0
  76. package/dist/components/features/planning/planningCreateIntent.js +16 -0
  77. package/dist/components/features/planning/planningNavigator.d.ts +33 -0
  78. package/dist/components/features/planning/planningNavigator.js +96 -0
  79. package/dist/components/features/planning/planningTaskArrangement.d.ts +18 -0
  80. package/dist/components/features/planning/planningTaskArrangement.js +106 -0
  81. package/dist/components/features/planning/planningWorkspaceModel.d.ts +121 -0
  82. package/dist/components/features/planning/planningWorkspaceModel.js +5 -0
  83. package/dist/components/features/settings/CategoryManager.js +2 -2
  84. package/dist/components/features/settings/TaxonomyEditor.js +1 -1
  85. package/dist/components/features/settings/TaxonomyManager.js +1 -1
  86. package/dist/components/features/settings/TypeManager.js +1 -1
  87. package/dist/components/features/taskforceAgentAssignments/AgentBehaviorAssignments.d.ts +10 -0
  88. package/dist/components/features/taskforceAgentAssignments/AgentBehaviorAssignments.js +175 -0
  89. package/dist/components/features/taskforceAgentAssignments/agentBehaviorCatalogApi.d.ts +27 -0
  90. package/dist/components/features/taskforceAgentAssignments/agentBehaviorCatalogApi.js +24 -0
  91. package/dist/components/features/taskforceAgentEditorModel.d.ts +109 -0
  92. package/dist/components/features/taskforceAgentEditorModel.js +145 -0
  93. package/dist/components/features/useDocumentWorkspaceController.d.ts +20 -1
  94. package/dist/components/features/useDocumentWorkspaceController.js +106 -21
  95. package/dist/components/features/workflowManager/WorkflowManagerModule.d.ts +11 -0
  96. package/dist/components/features/workflowManager/WorkflowManagerModule.js +313 -0
  97. package/dist/components/features/workflowManager/WorkflowPublishDialog.d.ts +11 -0
  98. package/dist/components/features/workflowManager/WorkflowPublishDialog.js +8 -0
  99. package/dist/components/features/workflowManager/types.d.ts +74 -0
  100. package/dist/components/features/workflowManager/types.js +1 -0
  101. package/dist/components/features/workflowManager/useWorkflowManager.d.ts +30 -0
  102. package/dist/components/features/workflowManager/useWorkflowManager.js +213 -0
  103. package/dist/components/features/workflowManager/workflowManagerApi.d.ts +52 -0
  104. package/dist/components/features/workflowManager/workflowManagerApi.js +142 -0
  105. package/dist/components/task/TaskActionHeader.d.ts +6 -3
  106. package/dist/components/task/TaskActionHeader.js +46 -53
  107. package/dist/components/task/TaskCard.d.ts +10 -2
  108. package/dist/components/task/TaskCard.js +103 -54
  109. package/dist/components/task/TaskContextUpload.d.ts +1 -0
  110. package/dist/components/task/TaskContextUpload.js +3 -2
  111. package/dist/components/task/TaskForm.d.ts +12 -17
  112. package/dist/components/task/TaskForm.js +544 -199
  113. package/dist/components/task/TaskImageReviews.d.ts +8 -0
  114. package/dist/components/task/TaskImageReviews.js +47 -0
  115. package/dist/components/task/TaskKanban.d.ts +11 -12
  116. package/dist/components/task/TaskKanban.js +70 -18
  117. package/dist/components/task/TaskList.d.ts +9 -8
  118. package/dist/components/task/TaskList.js +46 -32
  119. package/dist/components/task/TaskReferenceBadge.d.ts +2 -1
  120. package/dist/components/task/TaskReferenceBadge.js +3 -2
  121. package/dist/components/task/TaskStatusActions.d.ts +3 -1
  122. package/dist/components/task/TaskStatusActions.js +17 -6
  123. package/dist/components/task/TaskWorkflowAssignmentField.d.ts +18 -0
  124. package/dist/components/task/TaskWorkflowAssignmentField.js +362 -0
  125. package/dist/components/task/TaskWorkstreamPicker.d.ts +8 -0
  126. package/dist/components/task/TaskWorkstreamPicker.js +24 -0
  127. package/dist/components/task/TrashRestoreControls.d.ts +18 -0
  128. package/dist/components/task/TrashRestoreControls.js +71 -0
  129. package/dist/components/ui/AiIdentityRosterCard.d.ts +20 -0
  130. package/dist/components/ui/AiIdentityRosterCard.js +5 -0
  131. package/dist/components/ui/AssetTraySortControl.d.ts +10 -0
  132. package/dist/components/ui/AssetTraySortControl.js +38 -0
  133. package/dist/components/ui/AssigneeIdentity.d.ts +12 -0
  134. package/dist/components/ui/AssigneeIdentity.js +41 -0
  135. package/dist/components/ui/DiscardChangesDialog.d.ts +10 -0
  136. package/dist/components/ui/DiscardChangesDialog.js +7 -0
  137. package/dist/components/ui/DisclosureSectionHeader.d.ts +4 -1
  138. package/dist/components/ui/DisclosureSectionHeader.js +2 -2
  139. package/dist/components/ui/EditableAvatarButton.d.ts +6 -1
  140. package/dist/components/ui/EditableAvatarButton.js +6 -5
  141. package/dist/components/ui/HierarchyActionBadge.d.ts +2 -1
  142. package/dist/components/ui/HierarchyActionBadge.js +2 -2
  143. package/dist/components/ui/Markdown.d.ts +13 -3
  144. package/dist/components/ui/Markdown.fixture.d.ts +1 -0
  145. package/dist/components/ui/Markdown.fixture.js +23 -0
  146. package/dist/components/ui/Markdown.js +158 -68
  147. package/dist/components/ui/Modal.d.ts +3 -1
  148. package/dist/components/ui/Modal.js +85 -19
  149. package/dist/components/ui/MultiSelectFilter.d.ts +9 -2
  150. package/dist/components/ui/MultiSelectFilter.js +26 -5
  151. package/dist/components/ui/ReferenceBadgeButton.js +2 -3
  152. package/dist/components/ui/TaxonomyDropdown.d.ts +10 -1
  153. package/dist/components/ui/TaxonomyDropdown.js +149 -58
  154. package/dist/components/ui/TopNoticeLayer.d.ts +2 -1
  155. package/dist/components/ui/TopNoticeLayer.js +5 -2
  156. package/dist/components/ui/useFallbackImageUrl.d.ts +4 -0
  157. package/dist/components/ui/useFallbackImageUrl.js +20 -0
  158. package/dist/components/views/AppShellHeader.js +2 -2
  159. package/dist/components/views/StandaloneLayout.d.ts +1 -0
  160. package/dist/components/views/StandaloneLayout.js +1684 -620
  161. package/dist/components/views/WidgetView.d.ts +1 -0
  162. package/dist/components/views/WidgetView.js +95 -30
  163. package/dist/components/views/chrome/WorkspaceChromeSections.d.ts +4 -2
  164. package/dist/components/views/chrome/WorkspaceChromeSections.js +3 -6
  165. package/dist/components/views/chrome/workspaceChrome.d.ts +5 -8
  166. package/dist/components/views/chrome/workspaceChrome.js +62 -27
  167. package/dist/components/views/panels/FilterToolbar.d.ts +4 -3
  168. package/dist/components/views/panels/FilterToolbar.js +8 -5
  169. package/dist/components/views/panels/FilterToolbarControls.d.ts +11 -2
  170. package/dist/components/views/panels/FilterToolbarControls.js +35 -20
  171. package/dist/components/views/panels/PlanningDrawer.d.ts +62 -51
  172. package/dist/components/views/panels/PlanningDrawer.js +993 -314
  173. package/dist/components/views/planningScope.d.ts +4 -0
  174. package/dist/components/views/planningScope.js +12 -1
  175. package/dist/components/views/standalone/modals/AccountSettingsModal.d.ts +62 -0
  176. package/dist/components/views/standalone/modals/AccountSettingsModal.js +197 -0
  177. package/dist/components/views/standalone/modals/AvatarImageManagerModal.d.ts +7 -2
  178. package/dist/components/views/standalone/modals/AvatarImageManagerModal.js +56 -9
  179. package/dist/components/views/standalone/modals/HelpModal.d.ts +1 -2
  180. package/dist/components/views/standalone/modals/HelpModal.js +3 -4
  181. package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +8 -9
  182. package/dist/components/views/standalone/modals/SyncStatusModal.js +85 -25
  183. package/dist/components/views/standalone/modals/TeamManagementModal.js +1 -1
  184. package/dist/config/applicationBaseUrl.d.ts +2 -0
  185. package/dist/config/applicationBaseUrl.js +23 -0
  186. package/dist/config/envSchema.d.ts +1 -1
  187. package/dist/config/envSchema.js +166 -5
  188. package/dist/core/AdminAuditRetentionService.d.ts +43 -0
  189. package/dist/core/AdminAuditRetentionService.js +126 -0
  190. package/dist/core/AiProfileService.d.ts +34 -0
  191. package/dist/core/AiProfileService.js +516 -252
  192. package/dist/core/AttachmentLinkService.d.ts +10 -2
  193. package/dist/core/AttachmentLinkService.js +44 -12
  194. package/dist/core/AuthIdentityService.d.ts +6 -0
  195. package/dist/core/AuthIdentityService.js +38 -0
  196. package/dist/core/AuthTokenService.d.ts +1 -0
  197. package/dist/core/AuthTokenService.js +13 -0
  198. package/dist/core/DeletedTaskLifecycleService.d.ts +4 -2
  199. package/dist/core/DeletedTaskLifecycleService.js +124 -38
  200. package/dist/core/GlobalSettingsService.d.ts +3 -1
  201. package/dist/core/GlobalSettingsService.js +30 -4
  202. package/dist/core/InitiativeDurableMutationService.d.ts +89 -0
  203. package/dist/core/InitiativeDurableMutationService.js +187 -0
  204. package/dist/core/McpTokenService.d.ts +1 -0
  205. package/dist/core/McpTokenService.js +39 -13
  206. package/dist/core/PlanningCommandPreparationService.d.ts +60 -0
  207. package/dist/core/PlanningCommandPreparationService.js +149 -0
  208. package/dist/core/ScheduleCommandService.d.ts +76 -0
  209. package/dist/core/ScheduleCommandService.js +165 -0
  210. package/dist/core/SyncReconciliationService.d.ts +29 -6
  211. package/dist/core/SyncReconciliationService.js +256 -84
  212. package/dist/core/TaskActivityService.d.ts +22 -2
  213. package/dist/core/TaskActivityService.js +177 -29
  214. package/dist/core/TaskAttachmentLinksDurableMutationService.d.ts +31 -0
  215. package/dist/core/TaskAttachmentLinksDurableMutationService.js +231 -0
  216. package/dist/core/TaskChecklistCommandService.d.ts +50 -0
  217. package/dist/core/TaskChecklistCommandService.js +111 -0
  218. package/dist/core/TaskDurableCreateMutationService.d.ts +38 -0
  219. package/dist/core/TaskDurableCreateMutationService.js +85 -0
  220. package/dist/core/TaskDurableDeleteMutationService.d.ts +47 -0
  221. package/dist/core/TaskDurableDeleteMutationService.js +54 -0
  222. package/dist/core/TaskDurableLifecycleMutationService.d.ts +38 -0
  223. package/dist/core/TaskDurableLifecycleMutationService.js +42 -0
  224. package/dist/core/TaskDurableRelationshipMutationService.d.ts +58 -0
  225. package/dist/core/TaskDurableRelationshipMutationService.js +66 -0
  226. package/dist/core/TaskDurableRestoreMutationService.d.ts +31 -0
  227. package/dist/core/TaskDurableRestoreMutationService.js +33 -0
  228. package/dist/core/TaskDurableStatusMutationService.d.ts +74 -0
  229. package/dist/core/TaskDurableStatusMutationService.js +247 -0
  230. package/dist/core/TaskDurableSyncMutationService.d.ts +34 -0
  231. package/dist/core/TaskDurableSyncMutationService.js +70 -0
  232. package/dist/core/TaskDurableWorkflowMutationService.d.ts +48 -0
  233. package/dist/core/TaskDurableWorkflowMutationService.js +59 -0
  234. package/dist/core/TaskLifecycleCommandService.d.ts +101 -0
  235. package/dist/core/TaskLifecycleCommandService.js +161 -0
  236. package/dist/core/TaskRootCommandPreparationService.d.ts +35 -0
  237. package/dist/core/TaskRootCommandPreparationService.js +103 -0
  238. package/dist/core/Taskforce.d.ts +479 -59
  239. package/dist/core/Taskforce.js +3671 -841
  240. package/dist/core/WorkflowAssignmentService.d.ts +40 -0
  241. package/dist/core/WorkflowAssignmentService.js +158 -0
  242. package/dist/core/WorkflowExecutionService.d.ts +69 -0
  243. package/dist/core/WorkflowExecutionService.js +342 -0
  244. package/dist/core/WorkflowTaskActivationService.d.ts +32 -0
  245. package/dist/core/WorkflowTaskActivationService.js +63 -0
  246. package/dist/core/WorkflowTemplateService.d.ts +64 -0
  247. package/dist/core/WorkflowTemplateService.js +223 -0
  248. package/dist/core/WorkspaceLifecycleService.d.ts +1 -0
  249. package/dist/core/WorkspaceLifecycleService.js +18 -0
  250. package/dist/core/WorkstreamDurableMutationService.d.ts +90 -0
  251. package/dist/core/WorkstreamDurableMutationService.js +184 -0
  252. package/dist/core/planningReferencePolicy.d.ts +14 -0
  253. package/dist/core/planningReferencePolicy.js +53 -0
  254. package/dist/core/taskReferencePolicy.js +24 -3
  255. package/dist/core/types.d.ts +10 -10
  256. package/dist/documentReviews/DocumentReviewCommentStore.d.ts +22 -2
  257. package/dist/documentReviews/DocumentReviewCommentStore.js +92 -8
  258. package/dist/documentReviews/commandService.d.ts +51 -0
  259. package/dist/documentReviews/commandService.js +63 -0
  260. package/dist/documentReviews/service.d.ts +20 -1
  261. package/dist/documentReviews/service.js +234 -24
  262. package/dist/documentReviews/types.d.ts +18 -1
  263. package/dist/hooks/sync/bootstrap.d.ts +3 -7
  264. package/dist/hooks/sync/bootstrap.js +6 -14
  265. package/dist/hooks/sync/browserSyncAuthority.d.ts +21 -0
  266. package/dist/hooks/sync/browserSyncAuthority.js +70 -0
  267. package/dist/hooks/sync/browserSyncRemoteServices.d.ts +29 -0
  268. package/dist/hooks/sync/browserSyncRemoteServices.js +58 -0
  269. package/dist/hooks/sync/controlPlane.d.ts +1 -37
  270. package/dist/hooks/sync/controlPlane.js +1 -78
  271. package/dist/hooks/sync/lifecyclePolicy.d.ts +1 -45
  272. package/dist/hooks/sync/lifecyclePolicy.js +1 -93
  273. package/dist/hooks/sync/orchestratorShared.d.ts +9 -3
  274. package/dist/hooks/sync/orchestratorShared.js +70 -96
  275. package/dist/hooks/sync/pullLifecycle.d.ts +1 -31
  276. package/dist/hooks/sync/pullLifecycle.js +1 -24
  277. package/dist/hooks/sync/realtime.d.ts +4 -1
  278. package/dist/hooks/sync/realtime.js +103 -3
  279. package/dist/hooks/sync/recovery.d.ts +1 -84
  280. package/dist/hooks/sync/recovery.js +1 -245
  281. package/dist/hooks/sync/transfers.d.ts +8 -129
  282. package/dist/hooks/sync/transfers.js +19 -581
  283. package/dist/hooks/sync/useDataVersionRefresh.d.ts +6 -1
  284. package/dist/hooks/sync/useDataVersionRefresh.js +127 -12
  285. package/dist/hooks/sync/useDurableLocalOutboxDrain.d.ts +14 -0
  286. package/dist/hooks/sync/useDurableLocalOutboxDrain.js +208 -0
  287. package/dist/hooks/sync/useDurableTaskCreateMutation.d.ts +15 -0
  288. package/dist/hooks/sync/useDurableTaskCreateMutation.js +152 -0
  289. package/dist/hooks/sync/useDurableTaskDeleteMutation.d.ts +11 -0
  290. package/dist/hooks/sync/useDurableTaskDeleteMutation.js +21 -0
  291. package/dist/hooks/sync/useDurableTaskLifecycleMutation.d.ts +12 -0
  292. package/dist/hooks/sync/useDurableTaskLifecycleMutation.js +22 -0
  293. package/dist/hooks/sync/useDurableTaskMetadataMutation.d.ts +14 -0
  294. package/dist/hooks/sync/useDurableTaskMetadataMutation.js +24 -0
  295. package/dist/hooks/sync/useDurableTaskRestoreMutation.d.ts +12 -0
  296. package/dist/hooks/sync/useDurableTaskRestoreMutation.js +24 -0
  297. package/dist/hooks/sync/useDurableTaskStatusMutation.d.ts +18 -0
  298. package/dist/hooks/sync/useDurableTaskStatusMutation.js +23 -0
  299. package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.d.ts +23 -0
  300. package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.js +414 -0
  301. package/dist/hooks/sync/useSyncStatusActions.d.ts +2 -1
  302. package/dist/hooks/sync/useSyncStatusActions.js +8 -3
  303. package/dist/hooks/tasks/taskHttpMutation.d.ts +25 -0
  304. package/dist/hooks/tasks/taskHttpMutation.js +134 -0
  305. package/dist/hooks/tasks/useCurrentTaskRelations.d.ts +6 -1
  306. package/dist/hooks/tasks/useCurrentTaskRelations.js +32 -6
  307. package/dist/hooks/tasks/useTaskEditorNavigation.d.ts +4 -3
  308. package/dist/hooks/tasks/useTaskEditorNavigation.js +9 -13
  309. package/dist/hooks/tasks/useTaskFormActions.d.ts +17 -2
  310. package/dist/hooks/tasks/useTaskFormActions.js +309 -55
  311. package/dist/hooks/tasks/useTaskReferenceContract.d.ts +5 -0
  312. package/dist/hooks/tasks/useTaskReferenceContract.js +17 -0
  313. package/dist/hooks/tasks/useTaskRelationships.d.ts +1 -3
  314. package/dist/hooks/tasks/useTaskRelationships.js +5 -25
  315. package/dist/hooks/tasks/useTrashSelection.d.ts +12 -0
  316. package/dist/hooks/tasks/useTrashSelection.js +49 -0
  317. package/dist/hooks/ui/useInitiativeTemplates.d.ts +24 -0
  318. package/dist/hooks/ui/useInitiativeTemplates.js +22 -0
  319. package/dist/hooks/ui/useSettingsModel.d.ts +5 -29
  320. package/dist/hooks/ui/useSettingsModel.js +31 -15
  321. package/dist/hooks/ui/useSettingsPersistence.d.ts +0 -1
  322. package/dist/hooks/ui/useSettingsPersistence.js +4 -8
  323. package/dist/hooks/ui/useSettingsTaxonomyManagement.js +31 -0
  324. package/dist/hooks/useFilterSort.d.ts +2 -2
  325. package/dist/hooks/useFilterSort.js +19 -15
  326. package/dist/hooks/useRealtimeSync.d.ts +10 -0
  327. package/dist/hooks/useRealtimeSync.js +57 -4
  328. package/dist/hooks/useSyncOrchestrator.d.ts +32 -1
  329. package/dist/hooks/useSyncOrchestrator.js +963 -287
  330. package/dist/hooks/useTaskData.d.ts +11 -2
  331. package/dist/hooks/useTaskData.js +59 -26
  332. package/dist/hooks/useTaskMutations.d.ts +42 -5
  333. package/dist/hooks/useTaskMutations.js +750 -125
  334. package/dist/hooks/useTaskforce.d.ts +114 -118
  335. package/dist/hooks/useTaskforce.js +1106 -396
  336. package/dist/hooks/useUiNotice.d.ts +5 -1
  337. package/dist/hooks/useUiNotice.js +13 -2
  338. package/dist/hooks/useWorkspaceSyncController.d.ts +9 -0
  339. package/dist/hooks/useWorkspaceSyncController.js +159 -17
  340. package/dist/hooks/workspace/usePersistedAppUiState.d.ts +74 -0
  341. package/dist/hooks/workspace/usePersistedAppUiState.js +325 -0
  342. package/dist/hooks/workspace/usePersistedLayoutUiState.d.ts +76 -0
  343. package/dist/hooks/workspace/usePersistedLayoutUiState.js +479 -0
  344. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.d.ts +2 -7
  345. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +42 -31
  346. package/dist/hooks/workspace/workspaceLocalState.d.ts +42 -6
  347. package/dist/hooks/workspace/workspaceLocalState.js +213 -5
  348. package/dist/hooks/workstreams/workstreamHttpMutation.d.ts +23 -0
  349. package/dist/hooks/workstreams/workstreamHttpMutation.js +134 -0
  350. package/dist/localization/locales/en-US.d.ts +3 -3
  351. package/dist/localization/locales/en-US.js +3 -3
  352. package/dist/localization/locales/es-419.js +3 -3
  353. package/dist/localization/locales/pt-BR.js +3 -3
  354. package/dist/mcp/adminWorkspaceRegistrar.js +2 -40
  355. package/dist/mcp/aiProfileBootstrap.d.ts +3 -0
  356. package/dist/mcp/aiProfileBootstrap.js +4 -0
  357. package/dist/mcp/canonicalAssetHelpers.d.ts +16 -4
  358. package/dist/mcp/canonicalAssetHelpers.js +104 -35
  359. package/dist/mcp/clientIntegrations.d.ts +4 -2
  360. package/dist/mcp/clientIntegrations.js +104 -53
  361. package/dist/mcp/clientRegistry.d.ts +30 -0
  362. package/dist/mcp/clientRegistry.js +134 -0
  363. package/dist/mcp/collaborationRegistrar.js +21 -7
  364. package/dist/mcp/documentAssetRegistrar.js +227 -107
  365. package/dist/mcp/documentContentCommand.d.ts +94 -0
  366. package/dist/mcp/documentContentCommand.js +226 -0
  367. package/dist/mcp/documentHelpers.d.ts +14 -59
  368. package/dist/mcp/documentHelpers.js +52 -61
  369. package/dist/mcp/durableTaskMutationRouter.d.ts +65 -0
  370. package/dist/mcp/durableTaskMutationRouter.js +217 -0
  371. package/dist/mcp/durableTaskRelationshipMutationRouter.d.ts +38 -0
  372. package/dist/mcp/durableTaskRelationshipMutationRouter.js +168 -0
  373. package/dist/mcp/durableTaskRootMutationRouter.d.ts +64 -0
  374. package/dist/mcp/durableTaskRootMutationRouter.js +226 -0
  375. package/dist/mcp/gitWorktreeRoots.d.ts +2 -0
  376. package/dist/mcp/gitWorktreeRoots.js +19 -0
  377. package/dist/mcp/legacyServer.d.ts +1 -0
  378. package/dist/mcp/legacyServer.js +42 -0
  379. package/dist/mcp/localCliHealth.d.ts +56 -0
  380. package/dist/mcp/localCliHealth.js +170 -0
  381. package/dist/mcp/localServiceProxy.d.ts +23 -0
  382. package/dist/mcp/localServiceProxy.js +255 -0
  383. package/dist/mcp/mcpInputValidator.d.ts +17 -0
  384. package/dist/mcp/mcpInputValidator.js +58 -0
  385. package/dist/mcp/planningAttachmentCommandAdapter.d.ts +127 -0
  386. package/dist/mcp/planningAttachmentCommandAdapter.js +188 -0
  387. package/dist/mcp/programScaffoldCommandAdapter.d.ts +6 -0
  388. package/dist/mcp/programScaffoldCommandAdapter.js +39 -0
  389. package/dist/mcp/proxyServer.d.ts +1 -0
  390. package/dist/mcp/proxyServer.js +2 -0
  391. package/dist/mcp/runtime.d.ts +86 -1
  392. package/dist/mcp/runtime.js +4562 -2270
  393. package/dist/mcp/server.js +29 -2
  394. package/dist/mcp/sharedLocalServiceGateD.d.ts +115 -0
  395. package/dist/mcp/sharedLocalServiceGateD.js +344 -0
  396. package/dist/mcp/stdioLifecycle.d.ts +22 -0
  397. package/dist/mcp/stdioLifecycle.js +54 -0
  398. package/dist/mcp/taskAttachmentCommandAdapter.d.ts +190 -0
  399. package/dist/mcp/taskAttachmentCommandAdapter.js +464 -0
  400. package/dist/mcp/taskAttachmentHelpers.d.ts +8 -6
  401. package/dist/mcp/taskAttachmentHelpers.js +74 -2
  402. package/dist/mcp/taskAttachmentTypes.d.ts +26 -5
  403. package/dist/mcp/taskPlanCommand.d.ts +64 -0
  404. package/dist/mcp/taskPlanCommand.js +98 -0
  405. package/dist/mcp/taskPlanningRegistrar.js +253 -101
  406. package/dist/mcp/toolCallCompatibility.d.ts +6 -0
  407. package/dist/mcp/toolCallCompatibility.js +16 -0
  408. package/dist/mcp/toolCatalog.d.ts +3 -1
  409. package/dist/mcp/toolProfiles.d.ts +18 -0
  410. package/dist/mcp/toolProfiles.js +79 -0
  411. package/dist/mcp/toolRegistry.d.ts +102 -609
  412. package/dist/mcp/toolRegistry.js +108 -88
  413. package/dist/mcp/workflowExecutionRegistrar.d.ts +2 -0
  414. package/dist/mcp/workflowExecutionRegistrar.js +51 -0
  415. package/dist/migrations/taskSchemaMigrations.d.ts +35 -0
  416. package/dist/migrations/taskSchemaMigrations.js +1797 -4
  417. package/dist/migrations/taskUpdatedAtSyncDriftMigration.d.ts +20 -0
  418. package/dist/migrations/taskUpdatedAtSyncDriftMigration.js +153 -0
  419. package/dist/migrations/taskforceAgentDefinitionMigration.d.ts +26 -0
  420. package/dist/migrations/taskforceAgentDefinitionMigration.js +116 -0
  421. package/dist/plugins/vite.js +48 -17
  422. package/dist/public/Taskforce_Van.webp +0 -0
  423. package/dist/runtime/appGateDefinitions.d.ts +16 -10
  424. package/dist/runtime/appGateDefinitions.js +16 -10
  425. package/dist/runtime/appGates.d.ts +5 -4
  426. package/dist/runtime/appGates.js +4 -3
  427. package/dist/server/aiProfileAvatarAssets.d.ts +11 -8
  428. package/dist/server/aiProfileAvatarAssets.js +159 -70
  429. package/dist/server/auth.js +15 -1
  430. package/dist/server/cors.d.ts +2 -1
  431. package/dist/server/cors.js +45 -8
  432. package/dist/server/email.d.ts +3 -1
  433. package/dist/server/email.js +46 -8
  434. package/dist/server/index.d.ts +24 -1
  435. package/dist/server/index.js +342 -46
  436. package/dist/server/localDataOwnerPermit.d.ts +18 -0
  437. package/dist/server/localDataOwnerPermit.js +58 -0
  438. package/dist/server/localDatabaseIdentity.d.ts +14 -0
  439. package/dist/server/localDatabaseIdentity.js +69 -0
  440. package/dist/server/localRealtimeFileInvalidation.d.ts +1 -0
  441. package/dist/server/localRealtimeFileInvalidation.js +7 -0
  442. package/dist/server/localServiceLease.d.ts +62 -0
  443. package/dist/server/localServiceLease.js +477 -0
  444. package/dist/server/localServiceOwnershipBootstrap.d.ts +19 -0
  445. package/dist/server/localServiceOwnershipBootstrap.js +84 -0
  446. package/dist/server/localServiceSessions.d.ts +87 -0
  447. package/dist/server/localServiceSessions.js +309 -0
  448. package/dist/server/localServiceWindowsAcl.d.ts +8 -0
  449. package/dist/server/localServiceWindowsAcl.js +60 -0
  450. package/dist/server/localSyncProcessLockBootstrap.d.ts +3 -0
  451. package/dist/server/localSyncProcessLockBootstrap.js +16 -0
  452. package/dist/server/localWorkspaceSyncServerComposition.d.ts +59 -0
  453. package/dist/server/localWorkspaceSyncServerComposition.js +91 -0
  454. package/dist/server/localWorkspaceSyncServerRuntime.d.ts +119 -0
  455. package/dist/server/localWorkspaceSyncServerRuntime.js +1163 -0
  456. package/dist/server/rateLimit.d.ts +1 -0
  457. package/dist/server/rateLimit.js +16 -0
  458. package/dist/server/routes/admin.d.ts +2 -4
  459. package/dist/server/routes/admin.js +199 -337
  460. package/dist/server/routes/agentRoles.d.ts +13 -0
  461. package/dist/server/routes/agentRoles.js +273 -0
  462. package/dist/server/routes/agentSkills.d.ts +16 -0
  463. package/dist/server/routes/agentSkills.js +291 -0
  464. package/dist/server/routes/agents.d.ts +49 -0
  465. package/dist/server/routes/agents.js +1455 -0
  466. package/dist/server/routes/annotatedAttachments.js +46 -9
  467. package/dist/server/routes/assetAccess.d.ts +36 -0
  468. package/dist/server/routes/assetAccess.js +93 -0
  469. package/dist/server/routes/auth.d.ts +4 -3
  470. package/dist/server/routes/auth.js +236 -21
  471. package/dist/server/routes/authSupport.d.ts +3 -1
  472. package/dist/server/routes/authSupport.js +22 -8
  473. package/dist/server/routes/documentReviews.d.ts +2 -0
  474. package/dist/server/routes/documentReviews.js +155 -15
  475. package/dist/server/routes/documents.d.ts +1 -0
  476. package/dist/server/routes/documents.js +335 -141
  477. package/dist/server/routes/durableTaskHttpRouters.d.ts +165 -0
  478. package/dist/server/routes/durableTaskHttpRouters.js +89 -0
  479. package/dist/server/routes/localMcpHealth.d.ts +11 -0
  480. package/dist/server/routes/localMcpHealth.js +29 -0
  481. package/dist/server/routes/localService.d.ts +13 -0
  482. package/dist/server/routes/localService.js +444 -0
  483. package/dist/server/routes/localUpdate.d.ts +11 -0
  484. package/dist/server/routes/localUpdate.js +154 -0
  485. package/dist/server/routes/primitives.d.ts +27 -0
  486. package/dist/server/routes/primitives.js +18 -0
  487. package/dist/server/routes/resources.d.ts +1 -10
  488. package/dist/server/routes/resources.js +1 -153
  489. package/dist/server/routes/shared.d.ts +31 -2
  490. package/dist/server/routes/shared.js +394 -0
  491. package/dist/server/routes/sync.d.ts +2 -0
  492. package/dist/server/routes/sync.js +184 -272
  493. package/dist/server/routes/syncAuxRoutes.d.ts +3 -1
  494. package/dist/server/routes/syncAuxRoutes.js +9 -4
  495. package/dist/server/routes/syncCoordinatorLocalRoutes.d.ts +6 -0
  496. package/dist/server/routes/syncCoordinatorLocalRoutes.js +867 -0
  497. package/dist/server/routes/syncPullApplyRoutes.d.ts +29 -1
  498. package/dist/server/routes/syncPullApplyRoutes.js +520 -17
  499. package/dist/server/routes/syncPushRoutes.d.ts +33 -4
  500. package/dist/server/routes/syncPushRoutes.js +251 -62
  501. package/dist/server/routes/syncRouteTypes.d.ts +1 -1
  502. package/dist/server/routes/syncSnapshotRoutes.d.ts +15 -7
  503. package/dist/server/routes/syncSnapshotRoutes.js +95 -17
  504. package/dist/server/routes/syncV3DiagnosticsRoutes.d.ts +14 -0
  505. package/dist/server/routes/syncV3DiagnosticsRoutes.js +72 -0
  506. package/dist/server/routes/syncV3FeedRoutes.d.ts +20 -0
  507. package/dist/server/routes/syncV3FeedRoutes.js +462 -0
  508. package/dist/server/routes/syncV3LocalCaptureRoutes.d.ts +37 -0
  509. package/dist/server/routes/syncV3LocalCaptureRoutes.js +897 -0
  510. package/dist/server/routes/syncV3LocalDispatchRoutes.d.ts +17 -0
  511. package/dist/server/routes/syncV3LocalDispatchRoutes.js +280 -0
  512. package/dist/server/routes/syncV3LocalFeedApplyRoutes.d.ts +17 -0
  513. package/dist/server/routes/syncV3LocalFeedApplyRoutes.js +493 -0
  514. package/dist/server/routes/syncV3LocalOwnershipRoutes.d.ts +10 -0
  515. package/dist/server/routes/syncV3LocalOwnershipRoutes.js +51 -0
  516. package/dist/server/routes/syncV3LocalRecoveryRoutes.d.ts +12 -0
  517. package/dist/server/routes/syncV3LocalRecoveryRoutes.js +78 -0
  518. package/dist/server/routes/syncV3OperationRoutes.d.ts +35 -0
  519. package/dist/server/routes/syncV3OperationRoutes.js +1136 -0
  520. package/dist/server/routes/tasks.d.ts +0 -2
  521. package/dist/server/routes/tasks.js +932 -195
  522. package/dist/server/routes/workflows.d.ts +26 -0
  523. package/dist/server/routes/workflows.js +500 -0
  524. package/dist/server/routes.d.ts +1 -6
  525. package/dist/server/routes.js +148 -339
  526. package/dist/server/smtpTransport.d.ts +11 -3
  527. package/dist/server/smtpTransport.js +9 -2
  528. package/dist/server/start.js +42 -10
  529. package/dist/service/localServiceCli.d.ts +33 -0
  530. package/dist/service/localServiceCli.js +365 -0
  531. package/dist/service/localServiceClientLifecycle.d.ts +25 -0
  532. package/dist/service/localServiceClientLifecycle.js +128 -0
  533. package/dist/service/localServiceOpen.d.ts +17 -0
  534. package/dist/service/localServiceOpen.js +27 -0
  535. package/dist/services/agentRoleResolver.d.ts +4 -0
  536. package/dist/services/agentRoleResolver.js +7 -0
  537. package/dist/services/aiProfileAvatarGenerationService.d.ts +41 -0
  538. package/dist/services/aiProfileAvatarGenerationService.js +158 -0
  539. package/dist/services/avatarImageProvider.d.ts +33 -0
  540. package/dist/services/avatarImageProvider.js +140 -0
  541. package/dist/services/bedrockAnthropicMessagesModelGateway.d.ts +24 -0
  542. package/dist/services/bedrockAnthropicMessagesModelGateway.js +95 -0
  543. package/dist/services/bedrockMantleModelGateway.d.ts +43 -0
  544. package/dist/services/bedrockMantleModelGateway.js +81 -0
  545. package/dist/services/bedrockModelGateway.d.ts +26 -0
  546. package/dist/services/bedrockModelGateway.js +94 -0
  547. package/dist/services/modelGateway.d.ts +82 -0
  548. package/dist/services/modelGateway.js +61 -0
  549. package/dist/services/taskforceAgentAvatarImageProvider.d.ts +8 -0
  550. package/dist/services/taskforceAgentAvatarImageProvider.js +24 -0
  551. package/dist/services/taskforceAgentMcpBridge.d.ts +77 -0
  552. package/dist/services/taskforceAgentMcpBridge.js +527 -0
  553. package/dist/shared/agentRoleDefinition.d.ts +34 -0
  554. package/dist/shared/agentRoleDefinition.js +207 -0
  555. package/dist/shared/aiProfileAvatarEligibility.d.ts +10 -0
  556. package/dist/shared/aiProfileAvatarEligibility.js +27 -0
  557. package/dist/shared/aiProfileColors.d.ts +7 -0
  558. package/dist/shared/aiProfileColors.js +33 -0
  559. package/dist/shared/colorPalette.d.ts +3 -0
  560. package/dist/shared/colorPalette.js +20 -0
  561. package/dist/shared/commentProvenance.d.ts +4 -0
  562. package/dist/shared/commentProvenance.js +6 -0
  563. package/dist/shared/deletedTaskRetention.d.ts +2 -0
  564. package/dist/shared/deletedTaskRetention.js +7 -0
  565. package/dist/shared/passwordPolicy.d.ts +2 -1
  566. package/dist/shared/passwordPolicy.js +9 -0
  567. package/dist/shared/taskDeepLinks.d.ts +28 -0
  568. package/dist/shared/taskDeepLinks.js +48 -0
  569. package/dist/shared/taskRestoreDestination.d.ts +2 -0
  570. package/dist/shared/taskRestoreDestination.js +5 -0
  571. package/dist/shared/taskforceAgentDefinition.d.ts +88 -0
  572. package/dist/shared/taskforceAgentDefinition.js +434 -0
  573. package/dist/shared/taskforceAgentExecutionSnapshot.d.ts +50 -0
  574. package/dist/shared/taskforceAgentExecutionSnapshot.js +68 -0
  575. package/dist/shared/taskforceAgentModels.d.ts +56 -0
  576. package/dist/shared/taskforceAgentModels.js +314 -0
  577. package/dist/shared/taskforceAgentRunContext.d.ts +23 -0
  578. package/dist/shared/taskforceAgentRunContext.js +21 -0
  579. package/dist/shared/taskforceAgentRuntimeResolution.d.ts +31 -0
  580. package/dist/shared/taskforceAgentRuntimeResolution.js +72 -0
  581. package/dist/shared/taskforceAgentSkill.d.ts +33 -0
  582. package/dist/shared/taskforceAgentSkill.js +149 -0
  583. package/dist/shared/taxonomyLibrary.js +1 -1
  584. package/dist/storage/agentRoleStore.d.ts +91 -0
  585. package/dist/storage/agentRoleStore.js +385 -0
  586. package/dist/storage/databaseAdapter.d.ts +1 -0
  587. package/dist/storage/databaseAdapter.js +7 -1
  588. package/dist/storage/documentIntegrity.d.ts +12 -3
  589. package/dist/storage/documentIntegrity.js +105 -27
  590. package/dist/storage/objectStorageClient.d.ts +10 -4
  591. package/dist/storage/objectStorageClient.js +73 -43
  592. package/dist/storage/postgresAdapter.d.ts +2 -1
  593. package/dist/storage/postgresAdapter.js +38 -6
  594. package/dist/storage/postgresWorker.js +65 -1
  595. package/dist/storage/sqliteAdapter.d.ts +1 -1
  596. package/dist/storage/sqliteAdapter.js +7 -1
  597. package/dist/storage/sqliteWalHealth.d.ts +71 -0
  598. package/dist/storage/sqliteWalHealth.js +176 -0
  599. package/dist/storage/taskDataPath.d.ts +1 -0
  600. package/dist/storage/taskDataPath.js +20 -0
  601. package/dist/storage/taskforceAgentConversationStore.d.ts +66 -0
  602. package/dist/storage/taskforceAgentConversationStore.js +264 -0
  603. package/dist/storage/taskforceAgentSkillStore.d.ts +93 -0
  604. package/dist/storage/taskforceAgentSkillStore.js +355 -0
  605. package/dist/storage/taskforceAgentStore.d.ts +105 -0
  606. package/dist/storage/taskforceAgentStore.js +549 -0
  607. package/dist/storage/workflowStore.d.ts +223 -0
  608. package/dist/storage/workflowStore.js +1032 -0
  609. package/dist/storage/workspaceAssetStore.d.ts +70 -0
  610. package/dist/storage/workspaceAssetStore.js +418 -25
  611. package/dist/sync/aiProfileAvatarSyncPaths.d.ts +14 -0
  612. package/dist/sync/aiProfileAvatarSyncPaths.js +56 -0
  613. package/dist/sync/cloudSyncApi.d.ts +329 -0
  614. package/dist/sync/cloudSyncApi.js +596 -4
  615. package/dist/sync/collaborationSyncPayload.d.ts +5 -1
  616. package/dist/sync/collaborationSyncPayload.js +213 -1
  617. package/dist/sync/collaborationSyncState.d.ts +23 -3
  618. package/dist/sync/collaborationSyncState.js +92 -3
  619. package/dist/sync/contentSyncPayload.d.ts +9 -0
  620. package/dist/sync/contentSyncPayload.js +29 -0
  621. package/dist/sync/contentSyncState.d.ts +79 -4
  622. package/dist/sync/contentSyncState.js +1113 -313
  623. package/dist/sync/coordinator/localSyncBrowserApplyPermitContext.d.ts +39 -0
  624. package/dist/sync/coordinator/localSyncBrowserApplyPermitContext.js +234 -0
  625. package/dist/sync/coordinator/localSyncBrowserAuthorityCapability.d.ts +7 -0
  626. package/dist/sync/coordinator/localSyncBrowserAuthorityCapability.js +10 -0
  627. package/dist/sync/coordinator/localSyncCommittedApplyPolicy.d.ts +7 -0
  628. package/dist/sync/coordinator/localSyncCommittedApplyPolicy.js +41 -0
  629. package/dist/sync/coordinator/localSyncCoordinatorBrowserClient.d.ts +178 -0
  630. package/dist/sync/coordinator/localSyncCoordinatorBrowserClient.js +131 -0
  631. package/dist/sync/coordinator/localSyncCoordinatorCommandLifecycle.d.ts +25 -0
  632. package/dist/sync/coordinator/localSyncCoordinatorCommandLifecycle.js +200 -0
  633. package/dist/sync/coordinator/localSyncCoordinatorHost.d.ts +84 -0
  634. package/dist/sync/coordinator/localSyncCoordinatorHost.js +435 -0
  635. package/dist/sync/coordinator/localSyncCoordinatorRouteServices.d.ts +33 -0
  636. package/dist/sync/coordinator/localSyncCoordinatorRouteServices.js +1 -0
  637. package/dist/sync/coordinator/localSyncCoordinatorStore.d.ts +122 -0
  638. package/dist/sync/coordinator/localSyncCoordinatorStore.js +1039 -0
  639. package/dist/sync/coordinator/localSyncCoordinatorTypes.d.ts +82 -0
  640. package/dist/sync/coordinator/localSyncCoordinatorTypes.js +9 -0
  641. package/dist/sync/coordinator/localSyncDispatchTracker.d.ts +15 -0
  642. package/dist/sync/coordinator/localSyncDispatchTracker.js +68 -0
  643. package/dist/sync/coordinator/localSyncExecutionPermitStore.d.ts +200 -0
  644. package/dist/sync/coordinator/localSyncExecutionPermitStore.js +1388 -0
  645. package/dist/sync/coordinator/localSyncExecutionPermitTypes.d.ts +52 -0
  646. package/dist/sync/coordinator/localSyncExecutionPermitTypes.js +8 -0
  647. package/dist/sync/coordinator/localSyncOwnershipDrainBarrier.d.ts +33 -0
  648. package/dist/sync/coordinator/localSyncOwnershipDrainBarrier.js +83 -0
  649. package/dist/sync/coordinator/localSyncPermitTransactionHooks.d.ts +9 -0
  650. package/dist/sync/coordinator/localSyncPermitTransactionHooks.js +27 -0
  651. package/dist/sync/coordinator/localSyncProcessLock.d.ts +12 -0
  652. package/dist/sync/coordinator/localSyncProcessLock.js +212 -0
  653. package/dist/sync/coordinator/localSyncV3DispatchRecoveryReconciler.d.ts +17 -0
  654. package/dist/sync/coordinator/localSyncV3DispatchRecoveryReconciler.js +82 -0
  655. package/dist/sync/coordinator/localWorkspaceSyncRunner.d.ts +134 -0
  656. package/dist/sync/coordinator/localWorkspaceSyncRunner.js +981 -0
  657. package/dist/sync/coordinator/localWorkspaceSyncRunnerState.d.ts +189 -0
  658. package/dist/sync/coordinator/localWorkspaceSyncRunnerState.js +961 -0
  659. package/dist/sync/coordinator/workspaceSyncCloudCredentialValidator.d.ts +19 -0
  660. package/dist/sync/coordinator/workspaceSyncCloudCredentialValidator.js +83 -0
  661. package/dist/sync/coordinator/workspaceSyncCredentialBroker.d.ts +117 -0
  662. package/dist/sync/coordinator/workspaceSyncCredentialBroker.js +323 -0
  663. package/dist/sync/coordinator/workspaceSyncLocalAccessBootstrap.d.ts +11 -0
  664. package/dist/sync/coordinator/workspaceSyncLocalAccessBootstrap.js +51 -0
  665. package/dist/sync/coordinator/workspaceSyncTransportGateway.d.ts +139 -0
  666. package/dist/sync/coordinator/workspaceSyncTransportGateway.js +738 -0
  667. package/dist/sync/engine/localWorkspaceContentManifestService.d.ts +21 -0
  668. package/dist/sync/engine/localWorkspaceContentManifestService.js +44 -0
  669. package/dist/sync/engine/workspaceSyncAtomicLocalPublisher.d.ts +36 -0
  670. package/dist/sync/engine/workspaceSyncAtomicLocalPublisher.js +203 -0
  671. package/dist/sync/engine/workspaceSyncContentLifecycleAdapter.d.ts +21 -0
  672. package/dist/sync/engine/workspaceSyncContentLifecycleAdapter.js +13 -0
  673. package/dist/sync/engine/workspaceSyncContentPullObligationStore.d.ts +65 -0
  674. package/dist/sync/engine/workspaceSyncContentPullObligationStore.js +160 -0
  675. package/dist/sync/engine/workspaceSyncContentVersionStore.d.ts +216 -0
  676. package/dist/sync/engine/workspaceSyncContentVersionStore.js +1068 -0
  677. package/dist/sync/engine/workspaceSyncEngineBrowserGatewayRemoteServices.d.ts +28 -0
  678. package/dist/sync/engine/workspaceSyncEngineBrowserGatewayRemoteServices.js +543 -0
  679. package/dist/sync/engine/workspaceSyncEngineContracts.d.ts +78 -0
  680. package/dist/sync/engine/workspaceSyncEngineContracts.js +1 -0
  681. package/dist/sync/engine/workspaceSyncEngineControlPlane.d.ts +37 -0
  682. package/dist/sync/engine/workspaceSyncEngineControlPlane.js +79 -0
  683. package/dist/sync/engine/workspaceSyncEngineIdentity.d.ts +1 -0
  684. package/dist/sync/engine/workspaceSyncEngineIdentity.js +4 -0
  685. package/dist/sync/engine/workspaceSyncEngineLifecyclePolicy.d.ts +68 -0
  686. package/dist/sync/engine/workspaceSyncEngineLifecyclePolicy.js +180 -0
  687. package/dist/sync/engine/workspaceSyncEngineLocalApply.d.ts +72 -0
  688. package/dist/sync/engine/workspaceSyncEngineLocalApply.js +132 -0
  689. package/dist/sync/engine/workspaceSyncEngineLocalServices.d.ts +70 -0
  690. package/dist/sync/engine/workspaceSyncEngineLocalServices.js +25 -0
  691. package/dist/sync/engine/workspaceSyncEngineParity.d.ts +8 -0
  692. package/dist/sync/engine/workspaceSyncEngineParity.js +7 -0
  693. package/dist/sync/engine/workspaceSyncEnginePullPolicy.d.ts +32 -0
  694. package/dist/sync/engine/workspaceSyncEnginePullPolicy.js +27 -0
  695. package/dist/sync/engine/workspaceSyncEnginePushCompletion.d.ts +20 -0
  696. package/dist/sync/engine/workspaceSyncEnginePushCompletion.js +87 -0
  697. package/dist/sync/engine/workspaceSyncEngineRecovery.d.ts +56 -0
  698. package/dist/sync/engine/workspaceSyncEngineRecovery.js +288 -0
  699. package/dist/sync/engine/workspaceSyncEngineRemoteServices.d.ts +104 -0
  700. package/dist/sync/engine/workspaceSyncEngineRemoteServices.js +21 -0
  701. package/dist/sync/engine/workspaceSyncEngineRuntime.d.ts +61 -0
  702. package/dist/sync/engine/workspaceSyncEngineRuntime.js +59 -0
  703. package/dist/sync/engine/workspaceSyncEngineServerApplyBoundary.d.ts +28 -0
  704. package/dist/sync/engine/workspaceSyncEngineServerApplyBoundary.js +86 -0
  705. package/dist/sync/engine/workspaceSyncEngineServerLocalServices.d.ts +73 -0
  706. package/dist/sync/engine/workspaceSyncEngineServerLocalServices.js +452 -0
  707. package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.d.ts +23 -0
  708. package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.js +451 -0
  709. package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.d.ts +125 -0
  710. package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.js +1124 -0
  711. package/dist/sync/engine/workspaceSyncEngineServerSnapshotReader.d.ts +63 -0
  712. package/dist/sync/engine/workspaceSyncEngineServerSnapshotReader.js +276 -0
  713. package/dist/sync/engine/workspaceSyncEngineTransferCompletion.d.ts +20 -0
  714. package/dist/sync/engine/workspaceSyncEngineTransferCompletion.js +37 -0
  715. package/dist/sync/engine/workspaceSyncEngineTransferTypes.d.ts +7 -0
  716. package/dist/sync/engine/workspaceSyncEngineTransferTypes.js +1 -0
  717. package/dist/sync/engine/workspaceSyncEngineTransfers.d.ts +240 -0
  718. package/dist/sync/engine/workspaceSyncEngineTransfers.js +1184 -0
  719. package/dist/sync/engine/workspaceSyncEngineV3LocalFeedApply.d.ts +39 -0
  720. package/dist/sync/engine/workspaceSyncEngineV3LocalFeedApply.js +39 -0
  721. package/dist/sync/engine/workspaceSyncImmutableContentGcRunner.d.ts +25 -0
  722. package/dist/sync/engine/workspaceSyncImmutableContentGcRunner.js +83 -0
  723. package/dist/sync/engine/workspaceSyncImmutableContentProvider.d.ts +71 -0
  724. package/dist/sync/engine/workspaceSyncImmutableContentProvider.js +209 -0
  725. package/dist/sync/engine/workspaceSyncImmutableContentStager.d.ts +32 -0
  726. package/dist/sync/engine/workspaceSyncImmutableContentStager.js +202 -0
  727. package/dist/sync/engine/workspaceSyncPublishedContentResolver.d.ts +43 -0
  728. package/dist/sync/engine/workspaceSyncPublishedContentResolver.js +142 -0
  729. package/dist/sync/engine/workspaceSyncServerContentRuntime.d.ts +26 -0
  730. package/dist/sync/engine/workspaceSyncServerContentRuntime.js +41 -0
  731. package/dist/sync/engine/workspaceSyncServerDataServices.d.ts +44 -0
  732. package/dist/sync/engine/workspaceSyncServerDataServices.js +143 -0
  733. package/dist/sync/engine/workspaceSyncTransferEvidence.d.ts +39 -0
  734. package/dist/sync/engine/workspaceSyncTransferEvidence.js +45 -0
  735. package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.d.ts +44 -0
  736. package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.js +990 -0
  737. package/dist/sync/engine/workspaceSyncV2PreparedContent.d.ts +82 -0
  738. package/dist/sync/engine/workspaceSyncV2PreparedContent.js +219 -0
  739. package/dist/sync/planningCanonicalFields.d.ts +41 -0
  740. package/dist/sync/planningCanonicalFields.js +211 -0
  741. package/dist/sync/planningSyncPayload.d.ts +5 -1
  742. package/dist/sync/planningSyncPayload.js +88 -4
  743. package/dist/sync/syncApplyHandlers.d.ts +98 -8
  744. package/dist/sync/syncApplyHandlers.js +816 -78
  745. package/dist/sync/syncResourceAdapters.d.ts +10 -0
  746. package/dist/sync/syncResourceAdapters.js +21 -1
  747. package/dist/sync/syncService.d.ts +57 -1
  748. package/dist/sync/syncService.js +1085 -138
  749. package/dist/sync/taskNestedContent.d.ts +2 -0
  750. package/dist/sync/taskNestedContent.js +8 -0
  751. package/dist/sync/taskSyncChangeKey.js +0 -1
  752. package/dist/sync/taskSyncPayload.d.ts +0 -1
  753. package/dist/sync/taskSyncPayload.js +14 -3
  754. package/dist/sync/v3/canonicalWorkspaceSyncJson.d.ts +2 -0
  755. package/dist/sync/v3/canonicalWorkspaceSyncJson.js +26 -0
  756. package/dist/sync/v3/combinedFeedCapability.d.ts +21 -0
  757. package/dist/sync/v3/combinedFeedCapability.js +80 -0
  758. package/dist/sync/v3/combinedFeedPrerequisites.d.ts +18 -0
  759. package/dist/sync/v3/combinedFeedPrerequisites.js +184 -0
  760. package/dist/sync/v3/durableInitiativeMutationRouter.d.ts +61 -0
  761. package/dist/sync/v3/durableInitiativeMutationRouter.js +287 -0
  762. package/dist/sync/v3/durableOperationReplay.d.ts +36 -0
  763. package/dist/sync/v3/durableOperationReplay.js +103 -0
  764. package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.d.ts +49 -0
  765. package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.js +198 -0
  766. package/dist/sync/v3/durableTaskChecklistMutationRouter.d.ts +47 -0
  767. package/dist/sync/v3/durableTaskChecklistMutationRouter.js +182 -0
  768. package/dist/sync/v3/durableTaskCommentMutationRouter.d.ts +47 -0
  769. package/dist/sync/v3/durableTaskCommentMutationRouter.js +191 -0
  770. package/dist/sync/v3/durableTaskHttpBulkMutationRouter.d.ts +60 -0
  771. package/dist/sync/v3/durableTaskHttpBulkMutationRouter.js +320 -0
  772. package/dist/sync/v3/durableTaskHttpRootMutationRouter.d.ts +40 -0
  773. package/dist/sync/v3/durableTaskHttpRootMutationRouter.js +518 -0
  774. package/dist/sync/v3/durableTaxonomyMutationRouter.d.ts +63 -0
  775. package/dist/sync/v3/durableTaxonomyMutationRouter.js +289 -0
  776. package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.d.ts +77 -0
  777. package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.js +361 -0
  778. package/dist/sync/v3/durableWorkstreamMutationRouter.d.ts +61 -0
  779. package/dist/sync/v3/durableWorkstreamMutationRouter.js +287 -0
  780. package/dist/sync/v3/durableWorkstreamTaskOrderMutationRouter.d.ts +42 -0
  781. package/dist/sync/v3/durableWorkstreamTaskOrderMutationRouter.js +122 -0
  782. package/dist/sync/v3/entityEventLegacyAdoptionContract.d.ts +6 -0
  783. package/dist/sync/v3/entityEventLegacyAdoptionContract.js +6 -0
  784. package/dist/sync/v3/entityEventLegacyAdoptionService.d.ts +62 -0
  785. package/dist/sync/v3/entityEventLegacyAdoptionService.js +180 -0
  786. package/dist/sync/v3/initiativeActivityAuthoritativeRevision.d.ts +11 -0
  787. package/dist/sync/v3/initiativeActivityAuthoritativeRevision.js +23 -0
  788. package/dist/sync/v3/initiativeActivityIdentity.d.ts +8 -0
  789. package/dist/sync/v3/initiativeActivityIdentity.js +14 -0
  790. package/dist/sync/v3/initiativeCoexistence.d.ts +26 -0
  791. package/dist/sync/v3/initiativeCoexistence.js +148 -0
  792. package/dist/sync/v3/initiativeFeedActivationCapability.d.ts +6 -0
  793. package/dist/sync/v3/initiativeFeedActivationCapability.js +16 -0
  794. package/dist/sync/v3/initiativeMutationPayload.d.ts +26 -0
  795. package/dist/sync/v3/initiativeMutationPayload.js +144 -0
  796. package/dist/sync/v3/initiativeMutationService.d.ts +62 -0
  797. package/dist/sync/v3/initiativeMutationService.js +206 -0
  798. package/dist/sync/v3/localEntityEventLegacyAdoption.d.ts +31 -0
  799. package/dist/sync/v3/localEntityEventLegacyAdoption.js +607 -0
  800. package/dist/sync/v3/localInitiativeOutboxHandler.d.ts +8 -0
  801. package/dist/sync/v3/localInitiativeOutboxHandler.js +88 -0
  802. package/dist/sync/v3/localInitiativeOutboxService.d.ts +50 -0
  803. package/dist/sync/v3/localInitiativeOutboxService.js +495 -0
  804. package/dist/sync/v3/localOperationIdentityStore.d.ts +81 -0
  805. package/dist/sync/v3/localOperationIdentityStore.js +388 -0
  806. package/dist/sync/v3/localOutboxDispatchCapability.d.ts +7 -0
  807. package/dist/sync/v3/localOutboxDispatchCapability.js +13 -0
  808. package/dist/sync/v3/localOutboxDispatchRuntime.d.ts +16 -0
  809. package/dist/sync/v3/localOutboxDispatchRuntime.js +269 -0
  810. package/dist/sync/v3/localOutboxDispatcher.d.ts +53 -0
  811. package/dist/sync/v3/localOutboxDispatcher.js +362 -0
  812. package/dist/sync/v3/localOutboxDrainClient.d.ts +50 -0
  813. package/dist/sync/v3/localOutboxDrainClient.js +250 -0
  814. package/dist/sync/v3/localOutboxOperationHandler.d.ts +31 -0
  815. package/dist/sync/v3/localOutboxOperationHandler.js +10 -0
  816. package/dist/sync/v3/localOutboxRecoveryClient.d.ts +14 -0
  817. package/dist/sync/v3/localOutboxRecoveryClient.js +45 -0
  818. package/dist/sync/v3/localOutboxRecoveryPreparationService.d.ts +12 -0
  819. package/dist/sync/v3/localOutboxRecoveryPreparationService.js +151 -0
  820. package/dist/sync/v3/localSyncIdentityStore.d.ts +9 -0
  821. package/dist/sync/v3/localSyncIdentityStore.js +43 -0
  822. package/dist/sync/v3/localTaskAttachmentLinksOutboxHandler.d.ts +10 -0
  823. package/dist/sync/v3/localTaskAttachmentLinksOutboxHandler.js +70 -0
  824. package/dist/sync/v3/localTaskAttachmentLinksOutboxService.d.ts +45 -0
  825. package/dist/sync/v3/localTaskAttachmentLinksOutboxService.js +291 -0
  826. package/dist/sync/v3/localTaskChecklistOutboxHandler.d.ts +10 -0
  827. package/dist/sync/v3/localTaskChecklistOutboxHandler.js +54 -0
  828. package/dist/sync/v3/localTaskChecklistOutboxService.d.ts +47 -0
  829. package/dist/sync/v3/localTaskChecklistOutboxService.js +221 -0
  830. package/dist/sync/v3/localTaskCommentOutboxHandler.d.ts +10 -0
  831. package/dist/sync/v3/localTaskCommentOutboxHandler.js +94 -0
  832. package/dist/sync/v3/localTaskCommentOutboxService.d.ts +75 -0
  833. package/dist/sync/v3/localTaskCommentOutboxService.js +391 -0
  834. package/dist/sync/v3/localTaskCreateClient.d.ts +27 -0
  835. package/dist/sync/v3/localTaskCreateClient.js +209 -0
  836. package/dist/sync/v3/localTaskCreateOutboxHandler.d.ts +8 -0
  837. package/dist/sync/v3/localTaskCreateOutboxHandler.js +147 -0
  838. package/dist/sync/v3/localTaskCreateOutboxService.d.ts +77 -0
  839. package/dist/sync/v3/localTaskCreateOutboxService.js +397 -0
  840. package/dist/sync/v3/localTaskDeleteClient.d.ts +10 -0
  841. package/dist/sync/v3/localTaskDeleteClient.js +23 -0
  842. package/dist/sync/v3/localTaskDeleteOutboxHandler.d.ts +8 -0
  843. package/dist/sync/v3/localTaskDeleteOutboxHandler.js +54 -0
  844. package/dist/sync/v3/localTaskDeleteOutboxService.d.ts +38 -0
  845. package/dist/sync/v3/localTaskDeleteOutboxService.js +235 -0
  846. package/dist/sync/v3/localTaskLegacyRootAdoption.d.ts +28 -0
  847. package/dist/sync/v3/localTaskLegacyRootAdoption.js +219 -0
  848. package/dist/sync/v3/localTaskLifecycleClient.d.ts +49 -0
  849. package/dist/sync/v3/localTaskLifecycleClient.js +57 -0
  850. package/dist/sync/v3/localTaskLifecycleOutboxHandler.d.ts +8 -0
  851. package/dist/sync/v3/localTaskLifecycleOutboxHandler.js +94 -0
  852. package/dist/sync/v3/localTaskLifecycleOutboxService.d.ts +60 -0
  853. package/dist/sync/v3/localTaskLifecycleOutboxService.js +304 -0
  854. package/dist/sync/v3/localTaskMetadataClient.d.ts +13 -0
  855. package/dist/sync/v3/localTaskMetadataClient.js +30 -0
  856. package/dist/sync/v3/localTaskMetadataOutboxHandler.d.ts +8 -0
  857. package/dist/sync/v3/localTaskMetadataOutboxHandler.js +70 -0
  858. package/dist/sync/v3/localTaskMetadataOutboxService.d.ts +48 -0
  859. package/dist/sync/v3/localTaskMetadataOutboxService.js +229 -0
  860. package/dist/sync/v3/localTaskOperationClient.d.ts +72 -0
  861. package/dist/sync/v3/localTaskOperationClient.js +195 -0
  862. package/dist/sync/v3/localTaskRelationshipOutboxHandler.d.ts +8 -0
  863. package/dist/sync/v3/localTaskRelationshipOutboxHandler.js +114 -0
  864. package/dist/sync/v3/localTaskRelationshipOutboxService.d.ts +45 -0
  865. package/dist/sync/v3/localTaskRelationshipOutboxService.js +192 -0
  866. package/dist/sync/v3/localTaskRestoreClient.d.ts +13 -0
  867. package/dist/sync/v3/localTaskRestoreClient.js +32 -0
  868. package/dist/sync/v3/localTaskRestoreOutboxHandler.d.ts +8 -0
  869. package/dist/sync/v3/localTaskRestoreOutboxHandler.js +41 -0
  870. package/dist/sync/v3/localTaskRestoreOutboxService.d.ts +56 -0
  871. package/dist/sync/v3/localTaskRestoreOutboxService.js +323 -0
  872. package/dist/sync/v3/localTaskStatusClient.d.ts +17 -0
  873. package/dist/sync/v3/localTaskStatusClient.js +35 -0
  874. package/dist/sync/v3/localTaskStatusOutboxHandler.d.ts +8 -0
  875. package/dist/sync/v3/localTaskStatusOutboxHandler.js +75 -0
  876. package/dist/sync/v3/localTaskStatusOutboxService.d.ts +53 -0
  877. package/dist/sync/v3/localTaskStatusOutboxService.js +422 -0
  878. package/dist/sync/v3/localTaxonomyCompositeOutboxService.d.ts +34 -0
  879. package/dist/sync/v3/localTaxonomyCompositeOutboxService.js +290 -0
  880. package/dist/sync/v3/localTaxonomyOutboxHandler.d.ts +9 -0
  881. package/dist/sync/v3/localTaxonomyOutboxHandler.js +106 -0
  882. package/dist/sync/v3/localTaxonomyOutboxService.d.ts +30 -0
  883. package/dist/sync/v3/localTaxonomyOutboxService.js +181 -0
  884. package/dist/sync/v3/localWorkflowRuntimeOutboxHandler.d.ts +8 -0
  885. package/dist/sync/v3/localWorkflowRuntimeOutboxHandler.js +113 -0
  886. package/dist/sync/v3/localWorkflowRuntimeOutboxService.d.ts +37 -0
  887. package/dist/sync/v3/localWorkflowRuntimeOutboxService.js +330 -0
  888. package/dist/sync/v3/localWorkspaceSyncServerOutboxDispatcher.d.ts +63 -0
  889. package/dist/sync/v3/localWorkspaceSyncServerOutboxDispatcher.js +264 -0
  890. package/dist/sync/v3/localWorkstreamOutboxHandler.d.ts +8 -0
  891. package/dist/sync/v3/localWorkstreamOutboxHandler.js +102 -0
  892. package/dist/sync/v3/localWorkstreamOutboxService.d.ts +52 -0
  893. package/dist/sync/v3/localWorkstreamOutboxService.js +579 -0
  894. package/dist/sync/v3/localWorkstreamTaskOrderOutboxHandler.d.ts +10 -0
  895. package/dist/sync/v3/localWorkstreamTaskOrderOutboxHandler.js +57 -0
  896. package/dist/sync/v3/localWorkstreamTaskOrderOutboxService.d.ts +30 -0
  897. package/dist/sync/v3/localWorkstreamTaskOrderOutboxService.js +128 -0
  898. package/dist/sync/v3/planningActivation.d.ts +13 -0
  899. package/dist/sync/v3/planningActivation.js +33 -0
  900. package/dist/sync/v3/planningAttachmentActivityValidation.d.ts +9 -0
  901. package/dist/sync/v3/planningAttachmentActivityValidation.js +87 -0
  902. package/dist/sync/v3/programScaffoldService.d.ts +143 -0
  903. package/dist/sync/v3/programScaffoldService.js +478 -0
  904. package/dist/sync/v3/syncDurabilityStore.d.ts +773 -0
  905. package/dist/sync/v3/syncDurabilityStore.js +4635 -0
  906. package/dist/sync/v3/taskActivityAuthoritativeRevision.d.ts +16 -0
  907. package/dist/sync/v3/taskActivityAuthoritativeRevision.js +67 -0
  908. package/dist/sync/v3/taskActivityJournal.d.ts +20 -0
  909. package/dist/sync/v3/taskActivityJournal.js +195 -0
  910. package/dist/sync/v3/taskAttachmentLinksActivityIdentity.d.ts +6 -0
  911. package/dist/sync/v3/taskAttachmentLinksActivityIdentity.js +14 -0
  912. package/dist/sync/v3/taskAttachmentLinksMutationService.d.ts +111 -0
  913. package/dist/sync/v3/taskAttachmentLinksMutationService.js +202 -0
  914. package/dist/sync/v3/taskChecklistActivityIdentity.d.ts +6 -0
  915. package/dist/sync/v3/taskChecklistActivityIdentity.js +14 -0
  916. package/dist/sync/v3/taskChecklistMutationService.d.ts +92 -0
  917. package/dist/sync/v3/taskChecklistMutationService.js +156 -0
  918. package/dist/sync/v3/taskCommentActivityIdentity.d.ts +7 -0
  919. package/dist/sync/v3/taskCommentActivityIdentity.js +15 -0
  920. package/dist/sync/v3/taskCommentMutationService.d.ts +150 -0
  921. package/dist/sync/v3/taskCommentMutationService.js +392 -0
  922. package/dist/sync/v3/taskCommentReconcileProvenance.d.ts +58 -0
  923. package/dist/sync/v3/taskCommentReconcileProvenance.js +170 -0
  924. package/dist/sync/v3/taskCreateActivation.d.ts +19 -0
  925. package/dist/sync/v3/taskCreateActivation.js +84 -0
  926. package/dist/sync/v3/taskCreateActivityIdentity.d.ts +7 -0
  927. package/dist/sync/v3/taskCreateActivityIdentity.js +18 -0
  928. package/dist/sync/v3/taskCreateMutationService.d.ts +103 -0
  929. package/dist/sync/v3/taskCreateMutationService.js +283 -0
  930. package/dist/sync/v3/taskDeleteActivation.d.ts +7 -0
  931. package/dist/sync/v3/taskDeleteActivation.js +14 -0
  932. package/dist/sync/v3/taskDeleteMutationService.d.ts +35 -0
  933. package/dist/sync/v3/taskDeleteMutationService.js +133 -0
  934. package/dist/sync/v3/taskLegacyRootAdoptionService.d.ts +78 -0
  935. package/dist/sync/v3/taskLegacyRootAdoptionService.js +175 -0
  936. package/dist/sync/v3/taskLifecycleActivityIdentity.d.ts +9 -0
  937. package/dist/sync/v3/taskLifecycleActivityIdentity.js +18 -0
  938. package/dist/sync/v3/taskLifecycleMutationPayload.d.ts +5 -0
  939. package/dist/sync/v3/taskLifecycleMutationPayload.js +28 -0
  940. package/dist/sync/v3/taskLifecycleMutationService.d.ts +66 -0
  941. package/dist/sync/v3/taskLifecycleMutationService.js +92 -0
  942. package/dist/sync/v3/taskMetadataActivation.d.ts +12 -0
  943. package/dist/sync/v3/taskMetadataActivation.js +38 -0
  944. package/dist/sync/v3/taskMetadataActivityIdentity.d.ts +7 -0
  945. package/dist/sync/v3/taskMetadataActivityIdentity.js +18 -0
  946. package/dist/sync/v3/taskMetadataCoexistence.d.ts +37 -0
  947. package/dist/sync/v3/taskMetadataCoexistence.js +134 -0
  948. package/dist/sync/v3/taskMetadataMutationService.d.ts +71 -0
  949. package/dist/sync/v3/taskMetadataMutationService.js +199 -0
  950. package/dist/sync/v3/taskRelationshipLegacyAdoptionService.d.ts +48 -0
  951. package/dist/sync/v3/taskRelationshipLegacyAdoptionService.js +164 -0
  952. package/dist/sync/v3/taskRelationshipMutationService.d.ts +50 -0
  953. package/dist/sync/v3/taskRelationshipMutationService.js +148 -0
  954. package/dist/sync/v3/taskRestoreMutationService.d.ts +90 -0
  955. package/dist/sync/v3/taskRestoreMutationService.js +179 -0
  956. package/dist/sync/v3/taskStatusActivation.d.ts +7 -0
  957. package/dist/sync/v3/taskStatusActivation.js +15 -0
  958. package/dist/sync/v3/taskStatusMutationService.d.ts +76 -0
  959. package/dist/sync/v3/taskStatusMutationService.js +308 -0
  960. package/dist/sync/v3/taskWorkflowMutationPayload.d.ts +4 -0
  961. package/dist/sync/v3/taskWorkflowMutationPayload.js +22 -0
  962. package/dist/sync/v3/taskWorkflowMutationService.d.ts +64 -0
  963. package/dist/sync/v3/taskWorkflowMutationService.js +102 -0
  964. package/dist/sync/v3/taxonomyCoexistence.d.ts +10 -0
  965. package/dist/sync/v3/taxonomyCoexistence.js +19 -0
  966. package/dist/sync/v3/taxonomyCompositeMutationService.d.ts +110 -0
  967. package/dist/sync/v3/taxonomyCompositeMutationService.js +304 -0
  968. package/dist/sync/v3/taxonomyMutationService.d.ts +57 -0
  969. package/dist/sync/v3/taxonomyMutationService.js +106 -0
  970. package/dist/sync/v3/taxonomyStateMutation.d.ts +22 -0
  971. package/dist/sync/v3/taxonomyStateMutation.js +49 -0
  972. package/dist/sync/v3/taxonomySyncPayload.d.ts +9 -0
  973. package/dist/sync/v3/taxonomySyncPayload.js +199 -0
  974. package/dist/sync/v3/workflowAssignmentSync.d.ts +22 -0
  975. package/dist/sync/v3/workflowAssignmentSync.js +213 -0
  976. package/dist/sync/v3/workflowRuntimeMutationService.d.ts +89 -0
  977. package/dist/sync/v3/workflowRuntimeMutationService.js +359 -0
  978. package/dist/sync/v3/workflowRuntimeOperationIdentity.d.ts +13 -0
  979. package/dist/sync/v3/workflowRuntimeOperationIdentity.js +35 -0
  980. package/dist/sync/v3/workflowRuntimeSync.d.ts +141 -0
  981. package/dist/sync/v3/workflowRuntimeSync.js +485 -0
  982. package/dist/sync/v3/workspaceSyncJournalReader.d.ts +43 -0
  983. package/dist/sync/v3/workspaceSyncJournalReader.js +45 -0
  984. package/dist/sync/v3/workspaceSyncLocalOwnershipSnapshot.d.ts +28 -0
  985. package/dist/sync/v3/workspaceSyncLocalOwnershipSnapshot.js +81 -0
  986. package/dist/sync/v3/workspaceSyncPayloadFingerprint.d.ts +1 -0
  987. package/dist/sync/v3/workspaceSyncPayloadFingerprint.js +5 -0
  988. package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.d.ts +16 -0
  989. package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.js +161 -0
  990. package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.d.ts +83 -0
  991. package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.js +161 -0
  992. package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.d.ts +16 -0
  993. package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.js +90 -0
  994. package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.d.ts +65 -0
  995. package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.js +356 -0
  996. package/dist/sync/v3/workspaceSyncV3CombinedCoverage.d.ts +51 -0
  997. package/dist/sync/v3/workspaceSyncV3CombinedCoverage.js +171 -0
  998. package/dist/sync/v3/workspaceSyncV3CombinedFeedOrchestrator.d.ts +43 -0
  999. package/dist/sync/v3/workspaceSyncV3CombinedFeedOrchestrator.js +535 -0
  1000. package/dist/sync/v3/workspaceSyncV3CombinedLocalApply.d.ts +50 -0
  1001. package/dist/sync/v3/workspaceSyncV3CombinedLocalApply.js +1149 -0
  1002. package/dist/sync/v3/workspaceSyncV3CombinedProjectionState.d.ts +96 -0
  1003. package/dist/sync/v3/workspaceSyncV3CombinedProjectionState.js +672 -0
  1004. package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.d.ts +42 -0
  1005. package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.js +598 -0
  1006. package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.d.ts +65 -0
  1007. package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.js +505 -0
  1008. package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.d.ts +78 -0
  1009. package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.js +511 -0
  1010. package/dist/sync/v3/workspaceSyncV3CombinedWireContract.d.ts +45 -0
  1011. package/dist/sync/v3/workspaceSyncV3CombinedWireContract.js +125 -0
  1012. package/dist/sync/v3/workspaceSyncV3CoverageRegistry.d.ts +13 -0
  1013. package/dist/sync/v3/workspaceSyncV3CoverageRegistry.js +34 -0
  1014. package/dist/sync/v3/workspaceSyncV3CursorEncoding.d.ts +1 -0
  1015. package/dist/sync/v3/workspaceSyncV3CursorEncoding.js +6 -0
  1016. package/dist/sync/v3/workspaceSyncV3DomainAdmission.d.ts +43 -0
  1017. package/dist/sync/v3/workspaceSyncV3DomainAdmission.js +118 -0
  1018. package/dist/sync/v3/workspaceSyncV3Feed.d.ts +95 -0
  1019. package/dist/sync/v3/workspaceSyncV3Feed.js +243 -0
  1020. package/dist/sync/v3/workspaceSyncV3FeedApply.d.ts +13 -0
  1021. package/dist/sync/v3/workspaceSyncV3FeedApply.js +67 -0
  1022. package/dist/sync/v3/workspaceSyncV3FeedClientContract.d.ts +3 -0
  1023. package/dist/sync/v3/workspaceSyncV3FeedClientContract.js +46 -0
  1024. package/dist/sync/v3/workspaceSyncV3FeedCursorKeys.d.ts +10 -0
  1025. package/dist/sync/v3/workspaceSyncV3FeedCursorKeys.js +58 -0
  1026. package/dist/sync/v3/workspaceSyncV3FeedOrchestrator.d.ts +31 -0
  1027. package/dist/sync/v3/workspaceSyncV3FeedOrchestrator.js +228 -0
  1028. package/dist/sync/v3/workspaceSyncV3FeedProfile.d.ts +32 -0
  1029. package/dist/sync/v3/workspaceSyncV3FeedProfile.js +21 -0
  1030. package/dist/sync/v3/workspaceSyncV3InitiativeLocalApply.d.ts +36 -0
  1031. package/dist/sync/v3/workspaceSyncV3InitiativeLocalApply.js +163 -0
  1032. package/dist/sync/v3/workspaceSyncV3InitiativeRepair.d.ts +33 -0
  1033. package/dist/sync/v3/workspaceSyncV3InitiativeRepair.js +118 -0
  1034. package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.d.ts +10 -0
  1035. package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.js +45 -0
  1036. package/dist/sync/v3/workspaceSyncV3LocalOutboxStatus.d.ts +27 -0
  1037. package/dist/sync/v3/workspaceSyncV3LocalOutboxStatus.js +83 -0
  1038. package/dist/sync/v3/workspaceSyncV3NestedCoverage.d.ts +10 -0
  1039. package/dist/sync/v3/workspaceSyncV3NestedCoverage.js +40 -0
  1040. package/dist/sync/v3/workspaceSyncV3NestedTaskApply.d.ts +83 -0
  1041. package/dist/sync/v3/workspaceSyncV3NestedTaskApply.js +325 -0
  1042. package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.d.ts +59 -0
  1043. package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.js +302 -0
  1044. package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.d.ts +47 -0
  1045. package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.js +329 -0
  1046. package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.d.ts +19 -0
  1047. package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.js +41 -0
  1048. package/dist/sync/v3/workspaceSyncV3NestedWireContract.d.ts +6 -0
  1049. package/dist/sync/v3/workspaceSyncV3NestedWireContract.js +16 -0
  1050. package/dist/sync/v3/workspaceSyncV3OperationProjection.d.ts +8 -0
  1051. package/dist/sync/v3/workspaceSyncV3OperationProjection.js +52 -0
  1052. package/dist/sync/v3/workspaceSyncV3OperationProtocol.d.ts +229 -0
  1053. package/dist/sync/v3/workspaceSyncV3OperationProtocol.js +1 -0
  1054. package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.d.ts +165 -0
  1055. package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.js +414 -0
  1056. package/dist/sync/v3/workspaceSyncV3OriginActor.d.ts +36 -0
  1057. package/dist/sync/v3/workspaceSyncV3OriginActor.js +61 -0
  1058. package/dist/sync/v3/workspaceSyncV3OriginAssertion.d.ts +46 -0
  1059. package/dist/sync/v3/workspaceSyncV3OriginAssertion.js +121 -0
  1060. package/dist/sync/v3/workspaceSyncV3OriginAssertionHeader.d.ts +1 -0
  1061. package/dist/sync/v3/workspaceSyncV3OriginAssertionHeader.js +1 -0
  1062. package/dist/sync/v3/workspaceSyncV3PlanningOrderCoverage.d.ts +10 -0
  1063. package/dist/sync/v3/workspaceSyncV3PlanningOrderCoverage.js +34 -0
  1064. package/dist/sync/v3/workspaceSyncV3PlanningOrderWireContract.d.ts +6 -0
  1065. package/dist/sync/v3/workspaceSyncV3PlanningOrderWireContract.js +10 -0
  1066. package/dist/sync/v3/workspaceSyncV3ProjectionState.d.ts +105 -0
  1067. package/dist/sync/v3/workspaceSyncV3ProjectionState.js +467 -0
  1068. package/dist/sync/v3/workspaceSyncV3TaskCommentAudit.d.ts +56 -0
  1069. package/dist/sync/v3/workspaceSyncV3TaskCommentAudit.js +250 -0
  1070. package/dist/sync/v3/workspaceSyncV3TaskRelationshipProjection.d.ts +30 -0
  1071. package/dist/sync/v3/workspaceSyncV3TaskRelationshipProjection.js +142 -0
  1072. package/dist/sync/v3/workspaceSyncV3TaskRootProjection.d.ts +40 -0
  1073. package/dist/sync/v3/workspaceSyncV3TaskRootProjection.js +246 -0
  1074. package/dist/sync/v3/workspaceSyncV3TaxonomyFeedProjection.d.ts +39 -0
  1075. package/dist/sync/v3/workspaceSyncV3TaxonomyFeedProjection.js +185 -0
  1076. package/dist/sync/v3/workspaceSyncV3WorkflowCoverage.d.ts +10 -0
  1077. package/dist/sync/v3/workspaceSyncV3WorkflowCoverage.js +36 -0
  1078. package/dist/sync/v3/workspaceSyncV3WorkflowRuntimeApply.d.ts +17 -0
  1079. package/dist/sync/v3/workspaceSyncV3WorkflowRuntimeApply.js +143 -0
  1080. package/dist/sync/v3/workspaceSyncV3WorkflowRuntimeProjection.d.ts +9 -0
  1081. package/dist/sync/v3/workspaceSyncV3WorkflowRuntimeProjection.js +195 -0
  1082. package/dist/sync/v3/workspaceSyncV3WorkflowWireContract.d.ts +11 -0
  1083. package/dist/sync/v3/workspaceSyncV3WorkflowWireContract.js +12 -0
  1084. package/dist/sync/v3/workspaceSyncV3WorkstreamProjection.d.ts +4 -0
  1085. package/dist/sync/v3/workspaceSyncV3WorkstreamProjection.js +98 -0
  1086. package/dist/sync/v3/workspaceSyncV3WorkstreamTaskOrderProjection.d.ts +9 -0
  1087. package/dist/sync/v3/workspaceSyncV3WorkstreamTaskOrderProjection.js +72 -0
  1088. package/dist/sync/v3/workstreamActivityAuthoritativeRevision.d.ts +11 -0
  1089. package/dist/sync/v3/workstreamActivityAuthoritativeRevision.js +23 -0
  1090. package/dist/sync/v3/workstreamActivityIdentity.d.ts +8 -0
  1091. package/dist/sync/v3/workstreamActivityIdentity.js +14 -0
  1092. package/dist/sync/v3/workstreamCoexistence.d.ts +19 -0
  1093. package/dist/sync/v3/workstreamCoexistence.js +64 -0
  1094. package/dist/sync/v3/workstreamMutationPayload.d.ts +27 -0
  1095. package/dist/sync/v3/workstreamMutationPayload.js +147 -0
  1096. package/dist/sync/v3/workstreamMutationService.d.ts +72 -0
  1097. package/dist/sync/v3/workstreamMutationService.js +256 -0
  1098. package/dist/sync/v3/workstreamTaskOrderMutationService.d.ts +55 -0
  1099. package/dist/sync/v3/workstreamTaskOrderMutationService.js +110 -0
  1100. package/dist/sync/v3/workstreamTaskOrderSync.d.ts +14 -0
  1101. package/dist/sync/v3/workstreamTaskOrderSync.js +25 -0
  1102. package/dist/sync/workspaceContentManifest.d.ts +86 -0
  1103. package/dist/sync/workspaceContentManifest.js +123 -0
  1104. package/dist/sync/workspacePullFeed.d.ts +186 -2
  1105. package/dist/sync/workspacePullFeed.js +513 -136
  1106. package/dist/sync/workspacePushPreparedPlan.d.ts +21 -0
  1107. package/dist/sync/workspacePushPreparedPlan.js +1 -0
  1108. package/dist/sync/workspaceRepair.d.ts +17 -25
  1109. package/dist/sync/workspaceRepair.js +348 -25
  1110. package/dist/sync/workspaceSyncContentDecryption.d.ts +6 -0
  1111. package/dist/sync/workspaceSyncContentDecryption.js +11 -0
  1112. package/dist/sync/workspaceSyncModel.d.ts +216 -5
  1113. package/dist/sync/workspaceSyncModel.js +371 -35
  1114. package/dist/sync/workspaceSyncSnapshotProjection.d.ts +11 -0
  1115. package/dist/sync/workspaceSyncSnapshotProjection.js +101 -0
  1116. package/dist/sync/workspaceSyncState.d.ts +13 -0
  1117. package/dist/sync/workspaceSyncState.js +36 -0
  1118. package/dist/sync/workspaceSyncV2SnapshotBuilder.d.ts +106 -0
  1119. package/dist/sync/workspaceSyncV2SnapshotBuilder.js +193 -0
  1120. package/dist/types.d.ts +23 -15
  1121. package/dist/types.js +2 -4
  1122. package/dist/ui/ai-profile-clients/amazon-nova.svg +1 -0
  1123. package/dist/ui/ai-profile-clients/antigravity.png +0 -0
  1124. package/dist/ui/ai-profile-clients/chatgpt.svg +10 -0
  1125. package/dist/ui/ai-profile-clients/claude-chat.svg +1 -0
  1126. package/dist/ui/ai-profile-clients/claude-code.svg +15 -0
  1127. package/dist/ui/ai-profile-clients/cline-app-icon-light.png +0 -0
  1128. package/dist/ui/ai-profile-clients/cline.svg +16 -0
  1129. package/dist/ui/ai-profile-clients/codex.svg +1 -0
  1130. package/dist/ui/ai-profile-clients/copilot.png +0 -0
  1131. package/dist/ui/ai-profile-clients/cursor.svg +1 -0
  1132. package/dist/ui/ai-profile-clients/deepseek.svg +1 -0
  1133. package/dist/ui/ai-profile-clients/gemini-cli-icon.png +0 -0
  1134. package/dist/ui/ai-profile-clients/gemini.svg +10 -0
  1135. package/dist/ui/ai-profile-clients/grok.svg +31 -0
  1136. package/dist/ui/ai-profile-clients/kiro.svg +11 -0
  1137. package/dist/ui/ai-profile-clients/llama.svg +1 -0
  1138. package/dist/ui/ai-profile-clients/mistral.svg +1 -0
  1139. package/dist/ui/ai-profile-clients/ms_copilot.jpeg +0 -0
  1140. package/dist/ui/ai-profile-clients/openclaw.png +0 -0
  1141. package/dist/ui/ai-profile-clients/perplexity.svg +1 -0
  1142. package/dist/ui/ai-profile-clients/vscode.svg +41 -0
  1143. package/dist/ui/ai-profile-clients/windsurf.svg +11 -0
  1144. package/dist/ui/assets/AiIdentityRosterCard-DB1BLO_j.js +1 -0
  1145. package/dist/ui/assets/AiProfilesModule-DPxQeF9N.js +1 -0
  1146. package/dist/ui/assets/AnnotatedAttachmentWorkspace-CBRZ8rca.css +1 -0
  1147. package/dist/ui/assets/AnnotatedAttachmentWorkspace-DHNYaNg6.js +3 -0
  1148. package/dist/ui/assets/AssetTraySortControl-B9k5caQW.css +1 -0
  1149. package/dist/ui/assets/AssetTraySortControl-DphbyHVc.js +1 -0
  1150. package/dist/ui/assets/ContextAttachmentManager-CMxSzHqc.js +3 -0
  1151. package/dist/ui/assets/DocumentWorkspace-BC7sy5TG.js +261 -0
  1152. package/dist/ui/assets/DocumentWorkspace-BIBGBfd7.css +1 -0
  1153. package/dist/ui/assets/EntityActivityTimeline-BfJbZRdl.css +1 -0
  1154. package/dist/ui/assets/EntityActivityTimeline-pJ2ZjZ-k.js +1 -0
  1155. package/dist/ui/assets/PlanningModule-CeTqXMMz.css +1 -0
  1156. package/dist/ui/assets/PlanningModule-t5GbvVR9.js +1 -0
  1157. package/dist/ui/assets/PlansPage-BVH_NfgT.js +1 -0
  1158. package/dist/ui/assets/PlansPage-C2nkK2Bp.css +1 -0
  1159. package/dist/ui/assets/TaskContextUpload-Ds4LnDzV.css +1 -0
  1160. package/dist/ui/assets/TaskContextUpload-bl4fOOUz.js +1 -0
  1161. package/dist/ui/assets/TaskSettings-xVsxSa0g.js +12 -0
  1162. package/dist/ui/assets/TaskforceAgentsModule-CkAxW19K.js +21 -0
  1163. package/dist/ui/assets/TaskforceAgentsModule-D6IC0S7Q.css +1 -0
  1164. package/dist/ui/assets/WorkflowManagerModule-BKqIGVnF.js +1 -0
  1165. package/dist/ui/assets/WorkflowManagerModule-DF10XENz.css +1 -0
  1166. package/dist/ui/assets/antigravity-DRKQga2U.png +0 -0
  1167. package/dist/ui/assets/cursor-BM_3k4Y4.svg +1 -0
  1168. package/dist/ui/assets/gemini-cli-icon-dBAVjCcn.png +0 -0
  1169. package/dist/ui/assets/grok-BuodbWaG.svg +31 -0
  1170. package/dist/ui/assets/index-BzJlVnNS.css +1 -0
  1171. package/dist/ui/assets/index-Cx7vZJHL.js +7 -0
  1172. package/dist/ui/assets/{vendor-dnd-DRzYolkg.js → vendor-dnd-CJ-AjP-Y.js} +1 -1
  1173. package/dist/ui/assets/{vendor-icons-CLnehDTw.js → vendor-icons-B8ZNsH1g.js} +1 -1
  1174. package/dist/ui/assets/{vendor-markdown-BUxTU7dS.js → vendor-markdown-_lhNCyq-.js} +9 -9
  1175. package/dist/ui/assets/vendor-router-AqJMU8Lz.js +3 -0
  1176. package/dist/ui/assets/vscode-C_7wk1WI.svg +41 -0
  1177. package/dist/ui/branding/logos/logo_dark_bg.png +0 -0
  1178. package/dist/ui/branding/logos/logo_favicon_dark.png +0 -0
  1179. package/dist/ui/branding/logos/logo_favicon_dark.svg +56 -0
  1180. package/dist/ui/branding/logos/logo_favicon_light.png +0 -0
  1181. package/dist/ui/branding/logos/logo_light_bg.png +0 -0
  1182. package/dist/ui/images/Taskforce_Van.webp +0 -0
  1183. package/dist/ui/index.html +6 -6
  1184. package/dist/update/uiUpdateService.d.ts +43 -0
  1185. package/dist/update/uiUpdateService.js +149 -0
  1186. package/dist/update/updateCli.d.ts +15 -0
  1187. package/dist/update/updateCli.js +76 -0
  1188. package/dist/update/updateExecutor.d.ts +40 -0
  1189. package/dist/update/updateExecutor.js +474 -0
  1190. package/dist/update/updateStatus.d.ts +83 -0
  1191. package/dist/update/updateStatus.js +703 -0
  1192. package/dist/utils/aiProfileAvatarPaths.d.ts +14 -0
  1193. package/dist/utils/aiProfileAvatarPaths.js +52 -0
  1194. package/dist/utils/aiProfileDefaultLogo.d.ts +7 -0
  1195. package/dist/utils/aiProfileDefaultLogo.js +84 -0
  1196. package/dist/utils/aiProfileEvents.d.ts +9 -1
  1197. package/dist/utils/annotatedAttachments.d.ts +8 -0
  1198. package/dist/utils/annotatedAttachments.js +17 -1
  1199. package/dist/utils/assetTraySorting.d.ts +25 -0
  1200. package/dist/utils/assetTraySorting.js +83 -0
  1201. package/dist/utils/assignees.d.ts +5 -0
  1202. package/dist/utils/assignees.js +14 -9
  1203. package/dist/utils/authLogin.d.ts +10 -0
  1204. package/dist/utils/authLogin.js +8 -0
  1205. package/dist/utils/authSessionEvents.d.ts +2 -0
  1206. package/dist/utils/authSessionEvents.js +6 -0
  1207. package/dist/utils/avatarUpload.js +5 -5
  1208. package/dist/utils/canonicalReferenceAttachments.d.ts +12 -0
  1209. package/dist/utils/canonicalReferenceAttachments.js +42 -0
  1210. package/dist/utils/cloudAssetDisplay.d.ts +2 -0
  1211. package/dist/utils/cloudAssetDisplay.js +8 -0
  1212. package/dist/utils/constants.d.ts +4 -11
  1213. package/dist/utils/constants.js +5 -64
  1214. package/dist/utils/contextAttachmentPreview.d.ts +11 -0
  1215. package/dist/utils/contextAttachmentPreview.js +8 -0
  1216. package/dist/utils/contextAttachmentUpload.d.ts +8 -0
  1217. package/dist/utils/contextAttachmentUpload.js +144 -0
  1218. package/dist/utils/documentNames.js +6 -4
  1219. package/dist/utils/entityReferences.d.ts +14 -0
  1220. package/dist/utils/entityReferences.js +21 -0
  1221. package/dist/utils/httpSetCookie.d.ts +3 -0
  1222. package/dist/utils/httpSetCookie.js +22 -0
  1223. package/dist/utils/imageNoteStoragePaths.d.ts +3 -0
  1224. package/dist/utils/imageNoteStoragePaths.js +19 -0
  1225. package/dist/utils/imageReferences.d.ts +6 -0
  1226. package/dist/utils/imageReferences.js +1 -0
  1227. package/dist/utils/planningArchiveOrchestrator.d.ts +23 -0
  1228. package/dist/utils/planningArchiveOrchestrator.js +37 -0
  1229. package/dist/utils/planningArchivePresentation.d.ts +20 -0
  1230. package/dist/utils/planningArchivePresentation.js +23 -0
  1231. package/dist/utils/planningArchiveReadiness.d.ts +26 -0
  1232. package/dist/utils/planningArchiveReadiness.js +30 -0
  1233. package/dist/utils/planningFavorites.d.ts +7 -0
  1234. package/dist/utils/planningFavorites.js +34 -0
  1235. package/dist/utils/syncEventPresentation.js +53 -0
  1236. package/dist/utils/syncStatusPresentation.d.ts +25 -0
  1237. package/dist/utils/syncStatusPresentation.js +86 -5
  1238. package/dist/utils/taskActivity.d.ts +9 -2
  1239. package/dist/utils/taskActivity.js +61 -0
  1240. package/dist/utils/taskDraftDefaults.d.ts +0 -8
  1241. package/dist/utils/taskDraftDefaults.js +0 -4
  1242. package/dist/utils/taskEvents.d.ts +11 -0
  1243. package/dist/utils/taskEvents.js +6 -0
  1244. package/dist/utils/taskHeaderQuickFilter.d.ts +14 -0
  1245. package/dist/utils/taskHeaderQuickFilter.js +32 -0
  1246. package/dist/utils/taskInvalidation.d.ts +23 -0
  1247. package/dist/utils/taskInvalidation.js +67 -0
  1248. package/dist/utils/taskNormalization.d.ts +2 -1
  1249. package/dist/utils/taskNormalization.js +44 -18
  1250. package/dist/utils/taskReferences.d.ts +16 -0
  1251. package/dist/utils/taskReferences.js +63 -0
  1252. package/dist/utils/taskforceAgentEvents.d.ts +8 -0
  1253. package/dist/utils/taskforceAgentEvents.js +6 -0
  1254. package/dist/utils/taskforceAgentSkillEvents.d.ts +7 -0
  1255. package/dist/utils/taskforceAgentSkillEvents.js +8 -0
  1256. package/dist/utils/theme.js +1 -1
  1257. package/dist/utils/uiNotice.d.ts +3 -0
  1258. package/dist/utils/uiNotice.js +1 -1
  1259. package/dist/utils/workspaceResourceEvents.d.ts +7 -0
  1260. package/dist/utils/workspaceResourceEvents.js +6 -0
  1261. package/dist/utils/workspaceSyncPresentation.d.ts +24 -0
  1262. package/dist/utils/workspaceSyncPresentation.js +243 -6
  1263. package/package.json +69 -21
  1264. package/dist/components/features/AgentsModule.d.ts +0 -18
  1265. package/dist/components/features/AgentsModule.js +0 -479
  1266. package/dist/components/features/InitiativesModule.d.ts +0 -22
  1267. package/dist/components/features/InitiativesModule.js +0 -33
  1268. package/dist/components/features/WorkflowsModule.d.ts +0 -27
  1269. package/dist/components/features/WorkflowsModule.js +0 -21
  1270. package/dist/components/features/settings/WorkflowEditor.d.ts +0 -15
  1271. package/dist/components/features/settings/WorkflowEditor.js +0 -245
  1272. package/dist/components/views/panels/DocumentFilterToolbar.d.ts +0 -10
  1273. package/dist/components/views/panels/DocumentFilterToolbar.js +0 -7
  1274. package/dist/components/views/standalone/modals/AccountHubModal.d.ts +0 -61
  1275. package/dist/components/views/standalone/modals/AccountHubModal.js +0 -108
  1276. package/dist/components/views/standalone/modals/EditProfileModal.d.ts +0 -19
  1277. package/dist/components/views/standalone/modals/EditProfileModal.js +0 -11
  1278. package/dist/hooks/ui/useResourceExport.d.ts +0 -21
  1279. package/dist/hooks/ui/useResourceExport.js +0 -87
  1280. package/dist/hooks/ui/useWorkflowTemplates.d.ts +0 -37
  1281. package/dist/hooks/ui/useWorkflowTemplates.js +0 -116
  1282. package/dist/mcp/clientProfileDefaults.d.ts +0 -12
  1283. package/dist/mcp/clientProfileDefaults.js +0 -37
  1284. package/dist/resources/templates/WORKFLOW_V2_POLICY.md +0 -55
  1285. package/dist/resources/templates/environments/aider.yaml +0 -14
  1286. package/dist/resources/templates/environments/antigravity.yaml +0 -10
  1287. package/dist/resources/templates/environments/claude.yaml +0 -10
  1288. package/dist/resources/templates/environments/cline.yaml +0 -10
  1289. package/dist/resources/templates/environments/codex.yaml +0 -13
  1290. package/dist/resources/templates/environments/copilot.yaml +0 -10
  1291. package/dist/resources/templates/environments/cursor.yaml +0 -9
  1292. package/dist/resources/templates/environments/gemini.yaml +0 -9
  1293. package/dist/resources/templates/environments/windsurf.yaml +0 -10
  1294. package/dist/resources/templates/workflow-sources/README.md +0 -9
  1295. package/dist/resources/templates/workflow-sources/workflowDocs.mjs +0 -530
  1296. package/dist/resources/templates/workflow-sources/workflowEditorOverrides.json +0 -1
  1297. package/dist/resources/templates/workflows/collaborate.yaml +0 -110
  1298. package/dist/resources/templates/workflows/do.yaml +0 -88
  1299. package/dist/resources/templates/workflows/evaluate.yaml +0 -117
  1300. package/dist/resources/templates/workflows/execute.yaml +0 -159
  1301. package/dist/resources/templates/workflows/plan.yaml +0 -119
  1302. package/dist/resources/templates/workflows/review.yaml +0 -115
  1303. package/dist/services/formatTransformers.d.ts +0 -29
  1304. package/dist/services/formatTransformers.js +0 -56
  1305. package/dist/services/templateEngine.d.ts +0 -46
  1306. package/dist/services/templateEngine.js +0 -148
  1307. package/dist/shared/workflowDefaults.d.ts +0 -9
  1308. package/dist/shared/workflowDefaults.js +0 -11
  1309. package/dist/ui/agent-logos/Gemini CLI.jpeg +0 -0
  1310. package/dist/ui/agent-logos/antigravity.jpeg +0 -0
  1311. package/dist/ui/agent-logos/chatgpt.png +0 -0
  1312. package/dist/ui/agent-logos/claude-code.jpeg +0 -0
  1313. package/dist/ui/agent-logos/codex.jpeg +0 -0
  1314. package/dist/ui/agent-logos/cursor.png +0 -0
  1315. package/dist/ui/agent-logos/openclaw.jpeg +0 -0
  1316. package/dist/ui/agent-logos/windsurf.png +0 -0
  1317. package/dist/ui/assets/AgentsModule-DvkbUHi0.js +0 -1
  1318. package/dist/ui/assets/AnnotatedAttachmentWorkspace-BVKew-mH.css +0 -1
  1319. package/dist/ui/assets/AnnotatedAttachmentWorkspace-jhOhxqHT.js +0 -3
  1320. package/dist/ui/assets/ContextAttachmentManager-BAmEyLHL.js +0 -3
  1321. package/dist/ui/assets/DocumentWorkspace-D4rJKXzd.css +0 -1
  1322. package/dist/ui/assets/DocumentWorkspace-X-CpD5OO.js +0 -252
  1323. package/dist/ui/assets/EntityActivityTimeline-DD33onAC.js +0 -1
  1324. package/dist/ui/assets/EntityActivityTimeline-DyqvvhuF.css +0 -1
  1325. package/dist/ui/assets/InitiativesModule-5nDXtIjf.js +0 -1
  1326. package/dist/ui/assets/PlansPage-B8nDR1hQ.js +0 -1
  1327. package/dist/ui/assets/PlansPage-DeAzWYTb.css +0 -1
  1328. package/dist/ui/assets/TaskContextUpload-DrGrXJHm.js +0 -1
  1329. package/dist/ui/assets/TaskSettings-BXVvZZwH.js +0 -9
  1330. package/dist/ui/assets/WorkflowsModule-DWCGhEWT.js +0 -5
  1331. package/dist/ui/assets/documentReferences-Crup321p.js +0 -1
  1332. package/dist/ui/assets/index-B9k24Aym.js +0 -5
  1333. package/dist/ui/assets/index-DNeR5dYW.css +0 -1
  1334. package/dist/ui/assets/vendor-router-BbWMxlnO.js +0 -3
  1335. package/dist/ui/branding/logos/logo_black_01.png +0 -0
  1336. package/dist/ui/branding/logos/logo_black_02.png +0 -0
  1337. package/dist/ui/branding/logos/logo_white_01.png +0 -0
  1338. package/dist/ui/branding/logos/logo_white_02.png +0 -0
  1339. package/scripts/generate-workflow-templates.mjs +0 -134
  1340. package/src/resources/templates/WORKFLOW_V2_POLICY.md +0 -55
  1341. package/src/resources/templates/environments/aider.yaml +0 -14
  1342. package/src/resources/templates/environments/antigravity.yaml +0 -10
  1343. package/src/resources/templates/environments/claude.yaml +0 -10
  1344. package/src/resources/templates/environments/cline.yaml +0 -10
  1345. package/src/resources/templates/environments/codex.yaml +0 -13
  1346. package/src/resources/templates/environments/copilot.yaml +0 -10
  1347. package/src/resources/templates/environments/cursor.yaml +0 -9
  1348. package/src/resources/templates/environments/gemini.yaml +0 -9
  1349. package/src/resources/templates/environments/windsurf.yaml +0 -10
  1350. package/src/resources/templates/workflow-sources/README.md +0 -9
  1351. package/src/resources/templates/workflow-sources/workflowDocs.mjs +0 -530
  1352. package/src/resources/templates/workflow-sources/workflowEditorOverrides.json +0 -1
  1353. package/src/resources/templates/workflows/collaborate.yaml +0 -110
  1354. package/src/resources/templates/workflows/do.yaml +0 -88
  1355. package/src/resources/templates/workflows/evaluate.yaml +0 -117
  1356. package/src/resources/templates/workflows/execute.yaml +0 -159
  1357. package/src/resources/templates/workflows/plan.yaml +0 -119
  1358. package/src/resources/templates/workflows/review.yaml +0 -115
  1359. /package/dist/ui/branding/logos/{logo_dark.svg → logo_dark_no_bg.svg} +0 -0
  1360. /package/dist/ui/branding/logos/{logo_favicon.svg → logo_favicon_light.svg} +0 -0
  1361. /package/dist/ui/branding/logos/{logo_light.svg → logo_light_no_bg.svg} +0 -0
@@ -1,72 +1,389 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { createHash, randomUUID } from 'crypto';
4
- function decodeTaskforceContextPath(value, normalizePath) {
5
- const normalized = String(value || '').trim();
6
- if (!normalized.startsWith('/api/taskforce/context/'))
4
+ import { listReferencedAiProfileAvatarAssetPaths } from './aiProfileAvatarSyncPaths.js';
5
+ import { normalizeCanonicalAssetKind } from '../utils/canonicalAssetKind.js';
6
+ import { WorkspaceSyncContentVersionStore } from './engine/workspaceSyncContentVersionStore.js';
7
+ import { WorkspaceSyncPublishedContentResolver, verifyWorkspaceSyncPublishedContentBody, } from './engine/workspaceSyncPublishedContentResolver.js';
8
+ import { compareWorkspaceMutationOrdering } from './workspaceSyncSurface.js';
9
+ import { publishWorkspaceSyncLocalFileAtomically, WorkspaceSyncAtomicLocalPublicationError, } from './engine/workspaceSyncAtomicLocalPublisher.js';
10
+ const referencedAvatarFingerprintCache = new Map();
11
+ const publishedContentResolverCache = new WeakMap();
12
+ const localFileFingerprintCache = new Map();
13
+ function fingerprintLocalFile(absolutePath) {
14
+ if (!fs.existsSync(absolutePath))
7
15
  return null;
8
- const encoded = normalized.slice('/api/taskforce/context/'.length).split(/[?#]/, 1)[0] || '';
9
- if (!encoded)
16
+ const stat = fs.statSync(absolutePath);
17
+ if (!stat.isFile())
10
18
  return null;
11
- try {
12
- return normalizePath(decodeURIComponent(encoded));
19
+ const cached = localFileFingerprintCache.get(absolutePath);
20
+ if (cached && cached.sizeBytes === stat.size && cached.mtimeMs === stat.mtimeMs && cached.ctimeMs === stat.ctimeMs) {
21
+ return { contentSha256: cached.contentSha256, sizeBytes: cached.sizeBytes };
13
22
  }
14
- catch {
23
+ const content = fs.readFileSync(absolutePath);
24
+ const fingerprint = {
25
+ contentSha256: createHash('sha256').update(content).digest('hex'),
26
+ sizeBytes: content.length,
27
+ mtimeMs: stat.mtimeMs,
28
+ ctimeMs: stat.ctimeMs,
29
+ };
30
+ localFileFingerprintCache.set(absolutePath, fingerprint);
31
+ return { contentSha256: fingerprint.contentSha256, sizeBytes: fingerprint.sizeBytes };
32
+ }
33
+ function getPublishedContentResolver(deps) {
34
+ if (deps.publishedContentResolver)
35
+ return deps.publishedContentResolver;
36
+ const core = deps.core;
37
+ const cacheKey = core;
38
+ const cached = publishedContentResolverCache.get(cacheKey);
39
+ if (cached)
40
+ return cached;
41
+ const resolver = new WorkspaceSyncPublishedContentResolver(new WorkspaceSyncContentVersionStore(core.getDatabaseAdapter()));
42
+ publishedContentResolverCache.set(cacheKey, resolver);
43
+ return resolver;
44
+ }
45
+ function resolvePublishedContent(deps, input) {
46
+ return getPublishedContentResolver(deps).resolve({
47
+ tenantId: deps.core.getTenantId(),
48
+ ...input,
49
+ });
50
+ }
51
+ function publishedContentIdentity(content) {
52
+ return content.source === 'versioned'
53
+ ? `version:${content.versionId}`
54
+ : `legacy:${content.storageProvider}:${content.physicalKey}`;
55
+ }
56
+ async function readPublishedContentBuffer(deps, basePath, content, label) {
57
+ let buffer = null;
58
+ let stat = null;
59
+ if (content.storageProvider === 'r2') {
60
+ const objectStorageClient = deps.getObjectStorageClient();
61
+ if (!objectStorageClient)
62
+ return null;
63
+ buffer = (await objectStorageClient.getObject(content.physicalKey))?.body || null;
64
+ }
65
+ else {
66
+ const root = path.resolve(basePath);
67
+ const absolutePath = path.resolve(root, content.physicalKey);
68
+ if (absolutePath === root || !absolutePath.startsWith(`${root}${path.sep}`))
69
+ return null;
70
+ if (!fs.existsSync(absolutePath))
71
+ return null;
72
+ stat = fs.statSync(absolutePath);
73
+ if (!stat.isFile())
74
+ return null;
75
+ buffer = fs.readFileSync(absolutePath);
76
+ }
77
+ if (!buffer)
15
78
  return null;
79
+ if (content.source === 'versioned') {
80
+ verifyWorkspaceSyncPublishedContentBody(buffer, content, label);
16
81
  }
82
+ return { buffer, stat };
17
83
  }
18
- function isAiProfileAvatarAssetPath(value, workspaceId) {
19
- const normalized = String(value || '').replace(/\\/g, '/');
20
- return normalized.startsWith(`workspaces/${workspaceId}/assets/images/ai-profiles/`)
21
- && normalized.includes('/avatar/');
84
+ async function readReferencedAvatarBuffer(deps, basePath, content, label) {
85
+ const primary = await readPublishedContentBuffer(deps, basePath, content, label);
86
+ if (primary?.buffer)
87
+ return primary.buffer;
88
+ if (content.source !== 'legacy' || content.storageProvider !== 'r2')
89
+ return null;
90
+ return (await readPublishedContentBuffer(deps, basePath, {
91
+ ...content,
92
+ storageProvider: 'local',
93
+ }, label))?.buffer || null;
22
94
  }
23
- function inferBinaryAssetMimeType(assetPath) {
24
- const ext = path.extname(assetPath).toLowerCase();
25
- if (ext === '.png')
26
- return 'image/png';
27
- if (ext === '.jpg' || ext === '.jpeg')
28
- return 'image/jpeg';
29
- if (ext === '.webp')
30
- return 'image/webp';
31
- if (ext === '.gif')
32
- return 'image/gif';
33
- return 'application/octet-stream';
95
+ function publishedContentAvailable(basePath, content) {
96
+ if (content.storageProvider === 'r2') {
97
+ return {
98
+ contentSha256: content.source === 'versioned' ? content.contentSha256 : '',
99
+ sizeBytes: content.source === 'versioned' ? content.sizeBytes : 0,
100
+ contentAvailable: content.source === 'versioned',
101
+ };
102
+ }
103
+ const root = path.resolve(basePath);
104
+ const absolutePath = path.resolve(root, content.physicalKey);
105
+ if (absolutePath === root || !absolutePath.startsWith(`${root}${path.sep}`)) {
106
+ return { contentSha256: '', sizeBytes: 0, contentAvailable: false };
107
+ }
108
+ if (content.source === 'versioned') {
109
+ if (!fs.existsSync(absolutePath)) {
110
+ return { contentSha256: '', sizeBytes: 0, contentAvailable: false };
111
+ }
112
+ const stat = fs.statSync(absolutePath);
113
+ return stat.isFile() && stat.size === content.sizeBytes
114
+ ? {
115
+ contentSha256: content.contentSha256,
116
+ sizeBytes: content.sizeBytes,
117
+ contentAvailable: true,
118
+ }
119
+ : { contentSha256: '', sizeBytes: 0, contentAvailable: false };
120
+ }
121
+ const fingerprint = fingerprintLocalFile(absolutePath);
122
+ if (!fingerprint)
123
+ return { contentSha256: '', sizeBytes: 0, contentAvailable: false };
124
+ return {
125
+ contentSha256: fingerprint.contentSha256,
126
+ sizeBytes: fingerprint.sizeBytes,
127
+ contentAvailable: true,
128
+ };
34
129
  }
35
- function inferAssetIdFromPath(assetPath) {
36
- const match = String(assetPath || '').match(/(^|\/)(asset-[a-f0-9]{32})(?=[^/]*$)/i);
37
- return match?.[2];
130
+ function compareWorkspaceSyncContentCursor(left, right) {
131
+ if (left.u !== right.u)
132
+ return left.u < right.u ? -1 : 1;
133
+ return Buffer.compare(Buffer.from(left.id, 'utf8'), Buffer.from(right.id, 'utf8'));
38
134
  }
39
- function listReferencedAiProfileAvatarAssetPaths(deps, workspaceId) {
40
- const profiles = typeof deps.core.listAiProfiles === 'function'
41
- ? deps.core.listAiProfiles(workspaceId, { includeArchived: true })
42
- : [];
43
- const referenced = new Map();
44
- for (const profile of Array.isArray(profiles) ? profiles : []) {
45
- const updatedAt = String(profile?.updatedAt || profile?.createdAt || '').trim();
46
- for (const url of [profile?.avatarUrl, profile?.avatarSourceUrl]) {
47
- const assetPath = decodeTaskforceContextPath(url, deps.normalizeTaskDataRelativePath);
48
- if (!assetPath || !isAiProfileAvatarAssetPath(assetPath, workspaceId))
49
- continue;
50
- if (referenced.has(assetPath))
135
+ export function readWorkspaceSyncContentFrontier(deps, workspaceId = 'default') {
136
+ if (!deps.workspaceAssetStore) {
137
+ const avatars = listReferencedAiProfileAvatarAssets(deps, workspaceId);
138
+ let avatarFrontier = null;
139
+ for (const [assetPath, metadata] of avatars) {
140
+ const candidate = { u: metadata.updatedAt, id: `asset:${assetPath}` };
141
+ if (Number.isFinite(Date.parse(candidate.u))
142
+ && (!avatarFrontier || compareWorkspaceSyncContentCursor(candidate, avatarFrontier) > 0))
143
+ avatarFrontier = candidate;
144
+ }
145
+ return avatarFrontier;
146
+ }
147
+ const assets = deps.workspaceAssetStore.listAllNormalizedByWorkspace(workspaceId, {
148
+ includeDeleted: true,
149
+ });
150
+ const linksByAssetId = groupWorkspaceAssetLinksByAssetId(deps.workspaceAssetStore, workspaceId);
151
+ const referencedAvatarAssets = listReferencedAiProfileAvatarAssets(deps, workspaceId);
152
+ const activeBinaryAssetPaths = new Set();
153
+ let frontier = null;
154
+ const include = (candidate) => {
155
+ if (Number.isFinite(Date.parse(candidate.u))
156
+ && candidate.id.length > 0
157
+ && (!frontier || compareWorkspaceSyncContentCursor(candidate, frontier) > 0))
158
+ frontier = candidate;
159
+ };
160
+ for (const asset of assets) {
161
+ const rawPath = String(asset.storageKey || '').trim();
162
+ const isDocument = asset.kind === 'document';
163
+ const normalizedPath = isDocument
164
+ ? deps.normalizeWorkspaceSyncDocumentPath(rawPath)
165
+ : deps.normalizeTaskDataRelativePath(rawPath);
166
+ if (!normalizedPath)
167
+ continue;
168
+ const isReplicatedBinaryAsset = (asset.kind === 'image' || asset.kind === 'file')
169
+ && asset.storageProvider !== 'external';
170
+ if (!isDocument && !isReplicatedBinaryAsset)
171
+ continue;
172
+ if (asset.deletedAt) {
173
+ if (!isDocument && referencedAvatarAssets.has(normalizedPath))
51
174
  continue;
52
- referenced.set(assetPath, {
53
- updatedAt,
54
- assetId: inferAssetIdFromPath(assetPath),
55
- originalFilename: path.basename(assetPath),
56
- mimeType: inferBinaryAssetMimeType(assetPath)
175
+ include({
176
+ u: String(asset.deletedAt).trim(),
177
+ id: `${isDocument ? 'doc-delete' : 'asset-delete'}:${normalizedPath}:${String(asset.assetId || '').trim()}`,
57
178
  });
179
+ continue;
58
180
  }
181
+ const { effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkStateFromLinks(asset, linksByAssetId.get(asset.assetId) || []);
182
+ include({
183
+ u: effectiveUpdatedAt,
184
+ id: `${isDocument ? 'doc' : 'asset'}:${isDocument ? normalizedPath : rawPath}`,
185
+ });
186
+ if (!isDocument)
187
+ activeBinaryAssetPaths.add(rawPath);
59
188
  }
60
- return referenced;
189
+ for (const [assetPath, metadata] of referencedAvatarAssets) {
190
+ if (activeBinaryAssetPaths.has(assetPath))
191
+ continue;
192
+ include({ u: metadata.updatedAt, id: `asset:${assetPath}` });
193
+ }
194
+ return frontier;
195
+ }
196
+ export function hasWorkspaceSyncContentAfter(deps, workspaceId, cursor) {
197
+ if (!cursor)
198
+ return true;
199
+ const db = deps.core.getDatabaseAdapter();
200
+ const tenantId = deps.core.getTenantId();
201
+ const threshold = cursor.u;
202
+ const rows = db.prepare(`
203
+ SELECT
204
+ asset.asset_id,
205
+ asset.kind,
206
+ asset.storage_provider,
207
+ asset.storage_key,
208
+ asset.original_filename,
209
+ asset.mime_type,
210
+ asset.deleted_at,
211
+ CASE
212
+ WHEN asset.deleted_at IS NOT NULL THEN asset.deleted_at
213
+ WHEN COALESCE((
214
+ SELECT MAX(CASE
215
+ WHEN link.updated_at > link.created_at THEN link.updated_at
216
+ ELSE link.created_at
217
+ END)
218
+ FROM workspace_asset_links link
219
+ WHERE link.tenant_id = asset.tenant_id
220
+ AND link.workspace_id = asset.workspace_id
221
+ AND link.asset_id = asset.asset_id
222
+ ), '') > COALESCE(asset.updated_at, asset.created_at, '')
223
+ THEN (
224
+ SELECT MAX(CASE
225
+ WHEN link.updated_at > link.created_at THEN link.updated_at
226
+ ELSE link.created_at
227
+ END)
228
+ FROM workspace_asset_links link
229
+ WHERE link.tenant_id = asset.tenant_id
230
+ AND link.workspace_id = asset.workspace_id
231
+ AND link.asset_id = asset.asset_id
232
+ )
233
+ ELSE COALESCE(asset.updated_at, asset.created_at, '')
234
+ END AS effective_updated_at
235
+ FROM workspace_assets asset
236
+ WHERE asset.tenant_id = ?
237
+ AND asset.workspace_id = ?
238
+ AND (
239
+ asset.kind = 'document'
240
+ OR (
241
+ asset.kind IN ('image', 'file')
242
+ AND asset.storage_provider <> 'external'
243
+ )
244
+ )
245
+ AND (
246
+ COALESCE(asset.deleted_at, asset.updated_at, asset.created_at, '') >= ?
247
+ OR EXISTS (
248
+ SELECT 1
249
+ FROM workspace_asset_links changed_link
250
+ WHERE changed_link.tenant_id = asset.tenant_id
251
+ AND changed_link.workspace_id = asset.workspace_id
252
+ AND changed_link.asset_id = asset.asset_id
253
+ AND (
254
+ changed_link.updated_at >= ?
255
+ OR changed_link.created_at >= ?
256
+ )
257
+ )
258
+ )
259
+ `).all(tenantId, workspaceId, threshold, threshold, threshold);
260
+ const referencedAvatarAssets = listReferencedAiProfileAvatarAssets(deps, workspaceId);
261
+ const isAfter = (candidate) => (Number.isFinite(Date.parse(candidate.u))
262
+ && compareWorkspaceSyncContentCursor(candidate, cursor) > 0);
263
+ for (const row of rows) {
264
+ const kind = normalizeCanonicalAssetKind({
265
+ kind: String(row.kind || 'file'),
266
+ storageKey: String(row.storage_key || ''),
267
+ originalFilename: String(row.original_filename || ''),
268
+ mimeType: String(row.mime_type || ''),
269
+ });
270
+ const isDocument = kind === 'document';
271
+ const normalizedPath = isDocument
272
+ ? deps.normalizeWorkspaceSyncDocumentPath(row.storage_key)
273
+ : deps.normalizeTaskDataRelativePath(String(row.storage_key || ''));
274
+ if (!normalizedPath)
275
+ continue;
276
+ const rawPath = String(row.storage_key || '').trim();
277
+ const deletedAt = String(row.deleted_at || '').trim();
278
+ if (deletedAt && !isDocument && referencedAvatarAssets.has(normalizedPath))
279
+ continue;
280
+ if (isAfter({
281
+ u: deletedAt || String(row.effective_updated_at || '').trim(),
282
+ id: deletedAt
283
+ ? `${isDocument ? 'doc-delete' : 'asset-delete'}:${normalizedPath}:${String(row.asset_id || '').trim()}`
284
+ : `${isDocument ? 'doc' : 'asset'}:${isDocument ? normalizedPath : rawPath}`,
285
+ }))
286
+ return true;
287
+ }
288
+ const headRows = db.prepare(`
289
+ SELECT
290
+ head.kind,
291
+ head.logical_path,
292
+ head.source_updated_at,
293
+ asset.kind AS asset_kind,
294
+ asset.storage_provider,
295
+ asset.original_filename,
296
+ asset.mime_type
297
+ FROM workspace_sync_content_heads head
298
+ INNER JOIN workspace_assets asset
299
+ ON asset.tenant_id = head.tenant_id
300
+ AND asset.workspace_id = head.workspace_id
301
+ AND asset.storage_key = head.logical_path
302
+ WHERE head.tenant_id = ?
303
+ AND head.workspace_id = ?
304
+ AND head.deleted_at IS NULL
305
+ AND asset.deleted_at IS NULL
306
+ AND head.source_updated_at >= ?
307
+ `).all(tenantId, workspaceId, threshold);
308
+ for (const row of headRows) {
309
+ const normalizedKind = normalizeCanonicalAssetKind({
310
+ kind: String(row.asset_kind || 'file'),
311
+ storageKey: String(row.logical_path || ''),
312
+ originalFilename: String(row.original_filename || ''),
313
+ mimeType: String(row.mime_type || ''),
314
+ });
315
+ const isDocument = normalizedKind === 'document';
316
+ if (String(row.kind || '') !== (isDocument ? 'document' : 'asset')
317
+ || (!isDocument && String(row.storage_provider || '') === 'external'))
318
+ continue;
319
+ const normalizedPath = isDocument
320
+ ? deps.normalizeWorkspaceSyncDocumentPath(row.logical_path)
321
+ : deps.normalizeTaskDataRelativePath(String(row.logical_path || ''));
322
+ if (normalizedPath && isAfter({
323
+ u: String(row.source_updated_at || '').trim(),
324
+ id: `${isDocument ? 'doc' : 'asset'}:${isDocument ? normalizedPath : String(row.logical_path || '').trim()}`,
325
+ }))
326
+ return true;
327
+ }
328
+ for (const [assetPath, metadata] of referencedAvatarAssets) {
329
+ const canonicalAsset = deps.workspaceAssetStore?.getByStorageKey(assetPath, workspaceId);
330
+ if (canonicalAsset
331
+ && !canonicalAsset.deletedAt
332
+ && (canonicalAsset.kind === 'image' || canonicalAsset.kind === 'file')
333
+ && canonicalAsset.storageProvider !== 'external')
334
+ continue;
335
+ if (isAfter({ u: metadata.updatedAt, id: `asset:${assetPath}` }))
336
+ return true;
337
+ }
338
+ return false;
339
+ }
340
+ function runWorkspaceSyncContentMetadataMutation(deps, input, apply) {
341
+ return deps.core.getDatabaseAdapter().transaction(() => {
342
+ new WorkspaceSyncContentVersionStore(deps.core.getDatabaseAdapter()).lockLogicalHead({
343
+ tenantId: deps.core.getTenantId(),
344
+ workspaceId: input.workspaceId,
345
+ kind: input.kind,
346
+ logicalPath: input.logicalPath,
347
+ }, input.updatedAt);
348
+ return apply();
349
+ })();
350
+ }
351
+ function newestDocumentMetadata(watermark, asset) {
352
+ if (!watermark) {
353
+ return asset
354
+ ? { updatedAt: asset.updatedAt, contentHash: asset.contentSha256 }
355
+ : null;
356
+ }
357
+ if (!asset)
358
+ return watermark;
359
+ return compareWorkspaceMutationOrdering(asset.updatedAt, watermark.updatedAt, asset.contentSha256, watermark.contentHash) >= 0
360
+ ? { updatedAt: asset.updatedAt, contentHash: asset.contentSha256 }
361
+ : watermark;
362
+ }
363
+ function hasPublishedWorkspaceSyncContentHead(deps, input) {
364
+ return Boolean(new WorkspaceSyncContentVersionStore(deps.core.getDatabaseAdapter()).getHead({
365
+ tenantId: deps.core.getTenantId(),
366
+ ...input,
367
+ }));
368
+ }
369
+ function listReferencedAiProfileAvatarAssets(deps, workspaceId) {
370
+ const profiles = typeof deps.core.listAiProfiles === 'function'
371
+ ? deps.core.listAiProfiles(workspaceId, { includeArchived: true })
372
+ : [];
373
+ return listReferencedAiProfileAvatarAssetPaths(profiles, workspaceId, deps.normalizeTaskDataRelativePath);
61
374
  }
62
375
  export function resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId) {
63
376
  if (!deps.workspaceAssetStore) {
64
377
  return {
65
378
  primaryLink: null,
379
+ activeLinks: [],
66
380
  effectiveUpdatedAt: String(asset.updatedAt || asset.createdAt || '').trim() || new Date().toISOString()
67
381
  };
68
382
  }
69
383
  const links = deps.workspaceAssetStore.listLinksForAsset(asset.assetId, workspaceId, { includeDeleted: true });
384
+ return resolveCanonicalAssetSyncLinkStateFromLinks(asset, links);
385
+ }
386
+ function resolveCanonicalAssetSyncLinkStateFromLinks(asset, links) {
70
387
  const activeLinks = links.filter((entry) => !entry.deletedAt);
71
388
  const primaryLink = activeLinks[0] || null;
72
389
  let effectiveUpdatedAt = String(asset.updatedAt || asset.createdAt || '').trim() || new Date().toISOString();
@@ -75,7 +392,25 @@ export function resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId) {
75
392
  if (linkUpdatedAt && linkUpdatedAt > effectiveUpdatedAt)
76
393
  effectiveUpdatedAt = linkUpdatedAt;
77
394
  }
78
- return { primaryLink, effectiveUpdatedAt };
395
+ return { primaryLink, activeLinks, effectiveUpdatedAt };
396
+ }
397
+ function groupWorkspaceAssetLinksByAssetId(store, workspaceId) {
398
+ const grouped = new Map();
399
+ for (const link of store.listLinksForWorkspace(workspaceId, { includeDeleted: true })) {
400
+ const current = grouped.get(link.assetId) || [];
401
+ current.push(link);
402
+ grouped.set(link.assetId, current);
403
+ }
404
+ return grouped;
405
+ }
406
+ function toSyncLinkPayloads(links) {
407
+ return links.map((link) => ({
408
+ targetType: link.targetType,
409
+ targetId: link.targetId,
410
+ role: link.role,
411
+ displayName: link.displayName,
412
+ updatedAt: link.updatedAt,
413
+ }));
79
414
  }
80
415
  function resolveSyncLinkTarget(primaryLink) {
81
416
  if (!primaryLink)
@@ -105,7 +440,10 @@ export function getCanonicalSyncDocumentMetadata(deps, relativePath, workspaceId
105
440
  const asset = deps.workspaceAssetStore.getByStorageKey(relativePath, workspaceId);
106
441
  if (!asset || asset.kind !== 'document')
107
442
  return {};
108
- const { primaryLink } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
443
+ const { primaryLink, activeLinks } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
444
+ return getCanonicalSyncDocumentMetadataFromState(asset, primaryLink, activeLinks, relativePath);
445
+ }
446
+ function getCanonicalSyncDocumentMetadataFromState(asset, primaryLink, activeLinks, relativePath) {
109
447
  const linkTarget = resolveSyncLinkTarget(primaryLink);
110
448
  return {
111
449
  assetId: asset.assetId,
@@ -118,15 +456,19 @@ export function getCanonicalSyncDocumentMetadata(deps, relativePath, workspaceId
118
456
  logicalName: asset.logicalName || null,
119
457
  caption: primaryLink?.displayName || null,
120
458
  originalFilename: asset.originalFilename || path.basename(relativePath),
121
- linkRole: primaryLink?.role === 'reference' ? 'reference' : 'attachment'
459
+ linkRole: primaryLink?.role === 'reference' ? 'reference' : 'attachment',
460
+ links: toSyncLinkPayloads(activeLinks),
122
461
  };
123
462
  }
124
463
  export function hasDocumentSyncMetadataDrift(deps, workspaceId, doc) {
125
464
  if (!deps.workspaceAssetStore)
126
465
  return false;
127
466
  const existingAsset = deps.workspaceAssetStore.getByStorageKey(doc.path, workspaceId);
467
+ const incomingAssetId = typeof doc.assetId === 'string' ? doc.assetId.trim() : '';
128
468
  if (!existingAsset || existingAsset.kind !== 'document')
129
- return false;
469
+ return Boolean(incomingAssetId);
470
+ if (incomingAssetId && existingAsset.assetId !== incomingAssetId)
471
+ return true;
130
472
  const { primaryLink } = resolveCanonicalAssetSyncLinkState(deps, existingAsset, workspaceId);
131
473
  const normalizedIncomingReference = Number.isFinite(Number(doc.referenceNumber))
132
474
  ? Math.max(1, Math.floor(Number(doc.referenceNumber)))
@@ -166,8 +508,11 @@ export function hasBinaryAssetSyncMetadataDrift(deps, workspaceId, asset) {
166
508
  if (!deps.workspaceAssetStore)
167
509
  return false;
168
510
  const existingAsset = deps.workspaceAssetStore.getByStorageKey(asset.path, workspaceId);
511
+ const incomingAssetId = typeof asset.assetId === 'string' ? asset.assetId.trim() : '';
169
512
  if (!existingAsset || (existingAsset.kind !== 'image' && existingAsset.kind !== 'file'))
170
- return false;
513
+ return Boolean(incomingAssetId);
514
+ if (incomingAssetId && existingAsset.assetId !== incomingAssetId)
515
+ return true;
171
516
  const { primaryLink } = resolveCanonicalAssetSyncLinkState(deps, existingAsset, workspaceId);
172
517
  const normalizedIncomingReference = Number.isFinite(Number(asset.referenceNumber))
173
518
  ? Math.max(1, Math.floor(Number(asset.referenceNumber)))
@@ -218,8 +563,43 @@ export function reconcileWorkspaceSyncLinks(deps, input) {
218
563
  : 'attachment';
219
564
  const linkUpdatedAt = String(input.updatedAt || '').trim() || new Date().toISOString();
220
565
  const existingLinks = deps.workspaceAssetStore.listLinksForAsset(assetId, workspaceId, { includeDeleted: true });
566
+ if (Array.isArray(input.links)) {
567
+ const desiredLinkKeys = new Set();
568
+ for (const link of input.links) {
569
+ const targetId = String(link.targetId || '').trim();
570
+ if (!targetId)
571
+ continue;
572
+ const key = `${link.targetType}:${targetId}:${link.role}`;
573
+ desiredLinkKeys.add(key);
574
+ deps.workspaceAssetStore.upsertLegacySyncLink({
575
+ workspaceId,
576
+ assetId,
577
+ targetType: link.targetType,
578
+ targetId,
579
+ role: link.role,
580
+ displayName: typeof link.displayName === 'string' && link.displayName.trim() ? link.displayName.trim() : null,
581
+ updatedAt: String(link.updatedAt || '').trim() || linkUpdatedAt,
582
+ deletedAt: null,
583
+ });
584
+ }
585
+ for (const link of existingLinks) {
586
+ if (link.deletedAt)
587
+ continue;
588
+ const key = `${link.targetType}:${link.targetId}:${link.role}`;
589
+ if (desiredLinkKeys.has(key))
590
+ continue;
591
+ deps.workspaceAssetStore.deleteLegacySyncLink({
592
+ workspaceId,
593
+ assetId,
594
+ targetType: link.targetType,
595
+ targetId: link.targetId,
596
+ role: link.role,
597
+ });
598
+ }
599
+ return;
600
+ }
221
601
  if (desiredLinkTarget) {
222
- deps.workspaceAssetStore.upsertLink({
602
+ deps.workspaceAssetStore.upsertLegacySyncLink({
223
603
  workspaceId,
224
604
  assetId,
225
605
  targetType: desiredLinkTarget.targetType,
@@ -239,7 +619,7 @@ export function reconcileWorkspaceSyncLinks(deps, input) {
239
619
  }
240
620
  if (link.deletedAt)
241
621
  continue;
242
- deps.workspaceAssetStore.deleteLink({
622
+ deps.workspaceAssetStore.deleteLegacySyncLink({
243
623
  workspaceId,
244
624
  assetId,
245
625
  targetType: link.targetType,
@@ -298,25 +678,23 @@ export async function listWorkspaceSyncDocumentsSnapshot(deps, basePath, workspa
298
678
  let stat = null;
299
679
  let content = null;
300
680
  let updatedAt = '';
681
+ let contentIdentity = `legacy:local:${relativePath}`;
301
682
  if (canonicalAsset?.kind === 'document') {
302
683
  updatedAt = resolveCanonicalAssetSyncLinkState(deps, canonicalAsset, workspaceId).effectiveUpdatedAt;
303
- if (canonicalAsset.storageProvider === 'r2' && objectStorageClient) {
304
- const object = await objectStorageClient.getObject(relativePath);
305
- if (!object?.body)
306
- continue;
307
- content = object.body.toString('utf8');
308
- }
309
- else {
310
- const absPath = path.resolve(path.join(root, relativePath));
311
- if (absPath !== root && !absPath.startsWith(`${root}${path.sep}`))
312
- continue;
313
- if (!fs.existsSync(absPath))
314
- continue;
315
- stat = fs.statSync(absPath);
316
- if (!stat.isFile())
317
- continue;
318
- content = fs.readFileSync(absPath, 'utf8');
319
- }
684
+ const published = resolvePublishedContent(deps, {
685
+ workspaceId,
686
+ kind: 'document',
687
+ logicalPath: relativePath,
688
+ legacyProvider: canonicalAsset.storageProvider === 'r2' ? 'r2' : 'local',
689
+ });
690
+ if (published.source === 'deleted')
691
+ continue;
692
+ contentIdentity = publishedContentIdentity(published);
693
+ const read = await readPublishedContentBuffer(deps, root, published, `Workspace sync document ${relativePath}`);
694
+ if (!read)
695
+ continue;
696
+ stat = read.stat;
697
+ content = read.buffer.toString('utf8');
320
698
  }
321
699
  else {
322
700
  const absPath = path.resolve(path.join(basePath, relativePath));
@@ -332,6 +710,7 @@ export async function listWorkspaceSyncDocumentsSnapshot(deps, basePath, workspa
332
710
  continue;
333
711
  const cached = workspaceCache.get(relativePath);
334
712
  if (cached
713
+ && cached.contentIdentity === contentIdentity
335
714
  && cached.size === Buffer.byteLength(content, 'utf8')
336
715
  && (canonicalAsset
337
716
  ? cached.updatedAt === updatedAt
@@ -374,6 +753,7 @@ export async function listWorkspaceSyncDocumentsSnapshot(deps, basePath, workspa
374
753
  });
375
754
  workspaceCache.set(relativePath, {
376
755
  path: relativePath,
756
+ contentIdentity,
377
757
  mtimeMs: stat?.mtimeMs ?? 0,
378
758
  ctimeMs: stat?.ctimeMs ?? 0,
379
759
  size: Buffer.byteLength(content, 'utf8'),
@@ -396,15 +776,22 @@ export async function listWorkspaceSyncDocumentsSnapshot(deps, basePath, workspa
396
776
  return docs;
397
777
  }
398
778
  export async function listWorkspaceSyncDocumentIndex(deps, basePath, workspaceId = 'default') {
779
+ const canonicalAssetByRawPath = new Map();
399
780
  const candidatePaths = new Set();
781
+ const linksByAssetId = deps.workspaceAssetStore
782
+ ? groupWorkspaceAssetLinksByAssetId(deps.workspaceAssetStore, workspaceId)
783
+ : new Map();
400
784
  // Keep the document index aligned with the snapshot invariant above: only
401
785
  // canonical workspace document assets may participate in shared document sync.
402
786
  if (deps.workspaceAssetStore) {
403
- const canonicalAssets = deps.workspaceAssetStore.listAllByWorkspace(workspaceId, {
787
+ const canonicalAssets = deps.workspaceAssetStore.listAllNormalizedByWorkspace(workspaceId, {
404
788
  includeDeleted: false,
405
789
  kind: 'document'
406
790
  });
407
791
  for (const asset of canonicalAssets) {
792
+ if (!canonicalAssetByRawPath.has(asset.storageKey)) {
793
+ canonicalAssetByRawPath.set(asset.storageKey, asset);
794
+ }
408
795
  const normalized = deps.normalizeWorkspaceSyncDocumentPath(asset.storageKey);
409
796
  if (normalized)
410
797
  candidatePaths.add(normalized);
@@ -413,10 +800,34 @@ export async function listWorkspaceSyncDocumentIndex(deps, basePath, workspaceId
413
800
  const docs = [];
414
801
  for (const relativePath of Array.from(candidatePaths).sort((a, b) => a.localeCompare(b))) {
415
802
  try {
416
- const canonicalAsset = deps.workspaceAssetStore?.getByStorageKey(relativePath, workspaceId);
803
+ const canonicalAsset = canonicalAssetByRawPath.get(relativePath);
417
804
  let updatedAt = '';
805
+ let contentSha256 = '';
806
+ let sizeBytes = 0;
807
+ let contentAvailable = false;
808
+ const linkState = canonicalAsset?.kind === 'document'
809
+ ? resolveCanonicalAssetSyncLinkStateFromLinks(canonicalAsset, linksByAssetId.get(canonicalAsset.assetId) || [])
810
+ : null;
418
811
  if (canonicalAsset?.kind === 'document') {
419
- updatedAt = resolveCanonicalAssetSyncLinkState(deps, canonicalAsset, workspaceId).effectiveUpdatedAt;
812
+ updatedAt = linkState.effectiveUpdatedAt;
813
+ const published = resolvePublishedContent(deps, {
814
+ workspaceId,
815
+ kind: 'document',
816
+ logicalPath: relativePath,
817
+ legacyProvider: canonicalAsset.storageProvider === 'r2' ? 'r2' : 'local',
818
+ });
819
+ if (published.source === 'deleted')
820
+ continue;
821
+ const availability = publishedContentAvailable(basePath, published);
822
+ contentSha256 = availability.contentSha256
823
+ || String(canonicalAsset.contentSha256 || '').trim().toLowerCase();
824
+ sizeBytes = availability.contentAvailable
825
+ ? availability.sizeBytes
826
+ : Math.max(0, Math.floor(Number(canonicalAsset.sizeBytes || 0)));
827
+ contentAvailable = availability.contentAvailable
828
+ || (published.source === 'legacy'
829
+ && published.storageProvider === 'r2'
830
+ && contentSha256.length === 64);
420
831
  }
421
832
  else {
422
833
  const absPath = path.resolve(path.join(basePath, relativePath));
@@ -431,13 +842,21 @@ export async function listWorkspaceSyncDocumentIndex(deps, basePath, workspaceId
431
842
  const existing = deps.core.getDocumentWatermark(workspaceId, relativePath);
432
843
  updatedAt = existing?.updatedAt
433
844
  || (Number.isFinite(stat.mtimeMs) ? new Date(stat.mtimeMs).toISOString() : new Date().toISOString());
845
+ contentSha256 = String(existing?.contentHash || '').trim().toLowerCase();
846
+ sizeBytes = stat.size;
847
+ contentAvailable = true;
434
848
  }
435
849
  if (!Number.isFinite(Date.parse(String(updatedAt || '').trim())))
436
850
  continue;
437
851
  docs.push({
438
852
  path: relativePath,
439
853
  updatedAt: String(updatedAt || '').trim(),
440
- ...getCanonicalSyncDocumentMetadata(deps, relativePath, workspaceId)
854
+ contentSha256,
855
+ sizeBytes,
856
+ contentAvailable,
857
+ ...(canonicalAsset?.kind === 'document' && linkState
858
+ ? getCanonicalSyncDocumentMetadataFromState(canonicalAsset, linkState.primaryLink, linkState.activeLinks, relativePath)
859
+ : {})
441
860
  });
442
861
  }
443
862
  catch (error) {
@@ -470,35 +889,26 @@ export async function listWorkspaceSyncBinaryAssetsSnapshot(deps, basePath, work
470
889
  continue;
471
890
  emittedPaths.add(storageKey);
472
891
  try {
473
- let buffer = null;
474
- if (asset.storageProvider === 'r2' && objectStorageClient) {
475
- const object = await objectStorageClient.getObject(storageKey);
476
- buffer = object?.body || null;
477
- }
478
- else {
479
- const absolutePath = path.resolve(root, storageKey);
480
- if (absolutePath !== root && !absolutePath.startsWith(`${root}${path.sep}`))
481
- continue;
482
- if (!fs.existsSync(absolutePath)) {
483
- deps.recordSyncDiagnostic(workspaceId, 'push', 'Asset registered in DB but file missing from disk — skipped from sync payload.', {
484
- source: 'assets.snapshot.missingFile',
485
- assetId: asset.assetId,
486
- path: storageKey
487
- });
488
- continue;
489
- }
490
- buffer = fs.readFileSync(absolutePath);
491
- }
892
+ const published = resolvePublishedContent(deps, {
893
+ workspaceId,
894
+ kind: 'asset',
895
+ logicalPath: storageKey,
896
+ legacyProvider: asset.storageProvider === 'r2' ? 'r2' : 'local',
897
+ });
898
+ if (published.source === 'deleted')
899
+ continue;
900
+ const read = await readPublishedContentBuffer(deps, root, published, `Workspace sync binary asset ${storageKey}`);
901
+ const buffer = read?.buffer || null;
492
902
  if (!buffer) {
493
903
  deps.recordSyncDiagnostic(workspaceId, 'push', 'Asset registered in DB but content could not be read — skipped from sync payload.', {
494
904
  source: 'assets.snapshot.emptyBuffer',
495
905
  assetId: asset.assetId,
496
906
  path: storageKey,
497
- storageProvider: asset.storageProvider
907
+ storageProvider: published.storageProvider
498
908
  });
499
909
  continue;
500
910
  }
501
- const { primaryLink, effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
911
+ const { primaryLink, activeLinks, effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
502
912
  const linkTarget = resolveSyncLinkTarget(primaryLink);
503
913
  snapshots.push({
504
914
  path: storageKey,
@@ -514,7 +924,8 @@ export async function listWorkspaceSyncBinaryAssetsSnapshot(deps, basePath, work
514
924
  logicalName: asset.logicalName || null,
515
925
  caption: primaryLink?.displayName || null,
516
926
  originalFilename: asset.originalFilename || path.basename(storageKey),
517
- linkRole: primaryLink?.role || (asset.kind === 'image' ? 'image' : 'attachment')
927
+ linkRole: primaryLink?.role || (asset.kind === 'image' ? 'image' : 'attachment'),
928
+ links: toSyncLinkPayloads(activeLinks),
518
929
  });
519
930
  }
520
931
  catch (error) {
@@ -525,7 +936,7 @@ export async function listWorkspaceSyncBinaryAssetsSnapshot(deps, basePath, work
525
936
  });
526
937
  }
527
938
  }
528
- const referencedAiAvatarAssets = listReferencedAiProfileAvatarAssetPaths(deps, workspaceId);
939
+ const referencedAiAvatarAssets = listReferencedAiProfileAvatarAssets(deps, workspaceId);
529
940
  for (const [assetPath, metadata] of referencedAiAvatarAssets.entries()) {
530
941
  if (emittedPaths.has(assetPath))
531
942
  continue;
@@ -533,14 +944,15 @@ export async function listWorkspaceSyncBinaryAssetsSnapshot(deps, basePath, work
533
944
  if (absolutePath === root || !absolutePath.startsWith(`${root}${path.sep}`))
534
945
  continue;
535
946
  try {
536
- let buffer = null;
537
- if (objectStorageClient) {
538
- const object = await objectStorageClient.getObject(assetPath);
539
- buffer = object?.body || null;
540
- }
541
- else if (fs.existsSync(absolutePath)) {
542
- buffer = fs.readFileSync(absolutePath);
543
- }
947
+ const published = resolvePublishedContent(deps, {
948
+ workspaceId,
949
+ kind: 'asset',
950
+ logicalPath: assetPath,
951
+ legacyProvider: objectStorageClient ? 'r2' : 'local',
952
+ });
953
+ if (published.source === 'deleted')
954
+ continue;
955
+ const buffer = await readReferencedAvatarBuffer(deps, root, published, `Workspace sync AI profile avatar ${assetPath}`);
544
956
  if (!buffer)
545
957
  continue;
546
958
  snapshots.push({
@@ -571,10 +983,13 @@ export async function listWorkspaceSyncBinaryAssetsSnapshot(deps, basePath, work
571
983
  return snapshots;
572
984
  }
573
985
  export async function listWorkspaceSyncBinaryAssetIndex(deps, workspaceId = 'default') {
574
- const assets = deps.workspaceAssetStore?.listAllByWorkspace(workspaceId, {
986
+ const assets = deps.workspaceAssetStore?.listAllNormalizedByWorkspace(workspaceId, {
575
987
  includeDeleted: false
576
988
  }) || [];
577
- const indexed = assets
989
+ const linksByAssetId = deps.workspaceAssetStore
990
+ ? groupWorkspaceAssetLinksByAssetId(deps.workspaceAssetStore, workspaceId)
991
+ : new Map();
992
+ const indexCandidates = assets
578
993
  .filter((asset) => asset.kind === 'image' || asset.kind === 'file')
579
994
  .filter((asset) => asset.storageProvider !== 'external')
580
995
  .filter((asset) => {
@@ -583,10 +998,11 @@ export async function listWorkspaceSyncBinaryAssetIndex(deps, workspaceId = 'def
583
998
  })
584
999
  .map((asset) => {
585
1000
  const storageKey = String(asset.storageKey || '').trim();
586
- const { primaryLink, effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
1001
+ const { primaryLink, activeLinks, effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkStateFromLinks(asset, linksByAssetId.get(asset.assetId) || []);
587
1002
  const linkTarget = resolveSyncLinkTarget(primaryLink);
588
1003
  const assetKind = asset.kind === 'image' ? 'image' : 'file';
589
1004
  return {
1005
+ asset,
590
1006
  path: storageKey,
591
1007
  updatedAt: effectiveUpdatedAt,
592
1008
  assetId: asset.assetId,
@@ -599,16 +1015,114 @@ export async function listWorkspaceSyncBinaryAssetIndex(deps, workspaceId = 'def
599
1015
  logicalName: asset.logicalName || null,
600
1016
  caption: primaryLink?.displayName || null,
601
1017
  originalFilename: asset.originalFilename || path.basename(storageKey),
602
- linkRole: primaryLink?.role || (asset.kind === 'image' ? 'image' : 'attachment')
1018
+ linkRole: primaryLink?.role || (asset.kind === 'image' ? 'image' : 'attachment'),
1019
+ links: toSyncLinkPayloads(activeLinks),
603
1020
  };
604
1021
  })
605
1022
  .filter((entry) => Number.isFinite(Date.parse(entry.updatedAt)) && entry.path.length > 0);
1023
+ const indexed = [];
1024
+ for (const candidate of indexCandidates) {
1025
+ try {
1026
+ const published = resolvePublishedContent(deps, {
1027
+ workspaceId,
1028
+ kind: 'asset',
1029
+ logicalPath: candidate.path,
1030
+ legacyProvider: candidate.asset.storageProvider === 'r2' ? 'r2' : 'local',
1031
+ });
1032
+ if (published.source === 'deleted')
1033
+ continue;
1034
+ const availability = publishedContentAvailable(deps.core.getPaths().basePath, published);
1035
+ const { asset: _asset, ...entry } = candidate;
1036
+ indexed.push({
1037
+ ...entry,
1038
+ contentSha256: availability.contentSha256
1039
+ || String(candidate.asset.contentSha256 || '').trim().toLowerCase(),
1040
+ sizeBytes: availability.contentAvailable
1041
+ ? availability.sizeBytes
1042
+ : Math.max(0, Math.floor(Number(candidate.asset.sizeBytes || 0))),
1043
+ contentAvailable: availability.contentAvailable
1044
+ || (published.source === 'legacy'
1045
+ && published.storageProvider === 'r2'
1046
+ && String(candidate.asset.contentSha256 || '').trim().length === 64),
1047
+ });
1048
+ }
1049
+ catch (error) {
1050
+ deps.recordSyncDiagnostic(workspaceId, 'pull', 'Failed to index binary asset snapshot entry.', {
1051
+ source: 'assets.snapshot.indexEntry',
1052
+ path: candidate.path,
1053
+ assetId: candidate.asset.assetId,
1054
+ error: String(error?.message || error || '')
1055
+ });
1056
+ }
1057
+ }
606
1058
  const indexedPaths = new Set(indexed.map((entry) => entry.path));
607
- for (const [assetPath, metadata] of listReferencedAiProfileAvatarAssetPaths(deps, workspaceId).entries()) {
1059
+ for (const [assetPath, metadata] of listReferencedAiProfileAvatarAssets(deps, workspaceId).entries()) {
608
1060
  if (indexedPaths.has(assetPath))
609
1061
  continue;
610
1062
  if (!Number.isFinite(Date.parse(metadata.updatedAt)))
611
1063
  continue;
1064
+ const fingerprintCacheKey = `${workspaceId}:${assetPath}`;
1065
+ let published;
1066
+ try {
1067
+ published = resolvePublishedContent(deps, {
1068
+ workspaceId,
1069
+ kind: 'asset',
1070
+ logicalPath: assetPath,
1071
+ legacyProvider: deps.getObjectStorageClient() ? 'r2' : 'local',
1072
+ });
1073
+ }
1074
+ catch (error) {
1075
+ deps.recordSyncDiagnostic(workspaceId, 'pull', 'Failed to resolve referenced AI profile avatar.', {
1076
+ source: 'assets.index.aiProfileAvatar.resolve',
1077
+ path: assetPath,
1078
+ error: String(error?.message || error || '')
1079
+ });
1080
+ continue;
1081
+ }
1082
+ if (published.source === 'deleted')
1083
+ continue;
1084
+ const contentIdentity = publishedContentIdentity(published);
1085
+ let fingerprint = referencedAvatarFingerprintCache.get(fingerprintCacheKey);
1086
+ if (!fingerprint
1087
+ || fingerprint.updatedAt !== metadata.updatedAt
1088
+ || fingerprint.contentIdentity !== contentIdentity) {
1089
+ if (published.source === 'versioned') {
1090
+ const availability = publishedContentAvailable(deps.core.getPaths().basePath, published);
1091
+ fingerprint = availability.contentAvailable
1092
+ ? {
1093
+ updatedAt: metadata.updatedAt,
1094
+ contentIdentity,
1095
+ contentSha256: availability.contentSha256,
1096
+ sizeBytes: availability.sizeBytes,
1097
+ }
1098
+ : undefined;
1099
+ }
1100
+ else {
1101
+ let content = null;
1102
+ try {
1103
+ content = await readReferencedAvatarBuffer(deps, deps.core.getPaths().basePath, published, `Workspace sync AI profile avatar index ${assetPath}`);
1104
+ }
1105
+ catch (error) {
1106
+ deps.recordSyncDiagnostic(workspaceId, 'pull', 'Failed to fingerprint referenced AI profile avatar.', {
1107
+ source: 'assets.index.aiProfileAvatar',
1108
+ path: assetPath,
1109
+ error: String(error?.message || error || '')
1110
+ });
1111
+ }
1112
+ fingerprint = content
1113
+ ? {
1114
+ updatedAt: metadata.updatedAt,
1115
+ contentIdentity,
1116
+ contentSha256: createHash('sha256').update(content).digest('hex'),
1117
+ sizeBytes: content.length,
1118
+ }
1119
+ : undefined;
1120
+ }
1121
+ if (fingerprint)
1122
+ referencedAvatarFingerprintCache.set(fingerprintCacheKey, fingerprint);
1123
+ else
1124
+ referencedAvatarFingerprintCache.delete(fingerprintCacheKey);
1125
+ }
612
1126
  indexed.push({
613
1127
  path: assetPath,
614
1128
  updatedAt: metadata.updatedAt,
@@ -622,7 +1136,10 @@ export async function listWorkspaceSyncBinaryAssetIndex(deps, workspaceId = 'def
622
1136
  logicalName: null,
623
1137
  caption: null,
624
1138
  originalFilename: metadata.originalFilename,
625
- linkRole: 'image'
1139
+ linkRole: 'image',
1140
+ contentSha256: fingerprint?.contentSha256 || '',
1141
+ sizeBytes: fingerprint?.sizeBytes || 0,
1142
+ contentAvailable: Boolean(fingerprint)
626
1143
  });
627
1144
  }
628
1145
  return indexed;
@@ -635,16 +1152,26 @@ export async function loadWorkspaceSyncDocumentPayload(deps, basePath, workspace
635
1152
  const absolutePath = path.resolve(path.join(root, normalizedPath));
636
1153
  if (absolutePath !== root && !absolutePath.startsWith(`${root}${path.sep}`))
637
1154
  return null;
638
- const objectStorageClient = deps.getObjectStorageClient();
639
1155
  const canonicalAsset = deps.workspaceAssetStore?.getByStorageKey(normalizedPath, workspaceId);
640
1156
  let content = '';
641
1157
  let stat = null;
1158
+ let contentIdentity = `legacy:local:${normalizedPath}`;
642
1159
  try {
643
- if (canonicalAsset?.kind === 'document' && canonicalAsset.storageProvider === 'r2' && objectStorageClient) {
644
- const object = await objectStorageClient.getObject(normalizedPath);
645
- if (!object?.body)
1160
+ if (canonicalAsset?.kind === 'document') {
1161
+ const published = resolvePublishedContent(deps, {
1162
+ workspaceId,
1163
+ kind: 'document',
1164
+ logicalPath: normalizedPath,
1165
+ legacyProvider: canonicalAsset.storageProvider === 'r2' ? 'r2' : 'local',
1166
+ });
1167
+ if (published.source === 'deleted')
1168
+ return null;
1169
+ contentIdentity = publishedContentIdentity(published);
1170
+ const read = await readPublishedContentBuffer(deps, root, published, `Targeted workspace sync document ${normalizedPath}`);
1171
+ if (!read)
646
1172
  return null;
647
- content = object.body.toString('utf8');
1173
+ content = read.buffer.toString('utf8');
1174
+ stat = read.stat;
648
1175
  }
649
1176
  else {
650
1177
  if (!fs.existsSync(absolutePath))
@@ -697,11 +1224,11 @@ export async function loadWorkspaceSyncDocumentPayload(deps, basePath, workspace
697
1224
  }
698
1225
  }
699
1226
  if (cached
700
- && stat
1227
+ && cached.contentIdentity === contentIdentity
701
1228
  && cached.size === Buffer.byteLength(content, 'utf8')
702
1229
  && (canonicalAsset
703
1230
  ? cached.updatedAt === updatedAt
704
- : cached.mtimeMs === stat.mtimeMs && cached.ctimeMs === stat.ctimeMs)) {
1231
+ : stat != null && cached.mtimeMs === stat.mtimeMs && cached.ctimeMs === stat.ctimeMs)) {
705
1232
  return {
706
1233
  path: normalizedPath,
707
1234
  updatedAt: cached.updatedAt,
@@ -711,6 +1238,7 @@ export async function loadWorkspaceSyncDocumentPayload(deps, basePath, workspace
711
1238
  }
712
1239
  workspaceCache.set(normalizedPath, {
713
1240
  path: normalizedPath,
1241
+ contentIdentity,
714
1242
  mtimeMs: stat?.mtimeMs ?? 0,
715
1243
  ctimeMs: stat?.ctimeMs ?? 0,
716
1244
  size: Buffer.byteLength(content, 'utf8'),
@@ -730,7 +1258,7 @@ export async function loadWorkspaceSyncBinaryAssetPayload(deps, basePath, worksp
730
1258
  return null;
731
1259
  const asset = deps.workspaceAssetStore?.getByStorageKey(normalizedPath, workspaceId) || null;
732
1260
  const referencedAiAvatar = !asset
733
- ? listReferencedAiProfileAvatarAssetPaths(deps, workspaceId).get(normalizedPath) || null
1261
+ ? listReferencedAiProfileAvatarAssets(deps, workspaceId).get(normalizedPath) || null
734
1262
  : null;
735
1263
  if (!referencedAiAvatar
736
1264
  && (!asset || (asset.kind !== 'image' && asset.kind !== 'file') || asset.storageProvider === 'external')) {
@@ -739,26 +1267,19 @@ export async function loadWorkspaceSyncBinaryAssetPayload(deps, basePath, worksp
739
1267
  const objectStorageClient = deps.getObjectStorageClient();
740
1268
  let buffer = null;
741
1269
  try {
742
- if ((asset?.storageProvider === 'r2' || referencedAiAvatar) && objectStorageClient) {
743
- const object = await objectStorageClient.getObject(normalizedPath);
744
- buffer = object?.body || null;
745
- }
746
- else {
747
- const root = path.resolve(basePath);
748
- const absolutePath = path.resolve(root, normalizedPath);
749
- if (absolutePath !== root && !absolutePath.startsWith(`${root}${path.sep}`))
750
- return null;
751
- if (!fs.existsSync(absolutePath))
752
- return null;
753
- buffer = fs.readFileSync(absolutePath);
754
- }
755
- if (!buffer && referencedAiAvatar && objectStorageClient) {
756
- const root = path.resolve(basePath);
757
- const absolutePath = path.resolve(root, normalizedPath);
758
- if (absolutePath !== root && absolutePath.startsWith(`${root}${path.sep}`) && fs.existsSync(absolutePath)) {
759
- buffer = fs.readFileSync(absolutePath);
760
- }
761
- }
1270
+ const published = resolvePublishedContent(deps, {
1271
+ workspaceId,
1272
+ kind: 'asset',
1273
+ logicalPath: normalizedPath,
1274
+ legacyProvider: asset
1275
+ ? (asset.storageProvider === 'r2' ? 'r2' : 'local')
1276
+ : (objectStorageClient ? 'r2' : 'local'),
1277
+ });
1278
+ if (published.source === 'deleted')
1279
+ return null;
1280
+ buffer = referencedAiAvatar && !asset
1281
+ ? await readReferencedAvatarBuffer(deps, basePath, published, `Targeted workspace sync binary asset ${normalizedPath}`)
1282
+ : (await readPublishedContentBuffer(deps, basePath, published, `Targeted workspace sync binary asset ${normalizedPath}`))?.buffer || null;
762
1283
  }
763
1284
  catch (error) {
764
1285
  deps.recordSyncDiagnostic(workspaceId, 'pull', 'Failed to load targeted binary asset payload.', {
@@ -791,7 +1312,7 @@ export async function loadWorkspaceSyncBinaryAssetPayload(deps, basePath, worksp
791
1312
  }
792
1313
  if (!asset)
793
1314
  return null;
794
- const { primaryLink, effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
1315
+ const { primaryLink, activeLinks, effectiveUpdatedAt } = resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId);
795
1316
  const linkTarget = resolveSyncLinkTarget(primaryLink);
796
1317
  const assetKind = asset.kind === 'image' ? 'image' : 'file';
797
1318
  return {
@@ -808,12 +1329,14 @@ export async function loadWorkspaceSyncBinaryAssetPayload(deps, basePath, worksp
808
1329
  logicalName: asset.logicalName || null,
809
1330
  caption: primaryLink?.displayName || null,
810
1331
  originalFilename: asset.originalFilename || path.basename(normalizedPath),
811
- linkRole: primaryLink?.role || (asset.kind === 'image' ? 'image' : 'attachment')
1332
+ linkRole: primaryLink?.role || (asset.kind === 'image' ? 'image' : 'attachment'),
1333
+ links: toSyncLinkPayloads(activeLinks),
812
1334
  };
813
1335
  }
814
1336
  export function listWorkspaceSyncBinaryAssetDeletesSnapshot(deps, workspaceId = 'default') {
815
1337
  if (!deps.workspaceAssetStore)
816
1338
  return [];
1339
+ const referencedAiAvatarAssets = listReferencedAiProfileAvatarAssets(deps, workspaceId);
817
1340
  const entries = deps.workspaceAssetStore.listAllByWorkspace(workspaceId, {
818
1341
  includeDeleted: true
819
1342
  })
@@ -825,6 +1348,8 @@ export function listWorkspaceSyncBinaryAssetDeletesSnapshot(deps, workspaceId =
825
1348
  const normalizedPath = deps.normalizeTaskDataRelativePath(asset.storageKey);
826
1349
  if (!normalizedPath)
827
1350
  return null;
1351
+ if (referencedAiAvatarAssets.has(normalizedPath))
1352
+ return null;
828
1353
  return {
829
1354
  path: normalizedPath,
830
1355
  deletedAt: String(asset.deletedAt || '').trim(),
@@ -833,71 +1358,159 @@ export function listWorkspaceSyncBinaryAssetDeletesSnapshot(deps, workspaceId =
833
1358
  });
834
1359
  return entries.filter((entry) => Boolean(entry && entry.path && entry.deletedAt));
835
1360
  }
836
- export async function writeWorkspaceSyncDocument(deps, basePath, doc, workspaceId = 'default', options) {
837
- const normalizedPath = deps.normalizeWorkspaceSyncDocumentPath(doc.path);
838
- if (!normalizedPath)
839
- return;
840
- const root = path.resolve(basePath);
841
- const targetPath = path.resolve(root, normalizedPath);
842
- if (targetPath !== root && !targetPath.startsWith(`${root}${path.sep}`))
843
- return;
844
- const objectStorageClient = deps.getObjectStorageClient();
845
- const content = String(doc.content || '');
846
- if (objectStorageClient) {
847
- try {
848
- await objectStorageClient.putObject(normalizedPath, Buffer.from(content, 'utf8'), 'text/markdown');
849
- }
850
- catch (error) {
851
- deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to write document to object storage.', {
852
- source: 'documents.write.putObject',
853
- path: normalizedPath,
854
- error: String(error?.message || error || '')
855
- });
856
- return;
857
- }
858
- }
859
- else {
860
- fs.mkdirSync(path.dirname(targetPath), { recursive: true });
861
- fs.writeFileSync(targetPath, content, 'utf8');
862
- }
1361
+ export function persistWorkspaceSyncDocumentMetadata(deps, input) {
1362
+ const { document: doc, normalizedPath, contentSha256, sizeBytes, storageProvider, workspaceId = 'default', options, } = input;
863
1363
  const updatedAt = String(doc.updatedAt || '').trim();
864
- const watermarkMs = Date.parse(updatedAt);
865
- if (!objectStorageClient && Number.isFinite(watermarkMs) && watermarkMs > 0) {
866
- const when = new Date(watermarkMs);
867
- fs.utimesSync(targetPath, when, when);
1364
+ const mutationUpdatedAt = updatedAt || new Date().toISOString();
1365
+ try {
1366
+ runWorkspaceSyncContentMetadataMutation(deps, {
1367
+ workspaceId,
1368
+ kind: 'document',
1369
+ logicalPath: normalizedPath,
1370
+ updatedAt: mutationUpdatedAt,
1371
+ }, () => {
1372
+ const current = newestDocumentMetadata(deps.core.getDocumentWatermark(workspaceId, normalizedPath), deps.workspaceAssetStore?.getByStorageKey(normalizedPath, workspaceId) || null);
1373
+ if ((options?.strictOrdering === true
1374
+ || hasPublishedWorkspaceSyncContentHead(deps, {
1375
+ workspaceId,
1376
+ kind: 'document',
1377
+ logicalPath: normalizedPath,
1378
+ }))
1379
+ &&
1380
+ current
1381
+ && compareWorkspaceMutationOrdering(mutationUpdatedAt, current.updatedAt, contentSha256, current.contentHash) < 0)
1382
+ return;
1383
+ const persistWatermark = options?.strictWatermark === true
1384
+ ? deps.core.upsertDocumentWatermarkStrict.bind(deps.core)
1385
+ : deps.core.upsertDocumentWatermark.bind(deps.core);
1386
+ persistWatermark(workspaceId, normalizedPath, contentSha256, mutationUpdatedAt);
1387
+ if (deps.workspaceAssetStore) {
1388
+ const existing = deps.workspaceAssetStore.getByStorageKey(normalizedPath, workspaceId);
1389
+ const effectiveUpdatedAt = mutationUpdatedAt;
1390
+ const incomingReferenceNumber = Number.isFinite(Number(doc.referenceNumber))
1391
+ ? Math.max(1, Math.floor(Number(doc.referenceNumber)))
1392
+ : null;
1393
+ const allowReferenceNumberReassignment = options?.allowReferenceNumberReassignment === true;
1394
+ const nextReferenceNumber = allowReferenceNumberReassignment
1395
+ ? (incomingReferenceNumber ?? existing?.referenceNumber ?? null)
1396
+ : (existing?.referenceNumber ?? incomingReferenceNumber ?? null);
1397
+ const originalFilename = String(doc.originalFilename
1398
+ || existing?.originalFilename
1399
+ || path.basename(normalizedPath)
1400
+ || 'document.md').trim() || 'document.md';
1401
+ const upsertedAsset = deps.workspaceAssetStore.upsertAsset({
1402
+ assetId: String(doc.assetId || existing?.assetId || `asset-${randomUUID().replace(/-/g, '')}`),
1403
+ workspaceId,
1404
+ kind: 'document',
1405
+ logicalName: typeof doc.logicalName === 'string' && doc.logicalName.trim().length > 0
1406
+ ? doc.logicalName.trim()
1407
+ : existing?.logicalName || null,
1408
+ originalFilename,
1409
+ mimeType: existing?.mimeType || 'text/markdown',
1410
+ storageProvider,
1411
+ storageKey: normalizedPath,
1412
+ contentSha256,
1413
+ sizeBytes,
1414
+ documentId: String(doc.documentId || existing?.documentId || `doc-${randomUUID().replace(/-/g, '')}`),
1415
+ referenceNumber: nextReferenceNumber,
1416
+ version: Number.isFinite(Number(doc.version))
1417
+ ? Math.max(1, Math.floor(Number(doc.version)))
1418
+ : Math.max(1, Number(existing?.version || 0) + 1),
1419
+ isLatest: true,
1420
+ scanStatus: existing?.scanStatus || 'clean',
1421
+ scanEngine: existing?.scanEngine || null,
1422
+ scanDetails: existing?.scanDetails || null,
1423
+ createdByUserId: existing?.createdByUserId || null,
1424
+ createdAt: existing?.createdAt || effectiveUpdatedAt,
1425
+ updatedAt: effectiveUpdatedAt,
1426
+ deletedAt: null,
1427
+ purgeAfter: null,
1428
+ allowReferenceNumberReassignment
1429
+ });
1430
+ const asset = allowReferenceNumberReassignment && incomingReferenceNumber
1431
+ ? deps.workspaceAssetStore.adoptReadableReferenceNumber(workspaceId, upsertedAsset.assetId, incomingReferenceNumber)
1432
+ : upsertedAsset;
1433
+ const linkTarget = resolveIncomingSyncLinkTarget(doc);
1434
+ reconcileWorkspaceSyncLinks(deps, {
1435
+ workspaceId,
1436
+ assetId: asset.assetId,
1437
+ taskId: linkTarget?.targetType === 'task' ? linkTarget.targetId : null,
1438
+ linkTargetType: linkTarget?.targetType || null,
1439
+ linkTargetId: linkTarget?.targetId || null,
1440
+ displayName: typeof doc.caption === 'string' && doc.caption.trim().length > 0
1441
+ ? doc.caption.trim()
1442
+ : null,
1443
+ role: doc.linkRole === 'reference' ? 'reference' : 'attachment',
1444
+ updatedAt: effectiveUpdatedAt,
1445
+ links: doc.links,
1446
+ });
1447
+ }
1448
+ });
1449
+ }
1450
+ catch (error) {
1451
+ deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to persist document watermark after write.', {
1452
+ source: 'documents.write.upsertWatermark',
1453
+ path: normalizedPath,
1454
+ error: String(error?.message || error || '')
1455
+ });
1456
+ throw error;
868
1457
  }
1458
+ deps.workspaceDocumentSnapshotCache.get(workspaceId)?.delete(normalizedPath);
1459
+ }
1460
+ export function persistWorkspaceSyncBinaryAssetMetadata(deps, input) {
1461
+ if (!deps.workspaceAssetStore)
1462
+ return;
1463
+ const workspaceAssetStore = deps.workspaceAssetStore;
1464
+ const { asset, normalizedPath, contentSha256, sizeBytes, storageProvider, workspaceId = 'default', options, } = input;
1465
+ const updatedAt = String(asset.updatedAt || '').trim();
1466
+ const mutationUpdatedAt = updatedAt || new Date().toISOString();
869
1467
  try {
870
- const contentHash = createHash('sha256').update(content).digest('hex');
871
- deps.core.upsertDocumentWatermark(workspaceId, normalizedPath, contentHash, updatedAt || new Date().toISOString());
872
- if (deps.workspaceAssetStore) {
873
- const existing = deps.workspaceAssetStore.getByStorageKey(normalizedPath, workspaceId);
874
- const effectiveUpdatedAt = updatedAt || new Date().toISOString();
875
- const incomingReferenceNumber = Number.isFinite(Number(doc.referenceNumber))
876
- ? Math.max(1, Math.floor(Number(doc.referenceNumber)))
1468
+ runWorkspaceSyncContentMetadataMutation(deps, {
1469
+ workspaceId,
1470
+ kind: 'asset',
1471
+ logicalPath: normalizedPath,
1472
+ updatedAt: mutationUpdatedAt,
1473
+ }, () => {
1474
+ const existing = workspaceAssetStore.getByStorageKey(normalizedPath, workspaceId);
1475
+ if ((options?.strictOrdering === true
1476
+ || hasPublishedWorkspaceSyncContentHead(deps, {
1477
+ workspaceId,
1478
+ kind: 'asset',
1479
+ logicalPath: normalizedPath,
1480
+ }))
1481
+ &&
1482
+ existing
1483
+ && compareWorkspaceMutationOrdering(mutationUpdatedAt, existing.updatedAt, contentSha256, existing.contentSha256) < 0)
1484
+ return;
1485
+ const effectiveUpdatedAt = mutationUpdatedAt;
1486
+ const incomingReferenceNumber = Number.isFinite(Number(asset.referenceNumber))
1487
+ ? Math.max(1, Math.floor(Number(asset.referenceNumber)))
877
1488
  : null;
878
1489
  const allowReferenceNumberReassignment = options?.allowReferenceNumberReassignment === true;
879
1490
  const nextReferenceNumber = allowReferenceNumberReassignment
880
1491
  ? (incomingReferenceNumber ?? existing?.referenceNumber ?? null)
881
1492
  : (existing?.referenceNumber ?? incomingReferenceNumber ?? null);
882
- const originalFilename = String(doc.originalFilename || existing?.originalFilename || path.basename(normalizedPath) || 'document.md').trim() || 'document.md';
883
- const asset = deps.workspaceAssetStore.upsertAsset({
884
- assetId: String(doc.assetId || existing?.assetId || `asset-${randomUUID().replace(/-/g, '')}`),
1493
+ const upsertedAssetRecord = workspaceAssetStore.upsertAsset({
1494
+ assetId: String(asset.assetId || existing?.assetId || `asset-${randomUUID().replace(/-/g, '')}`),
885
1495
  workspaceId,
886
- kind: 'document',
887
- logicalName: typeof doc.logicalName === 'string' && doc.logicalName.trim().length > 0
888
- ? doc.logicalName.trim()
1496
+ kind: asset.kind === 'image' ? 'image' : 'file',
1497
+ logicalName: typeof asset.logicalName === 'string' && asset.logicalName.trim().length > 0
1498
+ ? asset.logicalName.trim()
889
1499
  : existing?.logicalName || null,
890
- originalFilename,
891
- mimeType: existing?.mimeType || 'text/markdown',
892
- storageProvider: objectStorageClient ? 'r2' : 'local',
1500
+ originalFilename: String(asset.originalFilename
1501
+ || existing?.originalFilename
1502
+ || path.basename(normalizedPath)
1503
+ || 'asset').trim() || 'asset',
1504
+ mimeType: String(asset.mimeType
1505
+ || existing?.mimeType
1506
+ || 'application/octet-stream').trim() || 'application/octet-stream',
1507
+ storageProvider,
893
1508
  storageKey: normalizedPath,
894
- contentSha256: contentHash,
895
- sizeBytes: Buffer.byteLength(content, 'utf8'),
896
- documentId: String(doc.documentId || existing?.documentId || `doc-${randomUUID().replace(/-/g, '')}`),
1509
+ contentSha256,
1510
+ sizeBytes,
1511
+ documentId: null,
897
1512
  referenceNumber: nextReferenceNumber,
898
- version: Number.isFinite(Number(doc.version))
899
- ? Math.max(1, Math.floor(Number(doc.version)))
900
- : Math.max(1, Number(existing?.version || 0) + 1),
1513
+ version: null,
901
1514
  isLatest: true,
902
1515
  scanStatus: existing?.scanStatus || 'clean',
903
1516
  scanEngine: existing?.scanEngine || null,
@@ -909,27 +1522,106 @@ export async function writeWorkspaceSyncDocument(deps, basePath, doc, workspaceI
909
1522
  purgeAfter: null,
910
1523
  allowReferenceNumberReassignment
911
1524
  });
912
- const linkTarget = resolveIncomingSyncLinkTarget(doc);
1525
+ const assetRecord = allowReferenceNumberReassignment && incomingReferenceNumber
1526
+ ? workspaceAssetStore.adoptReadableReferenceNumber(workspaceId, upsertedAssetRecord.assetId, incomingReferenceNumber)
1527
+ : upsertedAssetRecord;
1528
+ const linkTarget = resolveIncomingSyncLinkTarget(asset);
913
1529
  reconcileWorkspaceSyncLinks(deps, {
914
1530
  workspaceId,
915
- assetId: asset.assetId,
1531
+ assetId: assetRecord.assetId,
916
1532
  taskId: linkTarget?.targetType === 'task' ? linkTarget.targetId : null,
917
1533
  linkTargetType: linkTarget?.targetType || null,
918
1534
  linkTargetId: linkTarget?.targetId || null,
919
- displayName: typeof doc.caption === 'string' && doc.caption.trim().length > 0 ? doc.caption.trim() : null,
920
- role: doc.linkRole === 'reference' ? 'reference' : 'attachment',
921
- updatedAt: effectiveUpdatedAt
1535
+ displayName: typeof asset.caption === 'string' && asset.caption.trim().length > 0
1536
+ ? asset.caption.trim()
1537
+ : null,
1538
+ role: asset.linkRole === 'reference'
1539
+ ? 'reference'
1540
+ : asset.kind === 'image'
1541
+ ? 'image'
1542
+ : 'attachment',
1543
+ updatedAt: effectiveUpdatedAt,
1544
+ links: asset.links,
922
1545
  });
923
- }
1546
+ });
924
1547
  }
925
1548
  catch (error) {
926
- deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to persist document watermark after write.', {
927
- source: 'documents.write.upsertWatermark',
1549
+ deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to persist binary asset metadata after write.', {
1550
+ source: 'assets.write.upsertAsset',
928
1551
  path: normalizedPath,
1552
+ assetId: typeof asset.assetId === 'string' ? asset.assetId : null,
1553
+ kind: asset.kind,
929
1554
  error: String(error?.message || error || '')
930
1555
  });
1556
+ throw error;
931
1557
  }
932
- deps.workspaceDocumentSnapshotCache.get(workspaceId)?.delete(normalizedPath);
1558
+ }
1559
+ export async function writeWorkspaceSyncDocument(deps, basePath, doc, workspaceId = 'default', options) {
1560
+ const normalizedPath = deps.normalizeWorkspaceSyncDocumentPath(doc.path);
1561
+ if (!normalizedPath)
1562
+ return;
1563
+ const root = path.resolve(basePath);
1564
+ const targetPath = path.resolve(root, normalizedPath);
1565
+ if (targetPath !== root && !targetPath.startsWith(`${root}${path.sep}`))
1566
+ return;
1567
+ const objectStorageClient = deps.getObjectStorageClient();
1568
+ const content = String(doc.content || '');
1569
+ const contentBuffer = Buffer.from(content, 'utf8');
1570
+ const contentSha256 = createHash('sha256').update(contentBuffer).digest('hex');
1571
+ const sizeBytes = contentBuffer.byteLength;
1572
+ const updatedAt = String(doc.updatedAt || '').trim();
1573
+ const watermarkMs = Date.parse(updatedAt);
1574
+ if (objectStorageClient) {
1575
+ try {
1576
+ await objectStorageClient.putObject(normalizedPath, contentBuffer, 'text/markdown');
1577
+ }
1578
+ catch (error) {
1579
+ deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to write document to object storage.', {
1580
+ source: 'documents.write.putObject',
1581
+ path: normalizedPath,
1582
+ error: String(error?.message || error || '')
1583
+ });
1584
+ throw error;
1585
+ }
1586
+ }
1587
+ else {
1588
+ try {
1589
+ publishWorkspaceSyncLocalFileAtomically({
1590
+ targetPath,
1591
+ body: contentBuffer,
1592
+ expectedSha256: contentSha256,
1593
+ expectedSizeBytes: sizeBytes,
1594
+ sourceUpdatedAt: Number.isFinite(watermarkMs) && watermarkMs > 0
1595
+ ? new Date(watermarkMs)
1596
+ : null,
1597
+ });
1598
+ }
1599
+ catch (error) {
1600
+ deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to publish document atomically.', {
1601
+ source: 'documents.write.atomicLocal',
1602
+ path: normalizedPath,
1603
+ error: String(error?.message || error || ''),
1604
+ ...(error instanceof WorkspaceSyncAtomicLocalPublicationError
1605
+ ? {
1606
+ code: error.code,
1607
+ boundary: error.boundary,
1608
+ published: error.published,
1609
+ }
1610
+ : {}),
1611
+ });
1612
+ throw error;
1613
+ }
1614
+ }
1615
+ const { content: _content, ...document } = doc;
1616
+ persistWorkspaceSyncDocumentMetadata(deps, {
1617
+ document,
1618
+ normalizedPath,
1619
+ contentSha256,
1620
+ sizeBytes,
1621
+ storageProvider: objectStorageClient ? 'r2' : 'local',
1622
+ workspaceId,
1623
+ options,
1624
+ });
933
1625
  }
934
1626
  export async function writeWorkspaceSyncBinaryAsset(deps, basePath, asset, workspaceId = 'default', options) {
935
1627
  const normalizedPath = deps.normalizeTaskDataRelativePath(asset.path);
@@ -941,6 +1633,10 @@ export async function writeWorkspaceSyncBinaryAsset(deps, basePath, asset, works
941
1633
  return;
942
1634
  const objectStorageClient = deps.getObjectStorageClient();
943
1635
  const buffer = Buffer.from(String(asset.contentBase64 || ''), 'base64');
1636
+ const contentSha256 = createHash('sha256').update(buffer).digest('hex');
1637
+ const sizeBytes = buffer.byteLength;
1638
+ const updatedAt = String(asset.updatedAt || '').trim();
1639
+ const watermarkMs = Date.parse(updatedAt);
944
1640
  if (objectStorageClient) {
945
1641
  try {
946
1642
  await objectStorageClient.putObject(normalizedPath, buffer, String(asset.mimeType || 'application/octet-stream').trim() || 'application/octet-stream');
@@ -951,84 +1647,121 @@ export async function writeWorkspaceSyncBinaryAsset(deps, basePath, asset, works
951
1647
  path: normalizedPath,
952
1648
  error: String(error?.message || error || '')
953
1649
  });
954
- return;
1650
+ throw error;
955
1651
  }
956
1652
  }
957
1653
  else {
958
- fs.mkdirSync(path.dirname(targetPath), { recursive: true });
959
- fs.writeFileSync(targetPath, buffer);
960
- }
961
- const updatedAt = String(asset.updatedAt || '').trim();
962
- const watermarkMs = Date.parse(updatedAt);
963
- if (!objectStorageClient && Number.isFinite(watermarkMs) && watermarkMs > 0) {
964
- const when = new Date(watermarkMs);
965
- fs.utimesSync(targetPath, when, when);
1654
+ try {
1655
+ publishWorkspaceSyncLocalFileAtomically({
1656
+ targetPath,
1657
+ body: buffer,
1658
+ expectedSha256: contentSha256,
1659
+ expectedSizeBytes: sizeBytes,
1660
+ sourceUpdatedAt: Number.isFinite(watermarkMs) && watermarkMs > 0
1661
+ ? new Date(watermarkMs)
1662
+ : null,
1663
+ });
1664
+ }
1665
+ catch (error) {
1666
+ deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to publish binary asset atomically.', {
1667
+ source: 'assets.write.atomicLocal',
1668
+ path: normalizedPath,
1669
+ error: String(error?.message || error || ''),
1670
+ ...(error instanceof WorkspaceSyncAtomicLocalPublicationError
1671
+ ? {
1672
+ code: error.code,
1673
+ boundary: error.boundary,
1674
+ published: error.published,
1675
+ }
1676
+ : {}),
1677
+ });
1678
+ throw error;
1679
+ }
966
1680
  }
967
- if (!deps.workspaceAssetStore)
968
- return;
969
- try {
970
- const existing = deps.workspaceAssetStore.getByStorageKey(normalizedPath, workspaceId);
971
- const effectiveUpdatedAt = updatedAt || new Date().toISOString();
972
- const incomingReferenceNumber = Number.isFinite(Number(asset.referenceNumber))
973
- ? Math.max(1, Math.floor(Number(asset.referenceNumber)))
974
- : null;
975
- const allowReferenceNumberReassignment = options?.allowReferenceNumberReassignment === true;
976
- const nextReferenceNumber = allowReferenceNumberReassignment
977
- ? (incomingReferenceNumber ?? existing?.referenceNumber ?? null)
978
- : (existing?.referenceNumber ?? incomingReferenceNumber ?? null);
979
- const assetRecord = deps.workspaceAssetStore.upsertAsset({
980
- assetId: String(asset.assetId || existing?.assetId || `asset-${randomUUID().replace(/-/g, '')}`),
981
- workspaceId,
982
- kind: asset.kind === 'image' ? 'image' : 'file',
983
- logicalName: typeof asset.logicalName === 'string' && asset.logicalName.trim().length > 0
984
- ? asset.logicalName.trim()
985
- : existing?.logicalName || null,
986
- originalFilename: String(asset.originalFilename || existing?.originalFilename || path.basename(normalizedPath) || 'asset').trim() || 'asset',
987
- mimeType: String(asset.mimeType || existing?.mimeType || 'application/octet-stream').trim() || 'application/octet-stream',
988
- storageProvider: objectStorageClient ? 'r2' : 'local',
989
- storageKey: normalizedPath,
990
- contentSha256: createHash('sha256').update(buffer).digest('hex'),
991
- sizeBytes: buffer.length,
992
- documentId: null,
993
- referenceNumber: nextReferenceNumber,
994
- version: null,
995
- isLatest: true,
996
- scanStatus: existing?.scanStatus || 'clean',
997
- scanEngine: existing?.scanEngine || null,
998
- scanDetails: existing?.scanDetails || null,
999
- createdByUserId: existing?.createdByUserId || null,
1000
- createdAt: existing?.createdAt || effectiveUpdatedAt,
1001
- updatedAt: effectiveUpdatedAt,
1002
- deletedAt: null,
1003
- purgeAfter: null,
1004
- allowReferenceNumberReassignment
1005
- });
1006
- const linkTarget = resolveIncomingSyncLinkTarget(asset);
1007
- reconcileWorkspaceSyncLinks(deps, {
1008
- workspaceId,
1009
- assetId: assetRecord.assetId,
1010
- taskId: linkTarget?.targetType === 'task' ? linkTarget.targetId : null,
1011
- linkTargetType: linkTarget?.targetType || null,
1012
- linkTargetId: linkTarget?.targetId || null,
1013
- displayName: typeof asset.caption === 'string' && asset.caption.trim().length > 0 ? asset.caption.trim() : null,
1014
- role: asset.linkRole === 'reference' ? 'reference' : asset.kind === 'image' ? 'image' : 'attachment',
1015
- updatedAt: effectiveUpdatedAt
1681
+ const { contentBase64: _contentBase64, ...bodylessAsset } = asset;
1682
+ persistWorkspaceSyncBinaryAssetMetadata(deps, {
1683
+ asset: bodylessAsset,
1684
+ normalizedPath,
1685
+ contentSha256,
1686
+ sizeBytes,
1687
+ storageProvider: objectStorageClient ? 'r2' : 'local',
1688
+ workspaceId,
1689
+ options,
1690
+ });
1691
+ }
1692
+ function beginWorkspaceSyncBinaryAssetMetadataDeletion(deps, input) {
1693
+ const { normalizedPath, deletedAt, workspaceId = 'default', } = input;
1694
+ if (!canDeleteWorkspaceSyncBinaryAssetMetadata(deps, normalizedPath, workspaceId)) {
1695
+ deps.recordSyncDiagnostic(workspaceId, 'apply', 'Skipped deleting a referenced AI profile avatar asset.', {
1696
+ source: 'assets.delete.aiProfileAvatarReference',
1697
+ path: normalizedPath
1016
1698
  });
1699
+ return null;
1017
1700
  }
1018
- catch (error) {
1019
- deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to persist binary asset metadata after write.', {
1020
- source: 'assets.write.upsertAsset',
1021
- path: normalizedPath,
1022
- assetId: typeof asset.assetId === 'string' ? asset.assetId : null,
1023
- kind: asset.kind,
1024
- error: String(error?.message || error || '')
1701
+ return () => {
1702
+ runWorkspaceSyncContentMetadataMutation(deps, {
1703
+ workspaceId,
1704
+ kind: 'asset',
1705
+ logicalPath: normalizedPath,
1706
+ updatedAt: deletedAt,
1707
+ }, () => {
1708
+ if (!canDeleteWorkspaceSyncBinaryAssetMetadata(deps, normalizedPath, workspaceId))
1709
+ return;
1710
+ const existingCanonicalAsset = deps.workspaceAssetStore?.getByStorageKey(normalizedPath, workspaceId) || null;
1711
+ if (!deps.workspaceAssetStore || !existingCanonicalAsset)
1712
+ return;
1713
+ if ((input.strictOrdering === true
1714
+ || hasPublishedWorkspaceSyncContentHead(deps, {
1715
+ workspaceId,
1716
+ kind: 'asset',
1717
+ logicalPath: normalizedPath,
1718
+ }))
1719
+ &&
1720
+ compareWorkspaceMutationOrdering(deletedAt, existingCanonicalAsset.updatedAt, `delete:${normalizedPath}`, existingCanonicalAsset.contentSha256) < 0)
1721
+ return;
1722
+ deps.workspaceAssetStore.markDeleted(existingCanonicalAsset.assetId, workspaceId, deletedAt);
1723
+ if (existingCanonicalAsset.kind === 'image') {
1724
+ deps.core.deleteAnnotatedAttachmentSessionsForImage({
1725
+ workspaceId,
1726
+ imageAssetId: existingCanonicalAsset.assetId,
1727
+ deletedAt,
1728
+ });
1729
+ }
1730
+ const links = deps.workspaceAssetStore.listLinksForAsset(existingCanonicalAsset.assetId, workspaceId, { includeDeleted: true });
1731
+ for (const link of links) {
1732
+ deps.workspaceAssetStore.deleteLink({
1733
+ workspaceId,
1734
+ assetId: existingCanonicalAsset.assetId,
1735
+ targetType: link.targetType,
1736
+ targetId: link.targetId,
1737
+ role: link.role
1738
+ });
1739
+ }
1025
1740
  });
1026
- }
1741
+ };
1742
+ }
1743
+ export function canDeleteWorkspaceSyncBinaryAssetMetadata(deps, normalizedPath, workspaceId = 'default') {
1744
+ return !listReferencedAiProfileAvatarAssets(deps, workspaceId).has(normalizedPath);
1745
+ }
1746
+ export function deleteWorkspaceSyncBinaryAssetMetadata(deps, input) {
1747
+ const complete = beginWorkspaceSyncBinaryAssetMetadataDeletion(deps, input);
1748
+ if (!complete)
1749
+ return false;
1750
+ complete();
1751
+ return true;
1027
1752
  }
1028
1753
  export function deleteWorkspaceSyncBinaryAsset(deps, basePath, assetPath, workspaceId = 'default') {
1029
1754
  const normalizedPath = deps.normalizeTaskDataRelativePath(assetPath);
1030
1755
  if (!normalizedPath)
1031
1756
  return;
1757
+ const deletedAt = new Date().toISOString();
1758
+ const completeMetadataDeletion = beginWorkspaceSyncBinaryAssetMetadataDeletion(deps, {
1759
+ normalizedPath,
1760
+ deletedAt,
1761
+ workspaceId,
1762
+ });
1763
+ if (!completeMetadataDeletion)
1764
+ return;
1032
1765
  const root = path.resolve(basePath);
1033
1766
  const targetPath = path.resolve(root, normalizedPath);
1034
1767
  const objectStorageClient = deps.getObjectStorageClient();
@@ -1048,29 +1781,72 @@ export function deleteWorkspaceSyncBinaryAsset(deps, basePath, assetPath, worksp
1048
1781
  error: String(error?.message || error || '')
1049
1782
  });
1050
1783
  }
1051
- if (deps.workspaceAssetStore) {
1052
- const existing = deps.workspaceAssetStore.getByStorageKey(normalizedPath, workspaceId);
1053
- if (existing) {
1054
- const deletedAt = new Date().toISOString();
1055
- deps.workspaceAssetStore.markDeleted(existing.assetId, workspaceId, deletedAt);
1056
- if (existing.kind === 'image') {
1057
- deps.core.deleteAnnotatedAttachmentSessionsForImage({
1784
+ completeMetadataDeletion();
1785
+ }
1786
+ function beginWorkspaceSyncDocumentMetadataDeletion(deps, input) {
1787
+ const { normalizedPath, deletedAt, workspaceId = 'default', } = input;
1788
+ return () => {
1789
+ runWorkspaceSyncContentMetadataMutation(deps, {
1790
+ workspaceId,
1791
+ kind: 'document',
1792
+ logicalPath: normalizedPath,
1793
+ updatedAt: deletedAt,
1794
+ }, () => {
1795
+ const existingCanonicalAsset = deps.workspaceAssetStore?.getByStorageKey(normalizedPath, workspaceId) || null;
1796
+ const current = newestDocumentMetadata(deps.core.getDocumentWatermark(workspaceId, normalizedPath), existingCanonicalAsset);
1797
+ if ((input.strictOrdering === true
1798
+ || hasPublishedWorkspaceSyncContentHead(deps, {
1058
1799
  workspaceId,
1059
- imageAssetId: existing.assetId,
1060
- deletedAt,
1061
- });
1800
+ kind: 'document',
1801
+ logicalPath: normalizedPath,
1802
+ }))
1803
+ &&
1804
+ current
1805
+ && compareWorkspaceMutationOrdering(deletedAt, current.updatedAt, `delete:${normalizedPath}`, current.contentHash) < 0)
1806
+ return;
1807
+ if (existingCanonicalAsset)
1808
+ deps.workspaceAssetStore.markDeleted(existingCanonicalAsset.assetId, workspaceId, deletedAt);
1809
+ if (input.strictWatermark === true) {
1810
+ deps.core.deleteDocumentWatermarkStrict(workspaceId, normalizedPath);
1062
1811
  }
1063
- const links = deps.workspaceAssetStore.listLinksForAsset(existing.assetId, workspaceId, { includeDeleted: true });
1064
- for (const link of links) {
1065
- deps.workspaceAssetStore.deleteLink({
1066
- workspaceId,
1067
- assetId: existing.assetId,
1068
- targetType: link.targetType,
1069
- targetId: link.targetId,
1070
- role: link.role
1071
- });
1812
+ else {
1813
+ deps.core.deleteDocumentWatermark(workspaceId, normalizedPath);
1072
1814
  }
1073
- }
1815
+ if (deps.workspaceAssetStore && existingCanonicalAsset) {
1816
+ if (existingCanonicalAsset.kind === 'image') {
1817
+ deps.core.deleteAnnotatedAttachmentSessionsForImage({
1818
+ workspaceId,
1819
+ imageAssetId: existingCanonicalAsset.assetId,
1820
+ deletedAt,
1821
+ });
1822
+ }
1823
+ const links = deps.workspaceAssetStore.listLinksForAsset(existingCanonicalAsset.assetId, workspaceId, { includeDeleted: true });
1824
+ for (const link of links) {
1825
+ deps.workspaceAssetStore.deleteLink({
1826
+ workspaceId,
1827
+ assetId: existingCanonicalAsset.assetId,
1828
+ targetType: link.targetType,
1829
+ targetId: link.targetId,
1830
+ role: link.role
1831
+ });
1832
+ }
1833
+ }
1834
+ });
1835
+ deps.workspaceDocumentSnapshotCache.get(workspaceId)?.delete(normalizedPath);
1836
+ };
1837
+ }
1838
+ export function deleteWorkspaceSyncDocumentMetadata(deps, input) {
1839
+ const complete = beginWorkspaceSyncDocumentMetadataDeletion(deps, input);
1840
+ try {
1841
+ complete();
1842
+ }
1843
+ catch (error) {
1844
+ deps.recordSyncDiagnostic(input.workspaceId || 'default', 'apply', 'Failed to delete document watermark.', {
1845
+ source: 'documents.delete.watermark',
1846
+ path: input.normalizedPath,
1847
+ error: String(error?.message || error || '')
1848
+ });
1849
+ throw error;
1074
1850
  }
1075
1851
  }
1076
1852
  export function deleteWorkspaceSyncDocument(deps, basePath, docPath, workspaceId = 'default') {
@@ -1081,6 +1857,12 @@ export function deleteWorkspaceSyncDocument(deps, basePath, docPath, workspaceId
1081
1857
  const targetPath = path.resolve(root, normalizedPath);
1082
1858
  if (targetPath !== root && !targetPath.startsWith(`${root}${path.sep}`))
1083
1859
  return;
1860
+ const deletedAt = new Date().toISOString();
1861
+ const completeMetadataDeletion = beginWorkspaceSyncDocumentMetadataDeletion(deps, {
1862
+ normalizedPath,
1863
+ deletedAt,
1864
+ workspaceId,
1865
+ });
1084
1866
  const objectStorageClient = deps.getObjectStorageClient();
1085
1867
  try {
1086
1868
  if (objectStorageClient) {
@@ -1098,31 +1880,7 @@ export function deleteWorkspaceSyncDocument(deps, basePath, docPath, workspaceId
1098
1880
  });
1099
1881
  }
1100
1882
  try {
1101
- deps.core.deleteDocumentWatermark(workspaceId, normalizedPath);
1102
- if (deps.workspaceAssetStore) {
1103
- const existing = deps.workspaceAssetStore.getByStorageKey(normalizedPath, workspaceId);
1104
- if (existing) {
1105
- const deletedAt = new Date().toISOString();
1106
- deps.workspaceAssetStore.markDeleted(existing.assetId, workspaceId, deletedAt);
1107
- if (existing.kind === 'image') {
1108
- deps.core.deleteAnnotatedAttachmentSessionsForImage({
1109
- workspaceId,
1110
- imageAssetId: existing.assetId,
1111
- deletedAt,
1112
- });
1113
- }
1114
- const links = deps.workspaceAssetStore.listLinksForAsset(existing.assetId, workspaceId, { includeDeleted: true });
1115
- for (const link of links) {
1116
- deps.workspaceAssetStore.deleteLink({
1117
- workspaceId,
1118
- assetId: existing.assetId,
1119
- targetType: link.targetType,
1120
- targetId: link.targetId,
1121
- role: link.role
1122
- });
1123
- }
1124
- }
1125
- }
1883
+ completeMetadataDeletion();
1126
1884
  }
1127
1885
  catch (error) {
1128
1886
  deps.recordSyncDiagnostic(workspaceId, 'apply', 'Failed to delete document watermark.', {
@@ -1130,11 +1888,13 @@ export function deleteWorkspaceSyncDocument(deps, basePath, docPath, workspaceId
1130
1888
  path: normalizedPath,
1131
1889
  error: String(error?.message || error || '')
1132
1890
  });
1891
+ deps.workspaceDocumentSnapshotCache.get(workspaceId)?.delete(normalizedPath);
1133
1892
  }
1134
- deps.workspaceDocumentSnapshotCache.get(workspaceId)?.delete(normalizedPath);
1135
1893
  }
1136
1894
  export function createContentSyncState(deps) {
1137
1895
  return {
1896
+ readWorkspaceSyncContentFrontier: (workspaceId = 'default') => readWorkspaceSyncContentFrontier(deps, workspaceId),
1897
+ hasWorkspaceSyncContentAfter: (workspaceId, cursor) => hasWorkspaceSyncContentAfter(deps, workspaceId, cursor),
1138
1898
  resolveCanonicalAssetSyncLinkState: (asset, workspaceId) => resolveCanonicalAssetSyncLinkState(deps, asset, workspaceId),
1139
1899
  getCanonicalSyncDocumentMetadata: (relativePath, workspaceId) => getCanonicalSyncDocumentMetadata(deps, relativePath, workspaceId),
1140
1900
  hasDocumentSyncMetadataDrift: (workspaceId, doc, _options) => hasDocumentSyncMetadataDrift(deps, workspaceId, doc),
@@ -1150,6 +1910,46 @@ export function createContentSyncState(deps) {
1150
1910
  listWorkspaceSyncBinaryAssetDeletesSnapshot: (workspaceId = 'default') => listWorkspaceSyncBinaryAssetDeletesSnapshot(deps, workspaceId),
1151
1911
  writeWorkspaceSyncDocument: (basePath, doc, workspaceId = 'default', options) => writeWorkspaceSyncDocument(deps, basePath, doc, workspaceId, options),
1152
1912
  writeWorkspaceSyncBinaryAsset: (basePath, asset, workspaceId = 'default', options) => writeWorkspaceSyncBinaryAsset(deps, basePath, asset, workspaceId, options),
1913
+ persistWorkspaceSyncDocumentMetadata: (document, workspaceId, metadata) => persistWorkspaceSyncDocumentMetadata(deps, {
1914
+ document,
1915
+ normalizedPath: document.path,
1916
+ contentSha256: metadata.contentSha256,
1917
+ sizeBytes: metadata.sizeBytes,
1918
+ storageProvider: metadata.storageProvider,
1919
+ workspaceId,
1920
+ options: {
1921
+ allowReferenceNumberReassignment: metadata.allowReferenceNumberReassignment,
1922
+ strictWatermark: metadata.strictWatermark,
1923
+ strictOrdering: metadata.strictOrdering,
1924
+ },
1925
+ }),
1926
+ persistWorkspaceSyncBinaryAssetMetadata: (asset, workspaceId, metadata) => persistWorkspaceSyncBinaryAssetMetadata(deps, {
1927
+ asset,
1928
+ normalizedPath: asset.path,
1929
+ contentSha256: metadata.contentSha256,
1930
+ sizeBytes: metadata.sizeBytes,
1931
+ storageProvider: metadata.storageProvider,
1932
+ workspaceId,
1933
+ options: {
1934
+ allowReferenceNumberReassignment: metadata.allowReferenceNumberReassignment,
1935
+ strictWatermark: metadata.strictWatermark,
1936
+ strictOrdering: metadata.strictOrdering,
1937
+ },
1938
+ }),
1939
+ deleteWorkspaceSyncBinaryAssetMetadata: (normalizedPath, workspaceId, deletedAt) => deleteWorkspaceSyncBinaryAssetMetadata(deps, {
1940
+ normalizedPath,
1941
+ workspaceId,
1942
+ deletedAt,
1943
+ strictOrdering: true,
1944
+ }),
1945
+ canDeleteWorkspaceSyncBinaryAssetMetadata: (normalizedPath, workspaceId) => canDeleteWorkspaceSyncBinaryAssetMetadata(deps, normalizedPath, workspaceId),
1946
+ deleteWorkspaceSyncDocumentMetadata: (normalizedPath, workspaceId, deletedAt) => deleteWorkspaceSyncDocumentMetadata(deps, {
1947
+ normalizedPath,
1948
+ workspaceId,
1949
+ deletedAt,
1950
+ strictWatermark: true,
1951
+ strictOrdering: true,
1952
+ }),
1153
1953
  deleteWorkspaceSyncBinaryAsset: (basePath, assetPath, workspaceId = 'default') => deleteWorkspaceSyncBinaryAsset(deps, basePath, assetPath, workspaceId),
1154
1954
  deleteWorkspaceSyncDocument: (basePath, docPath, workspaceId = 'default') => deleteWorkspaceSyncDocument(deps, basePath, docPath, workspaceId),
1155
1955
  };