@taskforcehq/taskforce 0.3.168
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.
- package/README.md +241 -0
- package/dist/Taskforce.d.ts +3 -0
- package/dist/Taskforce.js +3 -0
- package/dist/Taskforce.module.css +7587 -0
- package/dist/TaskforceCore.CategoryFallback.test.d.ts +1 -0
- package/dist/TaskforceCore.CategoryFallback.test.js +98 -0
- package/dist/TaskforceCore.d.ts +12 -0
- package/dist/TaskforceCore.js +729 -0
- package/dist/TaskforceCore.test.d.ts +1 -0
- package/dist/TaskforceCore.test.js +2132 -0
- package/dist/TaskforceScreenshot.d.ts +11 -0
- package/dist/TaskforceScreenshot.js +113 -0
- package/dist/TaskforceWidget.d.ts +6 -0
- package/dist/TaskforceWidget.js +101 -0
- package/dist/TaskforceWidget.test.d.ts +1 -0
- package/dist/TaskforceWidget.test.js +92 -0
- package/dist/UnsavedChangesRelaxed.test.d.ts +1 -0
- package/dist/UnsavedChangesRelaxed.test.js +16 -0
- package/dist/__tests__/localizationCatalogs.test.d.ts +1 -0
- package/dist/__tests__/localizationCatalogs.test.js +37 -0
- package/dist/__tests__/planParser.test.d.ts +1 -0
- package/dist/__tests__/planParser.test.js +183 -0
- package/dist/__tests__/releaseVersion.test.d.ts +1 -0
- package/dist/__tests__/releaseVersion.test.js +32 -0
- package/dist/__tests__/structuredCommentValidation.test.d.ts +1 -0
- package/dist/__tests__/structuredCommentValidation.test.js +31 -0
- package/dist/__tests__/structuredDocValidation.test.d.ts +1 -0
- package/dist/__tests__/structuredDocValidation.test.js +30 -0
- package/dist/__tests__/templateEngine.test.d.ts +1 -0
- package/dist/__tests__/templateEngine.test.js +150 -0
- package/dist/__tests__/templates.test.d.ts +1 -0
- package/dist/__tests__/templates.test.js +45 -0
- package/dist/__tests__/workflowDocumentFixtures.test.d.ts +1 -0
- package/dist/__tests__/workflowDocumentFixtures.test.js +78 -0
- package/dist/__tests__/workflowExportMatrix.test.d.ts +1 -0
- package/dist/__tests__/workflowExportMatrix.test.js +113 -0
- package/dist/__tests__/workflowExportSnapshots.test.d.ts +1 -0
- package/dist/__tests__/workflowExportSnapshots.test.js +28 -0
- package/dist/__tests__/workflowGeneration.test.d.ts +1 -0
- package/dist/__tests__/workflowGeneration.test.js +12 -0
- package/dist/__tests__/workflowSimulation.test.d.ts +1 -0
- package/dist/__tests__/workflowSimulation.test.js +113 -0
- package/dist/__tests__/workflowV2Policy.test.d.ts +1 -0
- package/dist/__tests__/workflowV2Policy.test.js +80 -0
- package/dist/api.d.ts +30 -0
- package/dist/api.js +85 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +217 -0
- package/dist/compat/priorityCompat.d.ts +2 -0
- package/dist/compat/priorityCompat.js +24 -0
- package/dist/components/features/DocumentGenerateModal.d.ts +9 -0
- package/dist/components/features/DocumentGenerateModal.js +114 -0
- package/dist/components/features/DocumentIndex.d.ts +19 -0
- package/dist/components/features/DocumentIndex.js +51 -0
- package/dist/components/features/DocumentViewer.d.ts +9 -0
- package/dist/components/features/DocumentViewer.js +253 -0
- package/dist/components/features/DocumentWorkspace.d.ts +21 -0
- package/dist/components/features/DocumentWorkspace.js +88 -0
- package/dist/components/features/TaskSettings.d.ts +209 -0
- package/dist/components/features/TaskSettings.js +500 -0
- package/dist/components/features/TaskSettings.test.d.ts +1 -0
- package/dist/components/features/TaskSettings.test.js +308 -0
- package/dist/components/features/settings/CategoryManager.d.ts +19 -0
- package/dist/components/features/settings/CategoryManager.js +113 -0
- package/dist/components/features/settings/TaxonomyEditor.d.ts +8 -0
- package/dist/components/features/settings/TaxonomyEditor.js +98 -0
- package/dist/components/features/settings/TaxonomyManager 2.d.ts +52 -0
- package/dist/components/features/settings/TaxonomyManager 2.js +75 -0
- package/dist/components/features/settings/TaxonomyManager.d.ts +54 -0
- package/dist/components/features/settings/TaxonomyManager.js +77 -0
- package/dist/components/features/settings/TypeManager.d.ts +10 -0
- package/dist/components/features/settings/TypeManager.js +50 -0
- package/dist/components/features/settings/WorkflowEditorPrototype.d.ts +15 -0
- package/dist/components/features/settings/WorkflowEditorPrototype.js +245 -0
- package/dist/components/task/TaskActionHeader.d.ts +20 -0
- package/dist/components/task/TaskActionHeader.js +13 -0
- package/dist/components/task/TaskCard.d.ts +47 -0
- package/dist/components/task/TaskCard.js +326 -0
- package/dist/components/task/TaskCard.test.d.ts +1 -0
- package/dist/components/task/TaskCard.test.js +95 -0
- package/dist/components/task/TaskContextUpload.d.ts +12 -0
- package/dist/components/task/TaskContextUpload.js +393 -0
- package/dist/components/task/TaskContextUpload.test.d.ts +1 -0
- package/dist/components/task/TaskContextUpload.test.js +189 -0
- package/dist/components/task/TaskForm.d.ts +105 -0
- package/dist/components/task/TaskForm.js +241 -0
- package/dist/components/task/TaskForm.test.d.ts +1 -0
- package/dist/components/task/TaskForm.test.js +288 -0
- package/dist/components/task/TaskKanban 2.d.ts +76 -0
- package/dist/components/task/TaskKanban 2.js +1004 -0
- package/dist/components/task/TaskKanban.d.ts +76 -0
- package/dist/components/task/TaskKanban.empty-column-drop.test.d.ts +1 -0
- package/dist/components/task/TaskKanban.empty-column-drop.test.js +66 -0
- package/dist/components/task/TaskKanban.js +1026 -0
- package/dist/components/task/TaskKanban.test.d.ts +1 -0
- package/dist/components/task/TaskKanban.test.js +46 -0
- package/dist/components/task/TaskList.d.ts +74 -0
- package/dist/components/task/TaskList.js +38 -0
- package/dist/components/task/TaskList.test.d.ts +1 -0
- package/dist/components/task/TaskList.test.js +270 -0
- package/dist/components/task/TaskScreenshotSection.d.ts +15 -0
- package/dist/components/task/TaskScreenshotSection.js +22 -0
- package/dist/components/ui/LevelSelector.d.ts +13 -0
- package/dist/components/ui/LevelSelector.js +25 -0
- package/dist/components/ui/LevelSelector.test.d.ts +1 -0
- package/dist/components/ui/LevelSelector.test.js +55 -0
- package/dist/components/ui/Markdown.d.ts +6 -0
- package/dist/components/ui/Markdown.js +94 -0
- package/dist/components/ui/Markdown.test.d.ts +1 -0
- package/dist/components/ui/Markdown.test.js +38 -0
- package/dist/components/ui/Modal.d.ts +16 -0
- package/dist/components/ui/Modal.js +49 -0
- package/dist/components/ui/MultiSelectFilter.d.ts +10 -0
- package/dist/components/ui/MultiSelectFilter.js +71 -0
- package/dist/components/ui/MultiSelectFilter.test.d.ts +1 -0
- package/dist/components/ui/MultiSelectFilter.test.js +74 -0
- package/dist/components/ui/TaxonomyDropdown.d.ts +17 -0
- package/dist/components/ui/TaxonomyDropdown.js +145 -0
- package/dist/components/ui/TaxonomyDropdown.test.d.ts +1 -0
- package/dist/components/ui/TaxonomyDropdown.test.js +130 -0
- package/dist/components/views/StandaloneLayout 2.d.ts +8 -0
- package/dist/components/views/StandaloneLayout 2.js +1660 -0
- package/dist/components/views/StandaloneLayout.d.ts +8 -0
- package/dist/components/views/StandaloneLayout.js +2117 -0
- package/dist/components/views/WidgetView.d.ts +8 -0
- package/dist/components/views/WidgetView.js +221 -0
- package/dist/config/envSchema.d.ts +28 -0
- package/dist/config/envSchema.js +374 -0
- package/dist/config/envSchema.test.d.ts +1 -0
- package/dist/config/envSchema.test.js +97 -0
- package/dist/config/surfaceBase.d.ts +2 -0
- package/dist/config/surfaceBase.js +8 -0
- package/dist/core/BulkUpdateFieldsPreview.test.d.ts +1 -0
- package/dist/core/BulkUpdateFieldsPreview.test.js +62 -0
- package/dist/core/CompletedAt.test.d.ts +1 -0
- package/dist/core/CompletedAt.test.js +44 -0
- package/dist/core/CreatedBy.test.d.ts +1 -0
- package/dist/core/CreatedBy.test.js +60 -0
- package/dist/core/EntitlementsPolicy.test.d.ts +1 -0
- package/dist/core/EntitlementsPolicy.test.js +145 -0
- package/dist/core/InitiativeTemplates.test.d.ts +1 -0
- package/dist/core/InitiativeTemplates.test.js +50 -0
- package/dist/core/ParentLifecycle.test.d.ts +1 -0
- package/dist/core/ParentLifecycle.test.js +98 -0
- package/dist/core/ScheduleFields.test.d.ts +1 -0
- package/dist/core/ScheduleFields.test.js +197 -0
- package/dist/core/SetupState.test.d.ts +1 -0
- package/dist/core/SetupState.test.js +113 -0
- package/dist/core/SystemAdmin.test.d.ts +1 -0
- package/dist/core/SystemAdmin.test.js +295 -0
- package/dist/core/TaskTaxonomyValidation.test.d.ts +1 -0
- package/dist/core/TaskTaxonomyValidation.test.js +64 -0
- package/dist/core/Taskforce.d.ts +1063 -0
- package/dist/core/Taskforce.ids.test.d.ts +1 -0
- package/dist/core/Taskforce.ids.test.js +168 -0
- package/dist/core/Taskforce.js +5981 -0
- package/dist/core/Taskforce.realtimeMutation.test.d.ts +1 -0
- package/dist/core/Taskforce.realtimeMutation.test.js +76 -0
- package/dist/core/WorkspaceDelete.test.d.ts +1 -0
- package/dist/core/WorkspaceDelete.test.js +140 -0
- package/dist/core/WorkspacePermissions.test.d.ts +1 -0
- package/dist/core/WorkspacePermissions.test.js +151 -0
- package/dist/core/WorkspacePlanMode.test.d.ts +1 -0
- package/dist/core/WorkspacePlanMode.test.js +104 -0
- package/dist/hooks/authGuardPolicy.d.ts +26 -0
- package/dist/hooks/authGuardPolicy.js +32 -0
- package/dist/hooks/authGuardPolicy.test.d.ts +1 -0
- package/dist/hooks/authGuardPolicy.test.js +76 -0
- package/dist/hooks/useDraggable.d.ts +12 -0
- package/dist/hooks/useDraggable.js +65 -0
- package/dist/hooks/useRealtimeSync.d.ts +24 -0
- package/dist/hooks/useRealtimeSync.js +275 -0
- package/dist/hooks/useRealtimeSync.test.d.ts +1 -0
- package/dist/hooks/useRealtimeSync.test.js +284 -0
- package/dist/hooks/useSyncOrchestrator.d.ts +164 -0
- package/dist/hooks/useSyncOrchestrator.js +1427 -0
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.d.ts +1 -0
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +367 -0
- package/dist/hooks/useTaskforce.d.ts +727 -0
- package/dist/hooks/useTaskforce.js +4396 -0
- package/dist/hooks/useTaskforce.priority-filters.test.d.ts +1 -0
- package/dist/hooks/useTaskforce.priority-filters.test.js +33 -0
- package/dist/hooks/useWorkspaceSyncController.d.ts +80 -0
- package/dist/hooks/useWorkspaceSyncController.js +598 -0
- package/dist/hooks/useWorkspaceSyncController.test.d.ts +1 -0
- package/dist/hooks/useWorkspaceSyncController.test.js +236 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/localization/index.d.ts +8 -0
- package/dist/localization/index.js +81 -0
- package/dist/localization/locales/en-US.d.ts +151 -0
- package/dist/localization/locales/en-US.js +150 -0
- package/dist/localization/locales/es-419.d.ts +2 -0
- package/dist/localization/locales/es-419.js +150 -0
- package/dist/localization/locales/pt-BR.d.ts +2 -0
- package/dist/localization/locales/pt-BR.js +150 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +33 -0
- package/dist/mcp/optionResolution.d.ts +14 -0
- package/dist/mcp/optionResolution.js +126 -0
- package/dist/mcp/optionResolution.test.d.ts +1 -0
- package/dist/mcp/optionResolution.test.js +39 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +1793 -0
- package/dist/mcp/structuredCommentValidation.d.ts +6 -0
- package/dist/mcp/structuredCommentValidation.js +56 -0
- package/dist/mcp/structuredDocValidation.d.ts +6 -0
- package/dist/mcp/structuredDocValidation.js +75 -0
- package/dist/migrations/billingSchemaParity.test.d.ts +1 -0
- package/dist/migrations/billingSchemaParity.test.js +46 -0
- package/dist/migrations/clientMigrations.d.ts +9 -0
- package/dist/migrations/clientMigrations.js +74 -0
- package/dist/migrations/flags.d.ts +6 -0
- package/dist/migrations/flags.js +8 -0
- package/dist/migrations/taskMigrations.d.ts +71 -0
- package/dist/migrations/taskMigrations.js +236 -0
- package/dist/migrations/taskMigrations.test.d.ts +1 -0
- package/dist/migrations/taskMigrations.test.js +34 -0
- package/dist/migrations/taskSchemaMigrations.d.ts +11 -0
- package/dist/migrations/taskSchemaMigrations.js +453 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/vite.d.ts +19 -0
- package/dist/plugins/vite.js +271 -0
- package/dist/public/android-chrome-192x192.png +0 -0
- package/dist/public/android-chrome-512x512.png +0 -0
- package/dist/public/apple-touch-icon.png +0 -0
- package/dist/public/favicon-16x16.png +0 -0
- package/dist/public/favicon-32x32.png +0 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/favicon.png +0 -0
- package/dist/public/site.webmanifest +1 -0
- package/dist/public/taskforce.png +0 -0
- package/dist/resources/templates/WORKFLOW_V2_POLICY.md +55 -0
- package/dist/resources/templates/environments/aider.yaml +14 -0
- package/dist/resources/templates/environments/antigravity.yaml +10 -0
- package/dist/resources/templates/environments/claude.yaml +10 -0
- package/dist/resources/templates/environments/cline.yaml +10 -0
- package/dist/resources/templates/environments/codex.yaml +13 -0
- package/dist/resources/templates/environments/copilot.yaml +10 -0
- package/dist/resources/templates/environments/cursor.yaml +9 -0
- package/dist/resources/templates/environments/gemini.yaml +9 -0
- package/dist/resources/templates/environments/windsurf.yaml +10 -0
- package/dist/resources/templates/workflow-sources/README.md +9 -0
- package/dist/resources/templates/workflow-sources/workflowDocs.mjs +520 -0
- package/dist/resources/templates/workflow-sources/workflowEditorOverrides.json +1 -0
- package/dist/resources/templates/workflows/collaborate.yaml +104 -0
- package/dist/resources/templates/workflows/do.yaml +82 -0
- package/dist/resources/templates/workflows/evaluate.yaml +111 -0
- package/dist/resources/templates/workflows/execute.yaml +142 -0
- package/dist/resources/templates/workflows/plan.yaml +112 -0
- package/dist/resources/templates/workflows/review.yaml +109 -0
- package/dist/runtime/capabilities.d.ts +8 -0
- package/dist/runtime/capabilities.js +16 -0
- package/dist/security/virusScan.d.ts +16 -0
- package/dist/security/virusScan.js +83 -0
- package/dist/server/auth.d.ts +51 -0
- package/dist/server/auth.js +266 -0
- package/dist/server/auth.test.d.ts +1 -0
- package/dist/server/auth.test.js +111 -0
- package/dist/server/buildInfo.d.ts +7 -0
- package/dist/server/buildInfo.js +100 -0
- package/dist/server/buildInfo.test.d.ts +1 -0
- package/dist/server/buildInfo.test.js +29 -0
- package/dist/server/cors.d.ts +7 -0
- package/dist/server/cors.js +76 -0
- package/dist/server/cors.test.d.ts +1 -0
- package/dist/server/cors.test.js +71 -0
- package/dist/server/email.d.ts +28 -0
- package/dist/server/email.js +138 -0
- package/dist/server/email.test.d.ts +1 -0
- package/dist/server/email.test.js +113 -0
- package/dist/server/index.cookieProxy.test.d.ts +1 -0
- package/dist/server/index.cookieProxy.test.js +19 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.js +757 -0
- package/dist/server/index.rateLimit.test.d.ts +1 -0
- package/dist/server/index.rateLimit.test.js +13 -0
- package/dist/server/index.test.d.ts +1 -0
- package/dist/server/index.test.js +19 -0
- package/dist/server/rateLimit.d.ts +29 -0
- package/dist/server/rateLimit.js +99 -0
- package/dist/server/rateLimit.test.d.ts +1 -0
- package/dist/server/rateLimit.test.js +107 -0
- package/dist/server/realtimeSync.auth.test.d.ts +1 -0
- package/dist/server/realtimeSync.auth.test.js +62 -0
- package/dist/server/realtimeSync.replay.test.d.ts +1 -0
- package/dist/server/realtimeSync.replay.test.js +192 -0
- package/dist/server/realtimeSync.workspaceIsolation.test.d.ts +1 -0
- package/dist/server/realtimeSync.workspaceIsolation.test.js +101 -0
- package/dist/server/realtimeSyncWs.d.ts +30 -0
- package/dist/server/realtimeSyncWs.js +257 -0
- package/dist/server/routes.billing.d.ts +15 -0
- package/dist/server/routes.billing.js +991 -0
- package/dist/server/routes.billing.test.d.ts +1 -0
- package/dist/server/routes.billing.test.js +387 -0
- package/dist/server/routes.d.ts +72 -0
- package/dist/server/routes.js +4820 -0
- package/dist/server/routes.sync.d.ts +17 -0
- package/dist/server/routes.sync.integration.test.d.ts +1 -0
- package/dist/server/routes.sync.integration.test.js +470 -0
- package/dist/server/routes.sync.js +1141 -0
- package/dist/server/routes.test.d.ts +1 -0
- package/dist/server/routes.test.js +4945 -0
- package/dist/server/runtimeMode.d.ts +4 -0
- package/dist/server/runtimeMode.js +25 -0
- package/dist/server/runtimeMode.test.d.ts +1 -0
- package/dist/server/runtimeMode.test.js +26 -0
- package/dist/server/securityHeaders.d.ts +3 -0
- package/dist/server/securityHeaders.js +25 -0
- package/dist/server/securityHeaders.test.d.ts +1 -0
- package/dist/server/securityHeaders.test.js +32 -0
- package/dist/server/smtpTransport.d.ts +21 -0
- package/dist/server/smtpTransport.js +11 -0
- package/dist/server/start.d.ts +1 -0
- package/dist/server/start.js +17 -0
- package/dist/services/formatTransformers.d.ts +29 -0
- package/dist/services/formatTransformers.js +56 -0
- package/dist/services/templateEngine.d.ts +46 -0
- package/dist/services/templateEngine.js +148 -0
- package/dist/shared/runtimeContract.d.ts +12 -0
- package/dist/shared/runtimeContract.js +23 -0
- package/dist/shared/runtimeContract.test.d.ts +1 -0
- package/dist/shared/runtimeContract.test.js +23 -0
- package/dist/soak/preflight.cli.d.ts +1 -0
- package/dist/soak/preflight.cli.js +28 -0
- package/dist/soak/preflight.d.ts +26 -0
- package/dist/soak/preflight.js +113 -0
- package/dist/soak/preflight.test.d.ts +1 -0
- package/dist/soak/preflight.test.js +39 -0
- package/dist/soak/syncSoakHarness.d.ts +6 -0
- package/dist/soak/syncSoakHarness.js +10 -0
- package/dist/storage/createDatabaseAdapter.d.ts +2 -0
- package/dist/storage/createDatabaseAdapter.js +9 -0
- package/dist/storage/databaseAdapter.d.ts +22 -0
- package/dist/storage/databaseAdapter.js +1 -0
- package/dist/storage/documentIntegrity.d.ts +28 -0
- package/dist/storage/documentIntegrity.js +103 -0
- package/dist/storage/documentPurge.d.ts +14 -0
- package/dist/storage/documentPurge.js +46 -0
- package/dist/storage/documentRegistry.d.ts +39 -0
- package/dist/storage/documentRegistry.js +115 -0
- package/dist/storage/integritySchedule.d.ts +17 -0
- package/dist/storage/integritySchedule.js +62 -0
- package/dist/storage/objectStorage.d.ts +20 -0
- package/dist/storage/objectStorage.js +15 -0
- package/dist/storage/objectStorageClient.d.ts +18 -0
- package/dist/storage/objectStorageClient.js +301 -0
- package/dist/storage/objectStorageConfig.d.ts +2 -0
- package/dist/storage/objectStorageConfig.js +45 -0
- package/dist/storage/postgresAdapter.d.ts +20 -0
- package/dist/storage/postgresAdapter.js +204 -0
- package/dist/storage/postgresWorker.d.ts +1 -0
- package/dist/storage/postgresWorker.js +110 -0
- package/dist/storage/providerConfig.d.ts +6 -0
- package/dist/storage/providerConfig.js +11 -0
- package/dist/storage/sqliteAdapter.d.ts +14 -0
- package/dist/storage/sqliteAdapter.js +28 -0
- package/dist/storage/taskAssetStore.d.ts +56 -0
- package/dist/storage/taskAssetStore.js +297 -0
- package/dist/sync/cloudSyncApi.d.ts +47 -0
- package/dist/sync/cloudSyncApi.js +138 -0
- package/dist/sync/cloudSyncApi.test.d.ts +1 -0
- package/dist/sync/cloudSyncApi.test.js +54 -0
- package/dist/sync/encryptionService.d.ts +11 -0
- package/dist/sync/encryptionService.js +61 -0
- package/dist/sync/encryptionService.test.d.ts +1 -0
- package/dist/sync/encryptionService.test.js +52 -0
- package/dist/sync/realtimeFeature.d.ts +6 -0
- package/dist/sync/realtimeFeature.js +20 -0
- package/dist/sync/realtimeFeature.test.d.ts +1 -0
- package/dist/sync/realtimeFeature.test.js +30 -0
- package/dist/sync/realtimeReconcile.d.ts +30 -0
- package/dist/sync/realtimeReconcile.js +90 -0
- package/dist/sync/realtimeReconcile.test.d.ts +1 -0
- package/dist/sync/realtimeReconcile.test.js +43 -0
- package/dist/sync/syncService.d.ts +96 -0
- package/dist/sync/syncService.js +423 -0
- package/dist/sync/syncService.test.d.ts +1 -0
- package/dist/sync/syncService.test.js +484 -0
- package/dist/sync/workspaceSyncModel.d.ts +61 -0
- package/dist/sync/workspaceSyncModel.js +136 -0
- package/dist/sync/workspaceSyncModel.test.d.ts +1 -0
- package/dist/sync/workspaceSyncModel.test.js +73 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +15 -0
- package/dist/types.d.ts +157 -0
- package/dist/types.js +41 -0
- package/dist/ui/assets/RussoOne-Regular-C3BxZIj7.ttf +0 -0
- package/dist/ui/assets/index-0W5vyCpn.css +1 -0
- package/dist/ui/assets/index-MCZuNNfn.js +23 -0
- package/dist/ui/assets/logo_white_01-0Vx-iIIv.png +0 -0
- package/dist/ui/assets/taskforce-BxLPokNB.png +0 -0
- package/dist/ui/assets/vendor-dnd-BI1K77C1.js +5 -0
- package/dist/ui/assets/vendor-icons-ZFG3SGwo.js +1 -0
- package/dist/ui/assets/vendor-markdown-CKYkQHfj.js +29 -0
- package/dist/ui/assets/vendor-react-DdIDsh7f.js +9 -0
- package/dist/ui/assets/vendor-router-BtiNU7Dl.js +3 -0
- package/dist/ui/branding/logos/logo_black_01.png +0 -0
- package/dist/ui/branding/logos/logo_black_02.png +0 -0
- package/dist/ui/branding/logos/logo_white_01.png +0 -0
- package/dist/ui/branding/logos/logo_white_02.png +0 -0
- package/dist/ui/favicon/android-chrome-192x192.png +0 -0
- package/dist/ui/favicon/android-chrome-512x512.png +0 -0
- package/dist/ui/favicon/apple-touch-icon.png +0 -0
- package/dist/ui/favicon/favicon-16x16.png +0 -0
- package/dist/ui/favicon/favicon-32x32.png +0 -0
- package/dist/ui/favicon/favicon.ico +0 -0
- package/dist/ui/favicon/favicon.png +0 -0
- package/dist/ui/favicon/site.webmanifest +1 -0
- package/dist/ui/fonts/RussoOne-Regular.ttf +0 -0
- package/dist/ui/images/taskforce.png +0 -0
- package/dist/ui/index.html +19 -0
- package/dist/utils/checklistMarkdown.d.ts +9 -0
- package/dist/utils/checklistMarkdown.js +46 -0
- package/dist/utils/constants.d.ts +21 -0
- package/dist/utils/constants.icons.test.d.ts +1 -0
- package/dist/utils/constants.icons.test.js +40 -0
- package/dist/utils/constants.js +100 -0
- package/dist/utils/contextFiles.d.ts +8 -0
- package/dist/utils/contextFiles.js +54 -0
- package/dist/utils/formatting.d.ts +5 -0
- package/dist/utils/formatting.js +30 -0
- package/dist/utils/planParser.d.ts +22 -0
- package/dist/utils/planParser.js +151 -0
- package/dist/utils/taskDragZones.d.ts +8 -0
- package/dist/utils/taskDragZones.js +14 -0
- package/dist/utils/taskDragZones.test.d.ts +1 -0
- package/dist/utils/taskDragZones.test.js +14 -0
- package/dist/utils/taskHierarchy.d.ts +4 -0
- package/dist/utils/taskHierarchy.js +69 -0
- package/dist/utils/taskHierarchy.test.d.ts +1 -0
- package/dist/utils/taskHierarchy.test.js +38 -0
- package/dist/utils/taskParenting.d.ts +3 -0
- package/dist/utils/taskParenting.js +24 -0
- package/dist/utils/taskParenting.test.d.ts +1 -0
- package/dist/utils/taskParenting.test.js +21 -0
- package/dist/utils/taskRelations.d.ts +6 -0
- package/dist/utils/taskRelations.js +24 -0
- package/dist/utils/taskRelations.test.d.ts +1 -0
- package/dist/utils/taskRelations.test.js +34 -0
- package/dist/utils/taskUtils.d.ts +2 -0
- package/dist/utils/taskUtils.js +20 -0
- package/dist/utils/taskforceApiClient.d.ts +7 -0
- package/dist/utils/taskforceApiClient.js +42 -0
- package/dist/utils/workspaceIdentity.d.ts +8 -0
- package/dist/utils/workspaceIdentity.js +47 -0
- package/dist/utils/workspaceIdentity.test.d.ts +1 -0
- package/dist/utils/workspaceIdentity.test.js +32 -0
- package/dist/utils/workspaceLifecycle.d.ts +26 -0
- package/dist/utils/workspaceLifecycle.js +69 -0
- package/dist/utils/workspaceLifecycle.test.d.ts +1 -0
- package/dist/utils/workspaceLifecycle.test.js +64 -0
- package/package.json +133 -0
- package/scripts/check-compat-boundaries.js +48 -0
- package/scripts/check-env.ts +24 -0
- package/scripts/check-localization-strings.mjs +49 -0
- package/scripts/check-runtime-boundaries.mjs +44 -0
- package/scripts/debug-global.mjs +34 -0
- package/scripts/debug-server.mjs +36 -0
- package/scripts/export-sqlite-to-postgres.mjs +125 -0
- package/scripts/generate-env-example.ts +8 -0
- package/scripts/generate-workflow-templates.mjs +134 -0
- package/scripts/mcp-stdio-adapter.mjs +160 -0
- package/scripts/postinstall.js +60 -0
- package/scripts/release-version-lib.mjs +88 -0
- package/scripts/release-version.mjs +72 -0
- package/scripts/run-dev-proxy.sh +49 -0
- package/scripts/run-e2e-realtime.sh +16 -0
- package/scripts/run-smoke.sh +23 -0
- package/scripts/run-soak.sh +29 -0
- package/scripts/test-global.js +143 -0
- package/scripts/update-homebrew-formula.sh +38 -0
- package/src/resources/templates/WORKFLOW_V2_POLICY.md +55 -0
- package/src/resources/templates/environments/aider.yaml +14 -0
- package/src/resources/templates/environments/antigravity.yaml +10 -0
- package/src/resources/templates/environments/claude.yaml +10 -0
- package/src/resources/templates/environments/cline.yaml +10 -0
- package/src/resources/templates/environments/codex.yaml +13 -0
- package/src/resources/templates/environments/copilot.yaml +10 -0
- package/src/resources/templates/environments/cursor.yaml +9 -0
- package/src/resources/templates/environments/gemini.yaml +9 -0
- package/src/resources/templates/environments/windsurf.yaml +10 -0
- package/src/resources/templates/workflow-sources/README.md +9 -0
- package/src/resources/templates/workflow-sources/workflowDocs.mjs +520 -0
- package/src/resources/templates/workflow-sources/workflowEditorOverrides.json +1 -0
- package/src/resources/templates/workflows/collaborate.yaml +104 -0
- package/src/resources/templates/workflows/do.yaml +82 -0
- package/src/resources/templates/workflows/evaluate.yaml +111 -0
- package/src/resources/templates/workflows/execute.yaml +142 -0
- package/src/resources/templates/workflows/plan.yaml +112 -0
- package/src/resources/templates/workflows/review.yaml +109 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export function useDraggable(initialPosition = { x: 0, y: 0 }) {
|
|
3
|
+
const [position, setPosition] = useState(initialPosition);
|
|
4
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
5
|
+
const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
|
|
6
|
+
const [initialTop, setInitialTop] = useState(0);
|
|
7
|
+
const modalRef = useRef(null);
|
|
8
|
+
const handleMouseDown = useCallback((e) => {
|
|
9
|
+
// Prevent drag if clicking buttons, inputs, selects, or textareas
|
|
10
|
+
const target = e.target;
|
|
11
|
+
if (target.closest('button') ||
|
|
12
|
+
target.closest('input') ||
|
|
13
|
+
target.closest('select') ||
|
|
14
|
+
target.closest('textarea') ||
|
|
15
|
+
target.closest('[role="button"]') ||
|
|
16
|
+
target.closest('.no-drag')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (modalRef.current) {
|
|
20
|
+
const rect = modalRef.current.getBoundingClientRect();
|
|
21
|
+
// We need to account for the current transform position
|
|
22
|
+
setInitialTop(rect.top - position.y);
|
|
23
|
+
}
|
|
24
|
+
setIsDragging(true);
|
|
25
|
+
setDragStart({
|
|
26
|
+
x: e.clientX - position.x,
|
|
27
|
+
y: e.clientY - position.y
|
|
28
|
+
});
|
|
29
|
+
}, [position]);
|
|
30
|
+
const handleMouseMove = useCallback((e) => {
|
|
31
|
+
if (isDragging) {
|
|
32
|
+
let newX = e.clientX - dragStart.x;
|
|
33
|
+
let newY = e.clientY - dragStart.y;
|
|
34
|
+
// Optional: Constrain Y so it doesn't go off top
|
|
35
|
+
if (newY < -initialTop) {
|
|
36
|
+
newY = -initialTop;
|
|
37
|
+
}
|
|
38
|
+
setPosition({ x: newX, y: newY });
|
|
39
|
+
}
|
|
40
|
+
}, [isDragging, dragStart, initialTop]);
|
|
41
|
+
const handleMouseUp = useCallback(() => {
|
|
42
|
+
setIsDragging(false);
|
|
43
|
+
}, []);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (isDragging) {
|
|
46
|
+
window.addEventListener('mousemove', handleMouseMove);
|
|
47
|
+
window.addEventListener('mouseup', handleMouseUp);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
51
|
+
window.removeEventListener('mouseup', handleMouseUp);
|
|
52
|
+
}
|
|
53
|
+
return () => {
|
|
54
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
55
|
+
window.removeEventListener('mouseup', handleMouseUp);
|
|
56
|
+
};
|
|
57
|
+
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
58
|
+
return {
|
|
59
|
+
position,
|
|
60
|
+
isDragging,
|
|
61
|
+
handleMouseDown,
|
|
62
|
+
modalRef,
|
|
63
|
+
setPosition
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type RealtimeReconcileTelemetry } from '../sync/realtimeReconcile';
|
|
2
|
+
export type RealtimeConnectionState = 'connected' | 'reconnecting' | 'degraded-fallback';
|
|
3
|
+
type RealtimeSignalType = 'taskforce:update' | 'taskforce:mutation' | 'taskforce:replay' | 'taskforce:replay-gap' | 'taskforce:replay-reset';
|
|
4
|
+
export interface RealtimeSyncSignal {
|
|
5
|
+
type: RealtimeSignalType;
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
eventId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UseRealtimeSyncInput {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
websocketUrl: string;
|
|
13
|
+
reconnectBaseMs?: number;
|
|
14
|
+
reconnectMaxMs?: number;
|
|
15
|
+
degradeAfterAttempts?: number;
|
|
16
|
+
replayLimit?: number;
|
|
17
|
+
onSignal?: (signal: RealtimeSyncSignal) => void;
|
|
18
|
+
onTelemetry?: (telemetry: RealtimeReconcileTelemetry) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useRealtimeSync(input: UseRealtimeSyncInput): {
|
|
21
|
+
connectionState: RealtimeConnectionState;
|
|
22
|
+
telemetry: RealtimeReconcileTelemetry;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { RealtimeReconcileTracker } from '../sync/realtimeReconcile';
|
|
3
|
+
export function useRealtimeSync(input) {
|
|
4
|
+
const { enabled, workspaceId, websocketUrl, reconnectBaseMs = 400, reconnectMaxMs = 10_000, degradeAfterAttempts = 5, replayLimit = 200, onSignal, onTelemetry } = input;
|
|
5
|
+
const [connectionState, setConnectionState] = useState('degraded-fallback');
|
|
6
|
+
const wsRef = useRef(null);
|
|
7
|
+
const reconnectTimerRef = useRef(null);
|
|
8
|
+
const reconnectAttemptRef = useRef(0);
|
|
9
|
+
const replayCursorRef = useRef('');
|
|
10
|
+
const recoveryInProgressRef = useRef(false);
|
|
11
|
+
const signalDebounceTimerRef = useRef(null);
|
|
12
|
+
const signalQueueRef = useRef(null);
|
|
13
|
+
const reconcileRef = useRef(new RealtimeReconcileTracker());
|
|
14
|
+
const [telemetry, setTelemetry] = useState({
|
|
15
|
+
accepted: 0,
|
|
16
|
+
duplicateDiscarded: 0,
|
|
17
|
+
outOfOrderDiscarded: 0,
|
|
18
|
+
invalidDiscarded: 0,
|
|
19
|
+
recoveryTriggered: 0
|
|
20
|
+
});
|
|
21
|
+
const normalizedWorkspaceId = useMemo(() => String(workspaceId || '').trim(), [workspaceId]);
|
|
22
|
+
const normalizedUrl = useMemo(() => String(websocketUrl || '').trim(), [websocketUrl]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
let disposed = false;
|
|
25
|
+
const clearReconnectTimer = () => {
|
|
26
|
+
if (reconnectTimerRef.current !== null) {
|
|
27
|
+
window.clearTimeout(reconnectTimerRef.current);
|
|
28
|
+
reconnectTimerRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const closeSocket = () => {
|
|
32
|
+
const existing = wsRef.current;
|
|
33
|
+
wsRef.current = null;
|
|
34
|
+
if (existing) {
|
|
35
|
+
try {
|
|
36
|
+
existing.close();
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// best-effort only
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const signalPriority = (type) => {
|
|
44
|
+
if (type === 'taskforce:replay-gap' || type === 'taskforce:replay-reset')
|
|
45
|
+
return 4;
|
|
46
|
+
if (type === 'taskforce:mutation' || type === 'taskforce:replay')
|
|
47
|
+
return 3;
|
|
48
|
+
return 1;
|
|
49
|
+
};
|
|
50
|
+
const queueSignal = (next) => {
|
|
51
|
+
const current = signalQueueRef.current;
|
|
52
|
+
if (current) {
|
|
53
|
+
const currentPriority = signalPriority(current.type);
|
|
54
|
+
const nextPriority = signalPriority(next.type);
|
|
55
|
+
if (nextPriority < currentPriority)
|
|
56
|
+
return;
|
|
57
|
+
if (nextPriority === currentPriority && current.eventId && !next.eventId)
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
signalQueueRef.current = next;
|
|
61
|
+
if (signalDebounceTimerRef.current !== null) {
|
|
62
|
+
window.clearTimeout(signalDebounceTimerRef.current);
|
|
63
|
+
}
|
|
64
|
+
signalDebounceTimerRef.current = window.setTimeout(() => {
|
|
65
|
+
signalDebounceTimerRef.current = null;
|
|
66
|
+
if (!signalQueueRef.current || typeof onSignal !== 'function')
|
|
67
|
+
return;
|
|
68
|
+
const queued = signalQueueRef.current;
|
|
69
|
+
signalQueueRef.current = null;
|
|
70
|
+
onSignal(queued);
|
|
71
|
+
}, 80);
|
|
72
|
+
};
|
|
73
|
+
const parseEvent = (raw) => {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(String(raw.data || ''));
|
|
76
|
+
if (!parsed || typeof parsed !== 'object')
|
|
77
|
+
return null;
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const saveReplayCursor = (event) => {
|
|
85
|
+
const serverEpoch = typeof event.serverEpoch === 'string' ? event.serverEpoch.trim() : '';
|
|
86
|
+
const seq = Number(event.seq);
|
|
87
|
+
if (!serverEpoch || !Number.isFinite(seq) || seq < 0)
|
|
88
|
+
return;
|
|
89
|
+
replayCursorRef.current = `${serverEpoch}:${Math.floor(seq)}`;
|
|
90
|
+
recoveryInProgressRef.current = false;
|
|
91
|
+
};
|
|
92
|
+
const syncTelemetry = () => {
|
|
93
|
+
const next = reconcileRef.current.getTelemetry();
|
|
94
|
+
setTelemetry(next);
|
|
95
|
+
if (typeof onTelemetry === 'function')
|
|
96
|
+
onTelemetry(next);
|
|
97
|
+
};
|
|
98
|
+
const sendReplayRequest = (socket) => {
|
|
99
|
+
const payload = {
|
|
100
|
+
type: 'taskforce:replay',
|
|
101
|
+
workspaceId: normalizedWorkspaceId,
|
|
102
|
+
limit: replayLimit
|
|
103
|
+
};
|
|
104
|
+
const cursor = replayCursorRef.current;
|
|
105
|
+
if (cursor)
|
|
106
|
+
payload.cursor = cursor;
|
|
107
|
+
socket.send(JSON.stringify(payload));
|
|
108
|
+
};
|
|
109
|
+
const scheduleReconnect = () => {
|
|
110
|
+
if (!enabled || disposed)
|
|
111
|
+
return;
|
|
112
|
+
clearReconnectTimer();
|
|
113
|
+
reconnectAttemptRef.current += 1;
|
|
114
|
+
const attempt = reconnectAttemptRef.current;
|
|
115
|
+
const baseDelay = Math.max(50, Math.floor(reconnectBaseMs));
|
|
116
|
+
const maxDelay = Math.max(baseDelay, Math.floor(reconnectMaxMs));
|
|
117
|
+
const delay = Math.min(maxDelay, baseDelay * Math.pow(2, Math.max(0, attempt - 1)));
|
|
118
|
+
setConnectionState(attempt >= degradeAfterAttempts ? 'degraded-fallback' : 'reconnecting');
|
|
119
|
+
reconnectTimerRef.current = window.setTimeout(() => {
|
|
120
|
+
if (disposed)
|
|
121
|
+
return;
|
|
122
|
+
reconnectTimerRef.current = null;
|
|
123
|
+
connect();
|
|
124
|
+
}, delay);
|
|
125
|
+
};
|
|
126
|
+
const connect = () => {
|
|
127
|
+
if (!enabled || disposed || !normalizedWorkspaceId || !normalizedUrl)
|
|
128
|
+
return;
|
|
129
|
+
closeSocket();
|
|
130
|
+
let socket;
|
|
131
|
+
try {
|
|
132
|
+
socket = new WebSocket(normalizedUrl);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
scheduleReconnect();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
wsRef.current = socket;
|
|
139
|
+
socket.addEventListener('open', () => {
|
|
140
|
+
reconnectAttemptRef.current = 0;
|
|
141
|
+
setConnectionState('connected');
|
|
142
|
+
socket.send(JSON.stringify({
|
|
143
|
+
type: 'taskforce:subscribe',
|
|
144
|
+
workspaceId: normalizedWorkspaceId
|
|
145
|
+
}));
|
|
146
|
+
sendReplayRequest(socket);
|
|
147
|
+
});
|
|
148
|
+
socket.addEventListener('message', (raw) => {
|
|
149
|
+
const event = parseEvent(raw);
|
|
150
|
+
if (!event || typeof event.type !== 'string')
|
|
151
|
+
return;
|
|
152
|
+
const eventWorkspaceId = typeof event.workspaceId === 'string'
|
|
153
|
+
? event.workspaceId.trim()
|
|
154
|
+
: normalizedWorkspaceId;
|
|
155
|
+
if (!eventWorkspaceId || eventWorkspaceId !== normalizedWorkspaceId)
|
|
156
|
+
return;
|
|
157
|
+
if (event.type === 'taskforce:update') {
|
|
158
|
+
queueSignal({
|
|
159
|
+
type: 'taskforce:update',
|
|
160
|
+
workspaceId: normalizedWorkspaceId
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (event.type === 'taskforce:mutation') {
|
|
165
|
+
const reconcile = reconcileRef.current.process({
|
|
166
|
+
eventId: event.eventId,
|
|
167
|
+
serverEpoch: event.serverEpoch,
|
|
168
|
+
seq: event.seq
|
|
169
|
+
});
|
|
170
|
+
if (!reconcile.accepted) {
|
|
171
|
+
syncTelemetry();
|
|
172
|
+
if (reconcile.shouldRecover) {
|
|
173
|
+
replayCursorRef.current = '';
|
|
174
|
+
if (!recoveryInProgressRef.current) {
|
|
175
|
+
recoveryInProgressRef.current = true;
|
|
176
|
+
queueSignal({
|
|
177
|
+
type: 'taskforce:replay-gap',
|
|
178
|
+
workspaceId: normalizedWorkspaceId
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
saveReplayCursor(event);
|
|
185
|
+
syncTelemetry();
|
|
186
|
+
queueSignal({
|
|
187
|
+
type: event.type,
|
|
188
|
+
workspaceId: normalizedWorkspaceId,
|
|
189
|
+
eventId: typeof event.eventId === 'string' ? event.eventId.trim() : undefined
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (event.type === 'taskforce:replay') {
|
|
194
|
+
const replayEvents = Array.isArray(event.events) ? event.events : [];
|
|
195
|
+
let acceptedReplayEvents = 0;
|
|
196
|
+
for (const replayEvent of replayEvents) {
|
|
197
|
+
const reconcile = reconcileRef.current.process({
|
|
198
|
+
eventId: replayEvent.eventId,
|
|
199
|
+
serverEpoch: replayEvent.serverEpoch,
|
|
200
|
+
seq: replayEvent.seq
|
|
201
|
+
});
|
|
202
|
+
if (!reconcile.accepted)
|
|
203
|
+
continue;
|
|
204
|
+
acceptedReplayEvents += 1;
|
|
205
|
+
saveReplayCursor(replayEvent);
|
|
206
|
+
}
|
|
207
|
+
recoveryInProgressRef.current = false;
|
|
208
|
+
syncTelemetry();
|
|
209
|
+
if (acceptedReplayEvents > 0 || event.truncated === true) {
|
|
210
|
+
queueSignal({ type: 'taskforce:replay', workspaceId: normalizedWorkspaceId });
|
|
211
|
+
}
|
|
212
|
+
if (event.truncated === true) {
|
|
213
|
+
sendReplayRequest(socket);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (event.type === 'taskforce:replay-gap' || event.type === 'taskforce:replay-reset') {
|
|
218
|
+
replayCursorRef.current = '';
|
|
219
|
+
if (recoveryInProgressRef.current)
|
|
220
|
+
return;
|
|
221
|
+
recoveryInProgressRef.current = true;
|
|
222
|
+
queueSignal({
|
|
223
|
+
type: event.type,
|
|
224
|
+
workspaceId: normalizedWorkspaceId
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
socket.addEventListener('close', () => {
|
|
229
|
+
if (wsRef.current === socket)
|
|
230
|
+
wsRef.current = null;
|
|
231
|
+
scheduleReconnect();
|
|
232
|
+
});
|
|
233
|
+
socket.addEventListener('error', () => {
|
|
234
|
+
try {
|
|
235
|
+
socket.close();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
// best-effort only
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
if (!enabled || !normalizedWorkspaceId || !normalizedUrl) {
|
|
243
|
+
setConnectionState('degraded-fallback');
|
|
244
|
+
clearReconnectTimer();
|
|
245
|
+
closeSocket();
|
|
246
|
+
return () => {
|
|
247
|
+
clearReconnectTimer();
|
|
248
|
+
closeSocket();
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
setConnectionState('reconnecting');
|
|
252
|
+
connect();
|
|
253
|
+
return () => {
|
|
254
|
+
disposed = true;
|
|
255
|
+
clearReconnectTimer();
|
|
256
|
+
if (signalDebounceTimerRef.current !== null) {
|
|
257
|
+
window.clearTimeout(signalDebounceTimerRef.current);
|
|
258
|
+
signalDebounceTimerRef.current = null;
|
|
259
|
+
}
|
|
260
|
+
signalQueueRef.current = null;
|
|
261
|
+
closeSocket();
|
|
262
|
+
};
|
|
263
|
+
}, [
|
|
264
|
+
enabled,
|
|
265
|
+
normalizedWorkspaceId,
|
|
266
|
+
normalizedUrl,
|
|
267
|
+
reconnectBaseMs,
|
|
268
|
+
reconnectMaxMs,
|
|
269
|
+
degradeAfterAttempts,
|
|
270
|
+
replayLimit,
|
|
271
|
+
onSignal,
|
|
272
|
+
onTelemetry
|
|
273
|
+
]);
|
|
274
|
+
return { connectionState, telemetry };
|
|
275
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
3
|
+
import { useRealtimeSync } from './useRealtimeSync';
|
|
4
|
+
class MockWebSocket {
|
|
5
|
+
static instances = [];
|
|
6
|
+
static OPEN = 1;
|
|
7
|
+
static CLOSED = 3;
|
|
8
|
+
url;
|
|
9
|
+
readyState = 0;
|
|
10
|
+
sent = [];
|
|
11
|
+
listeners = {
|
|
12
|
+
open: [],
|
|
13
|
+
message: [],
|
|
14
|
+
close: [],
|
|
15
|
+
error: []
|
|
16
|
+
};
|
|
17
|
+
constructor(url) {
|
|
18
|
+
this.url = url;
|
|
19
|
+
MockWebSocket.instances.push(this);
|
|
20
|
+
}
|
|
21
|
+
addEventListener(type, listener) {
|
|
22
|
+
this.listeners[type] = this.listeners[type] || [];
|
|
23
|
+
this.listeners[type].push(listener);
|
|
24
|
+
}
|
|
25
|
+
close() {
|
|
26
|
+
this.readyState = MockWebSocket.CLOSED;
|
|
27
|
+
this.emit('close', {});
|
|
28
|
+
}
|
|
29
|
+
send(payload) {
|
|
30
|
+
this.sent.push(payload);
|
|
31
|
+
}
|
|
32
|
+
emit(type, event) {
|
|
33
|
+
const handlers = this.listeners[type] || [];
|
|
34
|
+
handlers.forEach((handler) => handler(event));
|
|
35
|
+
}
|
|
36
|
+
open() {
|
|
37
|
+
this.readyState = MockWebSocket.OPEN;
|
|
38
|
+
this.emit('open', {});
|
|
39
|
+
}
|
|
40
|
+
message(payload) {
|
|
41
|
+
this.emit('message', { data: JSON.stringify(payload) });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
describe('useRealtimeSync', () => {
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
vi.useRealTimers();
|
|
47
|
+
vi.unstubAllGlobals();
|
|
48
|
+
MockWebSocket.instances = [];
|
|
49
|
+
});
|
|
50
|
+
it('connects, subscribes, and emits coalesced signal on update', async () => {
|
|
51
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
52
|
+
const onSignal = vi.fn();
|
|
53
|
+
const { result } = renderHook(() => useRealtimeSync({
|
|
54
|
+
enabled: true,
|
|
55
|
+
workspaceId: 'ws-1',
|
|
56
|
+
websocketUrl: 'wss://example.com/taskforce-ws',
|
|
57
|
+
onSignal
|
|
58
|
+
}));
|
|
59
|
+
expect(MockWebSocket.instances).toHaveLength(1);
|
|
60
|
+
const socket = MockWebSocket.instances[0];
|
|
61
|
+
act(() => {
|
|
62
|
+
socket.open();
|
|
63
|
+
socket.message({ type: 'taskforce:update', workspaceId: 'ws-1' });
|
|
64
|
+
socket.message({ type: 'taskforce:update', workspaceId: 'ws-1' });
|
|
65
|
+
});
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
expect(result.current.connectionState).toBe('connected');
|
|
68
|
+
});
|
|
69
|
+
await waitFor(() => {
|
|
70
|
+
expect(onSignal).toHaveBeenCalledTimes(1);
|
|
71
|
+
});
|
|
72
|
+
const outboundTypes = socket.sent.map((entry) => JSON.parse(entry).type);
|
|
73
|
+
expect(outboundTypes).toContain('taskforce:subscribe');
|
|
74
|
+
expect(outboundTypes).toContain('taskforce:replay');
|
|
75
|
+
});
|
|
76
|
+
it('reconnects with backoff and degrades after threshold', async () => {
|
|
77
|
+
vi.useFakeTimers();
|
|
78
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
79
|
+
const { result } = renderHook(() => useRealtimeSync({
|
|
80
|
+
enabled: true,
|
|
81
|
+
workspaceId: 'ws-1',
|
|
82
|
+
websocketUrl: 'wss://example.com/taskforce-ws',
|
|
83
|
+
reconnectBaseMs: 100,
|
|
84
|
+
reconnectMaxMs: 100,
|
|
85
|
+
degradeAfterAttempts: 2
|
|
86
|
+
}));
|
|
87
|
+
const first = MockWebSocket.instances[0];
|
|
88
|
+
act(() => {
|
|
89
|
+
first.open();
|
|
90
|
+
first.close();
|
|
91
|
+
});
|
|
92
|
+
expect(result.current.connectionState).toBe('reconnecting');
|
|
93
|
+
act(() => {
|
|
94
|
+
vi.advanceTimersByTime(100);
|
|
95
|
+
});
|
|
96
|
+
expect(MockWebSocket.instances).toHaveLength(2);
|
|
97
|
+
const second = MockWebSocket.instances[1];
|
|
98
|
+
act(() => {
|
|
99
|
+
second.close();
|
|
100
|
+
});
|
|
101
|
+
expect(result.current.connectionState).toBe('degraded-fallback');
|
|
102
|
+
});
|
|
103
|
+
it('does not connect when disabled', () => {
|
|
104
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
105
|
+
const { result } = renderHook(() => useRealtimeSync({
|
|
106
|
+
enabled: false,
|
|
107
|
+
workspaceId: 'ws-1',
|
|
108
|
+
websocketUrl: 'wss://example.com/taskforce-ws'
|
|
109
|
+
}));
|
|
110
|
+
expect(MockWebSocket.instances).toHaveLength(0);
|
|
111
|
+
expect(result.current.connectionState).toBe('degraded-fallback');
|
|
112
|
+
});
|
|
113
|
+
it('resumes replay from last acknowledged cursor after reconnect', async () => {
|
|
114
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
115
|
+
renderHook(() => useRealtimeSync({
|
|
116
|
+
enabled: true,
|
|
117
|
+
workspaceId: 'ws-1',
|
|
118
|
+
websocketUrl: 'wss://example.com/taskforce-ws'
|
|
119
|
+
}));
|
|
120
|
+
const first = MockWebSocket.instances[0];
|
|
121
|
+
act(() => {
|
|
122
|
+
first.open();
|
|
123
|
+
first.message({
|
|
124
|
+
type: 'taskforce:mutation',
|
|
125
|
+
workspaceId: 'ws-1',
|
|
126
|
+
serverEpoch: 'epoch-1',
|
|
127
|
+
seq: 5
|
|
128
|
+
});
|
|
129
|
+
first.close();
|
|
130
|
+
});
|
|
131
|
+
await waitFor(() => {
|
|
132
|
+
expect(MockWebSocket.instances.length).toBeGreaterThanOrEqual(2);
|
|
133
|
+
});
|
|
134
|
+
const second = MockWebSocket.instances[1];
|
|
135
|
+
act(() => {
|
|
136
|
+
second.open();
|
|
137
|
+
});
|
|
138
|
+
const replayPayloads = second.sent
|
|
139
|
+
.map((entry) => JSON.parse(entry))
|
|
140
|
+
.filter((entry) => entry.type === 'taskforce:replay');
|
|
141
|
+
expect(replayPayloads.length).toBeGreaterThanOrEqual(1);
|
|
142
|
+
expect(replayPayloads[0].cursor).toBe('epoch-1:5');
|
|
143
|
+
});
|
|
144
|
+
it('triggers full-resync signal once on replay-gap/reset until cursor recovers', async () => {
|
|
145
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
146
|
+
const onSignal = vi.fn();
|
|
147
|
+
renderHook(() => useRealtimeSync({
|
|
148
|
+
enabled: true,
|
|
149
|
+
workspaceId: 'ws-1',
|
|
150
|
+
websocketUrl: 'wss://example.com/taskforce-ws',
|
|
151
|
+
onSignal
|
|
152
|
+
}));
|
|
153
|
+
const socket = MockWebSocket.instances[0];
|
|
154
|
+
act(() => {
|
|
155
|
+
socket.open();
|
|
156
|
+
socket.message({ type: 'taskforce:replay-gap', workspaceId: 'ws-1' });
|
|
157
|
+
socket.message({ type: 'taskforce:replay-reset', workspaceId: 'ws-1' });
|
|
158
|
+
});
|
|
159
|
+
await waitFor(() => {
|
|
160
|
+
expect(onSignal).toHaveBeenCalledTimes(1);
|
|
161
|
+
});
|
|
162
|
+
expect(onSignal.mock.calls[0][0]?.type).toBe('taskforce:replay-gap');
|
|
163
|
+
act(() => {
|
|
164
|
+
socket.message({
|
|
165
|
+
type: 'taskforce:mutation',
|
|
166
|
+
workspaceId: 'ws-1',
|
|
167
|
+
serverEpoch: 'epoch-2',
|
|
168
|
+
seq: 1
|
|
169
|
+
});
|
|
170
|
+
socket.message({ type: 'taskforce:replay-reset', workspaceId: 'ws-1' });
|
|
171
|
+
});
|
|
172
|
+
await waitFor(() => {
|
|
173
|
+
expect(onSignal.mock.calls.length).toBeGreaterThanOrEqual(2);
|
|
174
|
+
});
|
|
175
|
+
expect(onSignal.mock.calls[1][0]?.type).toBe('taskforce:replay-reset');
|
|
176
|
+
});
|
|
177
|
+
it('converts out-of-order mutation delivery into replay-gap recovery signal and telemetry', async () => {
|
|
178
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
179
|
+
const onSignal = vi.fn();
|
|
180
|
+
const onTelemetry = vi.fn();
|
|
181
|
+
renderHook(() => useRealtimeSync({
|
|
182
|
+
enabled: true,
|
|
183
|
+
workspaceId: 'ws-1',
|
|
184
|
+
websocketUrl: 'wss://example.com/taskforce-ws',
|
|
185
|
+
onSignal,
|
|
186
|
+
onTelemetry
|
|
187
|
+
}));
|
|
188
|
+
const socket = MockWebSocket.instances[0];
|
|
189
|
+
act(() => {
|
|
190
|
+
socket.open();
|
|
191
|
+
socket.message({
|
|
192
|
+
type: 'taskforce:mutation',
|
|
193
|
+
workspaceId: 'ws-1',
|
|
194
|
+
eventId: 'epoch-1:1',
|
|
195
|
+
serverEpoch: 'epoch-1',
|
|
196
|
+
seq: 1
|
|
197
|
+
});
|
|
198
|
+
socket.message({
|
|
199
|
+
type: 'taskforce:mutation',
|
|
200
|
+
workspaceId: 'ws-1',
|
|
201
|
+
eventId: 'epoch-1:3',
|
|
202
|
+
serverEpoch: 'epoch-1',
|
|
203
|
+
seq: 3
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
await waitFor(() => {
|
|
207
|
+
expect(onSignal.mock.calls.some((call) => call?.[0]?.type === 'taskforce:replay-gap')).toBe(true);
|
|
208
|
+
});
|
|
209
|
+
await waitFor(() => {
|
|
210
|
+
expect(onTelemetry).toHaveBeenCalled();
|
|
211
|
+
});
|
|
212
|
+
const lastTelemetry = onTelemetry.mock.calls.at(-1)?.[0];
|
|
213
|
+
expect(lastTelemetry?.outOfOrderDiscarded).toBeGreaterThanOrEqual(1);
|
|
214
|
+
expect(lastTelemetry?.recoveryTriggered).toBeGreaterThanOrEqual(1);
|
|
215
|
+
});
|
|
216
|
+
it('prioritizes mutation over trailing update and keeps mutation eventId', async () => {
|
|
217
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
218
|
+
const onSignal = vi.fn();
|
|
219
|
+
renderHook(() => useRealtimeSync({
|
|
220
|
+
enabled: true,
|
|
221
|
+
workspaceId: 'ws-1',
|
|
222
|
+
websocketUrl: 'wss://example.com/taskforce-ws',
|
|
223
|
+
onSignal
|
|
224
|
+
}));
|
|
225
|
+
const socket = MockWebSocket.instances[0];
|
|
226
|
+
act(() => {
|
|
227
|
+
socket.open();
|
|
228
|
+
socket.message({
|
|
229
|
+
type: 'taskforce:mutation',
|
|
230
|
+
workspaceId: 'ws-1',
|
|
231
|
+
eventId: 'epoch-1:10',
|
|
232
|
+
serverEpoch: 'epoch-1',
|
|
233
|
+
seq: 10
|
|
234
|
+
});
|
|
235
|
+
socket.message({
|
|
236
|
+
type: 'taskforce:update',
|
|
237
|
+
workspaceId: 'ws-1'
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
await waitFor(() => {
|
|
241
|
+
expect(onSignal).toHaveBeenCalledTimes(1);
|
|
242
|
+
});
|
|
243
|
+
expect(onSignal.mock.calls[0][0]).toMatchObject({
|
|
244
|
+
type: 'taskforce:mutation',
|
|
245
|
+
workspaceId: 'ws-1',
|
|
246
|
+
eventId: 'epoch-1:10'
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
it('does not emit replay signal for duplicate-only replay batch', async () => {
|
|
250
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
251
|
+
const onSignal = vi.fn();
|
|
252
|
+
renderHook(() => useRealtimeSync({
|
|
253
|
+
enabled: true,
|
|
254
|
+
workspaceId: 'ws-1',
|
|
255
|
+
websocketUrl: 'wss://example.com/taskforce-ws',
|
|
256
|
+
onSignal
|
|
257
|
+
}));
|
|
258
|
+
const socket = MockWebSocket.instances[0];
|
|
259
|
+
act(() => {
|
|
260
|
+
socket.open();
|
|
261
|
+
socket.message({
|
|
262
|
+
type: 'taskforce:replay',
|
|
263
|
+
workspaceId: 'ws-1',
|
|
264
|
+
events: [
|
|
265
|
+
{ eventId: 'epoch-1:1', serverEpoch: 'epoch-1', seq: 1 }
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
socket.message({
|
|
269
|
+
type: 'taskforce:replay',
|
|
270
|
+
workspaceId: 'ws-1',
|
|
271
|
+
events: [
|
|
272
|
+
{ eventId: 'epoch-1:1', serverEpoch: 'epoch-1', seq: 1 }
|
|
273
|
+
]
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
await waitFor(() => {
|
|
277
|
+
expect(onSignal).toHaveBeenCalledTimes(1);
|
|
278
|
+
});
|
|
279
|
+
expect(onSignal.mock.calls[0][0]).toMatchObject({
|
|
280
|
+
type: 'taskforce:replay',
|
|
281
|
+
workspaceId: 'ws-1'
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
});
|