@memberjunction/server 2.44.0 → 2.45.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, AIVendorEntity, AIConfigurationEntity, AIAgentEntity, AIPromptModelEntity, AIAgentNoteEntity, AIAgentActionEntity, 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, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, GeneratedCodeEntity, AIPromptRunEntity, ConversationArtifactPermissionEntity, AIAgentLearningCycleEntity, ReportVersionEntity, AIConfigurationParamEntity } from '@memberjunction/core-entities';
22
+ import { ScheduledActionEntity, ScheduledActionParamEntity, ExplorerNavigationItemEntity, GeneratedCodeCategoryEntity, AIAgentModelEntity, AIAgentNoteTypeEntity, AIAgentRunEntity, AIVendorEntity, AIConfigurationEntity, AIAgentEntity, AIPromptModelEntity, AIAgentTypeEntity, AIAgentNoteEntity, AIAgentActionEntity, 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, ContentProcessRunEntity, ContentSourceEntity, ContentSourceParamEntity, ContentSourceTypeEntity, ContentSourceTypeParamEntity, ContentTypeEntity, ContentTypeAttributeEntity, ContentFileTypeEntity, ContentItemEntity, ContentItemAttributeEntity, ContentItemTagEntity, GeneratedCodeEntity, AIPromptRunEntity, AIAgentRunStepEntity, ConversationArtifactPermissionEntity, AIAgentLearningCycleEntity, ReportVersionEntity, AIConfigurationParamEntity } from '@memberjunction/core-entities';
23
23
 
24
24
 
25
25
  //****************************************************************************
@@ -1181,6 +1181,289 @@ export class AIAgentNoteTypeResolver extends ResolverBase {
1181
1181
 
1182
1182
  }
1183
1183
 
1184
+ //****************************************************************************
1185
+ // ENTITY CLASS for MJ: AI Agent Runs
1186
+ //****************************************************************************
1187
+ @ObjectType()
1188
+ export class AIAgentRun_ {
1189
+ @Field({description: `Unique identifier for this agent run`})
1190
+ @MaxLength(16)
1191
+ ID: string;
1192
+
1193
+ @Field({description: `Reference to the AIAgent that is being executed in this run`})
1194
+ @MaxLength(16)
1195
+ AgentID: string;
1196
+
1197
+ @Field({nullable: true, description: `Reference to the parent agent run if this is a sub-agent execution. NULL for root-level agent runs. Enables hierarchical execution tracking.`})
1198
+ @MaxLength(16)
1199
+ ParentRunID?: string;
1200
+
1201
+ @Field({description: `Current status of the agent run. Running -> Completed/Failed/Cancelled`})
1202
+ @MaxLength(100)
1203
+ Status: string;
1204
+
1205
+ @Field({description: `Timestamp when the agent run began execution`})
1206
+ @MaxLength(10)
1207
+ StartedAt: Date;
1208
+
1209
+ @Field({nullable: true, description: `Timestamp when the agent run completed (successfully or with failure). NULL while running.`})
1210
+ @MaxLength(10)
1211
+ CompletedAt?: Date;
1212
+
1213
+ @Field(() => Boolean, {nullable: true, description: `Indicates whether the agent run completed successfully. NULL while running, TRUE/FALSE when completed.`})
1214
+ Success?: boolean;
1215
+
1216
+ @Field({nullable: true, description: `Error message if the agent run failed. NULL for successful runs.`})
1217
+ ErrorMessage?: string;
1218
+
1219
+ @Field({nullable: true, description: `Identifier linking multiple agent runs that are part of the same conversation or user session`})
1220
+ @MaxLength(16)
1221
+ ConversationID?: string;
1222
+
1223
+ @Field({nullable: true, description: `User context identifier for authentication and permissions during the agent run`})
1224
+ @MaxLength(16)
1225
+ UserID?: string;
1226
+
1227
+ @Field({nullable: true, description: `Final result or output from the agent execution, stored as JSON or text`})
1228
+ Result?: string;
1229
+
1230
+ @Field({nullable: true, description: `JSON serialization of the complete agent state, including conversation context, variables, and execution state. Enables pause/resume functionality.`})
1231
+ AgentState?: string;
1232
+
1233
+ @Field(() => Int, {nullable: true, description: `Total number of tokens consumed by all LLM calls during this agent run`})
1234
+ TotalTokensUsed?: number;
1235
+
1236
+ @Field(() => Float, {nullable: true, description: `Total estimated cost for all AI model usage during this agent run`})
1237
+ TotalCost?: number;
1238
+
1239
+ @Field()
1240
+ @MaxLength(10)
1241
+ _mj__CreatedAt: Date;
1242
+
1243
+ @Field()
1244
+ @MaxLength(10)
1245
+ _mj__UpdatedAt: Date;
1246
+
1247
+ @Field(() => [AIAgentRunStep_])
1248
+ MJ_AIAgentRunSteps_AgentRunIDArray: AIAgentRunStep_[]; // Link to MJ_AIAgentRunSteps
1249
+
1250
+ @Field(() => [AIAgentRun_])
1251
+ MJ_AIAgentRuns_ParentRunIDArray: AIAgentRun_[]; // Link to MJ_AIAgentRuns
1252
+
1253
+ @Field(() => [AIPromptRun_])
1254
+ MJ_AIPromptRuns_AgentRunIDArray: AIPromptRun_[]; // Link to MJ_AIPromptRuns
1255
+
1256
+ }
1257
+
1258
+ //****************************************************************************
1259
+ // INPUT TYPE for MJ: AI Agent Runs
1260
+ //****************************************************************************
1261
+ @InputType()
1262
+ export class CreateAIAgentRunInput {
1263
+ @Field({ nullable: true })
1264
+ AgentID?: string;
1265
+
1266
+ @Field({ nullable: true })
1267
+ ParentRunID: string | null;
1268
+
1269
+ @Field({ nullable: true })
1270
+ Status?: string;
1271
+
1272
+ @Field({ nullable: true })
1273
+ StartedAt?: Date;
1274
+
1275
+ @Field({ nullable: true })
1276
+ CompletedAt: Date | null;
1277
+
1278
+ @Field(() => Boolean, { nullable: true })
1279
+ Success: boolean | null;
1280
+
1281
+ @Field({ nullable: true })
1282
+ ErrorMessage: string | null;
1283
+
1284
+ @Field({ nullable: true })
1285
+ ConversationID: string | null;
1286
+
1287
+ @Field({ nullable: true })
1288
+ UserID: string | null;
1289
+
1290
+ @Field({ nullable: true })
1291
+ Result: string | null;
1292
+
1293
+ @Field({ nullable: true })
1294
+ AgentState: string | null;
1295
+
1296
+ @Field(() => Int, { nullable: true })
1297
+ TotalTokensUsed?: number | null;
1298
+
1299
+ @Field(() => Float, { nullable: true })
1300
+ TotalCost?: number | null;
1301
+ }
1302
+
1303
+
1304
+ //****************************************************************************
1305
+ // INPUT TYPE for MJ: AI Agent Runs
1306
+ //****************************************************************************
1307
+ @InputType()
1308
+ export class UpdateAIAgentRunInput {
1309
+ @Field()
1310
+ ID: string;
1311
+
1312
+ @Field({ nullable: true })
1313
+ AgentID?: string;
1314
+
1315
+ @Field({ nullable: true })
1316
+ ParentRunID?: string | null;
1317
+
1318
+ @Field({ nullable: true })
1319
+ Status?: string;
1320
+
1321
+ @Field({ nullable: true })
1322
+ StartedAt?: Date;
1323
+
1324
+ @Field({ nullable: true })
1325
+ CompletedAt?: Date | null;
1326
+
1327
+ @Field(() => Boolean, { nullable: true })
1328
+ Success?: boolean | null;
1329
+
1330
+ @Field({ nullable: true })
1331
+ ErrorMessage?: string | null;
1332
+
1333
+ @Field({ nullable: true })
1334
+ ConversationID?: string | null;
1335
+
1336
+ @Field({ nullable: true })
1337
+ UserID?: string | null;
1338
+
1339
+ @Field({ nullable: true })
1340
+ Result?: string | null;
1341
+
1342
+ @Field({ nullable: true })
1343
+ AgentState?: string | null;
1344
+
1345
+ @Field(() => Int, { nullable: true })
1346
+ TotalTokensUsed?: number | null;
1347
+
1348
+ @Field(() => Float, { nullable: true })
1349
+ TotalCost?: number | null;
1350
+
1351
+ @Field(() => [KeyValuePairInput], { nullable: true })
1352
+ OldValues___?: KeyValuePairInput[];
1353
+ }
1354
+
1355
+ //****************************************************************************
1356
+ // RESOLVER for MJ: AI Agent Runs
1357
+ //****************************************************************************
1358
+ @ObjectType()
1359
+ export class RunAIAgentRunViewResult {
1360
+ @Field(() => [AIAgentRun_])
1361
+ Results: AIAgentRun_[];
1362
+
1363
+ @Field(() => String, {nullable: true})
1364
+ UserViewRunID?: string;
1365
+
1366
+ @Field(() => Int, {nullable: true})
1367
+ RowCount: number;
1368
+
1369
+ @Field(() => Int, {nullable: true})
1370
+ TotalRowCount: number;
1371
+
1372
+ @Field(() => Int, {nullable: true})
1373
+ ExecutionTime: number;
1374
+
1375
+ @Field({nullable: true})
1376
+ ErrorMessage?: string;
1377
+
1378
+ @Field(() => Boolean, {nullable: false})
1379
+ Success: boolean;
1380
+ }
1381
+
1382
+ @Resolver(AIAgentRun_)
1383
+ export class AIAgentRunResolver extends ResolverBase {
1384
+ @Query(() => RunAIAgentRunViewResult)
1385
+ async RunAIAgentRunViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1386
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1387
+ return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
1388
+ }
1389
+
1390
+ @Query(() => RunAIAgentRunViewResult)
1391
+ async RunAIAgentRunViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1392
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1393
+ return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
1394
+ }
1395
+
1396
+ @Query(() => RunAIAgentRunViewResult)
1397
+ async RunAIAgentRunDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1398
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1399
+ input.EntityName = 'MJ: AI Agent Runs';
1400
+ return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
1401
+ }
1402
+ @Query(() => AIAgentRun_, { nullable: true })
1403
+ async AIAgentRun(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<AIAgentRun_ | null> {
1404
+ this.CheckUserReadPermissions('MJ: AI Agent Runs', userPayload);
1405
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1406
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRuns] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Runs', userPayload, EntityPermissionType.Read, 'AND');
1407
+ const result = this.MapFieldNamesToCodeNames('MJ: AI Agent Runs', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
1408
+ return result;
1409
+ }
1410
+
1411
+ @FieldResolver(() => [AIAgentRunStep_])
1412
+ async MJ_AIAgentRunSteps_AgentRunIDArray(@Root() aiagentrun_: AIAgentRun_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1413
+ this.CheckUserReadPermissions('MJ: AI Agent Run Steps', userPayload);
1414
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1415
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRunSteps] WHERE [AgentRunID]='${aiagentrun_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Run Steps', userPayload, EntityPermissionType.Read, 'AND');
1416
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Run Steps', await dataSource.query(sSQL));
1417
+ return result;
1418
+ }
1419
+
1420
+ @FieldResolver(() => [AIAgentRun_])
1421
+ async MJ_AIAgentRuns_ParentRunIDArray(@Root() aiagentrun_: AIAgentRun_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1422
+ this.CheckUserReadPermissions('MJ: AI Agent Runs', userPayload);
1423
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1424
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRuns] WHERE [ParentRunID]='${aiagentrun_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Runs', userPayload, EntityPermissionType.Read, 'AND');
1425
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Runs', await dataSource.query(sSQL));
1426
+ return result;
1427
+ }
1428
+
1429
+ @FieldResolver(() => [AIPromptRun_])
1430
+ async MJ_AIPromptRuns_AgentRunIDArray(@Root() aiagentrun_: AIAgentRun_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1431
+ this.CheckUserReadPermissions('MJ: AI Prompt Runs', userPayload);
1432
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
1433
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIPromptRuns] WHERE [AgentRunID]='${aiagentrun_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Prompt Runs', userPayload, EntityPermissionType.Read, 'AND');
1434
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Prompt Runs', await dataSource.query(sSQL));
1435
+ return result;
1436
+ }
1437
+
1438
+ @Mutation(() => AIAgentRun_)
1439
+ async CreateAIAgentRun(
1440
+ @Arg('input', () => CreateAIAgentRunInput) input: CreateAIAgentRunInput,
1441
+ @Ctx() { dataSources, userPayload }: AppContext,
1442
+ @PubSub() pubSub: PubSubEngine
1443
+ ) {
1444
+ const dataSource = GetReadWriteDataSource(dataSources);
1445
+ return this.CreateRecord('MJ: AI Agent Runs', input, dataSource, userPayload, pubSub)
1446
+ }
1447
+
1448
+ @Mutation(() => AIAgentRun_)
1449
+ async UpdateAIAgentRun(
1450
+ @Arg('input', () => UpdateAIAgentRunInput) input: UpdateAIAgentRunInput,
1451
+ @Ctx() { dataSources, userPayload }: AppContext,
1452
+ @PubSub() pubSub: PubSubEngine
1453
+ ) {
1454
+ const dataSource = GetReadWriteDataSource(dataSources);
1455
+ return this.UpdateRecord('MJ: AI Agent Runs', input, dataSource, userPayload, pubSub);
1456
+ }
1457
+
1458
+ @Mutation(() => AIAgentRun_)
1459
+ async DeleteAIAgentRun(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1460
+ const dataSource = GetReadWriteDataSource(dataSources);
1461
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
1462
+ return this.DeleteRecord('MJ: AI Agent Runs', key, options, dataSource, userPayload, pubSub);
1463
+ }
1464
+
1465
+ }
1466
+
1184
1467
  //****************************************************************************
1185
1468
  // ENTITY CLASS for MJ: AI Vendors
1186
1469
  //****************************************************************************
@@ -1687,6 +1970,10 @@ export class AIAgent_ {
1687
1970
  @Field(() => Int, {nullable: true, description: `Number of recent messages to keep uncompressed when context compression is applied.`})
1688
1971
  ContextCompressionMessageRetentionCount?: number;
1689
1972
 
1973
+ @Field({description: `Reference to the AIAgentType that defines the category and system-level behavior for this agent. Cannot be null.`})
1974
+ @MaxLength(16)
1975
+ TypeID: string;
1976
+
1690
1977
  @Field({nullable: true})
1691
1978
  @MaxLength(510)
1692
1979
  Parent?: string;
@@ -1710,6 +1997,9 @@ export class AIAgent_ {
1710
1997
  @Field(() => [AIAgentPrompt_])
1711
1998
  MJ_AIAgentPrompts_AgentIDArray: AIAgentPrompt_[]; // Link to MJ_AIAgentPrompts
1712
1999
 
2000
+ @Field(() => [AIAgentRun_])
2001
+ MJ_AIAgentRuns_AgentIDArray: AIAgentRun_[]; // Link to MJ_AIAgentRuns
2002
+
1713
2003
  @Field(() => [AIAgentNote_])
1714
2004
  AIAgentNotes_AgentIDArray: AIAgentNote_[]; // Link to AIAgentNotes
1715
2005
 
@@ -1761,6 +2051,9 @@ export class CreateAIAgentInput {
1761
2051
 
1762
2052
  @Field(() => Int, { nullable: true })
1763
2053
  ContextCompressionMessageRetentionCount: number | null;
2054
+
2055
+ @Field({ nullable: true })
2056
+ TypeID?: string;
1764
2057
  }
1765
2058
 
1766
2059
 
@@ -1805,6 +2098,9 @@ export class UpdateAIAgentInput {
1805
2098
  @Field(() => Int, { nullable: true })
1806
2099
  ContextCompressionMessageRetentionCount?: number | null;
1807
2100
 
2101
+ @Field({ nullable: true })
2102
+ TypeID?: string;
2103
+
1808
2104
  @Field(() => [KeyValuePairInput], { nullable: true })
1809
2105
  OldValues___?: KeyValuePairInput[];
1810
2106
  }
@@ -1910,6 +2206,15 @@ export class AIAgentResolver extends ResolverBase {
1910
2206
  return result;
1911
2207
  }
1912
2208
 
2209
+ @FieldResolver(() => [AIAgentRun_])
2210
+ async MJ_AIAgentRuns_AgentIDArray(@Root() aiagent_: AIAgent_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2211
+ this.CheckUserReadPermissions('MJ: AI Agent Runs', userPayload);
2212
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2213
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRuns] WHERE [AgentID]='${aiagent_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Runs', userPayload, EntityPermissionType.Read, 'AND');
2214
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Runs', await dataSource.query(sSQL));
2215
+ return result;
2216
+ }
2217
+
1913
2218
  @FieldResolver(() => [AIAgentNote_])
1914
2219
  async AIAgentNotes_AgentIDArray(@Root() aiagent_: AIAgent_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
1915
2220
  this.CheckUserReadPermissions('AI Agent Notes', userPayload);
@@ -2220,6 +2525,179 @@ export class AIPromptModelResolver extends ResolverBase {
2220
2525
 
2221
2526
  }
2222
2527
 
2528
+ //****************************************************************************
2529
+ // ENTITY CLASS for MJ: AI Agent Types
2530
+ //****************************************************************************
2531
+ @ObjectType()
2532
+ export class AIAgentType_ {
2533
+ @Field({description: `Unique identifier for the agent type`})
2534
+ @MaxLength(16)
2535
+ ID: string;
2536
+
2537
+ @Field({description: `Unique name of the agent type (e.g., "Base", "CustomerSupport", "DataAnalysis"). Used for programmatic identification and factory instantiation.`})
2538
+ @MaxLength(200)
2539
+ Name: string;
2540
+
2541
+ @Field({nullable: true, description: `Detailed description of the agent type, its purpose, and typical use cases`})
2542
+ Description?: string;
2543
+
2544
+ @Field({nullable: true, description: `Reference to the AI Prompt that contains the system-level instructions for all agents of this type. This prompt will be blended with individual agent prompts.`})
2545
+ @MaxLength(16)
2546
+ SystemPromptID?: string;
2547
+
2548
+ @Field(() => Boolean, {description: `Indicates whether this agent type is available for use. Inactive types cannot be assigned to new agents.`})
2549
+ IsActive: boolean;
2550
+
2551
+ @Field()
2552
+ @MaxLength(10)
2553
+ _mj__CreatedAt: Date;
2554
+
2555
+ @Field()
2556
+ @MaxLength(10)
2557
+ _mj__UpdatedAt: Date;
2558
+
2559
+ @Field(() => [AIAgent_])
2560
+ AIAgents_TypeIDArray: AIAgent_[]; // Link to AIAgents
2561
+
2562
+ }
2563
+
2564
+ //****************************************************************************
2565
+ // INPUT TYPE for MJ: AI Agent Types
2566
+ //****************************************************************************
2567
+ @InputType()
2568
+ export class CreateAIAgentTypeInput {
2569
+ @Field({ nullable: true })
2570
+ Name?: string;
2571
+
2572
+ @Field({ nullable: true })
2573
+ Description: string | null;
2574
+
2575
+ @Field({ nullable: true })
2576
+ SystemPromptID: string | null;
2577
+
2578
+ @Field(() => Boolean, { nullable: true })
2579
+ IsActive?: boolean;
2580
+ }
2581
+
2582
+
2583
+ //****************************************************************************
2584
+ // INPUT TYPE for MJ: AI Agent Types
2585
+ //****************************************************************************
2586
+ @InputType()
2587
+ export class UpdateAIAgentTypeInput {
2588
+ @Field()
2589
+ ID: string;
2590
+
2591
+ @Field({ nullable: true })
2592
+ Name?: string;
2593
+
2594
+ @Field({ nullable: true })
2595
+ Description?: string | null;
2596
+
2597
+ @Field({ nullable: true })
2598
+ SystemPromptID?: string | null;
2599
+
2600
+ @Field(() => Boolean, { nullable: true })
2601
+ IsActive?: boolean;
2602
+
2603
+ @Field(() => [KeyValuePairInput], { nullable: true })
2604
+ OldValues___?: KeyValuePairInput[];
2605
+ }
2606
+
2607
+ //****************************************************************************
2608
+ // RESOLVER for MJ: AI Agent Types
2609
+ //****************************************************************************
2610
+ @ObjectType()
2611
+ export class RunAIAgentTypeViewResult {
2612
+ @Field(() => [AIAgentType_])
2613
+ Results: AIAgentType_[];
2614
+
2615
+ @Field(() => String, {nullable: true})
2616
+ UserViewRunID?: string;
2617
+
2618
+ @Field(() => Int, {nullable: true})
2619
+ RowCount: number;
2620
+
2621
+ @Field(() => Int, {nullable: true})
2622
+ TotalRowCount: number;
2623
+
2624
+ @Field(() => Int, {nullable: true})
2625
+ ExecutionTime: number;
2626
+
2627
+ @Field({nullable: true})
2628
+ ErrorMessage?: string;
2629
+
2630
+ @Field(() => Boolean, {nullable: false})
2631
+ Success: boolean;
2632
+ }
2633
+
2634
+ @Resolver(AIAgentType_)
2635
+ export class AIAgentTypeResolver extends ResolverBase {
2636
+ @Query(() => RunAIAgentTypeViewResult)
2637
+ async RunAIAgentTypeViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2638
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2639
+ return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
2640
+ }
2641
+
2642
+ @Query(() => RunAIAgentTypeViewResult)
2643
+ async RunAIAgentTypeViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2644
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2645
+ return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
2646
+ }
2647
+
2648
+ @Query(() => RunAIAgentTypeViewResult)
2649
+ async RunAIAgentTypeDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2650
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2651
+ input.EntityName = 'MJ: AI Agent Types';
2652
+ return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
2653
+ }
2654
+ @Query(() => AIAgentType_, { nullable: true })
2655
+ async AIAgentType(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<AIAgentType_ | null> {
2656
+ this.CheckUserReadPermissions('MJ: AI Agent Types', userPayload);
2657
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2658
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentTypes] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Types', userPayload, EntityPermissionType.Read, 'AND');
2659
+ const result = this.MapFieldNamesToCodeNames('MJ: AI Agent Types', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
2660
+ return result;
2661
+ }
2662
+
2663
+ @FieldResolver(() => [AIAgent_])
2664
+ async AIAgents_TypeIDArray(@Root() aiagenttype_: AIAgentType_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2665
+ this.CheckUserReadPermissions('AI Agents', userPayload);
2666
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
2667
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgents] WHERE [TypeID]='${aiagenttype_.ID}' ` + this.getRowLevelSecurityWhereClause('AI Agents', userPayload, EntityPermissionType.Read, 'AND');
2668
+ const result = this.ArrayMapFieldNamesToCodeNames('AI Agents', await dataSource.query(sSQL));
2669
+ return result;
2670
+ }
2671
+
2672
+ @Mutation(() => AIAgentType_)
2673
+ async CreateAIAgentType(
2674
+ @Arg('input', () => CreateAIAgentTypeInput) input: CreateAIAgentTypeInput,
2675
+ @Ctx() { dataSources, userPayload }: AppContext,
2676
+ @PubSub() pubSub: PubSubEngine
2677
+ ) {
2678
+ const dataSource = GetReadWriteDataSource(dataSources);
2679
+ return this.CreateRecord('MJ: AI Agent Types', input, dataSource, userPayload, pubSub)
2680
+ }
2681
+
2682
+ @Mutation(() => AIAgentType_)
2683
+ async UpdateAIAgentType(
2684
+ @Arg('input', () => UpdateAIAgentTypeInput) input: UpdateAIAgentTypeInput,
2685
+ @Ctx() { dataSources, userPayload }: AppContext,
2686
+ @PubSub() pubSub: PubSubEngine
2687
+ ) {
2688
+ const dataSource = GetReadWriteDataSource(dataSources);
2689
+ return this.UpdateRecord('MJ: AI Agent Types', input, dataSource, userPayload, pubSub);
2690
+ }
2691
+
2692
+ @Mutation(() => AIAgentType_)
2693
+ async DeleteAIAgentType(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
2694
+ const dataSource = GetReadWriteDataSource(dataSources);
2695
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
2696
+ return this.DeleteRecord('MJ: AI Agent Types', key, options, dataSource, userPayload, pubSub);
2697
+ }
2698
+
2699
+ }
2700
+
2223
2701
  //****************************************************************************
2224
2702
  // ENTITY CLASS for AI Agent Notes
2225
2703
  //****************************************************************************
@@ -2688,6 +3166,14 @@ export class AIPrompt_ {
2688
3166
  @Field(() => Boolean, {description: `When true, the configuration must match for a cache hit. When false, results from any configuration can be used.`})
2689
3167
  CacheMustMatchConfig: boolean;
2690
3168
 
3169
+ @Field({description: `Determines how the prompt is used in conversation: System (always first message), User (positioned by PromptPosition), Assistant (positioned by PromptPosition), or SystemOrUser (try system first, fallback to user last if system slot taken)`})
3170
+ @MaxLength(40)
3171
+ PromptRole: string;
3172
+
3173
+ @Field({description: `Controls message placement for User and Assistant role prompts: First (beginning of conversation) or Last (end of conversation). Not used for System role prompts which are always first`})
3174
+ @MaxLength(40)
3175
+ PromptPosition: string;
3176
+
2691
3177
  @Field()
2692
3178
  @MaxLength(510)
2693
3179
  Template: string;
@@ -2711,6 +3197,9 @@ export class AIPrompt_ {
2711
3197
  @Field(() => [AIResultCache_])
2712
3198
  AIResultCache_AIPromptIDArray: AIResultCache_[]; // Link to AIResultCache
2713
3199
 
3200
+ @Field(() => [AIAgentType_])
3201
+ MJ_AIAgentTypes_SystemPromptIDArray: AIAgentType_[]; // Link to MJ_AIAgentTypes
3202
+
2714
3203
  @Field(() => [AIConfiguration_])
2715
3204
  MJ_AIConfigurations_DefaultPromptForContextCompressionIDArray: AIConfiguration_[]; // Link to MJ_AIConfigurations
2716
3205
 
@@ -2828,6 +3317,12 @@ export class CreateAIPromptInput {
2828
3317
 
2829
3318
  @Field(() => Boolean, { nullable: true })
2830
3319
  CacheMustMatchConfig?: boolean;
3320
+
3321
+ @Field({ nullable: true })
3322
+ PromptRole?: string;
3323
+
3324
+ @Field({ nullable: true })
3325
+ PromptPosition?: string;
2831
3326
  }
2832
3327
 
2833
3328
 
@@ -2929,6 +3424,12 @@ export class UpdateAIPromptInput {
2929
3424
  @Field(() => Boolean, { nullable: true })
2930
3425
  CacheMustMatchConfig?: boolean;
2931
3426
 
3427
+ @Field({ nullable: true })
3428
+ PromptRole?: string;
3429
+
3430
+ @Field({ nullable: true })
3431
+ PromptPosition?: string;
3432
+
2932
3433
  @Field(() => [KeyValuePairInput], { nullable: true })
2933
3434
  OldValues___?: KeyValuePairInput[];
2934
3435
  }
@@ -2998,6 +3499,15 @@ export class AIPromptResolver extends ResolverBase {
2998
3499
  return result;
2999
3500
  }
3000
3501
 
3502
+ @FieldResolver(() => [AIAgentType_])
3503
+ async MJ_AIAgentTypes_SystemPromptIDArray(@Root() aiprompt_: AIPrompt_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3504
+ this.CheckUserReadPermissions('MJ: AI Agent Types', userPayload);
3505
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
3506
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentTypes] WHERE [SystemPromptID]='${aiprompt_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Types', userPayload, EntityPermissionType.Read, 'AND');
3507
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Types', await dataSource.query(sSQL));
3508
+ return result;
3509
+ }
3510
+
3001
3511
  @FieldResolver(() => [AIConfiguration_])
3002
3512
  async MJ_AIConfigurations_DefaultPromptForContextCompressionIDArray(@Root() aiprompt_: AIPrompt_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
3003
3513
  this.CheckUserReadPermissions('MJ: AI Configurations', userPayload);
@@ -7522,6 +8032,9 @@ export class User_ {
7522
8032
  @Field(() => [ConversationDetail_])
7523
8033
  ConversationDetails_UserIDArray: ConversationDetail_[]; // Link to ConversationDetails
7524
8034
 
8035
+ @Field(() => [AIAgentRun_])
8036
+ MJ_AIAgentRuns_UserIDArray: AIAgentRun_[]; // Link to MJ_AIAgentRuns
8037
+
7525
8038
  }
7526
8039
 
7527
8040
  //****************************************************************************
@@ -8043,6 +8556,15 @@ export class UserResolverBase extends ResolverBase {
8043
8556
  return result;
8044
8557
  }
8045
8558
 
8559
+ @FieldResolver(() => [AIAgentRun_])
8560
+ async MJ_AIAgentRuns_UserIDArray(@Root() user_: User_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
8561
+ this.CheckUserReadPermissions('MJ: AI Agent Runs', userPayload);
8562
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
8563
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRuns] WHERE [UserID]='${user_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Runs', userPayload, EntityPermissionType.Read, 'AND');
8564
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Runs', await dataSource.query(sSQL));
8565
+ return result;
8566
+ }
8567
+
8046
8568
  @Mutation(() => User_)
8047
8569
  async CreateUser(
8048
8570
  @Arg('input', () => CreateUserInput) input: CreateUserInput,
@@ -17396,6 +17918,9 @@ export class Conversation_ {
17396
17918
  @Field(() => [ConversationArtifact_])
17397
17919
  MJ_ConversationArtifacts_ConversationIDArray: ConversationArtifact_[]; // Link to MJ_ConversationArtifacts
17398
17920
 
17921
+ @Field(() => [AIAgentRun_])
17922
+ MJ_AIAgentRuns_ConversationIDArray: AIAgentRun_[]; // Link to MJ_AIAgentRuns
17923
+
17399
17924
  }
17400
17925
 
17401
17926
  //****************************************************************************
@@ -17560,6 +18085,15 @@ export class ConversationResolver extends ResolverBase {
17560
18085
  return result;
17561
18086
  }
17562
18087
 
18088
+ @FieldResolver(() => [AIAgentRun_])
18089
+ async MJ_AIAgentRuns_ConversationIDArray(@Root() conversation_: Conversation_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
18090
+ this.CheckUserReadPermissions('MJ: AI Agent Runs', userPayload);
18091
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
18092
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRuns] WHERE [ConversationID]='${conversation_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Runs', userPayload, EntityPermissionType.Read, 'AND');
18093
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Agent Runs', await dataSource.query(sSQL));
18094
+ return result;
18095
+ }
18096
+
17563
18097
  @Mutation(() => Conversation_)
17564
18098
  async CreateConversation(
17565
18099
  @Arg('input', () => CreateConversationInput) input: CreateConversationInput,
@@ -20584,6 +21118,10 @@ export class DataContextItem_ {
20584
21118
  @Field({nullable: true})
20585
21119
  Description?: string;
20586
21120
 
21121
+ @Field({nullable: true, description: `Optional programmatic identifier for this data context item. Must be unique within the DataContext and follow JavaScript naming conventions (letters, numbers, underscore, starting with letter or underscore). Used for improved code generation and programmatic access to data context items.`})
21122
+ @MaxLength(510)
21123
+ CodeName?: string;
21124
+
20587
21125
  @Field()
20588
21126
  @MaxLength(510)
20589
21127
  DataContext: string;
@@ -20636,6 +21174,9 @@ export class CreateDataContextItemInput {
20636
21174
 
20637
21175
  @Field({ nullable: true })
20638
21176
  Description: string | null;
21177
+
21178
+ @Field({ nullable: true })
21179
+ CodeName: string | null;
20639
21180
  }
20640
21181
 
20641
21182
 
@@ -20677,6 +21218,9 @@ export class UpdateDataContextItemInput {
20677
21218
  @Field({ nullable: true })
20678
21219
  Description?: string | null;
20679
21220
 
21221
+ @Field({ nullable: true })
21222
+ CodeName?: string | null;
21223
+
20680
21224
  @Field(() => [KeyValuePairInput], { nullable: true })
20681
21225
  OldValues___?: KeyValuePairInput[];
20682
21226
  }
@@ -31258,6 +31802,10 @@ export class AIModelVendor_ {
31258
31802
  @MaxLength(10)
31259
31803
  _mj__UpdatedAt: Date;
31260
31804
 
31805
+ @Field({nullable: true, description: `References the type/role of the vendor for this model (e.g., model developer, inference provider)`})
31806
+ @MaxLength(16)
31807
+ TypeID?: string;
31808
+
31261
31809
  @Field()
31262
31810
  @MaxLength(100)
31263
31811
  Model: string;
@@ -31266,6 +31814,10 @@ export class AIModelVendor_ {
31266
31814
  @MaxLength(100)
31267
31815
  Vendor: string;
31268
31816
 
31817
+ @Field({nullable: true})
31818
+ @MaxLength(100)
31819
+ Type?: string;
31820
+
31269
31821
  }
31270
31822
 
31271
31823
  //****************************************************************************
@@ -31308,6 +31860,9 @@ export class CreateAIModelVendorInput {
31308
31860
 
31309
31861
  @Field(() => Boolean, { nullable: true })
31310
31862
  SupportsStreaming?: boolean;
31863
+
31864
+ @Field({ nullable: true })
31865
+ TypeID: string | null;
31311
31866
  }
31312
31867
 
31313
31868
 
@@ -31355,6 +31910,9 @@ export class UpdateAIModelVendorInput {
31355
31910
  @Field(() => Boolean, { nullable: true })
31356
31911
  SupportsStreaming?: boolean;
31357
31912
 
31913
+ @Field({ nullable: true })
31914
+ TypeID?: string | null;
31915
+
31358
31916
  @Field(() => [KeyValuePairInput], { nullable: true })
31359
31917
  OldValues___?: KeyValuePairInput[];
31360
31918
  }
@@ -31468,6 +32026,9 @@ export class AIVendorTypeDefinition_ {
31468
32026
  @MaxLength(10)
31469
32027
  _mj__UpdatedAt: Date;
31470
32028
 
32029
+ @Field(() => [AIModelVendor_])
32030
+ MJ_AIModelVendors_TypeIDArray: AIModelVendor_[]; // Link to MJ_AIModelVendors
32031
+
31471
32032
  @Field(() => [AIVendorType_])
31472
32033
  MJ_AIVendorTypes_TypeIDArray: AIVendorType_[]; // Link to MJ_AIVendorTypes
31473
32034
 
@@ -31560,6 +32121,15 @@ export class AIVendorTypeDefinitionResolver extends ResolverBase {
31560
32121
  return result;
31561
32122
  }
31562
32123
 
32124
+ @FieldResolver(() => [AIModelVendor_])
32125
+ async MJ_AIModelVendors_TypeIDArray(@Root() aivendortypedefinition_: AIVendorTypeDefinition_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
32126
+ this.CheckUserReadPermissions('MJ: AI Model Vendors', userPayload);
32127
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
32128
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIModelVendors] WHERE [TypeID]='${aivendortypedefinition_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Model Vendors', userPayload, EntityPermissionType.Read, 'AND');
32129
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Model Vendors', await dataSource.query(sSQL));
32130
+ return result;
32131
+ }
32132
+
31563
32133
  @FieldResolver(() => [AIVendorType_])
31564
32134
  async MJ_AIVendorTypes_TypeIDArray(@Root() aivendortypedefinition_: AIVendorTypeDefinition_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
31565
32135
  this.CheckUserReadPermissions('MJ: AI Vendor Types', userPayload);
@@ -35314,6 +35884,21 @@ export class AIPromptRun_ {
35314
35884
  @MaxLength(10)
35315
35885
  _mj__UpdatedAt: Date;
35316
35886
 
35887
+ @Field({nullable: true, description: `References the parent AIPromptRun.ID for hierarchical execution tracking. NULL for top-level runs, populated for parallel children and result selector runs.`})
35888
+ @MaxLength(16)
35889
+ ParentID?: string;
35890
+
35891
+ @Field({description: `Type of prompt run execution: Single (standard single prompt), ParallelParent (coordinator for parallel execution), ParallelChild (individual parallel execution), ResultSelector (result selection prompt that chooses best result)`})
35892
+ @MaxLength(40)
35893
+ RunType: string;
35894
+
35895
+ @Field(() => Int, {nullable: true, description: `Execution order for parallel child runs and result selector runs. Used to track the sequence of execution within a parallel run group. NULL for single runs and parallel parent runs.`})
35896
+ ExecutionOrder?: number;
35897
+
35898
+ @Field({nullable: true, description: `Optional reference to the AIAgentRun that initiated this prompt execution. Links prompt runs to their parent agent runs for comprehensive execution tracking.`})
35899
+ @MaxLength(16)
35900
+ AgentRunID?: string;
35901
+
35317
35902
  @Field()
35318
35903
  @MaxLength(510)
35319
35904
  Prompt: string;
@@ -35334,6 +35919,9 @@ export class AIPromptRun_ {
35334
35919
  @MaxLength(200)
35335
35920
  Configuration?: string;
35336
35921
 
35922
+ @Field(() => [AIPromptRun_])
35923
+ MJ_AIPromptRuns_ParentIDArray: AIPromptRun_[]; // Link to MJ_AIPromptRuns
35924
+
35337
35925
  @Field(() => [AIResultCache_])
35338
35926
  AIResultCache_PromptRunIDArray: AIResultCache_[]; // Link to AIResultCache
35339
35927
 
@@ -35391,6 +35979,18 @@ export class CreateAIPromptRunInput {
35391
35979
 
35392
35980
  @Field({ nullable: true })
35393
35981
  ErrorMessage: string | null;
35982
+
35983
+ @Field({ nullable: true })
35984
+ ParentID: string | null;
35985
+
35986
+ @Field({ nullable: true })
35987
+ RunType?: string;
35988
+
35989
+ @Field(() => Int, { nullable: true })
35990
+ ExecutionOrder: number | null;
35991
+
35992
+ @Field({ nullable: true })
35993
+ AgentRunID: string | null;
35394
35994
  }
35395
35995
 
35396
35996
 
@@ -35450,6 +36050,18 @@ export class UpdateAIPromptRunInput {
35450
36050
  @Field({ nullable: true })
35451
36051
  ErrorMessage?: string | null;
35452
36052
 
36053
+ @Field({ nullable: true })
36054
+ ParentID?: string | null;
36055
+
36056
+ @Field({ nullable: true })
36057
+ RunType?: string;
36058
+
36059
+ @Field(() => Int, { nullable: true })
36060
+ ExecutionOrder?: number | null;
36061
+
36062
+ @Field({ nullable: true })
36063
+ AgentRunID?: string | null;
36064
+
35453
36065
  @Field(() => [KeyValuePairInput], { nullable: true })
35454
36066
  OldValues___?: KeyValuePairInput[];
35455
36067
  }
@@ -35510,6 +36122,15 @@ export class AIPromptRunResolver extends ResolverBase {
35510
36122
  return result;
35511
36123
  }
35512
36124
 
36125
+ @FieldResolver(() => [AIPromptRun_])
36126
+ async MJ_AIPromptRuns_ParentIDArray(@Root() aipromptrun_: AIPromptRun_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
36127
+ this.CheckUserReadPermissions('MJ: AI Prompt Runs', userPayload);
36128
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36129
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIPromptRuns] WHERE [ParentID]='${aipromptrun_.ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Prompt Runs', userPayload, EntityPermissionType.Read, 'AND');
36130
+ const result = this.ArrayMapFieldNamesToCodeNames('MJ: AI Prompt Runs', await dataSource.query(sSQL));
36131
+ return result;
36132
+ }
36133
+
35513
36134
  @FieldResolver(() => [AIResultCache_])
35514
36135
  async AIResultCache_PromptRunIDArray(@Root() aipromptrun_: AIPromptRun_, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
35515
36136
  this.CheckUserReadPermissions('AI Result Cache', userPayload);
@@ -35548,6 +36169,244 @@ export class AIPromptRunResolver extends ResolverBase {
35548
36169
 
35549
36170
  }
35550
36171
 
36172
+ //****************************************************************************
36173
+ // ENTITY CLASS for MJ: AI Agent Run Steps
36174
+ //****************************************************************************
36175
+ @ObjectType()
36176
+ export class AIAgentRunStep_ {
36177
+ @Field({description: `Unique identifier for this execution step`})
36178
+ @MaxLength(16)
36179
+ ID: string;
36180
+
36181
+ @Field({description: `Reference to the parent AIAgentRun that contains this step`})
36182
+ @MaxLength(16)
36183
+ AgentRunID: string;
36184
+
36185
+ @Field(() => Int, {description: `Sequential number of this step within the agent run, starting from 1`})
36186
+ StepNumber: number;
36187
+
36188
+ @Field({description: `Type of execution step: prompt, tool, subagent, decision`})
36189
+ @MaxLength(100)
36190
+ StepType: string;
36191
+
36192
+ @Field({description: `Human-readable name of what this step accomplishes`})
36193
+ @MaxLength(510)
36194
+ StepName: string;
36195
+
36196
+ @Field({nullable: true, description: `ID of the specific target being executed (AIPrompt.ID, AIAction.ID, AIAgent.ID, etc.). NULL for steps that don't target a specific entity.`})
36197
+ @MaxLength(16)
36198
+ TargetID?: string;
36199
+
36200
+ @Field({description: `Current execution status of this step: Running, Completed, Failed, Cancelled`})
36201
+ @MaxLength(100)
36202
+ Status: string;
36203
+
36204
+ @Field({description: `Timestamp when this step began execution`})
36205
+ @MaxLength(10)
36206
+ StartedAt: Date;
36207
+
36208
+ @Field({nullable: true, description: `Timestamp when this step completed. NULL while still running.`})
36209
+ @MaxLength(10)
36210
+ CompletedAt?: Date;
36211
+
36212
+ @Field(() => Boolean, {nullable: true, description: `Whether this step completed successfully. NULL while running, TRUE/FALSE when completed.`})
36213
+ Success?: boolean;
36214
+
36215
+ @Field({nullable: true, description: `Error message if this step failed. NULL for successful steps.`})
36216
+ ErrorMessage?: string;
36217
+
36218
+ @Field({nullable: true, description: `JSON serialization of input data passed to this step for execution`})
36219
+ InputData?: string;
36220
+
36221
+ @Field({nullable: true, description: `JSON serialization of the output data produced by this step`})
36222
+ OutputData?: string;
36223
+
36224
+ @Field()
36225
+ @MaxLength(10)
36226
+ _mj__CreatedAt: Date;
36227
+
36228
+ @Field()
36229
+ @MaxLength(10)
36230
+ _mj__UpdatedAt: Date;
36231
+
36232
+ }
36233
+
36234
+ //****************************************************************************
36235
+ // INPUT TYPE for MJ: AI Agent Run Steps
36236
+ //****************************************************************************
36237
+ @InputType()
36238
+ export class CreateAIAgentRunStepInput {
36239
+ @Field({ nullable: true })
36240
+ AgentRunID?: string;
36241
+
36242
+ @Field(() => Int, { nullable: true })
36243
+ StepNumber?: number;
36244
+
36245
+ @Field({ nullable: true })
36246
+ StepType?: string;
36247
+
36248
+ @Field({ nullable: true })
36249
+ StepName?: string;
36250
+
36251
+ @Field({ nullable: true })
36252
+ TargetID: string | null;
36253
+
36254
+ @Field({ nullable: true })
36255
+ Status?: string;
36256
+
36257
+ @Field({ nullable: true })
36258
+ StartedAt?: Date;
36259
+
36260
+ @Field({ nullable: true })
36261
+ CompletedAt: Date | null;
36262
+
36263
+ @Field(() => Boolean, { nullable: true })
36264
+ Success: boolean | null;
36265
+
36266
+ @Field({ nullable: true })
36267
+ ErrorMessage: string | null;
36268
+
36269
+ @Field({ nullable: true })
36270
+ InputData: string | null;
36271
+
36272
+ @Field({ nullable: true })
36273
+ OutputData: string | null;
36274
+ }
36275
+
36276
+
36277
+ //****************************************************************************
36278
+ // INPUT TYPE for MJ: AI Agent Run Steps
36279
+ //****************************************************************************
36280
+ @InputType()
36281
+ export class UpdateAIAgentRunStepInput {
36282
+ @Field()
36283
+ ID: string;
36284
+
36285
+ @Field({ nullable: true })
36286
+ AgentRunID?: string;
36287
+
36288
+ @Field(() => Int, { nullable: true })
36289
+ StepNumber?: number;
36290
+
36291
+ @Field({ nullable: true })
36292
+ StepType?: string;
36293
+
36294
+ @Field({ nullable: true })
36295
+ StepName?: string;
36296
+
36297
+ @Field({ nullable: true })
36298
+ TargetID?: string | null;
36299
+
36300
+ @Field({ nullable: true })
36301
+ Status?: string;
36302
+
36303
+ @Field({ nullable: true })
36304
+ StartedAt?: Date;
36305
+
36306
+ @Field({ nullable: true })
36307
+ CompletedAt?: Date | null;
36308
+
36309
+ @Field(() => Boolean, { nullable: true })
36310
+ Success?: boolean | null;
36311
+
36312
+ @Field({ nullable: true })
36313
+ ErrorMessage?: string | null;
36314
+
36315
+ @Field({ nullable: true })
36316
+ InputData?: string | null;
36317
+
36318
+ @Field({ nullable: true })
36319
+ OutputData?: string | null;
36320
+
36321
+ @Field(() => [KeyValuePairInput], { nullable: true })
36322
+ OldValues___?: KeyValuePairInput[];
36323
+ }
36324
+
36325
+ //****************************************************************************
36326
+ // RESOLVER for MJ: AI Agent Run Steps
36327
+ //****************************************************************************
36328
+ @ObjectType()
36329
+ export class RunAIAgentRunStepViewResult {
36330
+ @Field(() => [AIAgentRunStep_])
36331
+ Results: AIAgentRunStep_[];
36332
+
36333
+ @Field(() => String, {nullable: true})
36334
+ UserViewRunID?: string;
36335
+
36336
+ @Field(() => Int, {nullable: true})
36337
+ RowCount: number;
36338
+
36339
+ @Field(() => Int, {nullable: true})
36340
+ TotalRowCount: number;
36341
+
36342
+ @Field(() => Int, {nullable: true})
36343
+ ExecutionTime: number;
36344
+
36345
+ @Field({nullable: true})
36346
+ ErrorMessage?: string;
36347
+
36348
+ @Field(() => Boolean, {nullable: false})
36349
+ Success: boolean;
36350
+ }
36351
+
36352
+ @Resolver(AIAgentRunStep_)
36353
+ export class AIAgentRunStepResolver extends ResolverBase {
36354
+ @Query(() => RunAIAgentRunStepViewResult)
36355
+ async RunAIAgentRunStepViewByID(@Arg('input', () => RunViewByIDInput) input: RunViewByIDInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
36356
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36357
+ return super.RunViewByIDGeneric(input, dataSource, userPayload, pubSub);
36358
+ }
36359
+
36360
+ @Query(() => RunAIAgentRunStepViewResult)
36361
+ async RunAIAgentRunStepViewByName(@Arg('input', () => RunViewByNameInput) input: RunViewByNameInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
36362
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36363
+ return super.RunViewByNameGeneric(input, dataSource, userPayload, pubSub);
36364
+ }
36365
+
36366
+ @Query(() => RunAIAgentRunStepViewResult)
36367
+ async RunAIAgentRunStepDynamicView(@Arg('input', () => RunDynamicViewInput) input: RunDynamicViewInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
36368
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36369
+ input.EntityName = 'MJ: AI Agent Run Steps';
36370
+ return super.RunDynamicViewGeneric(input, dataSource, userPayload, pubSub);
36371
+ }
36372
+ @Query(() => AIAgentRunStep_, { nullable: true })
36373
+ async AIAgentRunStep(@Arg('ID', () => String) ID: string, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine): Promise<AIAgentRunStep_ | null> {
36374
+ this.CheckUserReadPermissions('MJ: AI Agent Run Steps', userPayload);
36375
+ const dataSource = GetReadOnlyDataSource(dataSources, { allowFallbackToReadWrite: true });
36376
+ const sSQL = `SELECT * FROM [${Metadata.Provider.ConfigData.MJCoreSchemaName}].[vwAIAgentRunSteps] WHERE [ID]='${ID}' ` + this.getRowLevelSecurityWhereClause('MJ: AI Agent Run Steps', userPayload, EntityPermissionType.Read, 'AND');
36377
+ const result = this.MapFieldNamesToCodeNames('MJ: AI Agent Run Steps', await dataSource.query(sSQL).then((r) => r && r.length > 0 ? r[0] : {}))
36378
+ return result;
36379
+ }
36380
+
36381
+ @Mutation(() => AIAgentRunStep_)
36382
+ async CreateAIAgentRunStep(
36383
+ @Arg('input', () => CreateAIAgentRunStepInput) input: CreateAIAgentRunStepInput,
36384
+ @Ctx() { dataSources, userPayload }: AppContext,
36385
+ @PubSub() pubSub: PubSubEngine
36386
+ ) {
36387
+ const dataSource = GetReadWriteDataSource(dataSources);
36388
+ return this.CreateRecord('MJ: AI Agent Run Steps', input, dataSource, userPayload, pubSub)
36389
+ }
36390
+
36391
+ @Mutation(() => AIAgentRunStep_)
36392
+ async UpdateAIAgentRunStep(
36393
+ @Arg('input', () => UpdateAIAgentRunStepInput) input: UpdateAIAgentRunStepInput,
36394
+ @Ctx() { dataSources, userPayload }: AppContext,
36395
+ @PubSub() pubSub: PubSubEngine
36396
+ ) {
36397
+ const dataSource = GetReadWriteDataSource(dataSources);
36398
+ return this.UpdateRecord('MJ: AI Agent Run Steps', input, dataSource, userPayload, pubSub);
36399
+ }
36400
+
36401
+ @Mutation(() => AIAgentRunStep_)
36402
+ async DeleteAIAgentRunStep(@Arg('ID', () => String) ID: string, @Arg('options___', () => DeleteOptionsInput) options: DeleteOptionsInput, @Ctx() { dataSources, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
36403
+ const dataSource = GetReadWriteDataSource(dataSources);
36404
+ const key = new CompositeKey([{FieldName: 'ID', Value: ID}]);
36405
+ return this.DeleteRecord('MJ: AI Agent Run Steps', key, options, dataSource, userPayload, pubSub);
36406
+ }
36407
+
36408
+ }
36409
+
35551
36410
  //****************************************************************************
35552
36411
  // ENTITY CLASS for MJ: Conversation Artifact Permissions
35553
36412
  //****************************************************************************