@memberjunction/server 6.2.0-edge.5 → 6.2.0-edge.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/agentSessions/SessionJanitor.d.ts +3 -3
- package/dist/agentSessions/SessionJanitor.js +3 -3
- package/dist/agentSessions/SessionManager.d.ts +15 -5
- package/dist/agentSessions/SessionManager.d.ts.map +1 -1
- package/dist/agentSessions/SessionManager.js +34 -12
- package/dist/agentSessions/SessionManager.js.map +1 -1
- package/dist/auth/AuthProviderCatalogRouter.d.ts.map +1 -1
- package/dist/auth/AuthProviderCatalogRouter.js +2 -0
- package/dist/auth/AuthProviderCatalogRouter.js.map +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +51 -10
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/initializeProviders.d.ts +10 -0
- package/dist/auth/initializeProviders.d.ts.map +1 -1
- package/dist/auth/initializeProviders.js +37 -1
- package/dist/auth/initializeProviders.js.map +1 -1
- package/dist/auth/localDevAuth.d.ts +79 -0
- package/dist/auth/localDevAuth.d.ts.map +1 -0
- package/dist/auth/localDevAuth.js +439 -0
- package/dist/auth/localDevAuth.js.map +1 -0
- package/dist/auth/magicLink/MagicLinkKeys.d.ts +2 -2
- package/dist/auth/magicLink/MagicLinkKeys.d.ts.map +1 -1
- package/dist/auth/magicLink/MagicLinkKeys.js +1 -1
- package/dist/auth/magicLink/MagicLinkKeys.js.map +1 -1
- package/dist/auth/magicLink/types.d.ts +12 -0
- package/dist/auth/magicLink/types.d.ts.map +1 -1
- package/dist/auth/sessionUserClone.d.ts +1 -1
- package/dist/auth/sessionUserClone.d.ts.map +1 -1
- package/dist/auth/sessionUserClone.js +3 -2
- package/dist/auth/sessionUserClone.js.map +1 -1
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.d.ts +292 -0
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.js +442 -0
- package/dist/broadcast/BaseCacheInvalidationBroadcastProvider.js.map +1 -0
- package/dist/broadcast/index.d.ts +6 -0
- package/dist/broadcast/index.d.ts.map +1 -0
- package/dist/broadcast/index.js +6 -0
- package/dist/broadcast/index.js.map +1 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.d.ts +43 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.js +144 -0
- package/dist/broadcast/providers/AWSIoTCoreBroadcastProvider.js.map +1 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.d.ts +46 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.js +149 -0
- package/dist/broadcast/providers/AzureWebPubSubBroadcastProvider.js.map +1 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.d.ts +49 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.js +131 -0
- package/dist/broadcast/providers/GCPPubSubBroadcastProvider.js.map +1 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.d.ts +24 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.d.ts.map +1 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.js +51 -0
- package/dist/broadcast/providers/SequencedRoleBucketBroadcastProvider.js.map +1 -0
- package/dist/cache.d.ts +3 -2
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/config.d.ts +496 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +3 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +29 -8
- package/dist/context.js.map +1 -1
- package/dist/coreRoutes.d.ts.map +1 -1
- package/dist/coreRoutes.js +14 -0
- package/dist/coreRoutes.js.map +1 -1
- package/dist/generated/graphql-schemas/__mj.d.ts +635 -14
- package/dist/generated/graphql-schemas/__mj.d.ts.map +1 -1
- package/dist/generated/graphql-schemas/__mj.js +3366 -418
- package/dist/generated/graphql-schemas/__mj.js.map +1 -1
- package/dist/generic/CacheInvalidationResolver.d.ts +50 -30
- package/dist/generic/CacheInvalidationResolver.d.ts.map +1 -1
- package/dist/generic/CacheInvalidationResolver.js +154 -79
- package/dist/generic/CacheInvalidationResolver.js.map +1 -1
- package/dist/generic/OrphanedConversationDetailReconciler.d.ts.map +1 -1
- package/dist/generic/OrphanedConversationDetailReconciler.js +2 -0
- package/dist/generic/OrphanedConversationDetailReconciler.js.map +1 -1
- package/dist/generic/PubSubManager.d.ts +10 -0
- package/dist/generic/PubSubManager.d.ts.map +1 -1
- package/dist/generic/PubSubManager.js +44 -1
- package/dist/generic/PubSubManager.js.map +1 -1
- package/dist/generic/PushStatusResolver.d.ts +39 -6
- package/dist/generic/PushStatusResolver.d.ts.map +1 -1
- package/dist/generic/PushStatusResolver.js +93 -11
- package/dist/generic/PushStatusResolver.js.map +1 -1
- package/dist/generic/ResolverBase.d.ts +65 -25
- package/dist/generic/ResolverBase.d.ts.map +1 -1
- package/dist/generic/ResolverBase.js +201 -101
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/generic/RunViewResolver.d.ts +11 -3
- package/dist/generic/RunViewResolver.d.ts.map +1 -1
- package/dist/generic/RunViewResolver.js +79 -13
- package/dist/generic/RunViewResolver.js.map +1 -1
- package/dist/generic/actionOutputFieldSecurity.d.ts +26 -0
- package/dist/generic/actionOutputFieldSecurity.d.ts.map +1 -0
- package/dist/generic/actionOutputFieldSecurity.js +47 -0
- package/dist/generic/actionOutputFieldSecurity.js.map +1 -0
- package/dist/generic/fieldSecurityTransport.d.ts +30 -0
- package/dist/generic/fieldSecurityTransport.d.ts.map +1 -0
- package/dist/generic/fieldSecurityTransport.js +30 -0
- package/dist/generic/fieldSecurityTransport.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -66
- package/dist/index.js.map +1 -1
- package/dist/integration/CustomColumnPromoter.d.ts.map +1 -1
- package/dist/integration/CustomColumnPromoter.js +6 -1
- package/dist/integration/CustomColumnPromoter.js.map +1 -1
- package/dist/logging/variablesLoggingMiddleware.d.ts +12 -0
- package/dist/logging/variablesLoggingMiddleware.d.ts.map +1 -1
- package/dist/logging/variablesLoggingMiddleware.js +50 -1
- package/dist/logging/variablesLoggingMiddleware.js.map +1 -1
- package/dist/realtimeSessions/SessionVerificationPortsBase.d.ts.map +1 -1
- package/dist/realtimeSessions/SessionVerificationPortsBase.js +1 -0
- package/dist/realtimeSessions/SessionVerificationPortsBase.js.map +1 -1
- package/dist/realtimeSessions/ownedRealtimeSession.d.ts +8 -6
- package/dist/realtimeSessions/ownedRealtimeSession.d.ts.map +1 -1
- package/dist/realtimeSessions/ownedRealtimeSession.js +15 -6
- package/dist/realtimeSessions/ownedRealtimeSession.js.map +1 -1
- package/dist/realtimeSessions/sessionAccess.d.ts +88 -11
- package/dist/realtimeSessions/sessionAccess.d.ts.map +1 -1
- package/dist/realtimeSessions/sessionAccess.js +125 -22
- package/dist/realtimeSessions/sessionAccess.js.map +1 -1
- package/dist/realtimeSessions/sessionConfigStamps.js +1 -1
- package/dist/realtimeSessions/sessionConfigStamps.js.map +1 -1
- package/dist/realtimeSessions/subscriptionAuthorization.d.ts.map +1 -1
- package/dist/realtimeSessions/subscriptionAuthorization.js +5 -2
- package/dist/realtimeSessions/subscriptionAuthorization.js.map +1 -1
- package/dist/realtimeSessions/verificationWorkflow.d.ts +2 -0
- package/dist/realtimeSessions/verificationWorkflow.d.ts.map +1 -1
- package/dist/realtimeSessions/verificationWorkflow.js +1 -1
- package/dist/realtimeSessions/verificationWorkflow.js.map +1 -1
- package/dist/realtimeWidget/WidgetRouter.d.ts.map +1 -1
- package/dist/realtimeWidget/WidgetRouter.js +19 -3
- package/dist/realtimeWidget/WidgetRouter.js.map +1 -1
- package/dist/realtimeWidget/WidgetSessionService.d.ts +67 -7
- package/dist/realtimeWidget/WidgetSessionService.d.ts.map +1 -1
- package/dist/realtimeWidget/WidgetSessionService.js +201 -19
- package/dist/realtimeWidget/WidgetSessionService.js.map +1 -1
- package/dist/realtimeWidget/host-identity.d.ts +1 -1
- package/dist/realtimeWidget/host-identity.js +1 -1
- package/dist/realtimeWidget/widgetCore.d.ts +20 -1
- package/dist/realtimeWidget/widgetCore.d.ts.map +1 -1
- package/dist/realtimeWidget/widgetCore.js +17 -1
- package/dist/realtimeWidget/widgetCore.js.map +1 -1
- package/dist/realtimeWidget/widgetGuestElevation.d.ts +1 -1
- package/dist/realtimeWidget/widgetGuestElevation.d.ts.map +1 -1
- package/dist/realtimeWidget/widgetGuestElevation.js +2 -1
- package/dist/realtimeWidget/widgetGuestElevation.js.map +1 -1
- package/dist/resolvers/ActionResolver.d.ts +19 -1
- package/dist/resolvers/ActionResolver.d.ts.map +1 -1
- package/dist/resolvers/ActionResolver.js +63 -12
- package/dist/resolvers/ActionResolver.js.map +1 -1
- package/dist/resolvers/AdhocQueryResolver.d.ts.map +1 -1
- package/dist/resolvers/AdhocQueryResolver.js +1 -0
- package/dist/resolvers/AdhocQueryResolver.js.map +1 -1
- package/dist/resolvers/AgentRunStatusPublisher.d.ts +18 -4
- package/dist/resolvers/AgentRunStatusPublisher.d.ts.map +1 -1
- package/dist/resolvers/AgentRunStatusPublisher.js +32 -8
- package/dist/resolvers/AgentRunStatusPublisher.js.map +1 -1
- package/dist/resolvers/AgentSessionResolver.d.ts +10 -4
- package/dist/resolvers/AgentSessionResolver.d.ts.map +1 -1
- package/dist/resolvers/AgentSessionResolver.js +40 -17
- package/dist/resolvers/AgentSessionResolver.js.map +1 -1
- package/dist/resolvers/EntityCommunicationsResolver.d.ts +13 -1
- package/dist/resolvers/EntityCommunicationsResolver.d.ts.map +1 -1
- package/dist/resolvers/EntityCommunicationsResolver.js +50 -14
- package/dist/resolvers/EntityCommunicationsResolver.js.map +1 -1
- package/dist/resolvers/FetchEntityVectorsResolver.d.ts +28 -0
- package/dist/resolvers/FetchEntityVectorsResolver.d.ts.map +1 -1
- package/dist/resolvers/FetchEntityVectorsResolver.js +117 -21
- package/dist/resolvers/FetchEntityVectorsResolver.js.map +1 -1
- package/dist/resolvers/FileCategoryResolver.d.ts.map +1 -1
- package/dist/resolvers/FileCategoryResolver.js +1 -0
- package/dist/resolvers/FileCategoryResolver.js.map +1 -1
- package/dist/resolvers/FileResolver.d.ts +5 -0
- package/dist/resolvers/FileResolver.d.ts.map +1 -1
- package/dist/resolvers/FileResolver.js +13 -4
- package/dist/resolvers/FileResolver.js.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.js +45 -7
- package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
- package/dist/resolvers/MergeRecordsResolver.d.ts +8 -1
- package/dist/resolvers/MergeRecordsResolver.d.ts.map +1 -1
- package/dist/resolvers/MergeRecordsResolver.js +31 -3
- package/dist/resolvers/MergeRecordsResolver.js.map +1 -1
- package/dist/resolvers/PipelineProgressResolver.d.ts +6 -0
- package/dist/resolvers/PipelineProgressResolver.d.ts.map +1 -1
- package/dist/resolvers/PipelineProgressResolver.js +5 -3
- package/dist/resolvers/PipelineProgressResolver.js.map +1 -1
- package/dist/resolvers/QueryResolver.d.ts.map +1 -1
- package/dist/resolvers/QueryResolver.js +20 -6
- package/dist/resolvers/QueryResolver.js.map +1 -1
- package/dist/resolvers/QuerySystemUserResolver.d.ts +2 -0
- package/dist/resolvers/QuerySystemUserResolver.d.ts.map +1 -1
- package/dist/resolvers/QuerySystemUserResolver.js +15 -6
- package/dist/resolvers/QuerySystemUserResolver.js.map +1 -1
- package/dist/resolvers/RSUResolver.d.ts.map +1 -1
- package/dist/resolvers/RSUResolver.js +12 -0
- package/dist/resolvers/RSUResolver.js.map +1 -1
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts +16 -2
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -1
- package/dist/resolvers/RealtimeClientSessionResolver.js +82 -28
- package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -1
- package/dist/resolvers/RemoteBrowserActionResolver.d.ts.map +1 -1
- package/dist/resolvers/RemoteBrowserActionResolver.js +11 -9
- package/dist/resolvers/RemoteBrowserActionResolver.js.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.d.ts +56 -8
- package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.js +209 -64
- package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
- package/dist/resolvers/RunTemplateResolver.d.ts.map +1 -1
- package/dist/resolvers/RunTemplateResolver.js +4 -4
- package/dist/resolvers/RunTemplateResolver.js.map +1 -1
- package/dist/resolvers/RunTestResolver.d.ts.map +1 -1
- package/dist/resolvers/RunTestResolver.js +3 -1
- package/dist/resolvers/RunTestResolver.js.map +1 -1
- package/dist/resolvers/SyncDataResolver.d.ts.map +1 -1
- package/dist/resolvers/SyncDataResolver.js +4 -0
- package/dist/resolvers/SyncDataResolver.js.map +1 -1
- package/dist/resolvers/TestQuerySQLResolver.d.ts.map +1 -1
- package/dist/resolvers/TestQuerySQLResolver.js +1 -0
- package/dist/resolvers/TestQuerySQLResolver.js.map +1 -1
- package/dist/resolvers/TransactionGroupResolver.d.ts +17 -2
- package/dist/resolvers/TransactionGroupResolver.d.ts.map +1 -1
- package/dist/resolvers/TransactionGroupResolver.js +60 -15
- package/dist/resolvers/TransactionGroupResolver.js.map +1 -1
- package/dist/resolvers/UserViewResolver.d.ts +1 -1
- package/dist/resolvers/UserViewResolver.d.ts.map +1 -1
- package/dist/resolvers/UserViewResolver.js +2 -1
- package/dist/resolvers/UserViewResolver.js.map +1 -1
- package/dist/rest/EntityCRUDHandler.d.ts +6 -0
- package/dist/rest/EntityCRUDHandler.d.ts.map +1 -1
- package/dist/rest/EntityCRUDHandler.js +19 -5
- package/dist/rest/EntityCRUDHandler.js.map +1 -1
- package/dist/rest/RESTEndpointHandler.d.ts.map +1 -1
- package/dist/rest/RESTEndpointHandler.js +8 -5
- package/dist/rest/RESTEndpointHandler.js.map +1 -1
- package/dist/rest/RealtimeRecordingHandler.d.ts +3 -3
- package/dist/rest/RealtimeRecordingHandler.d.ts.map +1 -1
- package/dist/rest/RealtimeRecordingHandler.js +7 -7
- package/dist/rest/RealtimeRecordingHandler.js.map +1 -1
- package/dist/rest/ViewOperationsHandler.d.ts +6 -0
- package/dist/rest/ViewOperationsHandler.d.ts.map +1 -1
- package/dist/rest/ViewOperationsHandler.js +22 -5
- package/dist/rest/ViewOperationsHandler.js.map +1 -1
- package/dist/serverRoleConfigUnits.d.ts +29 -0
- package/dist/serverRoleConfigUnits.d.ts.map +1 -0
- package/dist/serverRoleConfigUnits.js +33 -0
- package/dist/serverRoleConfigUnits.js.map +1 -0
- package/dist/services/TaskGraphContinuationDeliverer.d.ts +5 -0
- package/dist/services/TaskGraphContinuationDeliverer.d.ts.map +1 -1
- package/dist/services/TaskGraphContinuationDeliverer.js +42 -15
- package/dist/services/TaskGraphContinuationDeliverer.js.map +1 -1
- package/dist/types.d.ts +23 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +98 -98
- package/src/__tests__/ActionResolver.fieldSecurity.test.ts +237 -0
- package/src/__tests__/AdhocQueryResolver.dialect.test.ts +137 -0
- package/src/__tests__/AgentRunStatusPublisher.test.ts +49 -0
- package/src/__tests__/AgentSessionResolver.ownership.test.ts +137 -0
- package/src/__tests__/CustomColumnPromoterOnePass.test.ts +15 -1
- package/src/__tests__/EntityCommunicationsResolver.actingUser.test.ts +151 -0
- package/src/__tests__/EvolutionActsOnWhatItDetects.test.ts +113 -0
- package/src/__tests__/FetchEntityVectorsResolver.test.ts +206 -3
- package/src/__tests__/FileResolver.fieldSecurity.test.ts +82 -0
- package/src/__tests__/PipelineProgressResolver.filter.test.ts +58 -0
- package/src/__tests__/QuerySystemUserResolver.fieldSecurity.test.ts +49 -0
- package/src/__tests__/RESTEndpointHandler.test.ts +25 -0
- package/src/__tests__/RealtimeClientSessionResolver.configTamper.test.ts +23 -3
- package/src/__tests__/RealtimeClientSessionResolver.test.ts +324 -46
- package/src/__tests__/RemoteBrowserActionResolver.ownership.test.ts +98 -0
- package/src/__tests__/ResolverBase.clientOldValues.test.ts +37 -4
- package/src/__tests__/ResolverBase.deleteReturnProjection.test.ts +52 -0
- package/src/__tests__/ResolverBase.entityMessageRelay.test.ts +176 -0
- package/src/__tests__/ResolverBase.includeBinaryFields.test.ts +23 -1
- package/src/__tests__/ResolverBase.publishStatusUpdate.test.ts +68 -0
- package/src/__tests__/ResolverBase.userViewCacheAndDedup.test.ts +130 -0
- package/src/__tests__/RunAIAgentResolver.branch.test.ts +68 -13
- package/src/__tests__/RunAIAgentResolver.conversationWriter.test.ts +210 -0
- package/src/__tests__/RunAIAgentResolver.fireAndForgetCompletion.test.ts +209 -0
- package/src/__tests__/RunAIAgentResolver.historyFrom.test.ts +17 -27
- package/src/__tests__/RunAIAgentResolver.runDataGuard.test.ts +8 -2
- package/src/__tests__/RunAIAgentResolver.serverReply.test.ts +358 -0
- package/src/__tests__/RunAIAgentResolver.stoppedPredecessor.test.ts +4 -1
- package/src/__tests__/RunTemplateResolver.test.ts +35 -2
- package/src/__tests__/RunViewResolver.cacheCheckForwarding.test.ts +11 -0
- package/src/__tests__/SessionManager.test.ts +95 -0
- package/src/__tests__/TaskGraphContinuationDeliverer.test.ts +114 -3
- package/src/__tests__/TransactionGroupResolver.fieldSecurity.test.ts +199 -0
- package/src/__tests__/UserViewResolver.updateWhereClause.test.ts +15 -0
- package/src/__tests__/ViewOperationsHandler.test.ts +7 -2
- package/src/__tests__/WidgetSessionService.test.ts +583 -4
- package/src/__tests__/apiRootBoot.test.ts +1 -1
- package/src/__tests__/buildMagicLinkSessionUser.test.ts +96 -0
- package/src/__tests__/cacheBroadcastProviders.test.ts +403 -0
- package/src/__tests__/cacheInvalidationRecordData.test.ts +45 -0
- package/src/__tests__/fieldSecurityFixtures.ts +91 -0
- package/src/__tests__/globalCors.test.ts +3 -3
- package/src/__tests__/localDevAuth.test.ts +196 -0
- package/src/__tests__/orphanedConversationDetailReconciler.test.ts +10 -0
- package/src/__tests__/pushStatusResolver.filter.test.ts +57 -1
- package/src/__tests__/realtimeRecordingHandler.test.ts +19 -2
- package/src/__tests__/realtimeSessions/RealtimeSessionEventsResolver.test.ts +29 -1
- package/src/__tests__/realtimeSessions/ownedRealtimeSession.anonymous.test.ts +31 -0
- package/src/__tests__/realtimeSessions/ownedRealtimeSession.namedScoped.test.ts +37 -0
- package/src/__tests__/realtimeSessions/sessionAccess.test.ts +146 -7
- package/src/__tests__/realtimeSessions/sessionConfigStamps.test.ts +1 -1
- package/src/__tests__/realtimeSessions/verificationWorkflow.test.ts +25 -4
- package/src/__tests__/resolverBase.cloudEventChangedFields.test.ts +157 -0
- package/src/__tests__/resolverBase.fieldSecurityTransport.test.ts +222 -0
- package/src/__tests__/resolverBase.fls.test.ts +146 -97
- package/src/__tests__/restTransport.fieldSecurity.test.ts +148 -0
- package/src/__tests__/runParamsTimeZone.test.ts +179 -0
- package/src/__tests__/runStreams.fieldSecurity.test.ts +100 -0
- package/src/__tests__/runViewProperties.test.ts +114 -0
- package/src/__tests__/scalabilityBenchmarks.test.ts +765 -0
- package/src/__tests__/scalabilityDatabaseIntegration.test.ts +207 -0
- package/src/__tests__/sessionUserClone.test.ts +5 -1
- package/src/__tests__/startupSweepOrder.test.ts +40 -0
- package/src/__tests__/unifiedAuth.test.ts +28 -0
- package/src/__tests__/widgetGuestElevation.test.ts +2 -0
- package/src/agentSessions/SessionJanitor.ts +3 -3
- package/src/agentSessions/SessionManager.ts +35 -12
- package/src/auth/AuthProviderCatalogRouter.ts +3 -0
- package/src/auth/index.ts +56 -12
- package/src/auth/initializeProviders.ts +43 -1
- package/src/auth/localDevAuth.ts +528 -0
- package/src/auth/magicLink/MagicLinkKeys.ts +2 -2
- package/src/auth/magicLink/types.ts +10 -0
- package/src/auth/sessionUserClone.ts +3 -2
- package/src/broadcast/BaseCacheInvalidationBroadcastProvider.ts +674 -0
- package/src/broadcast/index.ts +5 -0
- package/src/broadcast/providers/AWSIoTCoreBroadcastProvider.ts +180 -0
- package/src/broadcast/providers/AzureWebPubSubBroadcastProvider.ts +182 -0
- package/src/broadcast/providers/GCPPubSubBroadcastProvider.ts +169 -0
- package/src/broadcast/providers/SequencedRoleBucketBroadcastProvider.ts +57 -0
- package/src/cache.ts +2 -1
- package/src/config.ts +69 -0
- package/src/context.ts +32 -8
- package/src/coreRoutes.ts +15 -0
- package/src/generated/graphql-schemas/__mj.ts +2239 -102
- package/src/generic/CacheInvalidationResolver.ts +135 -78
- package/src/generic/OrphanedConversationDetailReconciler.ts +4 -2
- package/src/generic/PubSubManager.ts +54 -1
- package/src/generic/PushStatusResolver.ts +108 -11
- package/src/generic/ResolverBase.ts +237 -107
- package/src/generic/RunViewResolver.ts +80 -15
- package/src/generic/actionOutputFieldSecurity.ts +75 -0
- package/src/generic/fieldSecurityTransport.ts +62 -0
- package/src/index.ts +127 -68
- package/src/integration/CustomColumnPromoter.ts +6 -1
- package/src/logging/variablesLoggingMiddleware.ts +59 -3
- package/src/realtimeSessions/README.md +7 -3
- package/src/realtimeSessions/SessionVerificationPortsBase.ts +1 -0
- package/src/realtimeSessions/ownedRealtimeSession.ts +20 -6
- package/src/realtimeSessions/sessionAccess.ts +181 -25
- package/src/realtimeSessions/sessionConfigStamps.ts +1 -1
- package/src/realtimeSessions/subscriptionAuthorization.ts +4 -2
- package/src/realtimeSessions/verificationWorkflow.ts +3 -1
- package/src/realtimeWidget/WidgetRouter.ts +22 -4
- package/src/realtimeWidget/WidgetSessionService.ts +252 -17
- package/src/realtimeWidget/host-identity.ts +1 -1
- package/src/realtimeWidget/widgetCore.ts +30 -1
- package/src/realtimeWidget/widgetGuestElevation.ts +2 -1
- package/src/resolvers/ActionResolver.ts +78 -15
- package/src/resolvers/AdhocQueryResolver.ts +1 -0
- package/src/resolvers/AgentRunStatusPublisher.ts +36 -8
- package/src/resolvers/AgentSessionResolver.ts +46 -18
- package/src/resolvers/EntityCommunicationsResolver.ts +56 -15
- package/src/resolvers/FetchEntityVectorsResolver.ts +132 -21
- package/src/resolvers/FileCategoryResolver.ts +1 -0
- package/src/resolvers/FileResolver.ts +14 -4
- package/src/resolvers/IntegrationDiscoveryResolver.ts +49 -7
- package/src/resolvers/MergeRecordsResolver.ts +23 -2
- package/src/resolvers/PipelineProgressResolver.ts +12 -3
- package/src/resolvers/QueryResolver.ts +20 -6
- package/src/resolvers/QuerySystemUserResolver.ts +15 -6
- package/src/resolvers/RSUResolver.ts +12 -0
- package/src/resolvers/RealtimeClientSessionResolver.ts +104 -33
- package/src/resolvers/RemoteBrowserActionResolver.ts +15 -10
- package/src/resolvers/RunAIAgentResolver.ts +258 -82
- package/src/resolvers/RunTemplateResolver.ts +6 -4
- package/src/resolvers/RunTestResolver.ts +3 -1
- package/src/resolvers/SyncDataResolver.ts +4 -0
- package/src/resolvers/TestQuerySQLResolver.ts +1 -0
- package/src/resolvers/TransactionGroupResolver.ts +66 -15
- package/src/resolvers/UserViewResolver.ts +2 -1
- package/src/resolvers/__tests__/MergeRecordsResolver.test.ts +43 -0
- package/src/rest/EntityCRUDHandler.ts +22 -5
- package/src/rest/RESTEndpointHandler.ts +8 -5
- package/src/rest/RealtimeRecordingHandler.ts +13 -10
- package/src/rest/ViewOperationsHandler.ts +24 -6
- package/src/serverRoleConfigUnits.ts +48 -0
- package/src/services/TaskGraphContinuationDeliverer.ts +52 -20
- package/src/types.ts +23 -1
|
@@ -143,20 +143,69 @@ export declare class RunAIAgentResolver extends ResolverBase {
|
|
|
143
143
|
*/
|
|
144
144
|
private sendFeedbackRequestNotification;
|
|
145
145
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
146
|
+
* Runs an agent's turn in a conversation: the server loads the history (attachments included, so the client never
|
|
147
|
+
* sends them), creates the agent's reply row, and runs the agent into it.
|
|
148
148
|
*
|
|
149
|
-
*
|
|
149
|
+
* Only the server writes agent replies (A19). The reply row (`Role` `AI`, In-Progress, its `ParentID` the user's
|
|
150
|
+
* message) is created here, as the person asking, before the run starts. In fire-and-forget mode the
|
|
151
|
+
* acknowledgement names it, `{ accepted, fireAndForget, conversationDetailId, createdAt }`, and is returned before
|
|
152
|
+
* the run publishes anything; every progress, streaming and completion message carries the same
|
|
153
|
+
* `conversationDetailId`. In synchronous mode the result's `agentRun.ConversationDetailID` names it.
|
|
154
|
+
*
|
|
155
|
+
* Threading, both optional: `replyParentId` puts the reply under another message of the same conversation the
|
|
156
|
+
* caller can read (MJ's chat threads a delegate's reply under the manager's); `announcedByAgentId` has the server
|
|
157
|
+
* first post that agent's fixed line "Continuing with **{agent}** for refinement..." and thread the reply under
|
|
158
|
+
* it, and the acknowledgement then also carries `announcementDetailId`.
|
|
159
|
+
*
|
|
160
|
+
* @param userMessageId - The person's message this turn answers, already saved.
|
|
150
161
|
* @param agentId - The agent to execute
|
|
151
162
|
* @param maxHistoryMessages - Maximum number of history messages to include (default: 20)
|
|
152
163
|
*/
|
|
153
|
-
RunAIAgentFromConversationDetail(
|
|
164
|
+
RunAIAgentFromConversationDetail(userMessageId: string, agentId: string, { userPayload, providers, dataSource }: AppContext, sessionId: string, pubSub: PubSubEngine, maxHistoryMessages?: number, data?: string, payload?: string, lastRunId?: string, autoPopulateLastRunPayload?: boolean, configurationId?: string, createArtifacts?: boolean, createNotification?: boolean, sourceArtifactId?: string, sourceArtifactVersionId?: string, fireAndForget?: boolean, planMode?: boolean, requestedSkillIDs?: string[],
|
|
154
165
|
/** History floor: an ISO-8601 timestamp, the first moment of the conversation this run may
|
|
155
166
|
* read. The history is loaded from there and no summary of earlier messages is used, and the
|
|
156
167
|
* run's own conversation reads honour it too. Omitted (clients send it only when set, so an
|
|
157
168
|
* older client never does), the run reads the whole conversation as before. An unreadable
|
|
158
169
|
* value fails the request rather than being dropped. */
|
|
159
|
-
agentHistoryFrom?: string
|
|
170
|
+
agentHistoryFrom?: string,
|
|
171
|
+
/** The message the reply threads under, when not the user's message: one in the same conversation the
|
|
172
|
+
* caller can read. */
|
|
173
|
+
replyParentId?: string,
|
|
174
|
+
/** An active agent (MJ's chat passes its conversation manager) whose fixed line "Continuing with
|
|
175
|
+
* **{agent}** for refinement..." the server posts before the reply, which then threads under it. */
|
|
176
|
+
announcedByAgentId?: string,
|
|
177
|
+
/** The fork the reply and history run on, when the turn forks from `userMessageId` (such as Regenerate).
|
|
178
|
+
* Checked to be a branch of the conversation whose path holds `userMessageId`. */
|
|
179
|
+
replyBranchId?: string): Promise<AIAgentRunResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Everything a conversation turn needs before its agent runs: the user's message (read as the caller, so a
|
|
182
|
+
* message they can't see is "not found", and for an anonymous visitor also checked against the conversation's
|
|
183
|
+
* scope stamp), the conversation history, the optional announcement line, and the reply
|
|
184
|
+
* row, created last so the history never holds the empty reply. Every row is written as `user`, the person asking,
|
|
185
|
+
* and marked as server-authored by {@link AgentRunner.CreateAgentReplyDetail}.
|
|
186
|
+
*/
|
|
187
|
+
private startConversationTurn;
|
|
188
|
+
/** The conversation, branch (null is Main) and sequence of a message, read as `user`; throws when they can't read it. */
|
|
189
|
+
private loadPlacementOf;
|
|
190
|
+
/**
|
|
191
|
+
* When a turn forks from an earlier message (such as Regenerate), the reply and history run on the fork while the
|
|
192
|
+
* user's message stays on the branch it was written on. Checks that `replyBranchId` is a branch of the turn's
|
|
193
|
+
* conversation whose path holds the user's message (`IsRowOnBranchPath` rather than exact `ForkFromSequence`
|
|
194
|
+
* equality is deliberate: `ConversationEngine.ForkPointFrom` sets `ForkFromSequence = message.Sequence` and the
|
|
195
|
+
* fork belongs to this conversation); returns `replyBranchId`, or throws before any row is created.
|
|
196
|
+
*/
|
|
197
|
+
private validateReplyBranch;
|
|
198
|
+
/**
|
|
199
|
+
* A reply's parent is part of what the reply says, so the server sets it, from a checked input: a message the
|
|
200
|
+
* caller can read, in the turn's own conversation. Returns its ID; throws otherwise.
|
|
201
|
+
*/
|
|
202
|
+
private validateReplyParent;
|
|
203
|
+
/**
|
|
204
|
+
* Posts the announcing agent's line, "Continuing with **{agent}** for refinement...", as a completed reply of the
|
|
205
|
+
* announcing agent. Its text is fixed and names the agent from metadata, so a caller chooses only whether it is
|
|
206
|
+
* posted and by which active agent, never what it says.
|
|
207
|
+
*/
|
|
208
|
+
private postContinuationAnnouncement;
|
|
160
209
|
/**
|
|
161
210
|
* Respond to a pending AIAgentRequest from the dashboard or API.
|
|
162
211
|
* Updates the request record with the response and optionally spawns a
|
|
@@ -170,9 +219,8 @@ export declare class RunAIAgentResolver extends ResolverBase {
|
|
|
170
219
|
ReassignAgentRequest(requestId: string, newUserID: string, { userPayload, providers }: AppContext, note?: string): Promise<AIAgentRunResult>;
|
|
171
220
|
/**
|
|
172
221
|
* Execute agent in background (fire-and-forget).
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* has already been sent.
|
|
222
|
+
* The client learns the outcome only from the run's completion status message (executeAIAgent publishes it,
|
|
223
|
+
* failure included), since the HTTP response has already been sent. A liveness pulse runs until the run ends.
|
|
176
224
|
*/
|
|
177
225
|
private executeAgentInBackground;
|
|
178
226
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunAIAgentResolver.d.ts","sourceRoot":"","sources":["../../src/resolvers/RunAIAgentResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkE,YAAY,EAAmD,MAAM,cAAc,CAAC;AAC7J,OAAO,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAQtD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"Run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C,wBAAwB;IA6DhC;;;;;;;;;;;;;;;;;;;OAmBG;YACW,sCAAsC;IAuEpD;;;OAGG;YACW,4BAA4B;IAmG1C;;;OAGG;YACW,uBAAuB;IAmDrC;;;;;OAKG;YACW,2BAA2B;CAuB5C"}
|
|
@@ -15,14 +15,17 @@ import { LogError, LogStatus, RunView } from '@memberjunction/core';
|
|
|
15
15
|
import { ArtifactMetadataEngine, ConversationEngine } from '@memberjunction/core-entities';
|
|
16
16
|
import { RouteArtifact } from './artifact-routing.js';
|
|
17
17
|
import { AgentRunner, ArtifactToolManager } from '@memberjunction/ai-agents';
|
|
18
|
-
import { MJAIAgentRunEntityExtended, ConversationUtility } from '@memberjunction/ai-core-plus';
|
|
18
|
+
import { MJAIAgentRunEntityExtended, ConversationUtility, ContinuationAnnouncementText } from '@memberjunction/ai-core-plus';
|
|
19
19
|
import { AIEngine } from '@memberjunction/aiengine';
|
|
20
20
|
import { ResolverBase } from '../generic/ResolverBase.js';
|
|
21
21
|
import { AgentRunStatusPublisher } from './AgentRunStatusPublisher.js';
|
|
22
|
+
import { ProjectEntityObjectForCaller } from '../generic/fieldSecurityTransport.js';
|
|
22
23
|
import { StartLivenessPulse } from '../generic/FireAndForgetHeartbeat.js';
|
|
24
|
+
import { StatusUpdateOwnerID } from '../generic/PushStatusResolver.js';
|
|
23
25
|
import { RequireSystemUser } from '../directives/RequireSystemUser.js';
|
|
24
26
|
import { GetReadWriteProvider } from '../util.js';
|
|
25
27
|
import { ResolveWidgetGuestRunContext, ElevateUserPayload } from '../realtimeWidget/widgetGuestElevation.js';
|
|
28
|
+
import { AuthorizeConversationTurn } from '../realtimeSessions/sessionAccess.js';
|
|
26
29
|
import { IsTrustedAgentRunCaller } from './agent-run-data-guard.js';
|
|
27
30
|
import { SafeJSONParse, UUIDsEqual } from '@memberjunction/global';
|
|
28
31
|
import { GetAttachmentService } from '@memberjunction/aiengine';
|
|
@@ -212,7 +215,7 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
212
215
|
* Sanitize ExecuteAgentResult for JSON serialization
|
|
213
216
|
* Removes circular references and non-serializable objects
|
|
214
217
|
*/
|
|
215
|
-
sanitizeAgentResult(result) {
|
|
218
|
+
sanitizeAgentResult(result, recipient) {
|
|
216
219
|
const sanitized = {
|
|
217
220
|
success: result.success,
|
|
218
221
|
payload: result.payload,
|
|
@@ -227,8 +230,9 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
227
230
|
};
|
|
228
231
|
// Safely extract agent run data using GetAll() for proper serialization
|
|
229
232
|
if (result.agentRun && typeof result.agentRun.GetAll === 'function') {
|
|
230
|
-
//
|
|
231
|
-
|
|
233
|
+
// GetAll() for the full serialized object including extended properties, projected for
|
|
234
|
+
// the recipient: the run comes from the agent engine, not from a load bound to them
|
|
235
|
+
sanitized.agentRun = ProjectEntityObjectForCaller(result.agentRun, recipient);
|
|
232
236
|
}
|
|
233
237
|
else {
|
|
234
238
|
// shouldn't ever get here
|
|
@@ -314,7 +318,10 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
314
318
|
/** ExecuteAgentParams.TrustReservedRunData: true only for a caller IsTrustedAgentRunCaller accepts. */
|
|
315
319
|
trustReservedRunData = false,
|
|
316
320
|
/** The conversation branch of the run — threaded into ExecuteAgentParams.ConversationBranchID. */
|
|
317
|
-
conversationBranchId
|
|
321
|
+
conversationBranchId,
|
|
322
|
+
/** The reply row this request created on the server for the run (`conversationDetailId` is its ID). The run
|
|
323
|
+
* writes into this instance, so its writes carry the server-authored marker and the user it was made as. */
|
|
324
|
+
replyDetail) {
|
|
318
325
|
const startTime = Date.now();
|
|
319
326
|
// Best-effort handle for persistInFlightAgentFailure. Populated from a
|
|
320
327
|
// progress event carrying metadata.agentRun, or from the successful
|
|
@@ -322,6 +329,8 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
322
329
|
// run is not marked Failed — the early-failure case we most want to
|
|
323
330
|
// persist, but we have no run object yet.
|
|
324
331
|
const agentRunRef = runRef ?? { current: null };
|
|
332
|
+
// The publisher owns every status message, including the failure completion the catch below sends.
|
|
333
|
+
const statusPublisher = new AgentRunStatusPublisher(pubSub, userPayload, sessionId, conversationDetailId);
|
|
325
334
|
try {
|
|
326
335
|
LogStatus(`=== RUNNING AI AGENT FOR ID: ${agentId} ===`);
|
|
327
336
|
// Parse and validate messages
|
|
@@ -346,9 +355,8 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
346
355
|
// singleton's transaction state with concurrent requests (e.g. conversation deletes).
|
|
347
356
|
const agentRunner = new AgentRunner(p);
|
|
348
357
|
console.log(`🚀 Starting agent execution with sessionId: ${sessionId}`);
|
|
349
|
-
// The
|
|
350
|
-
//
|
|
351
|
-
const statusPublisher = new AgentRunStatusPublisher(pubSub, userPayload, sessionId);
|
|
358
|
+
// The resolver still copies the run into agentRunRef, including noise steps, for the
|
|
359
|
+
// fire-and-forget liveness pulse.
|
|
352
360
|
const publishProgress = statusPublisher.OnProgress;
|
|
353
361
|
// Execute the agent in conversation context - handles conversation, artifacts, etc.
|
|
354
362
|
const conversationResult = await agentRunner.RunAgentInConversation({
|
|
@@ -381,10 +389,13 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
381
389
|
}
|
|
382
390
|
}, {
|
|
383
391
|
conversationDetailId: conversationDetailId, // Use existing if provided
|
|
392
|
+
agentResponseDetail: replyDetail, // the reply row this request created, when it did
|
|
384
393
|
conversationId: conversationId, // LATENCY OPT #2: pre-resolved to skip redundant load in AgentRunner
|
|
385
394
|
userMessage: userMessage, // Provide user message when conversationDetailId not provided
|
|
386
395
|
createArtifacts: createArtifacts || false,
|
|
387
|
-
sourceArtifactId: sourceArtifactId
|
|
396
|
+
sourceArtifactId: sourceArtifactId,
|
|
397
|
+
// A widget guest runs as the system user, but its conversation stays the guest's to write (MJ#4791).
|
|
398
|
+
ConversationWriter: userPayload.ElevatedFrom,
|
|
388
399
|
});
|
|
389
400
|
const result = conversationResult.agentResult;
|
|
390
401
|
// Use agent response detail ID if available, otherwise fall back to user message detail ID
|
|
@@ -424,7 +435,7 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
424
435
|
await Promise.all(postExecutionOps);
|
|
425
436
|
}
|
|
426
437
|
// Create sanitized payload for JSON serialization
|
|
427
|
-
const sanitizedResult = this.sanitizeAgentResult(result);
|
|
438
|
+
const sanitizedResult = this.sanitizeAgentResult(result, currentUser);
|
|
428
439
|
const returnResult = JSON.stringify(sanitizedResult);
|
|
429
440
|
// Publish final events with enriched result data for fire-and-forget clients
|
|
430
441
|
statusPublisher.PublishFinal(result, result.agentRun?.ConversationDetailID, returnResult);
|
|
@@ -445,10 +456,17 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
445
456
|
catch (error) {
|
|
446
457
|
const executionTime = Date.now() - startTime;
|
|
447
458
|
LogError(`AI Agent run failed:`, undefined, error);
|
|
448
|
-
|
|
459
|
+
// Never dereference a non-Error throw: this catch must not itself throw, since executeAIAgent resolves on
|
|
460
|
+
// every failure (executeAgentInBackground relies on it).
|
|
461
|
+
const errorMessage = (error instanceof Error && error.message) || 'Unknown error occurred';
|
|
449
462
|
// Fire-and-forget clients otherwise leave the run Running and the
|
|
450
463
|
// conversation detail In-Progress (Explorer red-pill timer).
|
|
451
|
-
await this.persistInFlightAgentFailure(p, userPayload, agentRunRef.current, conversationDetailId, errorMessage);
|
|
464
|
+
await this.persistInFlightAgentFailure(p, userPayload, agentRunRef.current, conversationDetailId, errorMessage, replyDetail);
|
|
465
|
+
// A fire-and-forget client has only this message to learn the run ended: without it, it waits out its
|
|
466
|
+
// idle timeout and then reconciles the run as a success. Published after the rows are closed, so a
|
|
467
|
+
// client that reloads the reply on this message reads the error. PublishFinal is the try's last step
|
|
468
|
+
// that can throw, so a run gets one completion or the other, never both.
|
|
469
|
+
statusPublisher.PublishFailure(conversationDetailId, errorMessage);
|
|
452
470
|
const errorResult = {
|
|
453
471
|
success: false,
|
|
454
472
|
errorMessage,
|
|
@@ -466,7 +484,9 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
466
484
|
* When executeAIAgent throws after the run/detail exist, close them so Explorer
|
|
467
485
|
* does not leave a red-pill timer on Status=Running / ConversationDetail In-Progress.
|
|
468
486
|
*/
|
|
469
|
-
async persistInFlightAgentFailure(provider, userPayload, run, conversationDetailId, errorMessage
|
|
487
|
+
async persistInFlightAgentFailure(provider, userPayload, run, conversationDetailId, errorMessage,
|
|
488
|
+
/** The run's reply row, when this request created it: written in place, as the server. */
|
|
489
|
+
replyDetail) {
|
|
470
490
|
try {
|
|
471
491
|
if (run && run.Status === 'Running') {
|
|
472
492
|
await run.EnsureSaveComplete();
|
|
@@ -482,7 +502,8 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
482
502
|
return;
|
|
483
503
|
}
|
|
484
504
|
if (conversationDetailId) {
|
|
485
|
-
const detail = await provider.GetEntityObject('MJ: Conversation Details', user);
|
|
505
|
+
const detail = replyDetail ?? await provider.GetEntityObject('MJ: Conversation Details', user);
|
|
506
|
+
await detail.EnsureSaveComplete(); // the run may still be saving into the same reply instance
|
|
486
507
|
if (await detail.Load(conversationDetailId) && detail.Status === 'In-Progress') {
|
|
487
508
|
await detail.EnsureSaveComplete();
|
|
488
509
|
detail.Status = 'Error';
|
|
@@ -741,16 +762,25 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
741
762
|
}
|
|
742
763
|
}
|
|
743
764
|
/**
|
|
744
|
-
*
|
|
745
|
-
*
|
|
765
|
+
* Runs an agent's turn in a conversation: the server loads the history (attachments included, so the client never
|
|
766
|
+
* sends them), creates the agent's reply row, and runs the agent into it.
|
|
746
767
|
*
|
|
747
|
-
*
|
|
768
|
+
* Only the server writes agent replies (A19). The reply row (`Role` `AI`, In-Progress, its `ParentID` the user's
|
|
769
|
+
* message) is created here, as the person asking, before the run starts. In fire-and-forget mode the
|
|
770
|
+
* acknowledgement names it, `{ accepted, fireAndForget, conversationDetailId, createdAt }`, and is returned before
|
|
771
|
+
* the run publishes anything; every progress, streaming and completion message carries the same
|
|
772
|
+
* `conversationDetailId`. In synchronous mode the result's `agentRun.ConversationDetailID` names it.
|
|
773
|
+
*
|
|
774
|
+
* Threading, both optional: `replyParentId` puts the reply under another message of the same conversation the
|
|
775
|
+
* caller can read (MJ's chat threads a delegate's reply under the manager's); `announcedByAgentId` has the server
|
|
776
|
+
* first post that agent's fixed line "Continuing with **{agent}** for refinement..." and thread the reply under
|
|
777
|
+
* it, and the acknowledgement then also carries `announcementDetailId`.
|
|
778
|
+
*
|
|
779
|
+
* @param userMessageId - The person's message this turn answers, already saved.
|
|
748
780
|
* @param agentId - The agent to execute
|
|
749
781
|
* @param maxHistoryMessages - Maximum number of history messages to include (default: 20)
|
|
750
782
|
*/
|
|
751
|
-
async RunAIAgentFromConversationDetail(
|
|
752
|
-
// Check API key scope authorization for agent execution
|
|
753
|
-
await this.CheckAPIKeyScopeAuthorization('agent:execute', agentId, userPayload);
|
|
783
|
+
async RunAIAgentFromConversationDetail(userMessageId, agentId, { userPayload, providers, dataSource }, sessionId, pubSub, maxHistoryMessages, data, payload, lastRunId, autoPopulateLastRunPayload, configurationId, createArtifacts, createNotification, sourceArtifactId, sourceArtifactVersionId, fireAndForget, planMode, requestedSkillIDs, agentHistoryFrom, replyParentId, announcedByAgentId, replyBranchId) {
|
|
754
784
|
const p = GetReadWriteProvider(providers);
|
|
755
785
|
const currentUser = this.GetUserFromPayload(userPayload);
|
|
756
786
|
if (!currentUser) {
|
|
@@ -765,10 +795,20 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
765
795
|
// AUTHORITATIVELY from the widget instance (never the client-supplied arg) — so a guest needs
|
|
766
796
|
// no grants to WRITE the AI run entities and cannot run an arbitrary agent under elevation.
|
|
767
797
|
// Conversation OWNERSHIP is still enforced under the guest principal below: the guest loads its
|
|
768
|
-
// own ConversationDetail through
|
|
769
|
-
//
|
|
798
|
+
// own ConversationDetail through its role's RLS filters, and startConversationTurn then checks
|
|
799
|
+
// the conversation's scope stamp against the visitor (MJ#6032), so a detail id from another
|
|
800
|
+
// visitor's session is refused before any elevated work happens. The reply row is written
|
|
801
|
+
// as the guest too, never as the elevated principal, which owns no guest's conversation.
|
|
770
802
|
const widgetElevation = await ResolveWidgetGuestRunContext(userPayload, p);
|
|
771
803
|
const effectiveAgentId = widgetElevation ? widgetElevation.PinnedAgentId : agentId;
|
|
804
|
+
// Check API key scope authorization for agent execution against the resolved agent id.
|
|
805
|
+
await this.CheckAPIKeyScopeAuthorization('agent:execute', effectiveAgentId, userPayload);
|
|
806
|
+
// A widget guest has one pinned agent and never posts a continuation announcement as another agent;
|
|
807
|
+
// an API-key caller must hold agent:execute for the announcing agent as well as the running agent.
|
|
808
|
+
const effectiveAnnouncedByAgentId = widgetElevation ? undefined : announcedByAgentId;
|
|
809
|
+
if (effectiveAnnouncedByAgentId) {
|
|
810
|
+
await this.CheckAPIKeyScopeAuthorization('agent:execute', effectiveAnnouncedByAgentId, userPayload);
|
|
811
|
+
}
|
|
772
812
|
const effectiveUserPayload = widgetElevation ? ElevateUserPayload(userPayload, widgetElevation.ElevatedUser) : userPayload;
|
|
773
813
|
// Only the system user or an API key holding the agent:trusted scope may set a run's scope and agent-type
|
|
774
814
|
// params through data (ExecuteAgentParams.TrustReservedRunData). Judged on the caller's own payload: a widget
|
|
@@ -779,25 +819,26 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
779
819
|
try {
|
|
780
820
|
// Parsed before anything loads: a floor the caller asked for must never be dropped.
|
|
781
821
|
const historyFrom = parseAgentHistoryFrom(agentHistoryFrom);
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
const
|
|
792
|
-
// The branch the
|
|
793
|
-
|
|
822
|
+
const turn = await this.startConversationTurn(p, currentUser, {
|
|
823
|
+
UserMessageId: userMessageId,
|
|
824
|
+
AgentId: effectiveAgentId,
|
|
825
|
+
MaxHistoryMessages: maxHistoryMessages || 20,
|
|
826
|
+
HistoryFrom: historyFrom,
|
|
827
|
+
ReplyParentId: replyParentId,
|
|
828
|
+
AnnouncedByAgentId: effectiveAnnouncedByAgentId,
|
|
829
|
+
ReplyBranchId: replyBranchId
|
|
830
|
+
});
|
|
831
|
+
const reply = turn.Reply;
|
|
832
|
+
// The turn's branch (the message's own branch, or a validated fork whose path holds the message)
|
|
833
|
+
// decides which path the run reads.
|
|
834
|
+
const branchId = turn.BranchId;
|
|
794
835
|
// A turn that follows a run the user STOPPED continues that run rather than starting
|
|
795
836
|
// over: chain it by LastRunID (the chat client never sends one) and, when the caller
|
|
796
837
|
// supplied no payload, roll the stopped run's FinalPayload into this run's start.
|
|
797
838
|
let effectiveLastRunId = lastRunId;
|
|
798
839
|
let effectiveAutoPopulate = autoPopulateLastRunPayload;
|
|
799
840
|
if (!effectiveLastRunId) {
|
|
800
|
-
const stoppedRunId = await this.findUserStoppedPredecessorRunId(
|
|
841
|
+
const stoppedRunId = await this.findUserStoppedPredecessorRunId(turn.ConversationId, effectiveAgentId, branchId, currentUser, p);
|
|
801
842
|
if (stoppedRunId) {
|
|
802
843
|
effectiveLastRunId = stoppedRunId;
|
|
803
844
|
if (effectiveAutoPopulate === undefined && payload == null) {
|
|
@@ -806,30 +847,29 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
806
847
|
LogStatus(`↩️ Continuing from user-stopped run ${stoppedRunId} (chained by LastRunID)`);
|
|
807
848
|
}
|
|
808
849
|
}
|
|
809
|
-
// Load conversation history with attachments from DB
|
|
810
|
-
const messages = await this.loadConversationHistoryWithAttachments(conversationId, currentUser, maxHistoryMessages || 20, p,
|
|
811
|
-
// The UI creates the agent-response placeholder row ('⏳ ...') before invoking
|
|
812
|
-
// this mutation — exclude it so the model never sees an empty assistant turn.
|
|
813
|
-
[conversationDetailId], historyFrom, branchId);
|
|
814
|
-
// Convert to JSON string for the existing executeAIAgent method
|
|
815
|
-
const messagesJson = JSON.stringify(messages);
|
|
816
850
|
if (fireAndForget) {
|
|
817
851
|
// Fire-and-forget mode: start execution in background, return immediately.
|
|
818
852
|
// The client will receive the result via WebSocket PubSub completion event.
|
|
819
|
-
this.executeAgentInBackground(p, dataSource, effectiveAgentId, effectiveUserPayload,
|
|
820
|
-
historyFrom, trustRunData, branchId);
|
|
853
|
+
this.executeAgentInBackground(p, dataSource, effectiveAgentId, effectiveUserPayload, turn.MessagesJson, sessionId, pubSub, data, payload, effectiveLastRunId, effectiveAutoPopulate, configurationId, reply.ID, createArtifacts || false, createNotification || false, sourceArtifactId, sourceArtifactVersionId, turn.ConversationId, planMode, requestedSkillIDs, undefined, // taskGraphDebug
|
|
854
|
+
historyFrom, trustRunData, branchId, reply);
|
|
821
855
|
LogStatus(`🔥 Fire-and-forget: Agent ${effectiveAgentId} execution started in background for session ${sessionId}`);
|
|
822
856
|
return {
|
|
823
857
|
success: true,
|
|
824
|
-
result: JSON.stringify({
|
|
858
|
+
result: JSON.stringify({
|
|
859
|
+
accepted: true,
|
|
860
|
+
fireAndForget: true,
|
|
861
|
+
conversationDetailId: reply.ID,
|
|
862
|
+
createdAt: reply.__mj_CreatedAt,
|
|
863
|
+
...(turn.Announcement ? { announcementDetailId: turn.Announcement.ID } : {})
|
|
864
|
+
})
|
|
825
865
|
};
|
|
826
866
|
}
|
|
827
867
|
// Synchronous mode (default): wait for execution to complete
|
|
828
|
-
return this.executeAIAgent(p, dataSource, effectiveAgentId, effectiveUserPayload,
|
|
829
|
-
effectiveLastRunId, effectiveAutoPopulate, configurationId,
|
|
868
|
+
return this.executeAIAgent(p, dataSource, effectiveAgentId, effectiveUserPayload, turn.MessagesJson, sessionId, pubSub, data, payload, undefined, // templateData
|
|
869
|
+
effectiveLastRunId, effectiveAutoPopulate, configurationId, reply.ID, createArtifacts || false, createNotification || false, sourceArtifactId, sourceArtifactVersionId, turn.ConversationId, // LATENCY OPT #2: pass pre-resolved conversationId
|
|
830
870
|
undefined, // runRef
|
|
831
871
|
planMode, requestedSkillIDs, undefined, // taskGraphDebug
|
|
832
|
-
historyFrom, trustRunData, branchId);
|
|
872
|
+
historyFrom, trustRunData, branchId, reply);
|
|
833
873
|
}
|
|
834
874
|
catch (error) {
|
|
835
875
|
const errorMessage = error.message || 'Unknown error loading conversation history';
|
|
@@ -841,6 +881,110 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
841
881
|
};
|
|
842
882
|
}
|
|
843
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Everything a conversation turn needs before its agent runs: the user's message (read as the caller, so a
|
|
886
|
+
* message they can't see is "not found", and for an anonymous visitor also checked against the conversation's
|
|
887
|
+
* scope stamp), the conversation history, the optional announcement line, and the reply
|
|
888
|
+
* row, created last so the history never holds the empty reply. Every row is written as `user`, the person asking,
|
|
889
|
+
* and marked as server-authored by {@link AgentRunner.CreateAgentReplyDetail}.
|
|
890
|
+
*/
|
|
891
|
+
async startConversationTurn(p, user, request) {
|
|
892
|
+
// LATENCY OPTIMIZATION (Opt #2 + #3): the user's message is loaded once here for its conversation and
|
|
893
|
+
// branch, which are threaded through the call chain rather than reloaded downstream.
|
|
894
|
+
const placement = await this.loadPlacementOf(p, user, request.UserMessageId);
|
|
895
|
+
const conversationId = placement.ConversationId;
|
|
896
|
+
// Loading the message as the caller is the whole ownership check for a named user. It is not for an
|
|
897
|
+
// anonymous visitor: every visitor is the one shared Anonymous user, so under a guest role whose row
|
|
898
|
+
// filters key on UserID another visitor's message loads fine (MJ#6032). The conversation's scope stamp
|
|
899
|
+
// decides instead, exactly as it does for the realtime gates — and before any row is written.
|
|
900
|
+
const access = await AuthorizeConversationTurn(conversationId, user, p);
|
|
901
|
+
if (!access.Allowed) {
|
|
902
|
+
LogError(`RunAIAgentFromConversationDetail: anonymous visitor ${user.AnonymousVisitorID ?? '(no visitor id)'} refused a turn in conversation ${conversationId} (${access.Reason})`);
|
|
903
|
+
throw new Error('Not authorized: you do not own this conversation');
|
|
904
|
+
}
|
|
905
|
+
const branchId = request.ReplyBranchId
|
|
906
|
+
? await this.validateReplyBranch(p, user, conversationId, placement, request.ReplyBranchId)
|
|
907
|
+
: placement.BranchId;
|
|
908
|
+
const parentId = request.ReplyParentId
|
|
909
|
+
? await this.validateReplyParent(p, user, request.ReplyParentId, conversationId)
|
|
910
|
+
: request.UserMessageId;
|
|
911
|
+
const messages = await this.loadConversationHistoryWithAttachments(conversationId, user, request.MaxHistoryMessages, p, undefined, request.HistoryFrom, branchId);
|
|
912
|
+
const runner = new AgentRunner(p);
|
|
913
|
+
const announcement = request.AnnouncedByAgentId
|
|
914
|
+
? await this.postContinuationAnnouncement(runner, user, conversationId, branchId, parentId, request.AnnouncedByAgentId, request.AgentId)
|
|
915
|
+
: undefined;
|
|
916
|
+
const reply = await runner.CreateAgentReplyDetail({
|
|
917
|
+
conversationId,
|
|
918
|
+
branchId,
|
|
919
|
+
agentId: request.AgentId,
|
|
920
|
+
contextUser: user,
|
|
921
|
+
parentId: announcement?.ID ?? parentId,
|
|
922
|
+
provider: p
|
|
923
|
+
});
|
|
924
|
+
return { ConversationId: conversationId, BranchId: branchId, MessagesJson: JSON.stringify(messages), Reply: reply, Announcement: announcement };
|
|
925
|
+
}
|
|
926
|
+
/** The conversation, branch (null is Main) and sequence of a message, read as `user`; throws when they can't read it. */
|
|
927
|
+
async loadPlacementOf(p, user, messageId) {
|
|
928
|
+
const message = await p.GetEntityObject('MJ: Conversation Details', user);
|
|
929
|
+
if (!await message.Load(messageId)) {
|
|
930
|
+
throw new Error(`Conversation detail ${messageId} not found`);
|
|
931
|
+
}
|
|
932
|
+
return { ConversationId: message.ConversationID, BranchId: message.BranchID ?? null, Sequence: message.Sequence ?? -1 };
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* When a turn forks from an earlier message (such as Regenerate), the reply and history run on the fork while the
|
|
936
|
+
* user's message stays on the branch it was written on. Checks that `replyBranchId` is a branch of the turn's
|
|
937
|
+
* conversation whose path holds the user's message (`IsRowOnBranchPath` rather than exact `ForkFromSequence`
|
|
938
|
+
* equality is deliberate: `ConversationEngine.ForkPointFrom` sets `ForkFromSequence = message.Sequence` and the
|
|
939
|
+
* fork belongs to this conversation); returns `replyBranchId`, or throws before any row is created.
|
|
940
|
+
*/
|
|
941
|
+
async validateReplyBranch(p, user, conversationId, userMessage, replyBranchId) {
|
|
942
|
+
if (UUIDsEqual(replyBranchId, userMessage.BranchId)) {
|
|
943
|
+
return replyBranchId;
|
|
944
|
+
}
|
|
945
|
+
if (userMessage.Sequence < 0) {
|
|
946
|
+
throw new Error(`Conversation detail is not on branch ${replyBranchId}'s path, so the reply cannot be written on that branch`);
|
|
947
|
+
}
|
|
948
|
+
const branches = await ConversationEngine.LoadBranchesFresh(conversationId, user, p);
|
|
949
|
+
const chain = ConversationEngine.BuildBranchChain(branches, replyBranchId);
|
|
950
|
+
if (!ConversationEngine.IsRowOnBranchPath({ BranchID: userMessage.BranchId, Sequence: userMessage.Sequence }, chain)) {
|
|
951
|
+
throw new Error(`Conversation detail is not on branch ${replyBranchId}'s path, so the reply cannot be written on that branch`);
|
|
952
|
+
}
|
|
953
|
+
return replyBranchId;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* A reply's parent is part of what the reply says, so the server sets it, from a checked input: a message the
|
|
957
|
+
* caller can read, in the turn's own conversation. Returns its ID; throws otherwise.
|
|
958
|
+
*/
|
|
959
|
+
async validateReplyParent(p, user, parentId, conversationId) {
|
|
960
|
+
const { ConversationId: parentConversationId } = await this.loadPlacementOf(p, user, parentId);
|
|
961
|
+
if (!UUIDsEqual(parentConversationId, conversationId)) {
|
|
962
|
+
throw new Error(`Conversation detail ${parentId} is not in this turn's conversation, so the reply cannot thread under it`);
|
|
963
|
+
}
|
|
964
|
+
return parentId;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Posts the announcing agent's line, "Continuing with **{agent}** for refinement...", as a completed reply of the
|
|
968
|
+
* announcing agent. Its text is fixed and names the agent from metadata, so a caller chooses only whether it is
|
|
969
|
+
* posted and by which active agent, never what it says.
|
|
970
|
+
*/
|
|
971
|
+
async postContinuationAnnouncement(runner, user, conversationId, branchId, parentId, announcerId, agentId) {
|
|
972
|
+
await AIEngine.Instance.Config(false, user);
|
|
973
|
+
const announcer = AIEngine.Instance.GetAgentByID(announcerId);
|
|
974
|
+
if (!announcer || announcer.Status !== 'Active') {
|
|
975
|
+
throw new Error(`Agent ${announcerId} cannot announce the turn: it is not an active agent`);
|
|
976
|
+
}
|
|
977
|
+
const agentName = AIEngine.Instance.GetAgentByID(agentId)?.Name ?? 'the agent';
|
|
978
|
+
return runner.CreateAgentReplyDetail({
|
|
979
|
+
conversationId,
|
|
980
|
+
branchId,
|
|
981
|
+
agentId: announcer.ID,
|
|
982
|
+
contextUser: user,
|
|
983
|
+
parentId,
|
|
984
|
+
message: ContinuationAnnouncementText(agentName),
|
|
985
|
+
status: 'Complete'
|
|
986
|
+
});
|
|
987
|
+
}
|
|
844
988
|
/**
|
|
845
989
|
* Respond to a pending AIAgentRequest from the dashboard or API.
|
|
846
990
|
* Updates the request record with the response and optionally spawns a
|
|
@@ -985,9 +1129,8 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
985
1129
|
}
|
|
986
1130
|
/**
|
|
987
1131
|
* Execute agent in background (fire-and-forget).
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
* has already been sent.
|
|
1132
|
+
* The client learns the outcome only from the run's completion status message (executeAIAgent publishes it,
|
|
1133
|
+
* failure included), since the HTTP response has already been sent. A liveness pulse runs until the run ends.
|
|
991
1134
|
*/
|
|
992
1135
|
executeAgentInBackground(p, dataSource, agentId, userPayload, messagesJson, sessionId, pubSub, data, payload, lastRunId, autoPopulateLastRunPayload, configurationId, conversationDetailId, createArtifacts = false, createNotification = false, sourceArtifactId, sourceArtifactVersionId,
|
|
993
1136
|
/** LATENCY OPT #2: Pre-resolved conversationId avoids redundant DB load in AgentRunner */
|
|
@@ -1001,27 +1144,26 @@ let RunAIAgentResolver = class RunAIAgentResolver extends ResolverBase {
|
|
|
1001
1144
|
/** ExecuteAgentParams.TrustReservedRunData — see executeAIAgent. */
|
|
1002
1145
|
trustReservedRunData = false,
|
|
1003
1146
|
/** The conversation branch of the run — threaded through to ExecuteAgentParams.ConversationBranchID. */
|
|
1004
|
-
conversationBranchId
|
|
1147
|
+
conversationBranchId,
|
|
1148
|
+
/** The reply row this request created for the run — see executeAIAgent. */
|
|
1149
|
+
replyDetail) {
|
|
1005
1150
|
// Ref the liveness pulse reads to enrich heartbeats once the run is created.
|
|
1006
1151
|
const runRef = { current: null };
|
|
1007
1152
|
const pulse = StartLivenessPulse({
|
|
1008
1153
|
pubSub,
|
|
1009
1154
|
sessionId,
|
|
1010
|
-
ownerUserId: userPayload
|
|
1155
|
+
ownerUserId: StatusUpdateOwnerID(userPayload),
|
|
1011
1156
|
resolver: 'RunAIAgentResolver',
|
|
1012
1157
|
readStatus: () => runRef.current
|
|
1013
1158
|
? { runId: runRef.current.ID, status: runRef.current.Status }
|
|
1014
1159
|
: undefined,
|
|
1015
1160
|
});
|
|
1016
|
-
//
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
//
|
|
1020
|
-
|
|
1021
|
-
LogError(`🔥 Fire-and-forget
|
|
1022
|
-
// Publish error completion event so the client knows the agent failed.
|
|
1023
|
-
// The publisher is created inside executeAIAgent, which rejected before returning one.
|
|
1024
|
-
new AgentRunStatusPublisher(pubSub, userPayload, sessionId).PublishFailure(conversationDetailId, errorMessage);
|
|
1161
|
+
// executeAIAgent resolves on every failure and publishes the run's completion itself (PublishFinal, or
|
|
1162
|
+
// PublishFailure from its catch), so nothing here publishes one.
|
|
1163
|
+
this.executeAIAgent(p, dataSource, agentId, userPayload, messagesJson, sessionId, pubSub, data, payload, undefined, lastRunId, autoPopulateLastRunPayload, configurationId, conversationDetailId, createArtifacts, createNotification, sourceArtifactId, sourceArtifactVersionId, conversationId, runRef, planMode, requestedSkillIDs, taskGraphDebug, conversationHistoryFrom, trustReservedRunData, conversationBranchId, replyDetail).catch((error) => {
|
|
1164
|
+
// Only a broken executeAIAgent contract lands here. Logged rather than left as an unhandled rejection;
|
|
1165
|
+
// no completion is published, because executeAIAgent may already have sent one.
|
|
1166
|
+
LogError(`🔥 Fire-and-forget run of agent ${agentId} for session ${sessionId} rejected, which executeAIAgent never should`, undefined, error);
|
|
1025
1167
|
}).finally(() => pulse.Stop());
|
|
1026
1168
|
}
|
|
1027
1169
|
/**
|
|
@@ -1318,7 +1460,7 @@ __decorate([
|
|
|
1318
1460
|
], RunAIAgentResolver.prototype, "RunAIAgentSystemUser", null);
|
|
1319
1461
|
__decorate([
|
|
1320
1462
|
Mutation(() => AIAgentRunResult),
|
|
1321
|
-
__param(0, Arg('
|
|
1463
|
+
__param(0, Arg('userMessageId')),
|
|
1322
1464
|
__param(1, Arg('agentId')),
|
|
1323
1465
|
__param(2, Ctx()),
|
|
1324
1466
|
__param(3, Arg('sessionId')),
|
|
@@ -1337,8 +1479,11 @@ __decorate([
|
|
|
1337
1479
|
__param(16, Arg('planMode', { nullable: true })),
|
|
1338
1480
|
__param(17, Arg('requestedSkillIDs', () => [String], { nullable: true })),
|
|
1339
1481
|
__param(18, Arg('agentHistoryFrom', { nullable: true })),
|
|
1482
|
+
__param(19, Arg('replyParentId', { nullable: true })),
|
|
1483
|
+
__param(20, Arg('announcedByAgentId', { nullable: true })),
|
|
1484
|
+
__param(21, Arg('replyBranchId', { nullable: true })),
|
|
1340
1485
|
__metadata("design:type", Function),
|
|
1341
|
-
__metadata("design:paramtypes", [String, String, Object, String, PubSubEngine, Number, String, String, String, Boolean, String, Boolean, Boolean, String, String, Boolean, Boolean, Array, String]),
|
|
1486
|
+
__metadata("design:paramtypes", [String, String, Object, String, PubSubEngine, Number, String, String, String, Boolean, String, Boolean, Boolean, String, String, Boolean, Boolean, Array, String, String, String, String]),
|
|
1342
1487
|
__metadata("design:returntype", Promise)
|
|
1343
1488
|
], RunAIAgentResolver.prototype, "RunAIAgentFromConversationDetail", null);
|
|
1344
1489
|
__decorate([
|