@taskforcehq/taskforce 0.3.305 → 0.3.307

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/README.md +0 -2
  2. package/dist/Taskforce.module.css +603 -107
  3. package/dist/TaskforceCore.js +216 -43
  4. package/dist/TaskforceCore.test.js +611 -28
  5. package/dist/assets/fonts/CourierPrime-Bold.woff2 +0 -0
  6. package/dist/assets/fonts/CourierPrime-BoldItalic.woff2 +0 -0
  7. package/dist/assets/fonts/CourierPrime-Italic.woff2 +0 -0
  8. package/dist/assets/fonts/CourierPrime-Regular.woff2 +0 -0
  9. package/dist/assets/fonts/Noir_medium.woff2 +0 -0
  10. package/dist/assets/fonts/Noir_regular.woff2 +0 -0
  11. package/dist/assets/fonts/RussoOne-Regular.woff2 +0 -0
  12. package/dist/assets/fonts/SpecialElite-Regular.woff2 +0 -0
  13. package/dist/compat/workspaceSyncCompat.js +46 -2
  14. package/dist/compat/workspaceSyncCompat.test.js +38 -1
  15. package/dist/components/activity/EntityActivityTimeline.d.ts +34 -0
  16. package/dist/components/activity/EntityActivityTimeline.js +81 -0
  17. package/dist/components/context/ContextAttachmentManager.d.ts +14 -0
  18. package/dist/components/context/ContextAttachmentManager.js +561 -0
  19. package/dist/components/features/AgentsModule.d.ts +14 -1
  20. package/dist/components/features/AgentsModule.js +366 -18
  21. package/dist/components/features/AgentsModule.test.js +507 -8
  22. package/dist/components/features/AnnotatedAttachmentWorkspace.d.ts +3 -1
  23. package/dist/components/features/AnnotatedAttachmentWorkspace.js +118 -4
  24. package/dist/components/features/AnnotatedAttachmentWorkspace.test.js +52 -0
  25. package/dist/components/features/DocumentIndex.d.ts +2 -2
  26. package/dist/components/features/DocumentIndex.js +3 -4
  27. package/dist/components/features/DocumentViewer.d.ts +7 -1
  28. package/dist/components/features/DocumentViewer.js +62 -4
  29. package/dist/components/features/DocumentWorkspace.d.ts +10 -2
  30. package/dist/components/features/DocumentWorkspace.js +15 -4
  31. package/dist/components/features/DocumentWorkspace.test.js +51 -1
  32. package/dist/components/features/TaskSettings.d.ts +2 -0
  33. package/dist/components/features/TaskSettings.js +83 -78
  34. package/dist/components/features/TaskSettings.test.js +171 -82
  35. package/dist/components/features/documentWorkspaceModel.d.ts +1 -1
  36. package/dist/components/task/TaskActionHeader.js +11 -5
  37. package/dist/components/task/TaskActionHeader.test.js +10 -0
  38. package/dist/components/task/TaskCard.js +24 -29
  39. package/dist/components/task/TaskCard.test.js +38 -3
  40. package/dist/components/task/TaskContextUpload.js +4 -526
  41. package/dist/components/task/TaskContextUpload.test.js +3 -3
  42. package/dist/components/task/TaskForm.js +61 -116
  43. package/dist/components/task/TaskForm.test.js +110 -8
  44. package/dist/components/task/TaskKanban.d.ts +2 -1
  45. package/dist/components/task/TaskKanban.js +94 -21
  46. package/dist/components/task/TaskKanban.test.js +36 -0
  47. package/dist/components/task/TaskList.js +5 -1
  48. package/dist/components/task/TaskList.test.js +4 -0
  49. package/dist/components/ui/EditableAvatarButton.d.ts +18 -0
  50. package/dist/components/ui/EditableAvatarButton.js +18 -0
  51. package/dist/components/ui/HierarchyActionBadge.d.ts +10 -0
  52. package/dist/components/ui/HierarchyActionBadge.js +5 -0
  53. package/dist/components/views/AppShellHeader.d.ts +3 -1
  54. package/dist/components/views/AppShellHeader.js +27 -11
  55. package/dist/components/views/AppShellHeader.test.js +18 -1
  56. package/dist/components/views/PlanComparisonPage.d.ts +9 -1
  57. package/dist/components/views/PlanComparisonPage.js +78 -14
  58. package/dist/components/views/PlanComparisonPage.test.js +257 -0
  59. package/dist/components/views/PlansPage.js +127 -36
  60. package/dist/components/views/PlansPage.test.js +294 -12
  61. package/dist/components/views/StandaloneLayout.js +529 -592
  62. package/dist/components/views/WidgetView.js +10 -8
  63. package/dist/components/views/panels/PlanningDrawer.d.ts +25 -5
  64. package/dist/components/views/panels/PlanningDrawer.js +270 -55
  65. package/dist/components/views/panels/PlanningDrawer.test.d.ts +1 -0
  66. package/dist/components/views/panels/PlanningDrawer.test.js +529 -0
  67. package/dist/components/views/planningScope.d.ts +20 -0
  68. package/dist/components/views/planningScope.js +25 -0
  69. package/dist/components/views/planningScope.test.d.ts +1 -0
  70. package/dist/components/views/planningScope.test.js +60 -0
  71. package/dist/components/views/standalone/modals/AccountHubModal.d.ts +26 -1
  72. package/dist/components/views/standalone/modals/AccountHubModal.js +76 -2
  73. package/dist/components/views/standalone/modals/AccountHubModal.test.js +20 -3
  74. package/dist/components/views/standalone/modals/AvatarImageManagerModal.d.ts +20 -0
  75. package/dist/components/views/standalone/modals/AvatarImageManagerModal.js +127 -0
  76. package/dist/components/views/standalone/modals/EditProfileModal.d.ts +2 -9
  77. package/dist/components/views/standalone/modals/EditProfileModal.js +3 -2
  78. package/dist/components/views/standalone/modals/SyncEnableWarningModal.d.ts +9 -0
  79. package/dist/components/views/standalone/modals/SyncEnableWarningModal.js +6 -0
  80. package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.d.ts +1 -0
  81. package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.js +24 -0
  82. package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +2 -1
  83. package/dist/components/views/standalone/modals/SyncStatusModal.js +2 -2
  84. package/dist/config/envSchema.js +1 -0
  85. package/dist/core/AiProfileService.d.ts +46 -2
  86. package/dist/core/AiProfileService.js +1073 -82
  87. package/dist/core/AiProfileService.test.js +19 -1
  88. package/dist/core/AiProfiles.test.js +1249 -44
  89. package/dist/core/AttachmentLinkService.d.ts +3 -0
  90. package/dist/core/AttachmentLinkService.js +110 -23
  91. package/dist/core/AuthIdentityService.d.ts +107 -0
  92. package/dist/core/AuthIdentityService.js +284 -0
  93. package/dist/core/AuthTokenService.d.ts +4 -0
  94. package/dist/core/AuthTokenService.js +34 -6
  95. package/dist/core/AuthTokenService.test.js +3 -3
  96. package/dist/core/EntitlementsPolicy.test.js +2 -2
  97. package/dist/core/GlobalSettingsService.js +127 -6
  98. package/dist/core/McpTokenService.d.ts +12 -0
  99. package/dist/core/McpTokenService.js +44 -1
  100. package/dist/core/PlanEntitlementService.d.ts +23 -2
  101. package/dist/core/PlanEntitlementService.js +343 -57
  102. package/dist/core/PlanFeatureCatalog.test.d.ts +1 -0
  103. package/dist/core/PlanFeatureCatalog.test.js +84 -0
  104. package/dist/core/PlanVersionPolicy.test.js +35 -2
  105. package/dist/core/PlanningEntities.test.js +418 -4
  106. package/dist/core/SignupMonetizationSettings.test.js +199 -27
  107. package/dist/core/SyncReconciliationService.js +2 -65
  108. package/dist/core/SystemAdmin.test.js +42 -42
  109. package/dist/core/TaskActivityService.d.ts +28 -1
  110. package/dist/core/TaskActivityService.js +227 -46
  111. package/dist/core/TaskActivitySync.test.d.ts +1 -0
  112. package/dist/core/TaskActivitySync.test.js +90 -0
  113. package/dist/core/TaskAttachmentsCanonical.test.js +51 -1
  114. package/dist/core/TaskAuditTimeline.test.js +96 -0
  115. package/dist/core/Taskforce.d.ts +415 -40
  116. package/dist/core/Taskforce.ids.test.js +58 -0
  117. package/dist/core/Taskforce.js +1543 -266
  118. package/dist/core/Taskforce.listTasksSlim.test.d.ts +1 -0
  119. package/dist/core/Taskforce.listTasksSlim.test.js +91 -0
  120. package/dist/core/Taskforce.mcpAuth.test.js +109 -0
  121. package/dist/core/UserProfileAvatarDrafts.test.js +30 -3
  122. package/dist/core/WorkspaceLifecycleService.js +0 -5
  123. package/dist/core/WorkspacePermissions.test.js +25 -1
  124. package/dist/core/WorkspacePlanMode.test.js +117 -16
  125. package/dist/core/shared.d.ts +1 -1
  126. package/dist/core/shared.js +5 -1
  127. package/dist/core/types.d.ts +75 -2
  128. package/dist/hooks/auth/useTaskforceAuthBootstrap.js +28 -2
  129. package/dist/hooks/bootstrapTimeouts.d.ts +4 -0
  130. package/dist/hooks/bootstrapTimeouts.js +8 -0
  131. package/dist/hooks/bootstrapTimeouts.test.d.ts +1 -0
  132. package/dist/hooks/bootstrapTimeouts.test.js +12 -0
  133. package/dist/hooks/sync/bootstrap.js +2 -0
  134. package/dist/hooks/sync/controlPlane.d.ts +37 -0
  135. package/dist/hooks/sync/controlPlane.js +78 -0
  136. package/dist/hooks/sync/controlPlane.test.d.ts +1 -0
  137. package/dist/hooks/sync/controlPlane.test.js +121 -0
  138. package/dist/hooks/sync/lifecyclePolicy.d.ts +45 -0
  139. package/dist/hooks/sync/lifecyclePolicy.js +93 -0
  140. package/dist/hooks/sync/lifecyclePolicy.test.d.ts +1 -0
  141. package/dist/hooks/sync/lifecyclePolicy.test.js +124 -0
  142. package/dist/hooks/sync/orchestratorShared.d.ts +13 -4
  143. package/dist/hooks/sync/orchestratorShared.js +129 -48
  144. package/dist/hooks/sync/orchestratorShared.test.js +50 -1
  145. package/dist/hooks/sync/pullLifecycle.d.ts +31 -0
  146. package/dist/hooks/sync/pullLifecycle.js +24 -0
  147. package/dist/hooks/sync/pullLifecycle.test.d.ts +1 -0
  148. package/dist/hooks/sync/pullLifecycle.test.js +80 -0
  149. package/dist/hooks/sync/recovery.d.ts +16 -2
  150. package/dist/hooks/sync/recovery.js +179 -53
  151. package/dist/hooks/sync/recovery.test.d.ts +1 -0
  152. package/dist/hooks/sync/recovery.test.js +292 -0
  153. package/dist/hooks/sync/transfers.d.ts +16 -3
  154. package/dist/hooks/sync/transfers.js +210 -66
  155. package/dist/hooks/sync/transfers.test.d.ts +1 -0
  156. package/dist/hooks/sync/transfers.test.js +928 -0
  157. package/dist/hooks/sync/useRecentSyncEvents.d.ts +21 -0
  158. package/dist/hooks/sync/useRecentSyncEvents.js +92 -0
  159. package/dist/hooks/sync/useRecentSyncEvents.test.d.ts +1 -0
  160. package/dist/hooks/sync/useRecentSyncEvents.test.js +124 -0
  161. package/dist/hooks/sync/useSyncStatusActions.d.ts +30 -0
  162. package/dist/hooks/sync/useSyncStatusActions.js +88 -0
  163. package/dist/hooks/sync/useSyncStatusActions.test.d.ts +1 -0
  164. package/dist/hooks/sync/useSyncStatusActions.test.js +133 -0
  165. package/dist/hooks/sync/useSyncStatusControls.d.ts +25 -0
  166. package/dist/hooks/sync/useSyncStatusControls.js +60 -0
  167. package/dist/hooks/sync/useSyncStatusControls.test.d.ts +1 -0
  168. package/dist/hooks/sync/useSyncStatusControls.test.js +88 -0
  169. package/dist/hooks/useFilterSort.js +13 -13
  170. package/dist/hooks/useFilterSort.test.js +87 -1
  171. package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +12 -0
  172. package/dist/hooks/useSyncOrchestrator.d.ts +9 -2
  173. package/dist/hooks/useSyncOrchestrator.js +409 -183
  174. package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +407 -0
  175. package/dist/hooks/useTaskData.js +8 -3
  176. package/dist/hooks/useTaskData.test.js +45 -0
  177. package/dist/hooks/useTaskforce.d.ts +145 -52
  178. package/dist/hooks/useTaskforce.js +592 -253
  179. package/dist/hooks/useTaskforce.runtime-routing.test.d.ts +1 -0
  180. package/dist/hooks/useTaskforce.runtime-routing.test.js +246 -0
  181. package/dist/hooks/useTaskforce.sync-behavior.test.js +2468 -201
  182. package/dist/hooks/useWorkspaceSyncController.d.ts +1 -0
  183. package/dist/hooks/useWorkspaceSyncController.js +13 -2
  184. package/dist/hooks/useWorkspaceSyncController.test.js +48 -0
  185. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.d.ts +16 -0
  186. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +328 -40
  187. package/dist/localization/locales/en-US.d.ts +0 -1
  188. package/dist/localization/locales/en-US.js +0 -1
  189. package/dist/localization/locales/es-419.js +0 -1
  190. package/dist/localization/locales/pt-BR.js +0 -1
  191. package/dist/mcp/canonicalAssetHelpers.d.ts +16 -4
  192. package/dist/mcp/canonicalAssetHelpers.js +18 -10
  193. package/dist/mcp/canonicalAssetHelpers.test.d.ts +1 -0
  194. package/dist/mcp/canonicalAssetHelpers.test.js +67 -0
  195. package/dist/mcp/clientIntegrations.d.ts +1 -0
  196. package/dist/mcp/clientIntegrations.js +25 -0
  197. package/dist/mcp/clientIntegrations.test.js +14 -3
  198. package/dist/mcp/clientProfileDefaults.js +3 -3
  199. package/dist/mcp/collaborationRegistrar.js +7 -7
  200. package/dist/mcp/documentAssetRegistrar.js +116 -10
  201. package/dist/mcp/runtime.d.ts +3 -0
  202. package/dist/mcp/runtime.js +1099 -185
  203. package/dist/mcp/runtime.test.js +1491 -140
  204. package/dist/mcp/taskAttachmentTypes.d.ts +1 -1
  205. package/dist/mcp/taskPlanningRegistrar.js +48 -0
  206. package/dist/mcp/toolRegistry.d.ts +56 -0
  207. package/dist/mcp/toolRegistry.js +8 -0
  208. package/dist/mcp/toolRegistry.test.js +4 -0
  209. package/dist/migrations/taskSchemaMigrations.d.ts +1 -1
  210. package/dist/migrations/taskSchemaMigrations.js +192 -61
  211. package/dist/migrations/taskSchemaMigrations.test.js +15 -0
  212. package/dist/resources/templates/workflow-sources/workflowDocs.mjs +6 -6
  213. package/dist/resources/templates/workflows/collaborate.yaml +1 -1
  214. package/dist/resources/templates/workflows/evaluate.yaml +2 -2
  215. package/dist/resources/templates/workflows/plan.yaml +1 -1
  216. package/dist/resources/templates/workflows/review.yaml +2 -2
  217. package/dist/server/aiProfileAvatarAssets.d.ts +49 -0
  218. package/dist/server/aiProfileAvatarAssets.js +319 -0
  219. package/dist/server/aiProfileAvatarAssets.test.d.ts +1 -0
  220. package/dist/server/aiProfileAvatarAssets.test.js +213 -0
  221. package/dist/server/annotatedAttachmentsRoutes.test.js +69 -10
  222. package/dist/server/auth/providers/apple.d.ts +33 -0
  223. package/dist/server/auth/providers/apple.js +82 -0
  224. package/dist/server/auth/providers/appleClientSecret.d.ts +37 -0
  225. package/dist/server/auth/providers/appleClientSecret.js +65 -0
  226. package/dist/server/auth/providers/github.d.ts +26 -0
  227. package/dist/server/auth/providers/github.js +86 -0
  228. package/dist/server/auth/providers/google.d.ts +21 -0
  229. package/dist/server/auth/providers/google.js +56 -0
  230. package/dist/server/auth/providers/types.d.ts +21 -0
  231. package/dist/server/auth/providers/types.js +1 -0
  232. package/dist/server/auth.d.ts +2 -0
  233. package/dist/server/auth.js +6 -3
  234. package/dist/server/documentReviewRoutes.test.js +36 -3
  235. package/dist/server/index.cookieProxy.test.js +1 -0
  236. package/dist/server/index.d.ts +12 -0
  237. package/dist/server/index.js +124 -9
  238. package/dist/server/index.rateLimit.test.js +3 -0
  239. package/dist/server/index.test.js +111 -3
  240. package/dist/server/routes/admin.d.ts +3 -0
  241. package/dist/server/routes/admin.js +459 -28
  242. package/dist/server/routes/annotatedAttachments.js +51 -0
  243. package/dist/server/routes/auth.d.ts +26 -2
  244. package/dist/server/routes/auth.js +1170 -71
  245. package/dist/server/routes/authSupport.d.ts +5 -1
  246. package/dist/server/routes/authSupport.js +13 -2
  247. package/dist/server/routes/billing.js +372 -35
  248. package/dist/server/routes/billing.test.js +595 -12
  249. package/dist/server/routes/documents.d.ts +1 -0
  250. package/dist/server/routes/documents.js +182 -70
  251. package/dist/server/routes/shared.d.ts +28 -2
  252. package/dist/server/routes/shared.js +69 -14
  253. package/dist/server/routes/sync.integration.test.js +658 -39
  254. package/dist/server/routes/sync.js +74 -608
  255. package/dist/server/routes/syncAuxRoutes.d.ts +15 -0
  256. package/dist/server/routes/syncAuxRoutes.js +91 -0
  257. package/dist/server/routes/syncAuxRoutes.test.d.ts +1 -0
  258. package/dist/server/routes/syncAuxRoutes.test.js +158 -0
  259. package/dist/server/routes/syncPullApplyRoutes.d.ts +36 -0
  260. package/dist/server/routes/syncPullApplyRoutes.js +204 -0
  261. package/dist/server/routes/syncPushRoutes.d.ts +24 -0
  262. package/dist/server/routes/syncPushRoutes.js +212 -0
  263. package/dist/server/routes/syncRouteGuards.d.ts +36 -0
  264. package/dist/server/routes/syncRouteGuards.js +67 -0
  265. package/dist/server/routes/syncRouteGuards.test.d.ts +1 -0
  266. package/dist/server/routes/syncRouteGuards.test.js +94 -0
  267. package/dist/server/routes/syncRouteTypes.d.ts +13 -0
  268. package/dist/server/routes/syncRouteTypes.js +1 -0
  269. package/dist/server/routes/syncSnapshotRoutes.d.ts +66 -0
  270. package/dist/server/routes/syncSnapshotRoutes.js +182 -0
  271. package/dist/server/routes/tasks.js +55 -10
  272. package/dist/server/routes/workspaces.js +36 -5
  273. package/dist/server/routes.js +147 -11
  274. package/dist/server/routes.test.js +2704 -183
  275. package/dist/services/workflowExportSnapshots.test.js +2 -0
  276. package/dist/shared/aiProfileSeatScope.d.ts +5 -0
  277. package/dist/shared/aiProfileSeatScope.js +21 -0
  278. package/dist/shared/aiProfileSurfaceType.d.ts +1 -1
  279. package/dist/shared/aiProfileSurfaceType.js +10 -8
  280. package/dist/shared/passwordPolicy.d.ts +13 -0
  281. package/dist/shared/passwordPolicy.js +84 -0
  282. package/dist/shared/passwordPolicy.test.d.ts +1 -0
  283. package/dist/shared/passwordPolicy.test.js +34 -0
  284. package/dist/storage/objectStorage.d.ts +1 -0
  285. package/dist/storage/objectStorage.js +2 -1
  286. package/dist/storage/objectStorageClient.d.ts +1 -0
  287. package/dist/storage/objectStorageClient.js +41 -8
  288. package/dist/storage/objectStorageClient.test.js +26 -1
  289. package/dist/storage/objectStorageConfig.js +3 -1
  290. package/dist/storage/objectStorageConfig.test.js +13 -1
  291. package/dist/storage/workspaceAssetStore.d.ts +15 -3
  292. package/dist/storage/workspaceAssetStore.js +132 -44
  293. package/dist/storage/workspaceAssetStore.test.js +93 -6
  294. package/dist/styles/fonts.css +70 -0
  295. package/dist/sync/collaborationSyncPayload.d.ts +6 -1
  296. package/dist/sync/collaborationSyncPayload.js +19 -11
  297. package/dist/sync/collaborationSyncPayload.test.js +14 -1
  298. package/dist/sync/collaborationSyncState.d.ts +3 -3
  299. package/dist/sync/collaborationSyncState.js +19 -12
  300. package/dist/sync/contentSyncPayload.d.ts +5 -1
  301. package/dist/sync/contentSyncPayload.js +9 -0
  302. package/dist/sync/contentSyncPayload.test.js +39 -0
  303. package/dist/sync/contentSyncState.d.ts +9 -9
  304. package/dist/sync/contentSyncState.js +248 -107
  305. package/dist/sync/planningSyncPayload.js +5 -0
  306. package/dist/sync/planningSyncPayload.test.js +24 -0
  307. package/dist/sync/syncApplyHandlers.d.ts +11 -4
  308. package/dist/sync/syncApplyHandlers.js +115 -42
  309. package/dist/sync/syncApplyHandlers.test.js +251 -4
  310. package/dist/sync/syncFieldSemantics.d.ts +12 -0
  311. package/dist/sync/syncFieldSemantics.js +55 -0
  312. package/dist/sync/syncResourceAdapters.d.ts +46 -0
  313. package/dist/sync/syncResourceAdapters.js +79 -0
  314. package/dist/sync/syncService.d.ts +6 -0
  315. package/dist/sync/syncService.js +65 -1
  316. package/dist/sync/syncService.test.js +96 -3
  317. package/dist/sync/taskSyncChangeKey.d.ts +2 -0
  318. package/dist/sync/taskSyncChangeKey.js +143 -0
  319. package/dist/sync/taskSyncPayload.js +3 -8
  320. package/dist/sync/workspacePullFeed.d.ts +4 -0
  321. package/dist/sync/workspacePullFeed.js +132 -72
  322. package/dist/sync/workspacePullFeed.test.js +92 -0
  323. package/dist/sync/workspaceRepair.js +5 -2
  324. package/dist/sync/workspaceSyncModel.d.ts +73 -6
  325. package/dist/sync/workspaceSyncModel.js +342 -73
  326. package/dist/sync/workspaceSyncModel.test.js +559 -14
  327. package/dist/sync/workspaceSyncState.d.ts +17 -0
  328. package/dist/sync/workspaceSyncState.js +2 -1
  329. package/dist/sync/workspaceSyncSurface.js +3 -8
  330. package/dist/types.d.ts +50 -2
  331. package/dist/ui/assets/AgentsModule-2y82_3DO.js +1 -0
  332. package/dist/ui/assets/AnnotatedAttachmentWorkspace-BTLZZCiQ.js +3 -0
  333. package/dist/ui/assets/AnnotatedAttachmentWorkspace-BVKew-mH.css +1 -0
  334. package/dist/ui/assets/ContextAttachmentManager-D2epuNnG.js +3 -0
  335. package/dist/ui/assets/CourierPrime-Bold-BuLj_dpw.woff2 +0 -0
  336. package/dist/ui/assets/CourierPrime-BoldItalic-BrK2pUkZ.woff2 +0 -0
  337. package/dist/ui/assets/CourierPrime-Italic-DFUZK5Ey.woff2 +0 -0
  338. package/dist/ui/assets/CourierPrime-Regular-BsKphzVf.woff2 +0 -0
  339. package/dist/ui/assets/DocumentWorkspace-D4rJKXzd.css +1 -0
  340. package/dist/ui/assets/DocumentWorkspace-sVa-3Do6.js +252 -0
  341. package/dist/ui/assets/EntityActivityTimeline-DyqvvhuF.css +1 -0
  342. package/dist/ui/assets/EntityActivityTimeline-Zods27y_.js +1 -0
  343. package/dist/ui/assets/{InitiativesModule-Dhm7M8e7.js → InitiativesModule-D4XseTwW.js} +1 -1
  344. package/dist/ui/assets/Noir_medium-bxQwKGzB.woff2 +0 -0
  345. package/dist/ui/assets/Noir_regular-ojf2kxlG.woff2 +0 -0
  346. package/dist/ui/assets/PlansPage-D5AcbO0L.js +1 -0
  347. package/dist/ui/assets/PlansPage-Dvqsz5zc.css +1 -0
  348. package/dist/ui/assets/RussoOne-Regular-Cu_qq_qC.woff2 +0 -0
  349. package/dist/ui/assets/SpecialElite-Regular-Di6gSvAS.woff2 +0 -0
  350. package/dist/ui/assets/TaskContextUpload-uC5qx4Bv.js +1 -0
  351. package/dist/ui/assets/TaskSettings-CqvPAsTv.js +9 -0
  352. package/dist/ui/assets/{WorkflowsModule-BcS4afRn.js → WorkflowsModule-oOA9bcdK.js} +4 -4
  353. package/dist/ui/assets/documentReferences-DPZuTgHh.js +1 -0
  354. package/dist/ui/assets/index-607WPo_X.js +4 -0
  355. package/dist/ui/assets/index-CYyodXsg.css +1 -0
  356. package/dist/ui/assets/{vendor-icons-BSUaRwF8.js → vendor-icons-B32hGuF2.js} +1 -1
  357. package/dist/ui/fonts/CourierPrime-Bold.ttf +0 -0
  358. package/dist/ui/fonts/CourierPrime-Bold.woff2 +0 -0
  359. package/dist/ui/fonts/CourierPrime-BoldItalic.ttf +0 -0
  360. package/dist/ui/fonts/CourierPrime-BoldItalic.woff2 +0 -0
  361. package/dist/ui/fonts/CourierPrime-Italic.ttf +0 -0
  362. package/dist/ui/fonts/CourierPrime-Italic.woff2 +0 -0
  363. package/dist/ui/fonts/CourierPrime-Regular.ttf +0 -0
  364. package/dist/ui/fonts/CourierPrime-Regular.woff2 +0 -0
  365. package/dist/ui/fonts/Noir_medium.otf +0 -0
  366. package/dist/ui/fonts/Noir_medium.woff2 +0 -0
  367. package/dist/ui/fonts/Noir_regular.otf +0 -0
  368. package/dist/ui/fonts/Noir_regular.woff2 +0 -0
  369. package/dist/ui/fonts/RussoOne-Regular.woff2 +0 -0
  370. package/dist/ui/fonts/SpecialElite-Regular.ttf +0 -0
  371. package/dist/ui/fonts/SpecialElite-Regular.woff2 +0 -0
  372. package/dist/ui/index.html +3 -3
  373. package/dist/ui/product/agent manager.png +0 -0
  374. package/dist/ui/product/agent_manager_02.png +0 -0
  375. package/dist/utils/accountProfileSummaryCache.d.ts +5 -0
  376. package/dist/utils/aiProfileEvents.d.ts +7 -0
  377. package/dist/utils/aiProfileEvents.js +6 -0
  378. package/dist/utils/assignees.d.ts +8 -0
  379. package/dist/utils/assignees.js +10 -1
  380. package/dist/utils/assignees.test.d.ts +1 -0
  381. package/dist/utils/assignees.test.js +25 -0
  382. package/dist/utils/avatarDisplay.d.ts +1 -0
  383. package/dist/utils/avatarDisplay.js +15 -0
  384. package/dist/utils/avatarUpload.d.ts +27 -0
  385. package/dist/utils/avatarUpload.js +132 -0
  386. package/dist/utils/avatarUpload.test.d.ts +1 -0
  387. package/dist/utils/avatarUpload.test.js +40 -0
  388. package/dist/utils/bootstrapTrace.d.ts +7 -0
  389. package/dist/utils/bootstrapTrace.js +29 -0
  390. package/dist/utils/commercialLifecyclePresentation.js +3 -0
  391. package/dist/utils/contextAssetEvents.d.ts +2 -0
  392. package/dist/utils/contextFiles.d.ts +3 -1
  393. package/dist/utils/contextFiles.js +2 -1
  394. package/dist/utils/syncEventDetails.d.ts +3 -0
  395. package/dist/utils/syncEventDetails.js +64 -0
  396. package/dist/utils/syncEventDetails.test.d.ts +1 -0
  397. package/dist/utils/syncEventDetails.test.js +23 -0
  398. package/dist/utils/syncEventPresentation.d.ts +15 -0
  399. package/dist/utils/syncEventPresentation.js +129 -0
  400. package/dist/utils/syncEventPresentation.test.d.ts +1 -0
  401. package/dist/utils/syncEventPresentation.test.js +64 -0
  402. package/dist/utils/syncStatusPresentation.d.ts +72 -0
  403. package/dist/utils/syncStatusPresentation.js +217 -0
  404. package/dist/utils/syncStatusPresentation.test.d.ts +1 -0
  405. package/dist/utils/syncStatusPresentation.test.js +164 -0
  406. package/dist/utils/taskActivity.d.ts +9 -1
  407. package/dist/utils/taskActivity.js +290 -22
  408. package/dist/utils/taskActivity.test.js +141 -8
  409. package/dist/utils/taskSearch.d.ts +22 -0
  410. package/dist/utils/taskSearch.js +87 -0
  411. package/dist/utils/taskSearch.test.d.ts +1 -0
  412. package/dist/utils/taskSearch.test.js +69 -0
  413. package/dist/utils/taskUtils.js +10 -3
  414. package/dist/utils/taskUtils.test.d.ts +1 -0
  415. package/dist/utils/taskUtils.test.js +19 -0
  416. package/dist/utils/workspaceSyncPresentation.d.ts +4 -0
  417. package/dist/utils/workspaceSyncPresentation.js +68 -2
  418. package/dist/utils/workspaceSyncPresentation.test.js +36 -1
  419. package/package.json +3 -2
  420. package/scripts/export-sqlite-to-postgres.mjs +7 -9
  421. package/scripts/run-e2e-realtime.sh +17 -3
  422. package/scripts/run-smoke.sh +17 -5
  423. package/scripts/run-soak.sh +17 -5
  424. package/src/resources/templates/workflow-sources/workflowDocs.mjs +6 -6
  425. package/src/resources/templates/workflows/collaborate.yaml +1 -1
  426. package/src/resources/templates/workflows/evaluate.yaml +2 -2
  427. package/src/resources/templates/workflows/plan.yaml +1 -1
  428. package/src/resources/templates/workflows/review.yaml +2 -2
  429. package/dist/ui/assets/AgentsModule-N2MnQBZk.js +0 -1
  430. package/dist/ui/assets/AnnotatedAttachmentWorkspace-BG6P_GVW.js +0 -3
  431. package/dist/ui/assets/AnnotatedAttachmentWorkspace-BaS2VwIr.css +0 -1
  432. package/dist/ui/assets/DocumentWorkspace-B3nV_Gc5.css +0 -1
  433. package/dist/ui/assets/DocumentWorkspace-DRbDMwh8.js +0 -252
  434. package/dist/ui/assets/PlansPage-C2dd2n1X.css +0 -1
  435. package/dist/ui/assets/PlansPage-Cq0zXj3I.js +0 -1
  436. package/dist/ui/assets/RussoOne-Regular-C3BxZIj7.ttf +0 -0
  437. package/dist/ui/assets/TaskSettings-ln0aF7xc.js +0 -9
  438. package/dist/ui/assets/index-C2-OXZV7.css +0 -1
  439. package/dist/ui/assets/index-DcSI5F86.js +0 -6
  440. package/scripts/migrate-planning-model.ts +0 -233
@@ -1,25 +1,92 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useState } from 'react';
3
- import { AlertTriangle, Bot, Check, Clock3, Loader2, Orbit, Sparkles } from 'lucide-react';
3
+ import { AlertTriangle, Bot, Check, ChevronLeft, Cloud, LaptopMinimal, Loader2, Plug } from 'lucide-react';
4
4
  import styles from '../../Taskforce.module.css';
5
- import { AI_PROFILE_SURFACE_TYPE_SECTION_ORDER, formatAiProfileSurfaceTypeLabel, formatAiProfileSurfaceTypeSectionLabel, getAiProfileSurfaceTypeSection, parseAiProfileSurfaceType } from '../../shared/aiProfileSurfaceType.js';
6
- export function AgentsModule({ workspaceId }) {
5
+ import { EditableAvatarButton } from '../ui/EditableAvatarButton';
6
+ import { AvatarImageManagerModal } from '../views/standalone/modals/AvatarImageManagerModal';
7
+ import { prepareAvatarUploadFile } from '../../utils/avatarUpload';
8
+ import { buildVersionedAvatarUrl } from '../../utils/avatarDisplay';
9
+ import { dispatchTaskforceAiProfilesMutated } from '../../utils/aiProfileEvents';
10
+ import { AI_PROFILE_SURFACE_TYPE_SECTION_ORDER, AI_PROFILE_SURFACE_TYPES, formatAiProfileSurfaceTypeLabel, formatAiProfileSurfaceTypeSectionLabel, getAiProfileSurfaceTypeSection, parseAiProfileSurfaceType } from '../../shared/aiProfileSurfaceType.js';
11
+ import { formatAiProfileSeatScopeLabel, parseAiProfileSeatScope } from '../../shared/aiProfileSeatScope.js';
12
+ function hasAiProfileAvatar(profile) {
13
+ return typeof profile.avatarUrl === 'string' && profile.avatarUrl.trim().length > 0;
14
+ }
15
+ function getAiProfileAvatarDisplayUrl(profile) {
16
+ if (!profile)
17
+ return '';
18
+ return buildVersionedAvatarUrl(profile.avatarUrl, profile.avatarRevision, profile.avatarUpdatedAt);
19
+ }
20
+ function getAiProfileAvatarSourceUrl(profile) {
21
+ if (!profile)
22
+ return '';
23
+ return buildVersionedAvatarUrl(profile.avatarSourceUrl, profile.avatarRevision, profile.avatarUpdatedAt);
24
+ }
25
+ function selectAiProfileGroupPrimary(profiles) {
26
+ return profiles.find(hasAiProfileAvatar) || profiles[0];
27
+ }
28
+ function buildAiProfileGroupKey(profile) {
29
+ return `${profile.seatScope || 'unknown'}:${profile.name.trim().toLowerCase()}`;
30
+ }
31
+ function formatDuplicateCount(count) {
32
+ const duplicates = Math.max(0, count - 1);
33
+ return `${duplicates} duplicate${duplicates === 1 ? '' : 's'}`;
34
+ }
35
+ function parseAiProfileSeatUsage(value) {
36
+ if (!value || typeof value !== 'object')
37
+ return null;
38
+ return {
39
+ used: Math.max(0, Number(value.used || 0)),
40
+ limit: value.limit === null || value.limit === undefined
41
+ ? null
42
+ : Math.max(0, Number(value.limit || 0)),
43
+ remaining: value.remaining === null || value.remaining === undefined
44
+ ? null
45
+ : Math.max(0, Number(value.remaining || 0)),
46
+ };
47
+ }
48
+ function renderAiProfileSeatScopeIcon(seatScope, options) {
49
+ const className = options?.variant === 'inline'
50
+ ? `${styles.aiProfileSeatScopeIcon} ${styles.aiProfileSeatScopeIconInline}`
51
+ : options?.variant === 'detail'
52
+ ? `${styles.aiProfileSeatScopeIcon} ${styles.aiProfileSeatScopeIconDetail}`
53
+ : styles.aiProfileSeatScopeIcon;
54
+ if (seatScope === 'cloud_metered') {
55
+ return (_jsx("span", { className: `${className} ${styles.aiProfileSeatScopeIconCloud}`, title: "Cloud MCP", "aria-label": "Cloud MCP", children: _jsx(Cloud, { size: 20 }) }));
56
+ }
57
+ if (seatScope === 'local_unmetered') {
58
+ return (_jsx("span", { className: `${className} ${styles.aiProfileSeatScopeIconLocal}`, title: "Local MCP", "aria-label": "Local MCP", children: _jsx(LaptopMinimal, { size: 20 }) }));
59
+ }
60
+ return null;
61
+ }
62
+ export function AgentsModule({ workspaceId, cloudAuthConfigured = false, authSessionResolved = false, isAuthenticated = false, cloudAiProfileSeatUsage = null, agentTrayOpen = false, onCloseAgentTray, mcpSettingsNode = null, }) {
7
63
  const [aiProfiles, setAiProfiles] = useState([]);
64
+ const [localAiProfileSeatUsage, setLocalAiProfileSeatUsage] = useState(null);
8
65
  const [aiProfilesLoading, setAiProfilesLoading] = useState(false);
9
66
  const [aiProfileMergeState, setAiProfileMergeState] = useState(null);
10
67
  const [aiProfileMergeStatus, setAiProfileMergeStatus] = useState(null);
68
+ const [aiProfileArchiveError, setAiProfileArchiveError] = useState(null);
69
+ const [aiProfileCategoryError, setAiProfileCategoryError] = useState(null);
70
+ const [aiProfileCategoryBusy, setAiProfileCategoryBusy] = useState(false);
11
71
  const [selectedGroupId, setSelectedGroupId] = useState(null);
72
+ const [avatarEditorProfileId, setAvatarEditorProfileId] = useState(null);
73
+ const [aiAvatarBusy, setAiAvatarBusy] = useState(false);
74
+ const [aiAvatarError, setAiAvatarError] = useState(null);
12
75
  const loadAiProfiles = useCallback(async () => {
13
76
  if (!workspaceId)
14
77
  return;
15
78
  setAiProfilesLoading(true);
16
79
  try {
17
- const res = await fetch(`/api/taskforce/workspace/assignee-options?workspaceId=${encodeURIComponent(workspaceId)}`, {
80
+ const rosterUrl = `/api/taskforce/workspace/assignee-options?workspaceId=${encodeURIComponent(workspaceId)}&kind=agent`;
81
+ const rosterResponse = await fetch(rosterUrl, {
18
82
  credentials: 'include',
19
83
  });
20
- const data = await res.json().catch(() => ({}));
21
- const agents = Array.isArray(data?.assignees)
22
- ? data.assignees
84
+ const rosterData = rosterResponse.ok
85
+ ? await rosterResponse.json().catch(() => ({}))
86
+ : {};
87
+ const fallbackSeatUsage = parseAiProfileSeatUsage(rosterData?.aiProfileSeatUsage);
88
+ const agents = Array.isArray(rosterData?.assignees)
89
+ ? rosterData.assignees
23
90
  .filter((assignee) => assignee.kind === 'agent')
24
91
  .map((assignee) => ({
25
92
  id: String(assignee.value || ''),
@@ -27,18 +94,31 @@ export function AgentsModule({ workspaceId }) {
27
94
  username: String(assignee.username || assignee.value || ''),
28
95
  icon: String(assignee.icon || 'Bot'),
29
96
  color: String(assignee.color || '#6B7280'),
97
+ avatarUrl: typeof assignee.avatarUrl === 'string' ? assignee.avatarUrl : null,
98
+ avatarSourceUrl: typeof assignee.avatarSourceUrl === 'string' ? assignee.avatarSourceUrl : null,
99
+ avatarRevision: Number.isFinite(Number(assignee.avatarRevision)) ? Math.max(0, Math.floor(Number(assignee.avatarRevision))) : 0,
100
+ avatarUpdatedAt: typeof assignee.avatarUpdatedAt === 'string' ? assignee.avatarUpdatedAt : null,
30
101
  kind: String(assignee.kind || 'agent'),
31
102
  description: typeof assignee.description === 'string' ? assignee.description : null,
32
103
  role: typeof assignee.role === 'string' ? assignee.role : null,
33
104
  provider: typeof assignee.provider === 'string' ? assignee.provider : null,
34
105
  model: typeof assignee.model === 'string' ? assignee.model : null,
35
106
  surfaceType: parseAiProfileSurfaceType(assignee.surfaceType),
107
+ seatScope: parseAiProfileSeatScope(assignee.seatScope),
108
+ archivedAt: typeof assignee.archivedAt === 'string' ? assignee.archivedAt : null,
36
109
  createdAt: String(assignee.createdAt || ''),
37
110
  updatedAt: String(assignee.updatedAt || assignee.createdAt || ''),
38
111
  lastActiveAt: typeof assignee.lastActiveAt === 'string' ? assignee.lastActiveAt : null,
39
112
  }))
40
113
  : [];
41
114
  setAiProfiles(agents);
115
+ setLocalAiProfileSeatUsage(fallbackSeatUsage);
116
+ setAiProfileArchiveError((current) => (current && !agents.some((agent) => agent.id === current.profileId)
117
+ ? null
118
+ : current));
119
+ setAiProfileCategoryError((current) => (current && !agents.some((agent) => agent.id === current.profileId)
120
+ ? null
121
+ : current));
42
122
  }
43
123
  finally {
44
124
  setAiProfilesLoading(false);
@@ -54,7 +134,7 @@ export function AgentsModule({ workspaceId }) {
54
134
  if (!bySection.has(section))
55
135
  bySection.set(section, new Map());
56
136
  const sectionEntries = bySection.get(section);
57
- const key = profile.name.toLowerCase();
137
+ const key = buildAiProfileGroupKey(profile);
58
138
  if (!sectionEntries.has(key))
59
139
  sectionEntries.set(key, []);
60
140
  sectionEntries.get(key).push(profile);
@@ -68,13 +148,14 @@ export function AgentsModule({ workspaceId }) {
68
148
  section,
69
149
  sectionLabel: formatAiProfileSurfaceTypeSectionLabel(section),
70
150
  profiles,
71
- primaryProfile: profiles[0]
151
+ primaryProfile: selectAiProfileGroupPrimary(profiles)
72
152
  }))
73
153
  }))
74
154
  .filter((entry) => entry.groups.length > 0);
75
155
  }, [aiProfiles]);
76
156
  const allGroups = useMemo(() => groupedProfilesBySurfaceType.flatMap((section) => section.groups), [groupedProfilesBySurfaceType]);
77
157
  const selectedGroup = useMemo(() => allGroups.find((group) => group.groupId === selectedGroupId) || allGroups[0] || null, [allGroups, selectedGroupId]);
158
+ const avatarEditorProfile = useMemo(() => aiProfiles.find((profile) => profile.id === avatarEditorProfileId) || null, [aiProfiles, avatarEditorProfileId]);
78
159
  useEffect(() => {
79
160
  if (!allGroups.length) {
80
161
  if (selectedGroupId !== null)
@@ -87,6 +168,7 @@ export function AgentsModule({ workspaceId }) {
87
168
  }, [allGroups, selectedGroupId]);
88
169
  const handleMerge = async (keepId, mergeId) => {
89
170
  setAiProfileMergeStatus(null);
171
+ setAiProfileArchiveError(null);
90
172
  try {
91
173
  const res = await fetch('/api/taskforce/workspace/ai-profiles/merge', {
92
174
  method: 'POST',
@@ -102,11 +184,225 @@ export function AgentsModule({ workspaceId }) {
102
184
  setAiProfileMergeState(null);
103
185
  setAiProfileMergeStatus({ type: 'success', message: 'AI profiles merged.' });
104
186
  await loadAiProfiles();
187
+ dispatchTaskforceAiProfilesMutated({ workspaceId, profileId: keepId, reason: 'merge' });
105
188
  }
106
189
  catch {
107
190
  setAiProfileMergeStatus({ type: 'error', message: 'Failed to merge AI profiles.' });
108
191
  }
109
192
  };
193
+ const handleArchive = async (profile) => {
194
+ const confirmed = window.confirm(`Remove ${profile.name} from the active roster? This frees an AI profile seat and preserves task and comment history.`);
195
+ if (!confirmed)
196
+ return;
197
+ setAiProfileArchiveError(null);
198
+ setAiProfileMergeStatus(null);
199
+ try {
200
+ const res = await fetch('/api/taskforce/workspace/ai-profiles/archive', {
201
+ method: 'POST',
202
+ credentials: 'include',
203
+ headers: { 'Content-Type': 'application/json' },
204
+ body: JSON.stringify({ profileId: profile.id, reason: 'manual_archive' }),
205
+ });
206
+ const data = await res.json().catch(() => ({}));
207
+ if (!res.ok) {
208
+ setAiProfileArchiveError({
209
+ profileId: profile.id,
210
+ message: String(data?.error || 'Failed to remove AI profile from roster.')
211
+ });
212
+ return;
213
+ }
214
+ if (aiProfileMergeState?.keepId === profile.id || aiProfileMergeState?.mergeId === profile.id) {
215
+ setAiProfileMergeState(null);
216
+ }
217
+ setAiProfileMergeStatus({ type: 'success', message: 'AI profile removed from active roster.' });
218
+ await loadAiProfiles();
219
+ dispatchTaskforceAiProfilesMutated({ workspaceId, profileId: profile.id, reason: 'archive' });
220
+ }
221
+ catch {
222
+ setAiProfileArchiveError({
223
+ profileId: profile.id,
224
+ message: 'Failed to remove AI profile from roster.'
225
+ });
226
+ }
227
+ };
228
+ const handleCategoryChange = async (group, value) => {
229
+ const nextSurfaceType = parseAiProfileSurfaceType(value);
230
+ const currentSurfaceTypes = new Set(group.profiles.map((profile) => profile.surfaceType ?? ''));
231
+ const nextSurfaceTypeKey = nextSurfaceType ?? '';
232
+ if (currentSurfaceTypes.size === 1 && currentSurfaceTypes.has(nextSurfaceTypeKey))
233
+ return;
234
+ setAiProfileCategoryBusy(true);
235
+ setAiProfileCategoryError(null);
236
+ setAiProfileMergeStatus(null);
237
+ const updatedProfiles = [];
238
+ try {
239
+ for (const profile of group.profiles) {
240
+ const res = await fetch('/api/taskforce/workspace/ai-profiles/surface-type', {
241
+ method: 'POST',
242
+ credentials: 'include',
243
+ headers: { 'Content-Type': 'application/json' },
244
+ body: JSON.stringify({
245
+ profileId: profile.id,
246
+ surfaceType: nextSurfaceType
247
+ }),
248
+ });
249
+ const data = await res.json().catch(() => ({}));
250
+ if (!res.ok || !data?.profile) {
251
+ throw new Error(String(data?.error || 'Failed to update AI profile category.'));
252
+ }
253
+ const updated = data.profile;
254
+ updatedProfiles.push({
255
+ ...profile,
256
+ surfaceType: parseAiProfileSurfaceType(updated.surfaceType),
257
+ updatedAt: typeof updated.updatedAt === 'string' ? updated.updatedAt : profile.updatedAt
258
+ });
259
+ }
260
+ const updatedById = new Map(updatedProfiles.map((profile) => [profile.id, profile]));
261
+ setAiProfiles((current) => current.map((profile) => updatedById.get(profile.id) || profile));
262
+ const nextPrimary = updatedById.get(group.primaryProfile.id) || {
263
+ ...group.primaryProfile,
264
+ surfaceType: nextSurfaceType
265
+ };
266
+ const nextSection = getAiProfileSurfaceTypeSection(nextPrimary.surfaceType);
267
+ setSelectedGroupId(`${nextSection}:${buildAiProfileGroupKey(nextPrimary)}`);
268
+ setAiProfileMergeStatus({ type: 'success', message: 'AI profile category updated.' });
269
+ for (const profile of updatedProfiles) {
270
+ dispatchTaskforceAiProfilesMutated({ workspaceId, profileId: profile.id, reason: 'update' });
271
+ }
272
+ }
273
+ catch (error) {
274
+ setAiProfileCategoryError({
275
+ profileId: group.primaryProfile.id,
276
+ message: String(error?.message || 'Failed to update AI profile category.')
277
+ });
278
+ }
279
+ finally {
280
+ setAiProfileCategoryBusy(false);
281
+ }
282
+ };
283
+ const fileToDataUrl = (file) => new Promise((resolve, reject) => {
284
+ const reader = new FileReader();
285
+ reader.onload = () => resolve(String(reader.result || ''));
286
+ reader.onerror = () => reject(new Error('Failed to read image file.'));
287
+ reader.readAsDataURL(file);
288
+ });
289
+ const applyAiProfileAvatarUpdate = (updatedProfile) => {
290
+ const updatedId = String(updatedProfile?.id || '').trim();
291
+ if (!updatedId)
292
+ return;
293
+ setAiProfiles((current) => current.map((profile) => (profile.id === updatedId
294
+ ? {
295
+ ...profile,
296
+ avatarUrl: typeof updatedProfile.avatarUrl === 'string' ? updatedProfile.avatarUrl : null,
297
+ avatarSourceUrl: typeof updatedProfile.avatarSourceUrl === 'string' ? updatedProfile.avatarSourceUrl : null,
298
+ avatarRevision: Number.isFinite(Number(updatedProfile.avatarRevision)) ? Math.max(0, Math.floor(Number(updatedProfile.avatarRevision))) : profile.avatarRevision,
299
+ avatarUpdatedAt: typeof updatedProfile.avatarUpdatedAt === 'string' ? updatedProfile.avatarUpdatedAt : profile.avatarUpdatedAt,
300
+ updatedAt: typeof updatedProfile.updatedAt === 'string' ? updatedProfile.updatedAt : profile.updatedAt
301
+ }
302
+ : profile)));
303
+ };
304
+ const uploadAiProfileAvatar = async (profileId, displayFile, sourceFile) => {
305
+ const displayDataUrl = await fileToDataUrl(displayFile);
306
+ const sourceDataUrl = sourceFile ? await fileToDataUrl(sourceFile) : null;
307
+ const payload = {
308
+ profileId,
309
+ displayImage: {
310
+ dataUrl: displayDataUrl,
311
+ mimeType: displayFile.type || 'application/octet-stream',
312
+ originalName: displayFile.name || 'display-avatar'
313
+ }
314
+ };
315
+ if (sourceFile && sourceDataUrl) {
316
+ payload.sourceImage = {
317
+ dataUrl: sourceDataUrl,
318
+ mimeType: sourceFile.type || 'application/octet-stream',
319
+ originalName: sourceFile.name || 'source-avatar'
320
+ };
321
+ }
322
+ const res = await fetch('/api/taskforce/workspace/ai-profiles/avatar/upload', {
323
+ method: 'POST',
324
+ credentials: 'include',
325
+ headers: { 'Content-Type': 'application/json' },
326
+ body: JSON.stringify(payload),
327
+ });
328
+ const data = await res.json().catch(() => ({}));
329
+ if (!res.ok || !data?.profile) {
330
+ throw new Error(String(data?.error || 'Failed to update AI profile avatar.'));
331
+ }
332
+ applyAiProfileAvatarUpdate(data.profile);
333
+ dispatchTaskforceAiProfilesMutated({ workspaceId, profileId, reason: 'avatar' });
334
+ };
335
+ const clearAiProfileAvatar = async (profileId) => {
336
+ const res = await fetch('/api/taskforce/workspace/ai-profiles/avatar', {
337
+ method: 'POST',
338
+ credentials: 'include',
339
+ headers: { 'Content-Type': 'application/json' },
340
+ body: JSON.stringify({
341
+ profileId,
342
+ avatarUrl: null,
343
+ avatarSourceUrl: null
344
+ })
345
+ });
346
+ const data = await res.json().catch(() => ({}));
347
+ if (!res.ok || !data?.profile) {
348
+ throw new Error(String(data?.error || 'Failed to update AI profile avatar.'));
349
+ }
350
+ applyAiProfileAvatarUpdate(data.profile);
351
+ dispatchTaskforceAiProfilesMutated({ workspaceId, profileId, reason: 'avatar' });
352
+ };
353
+ const handleAiProfileAvatarSelected = async (file, sourceFile) => {
354
+ if (!avatarEditorProfile)
355
+ return false;
356
+ if (!file.type.startsWith('image/')) {
357
+ setAiAvatarError('AI profile photo must be an image file.');
358
+ return false;
359
+ }
360
+ setAiAvatarBusy(true);
361
+ setAiAvatarError(null);
362
+ try {
363
+ const preparedAvatar = await prepareAvatarUploadFile(file, { maxBytes: 5 * 1024 * 1024 });
364
+ if (preparedAvatar.exceededLimit) {
365
+ throw new Error(file.type === 'image/gif'
366
+ ? 'Animated GIF AI profile photos must be 5 MB or smaller.'
367
+ : 'AI profile photo must be 5 MB or smaller.');
368
+ }
369
+ const uploadFile = preparedAvatar.file;
370
+ let preparedSourceFile = null;
371
+ if (sourceFile) {
372
+ const preparedSource = await prepareAvatarUploadFile(sourceFile, { maxBytes: 5 * 1024 * 1024 });
373
+ if (preparedSource.exceededLimit) {
374
+ throw new Error(sourceFile.type === 'image/gif'
375
+ ? 'Animated GIF AI profile photos must be 5 MB or smaller.'
376
+ : 'AI profile source photo must be 5 MB or smaller.');
377
+ }
378
+ preparedSourceFile = preparedSource.file;
379
+ }
380
+ await uploadAiProfileAvatar(avatarEditorProfile.id, uploadFile, preparedSourceFile);
381
+ return true;
382
+ }
383
+ catch (error) {
384
+ setAiAvatarError(String(error?.message || 'Failed to update AI profile photo.'));
385
+ return false;
386
+ }
387
+ finally {
388
+ setAiAvatarBusy(false);
389
+ }
390
+ };
391
+ const handleAiProfileAvatarRemove = async () => {
392
+ if (!avatarEditorProfile)
393
+ return;
394
+ setAiAvatarBusy(true);
395
+ setAiAvatarError(null);
396
+ try {
397
+ await clearAiProfileAvatar(avatarEditorProfile.id);
398
+ }
399
+ catch (error) {
400
+ setAiAvatarError(String(error?.message || 'Failed to remove AI profile photo.'));
401
+ }
402
+ finally {
403
+ setAiAvatarBusy(false);
404
+ }
405
+ };
110
406
  const formatTimestamp = (value) => {
111
407
  const normalized = String(value || '').trim();
112
408
  if (!normalized)
@@ -119,13 +415,65 @@ export function AgentsModule({ workspaceId }) {
119
415
  timeStyle: 'short'
120
416
  });
121
417
  };
122
- return (_jsx("div", { className: `${styles.standalonePage} ${styles.standaloneContent}`, style: { overflow: 'auto' }, children: _jsx("div", { className: styles.settingsContent, style: { maxWidth: 1080, margin: '0 auto', width: '100%' }, children: _jsx("div", { className: styles.settingGroup, children: _jsxs("div", { children: [_jsx("h4", { className: styles.settingSubTitle, children: "Registered AI Profiles" }), _jsx("p", { className: `${styles.settingsHint} ${styles.marginBottom12}`, children: "AI agents register profiles when connecting via MCP. Merge duplicates created when a token was lost." }), aiProfilesLoading && (_jsxs("div", { className: styles.settingsHint, children: [_jsx(Loader2, { size: 13, className: styles.spinner }), " Loading profiles\u2026"] })), !aiProfilesLoading && aiProfiles.length === 0 && (_jsx("div", { className: styles.settingsHint, children: "No AI profiles registered yet." })), !aiProfilesLoading && groupedProfilesBySurfaceType.length > 0 && (_jsxs("div", { className: styles.aiProfilesExplorer, children: [_jsx("div", { className: styles.aiProfilesListPane, children: _jsx("div", { className: styles.aiProfilesList, children: groupedProfilesBySurfaceType.map((section) => (_jsxs("div", { className: styles.aiProfilesSection, children: [_jsx("div", { className: styles.aiProfilesSectionHeader, children: section.label }), section.groups.map((group) => {
123
- const isSelected = selectedGroup?.groupId === group.groupId;
124
- const primary = group.primaryProfile;
125
- return (_jsxs("button", { type: "button", className: `${styles.aiProfileGroup} ${group.profiles.length > 1 ? styles.aiProfileGroupDuplicate : ''} ${isSelected ? styles.aiProfileGroupSelected : ''}`, onClick: () => setSelectedGroupId(group.groupId), "aria-pressed": isSelected, children: [_jsxs("div", { className: styles.aiProfileGroupHeader, children: [_jsx(Bot, { size: 13, style: { color: primary.color } }), _jsx("span", { className: styles.aiProfileName, children: primary.name }), group.profiles.length > 1 && (_jsxs("span", { className: styles.aiProfileDuplicateBadge, children: [_jsx(AlertTriangle, { size: 11 }), " ", group.profiles.length, " duplicates"] }))] }), _jsxs("div", { className: styles.settingsHint, style: { marginTop: 6 }, children: ["@", primary.username] }), (primary.surfaceType || primary.role || primary.provider || primary.model) && (_jsxs("div", { className: styles.aiProfileMetaRow, children: [primary.surfaceType && (_jsx("span", { className: styles.aiProfileSurfaceBadge, children: formatAiProfileSurfaceTypeLabel(primary.surfaceType) })), primary.role && _jsx("span", { children: primary.role }), primary.provider && _jsx("span", { children: primary.provider }), primary.model && _jsx("span", { children: primary.model })] })), primary.description && (_jsx("div", { className: styles.settingsHint, style: { marginTop: 4 }, children: primary.description }))] }, group.groupId));
126
- })] }, section.section))) }) }), selectedGroup && (_jsx("div", { className: styles.aiProfileDetailPane, children: _jsxs("div", { className: styles.aiProfileDetailCard, children: [_jsxs("div", { className: styles.aiProfileDetailHero, children: [_jsx("div", { className: styles.aiProfileDetailIcon, style: { color: selectedGroup.primaryProfile.color }, children: _jsx(Bot, { size: 18 }) }), _jsxs("div", { className: styles.aiProfileDetailHeading, children: [_jsx("div", { className: styles.aiProfileDetailTitleRow, children: _jsx("h5", { className: styles.aiProfileDetailTitle, children: selectedGroup.primaryProfile.name }) }), _jsxs("div", { className: styles.aiProfileDetailMetaRow, children: [_jsxs("span", { className: styles.aiProfileDetailHandle, children: ["@", selectedGroup.primaryProfile.username] }), _jsx("span", { className: styles.aiProfileDetailSectionBadge, children: selectedGroup.sectionLabel }), selectedGroup.profiles.length > 1 && (_jsxs("span", { className: styles.aiProfileDetailLinkedCount, children: [selectedGroup.profiles.length, " linked"] }))] })] })] }), selectedGroup.primaryProfile.description && (_jsx("div", { className: styles.aiProfileDetailDescription, children: selectedGroup.primaryProfile.description })), _jsxs("div", { className: styles.aiProfileDetailGrid, children: [_jsxs("div", { className: styles.aiProfileDetailStat, children: [_jsxs("span", { className: styles.aiProfileDetailStatLabel, children: [_jsx(Sparkles, { size: 12 }), " Role"] }), _jsx("span", { className: styles.aiProfileDetailStatValue, children: selectedGroup.primaryProfile.role || 'Not set' })] }), _jsxs("div", { className: styles.aiProfileDetailStat, children: [_jsxs("span", { className: styles.aiProfileDetailStatLabel, children: [_jsx(Orbit, { size: 12 }), " Provider"] }), _jsx("span", { className: styles.aiProfileDetailStatValue, children: [selectedGroup.primaryProfile.provider, selectedGroup.primaryProfile.model].filter(Boolean).join(' · ') || 'Not set' })] }), _jsxs("div", { className: styles.aiProfileDetailStat, children: [_jsxs("span", { className: styles.aiProfileDetailStatLabel, children: [_jsx(Clock3, { size: 12 }), " Last active"] }), _jsx("span", { className: styles.aiProfileDetailStatValue, children: formatTimestamp(selectedGroup.primaryProfile.lastActiveAt) })] }), _jsxs("div", { className: styles.aiProfileDetailStat, children: [_jsxs("span", { className: styles.aiProfileDetailStatLabel, children: [_jsx(Clock3, { size: 12 }), " Updated"] }), _jsx("span", { className: styles.aiProfileDetailStatValue, children: formatTimestamp(selectedGroup.primaryProfile.updatedAt) })] })] }), _jsxs("div", { className: styles.aiProfileInstanceSection, children: [_jsxs("div", { className: styles.aiProfileInstanceSectionHeader, children: [_jsx("span", { children: "Profile instances" }), _jsx("span", { className: styles.settingsHint, children: "Choose a keeper here if duplicates need to be merged." })] }), _jsx("div", { className: styles.aiProfileInstanceList, children: selectedGroup.profiles.map((profile) => (_jsxs("div", { className: styles.aiProfileInstanceCard, children: [_jsxs("div", { className: styles.aiProfileInstanceTopRow, children: [_jsxs("div", { children: [_jsxs("div", { className: styles.aiProfileInstanceName, children: ["@", profile.username] }), _jsx("div", { className: styles.aiProfileIdChip, children: profile.id })] }), selectedGroup.profiles.length > 1 && aiProfileMergeState?.keepId === profile.id && (_jsx("span", { className: styles.aiProfileKeepBadge, children: "Keeping" }))] }), _jsxs("div", { className: styles.aiProfileInstanceMeta, children: [_jsxs("span", { children: ["Created ", formatTimestamp(profile.createdAt)] }), _jsxs("span", { children: ["Updated ", formatTimestamp(profile.updatedAt)] })] }), selectedGroup.profiles.length > 1 && aiProfileMergeState?.keepId !== profile.id && (_jsx("button", { className: styles.secondaryHeaderBtn, title: "Keep this profile, merge others into it", onClick: () => {
127
- const otherId = selectedGroup.profiles.find((candidate) => candidate.id !== profile.id)?.id;
128
- if (otherId)
129
- setAiProfileMergeState({ keepId: profile.id, mergeId: otherId });
130
- }, children: "Keep this" }))] }, profile.id))) }), aiProfileMergeState && selectedGroup.profiles.some((profile) => profile.id === aiProfileMergeState.keepId) && (_jsxs("div", { className: styles.aiProfileMergeActions, children: [_jsx("button", { className: styles.dangerBtn, onClick: () => { void handleMerge(aiProfileMergeState.keepId, aiProfileMergeState.mergeId); }, children: "Merge duplicates" }), _jsx("button", { className: styles.secondaryHeaderBtn, onClick: () => setAiProfileMergeState(null), children: "Cancel" })] }))] })] }) }))] })), aiProfileMergeStatus && (_jsxs("div", { className: `${aiProfileMergeStatus.type === 'success' ? styles.successMessage : styles.errorMessage} ${styles.marginTop12}`, children: [aiProfileMergeStatus.type === 'success' ? _jsx(Check, { size: 14 }) : _jsx(AlertTriangle, { size: 14 }), aiProfileMergeStatus.message] }))] }) }) }) }));
418
+ const selectedProfileDataGroups = useMemo(() => {
419
+ if (!selectedGroup)
420
+ return { attributes: [], dates: [] };
421
+ const profile = selectedGroup.primaryProfile;
422
+ const formatRowValue = (value) => value || 'Not set';
423
+ return {
424
+ attributes: [
425
+ { label: 'Category', value: profile.surfaceType ? formatAiProfileSurfaceTypeLabel(profile.surfaceType) : '' },
426
+ { label: 'Connection', value: profile.seatScope ? formatAiProfileSeatScopeLabel(profile.seatScope) : '' },
427
+ { label: 'Provider', value: profile.provider || '' },
428
+ { label: 'Model', value: profile.model || '' },
429
+ ].map((row) => ({ ...row, value: formatRowValue(row.value) })),
430
+ dates: [
431
+ { label: 'Status', value: profile.archivedAt ? 'Retired' : 'Active' },
432
+ { label: 'Recruited', value: formatTimestamp(profile.createdAt) },
433
+ { label: 'Last updated', value: formatTimestamp(profile.updatedAt) },
434
+ { label: 'Last active', value: formatTimestamp(profile.lastActiveAt) },
435
+ ].map((row) => ({ ...row, value: formatRowValue(row.value) })),
436
+ };
437
+ }, [selectedGroup]);
438
+ const selectedGroupHasDuplicates = !!selectedGroup && selectedGroup.profiles.length > 1;
439
+ const shouldPromptForCloudLogin = cloudAuthConfigured && authSessionResolved && !isAuthenticated;
440
+ const displayedSeatUsage = cloudAuthConfigured
441
+ ? parseAiProfileSeatUsage(cloudAiProfileSeatUsage)
442
+ : localAiProfileSeatUsage;
443
+ const cloudAgentSeatLabel = shouldPromptForCloudLogin
444
+ ? 'Log into account for Cloud agents'
445
+ : displayedSeatUsage
446
+ ? `${displayedSeatUsage.used}/${displayedSeatUsage.limit === null ? 'Unlimited' : displayedSeatUsage.limit}`
447
+ : null;
448
+ const showAgentTray = !!mcpSettingsNode;
449
+ return (_jsxs("section", { className: `${styles.agentsModuleRoot} ${showAgentTray ? styles.agentsModuleWithTray : ''} ${showAgentTray && agentTrayOpen ? styles.agentsModuleTrayOpen : ''}`.trim(), children: [showAgentTray && (_jsxs("aside", { className: `${styles.agentTrayPanel} ${agentTrayOpen ? styles.agentTrayPanelOpen : ''}`.trim(), "aria-label": "Agent MCP settings tray", "aria-hidden": !agentTrayOpen, children: [_jsxs("div", { className: styles.agentTrayHeader, children: [_jsxs("span", { className: styles.agentTrayTitle, children: [_jsx(Plug, { size: 14 }), "MCP Settings"] }), _jsx("button", { type: "button", className: "tf-control-icon", onClick: onCloseAgentTray, title: "Collapse agent tray", "aria-label": "Collapse agent tray", children: _jsx(ChevronLeft, { size: 16 }) })] }), _jsx("div", { className: `${styles.agentTrayContent} tf-scrollbar tf-scrollbar--track-transparent`, children: _jsx("div", { className: styles.agentTrayContentInner, children: mcpSettingsNode }) })] })), _jsx("div", { className: styles.agentsModuleContent, children: _jsx("div", { className: `${styles.settingGroup} ${styles.agentsModuleGroup}`, children: _jsxs("div", { children: [_jsx("h4", { className: styles.settingSubTitle, children: "Registered AI Profiles" }), _jsx("p", { className: `${styles.settingsHint} ${styles.marginBottom12}`, children: "AI agents register profiles when connecting via MCP. Merge duplicates created when a token was lost, or remove inactive profiles from the active roster to free seats while preserving history." }), cloudAgentSeatLabel && (_jsx("div", { className: styles.aiProfileSeatSummary, children: shouldPromptForCloudLogin
450
+ ? cloudAgentSeatLabel
451
+ : `Registered Cloud Agents: ${cloudAgentSeatLabel}` })), aiProfilesLoading && (_jsxs("div", { className: styles.settingsHint, children: [_jsx(Loader2, { size: 13, className: styles.spinner }), " Loading profiles\u2026"] })), !aiProfilesLoading && aiProfiles.length === 0 && (_jsx("div", { className: styles.settingsHint, children: "No AI profiles registered yet." })), !aiProfilesLoading && groupedProfilesBySurfaceType.length > 0 && (_jsxs("div", { className: styles.aiProfilesExplorer, children: [_jsx("div", { className: `${styles.aiProfilesListPane} tf-scrollbar tf-scrollbar--track-transparent`, children: _jsx("div", { className: styles.aiProfilesList, children: groupedProfilesBySurfaceType.map((section) => (_jsxs("div", { className: styles.aiProfilesSection, children: [_jsx("div", { className: styles.aiProfilesSectionHeader, children: section.label }), section.groups.map((group) => {
452
+ const isSelected = selectedGroup?.groupId === group.groupId;
453
+ const primary = group.primaryProfile;
454
+ return (_jsxs("div", { role: "button", tabIndex: 0, className: `${styles.aiProfileGroup} ${group.profiles.length > 1 ? styles.aiProfileGroupDuplicate : ''} ${isSelected ? styles.aiProfileGroupSelected : ''}`, onClick: () => setSelectedGroupId(group.groupId), onKeyDown: (event) => {
455
+ if (event.key !== 'Enter' && event.key !== ' ')
456
+ return;
457
+ event.preventDefault();
458
+ setSelectedGroupId(group.groupId);
459
+ }, "aria-pressed": isSelected, children: [renderAiProfileSeatScopeIcon(primary.seatScope), _jsxs("div", { className: styles.aiProfileGroupHeader, children: [_jsx("span", { className: styles.aiProfileGroupAvatar, style: { color: primary.color }, children: primary.avatarUrl ? (_jsx("img", { src: getAiProfileAvatarDisplayUrl(primary), alt: "" })) : (_jsx(Bot, { size: 22 })) }), _jsxs("span", { className: styles.aiProfileGroupIdentity, children: [_jsx("span", { className: styles.aiProfileName, children: primary.name }), _jsxs("span", { className: styles.aiProfileHandle, children: ["@", primary.username] }), _jsx("span", { className: styles.aiProfileRole, children: primary.role || 'Role not set' }), group.profiles.length > 1 && (_jsxs("span", { className: styles.aiProfileDuplicateBadge, children: [_jsx(AlertTriangle, { size: 11 }), " ", formatDuplicateCount(group.profiles.length)] }))] })] })] }, group.groupId));
460
+ })] }, section.section))) }) }), selectedGroup && (_jsx("div", { className: styles.aiProfileDetailPane, children: _jsxs("div", { className: styles.aiProfileDetailCard, children: [renderAiProfileSeatScopeIcon(selectedGroup.primaryProfile.seatScope, { variant: 'detail' }), _jsxs("div", { className: styles.aiProfileDetailHero, children: [_jsx(EditableAvatarButton, { label: "Edit AI profile photo", imageUrl: getAiProfileAvatarDisplayUrl(selectedGroup.primaryProfile), fallback: _jsx(Bot, { size: 38 }), accentColor: selectedGroup.primaryProfile.color, size: 176, width: 153, height: 207, radius: 6, editBadgeSize: 28, editIconSize: 14, className: styles.aiProfileDetailAvatar, onClick: () => {
461
+ setAiAvatarError(null);
462
+ setAvatarEditorProfileId(selectedGroup.primaryProfile.id);
463
+ } }), _jsxs("div", { className: styles.aiProfileDetailHeading, children: [_jsx("div", { className: styles.aiProfileDetailTitleRow, children: _jsx("h5", { className: styles.aiProfileDetailTitle, children: selectedGroup.primaryProfile.name }) }), _jsxs("div", { className: styles.aiProfileDetailMetaRow, children: [_jsxs("span", { className: styles.aiProfileDetailHandle, children: ["@", selectedGroup.primaryProfile.username] }), selectedGroup.profiles.length > 1 && (_jsxs("span", { className: styles.aiProfileDetailLinkedCount, children: [selectedGroup.profiles.length, " linked"] }))] }), _jsxs("div", { className: styles.aiProfileDetailRole, children: ["Role: ", selectedGroup.primaryProfile.role || 'Not set'] }), selectedGroup.primaryProfile.description && (_jsx("div", { className: styles.aiProfileDetailDescription, children: selectedGroup.primaryProfile.description })), _jsxs("div", { className: styles.aiProfileSignatureColor, children: [_jsx("span", { children: "Signature color" }), _jsx("span", { className: styles.aiProfileSignatureSwatch, style: { backgroundColor: selectedGroup.primaryProfile.color }, "aria-hidden": "true" }), _jsx("span", { children: selectedGroup.primaryProfile.color })] })] })] }), _jsxs("div", { className: styles.aiProfileDetailDataList, children: [_jsx("div", { className: styles.aiProfileDetailDataGroup, children: selectedProfileDataGroups.attributes.map((row) => (_jsxs("div", { className: styles.aiProfileDetailDataRow, children: [_jsx("span", { className: styles.aiProfileDetailDataLabel, children: row.label }), row.label === 'Category' ? (_jsx("span", { className: styles.aiProfileDetailDataValue, children: _jsxs("select", { className: styles.aiProfileStatusSelect, "aria-label": "Agent category", value: selectedGroup.primaryProfile.surfaceType ?? '', disabled: aiProfileCategoryBusy, onChange: (event) => {
464
+ void handleCategoryChange(selectedGroup, event.target.value);
465
+ }, children: [_jsx("option", { value: "", children: "Unclassified" }), AI_PROFILE_SURFACE_TYPES.map((surfaceType) => (_jsx("option", { value: surfaceType, children: formatAiProfileSurfaceTypeLabel(surfaceType) }, surfaceType)))] }) })) : (_jsx("span", { className: styles.aiProfileDetailDataValue, children: row.value }))] }, row.label))) }), _jsx("div", { className: `${styles.aiProfileDetailDataGroup} ${styles.aiProfileDetailDateGroup}`, children: selectedProfileDataGroups.dates.map((row) => (_jsxs("div", { className: styles.aiProfileDetailDataRow, children: [_jsx("span", { className: styles.aiProfileDetailDataLabel, children: row.label }), row.label === 'Status' ? (_jsx("span", { className: styles.aiProfileDetailDataValue, children: _jsxs("select", { className: styles.aiProfileStatusSelect, "aria-label": "Agent roster status", value: selectedGroup.primaryProfile.archivedAt ? 'retired' : 'active', onChange: (event) => {
466
+ if (event.target.value === 'retire') {
467
+ void handleArchive(selectedGroup.primaryProfile);
468
+ }
469
+ }, children: [_jsx("option", { value: "active", children: "Active" }), selectedGroup.primaryProfile.archivedAt ? (_jsx("option", { value: "retired", children: "Retired" })) : (_jsx("option", { value: "retire", children: "Retire from roster" }))] }) })) : (_jsx("span", { className: styles.aiProfileDetailDataValue, children: row.value }))] }, row.label))) })] }), aiProfileCategoryError?.profileId === selectedGroup.primaryProfile.id && (_jsxs("div", { className: styles.aiProfileInlineError, role: "alert", children: [_jsx(AlertTriangle, { size: 12 }), _jsx("span", { children: aiProfileCategoryError.message })] })), selectedGroupHasDuplicates ? (_jsxs("div", { className: styles.aiProfileInstanceSection, children: [_jsxs("div", { className: styles.aiProfileInstanceSectionHeader, children: [_jsx("span", { children: "Profile instances" }), _jsx("span", { className: styles.settingsHint, children: "Choose a keeper here if duplicates need to be merged." })] }), _jsx("div", { className: styles.aiProfileInstanceList, children: selectedGroup.profiles.map((profile) => (_jsxs("div", { className: styles.aiProfileInstanceCard, children: [_jsxs("div", { className: styles.aiProfileInstanceTopRow, children: [_jsxs("div", { children: [_jsxs("div", { className: styles.aiProfileInstanceName, children: ["@", profile.username] }), _jsx("div", { className: styles.aiProfileIdChip, children: profile.id })] }), aiProfileMergeState?.keepId === profile.id && (_jsx("span", { className: styles.aiProfileKeepBadge, children: "Keeping" }))] }), _jsxs("div", { className: styles.aiProfileInstanceMeta, children: [_jsxs("span", { children: ["Created ", formatTimestamp(profile.createdAt)] }), _jsxs("span", { children: ["Updated ", formatTimestamp(profile.updatedAt)] })] }), aiProfileMergeState?.keepId !== profile.id && (_jsx("button", { className: styles.secondaryHeaderBtn, title: "Keep this profile, merge others into it", onClick: () => {
470
+ const otherId = selectedGroup.profiles.find((candidate) => candidate.id !== profile.id)?.id;
471
+ if (otherId)
472
+ setAiProfileMergeState({ keepId: profile.id, mergeId: otherId });
473
+ }, children: "Keep this" })), aiProfileArchiveError?.profileId === profile.id && (_jsxs("div", { className: styles.aiProfileInlineError, role: "alert", children: [_jsx(AlertTriangle, { size: 12 }), _jsx("span", { children: aiProfileArchiveError.message })] })), _jsx("button", { className: styles.aiProfileDangerTextButton, title: "Remove this profile from the active roster", onClick: () => { void handleArchive(profile); }, children: "Remove from roster" })] }, profile.id))) }), aiProfileMergeState && selectedGroup.profiles.some((profile) => profile.id === aiProfileMergeState.keepId) && (_jsxs("div", { className: styles.aiProfileMergeActions, children: [_jsx("button", { className: styles.dangerBtn, onClick: () => { void handleMerge(aiProfileMergeState.keepId, aiProfileMergeState.mergeId); }, children: "Merge duplicates" }), _jsx("button", { className: styles.secondaryHeaderBtn, onClick: () => setAiProfileMergeState(null), children: "Cancel" })] }))] })) : (_jsxs("div", { className: styles.aiProfileIdFooter, children: [_jsx("div", { className: styles.aiProfileIdFooterValue, children: selectedGroup.primaryProfile.id }), aiProfileArchiveError?.profileId === selectedGroup.primaryProfile.id && (_jsxs("div", { className: styles.aiProfileInlineError, role: "alert", children: [_jsx(AlertTriangle, { size: 12 }), _jsx("span", { children: aiProfileArchiveError.message })] }))] }))] }) }))] })), aiProfileMergeStatus && (_jsxs("div", { className: `${aiProfileMergeStatus.type === 'success' ? styles.successMessage : styles.errorMessage} ${styles.marginTop12}`, children: [aiProfileMergeStatus.type === 'success' ? _jsx(Check, { size: 14 }) : _jsx(AlertTriangle, { size: 14 }), aiProfileMergeStatus.message] }))] }) }) }), _jsx(AvatarImageManagerModal, { isOpen: !!avatarEditorProfile, theme: "dark", title: "Edit AI Profile Photo", currentImageUrl: getAiProfileAvatarDisplayUrl(avatarEditorProfile), editorImageUrl: getAiProfileAvatarSourceUrl(avatarEditorProfile), fallbackInitial: (avatarEditorProfile?.name || 'AI').charAt(0).toUpperCase(), accept: "image/png,image/jpeg,image/webp,image/gif", busy: aiAvatarBusy, hasPendingImage: false, canRemove: !!avatarEditorProfile?.avatarUrl, error: aiAvatarError, notice: null, onClose: () => {
474
+ if (aiAvatarBusy)
475
+ return;
476
+ setAvatarEditorProfileId(null);
477
+ setAiAvatarError(null);
478
+ }, onApplyImage: handleAiProfileAvatarSelected, onRemoveImage: handleAiProfileAvatarRemove })] }));
131
479
  }