@taskforcehq/taskforce 0.3.329 → 0.3.330

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 (321) hide show
  1. package/dist/Taskforce.module.css +290 -45
  2. package/dist/components/features/AiProfilesModule.js +3 -5
  3. package/dist/components/features/TaskSettings.js +70 -14
  4. package/dist/components/features/TaskforceAgentsModule.d.ts +1 -2
  5. package/dist/components/features/TaskforceAgentsModule.js +586 -116
  6. package/dist/components/features/agentConnections/AgentConnectionControl.d.ts +15 -0
  7. package/dist/components/features/agentConnections/AgentConnectionControl.js +125 -0
  8. package/dist/components/features/agentConnections/ModelConnectionsPanel.d.ts +18 -0
  9. package/dist/components/features/agentConnections/ModelConnectionsPanel.js +393 -0
  10. package/dist/components/features/agentConnections/modelConnectionsApi.d.ts +65 -0
  11. package/dist/components/features/agentConnections/modelConnectionsApi.js +129 -0
  12. package/dist/components/features/taskforceAgentAssignments/AgentBehaviorAssignments.js +15 -24
  13. package/dist/components/features/taskforceAgentEditorModel.d.ts +2 -1
  14. package/dist/components/features/taskforceAgentEditorModel.js +3 -1
  15. package/dist/components/features/workflowManager/workflowManagerApi.d.ts +1 -1
  16. package/dist/components/features/workflowManager/workflowManagerApi.js +3 -0
  17. package/dist/components/task/TaskWorkflowAssignmentField.js +68 -10
  18. package/dist/components/views/StandaloneLayout.js +27 -26
  19. package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +4 -3
  20. package/dist/components/views/standalone/modals/SyncStatusModal.js +33 -38
  21. package/dist/config/envSchema.js +48 -1
  22. package/dist/core/McpTokenService.d.ts +23 -1
  23. package/dist/core/McpTokenService.js +93 -10
  24. package/dist/core/TaskChecklistCommandService.d.ts +27 -0
  25. package/dist/core/TaskChecklistCommandService.js +83 -5
  26. package/dist/core/TaskLifecycleCommandService.d.ts +3 -1
  27. package/dist/core/TaskLifecycleCommandService.js +6 -2
  28. package/dist/core/Taskforce.d.ts +32 -0
  29. package/dist/core/Taskforce.js +125 -4
  30. package/dist/core/types.d.ts +8 -0
  31. package/dist/documentReviews/commandService.d.ts +2 -1
  32. package/dist/documentReviews/commandService.js +6 -3
  33. package/dist/hooks/sync/orchestratorShared.d.ts +1 -0
  34. package/dist/hooks/sync/orchestratorShared.js +2 -0
  35. package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.d.ts +3 -0
  36. package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.js +85 -9
  37. package/dist/hooks/sync/useSyncStatusControls.d.ts +4 -1
  38. package/dist/hooks/sync/useSyncStatusControls.js +47 -11
  39. package/dist/hooks/useSyncOrchestrator.d.ts +3 -0
  40. package/dist/hooks/useSyncOrchestrator.js +111 -2
  41. package/dist/hooks/useTaskData.d.ts +31 -1
  42. package/dist/hooks/useTaskData.js +29 -7
  43. package/dist/hooks/useTaskMutations.d.ts +3 -1
  44. package/dist/hooks/useTaskMutations.js +46 -12
  45. package/dist/hooks/useTaskforce.d.ts +2 -0
  46. package/dist/hooks/useTaskforce.js +11 -2
  47. package/dist/mcp/clientRegistry.d.ts +2 -2
  48. package/dist/mcp/clientRegistry.js +1 -1
  49. package/dist/mcp/documentAssetRegistrar.js +9 -6
  50. package/dist/mcp/durableTaskMutationRouter.d.ts +4 -1
  51. package/dist/mcp/durableTaskMutationRouter.js +10 -0
  52. package/dist/mcp/durableTaskRelationshipMutationRouter.js +4 -0
  53. package/dist/mcp/httpProtocolRouting.d.ts +10 -0
  54. package/dist/mcp/httpProtocolRouting.js +19 -0
  55. package/dist/mcp/localCliHealth.d.ts +2 -2
  56. package/dist/mcp/localCliHealth.js +2 -2
  57. package/dist/mcp/localServiceProxy.d.ts +1 -0
  58. package/dist/mcp/localServiceProxy.js +530 -68
  59. package/dist/mcp/planningAttachmentCommandAdapter.d.ts +3 -1
  60. package/dist/mcp/planningAttachmentCommandAdapter.js +20 -2
  61. package/dist/mcp/runtime.d.ts +54 -79
  62. package/dist/mcp/runtime.js +384 -97
  63. package/dist/mcp/taskPlanningRegistrar.js +23 -4
  64. package/dist/mcp/toolProfiles.d.ts +2 -0
  65. package/dist/mcp/toolProfiles.js +10 -0
  66. package/dist/mcp/toolRegistry.d.ts +1 -0
  67. package/dist/mcp/toolRegistry.js +1 -0
  68. package/dist/mcp/workflowExecutionRegistrar.js +4 -4
  69. package/dist/migrations/taskSchemaMigrations.d.ts +5 -0
  70. package/dist/migrations/taskSchemaMigrations.js +415 -0
  71. package/dist/runtime/appGates.d.ts +2 -1
  72. package/dist/runtime/appGates.js +7 -0
  73. package/dist/server/index.d.ts +3 -0
  74. package/dist/server/index.js +108 -11
  75. package/dist/server/localDatabaseIdentity.js +4 -1
  76. package/dist/server/localServiceLease.js +2 -1
  77. package/dist/server/localServiceSessions.d.ts +14 -17
  78. package/dist/server/localServiceSessions.js +308 -94
  79. package/dist/server/localWorkspaceSyncServerRuntime.js +12 -14
  80. package/dist/server/routes/admin.d.ts +4 -0
  81. package/dist/server/routes/admin.js +112 -3
  82. package/dist/server/routes/agents.d.ts +7 -0
  83. package/dist/server/routes/agents.js +277 -24
  84. package/dist/server/routes/billing.js +5 -1
  85. package/dist/server/routes/durableTaskHttpRouters.d.ts +2 -0
  86. package/dist/server/routes/executorPhaseAApprovals.d.ts +19 -0
  87. package/dist/server/routes/executorPhaseAApprovals.js +140 -0
  88. package/dist/server/routes/executorPhaseAIssuerRedemptions.d.ts +11 -0
  89. package/dist/server/routes/executorPhaseAIssuerRedemptions.js +24 -0
  90. package/dist/server/routes/githubReviewEvidence.d.ts +19 -0
  91. package/dist/server/routes/githubReviewEvidence.js +116 -0
  92. package/dist/server/routes/localService.d.ts +15 -4
  93. package/dist/server/routes/localService.js +136 -40
  94. package/dist/server/routes/modelConnections.d.ts +24 -0
  95. package/dist/server/routes/modelConnections.js +205 -0
  96. package/dist/server/routes/shared.d.ts +19 -0
  97. package/dist/server/routes/shared.js +95 -19
  98. package/dist/server/routes/sync.js +1 -0
  99. package/dist/server/routes/syncAuxRoutes.js +5 -1
  100. package/dist/server/routes/syncPushRoutes.d.ts +1 -0
  101. package/dist/server/routes/syncPushRoutes.js +1 -0
  102. package/dist/server/routes/syncV3FeedRoutes.js +10 -1
  103. package/dist/server/routes/syncV3OperationRoutes.js +35 -9
  104. package/dist/server/routes/tasks.js +21 -2
  105. package/dist/server/routes/workflows.js +9 -1
  106. package/dist/server/routes.js +59 -0
  107. package/dist/services/codexAppServerModelGateway.d.ts +54 -5
  108. package/dist/services/codexAppServerModelGateway.js +246 -21
  109. package/dist/services/codexDeviceCodeLoginManager.d.ts +39 -0
  110. package/dist/services/codexDeviceCodeLoginManager.js +265 -0
  111. package/dist/services/codexModelProviderConnectionLifecycle.d.ts +8 -0
  112. package/dist/services/codexModelProviderConnectionLifecycle.js +73 -0
  113. package/dist/services/executorPhaseAApprovalRuntime.d.ts +14 -0
  114. package/dist/services/executorPhaseAApprovalRuntime.js +24 -0
  115. package/dist/services/executorPhaseAApprovalService.d.ts +40 -0
  116. package/dist/services/executorPhaseAApprovalService.js +609 -0
  117. package/dist/services/executorPhaseADriftEvaluator.d.ts +78 -0
  118. package/dist/services/executorPhaseADriftEvaluator.js +93 -0
  119. package/dist/services/executorPhaseAIssuerCore.d.ts +126 -0
  120. package/dist/services/executorPhaseAIssuerCore.js +295 -0
  121. package/dist/services/executorPhaseAIssuerRedemptionService.d.ts +34 -0
  122. package/dist/services/executorPhaseAIssuerRedemptionService.js +158 -0
  123. package/dist/services/githubReviewEvidenceRuntime.d.ts +14 -0
  124. package/dist/services/githubReviewEvidenceRuntime.js +30 -0
  125. package/dist/services/githubReviewEvidenceService.d.ts +93 -0
  126. package/dist/services/githubReviewEvidenceService.js +336 -0
  127. package/dist/services/modelGateway.d.ts +7 -0
  128. package/dist/services/modelProviderConnectionService.d.ts +71 -0
  129. package/dist/services/modelProviderConnectionService.js +279 -0
  130. package/dist/services/modelProviderCredentialHome.d.ts +32 -0
  131. package/dist/services/modelProviderCredentialHome.js +271 -0
  132. package/dist/services/ownerScopedModelConnectionGateway.d.ts +12 -0
  133. package/dist/services/ownerScopedModelConnectionGateway.js +30 -0
  134. package/dist/services/taskforceAgentConnectionBindingService.d.ts +66 -0
  135. package/dist/services/taskforceAgentConnectionBindingService.js +185 -0
  136. package/dist/services/taskforceAgentMcpBridge.d.ts +1 -1
  137. package/dist/services/taskforceAgentMcpBridge.js +7 -24
  138. package/dist/shared/adminEdgeProxy.d.ts +5 -0
  139. package/dist/shared/adminEdgeProxy.js +94 -0
  140. package/dist/shared/adminProxySessionCookies.d.ts +16 -0
  141. package/dist/shared/adminProxySessionCookies.js +86 -0
  142. package/dist/shared/aiProfileColors.d.ts +31 -1
  143. package/dist/shared/aiProfileColors.js +14 -6
  144. package/dist/shared/executorPhaseAApprovalGoldenVector.json +269 -0
  145. package/dist/shared/executorPhaseAApprovalReceipt.d.ts +112 -0
  146. package/dist/shared/executorPhaseAApprovalReceipt.js +58 -0
  147. package/dist/shared/executorPhaseAApprovalTrustPolicy.json +10 -0
  148. package/dist/shared/executorPhaseADriftContracts.d.ts +37 -0
  149. package/dist/shared/executorPhaseADriftContracts.js +63 -0
  150. package/dist/shared/executorPhaseAIssuerContracts.d.ts +75 -0
  151. package/dist/shared/executorPhaseAIssuerContracts.js +90 -0
  152. package/dist/shared/executorPhaseARunAuthorization.d.ts +120 -0
  153. package/dist/shared/executorPhaseARunAuthorization.js +232 -0
  154. package/dist/shared/executorPhaseASchemaValidation.d.ts +7 -0
  155. package/dist/shared/executorPhaseASchemaValidation.js +53 -0
  156. package/dist/shared/executorPhaseASchemas/approval-receipt.schema.json +106 -0
  157. package/dist/shared/executorPhaseASchemas/drift-attestation.schema.json +54 -0
  158. package/dist/shared/executorPhaseASchemas/drift-request.schema.json +47 -0
  159. package/dist/shared/executorPhaseASchemas/foundation-manifest.schema.json +29 -0
  160. package/dist/shared/executorPhaseASchemas/issuer-audit-record.schema.json +24 -0
  161. package/dist/shared/executorPhaseASchemas/issuer-proof.schema.json +43 -0
  162. package/dist/shared/executorPhaseASchemas/issuer-redemption-request.schema.json +18 -0
  163. package/dist/shared/executorPhaseASchemas/issuer-redemption-response.schema.json +39 -0
  164. package/dist/shared/executorPhaseASchemas/logical-envelope.schema.json +149 -0
  165. package/dist/shared/executorPhaseASchemas/preflight-report.schema.json +216 -0
  166. package/dist/shared/executorPhaseASchemas/run-capability.schema.json +111 -0
  167. package/dist/shared/executorPhaseASchemas/sender-proof.schema.json +37 -0
  168. package/dist/shared/executorPhaseASchemas/workload-grant.schema.json +68 -0
  169. package/dist/shared/executorPhaseASchemas/workload-jwt-claims.schema.json +67 -0
  170. package/dist/shared/executorPhaseATiming.d.ts +1 -0
  171. package/dist/shared/executorPhaseATiming.js +1 -0
  172. package/dist/shared/planningIdentity.js +1 -1
  173. package/dist/shared/productLogoKeys.d.ts +2 -0
  174. package/dist/shared/productLogoKeys.js +18 -0
  175. package/dist/shared/taskforceAgentDefinition.d.ts +0 -1
  176. package/dist/shared/taskforceAgentDefinition.js +6 -9
  177. package/dist/shared/taskforceAgentModels.js +7 -3
  178. package/dist/shared/userFeatureGrants.d.ts +4 -0
  179. package/dist/shared/userFeatureGrants.js +7 -0
  180. package/dist/storage/executorPhaseAApprovalReceiptStore.d.ts +37 -0
  181. package/dist/storage/executorPhaseAApprovalReceiptStore.js +81 -0
  182. package/dist/storage/executorPhaseARunAuthorizationStore.d.ts +103 -0
  183. package/dist/storage/executorPhaseARunAuthorizationStore.js +492 -0
  184. package/dist/storage/githubReviewEvidenceInstallationStore.d.ts +26 -0
  185. package/dist/storage/githubReviewEvidenceInstallationStore.js +89 -0
  186. package/dist/storage/modelProviderConnectionStore.d.ts +99 -0
  187. package/dist/storage/modelProviderConnectionStore.js +446 -0
  188. package/dist/storage/postgresAdapter.d.ts +4 -0
  189. package/dist/storage/postgresAdapter.js +11 -0
  190. package/dist/storage/postgresWorker.js +9 -1
  191. package/dist/storage/postgresWorkerProtocol.d.ts +1 -0
  192. package/dist/storage/taskforceAgentConnectionBindingStore.d.ts +31 -0
  193. package/dist/storage/taskforceAgentConnectionBindingStore.js +84 -0
  194. package/dist/sync/coordinator/localSyncExecutionPermitStore.js +60 -29
  195. package/dist/sync/coordinator/localWorkspaceSyncPendingV2PushProgress.d.ts +10 -0
  196. package/dist/sync/coordinator/localWorkspaceSyncPendingV2PushProgress.js +29 -0
  197. package/dist/sync/coordinator/localWorkspaceSyncRunnerState.d.ts +15 -1
  198. package/dist/sync/coordinator/localWorkspaceSyncRunnerState.js +99 -2
  199. package/dist/sync/coordinator/workspaceSyncCredentialBroker.d.ts +1 -0
  200. package/dist/sync/coordinator/workspaceSyncCredentialBroker.js +33 -4
  201. package/dist/sync/engine/workspaceSyncContentLifecycleAdapter.d.ts +2 -1
  202. package/dist/sync/engine/workspaceSyncContentVersionStore.d.ts +38 -0
  203. package/dist/sync/engine/workspaceSyncContentVersionStore.js +50 -1
  204. package/dist/sync/engine/workspaceSyncEngineLifecyclePolicy.js +6 -6
  205. package/dist/sync/engine/workspaceSyncEnginePushCompletion.d.ts +14 -0
  206. package/dist/sync/engine/workspaceSyncEnginePushCompletion.js +84 -0
  207. package/dist/sync/engine/workspaceSyncEngineRecovery.js +1 -0
  208. package/dist/sync/engine/workspaceSyncEngineRuntime.d.ts +1 -0
  209. package/dist/sync/engine/workspaceSyncEngineRuntime.js +1 -0
  210. package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.js +112 -38
  211. package/dist/sync/engine/workspaceSyncEngineServerSnapshotReader.js +6 -0
  212. package/dist/sync/engine/workspaceSyncEngineTransfers.js +3 -1
  213. package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.d.ts +1 -0
  214. package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.js +29 -0
  215. package/dist/sync/syncApplyHandlers.d.ts +2 -0
  216. package/dist/sync/syncApplyHandlers.js +10 -1
  217. package/dist/sync/syncService.d.ts +15 -0
  218. package/dist/sync/syncService.js +83 -18
  219. package/dist/sync/taskforceAgentSyncAuthorization.d.ts +16 -0
  220. package/dist/sync/taskforceAgentSyncAuthorization.js +20 -0
  221. package/dist/sync/v3/combinedFeedCapability.js +4 -0
  222. package/dist/sync/v3/durableInitiativeMutationRouter.js +18 -10
  223. package/dist/sync/v3/durableOperationReplay.d.ts +14 -0
  224. package/dist/sync/v3/durableOperationReplay.js +18 -0
  225. package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.js +3 -0
  226. package/dist/sync/v3/durableTaskChecklistMutationRouter.d.ts +2 -1
  227. package/dist/sync/v3/durableTaskChecklistMutationRouter.js +58 -15
  228. package/dist/sync/v3/durableTaskCommentMutationRouter.js +3 -0
  229. package/dist/sync/v3/durableTaskHttpRootMutationRouter.d.ts +1 -1
  230. package/dist/sync/v3/durableTaskHttpRootMutationRouter.js +10 -0
  231. package/dist/sync/v3/durableTaxonomyMutationRouter.js +5 -0
  232. package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.d.ts +11 -0
  233. package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.js +39 -10
  234. package/dist/sync/v3/durableWorkstreamMutationRouter.js +18 -10
  235. package/dist/sync/v3/durableWorkstreamTaskOrderMutationRouter.js +16 -5
  236. package/dist/sync/v3/localOutboxDispatchRuntime.js +2 -2
  237. package/dist/sync/v3/localTaskChecklistOutboxHandler.js +16 -2
  238. package/dist/sync/v3/localTaskChecklistOutboxService.d.ts +4 -0
  239. package/dist/sync/v3/localTaskChecklistOutboxService.js +14 -1
  240. package/dist/sync/v3/localTaskStatusOutboxService.d.ts +8 -0
  241. package/dist/sync/v3/localTaskStatusOutboxService.js +219 -12
  242. package/dist/sync/v3/syncDurabilityStore.d.ts +34 -0
  243. package/dist/sync/v3/syncDurabilityStore.js +168 -2
  244. package/dist/sync/v3/taskChecklistMutationService.d.ts +11 -0
  245. package/dist/sync/v3/taskChecklistMutationService.js +44 -1
  246. package/dist/sync/v3/taskStatusMutationService.d.ts +29 -1
  247. package/dist/sync/v3/taskStatusMutationService.js +119 -3
  248. package/dist/sync/v3/workflowAssignmentSync.d.ts +5 -0
  249. package/dist/sync/v3/workflowAssignmentSync.js +27 -0
  250. package/dist/sync/v3/workspaceSyncJournalReader.js +1 -1
  251. package/dist/sync/v3/workspaceSyncOperationRetentionService.d.ts +16 -0
  252. package/dist/sync/v3/workspaceSyncOperationRetentionService.js +83 -0
  253. package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.d.ts +1 -0
  254. package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.js +9 -2
  255. package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.d.ts +7 -0
  256. package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.js +44 -32
  257. package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.d.ts +9 -5
  258. package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.js +54 -38
  259. package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.d.ts +10 -0
  260. package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.js +70 -31
  261. package/dist/sync/v3/workspaceSyncV3CombinedWireContract.d.ts +2 -1
  262. package/dist/sync/v3/workspaceSyncV3CombinedWireContract.js +16 -0
  263. package/dist/sync/v3/workspaceSyncV3CoverageRegistry.js +6 -0
  264. package/dist/sync/v3/workspaceSyncV3OperationProtocol.d.ts +3 -0
  265. package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.d.ts +5 -0
  266. package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.js +36 -2
  267. package/dist/sync/v3/workspaceSyncV3RepairSnapshotRetentionService.d.ts +17 -0
  268. package/dist/sync/v3/workspaceSyncV3RepairSnapshotRetentionService.js +64 -0
  269. package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverCoverage.d.ts +7 -0
  270. package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverCoverage.js +33 -0
  271. package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverWireContract.d.ts +7 -0
  272. package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverWireContract.js +8 -0
  273. package/dist/sync/workspaceRepair.d.ts +5 -2
  274. package/dist/sync/workspaceRepair.js +161 -6
  275. package/dist/sync/workspaceSyncModel.d.ts +21 -0
  276. package/dist/sync/workspaceSyncModel.js +35 -7
  277. package/dist/sync/workspaceSyncState.d.ts +1 -0
  278. package/dist/sync/workspaceSyncV2SnapshotBuilder.d.ts +6 -0
  279. package/dist/sync/workspaceSyncV2SnapshotBuilder.js +5 -0
  280. package/dist/ui/assets/AiIdentityRosterCard-OcSz1PkK.js +1 -0
  281. package/dist/ui/assets/AiProfilesModule-ByhYW5Xi.js +1 -0
  282. package/dist/ui/assets/{AnnotatedAttachmentWorkspace-B68Wg-RV.js → AnnotatedAttachmentWorkspace-BTM6nIg_.js} +1 -1
  283. package/dist/ui/assets/{AssetTraySortControl-C8Rztyal.js → AssetTraySortControl-DabEG8L4.js} +1 -1
  284. package/dist/ui/assets/{ContextAttachmentManager-Cj3c7X9y.js → ContextAttachmentManager-Coa8yVGM.js} +1 -1
  285. package/dist/ui/assets/{DocumentWorkspace-B5uvzems.js → DocumentWorkspace-BB0qhdix.js} +1 -1
  286. package/dist/ui/assets/{EntityActivityTimeline-BVFvCB5R.js → EntityActivityTimeline-CZ8x4UJE.js} +1 -1
  287. package/dist/ui/assets/{PlanningModule-B5DWQOGz.js → PlanningModule-pRPjR7v5.js} +1 -1
  288. package/dist/ui/assets/{PlansPage-AY4cGWco.js → PlansPage-D86pZSSl.js} +1 -1
  289. package/dist/ui/assets/{TaskContextUpload-DZxTVesW.js → TaskContextUpload-BVIkU9yT.js} +1 -1
  290. package/dist/ui/assets/TaskSettings-Cv1mNhv_.js +12 -0
  291. package/dist/ui/assets/TaskforceAgentsModule-b-8R25cJ.css +1 -0
  292. package/dist/ui/assets/TaskforceAgentsModule-gmH-PD2q.js +24 -0
  293. package/dist/ui/assets/{WorkflowManagerModule-DEr5di_r.js → WorkflowManagerModule-DbfnHJ-f.js} +1 -1
  294. package/dist/ui/assets/index-BZ-hdZSk.css +1 -0
  295. package/dist/ui/assets/index-CTsDBaef.js +7 -0
  296. package/dist/ui/assets/{vendor-icons-D9Lpw-j4.js → vendor-icons-Bsq-mcEn.js} +1 -1
  297. package/dist/ui/branding/logos/letterhead_dark.png +0 -0
  298. package/dist/ui/branding/logos/letterhead_light.png +0 -0
  299. package/dist/ui/branding/logos/signature_dark.png +0 -0
  300. package/dist/ui/branding/logos/signature_light.png +0 -0
  301. package/dist/ui/index.html +3 -3
  302. package/dist/utils/aiProfileDefaultLogo.js +16 -48
  303. package/dist/utils/httpSetCookie.d.ts +1 -0
  304. package/dist/utils/httpSetCookie.js +4 -1
  305. package/dist/utils/localRuntimeUrl.d.ts +1 -0
  306. package/dist/utils/localRuntimeUrl.js +14 -0
  307. package/dist/utils/productLogoRegistry.d.ts +2 -0
  308. package/dist/utils/productLogoRegistry.js +36 -0
  309. package/dist/utils/syncStatusPresentation.d.ts +4 -0
  310. package/dist/utils/syncStatusPresentation.js +17 -0
  311. package/dist/utils/taskEvents.d.ts +2 -0
  312. package/dist/utils/workspaceSyncPresentation.d.ts +1 -1
  313. package/dist/utils/workspaceSyncPresentation.js +23 -17
  314. package/package.json +22 -4
  315. package/dist/ui/assets/AiIdentityRosterCard-BZM4aQnM.js +0 -1
  316. package/dist/ui/assets/AiProfilesModule-BbAEWtHH.js +0 -1
  317. package/dist/ui/assets/TaskSettings-BeWAuyZj.js +0 -12
  318. package/dist/ui/assets/TaskforceAgentsModule-BifCYtjR.js +0 -21
  319. package/dist/ui/assets/TaskforceAgentsModule-D6IC0S7Q.css +0 -1
  320. package/dist/ui/assets/index-I5zhdtgt.js +0 -7
  321. package/dist/ui/assets/index-VRFsx3wz.css +0 -1
@@ -1,21 +0,0 @@
1
- import{j as e,r,a as Va}from"./vendor-react-CKJs5o3c.js";import{f as ht,B as Pt,C as Dt,E as Ze,t as a,F as Wa,w as Zs,G as In,H as En,J as $n,K as Ja,L as Bs,N as Hs,O as Fs,Q as Ln,S as qt,U as xs,V as Ya,W as Qa,M as Xa,X as Za,Y as ta,Z as er,_ as tr,$ as sr,a0 as ys,a1 as Pn}from"./index-I5zhdtgt.js";import{a as mt,A as nr,b as ar,w as Dn,r as Mn}from"./AiIdentityRosterCard-BZM4aQnM.js";import{ay as Qt,ba as ws,y as It,ao as rr,a0 as sa,$ as ir,aJ as or,aa as en,bb as lr,bc as $t,d as vt,W as cr,bd as dr,q as ur,g as mr,be as fr,S as rn,bf as pr,t as xt,w as Oe,R as on,a6 as tn,u as hr,X as Lt,Z as gt,bg as gr,Y as vr,v as na,A as aa,J as Tt,ak as xr,a2 as yr,a7 as br,O as kr,bh as Un,bi as jr}from"./vendor-icons-D9Lpw-j4.js";import"./vendor-markdown-_lhNCyq-.js";import"./vendor-dnd-CJ-AjP-Y.js";import"./vendor-router-AqJMU8Lz.js";const qs=1,Ce={name:80,shortDescription:240,purpose:2e3,listItem:1e3,listItems:24,workingGuidance:6e3,reference:200,promptContent:12e3};function On(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ae(t,n,i,o){t.push({code:n,path:i,message:o})}function zn(t,n,i,o){const d=new Set(n);Object.keys(t).forEach(C=>{d.has(C)||Ae(o,"unknown_field",i?`${i}.${C}`:C,"This field is not part of Agent Role v1.")})}function Ks(t,n,i,o){if(typeof t!="string")return Ae(o,"required_string",n,"A string value is required."),"";const d=t.trim();return d?d.length>i&&Ae(o,"string_too_long",n,`Must be ${i} characters or less.`):Ae(o,"required_string",n,"A non-empty value is required."),d}function Sr(t,n,i,o){if(t==null||t==="")return;if(typeof t!="string"){Ae(o,"invalid_string",n,"Must be a string when provided.");return}const d=t.trim();if(d)return d.length>i&&Ae(o,"string_too_long",n,`Must be ${i} characters or less.`),d}function bs(t,n,i,o){if(!Array.isArray(t))return Ae(o,"invalid_list",n,"Must be an array of strings."),[];i.required&&t.length===0&&Ae(o,"required_list",n,"Provide at least one item."),i.maxItems&&t.length>i.maxItems&&Ae(o,"too_many_items",n,`Provide no more than ${i.maxItems} items.`);const d=new Set,C=[];return t.forEach((S,x)=>{if(typeof S!="string"){Ae(o,"invalid_string",`${n}[${x}]`,"Must be a string.");return}const k=S.trim();if(!k){Ae(o,"empty_list_item",`${n}[${x}]`,"List items cannot be blank.");return}k.length>i.maxItemLength&&Ae(o,"string_too_long",`${n}[${x}]`,`Must be ${i.maxItemLength} characters or less.`),!d.has(k)&&(d.add(k),C.push(k))}),C}function ra(t){const n=[];if(!On(t))return{definition:null,issues:[{code:"invalid_definition",path:"",message:"Agent Role definition must be an object."}]};zn(t,["schemaVersion","name","shortDescription","purpose","responsibilities","expectedOutputs","workingGuidance","recommendations"],"",n),t.schemaVersion!==qs&&Ae(n,"unsupported_schema_version","schemaVersion",`Agent Role schemaVersion must be ${qs}.`);const i=Ks(t.name,"name",Ce.name,n),o=Ks(t.shortDescription,"shortDescription",Ce.shortDescription,n),d=Ks(t.purpose,"purpose",Ce.purpose,n),C=bs(t.responsibilities,"responsibilities",{required:!0,maxItems:Ce.listItems,maxItemLength:Ce.listItem},n),S=bs(t.expectedOutputs,"expectedOutputs",{required:!0,maxItems:Ce.listItems,maxItemLength:Ce.listItem},n),x=Sr(t.workingGuidance,"workingGuidance",Ce.workingGuidance,n),k=On(t.recommendations)?t.recommendations:null;k?zn(k,["skillRefs","capabilityGroups"],"recommendations",n):Ae(n,"invalid_recommendations","recommendations","Recommendations must be an object.");const z=bs(k?.skillRefs??[],"recommendations.skillRefs",{maxItems:Ce.listItems,maxItemLength:Ce.reference},n),O=bs(k?.capabilityGroups??[],"recommendations.capabilityGroups",{maxItems:Ce.listItems,maxItemLength:Ce.reference},n),F={schemaVersion:qs,name:i,shortDescription:o,purpose:d,responsibilities:C,expectedOutputs:S,...x?{workingGuidance:x}:{},recommendations:{skillRefs:z,capabilityGroups:O}};return n.length===0&&ia(F).length>Ce.promptContent&&Ae(n,"compiled_prompt_too_long","",`Compiled Role prompt content must be ${Ce.promptContent} characters or less.`),{definition:n.length===0?F:null,issues:n}}class Ar extends Error{constructor(n){super(n[0]?.message||"Agent Role definition is invalid."),this.issues=n,this.name="AgentRoleDefinitionValidationError"}code="AGENT_ROLE_DEFINITION_INVALID";statusCode=400}function Nr(t){const n=ra(t);if(!n.definition)throw new Ar(n.issues);return n.definition}function Gn(t){return t.map(n=>`- ${n}`).join(`
2
- `)}function ia(t){return[`Role: ${t.name}`,`Purpose and scope:
3
- ${t.purpose}`,`Responsibilities:
4
- ${Gn(t.responsibilities)}`,`Expected outputs:
5
- ${Gn(t.expectedOutputs)}`,t.workingGuidance?`Role-specific working guidance:
6
- ${t.workingGuidance}`:""].filter(Boolean).join(`
7
-
8
- `)}function wr(t){return ia(Nr(t))}const Cr="_toolAccess_2stgb_1",_r="_skillSelector_2stgb_2",Rr="_effectiveSummary_2stgb_3",Tr="_sectionHeader_2stgb_13",Ir="_workspaceHeader_2stgb_14",Er="_titleLine_2stgb_32",$r="_moduleGrid_2stgb_36",Lr="_moduleOption_2stgb_42",Pr="_unavailableCapability_2stgb_43",Dr="_moduleOptionSelected_2stgb_66",Mr="_moduleIcon_2stgb_76",Ur="_selectedSkillIcon_2stgb_77",Or="_provenanceIcon_2stgb_78",zr="_moduleCopy_2stgb_91",Gr="_futureGroups_2stgb_110",Br="_unknownNotice_2stgb_122",Hr="_disabledExplanation_2stgb_123",Fr="_catalogError_2stgb_147",qr="_selectedSkills_2stgb_160",Kr="_skillSearch_2stgb_168",Vr="_skillResults_2stgb_188",Wr="_emptySelection_2stgb_266",Jr="_provenanceGrid_2stgb_275",Yr="_unavailableProvenance_2stgb_312",Qr="_previewCaveat_2stgb_316",Xr="_librarySummary_2stgb_323",Zr="_workspacePanel_2stgb_346",ei="_futureAction_2stgb_356",ti="_workspaceTitleIcon_2stgb_370",si="_previewCardIcon_2stgb_371",ni="_relationshipFlow_2stgb_389",ai="_previewCards_2stgb_420",ri="_previewCard_2stgb_371",ii="_previewCardAvailable_2stgb_438",D={toolAccess:Cr,skillSelector:_r,effectiveSummary:Rr,sectionHeader:Tr,workspaceHeader:Ir,titleLine:Er,moduleGrid:$r,moduleOption:Lr,unavailableCapability:Pr,moduleOptionSelected:Dr,moduleIcon:Mr,selectedSkillIcon:Ur,provenanceIcon:Or,moduleCopy:zr,futureGroups:Gr,unknownNotice:Br,disabledExplanation:Hr,catalogError:Fr,selectedSkills:qr,skillSearch:Kr,skillResults:Vr,emptySelection:Wr,provenanceGrid:Jr,unavailableProvenance:Yr,previewCaveat:Qr,librarySummary:Xr,workspacePanel:Zr,futureAction:ei,workspaceTitleIcon:ti,previewCardIcon:si,relationshipFlow:ni,previewCards:ai,previewCard:ri,previewCardAvailable:ii},ln=[{key:"tasks",label:"Tasks and schedule",description:"Read and update tasks, checklists, task workflows, and schedule context.",icon:It},{key:"planning",label:"Initiatives and workstreams",description:"Read planning structure and add planning comments.",icon:rr},{key:"documents",label:"Documents",description:"Find and read Taskforce documents and their review context.",icon:sa},{key:"images",label:"Image Notes",description:"Find images and inspect annotation sessions.",icon:ir},{key:"workspace",label:"Workspace information",description:"Read workspace configuration, people, and managed Agent identity.",icon:or}],oi=ln.map(t=>t.key);function cn({selectedKeys:t,onChange:n,disabled:i=!1,mode:o="active",title:d="Tool Access",description:C,showFutureTools:S=!0,requireOne:x=!1,hasCustomOverrides:k=!1}){const z=new Set(t),O=new Set(oi),F=t.filter(_=>!O.has(_)),q=o==="active"?"Available now":o==="requirement"?"Requirement preview":"Inheritance preview",K=o==="active"?"tf-chip-success":"tf-chip-warning",j=(_,M)=>{if(!n||i)return;const W=M?[...t.filter(re=>re!==_),_]:t.filter(re=>re!==_),$=W.filter(re=>O.has(re)).length;x&&$===0||n(W)};return e.jsxs("section",{className:D.toolAccess,"aria-label":d,children:[e.jsxs("div",{className:D.sectionHeader,children:[e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:d}),e.jsx("p",{className:"tf-text-helper",children:C||"Choose which Taskforce modules this Agent can use. Fewer enabled tools reduce runtime tool context."})]}),e.jsx("span",{className:K,children:q})]}),e.jsx("div",{className:D.moduleGrid,children:ln.map(_=>{const M=_.icon,W=z.has(_.key);return e.jsxs("label",{className:`${D.moduleOption} ${W?D.moduleOptionSelected:""}`.trim(),children:[e.jsx("input",{type:"checkbox",checked:W,disabled:i||!n,onChange:$=>j(_.key,$.target.checked)}),e.jsx("span",{className:D.moduleIcon,"aria-hidden":"true",children:e.jsx(M,{size:16})}),e.jsxs("span",{className:D.moduleCopy,children:[e.jsx("strong",{children:_.label}),e.jsx("small",{children:_.description})]})]},_.key)})}),k?e.jsxs("div",{className:D.unknownNotice,role:"status",children:[e.jsx(en,{size:14}),e.jsx("span",{children:"Custom per-tool overrides are active. Change any module selection to replace them with the module policy shown here."})]}):null,F.length>0?e.jsxs("div",{className:D.unknownNotice,role:"status",children:[e.jsx(en,{size:14}),e.jsxs("span",{children:["Preserved legacy keys: ",F.join(", "),". They are not available in the current managed Tool Access catalog."]}),n&&!i?e.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:()=>n(t.filter(_=>O.has(_))),children:"Remove unsupported keys"}):null]}):null,S?e.jsxs("div",{className:D.futureGroups,children:[e.jsx(Fn,{icon:e.jsx(Qt,{size:16}),title:"Connected tools",description:"Workspace-approved APIs and external MCP tools will appear here.",status:"Connections not available yet"}),e.jsx(Fn,{icon:e.jsx(lr,{size:16}),title:"Code Workspace",description:"Repository read, edit, Git, and publication access will be configured separately.",status:"Code Workspace not configured"})]}):null]})}function li({skills:t,selectedIds:n,onChange:i,disabled:o=!1,loading:d=!1,error:C="",onRetry:S}){const[x,k]=r.useState(""),z=r.useRef(null),O=new Set(n),F=x.trim().toLowerCase(),q=t.filter(j=>j.lifecycleStatus==="active"&&!O.has(j.id)).filter(j=>!F||j.name.toLowerCase().includes(F)||j.description.toLowerCase().includes(F)).slice(0,8),K=new Map(t.map(j=>[j.id,j]));return e.jsxs("section",{className:D.skillSelector,"aria-label":"Included Skills",children:[e.jsxs("div",{className:D.sectionHeader,children:[e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:"Included Skills"}),e.jsx("p",{className:"tf-text-helper",children:"Select Skills by name. They are saved with this Role now; automatic Agent inheritance is preview-only."})]}),e.jsx("span",{className:"tf-chip-warning",children:"Inheritance preview"})]}),e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Find a Skill"}),e.jsxs("span",{className:D.skillSearch,children:[e.jsx(rn,{size:15,"aria-hidden":"true"}),e.jsx("input",{ref:z,type:"search",className:"tf-field-shell","aria-label":"Find a Skill to include",placeholder:d?"Loading Skills…":"Search by name or description",value:x,disabled:o||d,onChange:j=>k(j.target.value)})]})]}),C?e.jsxs("div",{className:D.catalogError,role:"alert",children:[e.jsx("span",{children:C}),S?e.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:S,children:"Retry"}):null]}):!d&&q.length>0?e.jsx("div",{className:D.skillResults,"aria-label":"Available Skills",children:q.map(j=>e.jsxs("button",{type:"button",disabled:o,onClick:()=>{i([...n,j.id]),k(""),z.current?.focus()},children:[e.jsxs("span",{children:[e.jsx("strong",{children:j.name}),e.jsx("small",{children:j.description||"No description"})]}),e.jsx("span",{className:"tf-chip-neutral",children:"Add"})]},j.id))}):d?null:e.jsx("p",{className:D.emptySelection,children:t.some(j=>j.lifecycleStatus==="active"&&!O.has(j.id))?"No Skills match this search.":"No additional Skills available."}),n.length>0?e.jsx("ul",{className:D.selectedSkills,children:n.map(j=>{const _=K.get(j);return e.jsxs("li",{children:[e.jsx("span",{className:D.selectedSkillIcon,"aria-hidden":"true",children:e.jsx(vt,{size:15})}),e.jsxs("span",{children:[e.jsx("strong",{children:_?.name||"Missing Skill"}),e.jsx("small",{children:_?.description||j})]}),e.jsx("button",{type:"button",className:"tf-button-ghost tf-button-compact",disabled:o,onClick:()=>{i(n.filter(M=>M!==j)),z.current?.focus()},children:"Remove"})]},j)})}):e.jsx("p",{className:D.emptySelection,children:"No Skills included in this Role."})]})}function ci({hasRole:t,directSkillCount:n,toolKeys:i}){const o=ln.filter(d=>i.includes(d.key)).map(d=>d.label);return e.jsxs("section",{className:D.effectiveSummary,"aria-label":"Effective configuration preview",children:[e.jsxs("div",{className:D.sectionHeader,children:[e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:"Effective configuration"}),e.jsx("p",{className:"tf-text-helper",children:"A preview of where this Agent’s behavior and access come from."})]}),e.jsx("span",{className:"tf-chip-warning",children:"Partial preview"})]}),e.jsxs("div",{className:D.provenanceGrid,children:[e.jsxs("div",{children:[e.jsx("span",{className:D.provenanceIcon,children:e.jsx($t,{size:15})}),e.jsxs("span",{children:[e.jsx("small",{children:"From Role"}),e.jsx("strong",{children:t?"Role guidance selected":"No Role selected"})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:D.provenanceIcon,children:e.jsx(vt,{size:15})}),e.jsxs("span",{children:[e.jsx("small",{children:"Added to Agent"}),e.jsxs("strong",{children:[n," direct ",n===1?"Skill":"Skills"]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:D.provenanceIcon,children:e.jsx(cr,{size:15})}),e.jsxs("span",{children:[e.jsx("small",{children:"Runtime Tool Access"}),e.jsx("strong",{children:o.length>0?o.join(", "):"No modules selected"})]})]}),e.jsxs("div",{className:D.unavailableProvenance,children:[e.jsx("span",{className:D.provenanceIcon,children:e.jsx(dr,{size:15})}),e.jsxs("span",{children:[e.jsx("small",{children:"Resources"}),e.jsx("strong",{children:"Not available yet"})]})]})]}),e.jsx("p",{className:D.previewCaveat,children:"Role guidance resolves today. Role-included Skills, Role Tool Access, Connections, and Resources are shown for experience review but are not yet inherited at runtime."})]})}function Bn({kind:t}){return e.jsxs("div",{className:D.librarySummary,children:[t==="connections"?e.jsx(Qt,{size:20}):e.jsx(ws,{size:20}),e.jsx("strong",{children:t==="connections"?"No Connections configured":"No Resource Collections yet"}),e.jsx("span",{children:t==="connections"?"Connections will make approved external tools and data providers available to Roles and Agents.":"Collections will tell Roles and Agents where to look for trusted information."}),e.jsx("span",{className:"tf-chip-neutral",children:"Preview only"})]})}function Hn({kind:t}){const n=t==="connections";return e.jsxs("section",{className:D.workspacePanel,"aria-labelledby":`${t}-preview-title`,children:[e.jsxs("header",{className:D.workspaceHeader,children:[e.jsx("div",{className:D.workspaceTitleIcon,"aria-hidden":"true",children:n?e.jsx(Qt,{size:20}):e.jsx(ws,{size:20})}),e.jsxs("div",{children:[e.jsxs("div",{className:D.titleLine,children:[e.jsx("h2",{id:`${t}-preview-title`,className:"tf-heading-page",children:n?"Connections":"Resources"}),e.jsx("span",{className:"tf-chip-warning",children:"Not available yet"})]}),e.jsx("p",{className:"tf-text-secondary",children:n?"Secure workspace integrations make external tools and provider data available for explicit Role and Agent access.":"Resource Collections define trusted places Agents can search without loading full source content into every prompt."})]}),e.jsxs("button",{type:"button",className:`tf-button-primary ${D.futureAction}`,disabled:!0,children:[n?e.jsx(ur,{size:15}):e.jsx(mr,{size:15}),n?"Add Connection":"New Collection"]})]}),e.jsxs("div",{className:D.relationshipFlow,"aria-label":"Configuration relationship",children:[e.jsx("span",{children:"Workspace"}),e.jsx("strong",{children:n?"Connection":"Resource Collection"}),e.jsx("span",{children:"Role"}),e.jsx("span",{children:"Agent"}),e.jsx("span",{children:"Runtime"})]}),e.jsx("div",{className:D.previewCards,children:n?e.jsxs(e.Fragment,{children:[e.jsx(_t,{icon:e.jsx(en,{size:18}),title:"Taskforce managed tools",description:"Built-in modules use Taskforce-managed credentials and the current allowlisted runtime.",status:"Available now",available:!0}),e.jsx(_t,{icon:e.jsx(ws,{size:18}),title:"Real estate data provider",description:"Example: search listings, retrieve property details, and read market statistics.",status:"Connection required"}),e.jsx(_t,{icon:e.jsx(Qt,{size:18}),title:"External MCP server",description:"Approved server tools will be imported individually with scopes and audit controls.",status:"Not available yet"})]}):e.jsxs(e.Fragment,{children:[e.jsx(_t,{icon:e.jsx(sa,{size:18}),title:"Taskforce documents",description:"Curate existing workspace documents into a reusable source collection.",status:"Collection manager required"}),e.jsx(_t,{icon:e.jsx(fr,{size:18}),title:"News sources",description:"Example: trusted publications, feeds, topics, regions, and recency rules.",status:"Provider required"}),e.jsx(_t,{icon:e.jsx(rn,{size:18}),title:"Web and data sources",description:"Allowed domains and connected datasets will be searched on demand.",status:"Not available yet"})]})}),e.jsxs("div",{className:D.disabledExplanation,children:[e.jsx(pr,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:"Why this is disabled"}),e.jsx("span",{children:n?"Credential storage, scopes, connection health, and external tool allowlisting are not implemented.":"Collection persistence, authorization, retrieval, and marketplace portability are not implemented."})]})]})]})}function Fn({icon:t,title:n,description:i,status:o}){return e.jsxs("div",{className:D.unavailableCapability,"aria-disabled":"true",children:[e.jsx("span",{className:D.moduleIcon,"aria-hidden":"true",children:t}),e.jsxs("span",{className:D.moduleCopy,children:[e.jsx("strong",{children:n}),e.jsx("small",{children:i})]}),e.jsx("span",{className:"tf-chip-neutral",children:o})]})}function _t({icon:t,title:n,description:i,status:o,available:d=!1}){return e.jsxs("article",{className:`${D.previewCard} ${d?D.previewCardAvailable:""}`.trim(),children:[e.jsx("div",{className:D.previewCardIcon,children:t}),e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-card",children:n}),e.jsx("p",{className:"tf-text-secondary",children:i})]}),e.jsx("span",{className:d?"tf-chip-success":"tf-chip-neutral",children:o})]})}const di="_root_kwk43_1",ui="_rootExternalLibrary_kwk43_11",mi="_library_kwk43_15",fi="_libraryExternal_kwk43_26",pi="_libraryHeader_kwk43_39",hi="_search_kwk43_50",gi="_retiredToggle_kwk43_78",vi="_libraryList_kwk43_86",xi="_libraryState_kwk43_95",yi="_libraryError_kwk43_107",bi="_libraryStateIcon_kwk43_112",ki="_libraryCard_kwk43_117",ji="_libraryCardSelected_kwk43_139",Si="_libraryCardIcon_kwk43_145",Ai="_libraryCardBody_kwk43_156",Ni="_editor_kwk43_180",wi="_editorHeader_kwk43_187",Ci="_editorTitle_kwk43_201",_i="_editorTitleLine_kwk43_213",Ri="_headerActions_kwk43_228",Ti="_feedbackError_kwk43_235",Ii="_feedbackSuccess_kwk43_236",Ei="_confirmation_kwk43_237",$i="_fieldError_kwk43_263",Li="_empty_kwk43_288",Pi="_emptyIcon_kwk43_298",Di="_editorGrid_kwk43_309",Mi="_formColumn_kwk43_319",Ui="_previewColumn_kwk43_325",Oi="_previewHeader_kwk43_336",zi="_previewNote_kwk43_347",Gi="_preview_kwk43_325",Bi="_previewEmpty_kwk43_368",Hi="_metrics_kwk43_382",Fi="_lifecycleAction_kwk43_400",qi="_history_kwk43_410",Ki="_spinner_kwk43_465",Vi="_visuallyHidden_kwk43_469",T={root:di,rootExternalLibrary:ui,library:mi,libraryExternal:fi,libraryHeader:pi,search:hi,retiredToggle:gi,libraryList:vi,libraryState:xi,libraryError:yi,libraryStateIcon:bi,libraryCard:ki,libraryCardSelected:ji,libraryCardIcon:Si,libraryCardBody:Ai,editor:Ni,editorHeader:wi,editorTitle:Ci,editorTitleLine:_i,headerActions:Ri,feedbackError:Ti,feedbackSuccess:Ii,confirmation:Ei,fieldError:$i,empty:Li,emptyIcon:Pi,editorGrid:Di,formColumn:Mi,previewColumn:Ui,previewHeader:Oi,previewNote:zi,preview:Gi,previewEmpty:Bi,metrics:Hi,lifecycleAction:Fi,history:qi,spinner:Ki,visuallyHidden:Vi};function oa({singularLabel:t,pluralLabel:n,description:i,icon:o,items:d,selectedId:C,searchValue:S,onSearchChange:x,showRetired:k,onShowRetiredChange:z,loading:O,error:F,emptyMessage:q,onRetry:K,onCreate:j,onSelect:_,libraryPortalTarget:M}){const W=e.jsxs(e.Fragment,{children:[M?e.jsxs("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:j,children:[e.jsx(xt,{size:14})," New ",t]}):e.jsxs("div",{className:T.libraryHeader,children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"tf-heading-card",children:["Available ",n]}),e.jsx("p",{className:"tf-text-helper",children:i})]}),e.jsxs("button",{type:"button",className:"tf-button-primary tf-button-compact",onClick:j,children:[e.jsx(xt,{size:14})," New"]})]}),e.jsxs("label",{className:T.search,children:[e.jsx(rn,{size:14,"aria-hidden":"true"}),e.jsxs("span",{className:T.visuallyHidden,children:["Search ",n]}),e.jsx("input",{"aria-label":`Search ${n}`,value:S,onChange:$=>x($.target.value),placeholder:`Search ${n.toLowerCase()}`})]}),e.jsxs("label",{className:T.retiredToggle,children:[e.jsx("input",{type:"checkbox",checked:k,onChange:$=>z($.target.checked)}),"Show retired"]}),e.jsx("div",{className:T.libraryList,"aria-busy":O,children:O?e.jsxs("div",{className:T.libraryState,children:[e.jsx(Oe,{size:16,className:T.spinner,"aria-hidden":"true"}),"Loading ",n,"…"]}):F?e.jsxs("div",{className:`${T.libraryState} ${T.libraryError}`,role:"alert",children:[e.jsx("span",{children:F}),K?e.jsx("button",{type:"button",className:"tf-button-secondary tf-button-compact",onClick:K,children:"Retry"}):null]}):d.length===0?e.jsxs("div",{className:T.libraryState,children:[e.jsx("span",{className:T.libraryStateIcon,"aria-hidden":"true",children:o}),q]}):d.map($=>{const re=$.id===C;return e.jsxs("button",{type:"button",className:`${T.libraryCard} ${re?T.libraryCardSelected:""}`.trim(),onClick:()=>_($.id),"aria-pressed":re,children:[e.jsx("span",{className:T.libraryCardIcon,"aria-hidden":"true",children:o}),e.jsxs("span",{className:T.libraryCardBody,children:[e.jsx("strong",{children:$.name}),e.jsx("span",{children:$.description})]}),$.lifecycleStatus==="retired"?e.jsx("span",{className:"tf-chip-warning",children:"Retired"}):null]},$.id)})})]});return M?Va.createPortal(e.jsx("div",{className:`${T.library} ${T.libraryExternal}`,"aria-label":`${t} list`,children:W}),M):e.jsx("aside",{className:T.library,"aria-label":`${t} Library`,children:W})}function la({icon:t,title:n,description:i,revision:o,retired:d=!1,showActions:C,dirty:S,saving:x,onReset:k,onSave:z}){return e.jsxs("header",{className:T.editorHeader,children:[e.jsxs("div",{className:T.editorTitle,children:[e.jsx("span",{"aria-hidden":"true",children:t}),e.jsxs("div",{children:[e.jsxs("div",{className:T.editorTitleLine,children:[e.jsx("h2",{className:"tf-heading-page",children:n}),d?e.jsx("span",{className:"tf-chip-warning",children:"Retired"}):null,!d&&o?e.jsxs("span",{className:"tf-chip-accent",children:["Revision ",o]}):null]}),e.jsx("p",{className:"tf-text-secondary",children:i})]})]}),C?e.jsxs("div",{className:T.headerActions,children:[e.jsxs("button",{type:"button",className:"tf-button-secondary tf-button-compact",disabled:!S||x,onClick:k,children:[e.jsx(on,{size:14})," Reset"]}),e.jsxs("button",{type:"button",className:"tf-button-primary tf-button-compact",disabled:!S||x||d,onClick:z,children:[x?e.jsx(Oe,{size:14,className:T.spinner}):e.jsx(tn,{size:14}),"Save"]})]}):null]})}function sn({type:t,message:n}){return e.jsxs("div",{className:t==="error"?T.feedbackError:T.feedbackSuccess,role:t==="error"?"alert":"status",children:[t==="error"?e.jsx(gt,{size:15}):e.jsx(It,{size:15}),e.jsx("span",{children:n})]})}function ca(t,n){return new Map(n?t.map(i=>[i.path,i.message]):[])}function da(t,n){const i=t.find(o=>n[o.path])?.path;i&&window.requestAnimationFrame(()=>n[i]?.focus())}function qe({id:t,message:n}){return n?e.jsx("small",{id:t,className:T.fieldError,children:n}):null}function ua({icon:t,title:n,description:i,actionLabel:o,onCreate:d}){return e.jsxs("div",{className:T.empty,children:[e.jsx("span",{className:T.emptyIcon,"aria-hidden":"true",children:t}),e.jsx("h3",{className:"tf-empty-title",children:n}),e.jsx("p",{className:"tf-empty-copy",children:i}),e.jsxs("button",{type:"button",className:"tf-button-primary",onClick:d,children:[e.jsx(xt,{size:15})," ",o]})]})}function ma({title:t,message:n,entityLabel:i,saving:o,onConfirm:d,onCancel:C}){const S=r.useId(),x=r.useId(),k=r.useRef(null);return r.useEffect(()=>{const z=document.activeElement instanceof HTMLElement?document.activeElement:null;return k.current?.focus(),()=>{z?.isConnected&&z.focus()}},[]),e.jsxs("div",{className:T.confirmation,role:"alertdialog","aria-modal":"false","aria-labelledby":S,"aria-describedby":x,onKeyDown:z=>{z.key!=="Escape"||o||(z.preventDefault(),C())},children:[e.jsxs("div",{children:[e.jsx("strong",{id:S,children:t}),e.jsx("span",{id:x,children:n})]}),e.jsxs("button",{type:"button",className:"tf-button-destructive tf-button-compact",disabled:o,onClick:d,"aria-label":`Confirm ${i} retirement`,children:[e.jsx(hr,{size:14})," Retire ",i]}),e.jsxs("button",{ref:k,type:"button",className:"tf-button-ghost tf-button-compact",disabled:o,onClick:C,"aria-label":`Cancel ${i} retirement`,children:[e.jsx(Lt,{size:14})," Cancel"]})]})}function fa({entityLabel:t,note:n,meta:i,children:o,metrics:d=[],revisions:C=[],lifecycleStatus:S,saving:x=!1,retireDescription:k,restoreDescription:z,onRetire:O,onRestore:F}){const q=!!(S&&k&&z&&O&&F);return e.jsxs("aside",{className:T.previewColumn,"aria-label":`Compiled ${t} preview`,children:[e.jsxs("div",{className:T.previewHeader,children:[e.jsxs("div",{children:[e.jsx("span",{className:"tf-label-micro",children:"Runtime preview"}),e.jsx("h3",{className:"tf-heading-section",children:"Compiled runtime preview"})]}),i]}),e.jsx("p",{className:T.previewNote,children:n}),o,d.length>0?e.jsx("div",{className:T.metrics,children:d.map(K=>e.jsxs("div",{children:[e.jsx("span",{children:K.label}),e.jsx("strong",{children:K.value})]},K.label))}):null,C.length>0?e.jsxs("details",{className:T.history,children:[e.jsxs("summary",{children:[e.jsx(gr,{size:12})," Revision history"]}),e.jsx("ol",{children:C.map(K=>e.jsxs("li",{children:[e.jsxs("strong",{children:["Revision ",K.revision]}),e.jsx("span",{children:new Date(K.createdAt).toLocaleString()}),e.jsx("code",{children:K.contentHash.slice(0,12)})]},K.revision))})]}):null,q?e.jsxs("div",{className:T.lifecycleAction,children:[e.jsxs("div",{children:[e.jsx("strong",{children:S==="retired"?`Restore ${t}`:`Retire ${t}`}),e.jsx("span",{children:S==="retired"?z:k})]}),S==="retired"?e.jsxs("button",{type:"button",className:"tf-button-secondary tf-button-compact",disabled:x,onClick:F,children:[e.jsx(on,{size:14})," Restore"]}):e.jsxs("button",{type:"button",className:"tf-button-destructive tf-button-compact",disabled:x,onClick:O,children:[e.jsx(vr,{size:14})," Retire"]})]}):null]})}const Wi="_formSection_dyv9a_1",Ji="_sectionHeader_dyv9a_9",Yi="_fieldGrid_dyv9a_13",Qi="_configurationPreview_dyv9a_27",Xi="_resourcesPreview_dyv9a_33",Zi="_previewCode_dyv9a_49",Xe={formSection:Wi,sectionHeader:Ji,fieldGrid:Yi,configurationPreview:Qi,resourcesPreview:Xi,previewCode:Zi},Kt={name:"",shortDescription:"",purpose:"",responsibilities:"",expectedOutputs:"",workingGuidance:"",skillRefs:"",capabilityGroups:""};function Et(t){return t.split(`
9
- `).map(n=>n.trim()).filter(Boolean)}function eo(t){return{schemaVersion:1,name:t.name,shortDescription:t.shortDescription,purpose:t.purpose,responsibilities:Et(t.responsibilities),expectedOutputs:Et(t.expectedOutputs),...t.workingGuidance.trim()?{workingGuidance:t.workingGuidance}:{},recommendations:{skillRefs:Et(t.skillRefs),capabilityGroups:Et(t.capabilityGroups)}}}function Vt(t){return{name:t.definition.name,shortDescription:t.definition.shortDescription,purpose:t.definition.purpose,responsibilities:t.definition.responsibilities.join(`
10
- `),expectedOutputs:t.definition.expectedOutputs.join(`
11
- `),workingGuidance:t.definition.workingGuidance||"",skillRefs:t.definition.recommendations.skillRefs.join(`
12
- `),capabilityGroups:t.definition.recommendations.capabilityGroups.join(`
13
- `)}}async function ks(t){return t.json().catch(()=>({}))}function to({workspaceId:t,libraryPortalTarget:n}){const[i,o]=r.useState([]),[d,C]=r.useState([]),[S,x]=r.useState(!0),[k,z]=r.useState(""),[O,F]=r.useState(null),[q,K]=r.useState(!1),[j,_]=r.useState(null),[M,W]=r.useState(Kt),[$,re]=r.useState(""),[ge,$e]=r.useState(!1),[Ke,ie]=r.useState(!0),[le,u]=r.useState(!1),[b,Q]=r.useState(null),[X,E]=r.useState(null),[Ne,H]=r.useState(!1),[L,be]=r.useState(!1),Ve=r.useRef({}),Te=r.useRef(0),G=i.find(p=>p.id===O)||null,te=G?Vt(G):Kt,pe=JSON.stringify(M)!==JSON.stringify(te),g=r.useCallback(p=>{F(p.id),K(!1),_(p.currentContentHash),W(Vt(p)),E(null),H(!1),be(!1)},[]),oe=r.useCallback(p=>{pe&&!window.confirm("Discard unsaved Role changes?")||g(p)},[g,pe]),ue=r.useCallback(async(p={})=>{ie(!0),Q(null);try{const R=await ht(`/api/taskforce/agent-roles?workspaceId=${encodeURIComponent(t)}&includeRetired=true`,{credentials:"include"}),U=await ks(R);if(!R.ok||U.success===!1||!Array.isArray(U.roles))throw new Error(String(U.error||"Unable to load Agent Roles."));const ee=U.roles,he=i.find(je=>je.id===O)||null,me=p.preserveDraft===!0&&(he?JSON.stringify(M)!==JSON.stringify(Vt(he)):Object.values(M).some(je=>je.trim().length>0));o(ee);const ke=ee.find(je=>je.id===O)||ee.find(je=>je.lifecycleStatus==="active")||ee[0]||null;ke?(F(ke.id),me?E({type:"error",message:"This Role changed during synchronization. Your unsaved edits were preserved; saving will require resolving the version conflict."}):(K(!1),_(ke.currentContentHash),W(Vt(ke)))):me?F(null):(F(null),K(!1),_(null),W(Kt))}catch(R){Q(String(R?.message||R||"Unable to load Agent Roles."))}finally{ie(!1)}},[M,i,O,t]);r.useEffect(()=>{ue()},[t]);const Le=r.useCallback(async()=>{const p=Te.current+1;Te.current=p,C([]),z(""),x(!0);try{const R=await ht(`/api/taskforce/agent-skills?workspaceId=${encodeURIComponent(t)}&includeRetired=true`,{credentials:"include"}),U=await ks(R);if(p!==Te.current)return;if(!R.ok||U.success===!1||!Array.isArray(U.skills))throw new Error(String(U.error||"Unable to load the Skill catalog."));C(U.skills.map(ee=>({id:String(ee.id),name:String(ee.definition?.name||"Unnamed Skill"),description:String(ee.definition?.shortDescription||""),lifecycleStatus:ee.lifecycleStatus==="retired"?"retired":"active"})))}catch(R){if(p!==Te.current)return;z(String(R?.message||"Unable to load the Skill catalog."))}finally{p===Te.current&&x(!1)}},[t]);r.useEffect(()=>(Le(),()=>{Te.current+=1}),[Le]),r.useEffect(()=>{const p=U=>{const ee=U.detail;(String(ee?.workspaceId||"").trim()||"default")!==t||ee?.reason!=="sync-apply"||ue({preserveDraft:!0})};window.addEventListener(Pt,p);const R=U=>{const ee=U.detail;(String(ee?.workspaceId||"").trim()||"default")===t&&Le()};return window.addEventListener(Dt,R),()=>{window.removeEventListener(Pt,p),window.removeEventListener(Dt,R)}},[ue,Le,t]);const Xt=r.useMemo(()=>{const p=$.trim().toLowerCase();return i.filter(R=>!ge&&R.lifecycleStatus==="retired"?!1:p?[R.definition.name,R.definition.shortDescription,R.definition.purpose].some(U=>U.toLowerCase().includes(p)):!0)},[$,i,ge]),ve=r.useMemo(()=>ra(eo(M)),[M]),de=r.useMemo(()=>{if(!ve.definition)return"";try{return wr(ve.definition)}catch{return""}},[ve]),Me=()=>{pe&&!window.confirm("Discard unsaved Role changes?")||(F(null),K(!0),_(null),W(Kt),E(null),H(!1),be(!1))},ce=()=>{const p=G?Vt(G):Kt;W(p),_(G?.currentContentHash||null),E(null),H(!1),be(!1)},f=(p,R)=>{W(U=>({...U,[p]:R})),E(null)},w=async()=>{if(!ve.definition||le){be(!0),E({type:"error",message:ve.issues[0]?.message||"Complete the required Role fields."}),da(ve.issues,Ve.current);return}u(!0),E(null);try{const p=await ht(G?`/api/taskforce/agent-roles/${encodeURIComponent(G.id)}`:"/api/taskforce/agent-roles",{method:G?"PATCH":"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:t,definition:ve.definition,...G?{expectedContentHash:j}:{}})}),R=await ks(p);if(!p.ok||R.success===!1||!R.role)throw new Error(String(R.error||"Unable to save Agent Role."));const U=R.role;o(ee=>ee.some(me=>me.id===U.id)?ee.map(me=>me.id===U.id?U:me):[...ee,U]),g(U),E({type:"success",message:`Saved ${U.definition.name}.`}),Ze({workspaceId:t,reason:"role-save"})}catch(p){E({type:"error",message:String(p?.message||p||"Unable to save Agent Role.")})}finally{u(!1)}},Y=async p=>{if(!(!G||le)){u(!0),E(null);try{const R=await ht(`/api/taskforce/agent-roles/${encodeURIComponent(G.id)}/${p}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:t,...p==="retire"?{confirm:!0}:{}})}),U=await ks(R);if(!R.ok||U.success===!1||!U.role)throw new Error(String(U.error||`Unable to ${p} Agent Role.`));const ee=U.role;o(he=>he.map(me=>me.id===ee.id?ee:me)),g(ee),p==="retire"&&$e(!0),E({type:"success",message:p==="retire"?`Retired ${ee.definition.name}.`:`Restored ${ee.definition.name}.`}),Ze({workspaceId:t,reason:p==="retire"?"role-retire":"role-restore"})}catch(R){E({type:"error",message:String(R?.message||R||`Unable to ${p} Agent Role.`)})}finally{u(!1)}}},N=r.useMemo(()=>ca(ve.issues,L),[ve.issues,L]),Z=(p,R,U,ee,he=p)=>{const me=`role-field-${he.replaceAll(".","-")}`,ke=N.get(he);return e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:R}),e.jsx("small",{id:`${me}-hint`,className:"tf-field-hint",children:U}),e.jsx("textarea",{ref:je=>{Ve.current[he]=je||void 0},id:me,className:"tf-field-shell","aria-label":R,"aria-describedby":`${me}-hint${ke?` ${me}-error`:""}`,"aria-errormessage":ke?`${me}-error`:void 0,value:M[p],onChange:je=>f(p,je.target.value),rows:ee,disabled:G?.lifecycleStatus==="retired","aria-invalid":!!ke}),e.jsx(qe,{id:`${me}-error`,message:ke})]})},xe=G?.usage.agentCount===0?"No active Agents currently reference this Role.":`${G?.usage.agentCount} active ${G?.usage.agentCount===1?"Agent references":"Agents reference"} this Role and will require repair before running.`;return e.jsxs("div",{className:`${T.root} ${n?T.rootExternalLibrary:""}`.trim(),children:[e.jsx(oa,{singularLabel:"Role",pluralLabel:"Roles",description:"Reusable professional profiles that define what an Agent does.",icon:e.jsx($t,{size:15}),items:Xt.map(p=>({id:p.id,name:p.definition.name,description:p.definition.shortDescription,lifecycleStatus:p.lifecycleStatus})),selectedId:O,searchValue:$,onSearchChange:re,showRetired:ge,onShowRetiredChange:$e,loading:Ke,error:b,emptyMessage:i.length===0?"No Roles configured yet.":"No Roles match this view.",onRetry:()=>{ue()},onCreate:Me,onSelect:p=>{const R=i.find(U=>U.id===p);R&&oe(R)},libraryPortalTarget:n}),e.jsxs("section",{className:T.editor,"aria-label":G?`Edit ${G.definition.name}`:"Create Role",children:[e.jsx(la,{icon:e.jsx($t,{size:18}),title:q?"New Role":G?.definition.name||"Role Manager",description:"Define reusable professional guidance for what an Agent does and produces.",revision:G?.currentRevision,retired:G?.lifecycleStatus==="retired",showActions:q||!!G,dirty:pe,saving:le,onReset:ce,onSave:()=>{w()}}),Ne&&G?e.jsx(ma,{title:`Retire ${G.definition.name}?`,message:xe,entityLabel:"Role",saving:le,onConfirm:()=>{Y("retire")},onCancel:()=>H(!1)}):null,X?e.jsx(sn,{type:X.type,message:X.message}):null,!q&&!G?e.jsx(ua,{icon:e.jsx($t,{size:24}),title:"Create your first Role",description:"Roles define reusable professional responsibilities, outputs, and working guidance for Taskforce Agents.",actionLabel:"New Role",onCreate:Me}):e.jsxs("div",{className:T.editorGrid,children:[e.jsxs("div",{className:T.formColumn,children:[e.jsxs("section",{className:Xe.formSection,children:[e.jsxs("div",{className:Xe.sectionHeader,children:[e.jsx("h3",{className:"tf-heading-section",children:"Identity and discovery"}),e.jsx("p",{className:"tf-text-helper",children:"Help people understand when this Role should be assigned."})]}),e.jsxs("div",{className:Xe.fieldGrid,children:[e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Role name"}),e.jsx("input",{ref:p=>{Ve.current.name=p||void 0},id:"role-field-name",className:"tf-field-shell",value:M.name,onChange:p=>f("name",p.target.value),disabled:G?.lifecycleStatus==="retired","aria-invalid":N.has("name"),"aria-errormessage":N.has("name")?"role-field-name-error":void 0}),e.jsx(qe,{id:"role-field-name-error",message:N.get("name")})]}),e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Short description"}),e.jsx("input",{ref:p=>{Ve.current.shortDescription=p||void 0},id:"role-field-short-description",className:"tf-field-shell",value:M.shortDescription,onChange:p=>f("shortDescription",p.target.value),disabled:G?.lifecycleStatus==="retired","aria-invalid":N.has("shortDescription"),"aria-errormessage":N.has("shortDescription")?"role-field-short-description-error":void 0}),e.jsx(qe,{id:"role-field-short-description-error",message:N.get("shortDescription")})]})]}),e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Purpose and scope"}),e.jsx("textarea",{ref:p=>{Ve.current.purpose=p||void 0},id:"role-field-purpose",className:"tf-field-shell",value:M.purpose,onChange:p=>f("purpose",p.target.value),rows:4,disabled:G?.lifecycleStatus==="retired","aria-invalid":N.has("purpose"),"aria-errormessage":N.has("purpose")?"role-field-purpose-error":void 0}),e.jsx(qe,{id:"role-field-purpose-error",message:N.get("purpose")})]})]}),e.jsxs("section",{className:Xe.formSection,children:[e.jsxs("div",{className:Xe.sectionHeader,children:[e.jsx("h3",{className:"tf-heading-section",children:"Runtime behavior"}),e.jsx("p",{className:"tf-text-helper",children:"This bounded guidance is compiled into the Agent runtime prompt."})]}),e.jsxs("div",{className:Xe.fieldGrid,children:[Z("responsibilities","Responsibilities","One responsibility per line.",6),Z("expectedOutputs","Expected outputs","One output or artifact per line.",6)]}),Z("workingGuidance","Role-specific working guidance","Optional operating guidance for agents using this Role.",5)]}),e.jsxs("div",{className:Xe.configurationPreview,children:[e.jsx(li,{skills:d,selectedIds:Et(M.skillRefs),loading:S,error:k,onRetry:()=>{Le()},disabled:G?.lifecycleStatus==="retired",onChange:p=>f("skillRefs",p.join(`
14
- `))}),e.jsx(cn,{selectedKeys:Et(M.capabilityGroups),mode:"preview",title:"Tool Access",description:"Choose the Taskforce modules this Role is intended to provide. The selection is saved now; automatic Agent inheritance is not active yet.",disabled:G?.lifecycleStatus==="retired",onChange:p=>f("capabilityGroups",p.join(`
15
- `))}),e.jsxs("section",{className:Xe.resourcesPreview,"aria-label":"Role Resources",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:"Resources"}),e.jsx("p",{className:"tf-text-helper",children:"Trusted collections this Role should consult will appear here."})]}),e.jsx("span",{className:"tf-chip-neutral",children:"Not available yet"}),e.jsx("button",{type:"button",className:"tf-button-secondary",disabled:!0,children:"Add Resource Collection"})]})]})]}),e.jsx(fa,{entityLabel:"Role",note:"This is the exact bounded Role content supplied to the Agent runtime. Included Skills, Tool Access, Resources, and discovery text are excluded until their inheritance is implemented.",meta:e.jsxs("span",{className:"tf-chip-count",children:[de.length.toLocaleString()," chars"]}),metrics:G?[{label:"Revision",value:G.currentRevision},{label:"Agent references",value:G.usage.agentCount},{label:"Status",value:G.lifecycleStatus==="retired"?"Retired":"Active"},{label:"Saved revisions",value:G.revisions.length}]:[],revisions:G?.revisions||[],lifecycleStatus:G?.lifecycleStatus,saving:le,retireDescription:"Remove it from new selection while preserving its revision history.",restoreDescription:"Allow this Role to resolve for new Agent runs again.",onRetire:()=>H(!0),onRestore:()=>{Y("restore")},children:de?e.jsx("pre",{className:`${T.preview} ${Xe.previewCode}`,children:de}):e.jsx("div",{className:T.previewEmpty,children:"Complete the required runtime fields to preview this Role."})})]})]})]})}async function so(t){const[n,i]=await Promise.all([fetch(`/api/taskforce/agent-roles?workspaceId=${encodeURIComponent(t)}&includeRetired=true`,{credentials:"include"}),fetch(`/api/taskforce/agent-skills?workspaceId=${encodeURIComponent(t)}&includeRetired=true`,{credentials:"include"})]),[o,d]=await Promise.all([n.json().catch(()=>({})),i.json().catch(()=>({}))]);if(!n.ok||o?.success===!1)throw new Error(String(o?.error||"Unable to load Roles."));if(!i.ok||d?.success===!1)throw new Error(String(d?.error||"Unable to load Skills."));return{roles:Array.isArray(o?.roles)?o.roles:[],skills:Array.isArray(d?.skills)?d.skills:[]}}const no="_assignments_omv6h_1",ao="_section_omv6h_8",ro="_sectionHeader_omv6h_16",io="_sectionHeading_omv6h_24",oo="_referenceCopy_omv6h_48",lo="_empty_omv6h_49",co="_roleControls_omv6h_61",uo="_skillAdd_omv6h_62",mo="_referenceList_omv6h_83",fo="_referenceRow_omv6h_91",po="_rowActions_omv6h_114",ho="_issue_omv6h_119",go="_loadError_omv6h_133",fe={assignments:no,section:ao,sectionHeader:ro,sectionHeading:io,referenceCopy:oo,empty:lo,roleControls:co,skillAdd:uo,referenceList:mo,referenceRow:fo,rowActions:po,issue:ho,loadError:go};function qn(t){return t.resolution==="pinned"?String(t.revision??""):""}function js(t,n){return{id:t.id,resolution:"pinned",revision:n}}function Kn(t){return{id:t.id,resolution:"current"}}function Vn(t,n){const i=(t?.revisions||[]).map(d=>d.revision).filter(d=>String(d).trim().length>0),o=n.resolution==="pinned"?n.revision:void 0;return o!==void 0&&!i.some(d=>String(d)===String(o))&&i.push(o),i.filter((d,C)=>i.findIndex(S=>String(S)===String(d))===C).sort((d,C)=>{const S=Number(d),x=Number(C);return Number.isFinite(S)&&Number.isFinite(x)?x-S:String(C).localeCompare(String(d))})}function Wn(t){const n=Number(t);return Number.isInteger(n)&&String(n)===t?n:t}function vo({workspaceId:t,roleRef:n,skillRefs:i,onRoleRefChange:o,onSkillRefsChange:d,onManageRoles:C,onManageSkills:S}){const[x,k]=r.useState([]),[z,O]=r.useState([]),[F,q]=r.useState(!0),[K,j]=r.useState(""),[_,M]=r.useState(""),W=r.useRef(0),$=r.useCallback(async()=>{const u=++W.current;q(!0),j("");try{const b=await so(t);if(u!==W.current)return;k(b.roles),O(b.skills)}catch(b){if(u!==W.current)return;j(String(b?.message||b||"Unable to load Role and Skill options."))}finally{u===W.current&&q(!1)}},[t]);r.useEffect(()=>($(),()=>{W.current+=1}),[$]),r.useEffect(()=>{const u=Q=>{const X=Q.detail;(String(X?.workspaceId||"").trim()||"default")===t&&(X?.reason!=="role-save"&&X?.reason!=="role-retire"&&X?.reason!=="role-restore"||$())},b=Q=>{const X=Q.detail;(String(X?.workspaceId||"").trim()||"default")===t&&$()};return window.addEventListener(Pt,u),window.addEventListener(Dt,b),()=>{window.removeEventListener(Pt,u),window.removeEventListener(Dt,b)}},[$,t]);const re=r.useMemo(()=>new Map(x.map(u=>[u.id,u])),[x]),ge=r.useMemo(()=>new Map(z.map(u=>[u.id,u])),[z]),$e=r.useMemo(()=>new Set(i.map(u=>u.id)),[i]),Ke=z.filter(u=>u.lifecycleStatus==="active"&&!$e.has(u.id)),ie=n&&re.get(n.id)||null,le=n?[...ie?[]:[`Role ${n.id} is missing or unavailable.`],...ie?.lifecycleStatus==="retired"?[`${ie.definition.name} is retired.`]:[],...n.resolution==="pinned"&&ie&&!ie.revisions.some(u=>String(u.revision)===String(n.revision))?[`Pinned Role revision ${String(n.revision)} is unavailable.`]:[]]:[];return e.jsxs("div",{className:fe.assignments,children:[e.jsxs("section",{className:fe.section,"aria-labelledby":"agent-role-heading",children:[e.jsxs("div",{className:fe.sectionHeader,children:[e.jsxs("div",{className:fe.sectionHeading,children:[e.jsx($t,{size:17}),e.jsxs("div",{children:[e.jsx("strong",{id:"agent-role-heading",children:"Role"}),e.jsx("small",{children:"Optional reusable professional profile. An Agent can have one Role."})]})]}),e.jsx("button",{type:"button",className:a.secondaryHeaderBtn,onClick:C,children:"Manage Roles"})]}),e.jsxs("div",{className:fe.roleControls,children:[e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Role"}),e.jsxs("select",{className:a.select,"aria-label":"Role",value:n?.id||"",disabled:F,onChange:u=>{const b=u.target.value;o(b?{id:b,resolution:"current"}:null)},children:[e.jsx("option",{value:"",children:"No Role"}),n&&!ie?e.jsxs("option",{value:n.id,children:["Missing Role · ",n.id]}):null,x.map(u=>e.jsxs("option",{value:u.id,disabled:u.lifecycleStatus==="retired",children:[u.definition.name,u.lifecycleStatus==="retired"?" · Retired":""]},u.id))]})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Version"}),e.jsxs("select",{className:a.select,"aria-label":"Role version",value:n?.resolution||"current",disabled:!n||!ie,onChange:u=>{if(!(!n||!ie)){if(u.target.value==="current"){o(Kn(n));return}o(js(n,ie.currentRevision))}},children:[e.jsx("option",{value:"current",children:"Use latest"}),e.jsx("option",{value:"pinned",children:"Pin revision"})]})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Revision"}),e.jsxs("select",{className:a.select,"aria-label":"Role pinned revision",value:n?qn(n):"",disabled:!n||n.resolution!=="pinned",onChange:u=>{n&&o(js(n,Wn(u.target.value)))},children:[e.jsx("option",{value:"",children:"Current"}),n?Vn(ie,n).map(u=>e.jsxs("option",{value:u,children:["Revision ",u]},u)):null]})]})]}),ie?.definition.shortDescription?e.jsx("small",{className:fe.empty,children:ie.definition.shortDescription}):null,le.map(u=>e.jsxs("div",{className:fe.issue,role:"alert",children:[e.jsx(gt,{size:13}),e.jsxs("span",{children:[u," Agent execution is blocked until this reference is repaired."]})]},u))]}),e.jsxs("section",{className:fe.section,"aria-labelledby":"agent-skills-heading",children:[e.jsxs("div",{className:fe.sectionHeader,children:[e.jsxs("div",{className:fe.sectionHeading,children:[e.jsx(vt,{size:17}),e.jsxs("div",{children:[e.jsx("strong",{id:"agent-skills-heading",children:"Skills"}),e.jsx("small",{children:"Composable behavior applied in this exact order. Later Skills take precedence when guidance conflicts."})]})]}),e.jsx("button",{type:"button",className:a.secondaryHeaderBtn,onClick:S,children:"Manage Skills"})]}),e.jsxs("div",{className:fe.skillAdd,children:[e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Add Skill"}),e.jsxs("select",{className:a.select,"aria-label":"Skill to add",value:_,disabled:F||Ke.length===0,onChange:u=>M(u.target.value),children:[e.jsx("option",{value:"",children:"Select a Skill"}),Ke.map(u=>e.jsx("option",{value:u.id,children:u.definition.name},u.id))]})]}),e.jsx("button",{type:"button",className:"tf-control-icon",disabled:!_,"aria-label":"Add selected Skill",title:"Add selected Skill",onClick:()=>{!_||$e.has(_)||(d([...i,{id:_,resolution:"current"}]),M(""))},children:e.jsx(xt,{size:14})})]}),i.length>0?e.jsx("ol",{className:fe.referenceList,children:i.map((u,b)=>{const Q=ge.get(u.id)||null,X=[...Q?[]:[`Skill ${u.id} is missing or unavailable.`],...Q?.lifecycleStatus==="retired"?[`${Q.definition.name} is retired.`]:[],...u.resolution==="pinned"&&Q&&!Q.revisions.some(E=>String(E.revision)===String(u.revision))?[`Pinned Skill revision ${String(u.revision)} is unavailable.`]:[]];return e.jsxs("li",{children:[e.jsxs("div",{className:fe.referenceRow,children:[e.jsxs("div",{className:fe.referenceCopy,children:[e.jsxs("strong",{children:[b+1,". ",Q?.definition.name||`Missing Skill · ${u.id}`]}),e.jsx("small",{children:Q?.definition.shortDescription||u.id})]}),e.jsxs("select",{className:a.select,"aria-label":`${Q?.definition.name||u.id} version`,value:u.resolution,disabled:!Q,onChange:E=>{const Ne=[...i];Ne[b]=E.target.value==="current"?Kn(u):js(u,Q?.revision||1),d(Ne)},children:[e.jsx("option",{value:"current",children:"Use latest"}),e.jsx("option",{value:"pinned",children:"Pin revision"})]}),e.jsxs("select",{className:a.select,"aria-label":`${Q?.definition.name||u.id} pinned revision`,value:qn(u),disabled:u.resolution!=="pinned",onChange:E=>{const Ne=[...i];Ne[b]=js(u,Wn(E.target.value)),d(Ne)},children:[e.jsx("option",{value:"",children:"Current"}),Vn(Q,u).map(E=>e.jsxs("option",{value:E,children:["Revision ",E]},E))]}),e.jsxs("div",{className:fe.rowActions,children:[e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact","aria-label":`Move ${Q?.definition.name||u.id} up`,disabled:b===0,onClick:()=>{if(b===0)return;const E=[...i];[E[b-1],E[b]]=[E[b],E[b-1]],d(E)},children:e.jsx(na,{size:14})}),e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact","aria-label":`Move ${Q?.definition.name||u.id} down`,disabled:b===i.length-1,onClick:()=>{if(b===i.length-1)return;const E=[...i];[E[b],E[b+1]]=[E[b+1],E[b]],d(E)},children:e.jsx(aa,{size:14})}),e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact","aria-label":`Remove ${Q?.definition.name||u.id}`,onClick:()=>d(i.filter((E,Ne)=>Ne!==b)),children:e.jsx(Lt,{size:14})})]})]}),X.map(E=>e.jsxs("div",{className:fe.issue,role:"alert",children:[e.jsx(gt,{size:13}),e.jsxs("span",{children:[E," Agent execution is blocked until this reference is repaired."]})]},E))]},`${u.id}-${b}`)})}):e.jsx("p",{className:fe.empty,children:"No Skills selected."}),K?e.jsx("p",{className:fe.loadError,role:"alert",children:K}):null]})]})}const xo=1,yo=[{key:"practical",label:"Practical"},{key:"encouraging",label:"Encouraging"},{key:"analytical",label:"Analytical"},{key:"direct",label:"Direct"},{key:"friendly-coach",label:"Friendly Coach"},{key:"creative-partner",label:"Creative Partner"}],bo=[{key:"concise",label:"Concise"},{key:"balanced",label:"Balanced"},{key:"detailed",label:"Detailed"},{key:"executive-summary",label:"Executive Summary"},{key:"critical-review",label:"Critical Review"},{key:"technical",label:"Technical"},{key:"creative",label:"Creative"}],ko=[{key:"taskforce-default",label:"Taskforce Agent"},{key:"photographic",label:"Photographic"},{key:"cinematic",label:"Cinematic"},{key:"painterly",label:"Painterly"},{key:"watercolor",label:"Watercolor"},{key:"graphic-novel",label:"Graphic Novel"},{key:"anime-inspired",label:"Anime-inspired"},{key:"stylized-3d",label:"Stylized 3D"},{key:"pixel-art",label:"Pixel Art"},{key:"ink-sketch",label:"Ink Sketch"}],_e="__custom__",jo="Default",So="Help users complete work in Taskforce.",Ao="Be concise and actionable.",dn=["tasks","planning","documents","images","workspace"],No=new Set(dn);function Yt(t,n={}){const i=t?.behavior.personality,o=t?.behavior.responseStyle,d=t?.presentation.avatar.artStyle,C=new Set(t?.toolPolicy.disabledCapabilities||[]),S=t?.toolPolicy.requestedCapabilities?.length?t.toolPolicy.requestedCapabilities:dn;return{purpose:t?.purpose||So,personalitySelection:i?.presetKey||(i?.customDescription?_e:""),personalityCustom:i?.customDescription||"",responseStyleSelection:o?.presetKey||(o?.customDescription?_e:""),responseStyleCustom:o?.customDescription||"",workingGuidelines:t?.behavior.workingGuidelines||n.systemPrompt||Ao,avatarVisualDescription:t?.presentation.avatar.visualDescription||"",avatarArtStyleSelection:d?.mode==="preset"?d.presetKey:d?.mode==="custom"?_e:"",avatarArtStyleCustom:d?.mode==="custom"?d.customDescription:"",roleRef:t?.roleRef?{...t.roleRef}:null,skillRefs:(t?.skillRefs||[]).map(x=>({...x})),requestedCapabilities:S.filter(x=>!C.has(x)),toolAccessChanged:!1}}function Jn(t,n){const i=n.trim();return t===_e?i?{customDescription:i}:void 0:t?{presetKey:t}:void 0}function wo(t,n){const i=n.trim();return t===_e?i?{mode:"custom",customDescription:i}:void 0:t?{mode:"preset",presetKey:t}:void 0}function Co(t){const{baseDefinition:n,draft:i}=t,o=Jn(i.personalitySelection,i.personalityCustom),d=Jn(i.responseStyleSelection,i.responseStyleCustom),C=i.workingGuidelines.trim(),S=i.avatarVisualDescription.trim(),x=wo(i.avatarArtStyleSelection,i.avatarArtStyleCustom),k=i.requestedCapabilities.filter(O=>No.has(O)),z=Wa(t.modelKey);return{...n||{},schemaVersion:xo,name:t.name.trim(),purpose:i.purpose.trim(),model:{providerKey:t.providerKey,modelKey:t.modelKey,modelSource:z?.source||"bedrock",tier:t.tier,...z?.source==="subscription_dev"?{connectionScope:"local_dev"}:{}},behavior:{...o?{personality:o}:{},...d?{responseStyle:d}:{},...C?{workingGuidelines:C}:{}},presentation:{avatar:{...S?{visualDescription:S}:{},...x?{artStyle:x}:{}}},...i.roleRef?{roleRef:{...i.roleRef}}:{roleRef:void 0},skillRefs:i.skillRefs.map(O=>({...O})),toolPolicy:n?.toolPolicy&&!i.toolAccessChanged?n.toolPolicy:{basePolicyRef:n?.toolPolicy.basePolicyRef||{id:"managed-agent-default",resolution:"current"},requestedCapabilities:k.length>0?k:void 0,disabledCapabilities:k.length===0?[...dn]:void 0,toolOverrides:void 0}}}function _o(t,n){const i=Yt(t);return i.avatarVisualDescription!==n.avatarVisualDescription||i.avatarArtStyleSelection!==n.avatarArtStyleSelection||i.avatarArtStyleCustom!==n.avatarArtStyleCustom}const Vs=1,Yn=2e4,Pe={name:80,shortDescription:280,purpose:1e3,instructions:12e3,listItems:20,listItem:1e3,capabilityGroup:160};function Ro(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function De(t,n,i,o){t.push({code:n,path:i,message:o})}function Ss(t,n,i,o){if(typeof t!="string")return De(o,"required_string",n,"A string value is required."),"";const d=t.trim();return d?d.length>i&&De(o,"string_too_long",n,`Must be ${i} characters or less.`):De(o,"required_string",n,"A non-empty value is required."),d}function Wt(t,n,i,o){if(!Array.isArray(t))return De(o,"required_array",n,"An array of strings is required."),[];t.length>Pe.listItems&&De(o,"too_many_items",n,`Must contain ${Pe.listItems} items or fewer.`);const d=new Set,C=[];return t.slice(0,Pe.listItems).forEach((S,x)=>{if(typeof S!="string"){De(o,"invalid_list_item",`${n}.${x}`,"Must be a string.");return}const k=S.trim();if(!k){De(o,"empty_list_item",`${n}.${x}`,"Must not be empty.");return}k.length>i&&De(o,"string_too_long",`${n}.${x}`,`Must be ${i} characters or less.`);const z=k.toLocaleLowerCase();if(d.has(z)){De(o,"duplicate_list_item",`${n}.${x}`,"Duplicate items are not allowed.");return}d.add(z),C.push(k)}),C}function pa(t){return[["Instructions",t.instructions],["Expected inputs",t.expectedInputs.map((i,o)=>`${o+1}. ${i}`).join(`
16
- `)],["Expected outputs",t.expectedOutputs.map((i,o)=>`${o+1}. ${i}`).join(`
17
- `)],["Quality checks",t.qualityChecks.map((i,o)=>`${o+1}. ${i}`).join(`
18
- `)]].filter(([,i])=>!!i).map(([i,o])=>`${i}:
19
- ${o}`).join(`
20
-
21
- `)}function To(t){const n=[];if(!Ro(t))return{definition:null,issues:[{code:"invalid_definition",path:"definition",message:"Skill definition must be an object."}]};const i=new Set(["schemaVersion","name","shortDescription","purpose","instructions","expectedInputs","expectedOutputs","qualityChecks","exampleUseCases","recommendedCapabilityGroups"]);Object.keys(t).forEach(d=>{i.has(d)||De(n,"unknown_field",d,"This field is not part of Agent Skill v1.")}),t.schemaVersion!==Vs&&De(n,"unsupported_schema_version","schemaVersion",`schemaVersion must be ${Vs}.`);const o={schemaVersion:Vs,name:Ss(t.name,"name",Pe.name,n),shortDescription:Ss(t.shortDescription,"shortDescription",Pe.shortDescription,n),purpose:Ss(t.purpose,"purpose",Pe.purpose,n),instructions:Ss(t.instructions,"instructions",Pe.instructions,n),expectedInputs:Wt(t.expectedInputs,"expectedInputs",Pe.listItem,n),expectedOutputs:Wt(t.expectedOutputs,"expectedOutputs",Pe.listItem,n),qualityChecks:Wt(t.qualityChecks,"qualityChecks",Pe.listItem,n),exampleUseCases:Wt(t.exampleUseCases,"exampleUseCases",Pe.listItem,n),recommendedCapabilityGroups:Wt(t.recommendedCapabilityGroups,"recommendedCapabilityGroups",Pe.capabilityGroup,n)};return pa(o).length>Yn&&De(n,"compiled_prompt_too_long","instructions",`Compiled runtime content must be ${Yn} characters or less.`),{definition:n.length===0?o:null,issues:n}}const Io="_section_1e1mf_1",Eo="_sectionHeading_1e1mf_9",$o="_twoColumn_1e1mf_20",Lo="_instructions_1e1mf_26",Po="_orderedList_1e1mf_36",Do="_orderedRow_1e1mf_42",Mo="_orderedInput_1e1mf_49",Uo="_orderNumber_1e1mf_56",Oo="_orderActions_1e1mf_63",zo="_listEmpty_1e1mf_69",Re={section:Io,sectionHeading:Eo,twoColumn:$o,instructions:Lo,orderedList:Po,orderedRow:Do,orderedInput:Mo,orderNumber:Uo,orderActions:Oo,listEmpty:zo},Jt={name:"",shortDescription:"",purpose:"",instructions:"",expectedInputs:[],expectedOutputs:[],qualityChecks:[],exampleUseCases:[],recommendedCapabilityGroups:[]};function As(t){const{schemaVersion:n,...i}=t.definition;return{...i,expectedInputs:[...i.expectedInputs],expectedOutputs:[...i.expectedOutputs],qualityChecks:[...i.qualityChecks],exampleUseCases:[...i.exampleUseCases],recommendedCapabilityGroups:[...i.recommendedCapabilityGroups]}}function ft(t){return JSON.stringify(t)}function Ws(t,n){const o=(Array.isArray(t.issues)?t.issues:[])[0];return o?.message?`${o.path?`${o.path}: `:""}${o.message}`:String(t.error||n)}function Ns({fieldPath:t,label:n,helper:i,values:o,onChange:d,placeholder:C,disabled:S=!1,issues:x,fieldRefs:k}){const z=()=>d([...o,""]),O=(K,j)=>{const _=[...o];_[K]=j,d(_)},F=(K,j)=>{const _=K+j;if(_<0||_>=o.length)return;const M=[...o];[M[K],M[_]]=[M[_],M[K]],d(M)},q=x.get(t);return e.jsxs("div",{className:"tf-field-stack",children:[e.jsxs("div",{className:"tf-field-label-row",children:[e.jsx("span",{className:"tf-field-label",children:n}),e.jsxs("button",{type:"button",className:"tf-button-ghost tf-button-compact",disabled:S,onClick:z,children:[e.jsx(xt,{size:13})," Add"]})]}),e.jsx("span",{className:"tf-field-hint",children:i}),e.jsx(qe,{id:`skill-field-${t}-error`,message:q}),o.length===0?e.jsx("div",{className:Re.listEmpty,children:"No items added."}):e.jsx("div",{className:Re.orderedList,children:o.map((K,j)=>{const _=x.get(`${t}.${j}`),M=_||(j===0?q:void 0),W=_?`skill-field-${t}-${j}-error`:`skill-field-${t}-error`;return e.jsxs("div",{className:Re.orderedRow,children:[e.jsx("span",{className:Re.orderNumber,children:j+1}),e.jsxs("div",{className:Re.orderedInput,children:[e.jsx("input",{ref:$=>{k.current[`${t}.${j}`]=$||void 0,j===0&&(k.current[t]=$||void 0)},id:`skill-field-${t}-${j}`,className:"tf-field-shell","aria-label":`${n} item ${j+1}`,"aria-invalid":!!M,"aria-errormessage":M?W:void 0,value:K,placeholder:C,disabled:S,onChange:$=>O(j,$.target.value)}),e.jsx(qe,{id:`skill-field-${t}-${j}-error`,message:_})]}),e.jsxs("div",{className:Re.orderActions,children:[e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact tf-control-icon-quiet","aria-label":`Move ${n.toLowerCase()} item up`,disabled:S||j===0,onClick:()=>{S||F(j,-1)},children:e.jsx(na,{size:13})}),e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact tf-control-icon-quiet","aria-label":`Move ${n.toLowerCase()} item down`,disabled:S||j===o.length-1,onClick:()=>{S||F(j,1)},children:e.jsx(aa,{size:13})}),e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact tf-control-icon-quiet","aria-label":`Remove ${n.toLowerCase()} item`,disabled:S,onClick:()=>d(o.filter(($,re)=>re!==j)),children:e.jsx(Lt,{size:13})})]})]},`${t}-${j}`)})})]})}function Go({workspaceId:t,active:n=!0,libraryPortalTarget:i}){const[o,d]=r.useState([]),[C,S]=r.useState(null),[x,k]=r.useState(Jt),[z,O]=r.useState(ft(Jt)),[F,q]=r.useState(!1),[K,j]=r.useState(!0),[_,M]=r.useState(!1),[W,$]=r.useState(null),[re,ge]=r.useState(null),[$e,Ke]=r.useState(""),[ie,le]=r.useState(!1),[u,b]=r.useState(!1),[Q,X]=r.useState(!1),[E,Ne]=r.useState(!1),H=r.useRef({}),L=o.find(f=>f.id===C)||null,be=ft(x)!==z,Ve=r.useCallback(f=>{if(be&&!window.confirm("Discard unsaved Skill changes?"))return;const w=As(f);S(f.id),k(w),O(ft(w)),q(!1),b(!1),X(!1),$(null),ge(null)},[be]),Te=r.useCallback(async f=>{f?.quiet||j(!0);try{const w=await ht(`/api/taskforce/agent-skills?workspaceId=${encodeURIComponent(t)}&includeRetired=true`,{credentials:"include"}),Y=await w.json().catch(()=>({}));if(!w.ok||Y?.success===!1||!Array.isArray(Y?.skills))throw new Error(Ws(Y,"Unable to load Skills."));const N=Y.skills;d(N),S(Z=>{if(F)return Z;const xe=N.find(p=>p.id===Z)||N.find(p=>p.lifecycleStatus==="active")||N[0]||null;if(xe&&(!be||xe.id===Z)){const p=As(xe);k(p),O(ft(p))}return xe?.id||null}),$(null)}catch(w){$(String(w?.message||w||"Unable to load Skills."))}finally{j(!1)}},[F,be,t]);r.useEffect(()=>{!n||E||(Ne(!0),Te())},[n,Te,E]),r.useEffect(()=>{const f=w=>{const Y=w.detail;String(Y?.workspaceId||"").trim()===t&&Te({quiet:!0})};return window.addEventListener(Dt,f),()=>window.removeEventListener(Dt,f)},[Te,t]),r.useEffect(()=>{if(!be)return;const f=w=>{w.preventDefault(),w.returnValue=""};return window.addEventListener("beforeunload",f),()=>window.removeEventListener("beforeunload",f)},[be]);const G=r.useMemo(()=>{const f=$e.trim().toLocaleLowerCase();return o.filter(w=>!ie&&w.lifecycleStatus==="retired"?!1:f?[w.definition.name,w.definition.shortDescription,w.definition.purpose].some(Y=>Y.toLocaleLowerCase().includes(f)):!0)},[$e,ie,o]),te=r.useMemo(()=>({schemaVersion:1,...x}),[x]),pe=r.useMemo(()=>To(te),[te]),g=r.useMemo(()=>pa(te),[te]),oe=r.useMemo(()=>ca(pe.issues,Q),[pe.issues,Q]),ue=()=>{be&&!window.confirm("Discard unsaved Skill changes?")||(S(null),k(Jt),O(ft(Jt)),q(!0),b(!1),X(!1),$(null),ge(null))},Le=()=>{const f=L?As(L):Jt;k(f),O(ft(f)),b(!1),X(!1),$(null),ge(null)},Xt=async()=>{if(!_){if(!pe.definition){X(!0),$(pe.issues[0]?.message||"Complete the required Skill fields."),da(pe.issues,H.current);return}M(!0),$(null),ge(null);try{const f=L?`/api/taskforce/agent-skills/${encodeURIComponent(L.id)}`:"/api/taskforce/agent-skills",w=await ht(f,{method:L?"PATCH":"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t,definition:pe.definition,...L?{expectedContentHash:L.contentHash}:{}})}),Y=await w.json().catch(()=>({}));if(!w.ok||Y?.success===!1||!Y?.skill)throw new Error(Ws(Y,"Unable to save Skill."));const N=Y.skill,Z=As(N);d(xe=>xe.some(R=>R.id===N.id)?xe.map(R=>R.id===N.id?N:R):[...xe,N].sort((R,U)=>R.definition.name.localeCompare(U.definition.name))),S(N.id),k(Z),O(ft(Z)),q(!1),X(!1),ge(`Saved ${N.definition.name}.`),In({workspaceId:t,skillId:N.id,reason:L?"update":"create"})}catch(f){$(String(f?.message||f||"Unable to save Skill."))}finally{M(!1)}}},ve=async f=>{if(!(!L||_)){M(!0),$(null),ge(null);try{const w=await ht(`/api/taskforce/agent-skills/${encodeURIComponent(L.id)}/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t})}),Y=await w.json().catch(()=>({}));if(!w.ok||Y?.success===!1||!Y?.skill)throw new Error(Ws(Y,`Unable to ${f} Skill.`));const N=Y.skill;d(Z=>Z.map(xe=>xe.id===N.id?N:xe)),f==="retire"&&le(!0),b(!1),ge(`${f==="retire"?"Retired":"Restored"} ${N.definition.name}.`),In({workspaceId:t,skillId:N.id,reason:f})}catch(w){$(String(w?.message||w||`Unable to ${f} Skill.`))}finally{M(!1)}}},de=L?.usage.workflowCount,Me=L?L.usage.agentCount+(de||0):0,ce=[Me>0?`${Me} known Agent or Workflow configuration${Me===1?" references":"s reference"} this Skill and will require repair before running.`:"No known Agent or Workflow configurations currently reference this Skill.",de===null?"Workflow reference counts are unavailable in this version, so review attached Workflows before retiring it.":""].filter(Boolean).join(" ");return e.jsxs("div",{className:`${T.root} ${i?T.rootExternalLibrary:""}`.trim(),children:[e.jsx(oa,{singularLabel:"Skill",pluralLabel:"Skills",description:"Reusable capabilities that define how an Agent performs a class of work.",icon:e.jsx(vt,{size:15}),items:G.map(f=>({id:f.id,name:f.definition.name,description:f.definition.shortDescription,lifecycleStatus:f.lifecycleStatus})),selectedId:C,searchValue:$e,onSearchChange:Ke,showRetired:ie,onShowRetiredChange:le,loading:K,error:null,emptyMessage:o.length===0?"No Skills configured yet.":"No Skills match this view.",onCreate:ue,onSelect:f=>{const w=o.find(Y=>Y.id===f);w&&Ve(w)},libraryPortalTarget:i}),e.jsxs("main",{className:T.editor,children:[e.jsx(la,{icon:e.jsx(vt,{size:18}),title:F?"New Skill":L?.definition.name||"Skill Manager",description:"Define bounded, reusable guidance for how an Agent performs a class of work.",revision:L?.revision,retired:L?.lifecycleStatus==="retired",showActions:F||!!L,dirty:be,saving:_,onReset:Le,onSave:()=>{Xt()}}),u&&L?e.jsx(ma,{title:`Retire ${L.definition.name}?`,message:ce,entityLabel:"Skill",saving:_,onConfirm:()=>{ve("retire")},onCancel:()=>b(!1)}):null,W?e.jsx(sn,{type:"error",message:W}):null,re?e.jsx(sn,{type:"success",message:re}):null,!F&&!L?e.jsx(ua,{icon:e.jsx(vt,{size:24}),title:"Create your first Skill",description:"Skills package reusable instructions, inputs, outputs, and quality checks without granting tools or permissions.",actionLabel:"New Skill",onCreate:ue}):e.jsxs("div",{className:T.editorGrid,children:[e.jsxs("div",{className:T.formColumn,children:[e.jsxs("section",{className:Re.section,children:[e.jsx("div",{className:Re.sectionHeading,children:e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:"Identity and discovery"}),e.jsx("p",{className:"tf-text-helper",children:"These fields help people find and understand the Skill. They are not added to normal prompts."})]})}),e.jsxs("div",{className:Re.twoColumn,children:[e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Name"}),e.jsx("input",{ref:f=>{H.current.name=f||void 0},id:"skill-field-name",className:"tf-field-shell","aria-label":"Name","aria-invalid":!!oe.get("name"),"aria-errormessage":oe.get("name")?"skill-field-name-error":void 0,value:x.name,maxLength:80,disabled:L?.lifecycleStatus==="retired",onChange:f=>k(w=>({...w,name:f.target.value}))}),e.jsx(qe,{id:"skill-field-name-error",message:oe.get("name")})]}),e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Short description"}),e.jsx("input",{ref:f=>{H.current.shortDescription=f||void 0},id:"skill-field-short-description",className:"tf-field-shell","aria-label":"Short description","aria-invalid":!!oe.get("shortDescription"),"aria-errormessage":oe.get("shortDescription")?"skill-field-short-description-error":void 0,value:x.shortDescription,maxLength:280,disabled:L?.lifecycleStatus==="retired",onChange:f=>k(w=>({...w,shortDescription:f.target.value}))}),e.jsx(qe,{id:"skill-field-short-description-error",message:oe.get("shortDescription")})]})]}),e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Purpose"}),e.jsx("textarea",{ref:f=>{H.current.purpose=f||void 0},id:"skill-field-purpose",className:"tf-field-shell","aria-label":"Purpose","aria-invalid":!!oe.get("purpose"),"aria-errormessage":oe.get("purpose")?"skill-field-purpose-error":void 0,rows:3,value:x.purpose,maxLength:1e3,disabled:L?.lifecycleStatus==="retired",onChange:f=>k(w=>({...w,purpose:f.target.value}))}),e.jsx(qe,{id:"skill-field-purpose-error",message:oe.get("purpose")})]})]}),e.jsxs("section",{className:Re.section,children:[e.jsx("div",{className:Re.sectionHeading,children:e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:"Runtime behavior"}),e.jsx("p",{className:"tf-text-helper",children:"Only this bounded content is compiled into the Agent prompt."})]})}),e.jsxs("label",{className:"tf-field-stack",children:[e.jsx("span",{className:"tf-field-label",children:"Instructions"}),e.jsx("textarea",{ref:f=>{H.current.instructions=f||void 0},id:"skill-field-instructions",className:`tf-field-shell ${Re.instructions}`,"aria-label":"Instructions","aria-describedby":`skill-field-instructions-hint${oe.get("instructions")?" skill-field-instructions-error":""}`,"aria-invalid":!!oe.get("instructions"),"aria-errormessage":oe.get("instructions")?"skill-field-instructions-error":void 0,rows:9,value:x.instructions,maxLength:12e3,disabled:L?.lifecycleStatus==="retired",placeholder:"Describe how the Agent should perform this capability.",onChange:f=>k(w=>({...w,instructions:f.target.value}))}),e.jsx("span",{id:"skill-field-instructions-hint",className:"tf-field-hint",children:"Markdown is supported as text. Scripts and executable bundles are not supported."}),e.jsx(qe,{id:"skill-field-instructions-error",message:oe.get("instructions")})]}),e.jsx(Ns,{fieldPath:"expectedInputs",label:"Expected inputs",helper:"What information or artifacts should be available?",values:x.expectedInputs,placeholder:"e.g. Complete diff",onChange:f=>k(w=>({...w,expectedInputs:f})),disabled:L?.lifecycleStatus==="retired",issues:oe,fieldRefs:H}),e.jsx(Ns,{fieldPath:"expectedOutputs",label:"Expected outputs",helper:"What should this Skill produce?",values:x.expectedOutputs,placeholder:"e.g. Prioritized findings",onChange:f=>k(w=>({...w,expectedOutputs:f})),disabled:L?.lifecycleStatus==="retired",issues:oe,fieldRefs:H}),e.jsx(Ns,{fieldPath:"qualityChecks",label:"Quality checks",helper:"What must be true before the work is considered ready?",values:x.qualityChecks,placeholder:"e.g. Every finding cites evidence",onChange:f=>k(w=>({...w,qualityChecks:f})),disabled:L?.lifecycleStatus==="retired",issues:oe,fieldRefs:H})]}),e.jsxs("section",{className:Re.section,children:[e.jsx("div",{className:Re.sectionHeading,children:e.jsxs("div",{children:[e.jsx("h3",{className:"tf-heading-section",children:"Authoring metadata"}),e.jsx("p",{className:"tf-text-helper",children:"Useful for discovery and recommendations; excluded from runtime prompts and permissions."})]})}),e.jsx(Ns,{fieldPath:"exampleUseCases",label:"Example use cases",helper:"Situations where this Skill is useful.",values:x.exampleUseCases,placeholder:"e.g. Review a pull request",onChange:f=>k(w=>({...w,exampleUseCases:f})),disabled:L?.lifecycleStatus==="retired",issues:oe,fieldRefs:H}),e.jsx(cn,{selectedKeys:x.recommendedCapabilityGroups,title:"Required Tool Access",description:"Select the Taskforce modules this Skill expects. Requirements are saved for discovery but are not enforced or granted yet.",mode:"requirement",showFutureTools:!1,disabled:L?.lifecycleStatus==="retired",onChange:f=>k(w=>({...w,recommendedCapabilityGroups:f}))})]})]}),e.jsx(fa,{entityLabel:"Skill",note:"This is the exact bounded Skill content supplied to the Agent runtime. Discovery and recommendation metadata are excluded.",meta:e.jsxs("span",{className:"tf-chip-count",children:[g.length.toLocaleString()," chars"]}),metrics:L?[{label:"Revision",value:L.revision},{label:"Agent references",value:L.usage.agentCount},{label:"Workflow references",value:L.usage.workflowCount??"Unavailable"},{label:"Status",value:L.lifecycleStatus==="retired"?"Retired":"Active"}]:[],revisions:L?.revisions||[],lifecycleStatus:L?.lifecycleStatus,saving:_,retireDescription:"Remove it from new selection while preserving immutable history.",restoreDescription:"Allow this Skill to resolve for new Agent runs again.",onRetire:()=>b(!0),onRestore:()=>{ve("restore")},children:g?e.jsx("div",{className:T.preview,children:e.jsx(Zs,{variant:"detail",children:g})}):e.jsx("div",{className:T.previewEmpty,children:"Add runtime instructions to preview this Skill."})})]})]})]})}const Qn="Be concise and actionable.",at="New Taskforce Agent",Bo="Message this agent...",Ho=1e4,Rt=[{id:"agents",label:"Agents"},{id:"roles",label:"Roles"},{id:"skills",label:"Skills"},{id:"connections",label:"Connections"},{id:"resources",label:"Resources"}];function Xn(t){const n=t?.usage?.totalTokens;return n==null?"Not reported":`${n} tokens`}function Js(t){return t?.latencyMs===void 0||t?.latencyMs===null?"Not reported":`${t.latencyMs} ms`}function Ys(t){return t?.avatarUrl?ta(t.avatarUrl,t.avatarRevision,t.avatarUpdatedAt):""}function Fo(t){return t?.avatarSourceUrl?ta(t.avatarSourceUrl,t.avatarRevision,t.avatarUpdatedAt):""}function Qs({src:t,fallbackSize:n}){const{activeImageUrl:i,handleImageError:o}=er(t);return i?e.jsx("img",{src:i,alt:"",onError:o}):e.jsx(Tt,{size:n})}function Zn(t){return new Promise((n,i)=>{const o=new FileReader;o.onload=()=>n(String(o.result||"")),o.onerror=()=>i(new Error("Failed to read image file.")),o.readAsDataURL(t)})}function pt(t){if(t==null||t==="")return null;const n=Number(t);return Number.isFinite(n)?Math.max(0,Math.floor(n)):null}function qo(t){const n=String(t||"").replace(/\s+/g," ").trim();return n.length>260?`${n.slice(0,257).trim()}...`:n}function Ko(t){return/^\s*(?:<!doctype\s+html|<html\b)/i.test(String(t||""))}function ea(t){return"Taskforce HQ"}function Xs(t){return t==="fast"?"Fast":t==="advanced"?"Advanced":"Balanced"}function Vo(t){return t==="verified"?"Verified":t==="configured"?"Configured":"Unavailable"}const Wo=/(token|secret|password|credential|api[-_]?key|access[-_]?key)/i;function nn(t){return Array.isArray(t)?t.map(n=>nn(n)):!t||typeof t!="object"?typeof t!="string"?t:t.length>240?`${t.slice(0,237).trim()}...`:t:Object.fromEntries(Object.entries(t).map(([n,i])=>[n,Wo.test(n)?"[redacted]":nn(i)]))}function Jo(t){const n=nn(t||{}),i=JSON.stringify(n,null,2);return i.length>700?`${i.slice(0,697).trim()}...`:i}function Yo(t){const n=String(t||"").replace(/\s+/g," ").trim();return n?n.length>320?`${n.slice(0,317).trim()}...`:n:"No result text returned."}function Qo(t){const n=t.length;if(n===0)return"No tools used";const i=t.filter(d=>!d.ok).length,o=n===1?"tool":"tools";return i>0?`${n} ${o} used, ${i} failed`:`${n} ${o} used`}function Xo(t){const n=t.length,i=t.filter(d=>!d.ok).length,o=n===1?"tool":"tools";return i>0?`Used ${n} Taskforce ${o}; ${i} failed.`:`Used ${n} Taskforce ${o}.`}function Zo(t){return typeof t=="number"&&Number.isFinite(t)?`${t.toLocaleString()} tokens`:"Not configured"}function el(t,n){return t.role==="user"?"You":t.agentName||n}function tl(t){return{id:t.id,workspaceId:t.workspaceId,agentId:t.agentId,taskId:t.taskId,taskReference:t.taskReference,taskTitle:t.taskTitle,context:t.context,title:t.title||t.messages.find(n=>n.role==="user")?.content||"Agent chat",messageCount:t.messages.length,modelProvider:t.modelProvider,modelId:t.modelId,usage:t.usage,latencyMs:t.latencyMs,createdAt:t.createdAt,updatedAt:t.updatedAt}}function an(t){const n=t?.context?.type==="task"?t.context:null,i=String(n?.taskId||t?.taskId||"").trim();if(!i)return null;const o=String(n?.taskReference||t?.taskReference||"").trim(),d=String(n?.taskTitle||t?.taskTitle||"").trim();return{type:"task",taskId:i,taskReference:o,taskTitle:d}}function ha(t,n){return t?!n||n.taskId!==t.taskId?t:{type:"task",taskId:t.taskId,taskReference:t.taskReference||n.taskReference,taskTitle:t.taskTitle||n.taskTitle}:null}function ga(t){const n=String(t.taskReference||"").trim(),i=String(t.taskTitle||"").trim();return n?`${n}${i?` · ${i}`:""}`:i||"Linked task"}function sl(t,n=null){const i=String(t.title||"Agent chat").trim()||"Agent chat",o=Number(t.messageCount||0),d=an(t),C=d?ha(d,n):null,S=o>0?`${i} (${o})`:i;return C?`${ga(C)} · ${S}`:S}function fl({workspaceId:t,agentRosterTrayOpen:n=!0,onCloseAgentRosterTray:i,launchContext:o=null,onClearLaunchContext:d,onOpenTaskContext:C,taskReferences:S,surface:x="module",runtimeMode:k="local",cloudAuthConfigured:z=!1,authSessionResolved:O=!0,isAuthenticated:F=!1,resolveCloudAuthUrl:q,theme:K="dark",rememberedAgentId:j,rememberedConversationId:_,rememberedConversationByAgentId:M,rememberedSelectionReady:W=!0,onRememberSelection:$,onRenderDrawerHeader:re,onOpenConversation:ge}){const $e=r.useRef(1),Ke=r.useRef(null),ie=r.useRef(null),le=r.useRef(null),u=r.useRef(!1),b=r.useRef(!1),Q=r.useRef(null),X=r.useRef(0),E=r.useRef(0),Ne=r.useRef({agents:null,roles:null,skills:null,connections:null,resources:null}),[H,L]=r.useState("agents"),[be,Ve]=r.useState(null),[Te,G]=r.useState(null),[te,pe]=r.useState([]),[g,oe]=r.useState(null),[ue,Le]=r.useState(""),[Xt,ve]=r.useState("taskforce_hq"),[de,Me]=r.useState(En),[ce,f]=r.useState($n),[w,Y]=r.useState("balanced"),[N,Z]=r.useState(()=>Yt(null,{systemPrompt:Qn})),xe=N.workingGuidelines,p=r.useCallback(s=>{b.current=!0,Z(l=>({...l,workingGuidelines:s}))},[]),[R,U]=r.useState(""),[ee,he]=r.useState(!1),[me,ke]=r.useState(!1),[je,Zt]=r.useState(""),[Ie,es]=r.useState(null),[Mt,ts]=r.useState([]),[ss,yt]=r.useState([]),[va,bt]=r.useState(!1),[Cs,rt]=r.useState(""),[_s,ze]=r.useState(""),[kt,Ut]=r.useState(!1),[un,jt]=r.useState(null),[nl,We]=r.useState([]),[Rs,Ot]=r.useState(""),[al,xa]=r.useState(()=>[{id:$e.current++,type:"info",message:"Ready to run this agent through the server-side model gateway.",timestamp:new Date().toLocaleTimeString()}]),[we,mn]=r.useState(!1),[ns,fn]=r.useState(""),[Ue,Ts]=r.useState(null),[St,Is]=r.useState(null),[pn,Es]=r.useState([]),[$s,zt]=r.useState(""),[et,Ls]=r.useState(!1),[At,hn]=r.useState(!1),[ya,gn]=r.useState(!1),[Je,Nt]=r.useState(!1),[Ps,vn]=r.useState(!1),[Gt,Ye]=r.useState(null),[as,rs]=r.useState(null),[is,xn]=r.useState(()=>new Set),[ba,tt]=r.useState({}),[ka,yn]=r.useState(!1),[bn,os]=r.useState(!1),[ja,Ge]=r.useState(null),[Sa,it]=r.useState(null),[Ds,kn]=r.useState(!1),[Bt,Ms]=r.useState(()=>new Set),ot=r.useRef(new Map),Aa=r.useMemo(()=>Ja.filter(s=>Bs(s.key).length>0),[]),wt=r.useMemo(()=>Bs(de),[de]),Qe=r.useMemo(()=>wt.find(s=>s.key===ce)||null,[ce,wt]),I=r.useMemo(()=>te.find(s=>s.id===g)||null,[te,g]),ls=r.useMemo(()=>String(j||"").trim(),[j]),jn=r.useMemo(()=>String(_||"").trim(),[_]),cs=r.useMemo(()=>{const s={};return Object.entries(M||{}).forEach(([l,c])=>{const h=String(l||"").trim(),m=String(c||"").trim();!h||!m||(s[h]=m)}),s},[M]),Be=k==="local"&&z,Na=!Be||O&&F&&!!q,Us=!(k==="local"&&z)||O&&F,lt=r.useMemo(()=>Ys(I),[I]),wa=r.useMemo(()=>Fo(I),[I]),ct=!!(g&&Bt.has(g)),ds=g&&ba[g]||null,st=r.useMemo(()=>Mt.find(s=>s.id===Ie)||null,[Ie,Mt]),Se=r.useMemo(()=>{const s=String(o?.taskId||"").trim();if(!s)return null;const l=String(o?.taskReference||"").trim(),c=String(o?.taskTitle||"").trim();return{type:"task",taskId:s,taskReference:l,taskTitle:c}},[o?.taskId,o?.taskReference,o?.taskTitle]),Sn=r.useMemo(()=>an(st),[st]),He=Ie?Sn?ha(Sn,Se):null:Se,Ca=He?ga(He):"",_a=!!(He&&Se&&!Ie),us=r.useMemo(()=>{const s=String(st?.agentId||g||"").trim();return te.find(l=>l.id===s)||null},[te,g,st?.agentId]),Ra=us?.name||I?.name||ue.trim()||at,ms=us?.color||I?.color||(us?.id?mt(us.id):I?.id?mt(I.id):void 0),An=r.useRef(""),Ee=r.useCallback((s,l)=>{if(!$)return;const c=String(s||"").trim(),h=String(l||"").trim(),m=`${c}:${h}`;An.current!==m&&(An.current=m,$({agentId:c||null,conversationId:h||null}))},[$]),se=r.useCallback((s,l,c)=>{xa(h=>[...h,{id:$e.current++,type:s,message:l,timestamp:new Date().toLocaleTimeString(),...c&&c.length>0?{toolActivity:c}:{}}])},[]),dt=r.useCallback(()=>{E.current+=1,fn(""),Ts(null),Is(null),Es([]),zt(""),Ls(!1)},[]),fs=r.useCallback(s=>{X.current+=1,b.current=!1,le.current=s.id,oe(s.id),Le(s.name),ve("taskforce_hq"),Me(Hs(s.providerKey)),f(Fs(s.modelKey,s.providerKey)),Y(s.modelTier),Z(Yt(s.definition,{systemPrompt:s.systemPrompt})),U(s.color||mt(s.id)),he(!1),ke(!1),u.current=!1,es(null),ts([]),yt([]),bt(!1),rt(""),ze(""),Ut(!1),jt(null),We([]),Ye(null),dt()},[dt]),Os=r.useCallback(s=>{fs(s),Ee(s.id,cs[s.id]||null)},[fs,cs,Ee]),ut=r.useCallback(s=>{X.current+=1;const l=Array.isArray(s?.messages)?s.messages:[],c=[...l].reverse().find(h=>h.role==="assistant");es(s?.id||null),yt(l),bt(!1),rt(""),ze(""),Ut(!1),jt(c?{text:c.content,provider:s?.modelProvider||"taskforce_hq",modelId:s?.modelId||"Not reported",latencyMs:s?.latencyMs??null,usage:s?.usage||null}:null)},[]),Ht=r.useCallback(s=>{const l=tl(s);ts(c=>{const h=c.filter(m=>m.id!==l.id);return[l,...h]})},[]),Nn=r.useCallback(()=>{X.current+=1,b.current=!1,le.current=null,oe(null),Le(""),ve("taskforce_hq"),Me(En),f($n),Y("balanced"),Z(Yt(null,{systemPrompt:Qn})),U(""),he(!1),ke(!1),u.current=!1,es(null),ts([]),yt([]),bt(!1),rt(""),ze(""),Ut(!1),jt(null),We([]),Ye(null),dt(),Ee(null,null)},[Ee,dt]),ps=r.useCallback(s=>{if(s.type==="new"){Nn(),se("info","Started a new Taskforce agent draft.");return}Os(s.agent)},[se,Nn,Os]),Ft=r.useCallback(s=>{if(!(s.type==="agent"&&s.agent.id===le.current)){if(!b.current){ps(s);return}rs(s)}},[ps]),Ta=r.useCallback(()=>{if(!as)return;const s=as;rs(null),b.current=!1,ps(s)},[as,ps]);r.useEffect(()=>{const s=l=>{b.current&&(l.preventDefault(),l.returnValue="")};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[]);const zs=r.useCallback(async(s,l)=>{Nt(!0);try{const c=await fetch(`/api/taskforce/agents/${encodeURIComponent(s)}/conversation?workspaceId=${encodeURIComponent(t)}&conversationId=${encodeURIComponent(l)}`,{credentials:"include"}),h=typeof c.clone=="function"?await c.clone().text().catch(()=>""):"",m=await c.json().catch(()=>({}));if(!c.ok||m?.success===!1){const v=c.status===404?"Taskforce agent conversation API route is not available. Restart the app server so the latest routes are active.":`Unable to load saved agent conversation. HTTP ${c.status||"unknown"}.`;se("error",String(m?.error||h||v));return}if(le.current!==s)return;const y=m?.conversation||null;ut(y),y&&Ht(y),Ee(s,y?.id||null),We([])}catch(c){se("error",String(c?.message||c||"Unable to load saved agent conversation."))}finally{Nt(!1)}},[se,ut,Ee,Ht,t]),hs=r.useCallback(async s=>{gn(!0),Nt(!0);try{const l=await fetch(`/api/taskforce/agents/${encodeURIComponent(s)}/conversations?workspaceId=${encodeURIComponent(t)}`,{credentials:"include"}),c=typeof l.clone=="function"?await l.clone().text().catch(()=>""):"",h=await l.json().catch(()=>({}));if(!l.ok||h?.success===!1){const y=l.status===404?"Taskforce agent conversation API route is not available. Restart the app server so the latest routes are active.":`Unable to load saved agent conversations. HTTP ${l.status||"unknown"}.`;se("error",String(h?.error||c||y));return}if(le.current!==s)return;const m=Array.isArray(h?.conversations)?h.conversations:[];if(ts(m),m.length>0){const y=cs[s]||(s===ls?jn:""),v=y?m.find(V=>V.id===y):null,A=Se?m.find(V=>an(V)?.taskId===Se.taskId):null,J=v?.id||A?.id||(Se?null:m[0].id);J?await zs(s,J):(ut(null),Ee(s,null),We([]))}else ut(null),Ee(s,null),We([])}catch(l){se("error",String(l?.message||l||"Unable to load saved agent conversations."))}finally{gn(!1),Nt(!1)}},[se,ut,zs,ls,cs,jn,Ee,Se,t]),Fe=r.useCallback(async s=>{const l=s?.quiet===!0;l||(hn(!0),Ye(null));try{const c=await fetch(`/api/taskforce/agents?workspaceId=${encodeURIComponent(t)}`,{credentials:"include"}),h=typeof c.clone=="function"?await c.clone().text().catch(()=>""):"",m=await c.json().catch(()=>({}));if(!c.ok||m?.success===!1){const J=c.status===404?"Taskforce agent API route is not available. Restart the app server so the latest routes are active.":`Unable to load saved agents. HTTP ${c.status||"unknown"}.`,V=String(m?.error||h||J);se("error",V),l||Ye({type:"error",message:V});return}const y=Array.isArray(m?.agents)?m.agents:[];ie.current=t,pe(J=>{const V=new Map(J.map(B=>[B.id,B]));return y.map(B=>{const ne=ot.current.get(B.id),P=pt(B.avatarRevision);if(ne===void 0||P!==null&&P>=ne)return B;const ae=V.get(B.id);return ae?{...B,profileId:ae.profileId||B.profileId||null,avatarUrl:ae.avatarUrl,avatarSourceUrl:ae.avatarSourceUrl,avatarRevision:ae.avatarRevision,avatarUpdatedAt:ae.avatarUpdatedAt}:B})}),Ms(J=>{let V=null;for(const B of J){const ne=ot.current.get(B),P=y.find(ye=>ye.id===B),ae=pt(P?.avatarRevision);ne===void 0||ae===null||ae<ne||(V??=new Set(J),V.delete(B),ot.current.delete(B))}return V||J});const v=le.current,A=v?y.find(J=>J.id===v):null;A&&!u.current&&U(A.color||mt(A.id))}catch(c){const h=String(c?.message||c||"Unable to load saved agents.");se("error",h),l||Ye({type:"error",message:h})}finally{l||hn(!1)}},[se,t]);r.useEffect(()=>{dt()},[dt,t]),r.useEffect(()=>{Fe()},[Fe]),r.useEffect(()=>{if(!W||ie.current!==t||Ke.current===t)return;if(te.length===0){if(At)return;Ee(null,null);return}Ke.current=t;const s=te.find(l=>l.id===ls);b.current||fs(s||te[0])},[te,fs,At,ls,W,Ee,t]),r.useEffect(()=>{const s=l=>{const c=l.detail;if((String(c?.workspaceId||"").trim()||"default")!==t)return;const m=c?.reason;if(!(m==="sync-apply"||m==="agent-avatar-upload"||m==="agent-avatar-remove"||m==="agent-avatar-generate"&&!Be)||(Fe({quiet:!0}),m!=="sync-apply"))return;const v=String(c?.agentId||"").trim(),A=le.current;A&&(!v||v===A)&&hs(A)};return window.addEventListener(Pt,s),()=>window.removeEventListener(Pt,s)},[Fe,hs,Be,t]),r.useEffect(()=>{const s=l=>{const c=l.detail;if((String(c?.workspaceId||"").trim()||"default")!==t||c?.origin==="taskforce-agents-module")return;const m=c?.taskforceAgentAvatar,y=String(m?.agentId||"").trim();if(m&&y){const v=pt(m.avatarRevision)??0;Be&&(ot.current.set(y,v),Ms(A=>new Set(A).add(y))),pe(A=>A.map(J=>J.id===y?{...J,profileId:c.profileId||J.profileId||null,avatarUrl:m.avatarUrl,avatarSourceUrl:m.avatarSourceUrl,avatarRevision:v,avatarUpdatedAt:m.avatarUpdatedAt}:J))}Fe({quiet:!0})};return window.addEventListener(Ln,s),()=>window.removeEventListener(Ln,s)},[Fe,Be,t]),r.useEffect(()=>{const s=window.setInterval(()=>{Fe({quiet:!0})},Ho);return()=>window.clearInterval(s)},[Fe]),r.useEffect(()=>{le.current=g},[g]),r.useEffect(()=>{g&&hs(g)},[hs,g]),r.useEffect(()=>{if(Bt.size===0)return;const s=window.setInterval(()=>{Fe()},4e3);return()=>window.clearInterval(s)},[Bt.size,Fe]),r.useEffect(()=>{if(!(x!=="taskDrawer"||!re))return re(e.jsxs("div",{className:a.taskforceAgentDrawerAgentHeader,children:[e.jsxs("button",{type:"button",className:`${a.taskforceAgentDrawerAgentAvatar} ${a.taskforceAgentDrawerAgentAvatarButton} ${ct?a.taskforceAgentAvatarSyncing:""}`.trim(),onClick:()=>kn(s=>!s),disabled:!g,title:I?`View ${I.name} profile`:"Select an agent to view profile","aria-label":I?`View ${I.name} profile`:"View agent profile","aria-expanded":Ds,children:[lt?e.jsx(Qs,{src:lt,fallbackSize:16}):e.jsx(Tt,{size:16}),ct?e.jsx(Oe,{size:12,className:`${a.spinner} ${a.taskforceAgentAvatarSyncIcon}`}):null]}),e.jsx("label",{className:a.taskforceAgentDrawerAgentPicker,children:e.jsx("select",{className:a.select,value:g||"",onChange:s=>{const l=te.find(c=>c.id===s.target.value);l&&Ft({type:"agent",agent:l})},disabled:!W||At||te.length===0||we,"aria-label":"Agent",children:te.length>0?te.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id)):e.jsx("option",{value:"",children:"No agents configured"})})})]})),()=>re(null)},[te,Ds,ct,At,re,Ft,I,lt,g,x,we]),r.useEffect(()=>{Se&&se("info",`Task context attached: ${Se.taskReference}.`)},[se,Se]),r.useEffect(()=>{Q.current?.scrollIntoView?.({block:"end"})},[ss.length,Je,we]);const wn=r.useCallback(()=>Co({baseDefinition:I?.definition,draft:N,name:ue.trim()||at,providerKey:de,modelKey:ce,tier:Qe?.defaultTier||w}),[ue,N,ce,w,de,I?.definition,Qe?.defaultTier]),Ia=async()=>{const s=ue.trim(),l=N.purpose.trim();if(!s||!l||!ce||Ps)return;const c=!g,h=wn();vn(!0),Ye(null);try{const m=g?`/api/taskforce/agents/${encodeURIComponent(g)}`:"/api/taskforce/agents",y=await fetch(m,{method:g?"PATCH":"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t,definition:h,lifecycleStatus:I?.lifecycleStatus||(I?.enabled===!1?"disabled":"active"),...g?{expectedDefinitionHash:I?.definitionHash}:{},...ee&&R?{signatureColor:R}:{},...me?{resetSignatureColor:!0}:{}})}),v=await y.json().catch(()=>({}));if(!y.ok||v?.success===!1||!v?.agent){const V=v?.code==="TASKFORCE_AGENT_DEFINITION_CONFLICT"?"This Agent changed after you opened it. Your draft is preserved; reload the Agent before saving again.":String(v?.error||"Unable to save agent.");se("error",V),Ye({type:"error",message:V});return}const A=v.agent;b.current=!1,pe(V=>V.some(ne=>ne.id===A.id)?V.map(ne=>ne.id===A.id?A:ne):[A,...V]),c?Os(A):(Le(A.name),ve("taskforce_hq"),Me(Hs(A.providerKey)),f(Fs(A.modelKey,A.providerKey)),Y(A.modelTier),Z(Yt(A.definition,{systemPrompt:A.systemPrompt})),U(A.color||mt(A.id)),he(!1),ke(!1),u.current=!1);const J=`Saved ${A.name}.`;se("success",J),Ye({type:"success",message:J}),Ze({workspaceId:t,agentId:A.id,reason:"agent-save"}),A.profileId&&ys({workspaceId:t,profileId:A.profileId,reason:"update",origin:"taskforce-agents-module"}),c&&!Ys(A)&&Cn(A)}catch(m){const y=String(m?.message||m||"Unable to save agent.");se("error",y),Ye({type:"error",message:y})}finally{vn(!1)}};async function Cn(s){const l=s.id;if(!l||is.has(l))return!1;if(!Na){const c=O?"Sign in to Taskforce Cloud to generate agent avatars.":"Cloud sign-in is still loading. Try again in a moment.";return tt(h=>({...h,[l]:{error:c,notice:null}})),!1}xn(c=>new Set(c).add(l)),Ge(null),it(null),tt(c=>({...c,[l]:{error:null,notice:null}}));try{const c=`/api/taskforce/agents/${encodeURIComponent(l)}/avatar/generate`,h=Be&&q?q(c):c,m=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t})}),y=typeof m.clone=="function"?await m.clone().text().catch(()=>""):"",v=await m.json().catch(()=>({}));if(!m.ok||v?.success===!1||!v?.agent){const ne=m.status?`Unable to generate agent avatar. HTTP ${m.status}.`:"Unable to generate agent avatar.",P=v?.details&&typeof v.details=="object"?v.details:null,ae=[typeof P?.modelId=="string"&&P.modelId?`model ${P.modelId}`:"",typeof P?.region=="string"&&P.region?`region ${P.region}`:""].filter(Boolean),ye=ae.length?` Tried ${ae.join(" in ")}.`:"",nt=Ko(y)?`${ne} Please try again.`:qo(y),gs=`${String(v?.error||nt||ne)}${ye}`;return tt(vs=>({...vs,[l]:{error:gs,notice:null}})),!1}const A=v.agent,J=typeof v?.avatar?.profileId=="string"?v.avatar.profileId.trim():"",V=Be&&q?{...A,avatarUrl:A.avatarUrl?Mn(A.avatarUrl):A.avatarUrl,avatarSourceUrl:A.avatarSourceUrl?Mn(A.avatarSourceUrl):A.avatarSourceUrl}:A,B={...V,profileId:V.profileId||J||s.profileId||null};if(pe(ne=>ne.map(P=>P.id===B.id?{...P,...B,profileId:B.profileId||P.profileId||null}:P)),Be){const ne=pt(B.avatarRevision)??pt(v?.avatar?.avatarRevision)??0;ot.current.set(B.id,ne),Ms(P=>new Set(P).add(B.id)),tt(P=>({...P,[l]:{error:null,notice:`Generated photo for ${B.name} was saved in Taskforce Cloud. The local copy will be retained when sync runs.`}}))}else tt(ne=>({...ne,[l]:{error:null,notice:`Generated photo for ${B.name} was saved.`}}));return Ze({workspaceId:t,agentId:B.id,reason:"agent-avatar-generate"}),ys({workspaceId:t,profileId:typeof v?.avatar?.profileId=="string"?v.avatar.profileId:null,reason:"avatar",origin:"taskforce-agents-module"}),!0}catch(c){const h=String(c?.message||c||"Unable to generate agent avatar.");return tt(m=>({...m,[l]:{error:h,notice:null}})),!1}finally{xn(c=>{const h=new Set(c);return h.delete(l),h})}}const Ea=async()=>!g||!I?!1:_o(I.definition,N)?(Ge("Save the avatar description and art style before generating."),it(null),!1):Cn(I),_n=s=>{const l=String(s?.id||"").trim();l&&pe(c=>c.map(h=>h.profileId===l?{...h,avatarUrl:typeof s.avatarUrl=="string"?s.avatarUrl:null,avatarSourceUrl:typeof s.avatarSourceUrl=="string"?s.avatarSourceUrl:null,avatarRevision:Number.isFinite(Number(s.avatarRevision))?Math.max(0,Math.floor(Number(s.avatarRevision))):h.avatarRevision,avatarUpdatedAt:typeof s.avatarUpdatedAt=="string"?s.avatarUpdatedAt:h.avatarUpdatedAt}:h))},$a=async(s,l,c)=>{const h=String(I?.profileId||"").trim();if(!g||!h)return Ge("Save the agent before editing its profile photo."),!1;if(!s.type.startsWith("image/"))return Ge("Agent profile photo must be an image file."),!1;os(!0),Ge(null),it(null),tt(y=>{const v={...y};return delete v[g],v});const m=Be&&Bt.has(g)&&!!q;try{const y=await Pn(s,{maxBytes:5242880});if(y.exceededLimit)throw new Error(s.type==="image/gif"?"Animated GIF agent photos must be 5 MB or smaller.":"Agent profile photo must be 5 MB or smaller.");let v=null;if(l){const vs=await Pn(l,{maxBytes:5242880});if(vs.exceededLimit)throw new Error(l.type==="image/gif"?"Animated GIF agent source photos must be 5 MB or smaller.":"Agent profile source photo must be 5 MB or smaller.");v=vs.file}const A=y.file,J=await Zn(A),V=v?await Zn(v):null,B={profileId:h,preserveExistingSource:c?.preserveExistingSource===!0,displayImage:{dataUrl:J,mimeType:A.type||"application/octet-stream",originalName:A.name||"display-avatar"}};v&&V&&(B.sourceImage={dataUrl:V,mimeType:v.type||"application/octet-stream",originalName:v.name||"source-avatar"});const ne="/api/taskforce/workspace/ai-profiles/avatar/upload",P=m&&q?Dn(q(ne)):ne,ae=await fetch(P,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),ye=await ae.json().catch(()=>({}));if(!ae.ok||!ye?.profile)throw new Error(String(ye?.error||"Failed to update agent profile photo."));const nt=m&&q?{...ye.profile,avatarUrl:ye.profile.avatarUrl?q(ye.profile.avatarUrl):ye.profile.avatarUrl,avatarSourceUrl:ye.profile.avatarSourceUrl?q(ye.profile.avatarSourceUrl):ye.profile.avatarSourceUrl}:ye.profile;_n(nt);const gs=pt(nt.avatarRevision);return m&&gs!==null&&ot.current.set(g,gs),m||(Ze({workspaceId:t,agentId:g,reason:"agent-avatar-upload"}),ys({workspaceId:t,profileId:h,reason:"avatar",origin:"taskforce-agents-module"})),!0}catch(y){return Ge(String(y?.message||"Failed to update agent profile photo.")),!1}finally{os(!1)}},La=async()=>{const s=String(I?.profileId||"").trim();if(!g||!s)return;os(!0),Ge(null),it(null),tt(c=>{const h={...c};return delete h[g],h});const l=Be&&Bt.has(g)&&!!q;try{const c="/api/taskforce/workspace/ai-profiles/avatar",h=l&&q?Dn(q(c)):c,m=await fetch(h,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:s,avatarUrl:null,avatarSourceUrl:null})}),y=await m.json().catch(()=>({}));if(!m.ok||!y?.profile)throw new Error(String(y?.error||"Failed to remove agent profile photo."));_n(y.profile);const v=pt(y.profile.avatarRevision);l&&v!==null&&ot.current.set(g,v),it(l?"Agent profile photo removed in Taskforce Cloud. The local copy will be retained when sync runs.":"Agent profile photo removed."),l||(Ze({workspaceId:t,agentId:g,reason:"agent-avatar-remove"}),ys({workspaceId:t,profileId:s,reason:"avatar",origin:"taskforce-agents-module"}))}catch(c){Ge(String(c?.message||"Failed to remove agent profile photo."))}finally{os(!1)}},Pa=()=>Ft({type:"new"}),Da=s=>{b.current=!0;const l=Hs(s),c=Bs(l);Me(l),f(c[0]?.key||""),Y(c[0]?.defaultTier||"balanced")},Ma=s=>{b.current=!0;const l=Fs(s,de),c=wt.find(h=>h.key===l);f(l),c&&Y(c.defaultTier)},Gs=()=>{kt||(X.current+=1,bt(!1),rt(""),ze(""))},Ua=()=>{!g||!Ie||!st||(X.current+=1,rt(st.title||"Agent chat"),ze(""),bt(!0))},Oa=async s=>{s.preventDefault();const l=Cs.trim();if(!g||!Ie||kt)return;if(!l){ze("Chat name is required.");return}if(l===st?.title){Gs();return}const c=g,h=Ie,m=++X.current;Ut(!0),ze("");try{const y=await fetch(`/api/taskforce/agents/${encodeURIComponent(c)}/conversations/${encodeURIComponent(h)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t,title:l})}),v=await y.json().catch(()=>({}));if(X.current!==m||le.current!==c)return;if(!y.ok||v?.success===!1||!v?.conversation){ze(String(v?.error||"Unable to rename chat."));return}Ht(v.conversation),bt(!1),rt(""),Ze({workspaceId:t,agentId:c,conversationId:h,reason:"conversation-update"})}catch(y){if(X.current!==m||le.current!==c)return;ze(String(y?.message||y||"Unable to rename chat."))}finally{X.current===m&&Ut(!1)}},za=async()=>{if(!g){Zt(""),yt([]),jt(null),We([]),es(null),se("info","Started a new unsaved chat.");return}Nt(!0),We([]);try{const s=await fetch(`/api/taskforce/agents/${encodeURIComponent(g)}/conversation/new`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t,...Se?{taskId:Se.taskId,taskReference:Se.taskReference,taskTitle:Se.taskTitle}:{}})}),l=await s.json().catch(()=>({}));if(!s.ok||l?.success===!1){se("error",String(l?.error||"Unable to start a new chat."));return}Zt("");const c=l?.conversation||null;ut(c),Ee(g,c?.id||null),c&&Ht(c),Ze({workspaceId:t,agentId:g,conversationId:l?.conversation?.id||null,reason:"conversation-create"}),se("info","Started a new saved chat.")}catch(s){se("error",String(s?.message||s||"Unable to start a new chat."))}finally{Nt(!1)}},Ga=async()=>{const s=ns.trim(),l=ue.trim()||at;if(!s||!N.purpose.trim()||!ce||et)return;const c=wn();if(!Us){zt(O?"Sign in to Taskforce Cloud to test this agent.":"Cloud sign-in is still loading. Try again in a moment.");return}Ls(!0);const h=++E.current;Ts(null),Is(null),Es([]),zt("");try{const m=await fetch("/api/taskforce/agents/model-gateway/test",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t,agentName:l,providerKey:de,modelKey:ce,prompt:s,messages:[{role:"user",content:s}],draftDefinition:c})}),y=await m.json().catch(()=>({}));if(E.current!==h)return;if(!m.ok||y?.success===!1){zt(String(y?.error||"Agent test failed."));return}Ts(y?.result||null),Is({agentName:l,providerKey:de,modelKey:ce,prompt:s,definition:c});const v=Array.isArray(y?.mcpToolCalls)?y.mcpToolCalls:[];Es(v.reduce((A,J,V)=>{const B=String(J?.name||"").trim();return B&&A.push({id:`draft-${V}-${B}`,name:B,arguments:J.arguments,resultText:J.text,ok:J.ok!==!1}),A},[]))}catch(m){if(E.current!==h)return;zt(String(m?.message||m||"Agent test failed."))}finally{E.current===h&&Ls(!1)}},Rn=async()=>{const s=je.trim(),l=xe.trim(),c=ue.trim()||at;if(!s||!ce||we||Je)return;if(!Us){const y=O?"Sign in to Taskforce Cloud to chat with Taskforce agents.":"Cloud sign-in is still loading. Try again in a moment.";Ot(y),se("error",y);return}mn(!0),jt(null),Ot("");const h=Date.now(),m=[...ss,{role:"user",content:s}];yt(m),Zt(""),We([]),se("info",`Started test prompt for ${c}.`);try{const y=await fetch("/api/taskforce/agents/model-gateway/test",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({workspaceId:t,agentId:g,conversationId:Ie,agentName:c,providerKey:de,modelKey:ce,prompt:s,messages:m,system:l,tier:Qe?.defaultTier||w,...He?{taskId:He.taskId,taskReference:He.taskReference,taskTitle:He.taskTitle}:{}})}),v=await y.json().catch(()=>({}));if(!y.ok||v?.success===!1){const P=String(v?.error||"Model gateway test failed.");Ot(P),se("error",P);return}const A=v?.result||null;jt(A);const J=Array.isArray(v?.mcpToolCalls)?v.mcpToolCalls:[],V=J.reduce((P,ae,ye)=>{const nt=String(ae?.name||"").trim();return nt&&P.push({id:`${h}-${ye}-${nt}`,name:nt,arguments:ae.arguments,resultText:ae.text,ok:ae.ok!==!1}),P},[]);if(We(V),V.length>0){const P=V.some(ae=>!ae.ok);se(P?"error":"success",Xo(V),V)}const B=v?.workflowCompletion;let ne=B?.taskSnapshot||null;B?.executionId&&B.assignmentSnapshot&&(ne=await tr(B,{workspaceId:t,runtimeMode:k})),J.length>0&&V.forEach(P=>{(P.name==="add_comment"||P.name==="add_task_checklist_item"||P.name==="replace_task_checklist"||P.name==="complete_workflow_step")&&P.ok&&sr({workspaceId:t,taskId:(P.name==="complete_workflow_step"?B?.taskId:null)||He?.taskId||String(P.arguments?.taskId||P.arguments?.id||"").trim()||null,reason:P.name==="add_comment"?"agent-comment":P.name==="complete_workflow_step"?"workflow-step":"agent-checklist",...P.name==="complete_workflow_step"&&ne?{authoritativeTask:ne}:{}})}),v?.conversation?(ut(v.conversation),Ee(g,v.conversation.id||Ie||null),Ht(v.conversation),Ze({workspaceId:t,agentId:g,conversationId:v.conversation.id||Ie,reason:"conversation-update"})):yt(A?.text?[...m,{role:"assistant",content:String(A.text),agentId:g||void 0,agentName:c,providerKey:de,providerLabel:qt(de),modelKey:ce,modelLabel:xs(ce),modelId:String(A.modelId||""),...V.length>0?{toolActivity:V.map(({id:P,...ae})=>ae)}:{}}]:m),se("success",`Model gateway completed successfully in ${A?.latencyMs??Date.now()-h} ms.`)}catch(y){const v=String(y?.message||y||"Model gateway test failed.");Ot(v),se("error",v)}finally{mn(!1)}},Ba=s=>{s.key!=="Enter"||s.shiftKey||s.nativeEvent.isComposing||(s.preventDefault(),Rn())},Ha=s=>{!g||!s||s===Ie||zs(g,s)},Fa=s=>e.jsx("div",{className:a.taskforceAgentToolActivityList,children:s.map(l=>e.jsxs("details",{className:`${a.taskforceAgentToolCall} ${l.ok?"":a.taskforceAgentToolCallFailed}`.trim(),children:[e.jsxs("summary",{children:[l.ok?e.jsx(It,{size:13}):e.jsx(gt,{size:13}),e.jsx("span",{className:a.taskforceAgentToolCallName,children:l.name}),e.jsx("span",{className:a.taskforceAgentToolCallStatus,children:l.ok?"ok":"failed"})]}),e.jsxs("div",{className:a.taskforceAgentToolDetailsGrid,children:[e.jsx("span",{children:"Arguments"}),e.jsx("pre",{children:Jo(l.arguments)}),e.jsx("span",{children:"Result"}),e.jsx("pre",{children:Yo(l.resultText)})]})]},l.id))}),Tn=(s,l="Tool Activity")=>e.jsxs("details",{className:a.taskforceAgentToolActivity,children:[e.jsxs("summary",{children:[e.jsx("span",{children:l}),e.jsx("strong",{children:Qo(s)})]}),Fa(s)]}),Ct=H==="agents"?{icon:e.jsx(Tt,{size:14}),title:"Agent Roster",empty:"No agents configured yet."}:H==="roles"?{icon:e.jsx($t,{size:14}),title:"Role Library",empty:"No roles configured yet."}:H==="skills"?{icon:e.jsx(vt,{size:14}),title:"Skill Library",empty:"Browse and manage Skills in the editor."}:H==="connections"?{icon:e.jsx(Qt,{size:14}),title:"Connection Library",empty:"Connections are not available yet."}:{icon:e.jsx(ws,{size:14}),title:"Resource Library",empty:"Resource Collections are not available yet."},qa=e.jsxs("div",{className:a.taskforceAgentBuilderNavigation,children:[e.jsx("div",{className:a.taskforceAgentBuilderTabs,role:"tablist","aria-label":"Taskforce Agent builders",children:Rt.map((s,l)=>{const c=H===s.id;return e.jsx("button",{ref:h=>{Ne.current[s.id]=h},type:"button",className:`${a.taskforceAgentBuilderTab} ${c?a.taskforceAgentBuilderTabActive:""}`.trim(),role:"tab","aria-selected":c,"aria-controls":`taskforce-agent-builder-${s.id}`,id:`taskforce-agent-builder-tab-${s.id}`,tabIndex:c?0:-1,onClick:()=>L(s.id),onKeyDown:h=>{let m=l;if(h.key==="ArrowRight")m=(l+1)%Rt.length;else if(h.key==="ArrowLeft")m=(l-1+Rt.length)%Rt.length;else if(h.key==="Home")m=0;else if(h.key==="End")m=Rt.length-1;else return;h.preventDefault();const y=Rt[m];L(y.id),Ne.current[y.id]?.focus()},children:s.label},s.id)})}),H==="agents"?e.jsxs("button",{type:"button",className:`${a.secondaryHeaderBtn} ${a.taskforceAgentBuilderCreateBtn}`.trim(),onClick:Pa,children:[e.jsx(xt,{size:14}),"New Agent"]}):null]}),Ka=e.jsxs("aside",{className:`${a.docTrayPanel} ${n?a.docTrayPanelOpen:""}`.trim(),"aria-hidden":!n,"aria-label":Ct.title,children:[e.jsxs("div",{className:a.taskforceAgentRosterHeader,children:[e.jsxs("span",{className:a.taskforceAgentRosterTitle,children:[Ct.icon,Ct.title]}),H==="agents"&&At&&e.jsx(Oe,{size:14,className:a.spinner}),i?e.jsx("button",{type:"button",className:"tf-control-icon",onClick:i,title:`Collapse ${Ct.title.toLowerCase()}`,"aria-label":`Collapse ${Ct.title.toLowerCase()}`,children:e.jsx(xr,{size:16})}):null]}),e.jsx("div",{className:`${a.taskforceAgentRosterContent} tf-scrollbar tf-tray-scroll-viewport`,children:H==="roles"?e.jsx("div",{ref:Ve,className:a.taskforceAgentLibraryPortal}):H==="skills"?e.jsx("div",{ref:G,className:a.taskforceAgentLibraryPortal}):H==="connections"?e.jsx(Bn,{kind:"connections"}):H==="resources"?e.jsx(Bn,{kind:"resources"}):H==="agents"&&te.length>0?e.jsx("div",{className:a.taskforceAgentList,children:te.map(s=>{const l=Ys(s),c=s.color||mt(s.id);return e.jsx(nr,{name:s.name,username:s.username,subtitle:"Taskforce Agent",avatar:l?e.jsx(Qs,{src:l,fallbackSize:22}):e.jsx(Tt,{size:22}),avatarStyle:{color:c},selected:s.id===g,disabled:!W,onSelect:()=>Ft({type:"agent",agent:s}),ariaLabel:`Edit ${s.name}`,bottomUtility:e.jsx("span",{className:a.aiProfileGroupSignatureSwatch,style:{backgroundColor:c},title:`Signature color ${c}`,"aria-hidden":"true"})},s.id)})}):e.jsx("p",{className:a.taskforceAgentListEmpty,children:Ct.empty})})]});return x==="taskDrawer"?e.jsxs("div",{className:a.taskforceAgentDrawerSurface,children:[He?e.jsxs("div",{className:a.taskforceAgentContextBanner,children:[e.jsxs("div",{children:[e.jsx("span",{children:"Context"}),e.jsx("strong",{children:Ca})]}),e.jsxs("div",{className:a.taskforceAgentContextActions,children:[C?e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact",onClick:()=>C(He.taskId),title:"Open task","aria-label":"Open task",children:e.jsx(yr,{size:13})}):null,d&&_a?e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact",onClick:d,title:"Clear task context","aria-label":"Clear task context",children:e.jsx(Lt,{size:13})}):null]})]}):null,Ds&&I?e.jsxs("section",{className:a.taskforceAgentProfileTray,"aria-label":`${I.name} profile`,children:[e.jsxs("div",{className:a.taskforceAgentProfileTrayHeader,children:[e.jsxs("span",{className:`${a.taskforceAgentAvatarPreview} ${ct?a.taskforceAgentAvatarSyncing:""}`.trim(),"aria-hidden":"true",children:[lt?e.jsx(Qs,{src:lt,fallbackSize:18}):e.jsx(Tt,{size:18}),ct?e.jsx(Oe,{size:13,className:`${a.spinner} ${a.taskforceAgentAvatarSyncIcon}`}):null]}),e.jsxs("div",{className:a.taskforceAgentProfileTrayIdentity,children:[e.jsx("span",{children:"Agent profile"}),e.jsx("strong",{children:I.name}),e.jsxs("small",{children:[qt(I.providerKey)," · ",Xs(I.modelTier)]})]}),e.jsx("button",{type:"button",className:"tf-control-icon tf-control-icon-compact",onClick:()=>kn(!1),title:"Close agent profile","aria-label":"Close agent profile",children:e.jsx(Lt,{size:13})})]}),e.jsxs("dl",{className:a.taskforceAgentProfileTrayDetails,children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Platform"}),e.jsx("dd",{children:ea(I.modelProvider)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Provider"}),e.jsx("dd",{children:qt(I.providerKey)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{children:xs(I.modelKey)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Default tier"}),e.jsx("dd",{children:Xs(I.modelTier)})]})]})]}):null,e.jsxs("div",{className:a.taskforceAgentDrawerControls,children:[re?null:e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Agent"}),e.jsx("select",{className:a.select,value:g||"",onChange:s=>{const l=te.find(c=>c.id===s.target.value);l&&Ft({type:"agent",agent:l})},disabled:!W||At||te.length===0||we,children:te.length>0?te.map(s=>e.jsxs("option",{value:s.id,children:[s.name," · ",xs(s.modelKey)]},s.id)):e.jsx("option",{value:"",children:"No agents configured"})})]}),va?e.jsxs("form",{className:a.taskforceAgentConversationRename,onSubmit:Oa,children:[e.jsx("input",{className:a.input,"aria-label":"Chat name",value:Cs,onChange:s=>{rt(s.target.value),_s&&ze("")},onKeyDown:s=>{s.key==="Escape"&&(s.preventDefault(),Gs())},maxLength:120,autoFocus:!0,disabled:kt}),e.jsx("button",{type:"submit",className:"tf-control-icon","aria-label":"Save chat name",title:"Save chat name",disabled:kt||!Cs.trim(),children:kt?e.jsx(Oe,{size:14,className:a.spinner}):e.jsx(tn,{size:14})}),e.jsx("button",{type:"button",className:"tf-control-icon",onClick:Gs,"aria-label":"Cancel renaming",title:"Cancel",disabled:kt,children:e.jsx(Lt,{size:14})}),_s?e.jsx("div",{className:a.taskforceAgentConversationRenameError,role:"alert",children:_s}):null]}):e.jsxs("div",{className:a.taskforceAgentDrawerChatControls,children:[g?e.jsx("select",{className:`${a.select} ${a.taskforceAgentConversationSelect}`.trim(),"aria-label":"Saved chats",value:Ie||"",onChange:s=>Ha(s.target.value),disabled:we||Je||ya||Mt.length===0,children:Mt.length>0?e.jsxs(e.Fragment,{children:[Ie?null:e.jsx("option",{value:"",children:"Select chat"}),Mt.map(s=>e.jsx("option",{value:s.id,children:sl(s,Se)},s.id))]}):e.jsx("option",{value:"",children:"No chats"})}):null,e.jsx("button",{type:"button",className:"tf-control-icon",onClick:Ua,disabled:we||Je||!st,"aria-label":"Rename chat",title:"Rename chat",children:e.jsx(br,{size:14})}),e.jsx("button",{type:"button",className:"tf-control-icon",onClick:()=>{za()},disabled:we||Je||!g,"aria-label":"New chat",title:"New chat",children:e.jsx(xt,{size:14})})]})]}),e.jsxs("div",{className:`${a.taskforceAgentConversationList} ${a.taskforceAgentDrawerConversationList} tf-scrollbar`,children:[Je?e.jsx("div",{className:a.taskforceAgentConversationEmpty,children:"Loading saved conversation..."}):ss.length>0?ss.map((s,l)=>e.jsxs("div",{"data-conversation-role":s.role,style:s.role==="assistant"&&ms?{"--conversation-accent":ms}:void 0,className:`${a.taskforceAgentConversationMessage} ${s.role==="user"?a.taskforceAgentConversationMessageUser:a.taskforceAgentConversationMessageAssistant}`.trim(),children:[e.jsx("span",{children:el(s,Ra)}),e.jsx(Zs,{variant:"conversation",className:a.taskforceAgentConversationBody,taskReferences:S,children:s.content}),s.role==="assistant"&&s.toolActivity?.length?Tn(s.toolActivity.map((c,h)=>({...c,id:`${l}-${h}-${c.name}`})),"Taskforce actions"):null]},`${s.role}-${l}`)):we?null:e.jsx("div",{className:a.taskforceAgentConversationEmpty,children:g?"No conversation yet.":"Select an agent to start chatting."}),we&&!Je?e.jsxs("div",{"data-conversation-role":"assistant",style:ms?{"--conversation-accent":ms}:void 0,className:`${a.taskforceAgentConversationMessage} ${a.taskforceAgentConversationMessageAssistant}`.trim(),children:[e.jsx("span",{children:ue.trim()||at}),e.jsx("p",{children:"Waiting for model response..."})]}):null,e.jsx("div",{ref:Q,"aria-hidden":"true"})]}),e.jsxs("div",{className:a.taskforceAgentDrawerPrompt,children:[e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Message"}),e.jsx("textarea",{className:a.input,value:je,onChange:s=>{Zt(s.target.value),Rs&&Ot("")},onKeyDown:Ba,disabled:we||Je||!g,placeholder:we?"Waiting for response...":Bo,maxLength:4e3})]}),e.jsxs("button",{type:"button",className:a.secondaryHeaderBtn,onClick:()=>{Rn()},disabled:we||Je||!je.trim()||!ce||!g,children:[we?e.jsx(Oe,{size:14,className:a.spinner}):e.jsx(kr,{size:14}),"Send"]}),Rs?e.jsx("div",{className:a.taskforceAgentDrawerPromptStatus,role:"status",children:Rs}):null]}),e.jsxs("div",{className:a.taskforceAgentDrawerMetrics,"aria-label":"Response metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Usage"}),Xn(un)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Latency"}),Js(un)]})]})]}):e.jsxs("div",{className:`${a.standalonePage} ${a.standaloneContent} ${a.taskforceAgentsModuleRoot} ${n?a.taskforceAgentsModuleTrayOpen:""}`.trim(),children:[Ka,e.jsxs("div",{className:`${a.taskforceAgentsModuleMain} tf-scrollbar`,children:[e.jsxs("div",{className:a.settingsContent,style:{maxWidth:1180,margin:"0 auto",width:"100%"},children:[qa,e.jsx("div",{className:`${a.settingGroup} ${a.taskforceAgentBuilderPanel}`,hidden:H!=="agents",children:e.jsxs("div",{className:a.taskforceAgentTestGrid,role:"tabpanel",id:"taskforce-agent-builder-agents","aria-labelledby":"taskforce-agent-builder-tab-agents",children:[e.jsxs("div",{className:a.settingGroup,children:[e.jsxs("div",{className:a.taskforceAgentAvatarPanel,children:[e.jsxs("div",{className:a.taskforceAgentAvatarEditControl,children:[e.jsx(Ya,{label:I?`Edit ${I.name} photo`:"Photo editing is unavailable until agent creation",imageUrl:lt,fallback:e.jsx(Tt,{size:28}),accentColor:R||I?.color,size:88,editBadgeSize:28,editIconSize:14,disabled:!g,loading:!!(g&&is.has(g)),loadingLabel:`Generating ${I?.name||"agent"} photo`,error:!!ds?.error,errorLabel:ds?.error||"Agent photo generation failed",onClick:()=>{Ge(null),it(null),yn(!0)}}),ct?e.jsx(Oe,{size:16,className:`${a.spinner} ${a.taskforceAgentAvatarSyncIcon}`}):null]}),e.jsxs("div",{className:a.taskforceAgentAvatarCopy,children:[e.jsx("strong",{children:ue.trim()||I?.name||at}),e.jsx("span",{className:a.taskforceAgentAvatarRole,children:"Taskforce Agent"}),ct?e.jsx("small",{children:"Syncing avatar..."}):null]}),e.jsxs("div",{className:a.taskforceAgentToolbar,children:[Gt?e.jsxs("span",{className:Gt.type==="error"?"tf-chip-danger":"tf-chip-success",role:Gt.type==="error"?"alert":"status","aria-label":"Agent configuration status",children:[Gt.type==="error"?e.jsx(gt,{size:12}):e.jsx(It,{size:12}),Gt.message]}):null,e.jsxs("button",{type:"button",className:a.secondaryHeaderBtn,onClick:()=>{Ia()},disabled:Ps||!ue.trim()||!N.purpose.trim()||!ce,children:[Ps?e.jsx(Oe,{size:14,className:a.spinner}):e.jsx(tn,{size:14}),"Save"]})]})]}),I?.configurationState&&I.configurationState!=="valid"?e.jsxs("div",{className:a.taskforceAgentTestError,role:"alert",children:[e.jsx(gt,{size:14}),e.jsxs("span",{children:["This Agent configuration is ",I.configurationState.replace(/-/g," "),".",I.configurationIssues?.[0]?.message?` ${I.configurationIssues[0].message}`:" Repair the highlighted configuration before testing it."]})]}):null,e.jsxs("div",{className:a.topRow,children:[e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Agent Name"}),e.jsx("input",{className:a.input,value:ue,onChange:s=>{b.current=!0,Le(s.target.value)},placeholder:at,required:!0,maxLength:80})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Platform"}),e.jsx("div",{className:a.taskforceAgentReadonlyField,children:ea()})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Provider"}),e.jsx("select",{className:a.select,value:de,onChange:s=>Da(s.target.value),children:Aa.map(s=>e.jsx("option",{value:s.key,children:s.label},s.key))})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Model"}),e.jsx("select",{className:a.select,value:ce,onChange:s=>Ma(s.target.value),disabled:wt.length===0,children:wt.length>0?wt.map(s=>e.jsx("option",{value:s.key,children:s.label},s.key)):e.jsxs("option",{value:"",children:["No configured ",qt(de)," models yet"]})})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Default Tier"}),e.jsx("div",{className:a.taskforceAgentReadonlyField,children:Qe?Xs(Qe.defaultTier):"No configured tier"})]})]}),e.jsxs("div",{className:a.taskforceAgentSignatureColorField,children:[e.jsxs("div",{children:[e.jsx("span",{className:a.label,children:"Signature Color"}),e.jsx("small",{children:"Identifies this agent across Taskforce."})]}),e.jsxs("div",{className:a.aiProfileColorPicker,"aria-label":"Signature color options",children:[ar.map(s=>{const l=Qa[s];return e.jsx("button",{type:"button",className:a.aiProfileColorOption,style:{backgroundColor:l},"aria-label":`Use ${s}`,"aria-pressed":R.toLowerCase()===l.toLowerCase(),onClick:()=>{b.current=!0,U(l),he(!0),ke(!1),u.current=!0}},s)}),I?e.jsx("button",{type:"button",className:a.secondaryHeaderBtn,onClick:()=>{b.current=!0,U(mt(I.id)),he(!1),ke(!0),u.current=!0},children:"Reset"}):null]})]}),e.jsxs("div",{className:a.taskforceAgentBehaviorGrid,children:[e.jsxs("label",{className:`${a.field} ${a.taskforceAgentBehaviorWide}`,children:[e.jsx("span",{className:a.label,children:"Purpose"}),e.jsx("small",{className:a.taskforceAgentFieldHelper,children:"What should this agent help with?"}),e.jsx("textarea",{className:a.input,"aria-label":"Purpose",value:N.purpose,onChange:s=>{b.current=!0,Z(l=>({...l,purpose:s.target.value}))},maxLength:1e3,rows:3,required:!0})]}),e.jsx("div",{className:a.taskforceAgentBehaviorWide,children:e.jsx(vo,{workspaceId:t,roleRef:N.roleRef,skillRefs:N.skillRefs,onRoleRefChange:s=>{b.current=!0,Z(l=>({...l,roleRef:s}))},onSkillRefsChange:s=>{b.current=!0,Z(l=>({...l,skillRefs:s}))},onManageRoles:()=>L("roles"),onManageSkills:()=>L("skills")})}),e.jsx("div",{className:a.taskforceAgentBehaviorWide,children:e.jsx(cn,{selectedKeys:N.requestedCapabilities,hasCustomOverrides:!!(I?.definition?.toolPolicy.toolOverrides?.length&&!N.toolAccessChanged),onChange:s=>{b.current=!0,Z(l=>({...l,requestedCapabilities:s,toolAccessChanged:!0}))}})}),e.jsx("div",{className:a.taskforceAgentBehaviorWide,children:e.jsx(ci,{hasRole:!!N.roleRef,directSkillCount:N.skillRefs.length,toolKeys:N.requestedCapabilities})}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Personality and Voice"}),e.jsx("small",{className:a.taskforceAgentFieldHelper,children:"How should this agent behave or portray itself?"}),e.jsxs("select",{className:a.select,"aria-label":"Personality and Voice",value:N.personalitySelection,onChange:s=>{b.current=!0,Z(l=>({...l,personalitySelection:s.target.value,personalityCustom:s.target.value===_e?l.personalityCustom:""}))},children:[e.jsx("option",{value:"",children:"No preset"}),yo.map(s=>e.jsx("option",{value:s.key,children:s.label},s.key)),e.jsx("option",{value:_e,children:"Custom"})]})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Response Style"}),e.jsx("small",{className:a.taskforceAgentFieldHelper,children:"How should answers be written and structured?"}),e.jsxs("select",{className:a.select,"aria-label":"Response Style",value:N.responseStyleSelection,onChange:s=>{b.current=!0,Z(l=>({...l,responseStyleSelection:s.target.value,responseStyleCustom:s.target.value===_e?l.responseStyleCustom:""}))},children:[e.jsx("option",{value:"",children:"No preset"}),bo.map(s=>e.jsx("option",{value:s.key,children:s.label},s.key)),e.jsx("option",{value:_e,children:"Custom"})]})]}),N.personalitySelection===_e?e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Custom Personality and Voice"}),e.jsx("textarea",{className:a.input,"aria-label":"Custom Personality and Voice",value:N.personalityCustom,onChange:s=>{b.current=!0,Z(l=>({...l,personalityCustom:s.target.value}))},maxLength:4e3,rows:3})]}):null,N.responseStyleSelection===_e?e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Custom Response Style"}),e.jsx("textarea",{className:a.input,"aria-label":"Custom Response Style",value:N.responseStyleCustom,onChange:s=>{b.current=!0,Z(l=>({...l,responseStyleCustom:s.target.value}))},maxLength:4e3,rows:3})]}):null,e.jsxs("label",{className:`${a.field} ${a.taskforceAgentBehaviorWide}`,children:[e.jsx("span",{className:a.label,children:"Working Guidelines"}),e.jsx("small",{className:a.taskforceAgentFieldHelper,children:"How should this agent approach tasks, decisions, and constraints?"}),e.jsx("textarea",{className:a.input,"aria-label":"Working Guidelines",style:{minHeight:108,resize:"vertical"},value:xe,onChange:s=>p(s.target.value),maxLength:8e3})]})]}),e.jsxs("div",{className:a.taskforceAgentPresentationGroup,children:[e.jsxs("div",{children:[e.jsx("span",{className:a.label,children:"Avatar Generation Direction"}),e.jsx("small",{className:a.taskforceAgentFieldHelper,children:"Saved for manual avatar generation only. These details are excluded from normal Agent context."})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Avatar Visual Description"}),e.jsx("textarea",{className:a.input,"aria-label":"Avatar Visual Description",value:N.avatarVisualDescription,onChange:s=>{b.current=!0,Z(l=>({...l,avatarVisualDescription:s.target.value}))},maxLength:4e3,rows:3,placeholder:"Describe what this agent or character looks like."})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Avatar Art Style"}),e.jsxs("select",{className:a.select,"aria-label":"Avatar Art Style",value:N.avatarArtStyleSelection,onChange:s=>{b.current=!0,Z(l=>({...l,avatarArtStyleSelection:s.target.value,avatarArtStyleCustom:s.target.value===_e?l.avatarArtStyleCustom:""}))},children:[e.jsx("option",{value:"",children:jo}),ko.map(s=>e.jsx("option",{value:s.key,children:s.label},s.key)),e.jsx("option",{value:_e,children:"Custom"})]})]}),N.avatarArtStyleSelection===_e?e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Custom Avatar Art Style"}),e.jsx("textarea",{className:a.input,"aria-label":"Custom Avatar Art Style",value:N.avatarArtStyleCustom,onChange:s=>{b.current=!0,Z(l=>({...l,avatarArtStyleCustom:s.target.value}))},maxLength:4e3,rows:3,placeholder:"Describe medium, palette, lighting, period, or atmosphere."})]}):null]}),e.jsxs("details",{className:a.taskforceAgentToolActivity,children:[e.jsxs("summary",{children:[e.jsx("span",{children:"Technical model details"}),e.jsx("strong",{children:Qe?Vo(Qe.availability):"Unavailable"})]}),e.jsxs("div",{className:a.taskforceAgentMetaGrid,children:[e.jsxs("div",{children:[e.jsx("span",{children:"Model ID"}),e.jsx("code",{children:Qe?.runtimeModelId||"No configured model"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Max Output"}),e.jsx("strong",{children:Zo(Qe?.defaultMaxTokens)})]})]})]})]}),e.jsx("div",{className:a.taskforceAgentOutputStack,children:e.jsxs("section",{className:a.taskforceAgentOutputPanel,"aria-labelledby":"taskforce-agent-test-title",children:[e.jsx("div",{className:a.settingTitleRow,children:e.jsxs("div",{className:a.taskforceAgentTestTitle,children:[e.jsx("span",{className:a.taskforceAgentBuilderEmptyIcon,"aria-hidden":"true",children:e.jsx(Un,{size:18})}),e.jsxs("div",{children:[e.jsx("h4",{id:"taskforce-agent-test-title",className:a.settingSubTitle,children:"Test Agent"}),e.jsx("p",{children:"Run one isolated prompt against the current draft, including unsaved changes."})]})]})}),e.jsxs("div",{className:a.taskforceAgentTestNotice,children:[e.jsx(It,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:"Test messages are not saved to conversations and cannot write to task-scoped tools."})]}),e.jsxs("label",{className:a.field,children:[e.jsx("span",{className:a.label,children:"Test Prompt"}),e.jsx("textarea",{className:a.input,value:ns,onChange:s=>fn(s.target.value),placeholder:"Ask the draft agent a representative question...",rows:5,disabled:et})]}),e.jsxs("div",{className:a.taskforceAgentTestActions,children:[e.jsxs("button",{type:"button",className:a.secondaryHeaderBtn,onClick:dt,disabled:et||!ns&&!Ue&&!$s,children:[e.jsx(on,{size:14}),"Reset"]}),g&&ge?e.jsxs("button",{type:"button",className:a.secondaryHeaderBtn,onClick:()=>ge(g),disabled:et,children:[e.jsx(jr,{size:14}),"Open in Conversation"]}):null,e.jsxs("button",{type:"button",className:a.primaryUpdateBtn,onClick:()=>{Ga()},disabled:et||!ns.trim()||!N.purpose.trim()||!ce,children:[et?e.jsx(Oe,{size:14,className:a.spinner}):e.jsx(Un,{size:14}),et?"Testing...":"Run Test"]})]}),Us?null:e.jsx("p",{className:a.taskforceAgentTestRestriction,children:O?"Sign in to Taskforce Cloud to run agent tests.":"Checking Taskforce Cloud sign-in..."}),$s?e.jsxs("div",{className:a.taskforceAgentTestError,role:"alert",children:[e.jsx(gt,{size:14}),e.jsx("span",{children:$s})]}):null,et?e.jsxs("div",{className:a.taskforceAgentTestPending,role:"status",children:[e.jsx(Oe,{size:15,className:a.spinner}),e.jsx("span",{children:"Running isolated test..."})]}):null,Ue?e.jsxs("div",{className:a.taskforceAgentTestResult,role:"status","aria-live":"polite",children:[e.jsxs("div",{className:a.taskforceAgentTestResultHeader,children:[e.jsxs("span",{children:[e.jsx(It,{size:14})," Test completed"]}),e.jsxs("span",{children:[Js(Ue)," · ",Xn(Ue)]})]}),e.jsx("div",{className:a.taskforceAgentTestResponse,children:e.jsx(Zs,{variant:"conversation",children:Ue.text})}),e.jsxs("details",{className:a.taskforceAgentToolActivity,children:[e.jsxs("summary",{children:[e.jsx("span",{children:"Response Details"}),e.jsx("strong",{children:xs(St?.modelKey||ce)})]}),e.jsxs("div",{className:a.taskforceAgentMetaGrid,children:[e.jsxs("div",{children:[e.jsx("span",{children:"Tested agent"}),e.jsx("strong",{children:St?.agentName||ue.trim()||at})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Provider"}),e.jsx("strong",{children:qt(St?.providerKey||de)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Runtime model"}),e.jsx("code",{children:Ue.modelId||"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Test prompt"}),e.jsx("strong",{children:St?.prompt||"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Tested purpose"}),e.jsx("strong",{children:St?.definition.purpose||"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Tested working guidelines"}),e.jsx("strong",{children:St?.definition.behavior.workingGuidelines||"None"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Stop reason"}),e.jsx("strong",{children:Ue.stopReason||"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Input tokens"}),e.jsx("strong",{children:Ue.usage?.inputTokens??"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Output tokens"}),e.jsx("strong",{children:Ue.usage?.outputTokens??"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Total tokens"}),e.jsx("strong",{children:Ue.usage?.totalTokens??"Not reported"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Latency"}),e.jsx("strong",{children:Js(Ue)})]})]}),pn.length>0?Tn(pn,"Managed Tool Activity"):null]})]}):null]})})]})}),e.jsx("section",{className:a.taskforceAgentBuilderPanel,role:"tabpanel",id:"taskforce-agent-builder-roles","aria-labelledby":"taskforce-agent-builder-tab-roles",hidden:H!=="roles",children:H==="roles"?e.jsx(to,{workspaceId:t,libraryPortalTarget:be}):null}),e.jsx("section",{className:a.taskforceAgentBuilderPanel,role:"tabpanel",id:"taskforce-agent-builder-skills","aria-labelledby":"taskforce-agent-builder-tab-skills",hidden:H!=="skills",children:e.jsx(Go,{workspaceId:t,active:H==="skills",libraryPortalTarget:Te},t)}),e.jsx("section",{className:a.taskforceAgentBuilderPanel,role:"tabpanel",id:"taskforce-agent-builder-connections","aria-labelledby":"taskforce-agent-builder-tab-connections",hidden:H!=="connections",children:H==="connections"?e.jsx(Hn,{kind:"connections"}):null}),e.jsx("section",{className:a.taskforceAgentBuilderPanel,role:"tabpanel",id:"taskforce-agent-builder-resources","aria-labelledby":"taskforce-agent-builder-tab-resources",hidden:H!=="resources",children:H==="resources"?e.jsx(Hn,{kind:"resources"}):null})]}),e.jsx(Xa,{isOpen:!!as,onClose:()=>rs(null),title:"Discard unsaved changes?",size:"sm",theme:K,closeOnOverlayClick:!1,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"tf-button-secondary",onClick:()=>rs(null),"data-modal-initial-focus":!0,children:"Keep editing"}),e.jsx("button",{type:"button",className:"tf-button-destructive",onClick:Ta,children:"Discard changes"})]}),children:e.jsx("p",{children:"Your unsaved Agent changes will be lost."})}),e.jsx(Za,{isOpen:ka,theme:K,title:"Edit Agent Profile Photo",currentImageUrl:lt,editorImageUrl:wa,fallbackInitial:(I?.name||"Agent").charAt(0).toUpperCase(),accept:"image/png,image/jpeg,image/webp,image/gif",busy:bn,generating:!!(g&&is.has(g)),generateLabel:I?.avatarUrl?"Regenerate":"Generate",hasPendingImage:!1,canRemove:!!I?.avatarUrl,error:ja||ds?.error||null,notice:Sa||ds?.notice||null,onClose:()=>{bn||(yn(!1),Ge(null),it(null))},onApplyImage:$a,onGenerateImage:g&&!is.has(g)?Ea:void 0,onRemoveImage:La},g||"agent-avatar-draft")]})]})}export{fl as TaskforceAgentsModule};
@@ -1 +0,0 @@
1
- ._toolAccess_2stgb_1,._skillSelector_2stgb_2,._effectiveSummary_2stgb_3{display:grid;gap:14px;min-width:0;padding:16px;border:1px solid var(--border-divider);border-radius:var(--radius-md);background:var(--surface-inset)}._sectionHeader_2stgb_13,._workspaceHeader_2stgb_14{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}._sectionHeader_2stgb_13>div,._workspaceHeader_2stgb_14>div{min-width:0}._sectionHeader_2stgb_13 p,._workspaceHeader_2stgb_14 p{margin-top:5px}._sectionHeader_2stgb_13>span,._titleLine_2stgb_32>span{flex:0 0 auto}._moduleGrid_2stgb_36{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}._moduleOption_2stgb_42,._unavailableCapability_2stgb_43{display:grid;grid-template-columns:auto auto minmax(0,1fr) auto;align-items:center;gap:9px;min-width:0;padding:10px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-panel)}._moduleOption_2stgb_42{cursor:pointer;transition:background-color var(--transition-base),border-color var(--transition-base)}._moduleOption_2stgb_42:hover{border-color:var(--border-strong)}._moduleOptionSelected_2stgb_66{border-color:var(--brand-primary-border);background:var(--surface-accent-soft)}._moduleOption_2stgb_42 input{margin:0;accent-color:var(--brand-primary)}._moduleIcon_2stgb_76,._selectedSkillIcon_2stgb_77,._provenanceIcon_2stgb_78{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-inset);color:var(--text-secondary)}._moduleCopy_2stgb_91,._moduleCopy_2stgb_91 strong,._moduleCopy_2stgb_91 small{display:block;min-width:0}._moduleCopy_2stgb_91 strong{color:var(--text-title);font-size:.8125rem}._moduleCopy_2stgb_91 small{margin-top:2px;color:var(--text-helper);font-size:.72rem;line-height:1.35}._futureGroups_2stgb_110{display:grid;gap:8px;padding-top:12px;border-top:1px solid var(--border-divider)}._unavailableCapability_2stgb_43{grid-template-columns:auto minmax(0,1fr) auto;opacity:.78}._unknownNotice_2stgb_122,._disabledExplanation_2stgb_123{display:flex;align-items:flex-start;gap:9px;padding:10px 12px;border:1px solid color-mix(in srgb,var(--status-warning) 28%,var(--border-default));border-radius:var(--radius-md);background:var(--status-warning-bg);color:var(--status-warning-text);font-size:.75rem;line-height:1.4}._unknownNotice_2stgb_122 svg,._disabledExplanation_2stgb_123 svg{flex:0 0 auto;margin-top:1px}._unknownNotice_2stgb_122>button{flex:0 0 auto;margin-left:auto}._catalogError_2stgb_147{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;border:1px solid var(--status-error);border-radius:var(--radius-md);background:var(--status-error-bg);color:var(--status-error-text);font-size:.75rem}._selectedSkills_2stgb_160{display:grid;gap:7px;margin:0;padding:0;list-style:none}._skillSearch_2stgb_168{position:relative;display:block}._skillSearch_2stgb_168>svg{position:absolute;z-index:1;top:50%;left:11px;color:var(--text-helper);pointer-events:none;transform:translateY(-50%)}._skillSearch_2stgb_168 input{width:100%;padding-left:34px}._skillResults_2stgb_188{display:grid;gap:7px;max-height:230px;overflow-y:auto}._skillResults_2stgb_188>button{appearance:none;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px;padding:9px 10px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-panel);color:inherit;text-align:left;cursor:pointer}._skillResults_2stgb_188>button:hover:not(:disabled){border-color:var(--border-strong);background:var(--surface-hover)}._skillResults_2stgb_188 strong,._skillResults_2stgb_188 small{display:block}._skillResults_2stgb_188 strong{color:var(--text-title);font-size:.8125rem}._skillResults_2stgb_188 small{margin-top:2px;overflow:hidden;color:var(--text-helper);font-size:.72rem;text-overflow:ellipsis;white-space:nowrap}._selectedSkills_2stgb_160 li{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:9px;padding:9px 10px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-panel)}._selectedSkills_2stgb_160 li>span:nth-child(2),._selectedSkills_2stgb_160 strong,._selectedSkills_2stgb_160 small{display:block;min-width:0}._selectedSkills_2stgb_160 strong{color:var(--text-title);font-size:.8125rem}._selectedSkills_2stgb_160 small{margin-top:2px;overflow:hidden;color:var(--text-helper);font-size:.72rem;text-overflow:ellipsis;white-space:nowrap}._emptySelection_2stgb_266{margin:0;padding:12px;border:1px dashed var(--border-default);border-radius:var(--radius-md);color:var(--text-helper);font-size:.75rem}._provenanceGrid_2stgb_275{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}._provenanceGrid_2stgb_275>div{display:flex;align-items:center;gap:9px;min-width:0;padding:10px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-panel)}._provenanceGrid_2stgb_275 small,._provenanceGrid_2stgb_275 strong{display:block}._provenanceGrid_2stgb_275 small{color:var(--text-helper);font-size:.68rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase}._provenanceGrid_2stgb_275 strong{margin-top:2px;color:var(--text-title);font-size:.78rem;line-height:1.35}._unavailableProvenance_2stgb_312{opacity:.72}._previewCaveat_2stgb_316{margin:0;color:var(--text-helper);font-size:.72rem;line-height:1.45}._librarySummary_2stgb_323{min-height:220px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:18px;color:var(--text-helper);text-align:center}._librarySummary_2stgb_323 strong{color:var(--text-secondary);font-size:.82rem}._librarySummary_2stgb_323>span:not([class]){max-width:26ch;font-size:.74rem;line-height:1.45}._workspacePanel_2stgb_346{display:grid;gap:22px;min-height:min(620px,72vh);padding:22px;border:1px solid var(--border-default);border-radius:var(--radius-lg);background:var(--surface-panel)}._futureAction_2stgb_356:disabled{border-color:var(--border-default);background:var(--surface-inset);color:var(--text-muted);box-shadow:none;cursor:not-allowed;opacity:1}._workspaceHeader_2stgb_14{display:grid;grid-template-columns:auto minmax(0,1fr) auto}._workspaceTitleIcon_2stgb_370,._previewCardIcon_2stgb_371{width:42px;height:42px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-inset);color:var(--text-secondary)}._titleLine_2stgb_32{display:flex;align-items:center;gap:9px}._relationshipFlow_2stgb_389{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;gap:18px;padding:12px;border:1px solid var(--border-divider);border-radius:var(--radius-md);background:var(--surface-inset)}._relationshipFlow_2stgb_389 span,._relationshipFlow_2stgb_389 strong{position:relative;min-width:0;color:var(--text-secondary);font-size:.75rem;text-align:center}._relationshipFlow_2stgb_389 strong{color:var(--brand-primary-strong)}._relationshipFlow_2stgb_389>*:not(:last-child):after{content:"→";position:absolute;right:-14px;color:var(--text-helper)}._previewCards_2stgb_420{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}._previewCard_2stgb_371{display:grid;align-content:start;gap:12px;min-width:0;padding:16px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-inset);opacity:.78}._previewCardAvailable_2stgb_438{background:var(--surface-panel);opacity:1}._previewCard_2stgb_371 p{margin-top:5px}._previewCard_2stgb_371>span{width:fit-content}._disabledExplanation_2stgb_123{margin-top:auto}._disabledExplanation_2stgb_123 div,._disabledExplanation_2stgb_123 strong,._disabledExplanation_2stgb_123 span{display:block}._disabledExplanation_2stgb_123 strong{color:var(--status-warning-text)}._disabledExplanation_2stgb_123 span{margin-top:2px;color:var(--text-secondary)}@container agent-behavior-manager (max-width: 620px){._moduleGrid_2stgb_36,._provenanceGrid_2stgb_275{grid-template-columns:1fr}}@media(max-width:760px){._sectionHeader_2stgb_13,._workspaceHeader_2stgb_14{grid-template-columns:1fr;flex-direction:column}._workspaceHeader_2stgb_14>button{width:100%}._relationshipFlow_2stgb_389{grid-template-columns:1fr;gap:7px}._relationshipFlow_2stgb_389>*:not(:last-child):after{content:"↓";position:static;display:block;margin-top:5px}._previewCards_2stgb_420{grid-template-columns:1fr}._unavailableCapability_2stgb_43,._selectedSkills_2stgb_160 li{grid-template-columns:auto minmax(0,1fr)}._unknownNotice_2stgb_122{flex-wrap:wrap}._unknownNotice_2stgb_122>button{width:100%;margin-left:23px}._unavailableCapability_2stgb_43>span:last-child,._selectedSkills_2stgb_160 button{grid-column:2;justify-self:start}}._root_kwk43_1{display:grid;grid-template-columns:minmax(230px,280px) minmax(0,1fr);width:100%;min-height:0;height:100%;color:var(--text-body);background:var(--surface-page)}._rootExternalLibrary_kwk43_11{grid-template-columns:minmax(0,1fr)}._library_kwk43_15{display:flex;min-width:0;flex-direction:column;gap:12px;padding:16px 12px;border-right:1px solid var(--border-divider);background:var(--surface-panel);overflow-y:auto}._libraryExternal_kwk43_26{width:100%;height:100%;padding:12px 0 16px;border-right:0;background:transparent;overflow:hidden}._libraryExternal_kwk43_26>button{width:100%}._libraryHeader_kwk43_39{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}._libraryHeader_kwk43_39 p{margin-top:3px}._search_kwk43_50{display:flex;align-items:center;gap:7px;min-height:34px;padding:0 9px;border:1px solid var(--field-border);border-radius:var(--radius-md);color:var(--text-helper);background:var(--field-bg)}._search_kwk43_50:focus-within{border-color:var(--field-focus-border);box-shadow:0 0 0 3px var(--field-focus-ring)}._search_kwk43_50 input{min-width:0;width:100%;border:0;outline:0;color:var(--field-text);background:transparent;font:inherit;font-size:.8125rem}._retiredToggle_kwk43_78{display:inline-flex;align-items:center;gap:6px;color:var(--text-secondary);font-size:.75rem}._libraryList_kwk43_86{display:flex;min-height:0;flex:1;flex-direction:column;gap:7px;overflow-y:auto}._libraryState_kwk43_95{display:flex;min-height:96px;align-items:center;justify-content:center;gap:8px;padding:16px;color:var(--text-helper);text-align:center;font-size:.8125rem}._libraryError_kwk43_107{flex-direction:column;color:var(--status-error-text)}._libraryStateIcon_kwk43_112{display:inline-flex;color:var(--brand-primary)}._libraryCard_kwk43_117{display:grid;grid-template-columns:30px minmax(0,1fr) auto;align-items:center;gap:8px;width:100%;min-width:0;padding:10px;border:1px solid var(--agent-card-border);border-radius:var(--radius-md);color:var(--text-body);text-align:left;background:var(--agent-card-bg);box-shadow:var(--agent-card-shadow);cursor:pointer}._libraryCard_kwk43_117:hover{border-color:var(--agent-card-hover-border);background:var(--agent-card-hover-bg)}._libraryCardSelected_kwk43_139{border-color:var(--agent-card-selected-border);background:var(--agent-card-selected-bg);box-shadow:var(--agent-card-selected-shadow)}._libraryCardIcon_kwk43_145{display:inline-flex;width:30px;height:30px;align-items:center;justify-content:center;border-radius:var(--radius-md);color:var(--brand-primary);background:var(--brand-primary-soft)}._libraryCardBody_kwk43_156{display:flex;min-width:0;flex-direction:column;gap:3px}._libraryCardBody_kwk43_156 strong,._libraryCardBody_kwk43_156 span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._libraryCardBody_kwk43_156 strong{color:var(--text-title);font-size:.8125rem}._libraryCardBody_kwk43_156 span{color:var(--text-helper);font-size:.72rem}._editor_kwk43_180{min-width:0;overflow-y:auto;container-name:agent-behavior-manager;container-type:inline-size}._editorHeader_kwk43_187{position:sticky;top:0;z-index:3;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:18px clamp(18px,3vw,32px);border-bottom:1px solid var(--border-divider);background:color-mix(in srgb,var(--surface-page) 94%,transparent);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}._editorTitle_kwk43_201{display:flex;min-width:0;align-items:flex-start;gap:10px;color:var(--brand-primary)}._editorTitle_kwk43_201>div{min-width:0}._editorTitleLine_kwk43_213{display:flex;align-items:center;flex-wrap:wrap;gap:8px}._editorTitleLine_kwk43_213 h2{color:var(--text-title)}._editorTitle_kwk43_201 p{margin-top:5px}._headerActions_kwk43_228{display:flex;flex:0 0 auto;align-items:center;gap:8px}._feedbackError_kwk43_235,._feedbackSuccess_kwk43_236,._confirmation_kwk43_237{margin:16px clamp(18px,3vw,32px) 0;padding:10px 12px;border-radius:var(--radius-md);font-size:.8125rem}._feedbackError_kwk43_235,._feedbackSuccess_kwk43_236{display:flex;align-items:center;gap:7px}._feedbackError_kwk43_235{border:1px solid color-mix(in srgb,var(--status-error) 35%,transparent);color:var(--status-error-text);background:var(--status-error-bg)}._feedbackSuccess_kwk43_236{border:1px solid color-mix(in srgb,var(--status-success) 35%,transparent);color:var(--status-success-text);background:var(--status-success-bg)}._fieldError_kwk43_263{color:var(--status-error-text);font-size:.72rem;line-height:1.4}._confirmation_kwk43_237{display:flex;align-items:center;gap:12px;border:1px solid color-mix(in srgb,var(--status-warning) 40%,var(--border-default));background:var(--status-warning-bg)}._confirmation_kwk43_237>div{display:flex;flex:1;flex-direction:column;gap:3px}._confirmation_kwk43_237 span{color:var(--text-secondary)}._empty_kwk43_288{min-height:420px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:32px}._emptyIcon_kwk43_298{width:48px;height:48px;display:grid;place-items:center;border:1px solid var(--brand-primary-border);border-radius:var(--radius-full);color:var(--brand-primary);background:var(--brand-primary-soft)}._editorGrid_kwk43_309{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(280px,.78fr);gap:20px;width:min(100%,1040px);margin:0 auto;padding:8px clamp(18px,3vw,32px) 48px;align-items:start}._formColumn_kwk43_319{display:flex;min-width:0;flex-direction:column}._previewColumn_kwk43_325{position:sticky;top:92px;min-width:0;margin-top:20px;padding:16px;border:1px solid var(--border-divider);border-radius:var(--radius-md);background:var(--surface-inset)}._previewHeader_kwk43_336{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}._previewHeader_kwk43_336 h3{margin-top:4px}._previewNote_kwk43_347{margin:12px 0 0;color:var(--text-helper);font-size:.75rem;line-height:1.5}._preview_kwk43_325{max-height:460px;min-height:120px;margin:14px 0 0;padding:14px;overflow:auto;border:1px solid var(--code-block-border);border-radius:var(--radius-md);color:var(--code-block-text);background:var(--code-block-bg);font-size:.75rem;line-height:1.55}._previewEmpty_kwk43_368{display:flex;min-height:96px;align-items:center;justify-content:center;margin-top:14px;padding:16px;border:1px dashed var(--border-default);border-radius:var(--radius-md);color:var(--text-helper);text-align:center;font-size:.8125rem}._metrics_kwk43_382{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:14px}._metrics_kwk43_382>div{display:flex;flex-direction:column;gap:4px;padding:10px;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-page)}._metrics_kwk43_382 span,._lifecycleAction_kwk43_400 span{color:var(--text-helper);font-size:.72rem}._metrics_kwk43_382 strong{color:var(--text-title);font-size:.8125rem}._history_kwk43_410{margin-top:14px;color:var(--text-secondary);font-size:.75rem}._history_kwk43_410 summary{display:inline-flex;align-items:center;gap:5px;cursor:pointer;font-weight:600}._history_kwk43_410 ol{display:flex;flex-direction:column;gap:8px;margin:10px 0 0;padding:0;list-style:none}._history_kwk43_410 li{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:8px;align-items:center}._history_kwk43_410 li span,._history_kwk43_410 code{color:var(--text-helper)}._history_kwk43_410 code{font-size:.625rem}._lifecycleAction_kwk43_400{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:14px;padding-top:14px;border-top:1px solid var(--border-divider)}._lifecycleAction_kwk43_400>div{display:flex;flex-direction:column;gap:3px}._spinner_kwk43_465{animation:_behavior-manager-spin_kwk43_1 .9s linear infinite}._visuallyHidden_kwk43_469{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@keyframes _behavior-manager-spin_kwk43_1{to{transform:rotate(360deg)}}@container agent-behavior-manager (max-width: 680px){._editorGrid_kwk43_309{grid-template-columns:1fr}._previewColumn_kwk43_325{position:static;margin-top:0}}@container agent-behavior-manager (max-width: 620px){._editorHeader_kwk43_187,._confirmation_kwk43_237,._lifecycleAction_kwk43_400{align-items:stretch;flex-direction:column}._headerActions_kwk43_228{width:100%}._headerActions_kwk43_228>button{flex:1}}@container agent-behavior-manager (max-width: 480px){._metrics_kwk43_382{grid-template-columns:1fr}._history_kwk43_410 li{grid-template-columns:1fr auto}._history_kwk43_410 li span{grid-column:1 / -1;grid-row:2}}@media(max-width:760px){._root_kwk43_1{display:block;height:auto}._library_kwk43_15{max-height:280px;border-right:0;border-bottom:1px solid var(--border-divider)}._libraryExternal_kwk43_26{max-height:none;border-bottom:0}._editor_kwk43_180{overflow:visible}._editorHeader_kwk43_187{position:static}}._formSection_dyv9a_1{display:flex;flex-direction:column;gap:16px;padding:20px 0;border-bottom:1px solid var(--border-divider)}._sectionHeader_dyv9a_9 p{margin-top:5px}._fieldGrid_dyv9a_13{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}._formSection_dyv9a_1 textarea{resize:vertical}._formSection_dyv9a_1 [aria-invalid=true]{border-color:var(--status-error)}._configurationPreview_dyv9a_27{display:grid;gap:12px;padding-top:20px}._resourcesPreview_dyv9a_33{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:12px;padding:16px;border:1px solid var(--border-divider);border-radius:var(--radius-md);background:var(--surface-inset);opacity:.78}._resourcesPreview_dyv9a_33 p{margin-top:5px}._previewCode_dyv9a_49{font-family:var(--font-mono);white-space:pre-wrap}@container agent-behavior-manager (max-width: 620px){._fieldGrid_dyv9a_13,._resourcesPreview_dyv9a_33{grid-template-columns:1fr}._resourcesPreview_dyv9a_33>span,._resourcesPreview_dyv9a_33>button{justify-self:start}}._assignments_omv6h_1{display:grid;grid-column:1 / -1;gap:14px;min-width:0}._section_omv6h_8{min-width:0;border:1px solid var(--border-default);border-radius:var(--radius-md);background:var(--surface-panel);padding:12px}._sectionHeader_omv6h_16{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px}._sectionHeading_omv6h_24{display:flex;gap:9px;min-width:0}._sectionHeading_omv6h_24 svg{flex:0 0 auto;margin-top:2px;color:var(--text-helper)}._sectionHeading_omv6h_24 strong,._sectionHeading_omv6h_24 small{display:block}._sectionHeading_omv6h_24 strong{color:var(--text-title);font-size:14px;line-height:1.3}._sectionHeading_omv6h_24 small,._referenceCopy_omv6h_48 small,._empty_omv6h_49{color:var(--text-helper);font-size:12px;line-height:1.4}._sectionHeader_omv6h_16>button{flex:0 0 auto;align-self:center;white-space:nowrap}._roleControls_omv6h_61,._skillAdd_omv6h_62{display:grid;grid-template-columns:minmax(180px,1fr) minmax(120px,160px) minmax(110px,140px);gap:10px}._roleControls_omv6h_61>*,._skillAdd_omv6h_62>*{min-width:0}._skillAdd_omv6h_62{grid-template-columns:minmax(180px,1fr) auto;align-items:end;margin-bottom:10px}._skillAdd_omv6h_62>button{justify-self:end}._referenceList_omv6h_83{display:grid;gap:8px;margin:0;padding:0;list-style:none}._referenceRow_omv6h_91{display:grid;grid-template-columns:minmax(160px,1fr) minmax(105px,140px) minmax(95px,125px) auto;align-items:center;gap:8px;border:1px solid var(--border-default);border-radius:var(--radius-md);padding:9px 10px;background:var(--surface-inset)}._referenceCopy_omv6h_48{min-width:0}._referenceCopy_omv6h_48 strong,._referenceCopy_omv6h_48 small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._rowActions_omv6h_114{display:flex;gap:4px}._issue_omv6h_119{display:flex;align-items:flex-start;gap:7px;margin-top:10px;color:var(--color-warning);font-size:12px}._issue_omv6h_119 svg{flex:0 0 auto;margin-top:1px}._loadError_omv6h_133{color:var(--status-error-text);font-size:12px}@media(max-width:860px){._roleControls_omv6h_61,._referenceRow_omv6h_91{grid-template-columns:1fr}._rowActions_omv6h_114{justify-content:flex-end}}@media(max-width:560px){._skillAdd_omv6h_62{grid-template-columns:1fr}._sectionHeader_omv6h_16{flex-direction:column;align-items:stretch}._sectionHeader_omv6h_16>button{width:100%}}._section_1e1mf_1{display:flex;flex-direction:column;gap:16px;padding:20px 0;border-bottom:1px solid var(--border-divider)}._sectionHeading_1e1mf_9{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}._sectionHeading_1e1mf_9 p{margin-top:5px}._twoColumn_1e1mf_20{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}._instructions_1e1mf_26{min-height:180px;resize:vertical;font-family:var(--font-mono)}._section_1e1mf_1 [aria-invalid=true]{border-color:var(--status-error)}._orderedList_1e1mf_36{display:flex;flex-direction:column;gap:6px}._orderedRow_1e1mf_42{display:grid;grid-template-columns:24px minmax(0,1fr) auto;align-items:center;gap:7px}._orderedInput_1e1mf_49{display:flex;min-width:0;flex-direction:column;gap:4px}._orderNumber_1e1mf_56{color:var(--text-helper);text-align:center;font-size:.72rem;font-family:var(--font-mono)}._orderActions_1e1mf_63{display:flex;align-items:center;gap:2px}._listEmpty_1e1mf_69{padding:10px;border:1px dashed var(--border-default);border-radius:var(--radius-md);color:var(--text-helper);font-size:.75rem}@container agent-behavior-manager (max-width: 620px){._sectionHeading_1e1mf_9{align-items:stretch;flex-direction:column}._twoColumn_1e1mf_20{grid-template-columns:1fr}._orderedRow_1e1mf_42{grid-template-columns:20px minmax(0,1fr)}._orderActions_1e1mf_63{grid-column:2;justify-content:flex-end}}