@yrpri/api 9.0.103 → 9.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/active-citizen/controllers/activities.cjs +0 -174
- package/dist/active-citizen/controllers/news_feeds.cjs +0 -96
- package/dist/active-citizen/controllers/notifications.cjs +0 -243
- package/dist/active-citizen/controllers/recommendations.cjs +0 -280
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +0 -204
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +0 -66
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +0 -38
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +0 -334
- package/dist/active-citizen/engine/analytics/importer.js +0 -308
- package/dist/active-citizen/engine/analytics/manager.cjs +0 -377
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +0 -500
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +0 -194
- package/dist/active-citizen/engine/analytics/utils.cjs +0 -369
- package/dist/active-citizen/engine/marketing/campaign.cjs +0 -90
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +0 -313
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +0 -239
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +0 -211
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +0 -120
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +0 -114
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +0 -101
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +0 -84
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +0 -15
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +0 -133
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +0 -185
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +0 -184
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +0 -170
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +0 -109
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +0 -140
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +0 -279
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +0 -386
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +0 -49
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +0 -68
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +0 -288
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +0 -33
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +0 -56
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +0 -106
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +0 -344
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +0 -810
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +0 -15
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +0 -362
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +0 -268
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +0 -439
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +0 -569
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +0 -233
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +0 -118
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +0 -41
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +0 -148
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +0 -54
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +0 -31
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +0 -471
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +0 -212
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +0 -153
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +0 -80
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +0 -157
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +0 -139
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +0 -212
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +0 -83
- package/dist/active-citizen/engine/reports/commonUtils.js +0 -75
- package/dist/active-citizen/engine/reports/common_utils.cjs +0 -740
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +0 -596
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +0 -232
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +0 -277
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +0 -718
- package/dist/active-citizen/llms/baseChatBot.js +0 -183
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +0 -56
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +0 -109
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +0 -84
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +0 -49
- package/dist/active-citizen/llms/imageGeneration/iImageGenerator.js +0 -1
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +0 -64
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +0 -107
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +0 -110
- package/dist/active-citizen/llms/llmTranslation.js +0 -472
- package/dist/active-citizen/models/ac_activity.cjs +0 -216
- package/dist/active-citizen/models/ac_background_job.cjs +0 -109
- package/dist/active-citizen/models/ac_campaign.cjs +0 -97
- package/dist/active-citizen/models/ac_client_activity.cjs +0 -23
- package/dist/active-citizen/models/ac_delayed_notification.cjs +0 -43
- package/dist/active-citizen/models/ac_following.cjs +0 -43
- package/dist/active-citizen/models/ac_list.cjs +0 -68
- package/dist/active-citizen/models/ac_list_users.cjs +0 -19
- package/dist/active-citizen/models/ac_mute.cjs +0 -27
- package/dist/active-citizen/models/ac_news_feed_item.cjs +0 -57
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +0 -59
- package/dist/active-citizen/models/ac_notification.cjs +0 -292
- package/dist/active-citizen/models/ac_translation_cache.cjs +0 -750
- package/dist/active-citizen/models/ac_watching.cjs +0 -31
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +0 -13
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +0 -63
- package/dist/active-citizen/scripts/kue_status.js +0 -31
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +0 -24
- package/dist/active-citizen/scripts/translation_clear_language.js +0 -117
- package/dist/active-citizen/scripts/translation_delete.js +0 -27
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +0 -180
- package/dist/active-citizen/scripts/translation_update.js +0 -28
- package/dist/active-citizen/scripts/translations_list.js +0 -27
- package/dist/active-citizen/utils/airbrake.cjs +0 -17
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +0 -21
- package/dist/active-citizen/utils/i18n.cjs +0 -3
- package/dist/active-citizen/utils/logger.cjs +0 -25
- package/dist/active-citizen/utils/redisConnection.cjs +0 -29
- package/dist/active-citizen/utils/to_json.cjs +0 -9
- package/dist/active-citizen/utils/translation_cloning.cjs +0 -171
- package/dist/active-citizen/utils/translation_helpers.cjs +0 -534
- package/dist/active-citizen/utils/truncate_text.cjs +0 -21
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +0 -253
- package/dist/active-citizen/utils/updateLocaleFolders.js +0 -34
- package/dist/active-citizen/workers/activity.cjs +0 -189
- package/dist/active-citizen/workers/anonymizations.cjs +0 -734
- package/dist/active-citizen/workers/bulk_status_update.cjs +0 -458
- package/dist/active-citizen/workers/delayed_jobs.cjs +0 -244
- package/dist/active-citizen/workers/deletions.cjs +0 -1911
- package/dist/active-citizen/workers/email.cjs +0 -9
- package/dist/active-citizen/workers/fraud_management.cjs +0 -109
- package/dist/active-citizen/workers/generativeAi.js +0 -56
- package/dist/active-citizen/workers/main.cjs +0 -89
- package/dist/active-citizen/workers/marketing.cjs +0 -25
- package/dist/active-citizen/workers/moderation.cjs +0 -73
- package/dist/active-citizen/workers/notification_delivery.cjs +0 -368
- package/dist/active-citizen/workers/notification_news_feed.cjs +0 -142
- package/dist/active-citizen/workers/queue.cjs +0 -99
- package/dist/active-citizen/workers/recount.cjs +0 -74
- package/dist/active-citizen/workers/reports.cjs +0 -42
- package/dist/active-citizen/workers/similarities.cjs +0 -21
- package/dist/active-citizen/workers/speech_to_text.cjs +0 -482
- package/dist/agents/assistants/agentAssistant.js +0 -88
- package/dist/agents/assistants/baseAssistant.js +0 -888
- package/dist/agents/assistants/baseAssistantWithVoice.js +0 -150
- package/dist/agents/assistants/modes/agentDirectConnection.js +0 -84
- package/dist/agents/assistants/modes/agentSelectionMode.js +0 -44
- package/dist/agents/assistants/modes/baseAssistantMode.js +0 -54
- package/dist/agents/assistants/modes/tools/agentTools.js +0 -447
- package/dist/agents/assistants/modes/tools/baseTools.js +0 -58
- package/dist/agents/assistants/modes/tools/loginTools.js +0 -156
- package/dist/agents/assistants/modes/tools/models/agents.js +0 -146
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +0 -332
- package/dist/agents/assistants/modes/tools/models/users.js +0 -11
- package/dist/agents/assistants/modes/tools/navigationTools.js +0 -166
- package/dist/agents/assistants/modes/tools/subscriptionTools.js +0 -323
- package/dist/agents/assistants/modes/tools/workflowConverstationTools.js +0 -112
- package/dist/agents/assistants/voiceAssistant.js +0 -619
- package/dist/agents/controllers/agentProductController.js +0 -103
- package/dist/agents/controllers/agentSubscriptionController.js +0 -261
- package/dist/agents/controllers/assistantsController.js +0 -511
- package/dist/agents/controllers/policySynthAgents.js +0 -395
- package/dist/agents/managers/agentProductManager.js +0 -91
- package/dist/agents/managers/emailInvitesManager.js +0 -55
- package/dist/agents/managers/emailTemplateRenderer.js +0 -362
- package/dist/agents/managers/newAiModelSetup.js +0 -650
- package/dist/agents/managers/notificationAgentQueueManager.js +0 -510
- package/dist/agents/managers/subscriptionManager.js +0 -535
- package/dist/agents/managers/workflowConversationManager.js +0 -79
- package/dist/agents/models/agentProduct.js +0 -116
- package/dist/agents/models/agentProductBoosterPurchase.js +0 -58
- package/dist/agents/models/agentProductBundle.js +0 -68
- package/dist/agents/models/agentProductRun.js +0 -52
- package/dist/agents/models/discount.js +0 -88
- package/dist/agents/models/subscription.js +0 -79
- package/dist/agents/models/subscriptionPlan.js +0 -46
- package/dist/agents/models/subscriptionUser.js +0 -27
- package/dist/agents/models/testData/createEvolyAgentProduct.js +0 -477
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +0 -233
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/workflowConversation.js +0 -53
- package/dist/agents/tools/setTemplateWorkflowCommunityId.js +0 -46
- package/dist/app.js +0 -943
- package/dist/authorization.cjs +0 -1860
- package/dist/bot_control.js +0 -1930
- package/dist/config/config.cjs +0 -14
- package/dist/config/config.js +0 -14
- package/dist/controllers/allOurIdeas.js +0 -696
- package/dist/controllers/audios.cjs +0 -100
- package/dist/controllers/bulkStatusUpdates.cjs +0 -202
- package/dist/controllers/categories.cjs +0 -199
- package/dist/controllers/communities.cjs +0 -2996
- package/dist/controllers/domains.cjs +0 -1341
- package/dist/controllers/externalIds.cjs +0 -223
- package/dist/controllers/groups.cjs +0 -4309
- package/dist/controllers/images.cjs +0 -499
- package/dist/controllers/index.cjs +0 -449
- package/dist/controllers/legacyPages.cjs +0 -35
- package/dist/controllers/legacyPosts.cjs +0 -56
- package/dist/controllers/legacyUsers.cjs +0 -36
- package/dist/controllers/nonSpa.cjs +0 -574
- package/dist/controllers/organizations.cjs +0 -250
- package/dist/controllers/points.cjs +0 -1137
- package/dist/controllers/posts.cjs +0 -2036
- package/dist/controllers/ratings.cjs +0 -234
- package/dist/controllers/users.cjs +0 -2255
- package/dist/controllers/videos.cjs +0 -226
- package/dist/deleteUnwantedDeclerations.cjs +0 -55
- package/dist/migrations/agentAuditLogs.cjs +0 -46
- package/dist/migrations/agentClasses.cjs +0 -60
- package/dist/migrations/agentConnectorClasses.cjs +0 -61
- package/dist/migrations/agentConnectors.cjs +0 -50
- package/dist/migrations/agentEvals.cjs +0 -45
- package/dist/migrations/agentRegistries.cjs +0 -40
- package/dist/migrations/agents.cjs +0 -54
- package/dist/migrations/aiModels.cjs +0 -49
- package/dist/migrations/apiUsage.cjs +0 -47
- package/dist/migrations/apis.cjs +0 -49
- package/dist/migrations/groupPrivateData.cjs +0 -30
- package/dist/migrations/modelUsage.cjs +0 -60
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +0 -23
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +0 -360
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +0 -29
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +0 -24
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +0 -29
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +0 -22
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +0 -23
- package/dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js +0 -18
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +0 -36
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +0 -41
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +0 -88
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +0 -33
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +0 -38
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +0 -127
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +0 -68
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +0 -63
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +0 -14
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +0 -71
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +0 -12
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +0 -46
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +0 -46
- package/dist/migrations/privateAccessStore.cjs +0 -55
- package/dist/migrations/zzz_associations.cjs +0 -154
- package/dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs +0 -100
- package/dist/migrations/zzzzz_create_agent_runs.cjs +0 -606
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +0 -11
- package/dist/migrations/zzzzzzz_create_trees.cjs +0 -81
- package/dist/models/audio.cjs +0 -430
- package/dist/models/bulk_status_update.cjs +0 -58
- package/dist/models/campaign.cjs +0 -78
- package/dist/models/category.cjs +0 -94
- package/dist/models/community.cjs +0 -337
- package/dist/models/domain.cjs +0 -486
- package/dist/models/endorsement.cjs +0 -39
- package/dist/models/general_data_store.cjs +0 -20
- package/dist/models/group.cjs +0 -728
- package/dist/models/image.cjs +0 -579
- package/dist/models/index.cjs +0 -186
- package/dist/models/invite.cjs +0 -48
- package/dist/models/iso_country.cjs +0 -16
- package/dist/models/organization.cjs +0 -122
- package/dist/models/page.cjs +0 -273
- package/dist/models/point.cjs +0 -622
- package/dist/models/point_quality.cjs +0 -39
- package/dist/models/point_revision.cjs +0 -47
- package/dist/models/post.cjs +0 -680
- package/dist/models/post_revision.cjs +0 -38
- package/dist/models/post_status_change.cjs +0 -35
- package/dist/models/promotion.cjs +0 -34
- package/dist/models/rating.cjs +0 -51
- package/dist/models/relationship.cjs +0 -19
- package/dist/models/request_to_join.cjs +0 -20
- package/dist/models/user.cjs +0 -604
- package/dist/models/user_legacy_password.cjs +0 -13
- package/dist/models/video.cjs +0 -1137
- package/dist/publish.js +0 -40
- package/dist/repack.js +0 -53
- package/dist/scripts/addRatingUsersToGroup.js +0 -51
- package/dist/scripts/addUserToOrganization.js +0 -71
- package/dist/scripts/analyseRatingsForCommunity.js +0 -150
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +0 -28
- package/dist/scripts/analyzeEndorsementsByCountry.js +0 -70
- package/dist/scripts/analyzePostsForCommunity.js +0 -185
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +0 -14
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +0 -110
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +0 -116
- package/dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +0 -124
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +0 -141
- package/dist/scripts/change/changeVideoAspectTo.js +0 -34
- package/dist/scripts/change/setUseNewVersion.cjs +0 -22
- package/dist/scripts/changeCommunityGroupcount.js +0 -30
- package/dist/scripts/changeCommunityPostCount.js +0 -30
- package/dist/scripts/changeGroupPostCount.js +0 -30
- package/dist/scripts/changeLanguage.js +0 -50
- package/dist/scripts/changeOfficalStatus.js +0 -30
- package/dist/scripts/cleanups/deleteAnonNotifications.cjs +0 -91
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +0 -62
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +0 -72
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +0 -43
- package/dist/scripts/clearAllEndorsementInGroup.js +0 -50
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +0 -129
- package/dist/scripts/cloning/cloneFromUrlScript.js +0 -65
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +0 -140
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +0 -140
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +0 -173
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +0 -18
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +0 -26
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +0 -205
- package/dist/scripts/cloning/copyPostToGroupOld.js +0 -397
- package/dist/scripts/cloning/copyPostVideosFromURL.js +0 -236
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +0 -17
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +0 -139
- package/dist/scripts/cloning/setAdminsFromURL.js +0 -161
- package/dist/scripts/cloning/setExternalIdsFromURL.js +0 -129
- package/dist/scripts/countCommunity.js +0 -291
- package/dist/scripts/countCommunityUsers.js +0 -152
- package/dist/scripts/countDelayedNotifications.js +0 -18
- package/dist/scripts/countGroup.js +0 -246
- package/dist/scripts/countStuff.js +0 -67
- package/dist/scripts/countUniqueVotersInAGroup.js +0 -48
- package/dist/scripts/createInvitesAndShow.js +0 -75
- package/dist/scripts/database/sync_database.js +0 -14
- package/dist/scripts/database/sync_dev_database.js +0 -17
- package/dist/scripts/debugNotifications.js +0 -58
- package/dist/scripts/deleteAllNewsFeeds.js +0 -10
- package/dist/scripts/deleteCategory.js +0 -13
- package/dist/scripts/deleteOldAppActivities.js +0 -40
- package/dist/scripts/deletePostContactDataForCommunity.js +0 -53
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +0 -1026
- package/dist/scripts/displayAuthorForPost.js +0 -16
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +0 -183
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +0 -208
- package/dist/scripts/exportAllStatusChanges.js +0 -36
- package/dist/scripts/exportClientAcitivity.js +0 -36
- package/dist/scripts/exportEndorsementsForCommunity.js +0 -79
- package/dist/scripts/exportPointQualitiesForCommunity.js +0 -84
- package/dist/scripts/exportPostsAndPointsForCommunity.js +0 -147
- package/dist/scripts/exportPostsDataSetForDomain.js +0 -244
- package/dist/scripts/exportPostsForGroup.js +0 -173
- package/dist/scripts/exportRatingsForPost.js +0 -15
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +0 -123
- package/dist/scripts/exportUsersForCommunity.js +0 -24
- package/dist/scripts/exportUsersForDomain.js +0 -24
- package/dist/scripts/exportUsersForGroup.js +0 -24
- package/dist/scripts/exports/ratingDistribution.js +0 -71
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +0 -56
- package/dist/scripts/findUnusedClientImports.js +0 -56
- package/dist/scripts/fixAllPostPointCounts.js +0 -22
- package/dist/scripts/fixAnonNotificationsSettings.js +0 -48
- package/dist/scripts/fixCountKopavogur.js +0 -9
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +0 -190
- package/dist/scripts/fixExternalUserId.js +0 -24
- package/dist/scripts/fixGroupAccess.js +0 -16
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +0 -49
- package/dist/scripts/fixNotificationSettings.js +0 -39
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +0 -64
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +0 -49
- package/dist/scripts/gallery/exportGalleryData.js +0 -40
- package/dist/scripts/gallery/importGalleryForCommunity.js +0 -168
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +0 -55
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +0 -58
- package/dist/scripts/genderAnalysis.js +0 -63
- package/dist/scripts/genderAnalysisByStatus.js +0 -62
- package/dist/scripts/importAllLocalesFromLocalFolders.js +0 -55
- package/dist/scripts/importDomain.js +0 -1652
- package/dist/scripts/keys/addOidcToDomain.cjs +0 -61
- package/dist/scripts/landUseGame/export3Ddata.js +0 -162
- package/dist/scripts/listLanguagesForGroup.js +0 -54
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +0 -27
- package/dist/scripts/makeRecursiveMapData.js +0 -103
- package/dist/scripts/mapping/community_map_csv.js +0 -145
- package/dist/scripts/moveCommunityToDomain.js +0 -22
- package/dist/scripts/moveGroupToCommunity.js +0 -23
- package/dist/scripts/movePostToGroup.js +0 -101
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +0 -297
- package/dist/scripts/oldMovePostToGroup.js +0 -153
- package/dist/scripts/processCsvForPdfUrls.js +0 -37
- package/dist/scripts/processCsvForTranslationAndToxicity.js +0 -125
- package/dist/scripts/recount/recount_recursive_communities.js +0 -125
- package/dist/scripts/recountALLCommunityGroupCounts.js +0 -37
- package/dist/scripts/recountAll.js +0 -97
- package/dist/scripts/recountCommunitesFromUrl.js +0 -58
- package/dist/scripts/recountCommunity.js +0 -19
- package/dist/scripts/recountGroup.js +0 -218
- package/dist/scripts/recountGroupNoUserChange.js +0 -219
- package/dist/scripts/resetAllEndorsementsForGroup.js +0 -57
- package/dist/scripts/resetEnTranslationForGroup.js +0 -45
- package/dist/scripts/setAdminOnAll.cjs +0 -107
- package/dist/scripts/setDomainAdmin.cjs +0 -43
- package/dist/scripts/setDomainLocales.js +0 -33
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +0 -29
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +0 -86
- package/dist/scripts/setMemberOfAll.js +0 -101
- package/dist/scripts/setNewUserForContentOfCommunity.js +0 -189
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +0 -35
- package/dist/scripts/setUserOnAll.js +0 -101
- package/dist/scripts/showCategoryForGroup.js +0 -18
- package/dist/scripts/showOldActivityTypes.js +0 -14
- package/dist/scripts/showPostsMissingCategoryForGroup.js +0 -17
- package/dist/scripts/showStatuses.js +0 -17
- package/dist/scripts/showUniqueVotersInCommunity.js +0 -61
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +0 -66
- package/dist/scripts/simpleExportForGroupsForCommunity.js +0 -46
- package/dist/scripts/simpleExportForPointsForCommunity.js +0 -82
- package/dist/scripts/simpleExportForPostsForCommunity.js +0 -61
- package/dist/scripts/testForEndorsments.js +0 -21
- package/dist/scripts/undeleteGroupAndAllContent.js +0 -151
- package/dist/scripts/undeletePost.js +0 -135
- package/dist/scripts/unlinkSsn.js +0 -23
- package/dist/scripts/updateFromAlthingi.js +0 -303
- package/dist/server.js +0 -3
- package/dist/utils/airbrake.cjs +0 -17
- package/dist/utils/cjsCodeReview.js +0 -99
- package/dist/utils/community_mapping_tools.cjs +0 -124
- package/dist/utils/copy_utils.cjs +0 -1399
- package/dist/utils/docx_utils.cjs +0 -464
- package/dist/utils/export_utils.cjs +0 -491
- package/dist/utils/i18n.cjs +0 -17
- package/dist/utils/is_valid_db_id.cjs +0 -28
- package/dist/utils/logger.cjs +0 -25
- package/dist/utils/loggerTs.js +0 -26
- package/dist/utils/manifest_generator.cjs +0 -104
- package/dist/utils/parse_domain.cjs +0 -16
- package/dist/utils/recount_utils.cjs +0 -415
- package/dist/utils/sharing_parameters.cjs +0 -111
- package/dist/utils/sitemap_generator.cjs +0 -286
- package/dist/utils/to_json.cjs +0 -14
- package/dist/utils/ypLanguages.js +0 -747
- package/dist/webSockets.js +0 -77
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { NotificationAgentQueueManager } from "../../../../managers/notificationAgentQueueManager.js";
|
|
2
|
-
import { YpAgentProductRun } from "../../../../models/agentProductRun.js";
|
|
3
|
-
import { SubscriptionModels } from "./subscriptions.js";
|
|
4
|
-
export class AgentModels {
|
|
5
|
-
constructor(assistant) {
|
|
6
|
-
this.assistant = assistant;
|
|
7
|
-
this.subscriptionModels = new SubscriptionModels(assistant);
|
|
8
|
-
this.queueManager = new NotificationAgentQueueManager(this.assistant.wsClients);
|
|
9
|
-
}
|
|
10
|
-
async getCurrentAgentAndWorkflow() {
|
|
11
|
-
const agent = await this.assistant.getCurrentAgentProduct();
|
|
12
|
-
const currentRun = await this.assistant.getCurrentAgentRun();
|
|
13
|
-
if (!currentRun && !agent) {
|
|
14
|
-
throw new Error("No agent or run found");
|
|
15
|
-
}
|
|
16
|
-
else if (!currentRun) {
|
|
17
|
-
return {
|
|
18
|
-
agent: agent,
|
|
19
|
-
run: undefined,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return {
|
|
24
|
-
agent: agent,
|
|
25
|
-
run: currentRun,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
convertToUnderscoresWithMaxLength(str) {
|
|
30
|
-
const converted = str
|
|
31
|
-
.replace(/\s+/g, "_") // Replace spaces with underscores
|
|
32
|
-
.replace(/([A-Z])/g, "_$1") // Add underscore before capital letters
|
|
33
|
-
.replace(/^_/, "") // Remove leading underscore
|
|
34
|
-
.replace(/-/g, "_") // Replace hyphens with underscores
|
|
35
|
-
.replace(/_+/g, "_") // Replace multiple underscores with single
|
|
36
|
-
.toLowerCase();
|
|
37
|
-
return converted.length > 34 ? converted.slice(0, 34) : converted;
|
|
38
|
-
}
|
|
39
|
-
async startCurrentWorkflowStep(agentRunId, structuredAnswersOverrides) {
|
|
40
|
-
try {
|
|
41
|
-
const agentRunToUpdate = await YpAgentProductRun.findByPk(agentRunId);
|
|
42
|
-
if (!agentRunToUpdate) {
|
|
43
|
-
throw new Error("Agent run not found");
|
|
44
|
-
}
|
|
45
|
-
if (!this.assistant.memory.currentAgentStatus?.subscriptionId) {
|
|
46
|
-
throw new Error("No active subscription found for this agent");
|
|
47
|
-
}
|
|
48
|
-
const workflow = agentRunToUpdate.workflow;
|
|
49
|
-
const totalSteps = workflow.steps.length;
|
|
50
|
-
let currentStepIndex = workflow.currentStepIndex;
|
|
51
|
-
let currentStep = workflow.steps[currentStepIndex];
|
|
52
|
-
const isLastStep = currentStepIndex >= totalSteps - 1;
|
|
53
|
-
console.log(`oldStep: ${JSON.stringify(currentStep, null, 2)}`);
|
|
54
|
-
if (currentStep.type !== "agentOps" && !isLastStep) {
|
|
55
|
-
workflow.currentStepIndex++;
|
|
56
|
-
currentStepIndex = workflow.currentStepIndex;
|
|
57
|
-
currentStep = workflow.steps[currentStepIndex];
|
|
58
|
-
}
|
|
59
|
-
currentStep.startTime = new Date();
|
|
60
|
-
console.log(`newStep: ${JSON.stringify(currentStep, null, 2)}`);
|
|
61
|
-
if (currentStepIndex >= totalSteps) {
|
|
62
|
-
throw new Error(`Agent run ${agentRunId} is already at the last step of the workflow`);
|
|
63
|
-
}
|
|
64
|
-
const agentId = currentStep.agentId;
|
|
65
|
-
if (!agentId) {
|
|
66
|
-
throw new Error("No agent ID found in the current step");
|
|
67
|
-
}
|
|
68
|
-
// Start processing with websocket client ID
|
|
69
|
-
const jobId = await this.queueManager.startAgentProcessingWithWsClient(agentId, agentRunId, this.assistant.wsClientId, structuredAnswersOverrides);
|
|
70
|
-
if (!jobId) {
|
|
71
|
-
throw new Error("Failed to start agent processing");
|
|
72
|
-
}
|
|
73
|
-
workflow.steps[currentStepIndex].queueJobId = jobId;
|
|
74
|
-
agentRunToUpdate.status = "running";
|
|
75
|
-
agentRunToUpdate.changed("workflow", true);
|
|
76
|
-
await agentRunToUpdate.save();
|
|
77
|
-
return {
|
|
78
|
-
agentRun: agentRunToUpdate,
|
|
79
|
-
previousStep: currentStep,
|
|
80
|
-
currentStep: workflow.steps[currentStepIndex],
|
|
81
|
-
message: "Agent workflow started successfully",
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
console.error(error);
|
|
86
|
-
throw new Error("Error starting agent workflow step");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async getCurrentWorkflowStep() {
|
|
90
|
-
const agentRun = await this.getCurrentAgentAndWorkflow();
|
|
91
|
-
return agentRun.run.workflow.steps[agentRun.run.workflow.currentStepIndex];
|
|
92
|
-
}
|
|
93
|
-
async getNextWorkflowStep() {
|
|
94
|
-
const agentRun = await this.getCurrentAgentAndWorkflow();
|
|
95
|
-
if (!agentRun.run) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
//TODO: look into this deal with the difference between agentOps and engagment
|
|
99
|
-
if (agentRun.run.workflow.currentStepIndex === 0) {
|
|
100
|
-
return agentRun.run.workflow.steps[0];
|
|
101
|
-
}
|
|
102
|
-
if (agentRun.run.workflow.currentStepIndex >=
|
|
103
|
-
agentRun.run.workflow.steps.length - 1) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
return agentRun.run.workflow.steps[agentRun.run.workflow.currentStepIndex + 1];
|
|
107
|
-
}
|
|
108
|
-
async stopCurrentWorkflowStep() {
|
|
109
|
-
console.log("---------------------> stopCurrentWorkflowStep");
|
|
110
|
-
const agent = await this.assistant.getCurrentAgentProduct();
|
|
111
|
-
const currentRun = (await YpAgentProductRun.findByPk(this.assistant.memory.currentAgentStatus?.activeAgentRunId));
|
|
112
|
-
if (!currentRun) {
|
|
113
|
-
throw new Error("No active workflow found to stop");
|
|
114
|
-
}
|
|
115
|
-
const currentStep = currentRun.workflow.steps[currentRun.workflow.currentStepIndex];
|
|
116
|
-
if (!agent) {
|
|
117
|
-
throw new Error("No agent found");
|
|
118
|
-
}
|
|
119
|
-
if (!currentStep.agentId) {
|
|
120
|
-
throw new Error("No agent ID found in the current step");
|
|
121
|
-
}
|
|
122
|
-
// Stop processing using queue manager
|
|
123
|
-
await this.queueManager.stopAgentProcessing(currentStep.agentId, this.assistant.wsClientId, currentRun.id);
|
|
124
|
-
// Update run status
|
|
125
|
-
currentRun.status = "stopped";
|
|
126
|
-
currentRun.end_time = new Date();
|
|
127
|
-
await currentRun.save();
|
|
128
|
-
// Get current status from queue manager
|
|
129
|
-
const queueStatus = await this.queueManager.getAgentStatus(agent.id);
|
|
130
|
-
if (queueStatus) {
|
|
131
|
-
console.log(`Current queue status for agent ${agent.id}:`, queueStatus);
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
agent,
|
|
135
|
-
run: currentRun,
|
|
136
|
-
message: "Agent workflow stopped successfully",
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
async checkAgentStatus() {
|
|
140
|
-
const agent = await this.assistant.getCurrentAgentProduct();
|
|
141
|
-
if (!agent) {
|
|
142
|
-
throw new Error("No agent found");
|
|
143
|
-
}
|
|
144
|
-
return this.queueManager.getAgentStatus(agent.id);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { YpSubscription } from "../../../../models/subscription.js";
|
|
2
|
-
import { YpSubscriptionPlan } from "../../../../models/subscriptionPlan.js";
|
|
3
|
-
import { YpAgentProduct } from "../../../../models/agentProduct.js";
|
|
4
|
-
import { YpAgentProductBundle } from "../../../../models/agentProductBundle.js";
|
|
5
|
-
import { YpAgentProductRun } from "../../../../models/agentProductRun.js";
|
|
6
|
-
import { Op } from "sequelize";
|
|
7
|
-
export class SubscriptionModels {
|
|
8
|
-
constructor(assistant) {
|
|
9
|
-
this.assistant = assistant;
|
|
10
|
-
}
|
|
11
|
-
async loadAgentSubscriptionPlans() {
|
|
12
|
-
try {
|
|
13
|
-
const firstBundle = await YpAgentProductBundle.findOne({
|
|
14
|
-
where: {
|
|
15
|
-
//TODO: get working
|
|
16
|
-
//domain_id: this.domainId,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
// Get all available subscription plans with their associated agent products
|
|
20
|
-
const availablePlans = await YpSubscriptionPlan.findAll({
|
|
21
|
-
where: {
|
|
22
|
-
id: {
|
|
23
|
-
[Op.in]: [1, 6],
|
|
24
|
-
},
|
|
25
|
-
// status: 'active', // Only get active plans
|
|
26
|
-
},
|
|
27
|
-
attributes: ['id', 'configuration', 'name', 'description'],
|
|
28
|
-
include: [
|
|
29
|
-
{
|
|
30
|
-
model: YpAgentProduct,
|
|
31
|
-
as: "AgentProduct",
|
|
32
|
-
attributes: {
|
|
33
|
-
exclude: ["created_at", "updated_at"],
|
|
34
|
-
},
|
|
35
|
-
include: [
|
|
36
|
-
{
|
|
37
|
-
model: YpAgentProductBundle,
|
|
38
|
-
as: "AgentBundles",
|
|
39
|
-
required: false,
|
|
40
|
-
attributes: {
|
|
41
|
-
exclude: ["created_at", "updated_at"],
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
console.log(`-----------XXXXXXXXXXXXXXXx----------_> ${JSON.stringify(availablePlans, null, 2)}`);
|
|
49
|
-
return {
|
|
50
|
-
availablePlans: availablePlans.map((plan) => ({
|
|
51
|
-
subscriptionPlanId: plan.id,
|
|
52
|
-
type: plan.configuration?.type || "coming_soon",
|
|
53
|
-
name: plan.AgentProduct?.configuration?.displayName || "No name available",
|
|
54
|
-
description: plan.AgentProduct?.description || "No description available",
|
|
55
|
-
imageUrl: plan.configuration?.imageUrl || "",
|
|
56
|
-
// price: plan.configuration?.amount || 0,
|
|
57
|
-
// currency: plan.configuration?.currency || "USD",
|
|
58
|
-
// maxRunsPerCycle: plan.configuration?.max_runs_per_cycle || 0,
|
|
59
|
-
})),
|
|
60
|
-
availableBundle: firstBundle
|
|
61
|
-
? {
|
|
62
|
-
agentBundleId: firstBundle.id,
|
|
63
|
-
name: firstBundle.name,
|
|
64
|
-
description: firstBundle.description || "",
|
|
65
|
-
imageUrl: firstBundle.configuration?.imageUrl || "",
|
|
66
|
-
}
|
|
67
|
-
: "No bundle available",
|
|
68
|
-
systemStatus: {
|
|
69
|
-
healthy: true,
|
|
70
|
-
lastUpdated: new Date(),
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error("Error loading available subscription plans:", error);
|
|
76
|
-
return {
|
|
77
|
-
availablePlans: [],
|
|
78
|
-
availableBundle: "No bundle available",
|
|
79
|
-
systemStatus: {
|
|
80
|
-
healthy: false,
|
|
81
|
-
lastUpdated: new Date(),
|
|
82
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async loadAgentProductPlanAndSubscription(subscriptionPlanId) {
|
|
88
|
-
const plan = (await YpSubscriptionPlan.findOne({
|
|
89
|
-
where: {
|
|
90
|
-
id: subscriptionPlanId,
|
|
91
|
-
},
|
|
92
|
-
include: [
|
|
93
|
-
{
|
|
94
|
-
model: YpAgentProduct,
|
|
95
|
-
as: "AgentProduct",
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
}));
|
|
99
|
-
if (!plan) {
|
|
100
|
-
throw new Error(`Agent product with id ${subscriptionPlanId} not found`);
|
|
101
|
-
}
|
|
102
|
-
let subscription = null;
|
|
103
|
-
if (this.assistant.memory.currentUser) {
|
|
104
|
-
subscription = (await YpSubscription.findOne({
|
|
105
|
-
where: {
|
|
106
|
-
subscription_plan_id: subscriptionPlanId,
|
|
107
|
-
status: "active",
|
|
108
|
-
user_id: this.assistant.memory.currentUser?.id,
|
|
109
|
-
},
|
|
110
|
-
include: [
|
|
111
|
-
{
|
|
112
|
-
model: YpSubscriptionPlan,
|
|
113
|
-
as: "Plan",
|
|
114
|
-
attributes: ['id', 'configuration'],
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
}));
|
|
118
|
-
}
|
|
119
|
-
return { subscription, plan };
|
|
120
|
-
}
|
|
121
|
-
async loadUserAgentSubscriptions() {
|
|
122
|
-
try {
|
|
123
|
-
// Get available agent products from user's subscriptions for their domain
|
|
124
|
-
const availableSubscriptions = await YpSubscription.findAll({
|
|
125
|
-
where: {
|
|
126
|
-
user_id: this.assistant.memory.currentUser?.id,
|
|
127
|
-
domain_id: this.assistant.domainId,
|
|
128
|
-
status: "active",
|
|
129
|
-
},
|
|
130
|
-
include: [
|
|
131
|
-
{
|
|
132
|
-
model: YpSubscriptionPlan,
|
|
133
|
-
as: "Plan",
|
|
134
|
-
include: [
|
|
135
|
-
{
|
|
136
|
-
model: YpAgentProduct,
|
|
137
|
-
as: "AgentProduct",
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
model: YpAgentProduct,
|
|
143
|
-
as: "AgentProduct",
|
|
144
|
-
attributes: {
|
|
145
|
-
exclude: ["created_at", "updated_at"],
|
|
146
|
-
},
|
|
147
|
-
include: [
|
|
148
|
-
{
|
|
149
|
-
model: YpAgentProductBundle,
|
|
150
|
-
as: "AgentBundles",
|
|
151
|
-
required: false,
|
|
152
|
-
attributes: {
|
|
153
|
-
exclude: ["created_at", "updated_at"],
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
});
|
|
160
|
-
// Get currently running agents for the domain
|
|
161
|
-
const runningAgents = await YpAgentProductRun.findAll({
|
|
162
|
-
where: {
|
|
163
|
-
//domain_id: this.domainId, //TODO: get working
|
|
164
|
-
status: "running",
|
|
165
|
-
},
|
|
166
|
-
include: [
|
|
167
|
-
{
|
|
168
|
-
model: YpSubscription,
|
|
169
|
-
as: "Subscription",
|
|
170
|
-
where: {
|
|
171
|
-
domain_id: this.assistant.domainId,
|
|
172
|
-
status: "active",
|
|
173
|
-
},
|
|
174
|
-
include: [
|
|
175
|
-
{
|
|
176
|
-
model: YpAgentProduct,
|
|
177
|
-
as: "AgentProduct",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
model: YpSubscriptionPlan,
|
|
181
|
-
as: "Plan",
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
});
|
|
187
|
-
return {
|
|
188
|
-
availableSubscriptions: availableSubscriptions,
|
|
189
|
-
runningAgents: runningAgents.map((run) => ({
|
|
190
|
-
runId: run.id,
|
|
191
|
-
agentProductId: run.Subscription?.AgentProduct?.id || 0,
|
|
192
|
-
agentRunId: run.id,
|
|
193
|
-
agentName: run.Subscription?.AgentProduct?.name || "",
|
|
194
|
-
startTime: run.start_time,
|
|
195
|
-
status: run.status,
|
|
196
|
-
workflow: run.workflow,
|
|
197
|
-
subscriptionId: run.subscription_id,
|
|
198
|
-
})),
|
|
199
|
-
systemStatus: {
|
|
200
|
-
healthy: true,
|
|
201
|
-
lastUpdated: new Date(),
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
console.error("Error loading agent status:", error);
|
|
207
|
-
return {
|
|
208
|
-
availableSubscriptions: [],
|
|
209
|
-
runningAgents: [],
|
|
210
|
-
systemStatus: {
|
|
211
|
-
healthy: false,
|
|
212
|
-
lastUpdated: new Date(),
|
|
213
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
async unsubscribeFromAgentPlan(subscriptionId) {
|
|
219
|
-
try {
|
|
220
|
-
const subscription = await YpSubscription.findOne({
|
|
221
|
-
where: {
|
|
222
|
-
id: subscriptionId,
|
|
223
|
-
user_id: this.assistant.memory.currentUser?.id,
|
|
224
|
-
domain_id: this.assistant.domainId,
|
|
225
|
-
status: "active",
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
if (!subscription) {
|
|
229
|
-
return {
|
|
230
|
-
success: false,
|
|
231
|
-
error: "Subscription not found or already inactive",
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
const userId = this.assistant.memory.currentUser?.id;
|
|
235
|
-
subscription.status = "cancelled";
|
|
236
|
-
subscription.configuration = {
|
|
237
|
-
cancelledAt: new Date(),
|
|
238
|
-
cancelledByUserId: userId,
|
|
239
|
-
};
|
|
240
|
-
subscription.end_date = new Date();
|
|
241
|
-
subscription.changed("configuration", true);
|
|
242
|
-
await subscription.save();
|
|
243
|
-
return {
|
|
244
|
-
success: true,
|
|
245
|
-
subscriptionId: subscription.id,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
const errorMessage = error instanceof Error
|
|
250
|
-
? error.message
|
|
251
|
-
: "Failed to unsubscribe from agent plan";
|
|
252
|
-
console.error(`Database error in unsubscribeFromAgentPlan: ${errorMessage}`);
|
|
253
|
-
return {
|
|
254
|
-
success: false,
|
|
255
|
-
error: errorMessage,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
async subscribeToAgentPlan(agentProductId, subscriptionPlanId, returnCurrentSubscription = false) {
|
|
260
|
-
try {
|
|
261
|
-
const plan = await YpSubscriptionPlan.findOne({
|
|
262
|
-
where: {
|
|
263
|
-
id: subscriptionPlanId,
|
|
264
|
-
},
|
|
265
|
-
include: [
|
|
266
|
-
{
|
|
267
|
-
model: YpAgentProduct,
|
|
268
|
-
as: "AgentProduct",
|
|
269
|
-
},
|
|
270
|
-
],
|
|
271
|
-
});
|
|
272
|
-
if (!plan) {
|
|
273
|
-
return {
|
|
274
|
-
success: false,
|
|
275
|
-
error: "Subscription plan not found",
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const userId = this.assistant.memory.currentUser?.id;
|
|
279
|
-
if (!userId) {
|
|
280
|
-
return {
|
|
281
|
-
success: false,
|
|
282
|
-
error: "User not found",
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
const existingSubscription = await YpSubscription.findOne({
|
|
286
|
-
where: {
|
|
287
|
-
subscription_plan_id: subscriptionPlanId,
|
|
288
|
-
user_id: userId,
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
if (returnCurrentSubscription && existingSubscription) {
|
|
292
|
-
return {
|
|
293
|
-
success: true,
|
|
294
|
-
plan: plan,
|
|
295
|
-
subscription: existingSubscription,
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
else if (existingSubscription) {
|
|
299
|
-
return {
|
|
300
|
-
success: false,
|
|
301
|
-
error: "User already subscribed to this plan",
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
console.log(`-------> subscribing to agent plan ${subscriptionPlanId} for user ${userId}`);
|
|
305
|
-
const subscription = await YpSubscription.create({
|
|
306
|
-
subscription_plan_id: subscriptionPlanId,
|
|
307
|
-
agent_product_id: agentProductId,
|
|
308
|
-
user_id: userId,
|
|
309
|
-
domain_id: this.assistant.domainId,
|
|
310
|
-
next_billing_date: new Date(),
|
|
311
|
-
status: "active",
|
|
312
|
-
start_date: new Date(),
|
|
313
|
-
configuration: plan.configuration,
|
|
314
|
-
});
|
|
315
|
-
return {
|
|
316
|
-
success: true,
|
|
317
|
-
plan: plan,
|
|
318
|
-
subscription: subscription,
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
catch (error) {
|
|
322
|
-
const errorMessage = error instanceof Error
|
|
323
|
-
? error.message
|
|
324
|
-
: "Failed to subscribe to agent plan";
|
|
325
|
-
console.error(`Database error in subscribeToAgentPlan: ${errorMessage}`);
|
|
326
|
-
return {
|
|
327
|
-
success: false,
|
|
328
|
-
error: errorMessage,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
// commonTools.ts
|
|
2
|
-
import { AgentModels } from "./models/agents.js";
|
|
3
|
-
import { SubscriptionModels } from "./models/subscriptions.js";
|
|
4
|
-
import { BaseAssistantTools } from "./baseTools.js";
|
|
5
|
-
export class NavigationTools extends BaseAssistantTools {
|
|
6
|
-
constructor(assistant) {
|
|
7
|
-
super(assistant);
|
|
8
|
-
this.agentModels = new AgentModels(assistant);
|
|
9
|
-
this.subscriptionModels = new SubscriptionModels(assistant);
|
|
10
|
-
}
|
|
11
|
-
async goBackToMainAssistant() {
|
|
12
|
-
await this.assistant.handleModeSwitch("agent_selection_mode", "User requested to return to the main assistant", {});
|
|
13
|
-
return {
|
|
14
|
-
success: true,
|
|
15
|
-
data: { message: "Returned to main assistant" },
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
get connectDirectlyToAgent() {
|
|
19
|
-
return {
|
|
20
|
-
name: "connect_directly_to_one_of_the_agents",
|
|
21
|
-
description: "Select an agent to work with. The user needs to be logged in to use this tool.",
|
|
22
|
-
type: "function",
|
|
23
|
-
parameters: {
|
|
24
|
-
type: "object",
|
|
25
|
-
properties: {
|
|
26
|
-
subscriptionPlanId: { type: "number" },
|
|
27
|
-
},
|
|
28
|
-
required: [
|
|
29
|
-
"subscriptionPlanId",
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
handler: this.connectToOneOfTheAgentsHandler.bind(this),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async connectToOneOfTheAgentsHandler(params) {
|
|
36
|
-
params = this.assistant.getCleanedParams(params);
|
|
37
|
-
console.log(`handler: connect_to_one_of_the_agents: ${JSON.stringify(params, null, 2)}`);
|
|
38
|
-
try {
|
|
39
|
-
let { plan, subscription } = await this.subscriptionModels.loadAgentProductPlanAndSubscription(params.subscriptionPlanId);
|
|
40
|
-
if (!plan?.AgentProduct) {
|
|
41
|
-
throw new Error(`Agent product with id ${params.subscriptionPlanId} not found`);
|
|
42
|
-
}
|
|
43
|
-
const result = await this.subscriptionModels.subscribeToAgentPlan(plan.AgentProduct.id, plan.id, true);
|
|
44
|
-
if (!result.success || !result.subscription || !result.plan) {
|
|
45
|
-
return {
|
|
46
|
-
success: false,
|
|
47
|
-
error: result.error || "Failed to subscribe to agent plan",
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
plan = result.plan;
|
|
51
|
-
subscription = result.subscription;
|
|
52
|
-
console.log(`Loading: ${plan?.AgentProduct?.name} ${subscription?.id}`);
|
|
53
|
-
await this.updateCurrentAgentProductPlan(plan, subscription);
|
|
54
|
-
await this.assistant.handleModeSwitch("agent_direct_connection_mode", `Directly connected to agent: ${plan?.AgentProduct?.name}`, params);
|
|
55
|
-
const html = `<div class="agent-chips"><yp-agent-chip-simple
|
|
56
|
-
isSelected
|
|
57
|
-
isSubscribed="1"
|
|
58
|
-
agentProductId="${plan?.AgentProduct?.id}"
|
|
59
|
-
subscriptionId="${subscription?.id}"
|
|
60
|
-
agentName="${plan?.name}"
|
|
61
|
-
agentDescription="${plan?.AgentProduct?.description}"
|
|
62
|
-
agentImageUrl="${plan?.AgentProduct?.configuration.avatar?.imageUrl}"
|
|
63
|
-
></yp-agent-chip-simple></div>`;
|
|
64
|
-
if (plan?.AgentProduct?.configuration.avatar?.imageUrl) {
|
|
65
|
-
this.assistant.sendAvatarUrlChange(plan?.AgentProduct?.configuration.avatar?.imageUrl, plan?.AgentProduct?.name);
|
|
66
|
-
}
|
|
67
|
-
this.assistant.triggerResponseIfNeeded("Agent selected");
|
|
68
|
-
return {
|
|
69
|
-
success: true,
|
|
70
|
-
html,
|
|
71
|
-
data: {
|
|
72
|
-
selectedAgentInformation: JSON.stringify(this.assistant.memory.currentAgentStatus, null, 2),
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
const errorMessage = error instanceof Error ? error.message : "Failed to select agent";
|
|
78
|
-
console.error(`Failed to select agent: ${errorMessage}`);
|
|
79
|
-
return {
|
|
80
|
-
success: false,
|
|
81
|
-
data: errorMessage,
|
|
82
|
-
error: errorMessage,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
get listAllAgentsAvailableForConnection() {
|
|
87
|
-
return {
|
|
88
|
-
name: "list_all_agents_available_for_connection",
|
|
89
|
-
description: "List all agent workflows available connecting to",
|
|
90
|
-
type: "function",
|
|
91
|
-
parameters: {
|
|
92
|
-
type: "object",
|
|
93
|
-
properties: {},
|
|
94
|
-
},
|
|
95
|
-
handler: this.listAllAgentsAvailableForConnectionsHandler.bind(this),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
async listAllAgentsAvailableForConnectionsHandler(params) {
|
|
99
|
-
params = this.assistant.getCleanedParams(params);
|
|
100
|
-
console.log(`handler: list_all_agents_available_for_connections: ${JSON.stringify(params, null, 2)}`);
|
|
101
|
-
try {
|
|
102
|
-
const status = await this.subscriptionModels.loadAgentSubscriptionPlans();
|
|
103
|
-
if (this.assistant.DEBUG) {
|
|
104
|
-
console.log(`list_all_agents_available_for_purchase: ${JSON.stringify(status, null, 2)}`);
|
|
105
|
-
}
|
|
106
|
-
let agentChips = "";
|
|
107
|
-
function planTypePriority(type) {
|
|
108
|
-
switch (type) {
|
|
109
|
-
case "coming_soon":
|
|
110
|
-
return 0;
|
|
111
|
-
case "paid":
|
|
112
|
-
return 1;
|
|
113
|
-
case "free_trial":
|
|
114
|
-
return 2;
|
|
115
|
-
default:
|
|
116
|
-
return 999;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// 2) Custom sort function
|
|
120
|
-
const sortedPlans = [...status.availablePlans].sort((a, b) => {
|
|
121
|
-
// Compare by type priority first
|
|
122
|
-
const typeComparison = planTypePriority(a.type) - planTypePriority(b.type);
|
|
123
|
-
if (typeComparison !== 0) {
|
|
124
|
-
// If types differ, that decides the order
|
|
125
|
-
return typeComparison;
|
|
126
|
-
}
|
|
127
|
-
// If both are the same type and it's "paid", sort by price descending
|
|
128
|
-
if (b.price && a.price && a.type === "paid" && b.type === "paid") {
|
|
129
|
-
return b.price - a.price;
|
|
130
|
-
}
|
|
131
|
-
// Otherwise keep them in the same order if they're not "paid"
|
|
132
|
-
return 0;
|
|
133
|
-
});
|
|
134
|
-
for (const agent of sortedPlans) {
|
|
135
|
-
agentChips += `<yp-agent-chip-simple
|
|
136
|
-
subscriptionPlanId="${agent.subscriptionPlanId}"
|
|
137
|
-
type="${agent.type}"
|
|
138
|
-
agentName="${agent.name}"
|
|
139
|
-
agentDescription="${agent.description}"
|
|
140
|
-
agentImageUrl="${agent.imageUrl}"
|
|
141
|
-
></yp-agent-chip-simple>`;
|
|
142
|
-
}
|
|
143
|
-
const html = `<div class="agent-chips">${agentChips}</div>`;
|
|
144
|
-
return {
|
|
145
|
-
success: true,
|
|
146
|
-
data: {
|
|
147
|
-
messageToAssistant: "You have shown the user the available agents for connection with a UI widget, now the user needs to choose which one to connect to",
|
|
148
|
-
status,
|
|
149
|
-
},
|
|
150
|
-
html,
|
|
151
|
-
metadata: {
|
|
152
|
-
timestamp: new Date().toISOString(),
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
const errorMessage = error instanceof Error ? error.message : "Failed to load agent status";
|
|
158
|
-
console.error(`Failed to load agent status: ${errorMessage}`);
|
|
159
|
-
return {
|
|
160
|
-
success: false,
|
|
161
|
-
data: errorMessage,
|
|
162
|
-
error: errorMessage,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|