@yrpri/api 9.0.102 → 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/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +56 -0
- package/active-citizen/llms/imageGeneration/collectionImageGenerator.js +6 -0
- package/agents/controllers/agentProductController.js +2 -1
- package/agents/controllers/agentSubscriptionController.js +20 -11
- package/agents/controllers/assistantsController.js +28 -18
- package/agents/controllers/policySynthAgents.js +33 -12
- package/agents/managers/newAiModelSetup.js +96 -0
- package/agents/managers/subscriptionManager.js +2 -2
- package/app.js +12 -12
- package/authorization.cjs +4 -0
- package/controllers/allOurIdeas.js +2 -1
- package/controllers/communities.cjs +47 -1
- package/controllers/groups.cjs +67 -4
- package/controllers/index.cjs +7 -7
- package/controllers/nonSpa.cjs +1 -1
- package/package.json +46 -44
- package/server.d.ts +104 -2
- package/utils/copy_utils.cjs +7 -1
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts +0 -21
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts.map +0 -1
- package/active-citizen/engine/allOurIdeas/explainAnswersAssistant.d.ts.map +0 -1
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts +0 -12
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts.map +0 -1
- package/active-citizen/engine/analytics/export_anon_community_activities.d.ts.map +0 -1
- package/active-citizen/engine/analytics/importer.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/categories_dataset.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/dataset_tools.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/sentiment_dataset.d.ts.map +0 -1
- package/active-citizen/engine/reports/xls_all_our_ideas_export.js +0 -141
- package/active-citizen/llms/baseChatBot.d.ts +0 -51
- package/active-citizen/llms/baseChatBot.d.ts.map +0 -1
- package/active-citizen/llms/collectionImageGenerator.js +0 -357
- package/active-citizen/llms/llmTranslation.d.ts +0 -24
- package/active-citizen/llms/llmTranslation.d.ts.map +0 -1
- package/active-citizen/scripts/fix_old_delayed_notifications.d.ts.map +0 -1
- package/active-citizen/scripts/kue_status.d.ts.map +0 -1
- package/active-citizen/scripts/kue_watch_stuck_jobs.d.ts.map +0 -1
- package/active-citizen/scripts/translation_clear_language.d.ts.map +0 -1
- package/active-citizen/scripts/translation_delete.d.ts.map +0 -1
- package/active-citizen/scripts/translation_replace_text_from_url.d.ts.map +0 -1
- package/active-citizen/scripts/translation_update.d.ts.map +0 -1
- package/active-citizen/scripts/translations_list.d.ts.map +0 -1
- package/active-citizen/utils/airbrake.d.ts.map +0 -1
- package/active-citizen/utils/airbrake.js +0 -17
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts +0 -21
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts.map +0 -1
- package/active-citizen/utils/updateLocaleFolders.d.ts +0 -2
- package/active-citizen/utils/updateLocaleFolders.d.ts.map +0 -1
- package/active-citizen/workers/cloudflare/voiceSession/worker.js +0 -213
- package/active-citizen/workers/generativeAi.d.ts.map +0 -1
- package/agents/agentProductManager.js +0 -91
- package/agents/assistants/agentAssistantOld.js +0 -863
- package/agents/assistants/modes/agentConfigurationMode.js +0 -63
- package/agents/assistants/modes/agentOperationsMode.js +0 -195
- package/agents/assistants/modes/commonTools.js +0 -58
- package/agents/assistants/modes/directConversationMode.js +0 -14
- package/agents/assistants/modes/toolHandlers/accountHandlers.js +0 -46
- package/agents/assistants/modes/toolHandlers/commonHandlers.js +0 -57
- package/agents/assistants/modes/toolHandlers/commonTools.js +0 -58
- package/agents/assistants/modes/toolHandlers/loginHandlers.js +0 -46
- package/agents/assistants/modes/toolHandlers/subscriptionHandlers.js +0 -469
- package/agents/assistants/modes/tools/agentConnectionTools.js +0 -326
- package/agents/assistants/modes/tools/commonHandlers.js +0 -57
- package/agents/assistants/modes/tools/loginHandlers.js +0 -46
- package/agents/assistants/modes/tools/subscriptionHandlers.js +0 -469
- package/agents/assistants/modes/tools/workflowConversationTools.js +0 -326
- package/agents/assistants/modes/tools/workflowTools.js +0 -112
- package/agents/controllers/assistantController.js +0 -243
- package/agents/managers/workflowManager.js +0 -76
- package/agents/models/testData/setupConfig.js +0 -140
- package/agents/models/workflow.js +0 -53
- package/agents/models/workflowConverstation.js +0 -53
- package/agents/subscriptionManager.js +0 -218
- package/agents/tools/updateCommunityWorkflow.js +0 -1
- package/agents/tools/updateTemplateWorkflow.js +0 -45
- package/app.d.ts +0 -40
- package/app.d.ts.map +0 -1
- package/bot_control.d.ts.map +0 -1
- package/migrations/200824_create_embeddings_and_org_update.cjs +0 -15
- package/migrations/270724_createUsersAndAdminsForClasses.cjs +0 -100
- package/publish.d.ts.map +0 -1
- package/repack.d.ts.map +0 -1
- package/scripts/addRatingUsersToGroup.d.ts.map +0 -1
- package/scripts/addUserToOrganization.d.ts.map +0 -1
- package/scripts/analyseRatingsForCommunity.d.ts.map +0 -1
- package/scripts/analyzeAndFixBrokenPointUsers.d.ts.map +0 -1
- package/scripts/analyzeEndorsementsByCountry.d.ts.map +0 -1
- package/scripts/analyzePostsForCommunity.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/listUpdates.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdate.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdateForGroup.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdateForGroup.js +0 -125
- package/scripts/bulkStatusUpdates/performUpdateForStatus.d.ts.map +0 -1
- package/scripts/change/changeVideoAspectTo.d.ts.map +0 -1
- package/scripts/change/setDomainAdmin.cjs +0 -45
- package/scripts/changeCommunityGroupcount.d.ts.map +0 -1
- package/scripts/changeCommunityPostCount.d.ts.map +0 -1
- package/scripts/changeGroupPostCount.d.ts.map +0 -1
- package/scripts/changeLanguage.d.ts.map +0 -1
- package/scripts/changeOfficalStatus.d.ts.map +0 -1
- package/scripts/cleanups/deleteAnonNotifications.d.ts.map +0 -1
- package/scripts/cleanups/deleteAnonNotifications.js +0 -91
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.d.ts.map +0 -1
- package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.d.ts.map +0 -1
- package/scripts/clearAllEndorsementInGroup.d.ts.map +0 -1
- package/scripts/cloning/clearUsersForCommunitiesFromUrl.d.ts.map +0 -1
- package/scripts/cloning/cloneFromUrlScript.d.ts.map +0 -1
- package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.d.ts.map +0 -1
- package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainWithEverything.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.d.ts.map +0 -1
- package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyPostToGroupOld.d.ts.map +0 -1
- package/scripts/cloning/copyPostVideosFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.d.ts.map +0 -1
- package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/setAdminsFromURL.d.ts.map +0 -1
- package/scripts/cloning/setExternalIdsFromURL.d.ts.map +0 -1
- package/scripts/countCommunity.d.ts.map +0 -1
- package/scripts/countCommunityUsers.d.ts.map +0 -1
- package/scripts/countDelayedNotifications.d.ts.map +0 -1
- package/scripts/countGroup.d.ts.map +0 -1
- package/scripts/countStuff.d.ts.map +0 -1
- package/scripts/countUniqueVotersInAGroup.d.ts.map +0 -1
- package/scripts/createInvitesAndShow.d.ts.map +0 -1
- package/scripts/database/seedTestAiModels.js +0 -64
- package/scripts/database/sync_database.d.ts.map +0 -1
- package/scripts/database/sync_dev_database.d.ts.map +0 -1
- package/scripts/debugNotifications.d.ts.map +0 -1
- package/scripts/deleteAllNewsFeeds.d.ts.map +0 -1
- package/scripts/deleteCategory.d.ts.map +0 -1
- package/scripts/deleteOldAppActivities.d.ts.map +0 -1
- package/scripts/deletePostContactDataForCommunity.d.ts.map +0 -1
- package/scripts/destroy/destroy_all_but_one_domain.d.ts.map +0 -1
- package/scripts/displayAuthorForPost.d.ts.map +0 -1
- package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.d.ts.map +0 -1
- package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.d.ts.map +0 -1
- package/scripts/exportAllStatusChanges.d.ts.map +0 -1
- package/scripts/exportClientAcitivity.d.ts.map +0 -1
- package/scripts/exportEndorsementsForCommunity.d.ts.map +0 -1
- package/scripts/exportPointQualitiesForCommunity.d.ts.map +0 -1
- package/scripts/exportPostsAndPointsForCommunity.d.ts.map +0 -1
- package/scripts/exportPostsDataSetForDomain.d.ts.map +0 -1
- package/scripts/exportPostsForGroup.d.ts.map +0 -1
- package/scripts/exportRatingsForPost.d.ts.map +0 -1
- package/scripts/exportUserEndorsementsWithUserAnalysis.d.ts.map +0 -1
- package/scripts/exportUsersForCommunity.d.ts.map +0 -1
- package/scripts/exportUsersForDomain.d.ts.map +0 -1
- package/scripts/exportUsersForGroup.d.ts.map +0 -1
- package/scripts/exports/ratingDistribution.d.ts.map +0 -1
- package/scripts/exports/whoEndorsedWhatByCommunity.d.ts.map +0 -1
- package/scripts/findUnusedClientImports.d.ts.map +0 -1
- package/scripts/fixAllPostPointCounts.d.ts.map +0 -1
- package/scripts/fixAnonNotificationsSettings.d.ts.map +0 -1
- package/scripts/fixCountKopavogur.d.ts.map +0 -1
- package/scripts/fixEndorsementsAfterCopyPostToGroup.d.ts.map +0 -1
- package/scripts/fixExternalUserId.d.ts.map +0 -1
- package/scripts/fixGroupAccess.d.ts.map +0 -1
- package/scripts/fixGroupIdeasAndPointsCount.d.ts.map +0 -1
- package/scripts/fixNotificationSettings.d.ts.map +0 -1
- package/scripts/fixSurveyRadioBakedInSubCodes.d.ts.map +0 -1
- package/scripts/fixWrongUserIdForStatusUpdates.d.ts.map +0 -1
- package/scripts/gallery/exportGalleryData.d.ts.map +0 -1
- package/scripts/gallery/importGalleryForCommunity.d.ts.map +0 -1
- package/scripts/gallery/readJsonAndDownloadImagesVersion2.d.ts.map +0 -1
- package/scripts/gallery/refreshAcApiPostIdsForCommunity.d.ts.map +0 -1
- package/scripts/genderAnalysis.d.ts.map +0 -1
- package/scripts/genderAnalysisByStatus.d.ts.map +0 -1
- package/scripts/importAllLocalesFromLocalFolders.d.ts.map +0 -1
- package/scripts/importDomain.d.ts.map +0 -1
- package/scripts/landUseGame/export3Ddata.d.ts.map +0 -1
- package/scripts/listLanguagesForGroup.d.ts.map +0 -1
- package/scripts/loadTestCreateDummyContentForGroup.d.ts.map +0 -1
- package/scripts/makeRecursiveMapData.d.ts.map +0 -1
- package/scripts/mapping/community_map_csv.d.ts.map +0 -1
- package/scripts/moveCommunityToDomain.d.ts.map +0 -1
- package/scripts/moveGroupToCommunity.d.ts.map +0 -1
- package/scripts/movePostToGroup.d.ts.map +0 -1
- package/scripts/movePostsToGroupsRecountGroupFromUrl.d.ts.map +0 -1
- package/scripts/oldMovePostToGroup.d.ts.map +0 -1
- package/scripts/processCsvForPdfUrls.d.ts.map +0 -1
- package/scripts/processCsvForTranslationAndToxicity.d.ts.map +0 -1
- package/scripts/recount/recount_recursive_communities.d.ts.map +0 -1
- package/scripts/recountALLCommunityGroupCounts.d.ts.map +0 -1
- package/scripts/recountAll.d.ts.map +0 -1
- package/scripts/recountCommunitesFromUrl.d.ts.map +0 -1
- package/scripts/recountCommunity.d.ts.map +0 -1
- package/scripts/recountGroup.d.ts.map +0 -1
- package/scripts/recountGroupNoUserChange.d.ts.map +0 -1
- package/scripts/resetAllEndorsementsForGroup.d.ts.map +0 -1
- package/scripts/resetEnTranslationForGroup.d.ts.map +0 -1
- package/scripts/setDomainLocales.d.ts.map +0 -1
- package/scripts/setLanguageOnGroupCommunitesFromUrl.d.ts.map +0 -1
- package/scripts/setMemberOfAll.d.ts.map +0 -1
- package/scripts/setNewUserForContentOfCommunity.d.ts.map +0 -1
- package/scripts/setOfficialStatusOnAllPostsForCommunity.d.ts.map +0 -1
- package/scripts/setUserOnAll.d.ts.map +0 -1
- package/scripts/showCategoryForGroup.d.ts.map +0 -1
- package/scripts/showOldActivityTypes.d.ts.map +0 -1
- package/scripts/showPostsMissingCategoryForGroup.d.ts.map +0 -1
- package/scripts/showStatuses.d.ts.map +0 -1
- package/scripts/showUniqueVotersInCommunity.d.ts.map +0 -1
- package/scripts/showUserAgentsAndIpsForEmails.d.ts.map +0 -1
- package/scripts/simpleExportForGroupsForCommunity.d.ts.map +0 -1
- package/scripts/simpleExportForPointsForCommunity.d.ts.map +0 -1
- package/scripts/simpleExportForPostsForCommunity.d.ts.map +0 -1
- package/scripts/testForEndorsments.d.ts.map +0 -1
- package/scripts/undeleteGroupAndAllContent.d.ts.map +0 -1
- package/scripts/undeletePost.d.ts.map +0 -1
- package/scripts/unlinkSsn.d.ts.map +0 -1
- package/scripts/updateFromAlthingi.d.ts.map +0 -1
- package/server.d.ts.map +0 -1
- package/utils/copyGroup.js +0 -246
- package/utils/loggerTs.d.ts +0 -4
- package/utils/loggerTs.d.ts.map +0 -1
- package/utils/ypLanguages.d.ts +0 -18
- package/utils/ypLanguages.d.ts.map +0 -1
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// agentConfigurationMode.ts
|
|
2
|
-
import { BaseAssistantMode } from './baseAssistantMode.js';
|
|
3
|
-
export class AgentConfigurationMode extends BaseAssistantMode {
|
|
4
|
-
constructor(assistant) {
|
|
5
|
-
super(assistant);
|
|
6
|
-
}
|
|
7
|
-
getMode() {
|
|
8
|
-
return {
|
|
9
|
-
name: 'agent_configuration',
|
|
10
|
-
description: 'Configure the selected agentProduct the users owns by collecting required information.',
|
|
11
|
-
systemPrompt: `You are the Agent Configuration Assistant. Help the user configure the selected agent by collecting required information.
|
|
12
|
-
Review the required questions and guide the user through answering them.
|
|
13
|
-
${this.renderCommon()}
|
|
14
|
-
${this.renderCurrentAgent()}`,
|
|
15
|
-
functions: [
|
|
16
|
-
{
|
|
17
|
-
name: 'show_question_form',
|
|
18
|
-
description: 'Display form for required questions',
|
|
19
|
-
type: 'function',
|
|
20
|
-
parameters: {
|
|
21
|
-
type: 'object',
|
|
22
|
-
properties: {
|
|
23
|
-
agentProductId: { type: 'number' },
|
|
24
|
-
},
|
|
25
|
-
required: ['agentProductId'],
|
|
26
|
-
},
|
|
27
|
-
handler: async (params) => {
|
|
28
|
-
params = this.assistant.getCleanedParams(params);
|
|
29
|
-
console.log(`handler: show_question_form: ${JSON.stringify(params, null, 2)}`);
|
|
30
|
-
try {
|
|
31
|
-
const questions = await this.getRequiredQuestions(params.agentProductId);
|
|
32
|
-
// Create HTML element for questions
|
|
33
|
-
let html = questions
|
|
34
|
-
.map((question) => `
|
|
35
|
-
<yp-structured-question
|
|
36
|
-
.question="${JSON.stringify(question)}"
|
|
37
|
-
></yp-structured-question>
|
|
38
|
-
`)
|
|
39
|
-
.join('\n');
|
|
40
|
-
return {
|
|
41
|
-
success: true,
|
|
42
|
-
data: questions,
|
|
43
|
-
html,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
const errorMessage = error instanceof Error
|
|
48
|
-
? error.message
|
|
49
|
-
: 'Failed to show questions';
|
|
50
|
-
console.error(`Failed to show questions: ${errorMessage}`);
|
|
51
|
-
return {
|
|
52
|
-
success: false,
|
|
53
|
-
data: errorMessage,
|
|
54
|
-
error: errorMessage,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
allowedTransitions: ['agent_operations'],
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { BaseAssistantMode } from './baseAssistantMode.js';
|
|
2
|
-
export class AgentOperationsMode extends BaseAssistantMode {
|
|
3
|
-
constructor(assistant) {
|
|
4
|
-
super(assistant);
|
|
5
|
-
}
|
|
6
|
-
getMode() {
|
|
7
|
-
return {
|
|
8
|
-
name: 'agent_operations',
|
|
9
|
-
description: 'Manage the selected agentProduct operations',
|
|
10
|
-
systemPrompt: `You are the Agent Operations Assistant. Help the user manage the selected agent's operations.
|
|
11
|
-
Available tools:
|
|
12
|
-
- Start/stop agent
|
|
13
|
-
- Get current status
|
|
14
|
-
- Handle engagement requests
|
|
15
|
-
- Show workflow
|
|
16
|
-
- Show workflow step details
|
|
17
|
-
Current agent status and workflow state are provided via functions.
|
|
18
|
-
${this.renderCommon()}
|
|
19
|
-
${this.renderAllAgentsStatus()}
|
|
20
|
-
${this.renderCurrentAgent()}
|
|
21
|
-
${this.renderCurrentWorkflowStatus()}`,
|
|
22
|
-
functions: [
|
|
23
|
-
{
|
|
24
|
-
name: 'run_agent_next_workflow_step',
|
|
25
|
-
description: "Run the next step in the selected agent's workflow",
|
|
26
|
-
type: 'function',
|
|
27
|
-
parameters: {
|
|
28
|
-
type: 'object',
|
|
29
|
-
properties: {
|
|
30
|
-
agentProductId: { type: 'number' },
|
|
31
|
-
},
|
|
32
|
-
required: ['agentProductId'],
|
|
33
|
-
},
|
|
34
|
-
handler: async (params) => {
|
|
35
|
-
params = this.assistant.getCleanedParams(params);
|
|
36
|
-
try {
|
|
37
|
-
if (!this.currentAgentId) {
|
|
38
|
-
throw new Error('No agent selected');
|
|
39
|
-
}
|
|
40
|
-
const result = await this.runAgentNextWorkflowStep(this.currentAgentId, params.configuration);
|
|
41
|
-
return {
|
|
42
|
-
success: true,
|
|
43
|
-
data: result,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
const errorMessage = error instanceof Error
|
|
48
|
-
? error.message
|
|
49
|
-
: 'Failed to start agent';
|
|
50
|
-
console.error(`Failed to start agent: ${errorMessage}`);
|
|
51
|
-
return {
|
|
52
|
-
success: false,
|
|
53
|
-
data: errorMessage,
|
|
54
|
-
error: errorMessage,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'show_engagement_group',
|
|
61
|
-
description: 'Show group for human engagement',
|
|
62
|
-
type: 'function',
|
|
63
|
-
parameters: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: {
|
|
66
|
-
groupId: { type: 'number' },
|
|
67
|
-
},
|
|
68
|
-
required: ['groupId'],
|
|
69
|
-
},
|
|
70
|
-
handler: async (params) => {
|
|
71
|
-
params = this.assistant.getCleanedParams(params);
|
|
72
|
-
console.log(`handler: show_engagement_group: ${JSON.stringify(params, null, 2)}`);
|
|
73
|
-
try {
|
|
74
|
-
// Create HTML element for group
|
|
75
|
-
const html = `<div class="group-container"><yp-group
|
|
76
|
-
.groupId="${params.groupId}"
|
|
77
|
-
.configuration="${JSON.stringify(params.configuration)}"
|
|
78
|
-
></yp-group></div>`;
|
|
79
|
-
return {
|
|
80
|
-
success: true,
|
|
81
|
-
html,
|
|
82
|
-
data: {
|
|
83
|
-
groupId: params.groupId,
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const errorMessage = error instanceof Error
|
|
89
|
-
? error.message
|
|
90
|
-
: 'Failed to show group';
|
|
91
|
-
console.error(`Failed to show group: ${errorMessage}`);
|
|
92
|
-
return {
|
|
93
|
-
success: false,
|
|
94
|
-
data: errorMessage,
|
|
95
|
-
error: errorMessage,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'stop_agent',
|
|
102
|
-
description: 'Stop the currently running agent',
|
|
103
|
-
type: 'function',
|
|
104
|
-
parameters: {
|
|
105
|
-
type: 'object',
|
|
106
|
-
properties: {
|
|
107
|
-
reason: { type: 'string' },
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
handler: async (params) => {
|
|
111
|
-
params = this.assistant.getCleanedParams(params);
|
|
112
|
-
console.log(`handler: stop_agent: ${JSON.stringify(params, null, 2)}`);
|
|
113
|
-
try {
|
|
114
|
-
if (!this.currentAgentId) {
|
|
115
|
-
throw new Error('No agent selected');
|
|
116
|
-
}
|
|
117
|
-
const result = await this.stopAgent(this.currentAgentId, params.reason);
|
|
118
|
-
return {
|
|
119
|
-
success: true,
|
|
120
|
-
data: {
|
|
121
|
-
agentId: this.currentAgentId,
|
|
122
|
-
stopTime: new Date().toISOString(),
|
|
123
|
-
finalStatus: result.status,
|
|
124
|
-
},
|
|
125
|
-
metadata: {
|
|
126
|
-
reason: params.reason,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
const errorMessage = error instanceof Error
|
|
132
|
-
? error.message
|
|
133
|
-
: 'Failed to stop agent';
|
|
134
|
-
console.error(`Failed to stop agent: ${errorMessage}`);
|
|
135
|
-
return {
|
|
136
|
-
success: false,
|
|
137
|
-
data: errorMessage,
|
|
138
|
-
error: errorMessage,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'show_workflow_for_selected_agent',
|
|
145
|
-
description: 'Display the workflow for the selected agent',
|
|
146
|
-
type: 'function',
|
|
147
|
-
parameters: {
|
|
148
|
-
type: 'object',
|
|
149
|
-
properties: {
|
|
150
|
-
agentProductId: { type: 'number' },
|
|
151
|
-
},
|
|
152
|
-
required: ['agentProductId'],
|
|
153
|
-
},
|
|
154
|
-
handler: async (params) => {
|
|
155
|
-
params = this.assistant.getCleanedParams(params);
|
|
156
|
-
console.log(`handler: show_workflow: ${JSON.stringify(params, null, 2)}`);
|
|
157
|
-
try {
|
|
158
|
-
if (!params.agentProductId) {
|
|
159
|
-
throw new Error('No agent selected');
|
|
160
|
-
}
|
|
161
|
-
const workflow = await this.getWorkflowStatus(params.agentProductId);
|
|
162
|
-
// Create visualization HTML
|
|
163
|
-
const html = `<div class="group-container"><yp-group
|
|
164
|
-
minimizeWorkflow="${true}"
|
|
165
|
-
collectionId="43"
|
|
166
|
-
></yp-group></div>`;
|
|
167
|
-
return {
|
|
168
|
-
success: true,
|
|
169
|
-
html,
|
|
170
|
-
data: { workFlowFound: true, workFlowDisplayed: true },
|
|
171
|
-
metadata: {
|
|
172
|
-
lastUpdated: new Date().toISOString(),
|
|
173
|
-
includesHistory: params.includeHistory,
|
|
174
|
-
showingDetails: params.showDetails,
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
const errorMessage = error instanceof Error
|
|
180
|
-
? error.message
|
|
181
|
-
: 'Failed to show workflow';
|
|
182
|
-
console.error(`Failed to show workflow: ${errorMessage}`);
|
|
183
|
-
return {
|
|
184
|
-
success: false,
|
|
185
|
-
data: errorMessage,
|
|
186
|
-
error: errorMessage,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
allowedTransitions: ['agent_subscription_and_selection', 'agent_direct_conversation'],
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// commonTools.ts
|
|
2
|
-
export class CommonTools {
|
|
3
|
-
constructor(assistant) {
|
|
4
|
-
this.assistant = assistant;
|
|
5
|
-
}
|
|
6
|
-
async logIn(params) {
|
|
7
|
-
// Implement log in logic
|
|
8
|
-
const { username, password } = params;
|
|
9
|
-
// Validate credentials
|
|
10
|
-
const isValid = await this.assistant.authService.validateCredentials(username, password);
|
|
11
|
-
if (isValid) {
|
|
12
|
-
this.assistant.isLoggedIn = true;
|
|
13
|
-
return {
|
|
14
|
-
success: true,
|
|
15
|
-
data: { message: 'Logged in successfully' },
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return {
|
|
20
|
-
success: false,
|
|
21
|
-
error: 'Invalid username or password',
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async logOut(params) {
|
|
26
|
-
// Implement log out logic with confirmation
|
|
27
|
-
const { confirmLogout } = params;
|
|
28
|
-
if (!confirmLogout) {
|
|
29
|
-
return {
|
|
30
|
-
success: false,
|
|
31
|
-
error: 'Please confirm that you want to log out',
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
this.assistant.isLoggedIn = false;
|
|
35
|
-
this.assistant.isSubscribedToCurrentAgent = false;
|
|
36
|
-
this.assistant.hasConfiguredCurrentAgent = false;
|
|
37
|
-
this.assistant.isCurrentAgentRunning = false;
|
|
38
|
-
return {
|
|
39
|
-
success: true,
|
|
40
|
-
data: { message: 'Logged out successfully' },
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// Subscription management tools
|
|
44
|
-
async subscribeToAgent(params) {
|
|
45
|
-
// Implement subscription logic
|
|
46
|
-
}
|
|
47
|
-
async unsubscribeFromAgent(params) {
|
|
48
|
-
// Implement unsubscription logic with confirmation
|
|
49
|
-
}
|
|
50
|
-
// Navigation tool
|
|
51
|
-
async goBackToMainAssistant() {
|
|
52
|
-
await this.assistant.handleModeSwitch('agent_subscription_and_selection', 'User requested to return to the main assistant', {});
|
|
53
|
-
return {
|
|
54
|
-
success: true,
|
|
55
|
-
data: { message: 'Returned to main assistant' },
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// DirectConversationMode.ts
|
|
2
|
-
import { BaseAssistantMode } from "./baseAssistantMode.js";
|
|
3
|
-
export class DirectConversationMode extends BaseAssistantMode {
|
|
4
|
-
constructor(assistant) {
|
|
5
|
-
super(assistant);
|
|
6
|
-
}
|
|
7
|
-
getMode() {
|
|
8
|
-
return {
|
|
9
|
-
name: "agent_direct_conversation",
|
|
10
|
-
description: "Direct conversation with any agent the user is subscribed to or available for purchase",
|
|
11
|
-
systemPrompt: "This system prompt should be set by the agent product configuration, if its being displayed here then something is wrong, please inform the user and refuse any questions about the agent",
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// commonTools.ts
|
|
2
|
-
export class AccountToolHandlers {
|
|
3
|
-
constructor(assistant) {
|
|
4
|
-
this.assistant = assistant;
|
|
5
|
-
}
|
|
6
|
-
async logIn(params) {
|
|
7
|
-
// Implement log in logic
|
|
8
|
-
const { username, password } = params;
|
|
9
|
-
// Validate credentials
|
|
10
|
-
/*const isValid = await this.assistant.authService.validateCredentials(username, password);
|
|
11
|
-
if (isValid) {
|
|
12
|
-
this.assistant.isLoggedIn = true;
|
|
13
|
-
return {
|
|
14
|
-
success: true,
|
|
15
|
-
data: { message: 'Logged in successfully' },
|
|
16
|
-
};
|
|
17
|
-
} else {
|
|
18
|
-
return {
|
|
19
|
-
success: false,
|
|
20
|
-
error: 'Invalid username or password',
|
|
21
|
-
};
|
|
22
|
-
}*/
|
|
23
|
-
return {
|
|
24
|
-
success: true,
|
|
25
|
-
data: { message: 'Logged in successfully' },
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async logOut(params) {
|
|
29
|
-
// Implement log out logic with confirmation
|
|
30
|
-
const { confirmLogout } = params;
|
|
31
|
-
if (!confirmLogout) {
|
|
32
|
-
return {
|
|
33
|
-
success: false,
|
|
34
|
-
error: 'Please confirm that you want to log out',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
this.assistant.isLoggedIn = false;
|
|
38
|
-
this.assistant.isSubscribedToCurrentAgent = false;
|
|
39
|
-
this.assistant.hasConfiguredCurrentAgent = false;
|
|
40
|
-
this.assistant.isCurrentAgentRunning = false;
|
|
41
|
-
return {
|
|
42
|
-
success: true,
|
|
43
|
-
data: { message: 'Logged out successfully' },
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// commonTools.ts
|
|
2
|
-
export class CommonToolHandlers {
|
|
3
|
-
constructor(assistant) {
|
|
4
|
-
this.assistant = assistant;
|
|
5
|
-
}
|
|
6
|
-
async goBackToMainAssistant() {
|
|
7
|
-
await this.assistant.handleModeSwitch('agent_subscription_and_selection', 'User requested to return to the main assistant', {});
|
|
8
|
-
return {
|
|
9
|
-
success: true,
|
|
10
|
-
data: { message: 'Returned to main assistant' },
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
async connectToOneOfTheAgentsHandler(params) {
|
|
14
|
-
params = this.assistant.getCleanedParams(params);
|
|
15
|
-
console.log(`handler: connect_to_one_of_the_agents: ${JSON.stringify(params, null, 2)}`);
|
|
16
|
-
try {
|
|
17
|
-
const agent = await this.validateAndSelectAgent(params.agentProductId);
|
|
18
|
-
const requiredQuestions = await this.getRequiredQuestions(params.agentProductId);
|
|
19
|
-
this.currentAgentId = params.agentProductId;
|
|
20
|
-
// If we have unanswered required questions, switch to configuration mode
|
|
21
|
-
if (requiredQuestions && requiredQuestions.length > 0) {
|
|
22
|
-
await this.assistant.handleModeSwitch("agent_configuration", "Required questions need to be answered", params);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
await this.assistant.handleModeSwitch("agent_operations", "Agent ready for operations", params);
|
|
26
|
-
}
|
|
27
|
-
const html = `<div class="agent-chips"><yp-agent-chip
|
|
28
|
-
isSelected
|
|
29
|
-
agentProductId="${agent.agentProductId}"
|
|
30
|
-
subscriptionId="${agent.subscriptionId}"
|
|
31
|
-
agentName="${agent.name}"
|
|
32
|
-
agentDescription="${agent.description}"
|
|
33
|
-
agentImageUrl="${agent.imageUrl}"
|
|
34
|
-
></yp-agent-chip></div>`;
|
|
35
|
-
this.assistant.triggerResponseIfNeeded("Agent selected");
|
|
36
|
-
return {
|
|
37
|
-
success: true,
|
|
38
|
-
html,
|
|
39
|
-
data: {
|
|
40
|
-
agent,
|
|
41
|
-
hasRequiredQuestions: requiredQuestions && requiredQuestions.length > 0,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
const errorMessage = error instanceof Error
|
|
47
|
-
? error.message
|
|
48
|
-
: "Failed to select agent";
|
|
49
|
-
console.error(`Failed to select agent: ${errorMessage}`);
|
|
50
|
-
return {
|
|
51
|
-
success: false,
|
|
52
|
-
data: errorMessage,
|
|
53
|
-
error: errorMessage,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// commonTools.ts
|
|
2
|
-
export class CommonTools {
|
|
3
|
-
constructor(assistant) {
|
|
4
|
-
this.assistant = assistant;
|
|
5
|
-
}
|
|
6
|
-
async logIn(params) {
|
|
7
|
-
// Implement log in logic
|
|
8
|
-
const { username, password } = params;
|
|
9
|
-
// Validate credentials
|
|
10
|
-
const isValid = await this.assistant.authService.validateCredentials(username, password);
|
|
11
|
-
if (isValid) {
|
|
12
|
-
this.assistant.isLoggedIn = true;
|
|
13
|
-
return {
|
|
14
|
-
success: true,
|
|
15
|
-
data: { message: 'Logged in successfully' },
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return {
|
|
20
|
-
success: false,
|
|
21
|
-
error: 'Invalid username or password',
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async logOut(params) {
|
|
26
|
-
// Implement log out logic with confirmation
|
|
27
|
-
const { confirmLogout } = params;
|
|
28
|
-
if (!confirmLogout) {
|
|
29
|
-
return {
|
|
30
|
-
success: false,
|
|
31
|
-
error: 'Please confirm that you want to log out',
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
this.assistant.isLoggedIn = false;
|
|
35
|
-
this.assistant.isSubscribedToCurrentAgent = false;
|
|
36
|
-
this.assistant.hasConfiguredCurrentAgent = false;
|
|
37
|
-
this.assistant.isCurrentAgentRunning = false;
|
|
38
|
-
return {
|
|
39
|
-
success: true,
|
|
40
|
-
data: { message: 'Logged out successfully' },
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// Subscription management tools
|
|
44
|
-
async subscribeToAgent(params) {
|
|
45
|
-
// Implement subscription logic
|
|
46
|
-
}
|
|
47
|
-
async unsubscribeFromAgent(params) {
|
|
48
|
-
// Implement unsubscription logic with confirmation
|
|
49
|
-
}
|
|
50
|
-
// Navigation tool
|
|
51
|
-
async goBackToMainAssistant() {
|
|
52
|
-
await this.assistant.handleModeSwitch('agent_subscription_and_selection', 'User requested to return to the main assistant', {});
|
|
53
|
-
return {
|
|
54
|
-
success: true,
|
|
55
|
-
data: { message: 'Returned to main assistant' },
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// commonTools.ts
|
|
2
|
-
export class LoginToolHandlers {
|
|
3
|
-
constructor(assistant) {
|
|
4
|
-
this.assistant = assistant;
|
|
5
|
-
}
|
|
6
|
-
async logIn(params) {
|
|
7
|
-
// Implement log in logic
|
|
8
|
-
const { username, password } = params;
|
|
9
|
-
// Validate credentials
|
|
10
|
-
/*const isValid = await this.assistant.authService.validateCredentials(username, password);
|
|
11
|
-
if (isValid) {
|
|
12
|
-
this.assistant.isLoggedIn = true;
|
|
13
|
-
return {
|
|
14
|
-
success: true,
|
|
15
|
-
data: { message: 'Logged in successfully' },
|
|
16
|
-
};
|
|
17
|
-
} else {
|
|
18
|
-
return {
|
|
19
|
-
success: false,
|
|
20
|
-
error: 'Invalid username or password',
|
|
21
|
-
};
|
|
22
|
-
}*/
|
|
23
|
-
return {
|
|
24
|
-
success: true,
|
|
25
|
-
data: { message: 'Logged in successfully' },
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async logOut(params) {
|
|
29
|
-
// Implement log out logic with confirmation
|
|
30
|
-
const { confirmLogout } = params;
|
|
31
|
-
if (!confirmLogout) {
|
|
32
|
-
return {
|
|
33
|
-
success: false,
|
|
34
|
-
error: 'Please confirm that you want to log out',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
this.assistant.isLoggedIn = false;
|
|
38
|
-
this.assistant.isCurrentAgentRunning = false;
|
|
39
|
-
this.assistant.isSubscribedToCurrentAgent = false;
|
|
40
|
-
this.assistant.hasConfiguredCurrentAgent = false;
|
|
41
|
-
return {
|
|
42
|
-
success: true,
|
|
43
|
-
data: { message: 'Logged out successfully' },
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|