@taskforcehq/taskforce 0.3.170 → 0.3.300
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 +52 -21
- package/dist/Taskforce.module.css +3394 -5981
- package/dist/TaskforceCore.CategoryFallback.test.js +5 -2
- package/dist/TaskforceCore.filter-persistence.test.js +402 -0
- package/dist/TaskforceCore.js +388 -71
- package/dist/TaskforceCore.routing.test.js +311 -0
- package/dist/TaskforceCore.test.js +3344 -615
- package/dist/TaskforceWidget.js +3 -2
- package/dist/__tests__/localizationCatalogs.test.js +48 -31
- package/dist/__tests__/workflowSimulation.test.js +2 -2
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.d.ts +60 -0
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.js +324 -0
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.test.js +278 -0
- package/dist/annotatedAttachments/payload.d.ts +2 -0
- package/dist/annotatedAttachments/payload.js +54 -0
- package/dist/annotatedAttachments/payload.test.js +67 -0
- package/dist/annotatedAttachments/service.d.ts +49 -0
- package/dist/annotatedAttachments/service.js +121 -0
- package/dist/annotatedAttachments/types.d.ts +86 -0
- package/dist/cli.js +74 -25
- package/dist/compat/deploymentCompat.d.ts +12 -0
- package/dist/compat/deploymentCompat.js +43 -0
- package/dist/compat/workspaceSyncCompat.d.ts +6 -0
- package/dist/compat/workspaceSyncCompat.js +79 -0
- package/dist/compat/workspaceSyncCompat.test.js +87 -0
- package/dist/components/features/AgentsModule.d.ts +5 -0
- package/dist/components/features/AgentsModule.js +131 -0
- package/dist/components/features/AgentsModule.test.js +102 -0
- package/dist/components/features/AnnotatedAttachmentWorkspace.d.ts +24 -0
- package/dist/components/features/AnnotatedAttachmentWorkspace.js +1942 -0
- package/dist/components/features/AnnotatedAttachmentWorkspace.test.js +2831 -0
- package/dist/components/features/DocumentGenerateModal.js +8 -16
- package/dist/components/features/DocumentIndex.d.ts +3 -4
- package/dist/components/features/DocumentIndex.js +22 -10
- package/dist/components/features/DocumentViewer.d.ts +6 -2
- package/dist/components/features/DocumentViewer.js +1000 -18
- package/dist/components/features/DocumentWorkspace.d.ts +40 -2
- package/dist/components/features/DocumentWorkspace.js +96 -16
- package/dist/components/features/DocumentWorkspace.test.js +1202 -0
- package/dist/components/features/InitiativesModule.d.ts +22 -0
- package/dist/components/features/InitiativesModule.js +33 -0
- package/dist/components/features/TaskSettings.d.ts +41 -32
- package/dist/components/features/TaskSettings.js +798 -313
- package/dist/components/features/TaskSettings.test.js +1221 -47
- package/dist/components/features/WorkflowsModule.d.ts +27 -0
- package/dist/components/features/WorkflowsModule.js +21 -0
- package/dist/components/features/documentWorkspaceFilters.d.ts +10 -0
- package/dist/components/features/documentWorkspaceFilters.js +11 -0
- package/dist/components/features/settings/CategoryManager.d.ts +2 -0
- package/dist/components/features/settings/CategoryManager.js +15 -8
- package/dist/components/features/settings/PriorityManager.d.ts +18 -0
- package/dist/components/features/settings/PriorityManager.js +51 -0
- package/dist/components/features/settings/TaxonomyEditor.d.ts +2 -1
- package/dist/components/features/settings/TaxonomyEditor.js +41 -18
- package/dist/components/features/settings/TaxonomyLibraryManager.d.ts +26 -0
- package/dist/components/features/settings/TaxonomyLibraryManager.js +301 -0
- package/dist/components/features/settings/TaxonomyLibraryManager.test.js +141 -0
- package/dist/components/features/settings/TaxonomyManager.d.ts +35 -12
- package/dist/components/features/settings/TaxonomyManager.js +59 -27
- package/dist/components/features/settings/TypeManager.d.ts +11 -0
- package/dist/components/features/settings/TypeManager.js +48 -11
- package/dist/components/features/settings/{WorkflowEditorPrototype.d.ts → WorkflowEditor.d.ts} +2 -2
- package/dist/components/features/settings/{WorkflowEditorPrototype.js → WorkflowEditor.js} +3 -3
- package/dist/components/task/TaskActionHeader.d.ts +12 -2
- package/dist/components/task/TaskActionHeader.js +64 -8
- package/dist/components/task/TaskActionHeader.test.js +73 -0
- package/dist/components/task/TaskCard.d.ts +14 -16
- package/dist/components/task/TaskCard.js +144 -174
- package/dist/components/task/TaskCard.test.js +416 -64
- package/dist/components/task/TaskContextUpload.d.ts +6 -5
- package/dist/components/task/TaskContextUpload.js +199 -64
- package/dist/components/task/TaskContextUpload.test.js +331 -14
- package/dist/components/task/TaskForm.d.ts +23 -29
- package/dist/components/task/TaskForm.js +348 -169
- package/dist/components/task/TaskForm.test.js +419 -23
- package/dist/components/task/TaskKanban.d.ts +20 -21
- package/dist/components/task/TaskKanban.js +176 -316
- package/dist/components/task/TaskKanban.planning-drop.test.js +93 -0
- package/dist/components/task/TaskList.d.ts +22 -11
- package/dist/components/task/TaskList.js +98 -12
- package/dist/components/task/TaskList.test.js +206 -7
- package/dist/components/task/TaskReferenceBadge.d.ts +12 -0
- package/dist/components/task/TaskReferenceBadge.js +5 -0
- package/dist/components/task/TaskStatusActions.d.ts +12 -0
- package/dist/components/task/TaskStatusActions.js +18 -0
- package/dist/components/task/TaskStatusActions.test.js +45 -0
- package/dist/components/ui/ImageReferenceBadge.d.ts +12 -0
- package/dist/components/ui/ImageReferenceBadge.js +5 -0
- package/dist/components/ui/LevelSelector.d.ts +2 -1
- package/dist/components/ui/LevelSelector.js +2 -2
- package/dist/components/ui/Markdown.d.ts +1 -2
- package/dist/components/ui/Markdown.js +2 -13
- package/dist/components/ui/Modal.d.ts +3 -2
- package/dist/components/ui/Modal.js +4 -3
- package/dist/components/ui/MultiSelectFilter.d.ts +3 -1
- package/dist/components/ui/MultiSelectFilter.js +2 -2
- package/dist/components/ui/ReferenceBadgeButton.d.ts +13 -0
- package/dist/components/ui/ReferenceBadgeButton.js +6 -0
- package/dist/components/ui/TaxonomyDropdown.d.ts +7 -1
- package/dist/components/ui/TaxonomyDropdown.js +58 -23
- package/dist/components/ui/TopNoticeLayer.d.ts +7 -0
- package/dist/components/ui/TopNoticeLayer.js +14 -0
- package/dist/components/ui/TopNoticeLayer.test.js +25 -0
- package/dist/components/views/AppShellHeader.d.ts +13 -0
- package/dist/components/views/AppShellHeader.js +19 -0
- package/dist/components/views/AppShellHeader.test.js +21 -0
- package/dist/components/views/PlanComparisonPage.d.ts +73 -0
- package/dist/components/views/PlanComparisonPage.js +196 -0
- package/dist/components/views/PlanComparisonPage.test.js +251 -0
- package/dist/components/views/PlansPage.d.ts +14 -0
- package/dist/components/views/PlansPage.js +355 -0
- package/dist/components/views/StandaloneLayout.d.ts +2 -2
- package/dist/components/views/StandaloneLayout.js +2212 -1194
- package/dist/components/views/WidgetView.d.ts +2 -2
- package/dist/components/views/WidgetView.js +149 -43
- package/dist/components/views/chrome/WorkspaceChromeSections.d.ts +57 -0
- package/dist/components/views/chrome/WorkspaceChromeSections.js +38 -0
- package/dist/components/views/chrome/WorkspaceChromeSections.test.js +54 -0
- package/dist/components/views/chrome/workspaceChrome.d.ts +31 -0
- package/dist/components/views/chrome/workspaceChrome.js +108 -0
- package/dist/components/views/chrome/workspaceChrome.test.js +52 -0
- package/dist/components/views/panels/DocumentFilterToolbar.d.ts +10 -0
- package/dist/components/views/panels/DocumentFilterToolbar.js +7 -0
- package/dist/components/views/panels/DocumentFilterToolbar.test.js +19 -0
- package/dist/components/views/panels/FilterToolbar.d.ts +66 -0
- package/dist/components/views/panels/FilterToolbar.js +21 -0
- package/dist/components/views/panels/FilterToolbar.test.d.ts +1 -0
- package/dist/components/views/panels/FilterToolbar.test.js +45 -0
- package/dist/components/views/panels/FilterToolbarControls.d.ts +46 -0
- package/dist/components/views/panels/FilterToolbarControls.js +61 -0
- package/dist/components/views/panels/PlanningDrawer.d.ts +115 -0
- package/dist/components/views/panels/PlanningDrawer.js +220 -0
- package/dist/components/views/panels/ScheduleSidebar.d.ts +52 -0
- package/dist/components/views/panels/ScheduleSidebar.js +127 -0
- package/dist/components/views/panels/scheduleUtils.d.ts +14 -0
- package/dist/components/views/panels/scheduleUtils.js +79 -0
- package/dist/components/views/teamManagementAccess.d.ts +6 -0
- package/dist/components/views/teamManagementAccess.js +18 -0
- package/dist/components/views/teamManagementAccess.test.d.ts +1 -0
- package/dist/components/views/teamManagementAccess.test.js +44 -0
- package/dist/config/clientDeployment.d.ts +2 -0
- package/dist/config/clientDeployment.js +13 -0
- package/dist/config/cloudEnvironment.d.ts +15 -0
- package/dist/config/cloudEnvironment.js +60 -0
- package/dist/config/deployment.d.ts +20 -0
- package/dist/config/deployment.js +67 -0
- package/dist/config/deployment.test.d.ts +1 -0
- package/dist/config/deployment.test.js +88 -0
- package/dist/config/envSchema.js +36 -8
- package/dist/config/envSchema.test.js +28 -0
- package/dist/core/AiProfileService.d.ts +66 -0
- package/dist/core/AiProfileService.js +320 -0
- package/dist/core/AiProfileService.test.d.ts +1 -0
- package/dist/core/AiProfileService.test.js +164 -0
- package/dist/core/AiProfiles.test.d.ts +1 -0
- package/dist/core/AiProfiles.test.js +449 -0
- package/dist/core/AttachmentLinkService.d.ts +15 -0
- package/dist/core/AttachmentLinkService.js +157 -0
- package/dist/core/AuthTokenService.d.ts +44 -0
- package/dist/core/AuthTokenService.js +207 -0
- package/dist/core/CreatedBy.test.js +134 -6
- package/dist/core/DeletedTaskLifecycleService.d.ts +33 -0
- package/dist/core/DeletedTaskLifecycleService.js +158 -0
- package/dist/core/DeletedTaskTrash.test.d.ts +1 -0
- package/dist/core/DeletedTaskTrash.test.js +104 -0
- package/dist/core/EntitlementsPolicy.test.js +78 -5
- package/dist/core/GlobalSettingsService.d.ts +16 -0
- package/dist/core/GlobalSettingsService.js +370 -0
- package/dist/core/JsonBackupRuntime.test.d.ts +1 -0
- package/dist/core/JsonBackupRuntime.test.js +155 -0
- package/dist/core/McpTokenService.d.ts +118 -0
- package/dist/core/McpTokenService.js +921 -0
- package/dist/core/PlanEntitlementService.d.ts +201 -0
- package/dist/core/PlanEntitlementService.js +1442 -0
- package/dist/core/PlanVersionPolicy.test.d.ts +1 -0
- package/dist/core/PlanVersionPolicy.test.js +178 -0
- package/dist/core/PlanningEntities.test.d.ts +1 -0
- package/dist/core/PlanningEntities.test.js +95 -0
- package/dist/core/ScheduleFields.test.js +15 -19
- package/dist/core/SignupMonetizationSettings.test.d.ts +1 -0
- package/dist/core/SignupMonetizationSettings.test.js +159 -0
- package/dist/core/Stats.test.d.ts +1 -0
- package/dist/core/Stats.test.js +36 -0
- package/dist/core/SyncReconciliationService.d.ts +93 -0
- package/dist/core/SyncReconciliationService.js +406 -0
- package/dist/core/SystemAdmin.test.js +578 -13
- package/dist/core/TaskActivityService.d.ts +21 -0
- package/dist/core/TaskActivityService.js +130 -0
- package/dist/core/TaskAttachmentsCanonical.test.d.ts +1 -0
- package/dist/core/TaskAttachmentsCanonical.test.js +306 -0
- package/dist/core/TaskAuditTimeline.test.d.ts +1 -0
- package/dist/core/TaskAuditTimeline.test.js +132 -0
- package/dist/core/TaskTaxonomyValidation.test.js +338 -15
- package/dist/core/Taskforce.d.ts +930 -183
- package/dist/core/Taskforce.ids.test.js +252 -0
- package/dist/core/Taskforce.js +3848 -2532
- package/dist/core/Taskforce.mcpAuth.test.d.ts +1 -0
- package/dist/core/Taskforce.mcpAuth.test.js +343 -0
- package/dist/core/Taskforce.realtimeMutation.test.js +57 -2
- package/dist/core/TaxonomySettingsService.d.ts +18 -0
- package/dist/core/TaxonomySettingsService.js +162 -0
- package/dist/core/WorkspaceDelete.test.js +32 -13
- package/dist/core/WorkspaceLifecycleService.d.ts +11 -0
- package/dist/core/WorkspaceLifecycleService.js +88 -0
- package/dist/core/WorkspacePermissions.test.js +95 -0
- package/dist/core/WorkspacePlanMode.test.js +114 -1
- package/dist/core/WorkspacePreferenceService.d.ts +41 -0
- package/dist/core/WorkspacePreferenceService.js +246 -0
- package/dist/core/WorkspaceSyncSettings.test.d.ts +1 -0
- package/dist/core/WorkspaceSyncSettings.test.js +65 -0
- package/dist/core/__tests__/TaskAttachmentsCanonical.test.d.ts +1 -0
- package/dist/core/__tests__/TaskAttachmentsCanonical.test.js +212 -0
- package/dist/core/shared.d.ts +36 -0
- package/dist/core/shared.js +128 -0
- package/dist/core/types.d.ts +614 -0
- package/dist/core/types.js +27 -0
- package/dist/documentReviews/DocumentReviewCommentStore.d.ts +56 -0
- package/dist/documentReviews/DocumentReviewCommentStore.js +230 -0
- package/dist/documentReviews/DocumentReviewSessionStore.d.ts +52 -0
- package/dist/documentReviews/DocumentReviewSessionStore.js +193 -0
- package/dist/documentReviews/DocumentReviewSessionStore.test.d.ts +1 -0
- package/dist/documentReviews/DocumentReviewSessionStore.test.js +127 -0
- package/dist/documentReviews/service.d.ts +68 -0
- package/dist/documentReviews/service.js +210 -0
- package/dist/documentReviews/types.d.ts +58 -0
- package/dist/documentReviews/types.js +1 -0
- package/dist/hooks/auth/useAuthGuardPolicy.d.ts +2 -0
- package/dist/hooks/auth/useAuthGuardPolicy.js +1 -0
- package/dist/hooks/tasks/useCurrentTaskRelations.d.ts +15 -0
- package/dist/hooks/tasks/useCurrentTaskRelations.js +37 -0
- package/dist/hooks/tasks/useTaskActions.d.ts +3 -0
- package/dist/hooks/tasks/useTaskActions.js +2 -0
- package/dist/hooks/tasks/useTaskEditorNavigation.d.ts +65 -0
- package/dist/hooks/tasks/useTaskEditorNavigation.js +235 -0
- package/dist/hooks/tasks/useTaskFilters.d.ts +2 -0
- package/dist/hooks/tasks/useTaskFilters.js +2 -0
- package/dist/hooks/tasks/useTaskFormActions.d.ts +58 -0
- package/dist/hooks/tasks/useTaskFormActions.js +365 -0
- package/dist/hooks/tasks/useTaskRelationships.d.ts +16 -0
- package/dist/hooks/tasks/useTaskRelationships.js +64 -0
- package/dist/hooks/ui/useResourceExport.d.ts +19 -0
- package/dist/hooks/ui/useResourceExport.js +84 -0
- package/dist/hooks/ui/useSettingsModel.d.ts +203 -0
- package/dist/hooks/ui/useSettingsModel.js +125 -0
- package/dist/hooks/ui/useSettingsPersistence.d.ts +36 -0
- package/dist/hooks/ui/useSettingsPersistence.js +254 -0
- package/dist/hooks/ui/useSettingsTaxonomyManagement.d.ts +119 -0
- package/dist/hooks/ui/useSettingsTaxonomyManagement.js +536 -0
- package/dist/hooks/ui/useUiNotice.d.ts +1 -0
- package/dist/hooks/ui/useUiNotice.js +1 -0
- package/dist/hooks/ui/useWorkflowTemplates.d.ts +37 -0
- package/dist/hooks/ui/useWorkflowTemplates.js +111 -0
- package/dist/hooks/ui/useZenMode.d.ts +5 -0
- package/dist/hooks/ui/useZenMode.js +32 -0
- package/dist/hooks/useFilterSort.d.ts +60 -0
- package/dist/hooks/useFilterSort.js +362 -0
- package/dist/hooks/useFilterSort.test.d.ts +1 -0
- package/dist/hooks/useFilterSort.test.js +333 -0
- package/dist/hooks/useRealtimeSync.d.ts +1 -0
- package/dist/hooks/useRealtimeSync.js +24 -9
- package/dist/hooks/useRealtimeSync.test.js +28 -1
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.d.ts +1 -0
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +34 -0
- package/dist/hooks/useSyncOrchestrator.d.ts +65 -103
- package/dist/hooks/useSyncOrchestrator.js +1538 -670
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +700 -174
- package/dist/hooks/useTaskData.d.ts +35 -0
- package/dist/hooks/useTaskData.js +239 -0
- package/dist/hooks/useTaskData.test.d.ts +1 -0
- package/dist/hooks/useTaskData.test.js +119 -0
- package/dist/hooks/useTaskMutations.d.ts +46 -0
- package/dist/hooks/useTaskMutations.js +472 -0
- package/dist/hooks/useTaskMutations.test.d.ts +1 -0
- package/dist/hooks/useTaskMutations.test.js +80 -0
- package/dist/hooks/useTaskforce.contract.test.d.ts +1 -0
- package/dist/hooks/useTaskforce.contract.test.js +7 -0
- package/dist/hooks/useTaskforce.d.ts +260 -295
- package/dist/hooks/useTaskforce.js +1954 -2623
- package/dist/hooks/useTaskforce.priority-filters.test.js +6 -11
- package/dist/hooks/useTaskforce.sync-behavior.test.d.ts +1 -0
- package/dist/hooks/useTaskforce.sync-behavior.test.js +1120 -0
- package/dist/hooks/useUiNotice.d.ts +16 -0
- package/dist/hooks/useUiNotice.js +49 -0
- package/dist/hooks/useWorkspaceSyncController.d.ts +23 -46
- package/dist/hooks/useWorkspaceSyncController.js +280 -461
- package/dist/hooks/useWorkspaceSyncController.test.js +106 -199
- package/dist/hooks/workspace/useTaskforceApiRouting.d.ts +8 -0
- package/dist/hooks/workspace/useTaskforceApiRouting.js +91 -0
- package/dist/hooks/workspace/useTaskforceApiRouting.test.d.ts +1 -0
- package/dist/hooks/workspace/useTaskforceApiRouting.test.js +60 -0
- package/dist/hooks/workspace/useWorkspaceSyncController.d.ts +1 -0
- package/dist/hooks/workspace/useWorkspaceSyncController.js +1 -0
- package/dist/hooks/workspace/workspaceLocalState.d.ts +30 -0
- package/dist/hooks/workspace/workspaceLocalState.js +101 -0
- package/dist/localization/locales/en-US.d.ts +1 -8
- package/dist/localization/locales/en-US.js +4 -11
- package/dist/localization/locales/es-419.js +2 -9
- package/dist/localization/locales/pt-BR.js +2 -9
- package/dist/localization/localizationCatalogs.test.d.ts +1 -0
- package/dist/localization/localizationCatalogs.test.js +37 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +9 -15
- package/dist/mcp/clientIntegrations.d.ts +33 -0
- package/dist/mcp/clientIntegrations.js +199 -0
- package/dist/mcp/clientIntegrations.test.d.ts +1 -0
- package/dist/mcp/clientIntegrations.test.js +110 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/optionResolution.test.js +6 -2
- package/dist/mcp/runtime.d.ts +120 -0
- package/dist/mcp/runtime.js +5668 -0
- package/dist/mcp/runtime.test.d.ts +1 -0
- package/dist/mcp/runtime.test.js +3293 -0
- package/dist/mcp/server.js +2 -1793
- package/dist/mcp/structuredCommentValidation.test.d.ts +1 -0
- package/dist/{__tests__ → mcp}/structuredCommentValidation.test.js +1 -1
- package/dist/mcp/structuredDocValidation.js +1 -2
- package/dist/mcp/structuredDocValidation.test.d.ts +1 -0
- package/dist/{__tests__ → mcp}/structuredDocValidation.test.js +9 -4
- package/dist/mcp/toolRegistry.d.ts +570 -0
- package/dist/mcp/toolRegistry.js +90 -0
- package/dist/mcp/toolRegistry.test.d.ts +1 -0
- package/dist/mcp/toolRegistry.test.js +30 -0
- package/dist/migrations/billingSchemaParity.test.js +111 -0
- package/dist/migrations/taskSchemaMigrations.d.ts +5 -0
- package/dist/migrations/taskSchemaMigrations.js +681 -39
- package/dist/migrations/taskSchemaMigrations.test.d.ts +1 -0
- package/dist/migrations/taskSchemaMigrations.test.js +210 -0
- package/dist/plugins/vite.js +13 -7
- package/dist/public/apple-touch-icon.png +0 -0
- package/dist/public/archive/phoenix/apple-touch-icon.png +0 -0
- package/dist/public/archive/phoenix/favicon.ico +0 -0
- package/dist/public/archive/phoenix/site.webmanifest +1 -0
- package/dist/public/favicon-96x96.png +0 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/favicon.svg +17 -0
- package/dist/public/site.webmanifest +21 -1
- package/dist/public/web-app-manifest-192x192.png +0 -0
- package/dist/public/web-app-manifest-512x512.png +0 -0
- package/dist/releaseVersion.test.d.ts +1 -0
- package/dist/{__tests__/releaseVersion.test.js → releaseVersion.test.js} +1 -1
- package/dist/resources/templates/WORKFLOW_V2_POLICY.md +1 -1
- package/dist/resources/templates/workflow-sources/workflowDocs.mjs +62 -52
- package/dist/resources/templates/workflows/collaborate.yaml +11 -5
- package/dist/resources/templates/workflows/do.yaml +8 -2
- package/dist/resources/templates/workflows/evaluate.yaml +13 -7
- package/dist/resources/templates/workflows/execute.yaml +40 -23
- package/dist/resources/templates/workflows/plan.yaml +15 -8
- package/dist/resources/templates/workflows/review.yaml +14 -8
- package/dist/runtime/appGateDefinitions.d.ts +32 -0
- package/dist/runtime/appGateDefinitions.js +32 -0
- package/dist/runtime/appGates.d.ts +29 -0
- package/dist/runtime/appGates.js +53 -0
- package/dist/runtime/appGates.test.d.ts +1 -0
- package/dist/runtime/appGates.test.js +42 -0
- package/dist/runtime/migrationFlags.d.ts +1 -0
- package/dist/runtime/migrationFlags.js +1 -0
- package/dist/server/annotatedAttachmentsRoutes.test.d.ts +1 -0
- package/dist/server/annotatedAttachmentsRoutes.test.js +473 -0
- package/dist/server/auth.js +14 -2
- package/dist/server/auth.test.js +21 -1
- package/dist/server/cors.js +11 -5
- package/dist/server/cors.test.js +6 -0
- package/dist/server/documentReviewRoutes.test.d.ts +1 -0
- package/dist/server/documentReviewRoutes.test.js +157 -0
- package/dist/server/index.cookieProxy.test.js +46 -1
- package/dist/server/index.d.ts +20 -0
- package/dist/server/index.js +168 -41
- package/dist/server/index.rateLimit.test.js +6 -0
- package/dist/server/index.test.js +133 -2
- package/dist/server/mockStripe.d.ts +72 -0
- package/dist/server/mockStripe.js +357 -0
- package/dist/server/realtimeSyncWs.js +4 -0
- package/dist/server/routes/admin.d.ts +114 -0
- package/dist/server/routes/admin.js +2226 -0
- package/dist/server/routes/annotatedAttachments.d.ts +24 -0
- package/dist/server/routes/annotatedAttachments.js +235 -0
- package/dist/server/routes/auth.d.ts +61 -0
- package/dist/server/routes/auth.js +1296 -0
- package/dist/server/{routes.billing.d.ts → routes/billing.d.ts} +3 -2
- package/dist/server/routes/billing.js +2001 -0
- package/dist/server/routes/billing.test.d.ts +1 -0
- package/dist/server/routes/billing.test.js +1631 -0
- package/dist/server/routes/documentReviews.d.ts +11 -0
- package/dist/server/routes/documentReviews.js +191 -0
- package/dist/server/routes/documents.d.ts +118 -0
- package/dist/server/routes/documents.js +1113 -0
- package/dist/server/routes/resources.d.ts +25 -0
- package/dist/server/routes/resources.js +225 -0
- package/dist/server/routes/shared.d.ts +35 -0
- package/dist/server/routes/shared.js +305 -0
- package/dist/server/routes/shared.test.d.ts +1 -0
- package/dist/server/routes/shared.test.js +32 -0
- package/dist/server/{routes.sync.d.ts → routes/sync.d.ts} +5 -5
- package/dist/server/routes/sync.integration.test.d.ts +1 -0
- package/dist/server/routes/sync.integration.test.js +2003 -0
- package/dist/server/routes/sync.js +3143 -0
- package/dist/server/routes/tasks.d.ts +72 -0
- package/dist/server/routes/tasks.js +1252 -0
- package/dist/server/routes/workspaces.d.ts +32 -0
- package/dist/server/routes/workspaces.js +307 -0
- package/dist/server/routes.d.ts +8 -9
- package/dist/server/routes.js +968 -4092
- package/dist/server/routes.test.js +9043 -2415
- package/dist/server/runtimeMode.d.ts +1 -1
- package/dist/server/runtimeMode.js +3 -18
- package/dist/server/runtimeMode.test.js +3 -3
- package/dist/server/securityHeaders.d.ts +1 -1
- package/dist/server/securityHeaders.js +65 -6
- package/dist/server/securityHeaders.test.js +40 -2
- package/dist/services/templateEngine.test.d.ts +1 -0
- package/dist/{__tests__ → services}/templateEngine.test.js +1 -1
- package/dist/services/templates.test.d.ts +1 -0
- package/dist/{__tests__ → services}/templates.test.js +1 -1
- package/dist/services/workflowDocumentFixtures.test.d.ts +1 -0
- package/dist/{__tests__ → services}/workflowDocumentFixtures.test.js +4 -4
- package/dist/services/workflowExportMatrix.test.d.ts +1 -0
- package/dist/{__tests__ → services}/workflowExportMatrix.test.js +1 -1
- package/dist/services/workflowExportSnapshots.test.d.ts +1 -0
- package/dist/services/workflowGeneration.test.d.ts +1 -0
- package/dist/services/workflowSimulation.test.d.ts +1 -0
- package/dist/services/workflowSimulation.test.js +113 -0
- package/dist/services/workflowV2Policy.test.d.ts +1 -0
- package/dist/{__tests__ → services}/workflowV2Policy.test.js +2 -2
- package/dist/shared/aiProfileSurfaceType.d.ts +9 -0
- package/dist/shared/aiProfileSurfaceType.js +49 -0
- package/dist/shared/customTaxonomyLibrary.d.ts +11 -0
- package/dist/shared/customTaxonomyLibrary.js +276 -0
- package/dist/shared/customTaxonomyLibrary.test.d.ts +1 -0
- package/dist/shared/customTaxonomyLibrary.test.js +20 -0
- package/dist/shared/taxonomyCatalog.d.ts +19 -0
- package/dist/shared/taxonomyCatalog.js +36 -0
- package/dist/shared/taxonomyDefaults.d.ts +29 -0
- package/dist/shared/taxonomyDefaults.js +26 -0
- package/dist/shared/taxonomyLibrary.d.ts +15 -0
- package/dist/shared/taxonomyLibrary.js +98 -0
- package/dist/shared/taxonomyLibrary.test.d.ts +1 -0
- package/dist/shared/taxonomyLibrary.test.js +26 -0
- package/dist/shared/taxonomyState.d.ts +36 -0
- package/dist/shared/taxonomyState.js +73 -0
- package/dist/shared/taxonomyState.test.d.ts +1 -0
- package/dist/shared/taxonomyState.test.js +71 -0
- package/dist/shared/workflowDefaults.d.ts +9 -0
- package/dist/shared/workflowDefaults.js +11 -0
- package/dist/storage/documentIntegrity.d.ts +2 -0
- package/dist/storage/documentIntegrity.js +34 -17
- package/dist/storage/documentPurge.d.ts +2 -1
- package/dist/storage/documentPurge.js +35 -8
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/objectStorage.d.ts +1 -1
- package/dist/storage/objectStorageClient.d.ts +6 -4
- package/dist/storage/objectStorageClient.js +77 -29
- package/dist/storage/objectStorageClient.test.d.ts +1 -0
- package/dist/storage/objectStorageClient.test.js +57 -0
- package/dist/storage/objectStorageConfig.js +3 -1
- package/dist/storage/objectStorageConfig.test.d.ts +1 -0
- package/dist/storage/objectStorageConfig.test.js +38 -0
- package/dist/storage/postgresAdapter.d.ts +5 -0
- package/dist/storage/postgresAdapter.js +2 -2
- package/dist/storage/postgresAdapter.test.d.ts +1 -0
- package/dist/storage/postgresAdapter.test.js +29 -0
- package/dist/storage/taskAssetStore.d.ts +7 -4
- package/dist/storage/taskAssetStore.js +65 -60
- package/dist/storage/workspaceAssetStore.d.ts +122 -0
- package/dist/storage/workspaceAssetStore.js +496 -0
- package/dist/storage/workspaceAssetStore.test.d.ts +1 -0
- package/dist/storage/workspaceAssetStore.test.js +501 -0
- package/dist/sync/cloudSyncApi.d.ts +33 -2
- package/dist/sync/cloudSyncApi.js +37 -15
- package/dist/sync/cloudSyncApi.test.js +60 -3
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +3 -0
- package/dist/sync/syncService.d.ts +25 -0
- package/dist/sync/syncService.js +184 -16
- package/dist/sync/syncService.test.js +289 -25
- package/dist/sync/workspaceRepair.d.ts +114 -0
- package/dist/sync/workspaceRepair.js +566 -0
- package/dist/sync/workspaceSyncModel.d.ts +230 -2
- package/dist/sync/workspaceSyncModel.js +456 -17
- package/dist/sync/workspaceSyncModel.test.js +642 -0
- package/dist/sync/workspaceSyncState.d.ts +12 -0
- package/dist/sync/workspaceSyncState.js +12 -0
- package/dist/sync/workspaceSyncSurface.d.ts +33 -0
- package/dist/sync/workspaceSyncSurface.js +74 -0
- package/dist/types.d.ts +143 -18
- package/dist/types.js +9 -24
- package/dist/ui/assets/AgentsModule-TVmCgizS.js +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BaS2VwIr.css +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-CAyhnPeR.js +3 -0
- package/dist/ui/assets/DocumentWorkspace-BOCw5e4D.js +250 -0
- package/dist/ui/assets/DocumentWorkspace-C_8T8oz-.css +1 -0
- package/dist/ui/assets/InitiativesModule-CN0r02Oi.js +1 -0
- package/dist/ui/assets/PlansPage-BlVC_lRq.css +1 -0
- package/dist/ui/assets/PlansPage-FcQSNLZd.js +1 -0
- package/dist/ui/assets/TaskSettings-BwB9NtmJ.css +1 -0
- package/dist/ui/assets/TaskSettings-Cw5zYD1L.js +8 -0
- package/dist/ui/assets/WorkflowsModule-CY9R2zPB.js +5 -0
- package/dist/ui/assets/index-Bzqy5QGm.js +6 -0
- package/dist/ui/assets/index-DxRiI3tY.css +1 -0
- package/dist/ui/assets/vendor-dnd-DRzYolkg.js +5 -0
- package/dist/ui/assets/{vendor-icons-ZFG3SGwo.js → vendor-icons-QZyhEwgT.js} +1 -1
- package/dist/ui/assets/{vendor-markdown-CKYkQHfj.js → vendor-markdown-BUxTU7dS.js} +1 -1
- package/dist/ui/assets/vendor-react-CKJs5o3c.js +61 -0
- package/dist/ui/assets/vendor-router-BbWMxlnO.js +3 -0
- package/dist/ui/branding/logos/logo.png +0 -0
- package/dist/ui/branding/logos/logo_dark.svg +27 -0
- package/dist/ui/branding/logos/logo_favicon.svg +35 -0
- package/dist/ui/branding/logos/logo_light.svg +27 -0
- package/dist/ui/favicon/apple-touch-icon.png +0 -0
- package/dist/ui/favicon/archive/phoenix/apple-touch-icon.png +0 -0
- package/dist/ui/favicon/archive/phoenix/favicon.ico +0 -0
- package/dist/ui/favicon/archive/phoenix/site.webmanifest +1 -0
- package/dist/ui/favicon/favicon-96x96.png +0 -0
- package/dist/ui/favicon/favicon.ico +0 -0
- package/dist/ui/favicon/favicon.svg +17 -0
- package/dist/ui/favicon/site.webmanifest +21 -1
- package/dist/ui/favicon/web-app-manifest-192x192.png +0 -0
- package/dist/ui/favicon/web-app-manifest-512x512.png +0 -0
- package/dist/ui/index.html +10 -7
- package/dist/ui/product/screen_01.png +0 -0
- package/dist/ui/product/screen_02.png +0 -0
- package/dist/ui/product/screen_03.png +0 -0
- package/dist/utils/annotatedAttachments.d.ts +20 -0
- package/dist/utils/annotatedAttachments.js +74 -0
- package/dist/utils/annotatedAttachments.test.d.ts +1 -0
- package/dist/utils/annotatedAttachments.test.js +108 -0
- package/dist/utils/assignees.d.ts +26 -0
- package/dist/utils/assignees.js +132 -0
- package/dist/utils/canonicalAssetKind.d.ts +16 -0
- package/dist/utils/canonicalAssetKind.js +39 -0
- package/dist/utils/canonicalAssetKind.test.d.ts +1 -0
- package/dist/utils/canonicalAssetKind.test.js +24 -0
- package/dist/utils/coalescedRefresh.d.ts +5 -0
- package/dist/utils/coalescedRefresh.js +16 -0
- package/dist/utils/coalescedRefresh.test.d.ts +1 -0
- package/dist/utils/coalescedRefresh.test.js +30 -0
- package/dist/utils/constants.d.ts +16 -3
- package/dist/utils/constants.icons.test.js +2 -1
- package/dist/utils/constants.js +70 -13
- package/dist/utils/contextAssetEvents.d.ts +7 -0
- package/dist/utils/contextAssetEvents.js +6 -0
- package/dist/utils/contextFiles.d.ts +14 -3
- package/dist/utils/contextFiles.js +40 -8
- package/dist/utils/documentManagerApi.d.ts +6 -0
- package/dist/utils/documentManagerApi.js +19 -0
- package/dist/utils/documentNames.d.ts +24 -0
- package/dist/utils/documentNames.js +91 -0
- package/dist/utils/documentReferences.d.ts +9 -0
- package/dist/utils/documentReferences.js +11 -0
- package/dist/utils/entityReferences.d.ts +9 -0
- package/dist/utils/entityReferences.js +32 -0
- package/dist/utils/imageReferences.d.ts +9 -0
- package/dist/utils/imageReferences.js +11 -0
- package/dist/utils/planParser.d.ts +2 -2
- package/dist/utils/planParser.js +11 -11
- package/dist/utils/planParser.test.d.ts +1 -0
- package/dist/{__tests__ → utils}/planParser.test.js +22 -22
- package/dist/utils/planningReferences.d.ts +17 -0
- package/dist/utils/planningReferences.js +30 -0
- package/dist/utils/planningReferences.test.d.ts +1 -0
- package/dist/utils/planningReferences.test.js +17 -0
- package/dist/utils/taskActivity.d.ts +9 -0
- package/dist/utils/taskActivity.js +147 -0
- package/dist/utils/taskActivity.test.d.ts +1 -0
- package/dist/utils/taskActivity.test.js +34 -0
- package/dist/utils/taskDraftDefaults.d.ts +21 -0
- package/dist/utils/taskDraftDefaults.js +40 -0
- package/dist/utils/taskDraftDefaults.test.d.ts +1 -0
- package/dist/utils/taskDraftDefaults.test.js +34 -0
- package/dist/utils/taskNormalization.d.ts +25 -0
- package/dist/utils/taskNormalization.js +161 -0
- package/dist/utils/taskNormalization.test.d.ts +1 -0
- package/dist/utils/taskNormalization.test.js +158 -0
- package/dist/utils/taskReferences.d.ts +5 -0
- package/dist/utils/taskReferences.js +11 -0
- package/dist/utils/taskforceApiClient.d.ts +2 -0
- package/dist/utils/taskforceApiClient.js +101 -3
- package/dist/utils/taskforceApiClient.test.d.ts +1 -0
- package/dist/utils/taskforceApiClient.test.js +44 -0
- package/dist/utils/taxonomyFilterOptions.d.ts +2 -0
- package/dist/utils/taxonomyFilterOptions.js +17 -0
- package/dist/utils/taxonomyFormDefaults.d.ts +3 -0
- package/dist/utils/taxonomyFormDefaults.js +28 -0
- package/dist/utils/taxonomyFormDefaults.test.d.ts +1 -0
- package/dist/utils/taxonomyFormDefaults.test.js +63 -0
- package/dist/utils/taxonomyLifecycle.d.ts +3 -0
- package/dist/utils/taxonomyLifecycle.js +17 -0
- package/dist/utils/taxonomySorting.d.ts +7 -0
- package/dist/utils/taxonomySorting.js +74 -0
- package/dist/utils/theme.d.ts +15 -0
- package/dist/utils/theme.js +23 -0
- package/dist/utils/uiNotice.d.ts +7 -0
- package/dist/utils/uiNotice.js +6 -0
- package/dist/utils/uiNotice.test.d.ts +1 -0
- package/dist/utils/uiNotice.test.js +18 -0
- package/dist/utils/workspaceIdentity.d.ts +14 -0
- package/dist/utils/workspaceIdentity.js +21 -0
- package/dist/utils/workspaceIdentity.test.js +30 -1
- package/dist/utils/workspaceSyncPresentation.d.ts +20 -0
- package/dist/utils/workspaceSyncPresentation.js +21 -0
- package/dist/utils/workspaceSyncPresentation.test.d.ts +1 -0
- package/dist/utils/workspaceSyncPresentation.test.js +36 -0
- package/package.json +28 -23
- package/scripts/bootstrap-playwright-auth.mjs +155 -0
- package/scripts/check-compat-boundaries.mjs +41 -0
- package/scripts/check-env.ts +9 -2
- package/scripts/debug-login.mjs +32 -0
- package/scripts/migrate-planning-model.ts +233 -0
- package/scripts/migrate-task-data-assets.mjs +408 -0
- package/scripts/playwright-auth.sh +11 -0
- package/scripts/run-dev-proxy.sh +2 -0
- package/scripts/update-homebrew-formula.sh +2 -2
- package/scripts/with-esbuild.sh +11 -0
- package/src/resources/templates/WORKFLOW_V2_POLICY.md +1 -1
- package/src/resources/templates/workflow-sources/workflowDocs.mjs +62 -52
- package/src/resources/templates/workflows/collaborate.yaml +11 -5
- package/src/resources/templates/workflows/do.yaml +8 -2
- package/src/resources/templates/workflows/evaluate.yaml +13 -7
- package/src/resources/templates/workflows/execute.yaml +40 -23
- package/src/resources/templates/workflows/plan.yaml +15 -8
- package/src/resources/templates/workflows/review.yaml +14 -8
- package/dist/TaskforceScreenshot.d.ts +0 -11
- package/dist/TaskforceScreenshot.js +0 -113
- package/dist/compat/priorityCompat.d.ts +0 -2
- package/dist/compat/priorityCompat.js +0 -24
- package/dist/components/features/settings/TaxonomyManager 2.d.ts +0 -52
- package/dist/components/features/settings/TaxonomyManager 2.js +0 -75
- package/dist/components/task/TaskKanban 2.d.ts +0 -76
- package/dist/components/task/TaskKanban 2.js +0 -1004
- package/dist/components/task/TaskScreenshotSection.d.ts +0 -15
- package/dist/components/task/TaskScreenshotSection.js +0 -22
- package/dist/components/views/StandaloneLayout 2.d.ts +0 -8
- package/dist/components/views/StandaloneLayout 2.js +0 -1660
- package/dist/core/InitiativeTemplates.test.js +0 -50
- package/dist/core/ParentLifecycle.test.js +0 -98
- package/dist/migrations/clientMigrations.d.ts +0 -9
- package/dist/migrations/clientMigrations.js +0 -74
- package/dist/migrations/flags.d.ts +0 -6
- package/dist/migrations/flags.js +0 -8
- package/dist/migrations/taskMigrations.d.ts +0 -71
- package/dist/migrations/taskMigrations.js +0 -236
- package/dist/migrations/taskMigrations.test.js +0 -34
- package/dist/server/routes.billing.js +0 -991
- package/dist/server/routes.billing.test.js +0 -387
- package/dist/server/routes.sync.integration.test.js +0 -470
- package/dist/server/routes.sync.js +0 -1141
- package/dist/soak/syncSoakHarness.d.ts +0 -6
- package/dist/soak/syncSoakHarness.js +0 -10
- package/dist/ui/assets/index-0W5vyCpn.css +0 -1
- package/dist/ui/assets/index-MCZuNNfn.js +0 -23
- package/dist/ui/assets/logo_white_01-0Vx-iIIv.png +0 -0
- package/dist/ui/assets/vendor-dnd-BI1K77C1.js +0 -5
- package/dist/ui/assets/vendor-react-DdIDsh7f.js +0 -9
- package/dist/ui/assets/vendor-router-BtiNU7Dl.js +0 -3
- package/dist/utils/taskHierarchy.d.ts +0 -4
- package/dist/utils/taskHierarchy.js +0 -69
- package/dist/utils/taskHierarchy.test.js +0 -38
- package/dist/utils/taskParenting.d.ts +0 -3
- package/dist/utils/taskParenting.js +0 -24
- package/dist/utils/taskParenting.test.js +0 -21
- package/dist/utils/taskRelations.d.ts +0 -6
- package/dist/utils/taskRelations.js +0 -24
- package/dist/utils/taskRelations.test.js +0 -34
- package/scripts/check-compat-boundaries.js +0 -48
- /package/dist/{__tests__/planParser.test.d.ts → TaskforceCore.filter-persistence.test.d.ts} +0 -0
- /package/dist/{__tests__/releaseVersion.test.d.ts → TaskforceCore.routing.test.d.ts} +0 -0
- /package/dist/{__tests__/structuredCommentValidation.test.d.ts → annotatedAttachments/AnnotatedAttachmentSessionStore.test.d.ts} +0 -0
- /package/dist/{__tests__/structuredDocValidation.test.d.ts → annotatedAttachments/payload.test.d.ts} +0 -0
- /package/dist/{__tests__/templateEngine.test.d.ts → annotatedAttachments/types.js} +0 -0
- /package/dist/{__tests__/templates.test.d.ts → compat/workspaceSyncCompat.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowDocumentFixtures.test.d.ts → components/features/AgentsModule.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowExportMatrix.test.d.ts → components/features/AnnotatedAttachmentWorkspace.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowExportSnapshots.test.d.ts → components/features/DocumentWorkspace.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowGeneration.test.d.ts → components/features/settings/TaxonomyLibraryManager.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowV2Policy.test.d.ts → components/task/TaskActionHeader.test.d.ts} +0 -0
- /package/dist/{core/InitiativeTemplates.test.d.ts → components/task/TaskKanban.planning-drop.test.d.ts} +0 -0
- /package/dist/{core/ParentLifecycle.test.d.ts → components/task/TaskStatusActions.test.d.ts} +0 -0
- /package/dist/{migrations/taskMigrations.test.d.ts → components/ui/TopNoticeLayer.test.d.ts} +0 -0
- /package/dist/{server/routes.billing.test.d.ts → components/views/AppShellHeader.test.d.ts} +0 -0
- /package/dist/{server/routes.sync.integration.test.d.ts → components/views/PlanComparisonPage.test.d.ts} +0 -0
- /package/dist/{utils/taskHierarchy.test.d.ts → components/views/chrome/WorkspaceChromeSections.test.d.ts} +0 -0
- /package/dist/{utils/taskParenting.test.d.ts → components/views/chrome/workspaceChrome.test.d.ts} +0 -0
- /package/dist/{utils/taskRelations.test.d.ts → components/views/panels/DocumentFilterToolbar.test.d.ts} +0 -0
- /package/dist/public/{android-chrome-192x192.png → archive/phoenix/android-chrome-192x192.png} +0 -0
- /package/dist/public/{android-chrome-512x512.png → archive/phoenix/android-chrome-512x512.png} +0 -0
- /package/dist/public/{favicon-16x16.png → archive/phoenix/favicon-16x16.png} +0 -0
- /package/dist/public/{favicon-32x32.png → archive/phoenix/favicon-32x32.png} +0 -0
- /package/dist/public/{favicon.png → archive/phoenix/favicon.png} +0 -0
- /package/dist/{__tests__ → services}/workflowExportSnapshots.test.js +0 -0
- /package/dist/{__tests__ → services}/workflowGeneration.test.js +0 -0
- /package/dist/ui/favicon/{android-chrome-192x192.png → archive/phoenix/android-chrome-192x192.png} +0 -0
- /package/dist/ui/favicon/{android-chrome-512x512.png → archive/phoenix/android-chrome-512x512.png} +0 -0
- /package/dist/ui/favicon/{favicon-16x16.png → archive/phoenix/favicon-16x16.png} +0 -0
- /package/dist/ui/favicon/{favicon-32x32.png → archive/phoenix/favicon-32x32.png} +0 -0
- /package/dist/ui/favicon/{favicon.png → archive/phoenix/favicon.png} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource and workflow route module.
|
|
3
|
+
*
|
|
4
|
+
* Handles filesystem browsing helpers, resource export, workflow template
|
|
5
|
+
* reads, workflow editor override persistence, and environment discovery.
|
|
6
|
+
*
|
|
7
|
+
* Routes registered here:
|
|
8
|
+
* GET /api/taskforce/folders
|
|
9
|
+
* POST /api/taskforce/validate-paths
|
|
10
|
+
* POST /api/taskforce/export-resources
|
|
11
|
+
* GET /api/taskforce/workflow-templates
|
|
12
|
+
* GET /api/taskforce/workflow-template/:name
|
|
13
|
+
* GET /api/taskforce/workflow-templates/:name
|
|
14
|
+
* GET /api/taskforce/workflow-editor/overrides
|
|
15
|
+
* POST /api/taskforce/workflow-editor/save
|
|
16
|
+
* POST /api/taskforce/workflow-editor/reset/:name
|
|
17
|
+
* GET /api/taskforce/environments
|
|
18
|
+
*/
|
|
19
|
+
import type { TaskforceCore } from '../../core/Taskforce.js';
|
|
20
|
+
import { type RouteHandler } from '../routes.js';
|
|
21
|
+
export interface ResourceRouteDependencies {
|
|
22
|
+
addRoute: (method: string, path: string, handler: RouteHandler) => void;
|
|
23
|
+
core: TaskforceCore;
|
|
24
|
+
}
|
|
25
|
+
export declare function registerResourceRoutes(deps: ResourceRouteDependencies): void;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource and workflow route module.
|
|
3
|
+
*
|
|
4
|
+
* Handles filesystem browsing helpers, resource export, workflow template
|
|
5
|
+
* reads, workflow editor override persistence, and environment discovery.
|
|
6
|
+
*
|
|
7
|
+
* Routes registered here:
|
|
8
|
+
* GET /api/taskforce/folders
|
|
9
|
+
* POST /api/taskforce/validate-paths
|
|
10
|
+
* POST /api/taskforce/export-resources
|
|
11
|
+
* GET /api/taskforce/workflow-templates
|
|
12
|
+
* GET /api/taskforce/workflow-template/:name
|
|
13
|
+
* GET /api/taskforce/workflow-templates/:name
|
|
14
|
+
* GET /api/taskforce/workflow-editor/overrides
|
|
15
|
+
* POST /api/taskforce/workflow-editor/save
|
|
16
|
+
* POST /api/taskforce/workflow-editor/reset/:name
|
|
17
|
+
* GET /api/taskforce/environments
|
|
18
|
+
*/
|
|
19
|
+
import * as fs from 'fs';
|
|
20
|
+
import * as path from 'path';
|
|
21
|
+
import { execFileSync } from 'child_process';
|
|
22
|
+
import { parseJsonBody } from '../routes.js';
|
|
23
|
+
const WORKFLOW_EDITOR_LOCKED_FIELDS = {
|
|
24
|
+
do: ['aliasesText', 'dispatchDefault', 'criticalToolsText', 'contentDefault'],
|
|
25
|
+
execute: ['aliasesText', 'dispatchDefault', 'criticalToolsText', 'contentDefault']
|
|
26
|
+
};
|
|
27
|
+
function draftFromTemplate(template) {
|
|
28
|
+
return {
|
|
29
|
+
description: String(template?.description || ''),
|
|
30
|
+
aliasesText: Array.isArray(template?.dispatch?.aliases) ? template.dispatch.aliases.join(', ') : '',
|
|
31
|
+
dispatchDefault: String(template?.dispatch?.default || ''),
|
|
32
|
+
criticalToolsText: Array.isArray(template?.compat?.requiredToolsCritical) ? template.compat.requiredToolsCritical.join('\n') : '',
|
|
33
|
+
optionalToolsText: Array.isArray(template?.compat?.requiredToolsOptional) ? template.compat.requiredToolsOptional.join('\n') : '',
|
|
34
|
+
contentDefault: String(template?.content?.default || '')
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function sanitizeWorkflowEditorDraft(name, draft, template) {
|
|
38
|
+
const lockedFields = WORKFLOW_EDITOR_LOCKED_FIELDS[name] || [];
|
|
39
|
+
if (lockedFields.length === 0)
|
|
40
|
+
return draft;
|
|
41
|
+
const baseDraft = draftFromTemplate(template);
|
|
42
|
+
const next = { ...draft };
|
|
43
|
+
for (const key of lockedFields) {
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(baseDraft, key)) {
|
|
45
|
+
next[key] = baseDraft[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return next;
|
|
49
|
+
}
|
|
50
|
+
export function registerResourceRoutes(deps) {
|
|
51
|
+
const { addRoute, core } = deps;
|
|
52
|
+
addRoute('GET', '/api/taskforce/folders', async (req, res) => {
|
|
53
|
+
const url = new URL(req.url || '', 'http://localhost');
|
|
54
|
+
const requestedPath = url.searchParams.get('path') || '';
|
|
55
|
+
const { projectRoot } = core.getPaths();
|
|
56
|
+
const fullPath = requestedPath ? path.resolve(projectRoot, requestedPath) : projectRoot;
|
|
57
|
+
const realPath = fs.existsSync(fullPath) ? fs.realpathSync(fullPath) : fullPath;
|
|
58
|
+
if (!realPath.startsWith(projectRoot)) {
|
|
59
|
+
res.writeHead(403, { 'Content-Type': 'application/json' });
|
|
60
|
+
res.end(JSON.stringify({ error: 'Access denied' }));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!fs.existsSync(realPath) || !fs.statSync(realPath).isDirectory()) {
|
|
64
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
65
|
+
res.end(JSON.stringify({ folders: [], files: [] }));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const entries = fs.readdirSync(realPath, { withFileTypes: true });
|
|
69
|
+
const folders = entries
|
|
70
|
+
.filter((entry) => {
|
|
71
|
+
if (entry.name.startsWith('.') && entry.name !== '.agent')
|
|
72
|
+
return false;
|
|
73
|
+
if (entry.name === 'node_modules')
|
|
74
|
+
return false;
|
|
75
|
+
return entry.isDirectory();
|
|
76
|
+
})
|
|
77
|
+
.map((entry) => entry.name)
|
|
78
|
+
.sort();
|
|
79
|
+
const files = entries
|
|
80
|
+
.filter((entry) => !entry.name.startsWith('.') && entry.isFile())
|
|
81
|
+
.map((entry) => entry.name)
|
|
82
|
+
.sort();
|
|
83
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
84
|
+
res.end(JSON.stringify({ folders, files }));
|
|
85
|
+
});
|
|
86
|
+
addRoute('POST', '/api/taskforce/validate-paths', async (req, res) => {
|
|
87
|
+
const body = await parseJsonBody(req);
|
|
88
|
+
const { paths } = body;
|
|
89
|
+
const { projectRoot } = core.getPaths();
|
|
90
|
+
const results = {};
|
|
91
|
+
if (Array.isArray(paths)) {
|
|
92
|
+
for (const candidatePath of paths) {
|
|
93
|
+
const fullPath = path.resolve(projectRoot, candidatePath);
|
|
94
|
+
if (fs.existsSync(fullPath)) {
|
|
95
|
+
const stats = fs.statSync(fullPath);
|
|
96
|
+
results[candidatePath] = {
|
|
97
|
+
exists: true,
|
|
98
|
+
isDirectory: stats.isDirectory(),
|
|
99
|
+
isFile: stats.isFile()
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
results[candidatePath] = { exists: false, isDirectory: false, isFile: false };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
108
|
+
res.end(JSON.stringify({ results }));
|
|
109
|
+
});
|
|
110
|
+
addRoute('POST', '/api/taskforce/export-resources', async (req, res) => {
|
|
111
|
+
const body = await parseJsonBody(req);
|
|
112
|
+
const { type, path: destRelativePath, variables, environment, workflowNames } = body;
|
|
113
|
+
try {
|
|
114
|
+
let count;
|
|
115
|
+
if ((type === 'workflows' || type === 'workflow') && workflowNames && Array.isArray(workflowNames)) {
|
|
116
|
+
count = core.exportWorkflows(environment || 'antigravity', workflowNames, variables);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
count = core.exportResources(type, destRelativePath, variables, environment);
|
|
120
|
+
}
|
|
121
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
122
|
+
res.end(JSON.stringify({ success: true, count }));
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
126
|
+
res.end(JSON.stringify({ success: false, error: error.message }));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
addRoute('GET', '/api/taskforce/workflow-templates', async (_req, res) => {
|
|
130
|
+
const templates = core.listWorkflowTemplates();
|
|
131
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
132
|
+
res.end(JSON.stringify({ templates }));
|
|
133
|
+
});
|
|
134
|
+
const workflowTemplateHandler = async (_req, res, params) => {
|
|
135
|
+
const name = (params?.name || '').trim();
|
|
136
|
+
if (!name) {
|
|
137
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
138
|
+
res.end(JSON.stringify({ error: 'Template name is required' }));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const template = core.getWorkflowTemplate(name);
|
|
143
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
144
|
+
res.end(JSON.stringify({ template }));
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
148
|
+
res.end(JSON.stringify({ error: error.message }));
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
addRoute('GET', '/api/taskforce/workflow-template/:name', workflowTemplateHandler);
|
|
152
|
+
addRoute('GET', '/api/taskforce/workflow-templates/:name', workflowTemplateHandler);
|
|
153
|
+
addRoute('GET', '/api/taskforce/workflow-editor/overrides', async (_req, res) => {
|
|
154
|
+
const names = core.listWorkflowOverrideNames();
|
|
155
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
156
|
+
res.end(JSON.stringify({ names }));
|
|
157
|
+
});
|
|
158
|
+
addRoute('POST', '/api/taskforce/workflow-editor/save', async (req, res) => {
|
|
159
|
+
const body = await parseJsonBody(req);
|
|
160
|
+
const { name, draft } = body || {};
|
|
161
|
+
if (!name || typeof name !== 'string') {
|
|
162
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
163
|
+
res.end(JSON.stringify({ success: false, error: 'Workflow name is required' }));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (!draft || typeof draft !== 'object') {
|
|
167
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
168
|
+
res.end(JSON.stringify({ success: false, error: 'Draft payload is required' }));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const root = core.getPaths().projectRoot;
|
|
172
|
+
const overridesPath = path.resolve(root, 'src/resources/templates/workflow-sources/workflowEditorOverrides.json');
|
|
173
|
+
try {
|
|
174
|
+
const template = core.getWorkflowTemplate(name);
|
|
175
|
+
const sanitizedDraft = sanitizeWorkflowEditorDraft(name, draft, template);
|
|
176
|
+
const raw = fs.existsSync(overridesPath) ? fs.readFileSync(overridesPath, 'utf8') : '{}';
|
|
177
|
+
const parsed = raw.trim() ? JSON.parse(raw) : {};
|
|
178
|
+
parsed[name] = {
|
|
179
|
+
...parsed[name],
|
|
180
|
+
...sanitizedDraft,
|
|
181
|
+
updatedAt: new Date().toISOString()
|
|
182
|
+
};
|
|
183
|
+
fs.writeFileSync(overridesPath, JSON.stringify(parsed, null, 2), 'utf8');
|
|
184
|
+
const generatorPath = path.resolve(root, 'scripts/generate-workflow-templates.mjs');
|
|
185
|
+
execFileSync('node', [generatorPath], { cwd: root, stdio: 'pipe' });
|
|
186
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
187
|
+
res.end(JSON.stringify({ success: true }));
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
191
|
+
res.end(JSON.stringify({ success: false, error: error.message }));
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
addRoute('POST', '/api/taskforce/workflow-editor/reset/:name', async (_req, res, params) => {
|
|
195
|
+
const name = (params?.name || '').trim();
|
|
196
|
+
if (!name) {
|
|
197
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
198
|
+
res.end(JSON.stringify({ success: false, error: 'Workflow name is required' }));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const root = core.getPaths().projectRoot;
|
|
202
|
+
const overridesPath = path.resolve(root, 'src/resources/templates/workflow-sources/workflowEditorOverrides.json');
|
|
203
|
+
try {
|
|
204
|
+
const raw = fs.existsSync(overridesPath) ? fs.readFileSync(overridesPath, 'utf8') : '{}';
|
|
205
|
+
const parsed = raw.trim() ? JSON.parse(raw) : {};
|
|
206
|
+
if (Object.prototype.hasOwnProperty.call(parsed, name)) {
|
|
207
|
+
delete parsed[name];
|
|
208
|
+
fs.writeFileSync(overridesPath, JSON.stringify(parsed, null, 2), 'utf8');
|
|
209
|
+
}
|
|
210
|
+
const generatorPath = path.resolve(root, 'scripts/generate-workflow-templates.mjs');
|
|
211
|
+
execFileSync('node', [generatorPath], { cwd: root, stdio: 'pipe' });
|
|
212
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
213
|
+
res.end(JSON.stringify({ success: true }));
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
217
|
+
res.end(JSON.stringify({ success: false, error: error.message }));
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
addRoute('GET', '/api/taskforce/environments', async (_req, res) => {
|
|
221
|
+
const environments = core.listEnvironments();
|
|
222
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
223
|
+
res.end(JSON.stringify({ environments }));
|
|
224
|
+
});
|
|
225
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared route helpers and middleware factories.
|
|
3
|
+
*
|
|
4
|
+
* These utilities are injected into every route module via their
|
|
5
|
+
* `*RouteDependencies` interface so that no module needs to reach back into
|
|
6
|
+
* routes.ts at runtime.
|
|
7
|
+
*/
|
|
8
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
9
|
+
import { TaskforceCore } from '../../core/Taskforce.js';
|
|
10
|
+
import type { RouteContext } from '../routes.js';
|
|
11
|
+
export declare function resolveErrorStatusCode(error: unknown, fallback?: number): number;
|
|
12
|
+
export declare function requestHeader(req: IncomingMessage, name: string, fallback?: string): string;
|
|
13
|
+
export declare function requestWorkspaceHeader(req: IncomingMessage): string;
|
|
14
|
+
export declare function requestAuthoritativeWorkspaceId(req: IncomingMessage): string;
|
|
15
|
+
export declare function requestRuntimeMode(req: IncomingMessage): 'local' | 'cloud';
|
|
16
|
+
export declare function requestRole(req: IncomingMessage): string;
|
|
17
|
+
export declare function requestSystemRole(req: IncomingMessage): 'system_admin' | 'user';
|
|
18
|
+
export declare function requestUserId(req: IncomingMessage): string;
|
|
19
|
+
export declare function makeRequestWorkspaceId(core: TaskforceCore, context: RouteContext): (req: IncomingMessage) => string;
|
|
20
|
+
export declare function makeResolveAuthenticatedUserId(core: TaskforceCore, context: RouteContext, requestWorkspaceId: (req: IncomingMessage) => string): (req: IncomingMessage) => string;
|
|
21
|
+
export declare function makeResolveAuthenticatedMutationUserId(core: TaskforceCore, context: RouteContext, requestWorkspaceId: (req: IncomingMessage) => string): (req: IncomingMessage) => string;
|
|
22
|
+
export declare function makeEnsureAppAccess(core: TaskforceCore, context: RouteContext): (req: IncomingMessage, res: ServerResponse) => boolean;
|
|
23
|
+
export declare function makeEnsureAdminRole(core: TaskforceCore, context: RouteContext): (req: IncomingMessage) => boolean;
|
|
24
|
+
export declare function makeEnsureAuthenticatedUser(): (req: IncomingMessage) => boolean;
|
|
25
|
+
export declare function ensureOwnerRole(req: IncomingMessage): boolean;
|
|
26
|
+
export declare function ensureWorkspaceAdminRole(req: IncomingMessage): boolean;
|
|
27
|
+
export declare function makeResolveAdminRequestActor(core: TaskforceCore, context: RouteContext): (req: IncomingMessage) => {
|
|
28
|
+
authenticated: boolean;
|
|
29
|
+
userId: string;
|
|
30
|
+
systemRole: "system_admin" | "user";
|
|
31
|
+
};
|
|
32
|
+
export declare function makeAuditAdminAction(core: TaskforceCore, context: RouteContext): (req: IncomingMessage, action: string, details: Record<string, unknown>) => void;
|
|
33
|
+
export declare function makeAuditAuthAction(core: TaskforceCore, requestWorkspaceId: (req: IncomingMessage) => string): (req: IncomingMessage, action: string, details: Record<string, unknown>) => void;
|
|
34
|
+
export declare function makeRequireCloudRuntime(context: RouteContext): (res: ServerResponse, feature: string) => boolean;
|
|
35
|
+
export declare function makeEnsureCloudPlanData(context: RouteContext): (req: IncomingMessage, res: ServerResponse) => boolean;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared route helpers and middleware factories.
|
|
3
|
+
*
|
|
4
|
+
* These utilities are injected into every route module via their
|
|
5
|
+
* `*RouteDependencies` interface so that no module needs to reach back into
|
|
6
|
+
* routes.ts at runtime.
|
|
7
|
+
*/
|
|
8
|
+
import { TaskforceRuleError } from '../../core/Taskforce.js';
|
|
9
|
+
import { resolveRequestAccess, } from '../auth.js';
|
|
10
|
+
// === SECTION: Error helpers ===
|
|
11
|
+
export function resolveErrorStatusCode(error, fallback = 400) {
|
|
12
|
+
if (error instanceof TaskforceRuleError)
|
|
13
|
+
return error.statusCode;
|
|
14
|
+
const statusCode = Number(error?.statusCode);
|
|
15
|
+
if (Number.isFinite(statusCode) && statusCode >= 400 && statusCode <= 599) {
|
|
16
|
+
return statusCode;
|
|
17
|
+
}
|
|
18
|
+
return fallback;
|
|
19
|
+
}
|
|
20
|
+
// === SECTION: Request header helpers ===
|
|
21
|
+
export function requestHeader(req, name, fallback = '') {
|
|
22
|
+
const value = req.headers?.[name.toLowerCase()];
|
|
23
|
+
if (typeof value === 'string')
|
|
24
|
+
return value;
|
|
25
|
+
if (Array.isArray(value) && value.length > 0)
|
|
26
|
+
return String(value[0]);
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
|
29
|
+
export function requestWorkspaceHeader(req) {
|
|
30
|
+
return requestHeader(req, 'x-taskforce-workspace-id', '').trim();
|
|
31
|
+
}
|
|
32
|
+
export function requestAuthoritativeWorkspaceId(req) {
|
|
33
|
+
const authoritative = requestHeader(req, 'x-taskforce-workspace-authoritative', '').trim().toLowerCase();
|
|
34
|
+
if (authoritative !== '1' && authoritative !== 'true')
|
|
35
|
+
return '';
|
|
36
|
+
return requestWorkspaceHeader(req);
|
|
37
|
+
}
|
|
38
|
+
export function requestRuntimeMode(req) {
|
|
39
|
+
const raw = String(requestHeader(req, 'x-taskforce-runtime-mode', '')).trim().toLowerCase();
|
|
40
|
+
return raw === 'cloud' ? 'cloud' : 'local';
|
|
41
|
+
}
|
|
42
|
+
export function requestRole(req) {
|
|
43
|
+
return requestHeader(req, 'x-taskforce-role', 'member');
|
|
44
|
+
}
|
|
45
|
+
export function requestSystemRole(req) {
|
|
46
|
+
const raw = requestHeader(req, 'x-taskforce-system-role', 'user').trim().toLowerCase();
|
|
47
|
+
return raw === 'system_admin' ? 'system_admin' : 'user';
|
|
48
|
+
}
|
|
49
|
+
export function requestUserId(req) {
|
|
50
|
+
return requestHeader(req, 'x-taskforce-user-id', 'anonymous') || 'anonymous';
|
|
51
|
+
}
|
|
52
|
+
// === SECTION: Workspace ID resolution ===
|
|
53
|
+
export function makeRequestWorkspaceId(core, context) {
|
|
54
|
+
return function requestWorkspaceId(req) {
|
|
55
|
+
if (requestRuntimeMode(req) === 'local') {
|
|
56
|
+
try {
|
|
57
|
+
const urlObj = new URL(req.url || '/', 'http://localhost');
|
|
58
|
+
const urlWorkspaceId = urlObj.searchParams.get('workspaceId');
|
|
59
|
+
if (urlWorkspaceId && urlWorkspaceId.trim().length > 0) {
|
|
60
|
+
return urlWorkspaceId.trim();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Ignore URL parsing errors
|
|
65
|
+
}
|
|
66
|
+
return core.resolvePreferredWorkspaceId({ allowDefault: true }) || 'default';
|
|
67
|
+
}
|
|
68
|
+
const authConfig = context.authConfig;
|
|
69
|
+
if (authConfig?.enabled) {
|
|
70
|
+
const access = resolveRequestAccess(req, authConfig);
|
|
71
|
+
const sessionWorkspaceId = String(access.workspaceId || '').trim();
|
|
72
|
+
if (access.authenticated && access.userId && access.userId !== 'anonymous') {
|
|
73
|
+
const memberWorkspaces = core.listUserWorkspaces(access.userId);
|
|
74
|
+
const memberWorkspaceIds = new Set(memberWorkspaces.map((workspace) => String(workspace.id || '').trim()).filter(Boolean));
|
|
75
|
+
if (memberWorkspaceIds.size === 0)
|
|
76
|
+
return 'default';
|
|
77
|
+
const requestedWorkspaceId = requestWorkspaceHeader(req);
|
|
78
|
+
const authoritativeWorkspaceId = requestAuthoritativeWorkspaceId(req);
|
|
79
|
+
if (authoritativeWorkspaceId) {
|
|
80
|
+
const allowed = memberWorkspaceIds.has(authoritativeWorkspaceId);
|
|
81
|
+
if (allowed)
|
|
82
|
+
return authoritativeWorkspaceId;
|
|
83
|
+
}
|
|
84
|
+
if (requestedWorkspaceId) {
|
|
85
|
+
const allowed = memberWorkspaceIds.has(requestedWorkspaceId);
|
|
86
|
+
if (allowed && !sessionWorkspaceId)
|
|
87
|
+
return requestedWorkspaceId;
|
|
88
|
+
}
|
|
89
|
+
if (sessionWorkspaceId && sessionWorkspaceId !== 'default' && memberWorkspaceIds.has(sessionWorkspaceId))
|
|
90
|
+
return sessionWorkspaceId;
|
|
91
|
+
const resolvedWorkspaceId = core.resolvePreferredUserWorkspaceId(access.userId, {
|
|
92
|
+
preferredWorkspaceId: requestedWorkspaceId || null,
|
|
93
|
+
persistedWorkspaceId: sessionWorkspaceId || null
|
|
94
|
+
});
|
|
95
|
+
if (resolvedWorkspaceId)
|
|
96
|
+
return resolvedWorkspaceId;
|
|
97
|
+
return 'default';
|
|
98
|
+
}
|
|
99
|
+
return 'default';
|
|
100
|
+
}
|
|
101
|
+
const requestedWorkspaceId = requestAuthoritativeWorkspaceId(req) || requestWorkspaceHeader(req);
|
|
102
|
+
if (requestedWorkspaceId) {
|
|
103
|
+
return requestedWorkspaceId;
|
|
104
|
+
}
|
|
105
|
+
return '';
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// === SECTION: Authenticated user ID resolution ===
|
|
109
|
+
export function makeResolveAuthenticatedUserId(core, context, requestWorkspaceId) {
|
|
110
|
+
return function resolveAuthenticatedUserId(req) {
|
|
111
|
+
const authConfig = context.authConfig;
|
|
112
|
+
if (authConfig?.enabled) {
|
|
113
|
+
const access = resolveRequestAccess(req, authConfig);
|
|
114
|
+
if (access.authenticated && access.userId && access.userId !== 'anonymous')
|
|
115
|
+
return access.userId;
|
|
116
|
+
}
|
|
117
|
+
const explicitUserId = String(requestUserId(req) || '').trim();
|
|
118
|
+
if (explicitUserId && explicitUserId !== 'anonymous')
|
|
119
|
+
return explicitUserId;
|
|
120
|
+
if (requestRuntimeMode(req) !== 'local')
|
|
121
|
+
return explicitUserId || 'anonymous';
|
|
122
|
+
const workspaceId = String(requestWorkspaceId(req) || '').trim() || 'default';
|
|
123
|
+
const fallbackUser = core.listWorkspaceUsers(workspaceId).find((user) => {
|
|
124
|
+
const status = String(user.status || '').trim().toLowerCase();
|
|
125
|
+
return status === 'active' && user.disabled !== true;
|
|
126
|
+
});
|
|
127
|
+
return String(fallbackUser?.userId || explicitUserId || 'anonymous').trim() || 'anonymous';
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function makeResolveAuthenticatedMutationUserId(core, context, requestWorkspaceId) {
|
|
131
|
+
return function resolveAuthenticatedMutationUserId(req) {
|
|
132
|
+
const authConfig = context.authConfig;
|
|
133
|
+
if (authConfig?.enabled) {
|
|
134
|
+
const access = resolveRequestAccess(req, authConfig);
|
|
135
|
+
if (access.authenticated && access.userId && access.userId !== 'anonymous')
|
|
136
|
+
return access.userId;
|
|
137
|
+
}
|
|
138
|
+
const explicitUserId = String(requestUserId(req) || '').trim();
|
|
139
|
+
if (explicitUserId && explicitUserId !== 'anonymous')
|
|
140
|
+
return explicitUserId;
|
|
141
|
+
if (requestRuntimeMode(req) === 'local') {
|
|
142
|
+
const workspaceId = String(requestWorkspaceId(req) || '').trim() || 'default';
|
|
143
|
+
const fallbackUser = core.listWorkspaceUsers(workspaceId).find((user) => {
|
|
144
|
+
const status = String(user.status || '').trim().toLowerCase();
|
|
145
|
+
return status === 'active' && user.disabled !== true;
|
|
146
|
+
});
|
|
147
|
+
const fallbackUserId = String(fallbackUser?.userId || '').trim();
|
|
148
|
+
if (fallbackUserId)
|
|
149
|
+
return fallbackUserId;
|
|
150
|
+
}
|
|
151
|
+
throw new TaskforceRuleError('Authenticated user required for mutation attribution.', 401, 'MUTATION_AUTH_REQUIRED');
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// === SECTION: App access guard ===
|
|
155
|
+
export function makeEnsureAppAccess(core, context) {
|
|
156
|
+
return function ensureAppAccess(req, res) {
|
|
157
|
+
if (requestRuntimeMode(req) !== 'cloud')
|
|
158
|
+
return true;
|
|
159
|
+
const authConfig = context.authConfig;
|
|
160
|
+
if (!authConfig?.enabled)
|
|
161
|
+
return true;
|
|
162
|
+
const access = resolveRequestAccess(req, authConfig);
|
|
163
|
+
if (!access.authenticated || !access.userId || access.userId === 'anonymous')
|
|
164
|
+
return true;
|
|
165
|
+
const accountAccess = core.getAccountAccessStatus(access.userId);
|
|
166
|
+
if (accountAccess.canAccessApp)
|
|
167
|
+
return true;
|
|
168
|
+
const code = accountAccess.gate === 'plan_selection_required'
|
|
169
|
+
? 'PLAN_SELECTION_REQUIRED'
|
|
170
|
+
: accountAccess.gate === 'misconfigured'
|
|
171
|
+
? 'ACCOUNT_ACCESS_MISCONFIGURED'
|
|
172
|
+
: 'ACCOUNT_ENTITLEMENT_REQUIRED';
|
|
173
|
+
res.writeHead(403, { 'Content-Type': 'application/json' });
|
|
174
|
+
res.end(JSON.stringify({
|
|
175
|
+
error: accountAccess.message || 'This account cannot access the app.',
|
|
176
|
+
code,
|
|
177
|
+
gate: accountAccess.gate,
|
|
178
|
+
canAccessPlans: accountAccess.canAccessPlans,
|
|
179
|
+
planSelectionRequired: accountAccess.planSelectionRequired
|
|
180
|
+
}));
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
// === SECTION: Role guards ===
|
|
185
|
+
export function makeEnsureAdminRole(core, context) {
|
|
186
|
+
return function ensureAdminRole(req) {
|
|
187
|
+
const actor = makeResolveAdminRequestActor(core, context)(req);
|
|
188
|
+
return actor.authenticated && actor.systemRole === 'system_admin';
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export function makeEnsureAuthenticatedUser() {
|
|
192
|
+
return function ensureAuthenticatedUser(req) {
|
|
193
|
+
const userId = String(requestUserId(req) || '').trim();
|
|
194
|
+
return userId.length > 0 && userId !== 'anonymous';
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function ensureOwnerRole(req) {
|
|
198
|
+
return requestRole(req) === 'owner';
|
|
199
|
+
}
|
|
200
|
+
export function ensureWorkspaceAdminRole(req) {
|
|
201
|
+
const role = requestRole(req);
|
|
202
|
+
return role === 'owner' || role === 'admin';
|
|
203
|
+
}
|
|
204
|
+
// === SECTION: Admin actor resolution ===
|
|
205
|
+
export function makeResolveAdminRequestActor(core, context) {
|
|
206
|
+
return function resolveAdminRequestActor(req) {
|
|
207
|
+
const authConfig = context.authConfig;
|
|
208
|
+
if (authConfig?.enabled) {
|
|
209
|
+
const access = resolveRequestAccess(req, authConfig);
|
|
210
|
+
if (access.authenticated && access.userId && access.userId !== 'anonymous') {
|
|
211
|
+
return {
|
|
212
|
+
authenticated: true,
|
|
213
|
+
userId: access.userId,
|
|
214
|
+
systemRole: core.getSystemRole(access.userId)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
authenticated: false,
|
|
219
|
+
userId: 'anonymous',
|
|
220
|
+
systemRole: 'user'
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const userId = String(requestUserId(req) || '').trim() || 'anonymous';
|
|
224
|
+
const systemRole = requestSystemRole(req);
|
|
225
|
+
return {
|
|
226
|
+
authenticated: systemRole === 'system_admin' || userId !== 'anonymous',
|
|
227
|
+
userId,
|
|
228
|
+
systemRole
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
// === SECTION: Audit helpers ===
|
|
233
|
+
export function makeAuditAdminAction(core, context) {
|
|
234
|
+
const resolveAdminRequestActor = makeResolveAdminRequestActor(core, context);
|
|
235
|
+
return function auditAdminAction(req, action, details) {
|
|
236
|
+
const actor = resolveAdminRequestActor(req);
|
|
237
|
+
const payload = {
|
|
238
|
+
ts: new Date().toISOString(),
|
|
239
|
+
action,
|
|
240
|
+
actorUserId: actor.userId,
|
|
241
|
+
actorRole: actor.systemRole,
|
|
242
|
+
workspaceId: 'system',
|
|
243
|
+
details
|
|
244
|
+
};
|
|
245
|
+
try {
|
|
246
|
+
core.addAdminAuditLog({
|
|
247
|
+
action: payload.action,
|
|
248
|
+
actorUserId: payload.actorUserId,
|
|
249
|
+
actorRole: payload.actorRole,
|
|
250
|
+
workspaceId: payload.workspaceId,
|
|
251
|
+
details: payload.details
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
console.warn(`[Taskforce Admin Audit] failed to persist log: ${String(error?.message || error)}`);
|
|
256
|
+
}
|
|
257
|
+
console.info(`[Taskforce Admin Audit] ${JSON.stringify(payload)}`);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export function makeAuditAuthAction(core, requestWorkspaceId) {
|
|
261
|
+
return function auditAuthAction(req, action, details) {
|
|
262
|
+
const payload = {
|
|
263
|
+
ts: new Date().toISOString(),
|
|
264
|
+
action,
|
|
265
|
+
actorUserId: requestUserId(req),
|
|
266
|
+
actorRole: requestRole(req),
|
|
267
|
+
workspaceId: requestWorkspaceId(req),
|
|
268
|
+
details
|
|
269
|
+
};
|
|
270
|
+
try {
|
|
271
|
+
core.addAdminAuditLog({
|
|
272
|
+
action: payload.action,
|
|
273
|
+
actorUserId: payload.actorUserId,
|
|
274
|
+
actorRole: payload.actorRole,
|
|
275
|
+
workspaceId: payload.workspaceId,
|
|
276
|
+
details: payload.details
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.warn(`[Taskforce Auth Audit] failed to persist log: ${String(error?.message || error)}`);
|
|
281
|
+
}
|
|
282
|
+
console.info(`[Taskforce Auth Audit] ${JSON.stringify(payload)}`);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
// === SECTION: Cloud runtime guard ===
|
|
286
|
+
export function makeRequireCloudRuntime(context) {
|
|
287
|
+
return function requireCloudRuntime(res, feature) {
|
|
288
|
+
if (context.authConfig?.runtimeMode === 'cloud')
|
|
289
|
+
return true;
|
|
290
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
291
|
+
res.end(JSON.stringify({ error: `${feature} is only available in cloud runtime.` }));
|
|
292
|
+
return false;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
// === SECTION: Cloud plan data guard ===
|
|
296
|
+
export function makeEnsureCloudPlanData(context) {
|
|
297
|
+
return function ensureCloudPlanData(req, res) {
|
|
298
|
+
const runtime = context.authConfig?.runtimeMode || requestRuntimeMode(req);
|
|
299
|
+
if (runtime === 'cloud')
|
|
300
|
+
return true;
|
|
301
|
+
res.writeHead(409, { 'Content-Type': 'application/json' });
|
|
302
|
+
res.end(JSON.stringify({ error: 'Plan and billing data are cloud-only.', code: 'CLOUD_PLAN_DATA_REQUIRED' }));
|
|
303
|
+
return false;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { makeRequestWorkspaceId } from './shared.js';
|
|
3
|
+
describe('makeRequestWorkspaceId', () => {
|
|
4
|
+
it('prefers explicit workspaceId query params in local mode', () => {
|
|
5
|
+
const core = {
|
|
6
|
+
resolvePreferredWorkspaceId: vi.fn().mockReturnValue('workspace-preferred')
|
|
7
|
+
};
|
|
8
|
+
const requestWorkspaceId = makeRequestWorkspaceId(core, {});
|
|
9
|
+
const req = {
|
|
10
|
+
url: '/api/taskforce/sync/workspace/ai-profiles?workspaceId=workspace-query',
|
|
11
|
+
headers: {
|
|
12
|
+
'x-taskforce-runtime-mode': 'local'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
expect(requestWorkspaceId(req)).toBe('workspace-query');
|
|
16
|
+
expect(core.resolvePreferredWorkspaceId).not.toHaveBeenCalled();
|
|
17
|
+
});
|
|
18
|
+
it('falls back to preferred workspace when local query param is absent', () => {
|
|
19
|
+
const core = {
|
|
20
|
+
resolvePreferredWorkspaceId: vi.fn().mockReturnValue('workspace-preferred')
|
|
21
|
+
};
|
|
22
|
+
const requestWorkspaceId = makeRequestWorkspaceId(core, {});
|
|
23
|
+
const req = {
|
|
24
|
+
url: '/api/taskforce/sync/workspace/ai-profiles',
|
|
25
|
+
headers: {
|
|
26
|
+
'x-taskforce-runtime-mode': 'local'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
expect(requestWorkspaceId(req)).toBe('workspace-preferred');
|
|
30
|
+
expect(core.resolvePreferredWorkspaceId).toHaveBeenCalledWith({ allowDefault: true });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IncomingMessage } from 'http';
|
|
2
|
-
import { TaskforceCore } from '
|
|
3
|
-
import { RouteHandler, RouteContext } from '
|
|
4
|
-
import { resolveRequestAccess, createSessionTokenCookie } from '
|
|
5
|
-
import { isReservedWorkspaceId } from '
|
|
2
|
+
import { TaskforceCore, TaskforceSyncCapable } from '../../core/Taskforce.js';
|
|
3
|
+
import { RouteHandler, RouteContext } from '../routes.js';
|
|
4
|
+
import { resolveRequestAccess, createSessionTokenCookie } from '../auth.js';
|
|
5
|
+
import { isReservedWorkspaceId } from '../../utils/workspaceIdentity.js';
|
|
6
6
|
export interface SyncRouteDependencies {
|
|
7
7
|
addRoute: (method: string, path: string, handler: RouteHandler) => void;
|
|
8
|
-
core: TaskforceCore;
|
|
8
|
+
core: TaskforceCore & TaskforceSyncCapable;
|
|
9
9
|
context: RouteContext;
|
|
10
10
|
auditAuthAction: (req: IncomingMessage, action: string, details: Record<string, unknown>) => void;
|
|
11
11
|
resolveErrorStatusCode: (error: unknown, fallback?: number) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|