@memberjunction/server 2.75.0 → 2.76.0

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.
@@ -19,7 +19,7 @@ import { mj_core_schema } from '../config.js';
19
19
 
20
20
 
21
21
 
22
- import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, GeneratedCodeCategoryEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentRunEntity, AIVendorEntity, AIConfigurationEntity, AIAgentEntity, AIModelCostEntity, AIPromptModelEntity, AIAgentTypeEntity, AIAgentNoteEntity, AIAgentActionEntity, AIModelPriceTypeEntity, AIPromptEntity, AIResultCacheEntity, AIPromptCategoryEntity, AIPromptTypeEntity, CompanyEntity, EmployeeEntity, UserFavoriteEntity, EmployeeCompanyIntegrationEntity, EmployeeRoleEntity, EmployeeSkillEntity, RoleEntity, SkillEntity, IntegrationURLFormatEntity, IntegrationEntity, CompanyIntegrationEntity, EntityFieldEntity, EntityEntity, UserEntity, EntityRelationshipEntity, UserRecordLogEntity, UserViewEntity, CompanyIntegrationRunEntity, CompanyIntegrationRunDetailEntity, ErrorLogEntity, ApplicationEntity, ApplicationEntityEntity, EntityPermissionEntity, UserApplicationEntityEntity, UserApplicationEntity, CompanyIntegrationRunAPILogEntity, ListEntity, ListDetailEntity, UserViewRunEntity, UserViewRunDetailEntity, WorkflowRunEntity, WorkflowEntity, WorkflowEngineEntity, RecordChangeEntity, UserRoleEntity, RowLevelSecurityFilterEntity, AuditLogEntity, AuthorizationEntity, AuthorizationRoleEntity, AuditLogTypeEntity, EntityFieldValueEntity, AIModelEntity, AIActionEntity, AIModelActionEntity, EntityAIActionEntity, AIModelTypeEntity, QueueTypeEntity, QueueEntity, QueueTaskEntity, DashboardEntity, OutputTriggerTypeEntity, OutputFormatTypeEntity, OutputDeliveryTypeEntity, ReportEntity, ReportSnapshotEntity, ResourceTypeEntity, TagEntity, TaggedItemEntity, WorkspaceEntity, WorkspaceItemEntity, DatasetEntity, DatasetItemEntity, ConversationDetailEntity, ConversationEntity, UserNotificationEntity, SchemaInfoEntity, CompanyIntegrationRecordMapEntity, RecordMergeLogEntity, RecordMergeDeletionLogEntity, QueryFieldEntity, QueryCategoryEntity, QueryEntity, QueryPermissionEntity, VectorIndexEntity, EntityDocumentTypeEntity, EntityDocumentRunEntity, VectorDatabaseEntity, EntityRecordDocumentEntity, EntityDocumentEntity, DataContextItemEntity, DataContextEntity, UserViewCategoryEntity, DashboardCategoryEntity, ReportCategoryEntity, FileStorageProviderEntity, FileEntity, FileCategoryEntity, FileEntityRecordLinkEntity, VersionInstallationEntity, DuplicateRunDetailMatchEntity, EntityDocumentSettingEntity, EntitySettingEntity, DuplicateRunEntity, DuplicateRunDetailEntity, ApplicationSettingEntity, ActionCategoryEntity, EntityActionEntity, EntityActionInvocationEntity, ActionAuthorizationEntity, EntityActionInvocationTypeEntity, ActionEntity, EntityActionFilterEntity, ActionFilterEntity, ActionContextTypeEntity, ActionResultCodeEntity, ActionContextEntity, ActionExecutionLogEntity, ActionParamEntity, ActionLibraryEntity, LibraryEntity, ListCategoryEntity, CommunicationProviderEntity, CommunicationRunEntity, CommunicationProviderMessageTypeEntity, CommunicationLogEntity, CommunicationBaseMessageTypeEntity, TemplateEntity, TemplateCategoryEntity, TemplateContentEntity, TemplateParamEntity, TemplateContentTypeEntity, RecommendationEntity, RecommendationProviderEntity, RecommendationRunEntity, RecommendationItemEntity, EntityCommunicationMessageTypeEntity, EntityCommunicationFieldEntity, RecordChangeReplayRunEntity, LibraryItemEntity, EntityRelationshipDisplayComponentEntity, EntityActionParamEntity, ResourcePermissionEntity, ResourceLinkEntity, ConversationArtifactVersionEntity, AIAgentRequestEntity, AIModelVendorEntity, AIVendorTypeDefinitionEntity, ReportUserStateEntity, QueryEntityEntity, DashboardUserStateEntity, ArtifactTypeEntity, AIVendorTypeEntity, ConversationArtifactEntity, AIAgentPromptEntity, DashboardUserPreferenceEntity, QueryParameterEntity, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, GeneratedCodeEntity, AIPromptRunEntity, AIAgentRunStepEntity, ConversationArtifactPermissionEntity, AIModelPriceUnitTypeEntity, AIAgentLearningCycleEntity, ReportVersionEntity, AIConfigurationParamEntity } from '@memberjunction/core-entities';
22
+ import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, GeneratedCodeCategoryEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentRunEntity, AIVendorEntity, AIConfigurationEntity, AIAgentEntity, AIAgentStepEntity, AIModelCostEntity, AIPromptModelEntity, AIAgentTypeEntity, AIAgentNoteEntity, AIAgentActionEntity, AIModelPriceTypeEntity, AIPromptEntity, AIResultCacheEntity, AIPromptCategoryEntity, AIPromptTypeEntity, CompanyEntity, EmployeeEntity, UserFavoriteEntity, EmployeeCompanyIntegrationEntity, EmployeeRoleEntity, EmployeeSkillEntity, RoleEntity, SkillEntity, IntegrationURLFormatEntity, IntegrationEntity, CompanyIntegrationEntity, EntityFieldEntity, EntityEntity, UserEntity, EntityRelationshipEntity, UserRecordLogEntity, UserViewEntity, CompanyIntegrationRunEntity, CompanyIntegrationRunDetailEntity, ErrorLogEntity, ApplicationEntity, ApplicationEntityEntity, EntityPermissionEntity, UserApplicationEntityEntity, UserApplicationEntity, CompanyIntegrationRunAPILogEntity, ListEntity, ListDetailEntity, UserViewRunEntity, UserViewRunDetailEntity, WorkflowRunEntity, WorkflowEntity, WorkflowEngineEntity, RecordChangeEntity, UserRoleEntity, RowLevelSecurityFilterEntity, AuditLogEntity, AuthorizationEntity, AuthorizationRoleEntity, AuditLogTypeEntity, EntityFieldValueEntity, AIModelEntity, AIActionEntity, AIModelActionEntity, EntityAIActionEntity, AIModelTypeEntity, QueueTypeEntity, QueueEntity, QueueTaskEntity, DashboardEntity, OutputTriggerTypeEntity, OutputFormatTypeEntity, OutputDeliveryTypeEntity, ReportEntity, ReportSnapshotEntity, ResourceTypeEntity, TagEntity, TaggedItemEntity, WorkspaceEntity, WorkspaceItemEntity, DatasetEntity, DatasetItemEntity, ConversationDetailEntity, ConversationEntity, UserNotificationEntity, SchemaInfoEntity, CompanyIntegrationRecordMapEntity, RecordMergeLogEntity, RecordMergeDeletionLogEntity, QueryFieldEntity, QueryCategoryEntity, QueryEntity, QueryPermissionEntity, VectorIndexEntity, EntityDocumentTypeEntity, EntityDocumentRunEntity, VectorDatabaseEntity, EntityRecordDocumentEntity, EntityDocumentEntity, DataContextItemEntity, DataContextEntity, UserViewCategoryEntity, DashboardCategoryEntity, ReportCategoryEntity, FileStorageProviderEntity, FileEntity, FileCategoryEntity, FileEntityRecordLinkEntity, VersionInstallationEntity, DuplicateRunDetailMatchEntity, EntityDocumentSettingEntity, EntitySettingEntity, DuplicateRunEntity, DuplicateRunDetailEntity, ApplicationSettingEntity, ActionCategoryEntity, EntityActionEntity, EntityActionInvocationEntity, ActionAuthorizationEntity, EntityActionInvocationTypeEntity, ActionEntity, EntityActionFilterEntity, ActionFilterEntity, ActionContextTypeEntity, ActionResultCodeEntity, ActionContextEntity, ActionExecutionLogEntity, ActionParamEntity, ActionLibraryEntity, LibraryEntity, ListCategoryEntity, CommunicationProviderEntity, CommunicationRunEntity, CommunicationProviderMessageTypeEntity, CommunicationLogEntity, CommunicationBaseMessageTypeEntity, TemplateEntity, TemplateCategoryEntity, TemplateContentEntity, TemplateParamEntity, TemplateContentTypeEntity, RecommendationEntity, RecommendationProviderEntity, RecommendationRunEntity, RecommendationItemEntity, EntityCommunicationMessageTypeEntity, EntityCommunicationFieldEntity, RecordChangeReplayRunEntity, LibraryItemEntity, EntityRelationshipDisplayComponentEntity, EntityActionParamEntity, ResourcePermissionEntity, ResourceLinkEntity, ConversationArtifactVersionEntity, AIAgentRequestEntity, AIModelVendorEntity, AIVendorTypeDefinitionEntity, ReportUserStateEntity, QueryEntityEntity, DashboardUserStateEntity, ArtifactTypeEntity, AIVendorTypeEntity, ConversationArtifactEntity, AIAgentPromptEntity, DashboardUserPreferenceEntity, QueryParameterEntity, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, GeneratedCodeEntity, AIPromptRunEntity, AIAgentRunStepEntity, ConversationArtifactPermissionEntity, AIModelPriceUnitTypeEntity, AIAgentStepPathEntity, AIAgentLearningCycleEntity, ReportVersionEntity, AIConfigurationParamEntity } from '@memberjunction/core-entities';
23
23
 
24
24
 
25
25
  //****************************************************************************
@@ -2289,6 +2289,12 @@ if this limit is exceeded.`})
2289
2289
  @Field(() => [AIAgentAction_])
2290
2290
  AIAgentActions_AgentIDArray: AIAgentAction_[]; // Link to AIAgentActions
2291
2291
 
2292
+ @Field(() => [AIAgentStep_])
2293
+ MJ_AIAgentSteps_AgentIDArray: AIAgentStep_[]; // Link to MJ_AIAgentSteps
2294
+
2295
+ @Field(() => [AIAgentStep_])
2296
+ MJ_AIAgentSteps_SubAgentIDArray: AIAgentStep_[]; // Link to MJ_AIAgentSteps
2297
+
2292
2298
  @Field(() => [AIAgentPrompt_])
2293
2299
  MJ_AIAgentPrompts_AgentIDArray: AIAgentPrompt_[]; // Link to MJ_AIAgentPrompts
2294
2300
 
@@ -2620,6 +2626,26 @@ export class AIAgentResolver extends ResolverBase {
2620
2626
  return result;
2621
2627
  }
2622
2628
 
2629
+ @FieldResolver(() => [AIAgentStep_])
2630
+ async MJ_AIAgentSteps_AgentIDArray(@Root() aiagent_: AIAgent_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2631
+ this.CheckUserReadPermissions('MJ: AI Agent Steps', userPayload);
2632
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2633
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentSteps] WHERE [AgentID]='${aiagent_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Steps', userPayload, EntityPermissionType.Read, 'AND');
2634
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
2635
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Steps', rows);
2636
+ return result;
2637
+ }
2638
+
2639
+ @FieldResolver(() => [AIAgentStep_])
2640
+ async MJ_AIAgentSteps_SubAgentIDArray(@Root() aiagent_: AIAgent_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2641
+ this.CheckUserReadPermissions('MJ: AI Agent Steps', userPayload);
2642
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2643
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentSteps] WHERE [SubAgentID]='${aiagent_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Steps', userPayload, EntityPermissionType.Read, 'AND');
2644
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
2645
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Steps', rows);
2646
+ return result;
2647
+ }
2648
+
2623
2649
  @FieldResolver(() => [AIAgentPrompt_])
2624
2650
  async MJ_AIAgentPrompts_AgentIDArray(@Root() aiagent_: AIAgent_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2625
2651
  this.CheckUserReadPermissions('MJ: AI Agent Prompts', userPayload);
@@ -2709,6 +2735,345 @@ export class AIAgentResolver extends ResolverBase {
2709
2735
 
2710
2736
  }
2711
2737
 
2738
+ //****************************************************************************
2739
+ // ENTITY CLASS for MJ: AI Agent Steps
2740
+ //****************************************************************************
2741
+ @ObjectType({ description: `Defines individual steps (nodes) in a flow-based AI agent execution graph` })
2742
+ export class AIAgentStep_ {
2743
+ @Field()
2744
+ @MaxLength(16)
2745
+ ID: string;
2746
+
2747
+ @Field()
2748
+ @MaxLength(16)
2749
+ AgentID: string;
2750
+
2751
+ @Field()
2752
+ @MaxLength(510)
2753
+ Name: string;
2754
+
2755
+ @Field({nullable: true})
2756
+ Description?: string;
2757
+
2758
+ @Field({description: `Type of step: Action (execute an action), Sub-Agent (delegate to another agent), or Prompt (run an AI prompt)`})
2759
+ @MaxLength(40)
2760
+ StepType: string;
2761
+
2762
+ @Field(() => Boolean, {description: `If true, this step is executed when the agent starts`})
2763
+ StartingStep: boolean;
2764
+
2765
+ @Field(() => Int, {nullable: true})
2766
+ TimeoutSeconds?: number;
2767
+
2768
+ @Field(() => Int)
2769
+ RetryCount: number;
2770
+
2771
+ @Field()
2772
+ @MaxLength(40)
2773
+ OnErrorBehavior: string;
2774
+
2775
+ @Field({nullable: true})
2776
+ @MaxLength(16)
2777
+ ActionID?: string;
2778
+
2779
+ @Field({nullable: true})
2780
+ @MaxLength(16)
2781
+ SubAgentID?: string;
2782
+
2783
+ @Field({nullable: true})
2784
+ @MaxLength(16)
2785
+ PromptID?: string;
2786
+
2787
+ @Field({nullable: true, description: `JSON configuration for mapping action output parameters to payload paths. Example: {"outputParam1": "payload.customer.status", "*": "payload.lastResult"}`})
2788
+ ActionOutputMapping?: string;
2789
+
2790
+ @Field(() => Int)
2791
+ PositionX: number;
2792
+
2793
+ @Field(() => Int)
2794
+ PositionY: number;
2795
+
2796
+ @Field(() => Int)
2797
+ Width: number;
2798
+
2799
+ @Field(() => Int)
2800
+ Height: number;
2801
+
2802
+ @Field()
2803
+ @MaxLength(10)
2804
+ _mj__CreatedAt: Date;
2805
+
2806
+ @Field()
2807
+ @MaxLength(10)
2808
+ _mj__UpdatedAt: Date;
2809
+
2810
+ @Field({description: `Controls whether this step is executed. Active=normal execution, Pending=skip but may activate later, Disabled=never execute`})
2811
+ @MaxLength(40)
2812
+ Status: string;
2813
+
2814
+ @Field({nullable: true, description: `JSON configuration for mapping static values or payload paths to action input parameters. Example: {"param1": "staticValue", "param2": "payload.dynamicValue"}`})
2815
+ ActionInputMapping?: string;
2816
+
2817
+ @Field({nullable: true})
2818
+ @MaxLength(510)
2819
+ Agent?: string;
2820
+
2821
+ @Field({nullable: true})
2822
+ @MaxLength(850)
2823
+ Action?: string;
2824
+
2825
+ @Field({nullable: true})
2826
+ @MaxLength(510)
2827
+ SubAgent?: string;
2828
+
2829
+ @Field({nullable: true})
2830
+ @MaxLength(510)
2831
+ Prompt?: string;
2832
+
2833
+ @Field(() => [AIAgentStepPath_])
2834
+ MJ_AIAgentStepPaths_DestinationStepIDArray: AIAgentStepPath_[]; // Link to MJ_AIAgentStepPaths
2835
+
2836
+ @Field(() => [AIAgentStepPath_])
2837
+ MJ_AIAgentStepPaths_OriginStepIDArray: AIAgentStepPath_[]; // Link to MJ_AIAgentStepPaths
2838
+
2839
+ }
2840
+
2841
+ //****************************************************************************
2842
+ // INPUT TYPE for MJ: AI Agent Steps
2843
+ //****************************************************************************
2844
+ @InputType()
2845
+ export class CreateAIAgentStepInput {
2846
+ @Field({ nullable: true })
2847
+ ID?: string;
2848
+
2849
+ @Field({ nullable: true })
2850
+ AgentID?: string;
2851
+
2852
+ @Field({ nullable: true })
2853
+ Name?: string;
2854
+
2855
+ @Field({ nullable: true })
2856
+ Description: string | null;
2857
+
2858
+ @Field({ nullable: true })
2859
+ StepType?: string;
2860
+
2861
+ @Field(() => Boolean, { nullable: true })
2862
+ StartingStep?: boolean;
2863
+
2864
+ @Field(() => Int, { nullable: true })
2865
+ TimeoutSeconds?: number | null;
2866
+
2867
+ @Field(() => Int, { nullable: true })
2868
+ RetryCount?: number;
2869
+
2870
+ @Field({ nullable: true })
2871
+ OnErrorBehavior?: string;
2872
+
2873
+ @Field({ nullable: true })
2874
+ ActionID: string | null;
2875
+
2876
+ @Field({ nullable: true })
2877
+ SubAgentID: string | null;
2878
+
2879
+ @Field({ nullable: true })
2880
+ PromptID: string | null;
2881
+
2882
+ @Field({ nullable: true })
2883
+ ActionOutputMapping: string | null;
2884
+
2885
+ @Field(() => Int, { nullable: true })
2886
+ PositionX?: number;
2887
+
2888
+ @Field(() => Int, { nullable: true })
2889
+ PositionY?: number;
2890
+
2891
+ @Field(() => Int, { nullable: true })
2892
+ Width?: number;
2893
+
2894
+ @Field(() => Int, { nullable: true })
2895
+ Height?: number;
2896
+
2897
+ @Field({ nullable: true })
2898
+ Status?: string;
2899
+
2900
+ @Field({ nullable: true })
2901
+ ActionInputMapping: string | null;
2902
+ }
2903
+
2904
+
2905
+ //****************************************************************************
2906
+ // INPUT TYPE for MJ: AI Agent Steps
2907
+ //****************************************************************************
2908
+ @InputType()
2909
+ export class UpdateAIAgentStepInput {
2910
+ @Field()
2911
+ ID: string;
2912
+
2913
+ @Field({ nullable: true })
2914
+ AgentID?: string;
2915
+
2916
+ @Field({ nullable: true })
2917
+ Name?: string;
2918
+
2919
+ @Field({ nullable: true })
2920
+ Description?: string | null;
2921
+
2922
+ @Field({ nullable: true })
2923
+ StepType?: string;
2924
+
2925
+ @Field(() => Boolean, { nullable: true })
2926
+ StartingStep?: boolean;
2927
+
2928
+ @Field(() => Int, { nullable: true })
2929
+ TimeoutSeconds?: number | null;
2930
+
2931
+ @Field(() => Int, { nullable: true })
2932
+ RetryCount?: number;
2933
+
2934
+ @Field({ nullable: true })
2935
+ OnErrorBehavior?: string;
2936
+
2937
+ @Field({ nullable: true })
2938
+ ActionID?: string | null;
2939
+
2940
+ @Field({ nullable: true })
2941
+ SubAgentID?: string | null;
2942
+
2943
+ @Field({ nullable: true })
2944
+ PromptID?: string | null;
2945
+
2946
+ @Field({ nullable: true })
2947
+ ActionOutputMapping?: string | null;
2948
+
2949
+ @Field(() => Int, { nullable: true })
2950
+ PositionX?: number;
2951
+
2952
+ @Field(() => Int, { nullable: true })
2953
+ PositionY?: number;
2954
+
2955
+ @Field(() => Int, { nullable: true })
2956
+ Width?: number;
2957
+
2958
+ @Field(() => Int, { nullable: true })
2959
+ Height?: number;
2960
+
2961
+ @Field({ nullable: true })
2962
+ Status?: string;
2963
+
2964
+ @Field({ nullable: true })
2965
+ ActionInputMapping?: string | null;
2966
+
2967
+ @Field(() => [KeyValuePairInput], { nullable: true })
2968
+ OldValues___?: KeyValuePairInput[];
2969
+ }
2970
+
2971
+ //****************************************************************************
2972
+ // RESOLVER for MJ: AI Agent Steps
2973
+ //****************************************************************************
2974
+ @ObjectType()
2975
+ export class RunAIAgentStepViewResult {
2976
+ @Field(() => [AIAgentStep_])
2977
+ Results: AIAgentStep_[];
2978
+
2979
+ @Field(() => String, {nullable: true})
2980
+ UserViewRunID?: string;
2981
+
2982
+ @Field(() => Int, {nullable: true})
2983
+ RowCount: number;
2984
+
2985
+ @Field(() => Int, {nullable: true})
2986
+ TotalRowCount: number;
2987
+
2988
+ @Field(() => Int, {nullable: true})
2989
+ ExecutionTime: number;
2990
+
2991
+ @Field({nullable: true})
2992
+ ErrorMessage?: string;
2993
+
2994
+ @Field(() => Boolean, {nullable: false})
2995
+ Success: boolean;
2996
+ }
2997
+
2998
+ @Resolver(AIAgentStep_)
2999
+ export class AIAgentStepResolver extends ResolverBase {
3000
+ @Query(() => RunAIAgentStepViewResult)
3001
+ async RunAIAgentStepViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3002
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3003
+ return super.RunViewByIDGeneric(input, connPool, userPayload, pubSub);
3004
+ }
3005
+
3006
+ @Query(() => RunAIAgentStepViewResult)
3007
+ async RunAIAgentStepViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3008
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3009
+ return super.RunViewByNameGeneric(input, connPool, userPayload, pubSub);
3010
+ }
3011
+
3012
+ @Query(() => RunAIAgentStepViewResult)
3013
+ async RunAIAgentStepDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3014
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3015
+ input.EntityName = 'MJ: AI Agent Steps';
3016
+ return super.RunDynamicViewGeneric(input, connPool, userPayload, pubSub);
3017
+ }
3018
+ @Query(() => AIAgentStep_, { nullable: true })
3019
+ async AIAgentStep(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<AIAgentStep_ | null> {
3020
+ this.CheckUserReadPermissions('MJ: AI Agent Steps', userPayload);
3021
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3022
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentSteps] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Steps', userPayload, EntityPermissionType.Read, 'AND');
3023
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
3024
+ const result = this.MapFieldNamesToCodeNames('MJ: AI Agent Steps', rows && rows.length > 0 ? rows[0] : {})
3025
+ return result;
3026
+ }
3027
+
3028
+ @FieldResolver(() => [AIAgentStepPath_])
3029
+ async MJ_AIAgentStepPaths_DestinationStepIDArray(@Root() aiagentstep_: AIAgentStep_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3030
+ this.CheckUserReadPermissions('MJ: AI Agent Step Paths', userPayload);
3031
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3032
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentStepPaths] WHERE [DestinationStepID]='${aiagentstep_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Step Paths', userPayload, EntityPermissionType.Read, 'AND');
3033
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
3034
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Step Paths', rows);
3035
+ return result;
3036
+ }
3037
+
3038
+ @FieldResolver(() => [AIAgentStepPath_])
3039
+ async MJ_AIAgentStepPaths_OriginStepIDArray(@Root() aiagentstep_: AIAgentStep_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3040
+ this.CheckUserReadPermissions('MJ: AI Agent Step Paths', userPayload);
3041
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3042
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentStepPaths] WHERE [OriginStepID]='${aiagentstep_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Step Paths', userPayload, EntityPermissionType.Read, 'AND');
3043
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
3044
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Step Paths', rows);
3045
+ return result;
3046
+ }
3047
+
3048
+ @Mutation(() => AIAgentStep_)
3049
+ async CreateAIAgentStep(
3050
+ @Arg('input', () => CreateAIAgentStepInput) input: CreateAIAgentStepInput,
3051
+ @Ctx() { dataSources, userPayload }: AppContext,
3052
+ @PubSub() pubSub: PubSubEngine
3053
+ ) {
3054
+ const connPool = GetReadWriteDataSource(dataSources);
3055
+ return this.CreateRecord('MJ: AI Agent Steps', input, connPool, userPayload, pubSub)
3056
+ }
3057
+
3058
+ @Mutation(() => AIAgentStep_)
3059
+ async UpdateAIAgentStep(
3060
+ @Arg('input', () => UpdateAIAgentStepInput) input: UpdateAIAgentStepInput,
3061
+ @Ctx() { dataSources, userPayload }: AppContext,
3062
+ @PubSub() pubSub: PubSubEngine
3063
+ ) {
3064
+ const connPool = GetReadWriteDataSource(dataSources);
3065
+ return this.UpdateRecord('MJ: AI Agent Steps', input, connPool, userPayload, pubSub);
3066
+ }
3067
+
3068
+ @Mutation(() => AIAgentStep_)
3069
+ async DeleteAIAgentStep(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3070
+ const connPool = GetReadWriteDataSource(dataSources);
3071
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
3072
+ return this.DeleteRecord('MJ: AI Agent Steps', key, options, connPool, userPayload, pubSub);
3073
+ }
3074
+
3075
+ }
3076
+
2712
3077
  //****************************************************************************
2713
3078
  // ENTITY CLASS for MJ: AI Model Costs
2714
3079
  //****************************************************************************
@@ -3257,6 +3622,17 @@ export class AIAgentType_ {
3257
3622
  @MaxLength(510)
3258
3623
  DriverClass?: string;
3259
3624
 
3625
+ @Field({nullable: true, description: `Optional Angular component key name for a subclass of BaseFormSectionComponent that provides a custom form section for this agent type. When specified, this component will be dynamically loaded and displayed as the first expandable section in the AI Agent form. This allows agent types to have specialized UI elements. The class must be registered with the MemberJunction class factory via @RegisterClass`})
3626
+ @MaxLength(1000)
3627
+ UIFormSectionKey?: string;
3628
+
3629
+ @Field({nullable: true, description: `Optional Angular component key name for a subclass of BaseFormComponent that will completely overrides the default AI Agent form for this agent type. When specified, this component will be used instead of the standard AI Agent form, allowing for completely custom form implementations. The class must be registered with the MemberJunction class factory via @RegisterClass. If both UIFormClass and UIFormSectionClass are specified, UIFormClass takes precedence.`})
3630
+ @MaxLength(1000)
3631
+ UIFormKey?: string;
3632
+
3633
+ @Field(() => Boolean, {description: `Determines whether the custom form section (specified by UIFormSectionClass) should be expanded by default when the AI Agent form loads. True means the section starts expanded, False means it starts collapsed. Only applies when UIFormSectionClass is specified. Defaults to 1 (expanded).`})
3634
+ UIFormSectionExpandedByDefault: boolean;
3635
+
3260
3636
  @Field({nullable: true})
3261
3637
  @MaxLength(510)
3262
3638
  SystemPrompt?: string;
@@ -3291,6 +3667,15 @@ export class CreateAIAgentTypeInput {
3291
3667
 
3292
3668
  @Field({ nullable: true })
3293
3669
  DriverClass: string | null;
3670
+
3671
+ @Field({ nullable: true })
3672
+ UIFormSectionKey: string | null;
3673
+
3674
+ @Field({ nullable: true })
3675
+ UIFormKey: string | null;
3676
+
3677
+ @Field(() => Boolean, { nullable: true })
3678
+ UIFormSectionExpandedByDefault?: boolean;
3294
3679
  }
3295
3680
 
3296
3681
 
@@ -3320,6 +3705,15 @@ export class UpdateAIAgentTypeInput {
3320
3705
  @Field({ nullable: true })
3321
3706
  DriverClass?: string | null;
3322
3707
 
3708
+ @Field({ nullable: true })
3709
+ UIFormSectionKey?: string | null;
3710
+
3711
+ @Field({ nullable: true })
3712
+ UIFormKey?: string | null;
3713
+
3714
+ @Field(() => Boolean, { nullable: true })
3715
+ UIFormSectionExpandedByDefault?: boolean;
3716
+
3323
3717
  @Field(() => [KeyValuePairInput], { nullable: true })
3324
3718
  OldValues___?: KeyValuePairInput[];
3325
3719
  }
@@ -4168,6 +4562,9 @@ export class AIPrompt_ {
4168
4562
  @Field(() => [AIPromptModel_])
4169
4563
  MJ_AIPromptModels_PromptIDArray: AIPromptModel_[]; // Link to MJ_AIPromptModels
4170
4564
 
4565
+ @Field(() => [AIAgentStep_])
4566
+ MJ_AIAgentSteps_PromptIDArray: AIAgentStep_[]; // Link to MJ_AIAgentSteps
4567
+
4171
4568
  @Field(() => [AIAgentPrompt_])
4172
4569
  MJ_AIAgentPrompts_PromptIDArray: AIAgentPrompt_[]; // Link to MJ_AIAgentPrompts
4173
4570
 
@@ -4600,6 +4997,16 @@ export class AIPromptResolver extends ResolverBase {
4600
4997
  return result;
4601
4998
  }
4602
4999
 
5000
+ @FieldResolver(() => [AIAgentStep_])
5001
+ async MJ_AIAgentSteps_PromptIDArray(@Root() aiprompt_: AIPrompt_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
5002
+ this.CheckUserReadPermissions('MJ: AI Agent Steps', userPayload);
5003
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
5004
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentSteps] WHERE [PromptID]='${aiprompt_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Steps', userPayload, EntityPermissionType.Read, 'AND');
5005
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
5006
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Steps', rows);
5007
+ return result;
5008
+ }
5009
+
4603
5010
  @FieldResolver(() => [AIAgentPrompt_])
4604
5011
  async MJ_AIAgentPrompts_PromptIDArray(@Root() aiprompt_: AIPrompt_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
4605
5012
  this.CheckUserReadPermissions('MJ: AI Agent Prompts', userPayload);
@@ -28519,6 +28926,9 @@ export class Action_ {
28519
28926
  @Field(() => [EntityAction_])
28520
28927
  EntityActions_ActionIDArray: EntityAction_[]; // Link to EntityActions
28521
28928
 
28929
+ @Field(() => [AIAgentStep_])
28930
+ MJ_AIAgentSteps_ActionIDArray: AIAgentStep_[]; // Link to MJ_AIAgentSteps
28931
+
28522
28932
  @Field(() => [ActionExecutionLog_])
28523
28933
  ActionExecutionLogs_ActionIDArray: ActionExecutionLog_[]; // Link to ActionExecutionLogs
28524
28934
 
@@ -28793,6 +29203,16 @@ export class ActionResolver extends ResolverBase {
28793
29203
  return result;
28794
29204
  }
28795
29205
 
29206
+ @FieldResolver(() => [AIAgentStep_])
29207
+ async MJ_AIAgentSteps_ActionIDArray(@Root() action_: Action_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
29208
+ this.CheckUserReadPermissions('MJ: AI Agent Steps', userPayload);
29209
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
29210
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentSteps] WHERE [ActionID]='${action_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Steps', userPayload, EntityPermissionType.Read, 'AND');
29211
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
29212
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Steps', rows);
29213
+ return result;
29214
+ }
29215
+
28796
29216
  @FieldResolver(() => [ActionExecutionLog_])
28797
29217
  async ActionExecutionLogs_ActionIDArray(@Root() action_: Action_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
28798
29218
  this.CheckUserReadPermissions('Action Execution Logs', userPayload);
@@ -41150,6 +41570,198 @@ export class AIModelPriceUnitTypeResolver extends ResolverBase {
41150
41570
 
41151
41571
  }
41152
41572
 
41573
+ //****************************************************************************
41574
+ // ENTITY CLASS for MJ: AI Agent Step Paths
41575
+ //****************************************************************************
41576
+ @ObjectType({ description: `Defines paths (edges) between steps in a flow-based AI agent execution graph` })
41577
+ export class AIAgentStepPath_ {
41578
+ @Field()
41579
+ @MaxLength(16)
41580
+ ID: string;
41581
+
41582
+ @Field()
41583
+ @MaxLength(16)
41584
+ OriginStepID: string;
41585
+
41586
+ @Field()
41587
+ @MaxLength(16)
41588
+ DestinationStepID: string;
41589
+
41590
+ @Field({nullable: true, description: `Boolean expression to evaluate. If null, path is always taken. Evaluated against payload and step results.`})
41591
+ Condition?: string;
41592
+
41593
+ @Field(() => Int, {description: `Path evaluation priority. Higher values are evaluated first. Use 0 or negative values for default/fallback paths that execute when no other conditions match.`})
41594
+ Priority: number;
41595
+
41596
+ @Field({nullable: true})
41597
+ @MaxLength(510)
41598
+ Description?: string;
41599
+
41600
+ @Field({nullable: true})
41601
+ PathPoints?: string;
41602
+
41603
+ @Field()
41604
+ @MaxLength(10)
41605
+ _mj__CreatedAt: Date;
41606
+
41607
+ @Field()
41608
+ @MaxLength(10)
41609
+ _mj__UpdatedAt: Date;
41610
+
41611
+ @Field()
41612
+ @MaxLength(510)
41613
+ OriginStep: string;
41614
+
41615
+ @Field()
41616
+ @MaxLength(510)
41617
+ DestinationStep: string;
41618
+
41619
+ }
41620
+
41621
+ //****************************************************************************
41622
+ // INPUT TYPE for MJ: AI Agent Step Paths
41623
+ //****************************************************************************
41624
+ @InputType()
41625
+ export class CreateAIAgentStepPathInput {
41626
+ @Field({ nullable: true })
41627
+ ID?: string;
41628
+
41629
+ @Field({ nullable: true })
41630
+ OriginStepID?: string;
41631
+
41632
+ @Field({ nullable: true })
41633
+ DestinationStepID?: string;
41634
+
41635
+ @Field({ nullable: true })
41636
+ Condition: string | null;
41637
+
41638
+ @Field(() => Int, { nullable: true })
41639
+ Priority?: number;
41640
+
41641
+ @Field({ nullable: true })
41642
+ Description: string | null;
41643
+
41644
+ @Field({ nullable: true })
41645
+ PathPoints: string | null;
41646
+ }
41647
+
41648
+
41649
+ //****************************************************************************
41650
+ // INPUT TYPE for MJ: AI Agent Step Paths
41651
+ //****************************************************************************
41652
+ @InputType()
41653
+ export class UpdateAIAgentStepPathInput {
41654
+ @Field()
41655
+ ID: string;
41656
+
41657
+ @Field({ nullable: true })
41658
+ OriginStepID?: string;
41659
+
41660
+ @Field({ nullable: true })
41661
+ DestinationStepID?: string;
41662
+
41663
+ @Field({ nullable: true })
41664
+ Condition?: string | null;
41665
+
41666
+ @Field(() => Int, { nullable: true })
41667
+ Priority?: number;
41668
+
41669
+ @Field({ nullable: true })
41670
+ Description?: string | null;
41671
+
41672
+ @Field({ nullable: true })
41673
+ PathPoints?: string | null;
41674
+
41675
+ @Field(() => [KeyValuePairInput], { nullable: true })
41676
+ OldValues___?: KeyValuePairInput[];
41677
+ }
41678
+
41679
+ //****************************************************************************
41680
+ // RESOLVER for MJ: AI Agent Step Paths
41681
+ //****************************************************************************
41682
+ @ObjectType()
41683
+ export class RunAIAgentStepPathViewResult {
41684
+ @Field(() => [AIAgentStepPath_])
41685
+ Results: AIAgentStepPath_[];
41686
+
41687
+ @Field(() => String, {nullable: true})
41688
+ UserViewRunID?: string;
41689
+
41690
+ @Field(() => Int, {nullable: true})
41691
+ RowCount: number;
41692
+
41693
+ @Field(() => Int, {nullable: true})
41694
+ TotalRowCount: number;
41695
+
41696
+ @Field(() => Int, {nullable: true})
41697
+ ExecutionTime: number;
41698
+
41699
+ @Field({nullable: true})
41700
+ ErrorMessage?: string;
41701
+
41702
+ @Field(() => Boolean, {nullable: false})
41703
+ Success: boolean;
41704
+ }
41705
+
41706
+ @Resolver(AIAgentStepPath_)
41707
+ export class AIAgentStepPathResolver extends ResolverBase {
41708
+ @Query(() => RunAIAgentStepPathViewResult)
41709
+ async RunAIAgentStepPathViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
41710
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
41711
+ return super.RunViewByIDGeneric(input, connPool, userPayload, pubSub);
41712
+ }
41713
+
41714
+ @Query(() => RunAIAgentStepPathViewResult)
41715
+ async RunAIAgentStepPathViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
41716
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
41717
+ return super.RunViewByNameGeneric(input, connPool, userPayload, pubSub);
41718
+ }
41719
+
41720
+ @Query(() => RunAIAgentStepPathViewResult)
41721
+ async RunAIAgentStepPathDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
41722
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
41723
+ input.EntityName = 'MJ: AI Agent Step Paths';
41724
+ return super.RunDynamicViewGeneric(input, connPool, userPayload, pubSub);
41725
+ }
41726
+ @Query(() => AIAgentStepPath_, { nullable: true })
41727
+ async AIAgentStepPath(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<AIAgentStepPath_ | null> {
41728
+ this.CheckUserReadPermissions('MJ: AI Agent Step Paths', userPayload);
41729
+ const connPool = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
41730
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentStepPaths] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Step Paths', userPayload, EntityPermissionType.Read, 'AND');
41731
+ const rows = await SQLServerDataProvider.ExecuteSQLWithPool(connPool, sSQL, undefined, this.GetUserFromPayload(userPayload));
41732
+ const result = this.MapFieldNamesToCodeNames('MJ: AI Agent Step Paths', rows && rows.length > 0 ? rows[0] : {})
41733
+ return result;
41734
+ }
41735
+
41736
+ @Mutation(() => AIAgentStepPath_)
41737
+ async CreateAIAgentStepPath(
41738
+ @Arg('input', () => CreateAIAgentStepPathInput) input: CreateAIAgentStepPathInput,
41739
+ @Ctx() { dataSources, userPayload }: AppContext,
41740
+ @PubSub() pubSub: PubSubEngine
41741
+ ) {
41742
+ const connPool = GetReadWriteDataSource(dataSources);
41743
+ return this.CreateRecord('MJ: AI Agent Step Paths', input, connPool, userPayload, pubSub)
41744
+ }
41745
+
41746
+ @Mutation(() => AIAgentStepPath_)
41747
+ async UpdateAIAgentStepPath(
41748
+ @Arg('input', () => UpdateAIAgentStepPathInput) input: UpdateAIAgentStepPathInput,
41749
+ @Ctx() { dataSources, userPayload }: AppContext,
41750
+ @PubSub() pubSub: PubSubEngine
41751
+ ) {
41752
+ const connPool = GetReadWriteDataSource(dataSources);
41753
+ return this.UpdateRecord('MJ: AI Agent Step Paths', input, connPool, userPayload, pubSub);
41754
+ }
41755
+
41756
+ @Mutation(() => AIAgentStepPath_)
41757
+ async DeleteAIAgentStepPath(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
41758
+ const connPool = GetReadWriteDataSource(dataSources);
41759
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
41760
+ return this.DeleteRecord('MJ: AI Agent Step Paths', key, options, connPool, userPayload, pubSub);
41761
+ }
41762
+
41763
+ }
41764
+
41153
41765
  //****************************************************************************
41154
41766
  // ENTITY CLASS for AI Agent Learning Cycles
41155
41767
  //****************************************************************************