@app-connect/core 1.7.36 → 1.7.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -16
- package/dist/connector/developerPortal.d.ts +6 -0
- package/{connector → dist/connector}/developerPortal.js +29 -12
- package/dist/connector/mock.d.ts +1 -0
- package/{connector → dist/connector}/mock.js +33 -17
- package/dist/connector/proxy/engine.d.ts +10 -0
- package/dist/connector/proxy/engine.js +222 -0
- package/dist/connector/proxy/index.d.ts +5 -0
- package/dist/connector/proxy/index.js +511 -0
- package/dist/connector/registry.d.ts +1 -0
- package/dist/connector/registry.js +243 -0
- package/dist/handlers/admin.d.ts +1 -0
- package/{handlers → dist/handlers}/admin.js +137 -78
- package/dist/handlers/appointment.d.ts +9 -0
- package/{handlers → dist/handlers}/appointment.js +58 -29
- package/dist/handlers/auth.d.ts +9 -0
- package/{handlers → dist/handlers}/auth.js +68 -40
- package/dist/handlers/calldown.d.ts +10 -0
- package/dist/handlers/calldown.js +134 -0
- package/dist/handlers/contact.d.ts +1 -0
- package/{handlers → dist/handlers}/contact.js +61 -39
- package/dist/handlers/disposition.d.ts +1 -0
- package/{handlers → dist/handlers}/disposition.js +20 -10
- package/dist/handlers/log.d.ts +1 -0
- package/{handlers → dist/handlers}/log.js +91 -124
- package/dist/handlers/managedAuth.d.ts +1 -0
- package/{handlers → dist/handlers}/managedAuth.js +134 -61
- package/dist/handlers/managedOAuth.d.ts +13 -0
- package/{handlers → dist/handlers}/managedOAuth.js +102 -30
- package/dist/handlers/plugin.d.ts +1 -0
- package/{handlers → dist/handlers}/plugin.js +59 -27
- package/dist/handlers/user.d.ts +1 -0
- package/{handlers → dist/handlers}/user.js +45 -27
- package/dist/index.d.ts +1 -0
- package/{index.js → dist/index.js} +548 -450
- package/dist/jest.config.d.ts +1 -0
- package/dist/jest.config.js +65 -0
- package/dist/lib/analytics.d.ts +4 -0
- package/{lib → dist/lib}/analytics.js +8 -6
- package/dist/lib/authSession.d.ts +5 -0
- package/{lib → dist/lib}/authSession.js +15 -43
- package/dist/lib/cacheCleanup.d.ts +4 -0
- package/{lib → dist/lib}/cacheCleanup.js +5 -17
- package/dist/lib/callLogComposer.d.ts +109 -0
- package/{lib → dist/lib}/callLogComposer.js +157 -197
- package/dist/lib/callLogLookup.d.ts +6 -0
- package/{lib → dist/lib}/callLogLookup.js +12 -34
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/debugTracer.d.ts +17 -0
- package/{lib → dist/lib}/debugTracer.js +7 -83
- package/dist/lib/encode.d.ts +3 -0
- package/dist/lib/encode.js +50 -0
- package/dist/lib/errorHandler.d.ts +7 -0
- package/dist/lib/errorHandler.js +161 -0
- package/dist/lib/generalErrorMessage.d.ts +7 -0
- package/{lib → dist/lib}/generalErrorMessage.js +6 -6
- package/dist/lib/jwt.d.ts +4 -0
- package/dist/lib/jwt.js +18 -0
- package/dist/lib/logger.d.ts +24 -0
- package/dist/lib/logger.js +126 -0
- package/dist/lib/migrateCallLogsSchema.d.ts +32 -0
- package/dist/lib/migrateCallLogsSchema.js +339 -0
- package/dist/lib/oauth.d.ts +4 -0
- package/{lib → dist/lib}/oauth.js +157 -160
- package/dist/lib/ringcentral.d.ts +24 -0
- package/dist/lib/ringcentral.js +226 -0
- package/dist/lib/s3ErrorLogReport.d.ts +4 -0
- package/{lib → dist/lib}/s3ErrorLogReport.js +11 -23
- package/dist/lib/sharedSMSComposer.d.ts +7 -0
- package/{lib → dist/lib}/sharedSMSComposer.js +21 -107
- package/dist/lib/util.d.ts +7 -0
- package/{lib → dist/lib}/util.js +9 -20
- package/dist/mcp/lib/oauthError.d.ts +1 -0
- package/dist/mcp/lib/oauthError.js +25 -0
- package/dist/mcp/lib/validator.d.ts +1 -0
- package/{mcp → dist/mcp}/lib/validator.js +16 -20
- package/dist/mcp/lib/widgetSessionToken.d.ts +1 -0
- package/dist/mcp/lib/widgetSessionToken.js +46 -0
- package/dist/mcp/mcpHandler.d.ts +8 -0
- package/{mcp → dist/mcp}/mcpHandler.js +98 -88
- package/dist/mcp/tools/cancelAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/cancelAppointment.js +7 -16
- package/dist/mcp/tools/checkAuthStatus.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/checkAuthStatus.js +21 -14
- package/dist/mcp/tools/confirmAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/confirmAppointment.js +7 -16
- package/dist/mcp/tools/createAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createAppointment.js +7 -19
- package/dist/mcp/tools/createCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createCallLog.js +18 -29
- package/dist/mcp/tools/createContact.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createContact.js +8 -20
- package/dist/mcp/tools/createMessageLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createMessageLog.js +14 -26
- package/dist/mcp/tools/doAuth.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/doAuth.js +17 -13
- package/dist/mcp/tools/findContactByName.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByName.js +9 -15
- package/dist/mcp/tools/findContactByPhone.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByPhone.js +8 -15
- package/dist/mcp/tools/getCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getCallLog.js +12 -21
- package/dist/mcp/tools/getGoogleFilePicker.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getGoogleFilePicker.js +9 -18
- package/dist/mcp/tools/getHelp.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getHelp.js +5 -6
- package/dist/mcp/tools/getPublicConnectors.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getPublicConnectors.js +19 -18
- package/dist/mcp/tools/getSessionInfo.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getSessionInfo.js +10 -16
- package/dist/mcp/tools/index.d.ts +8 -0
- package/dist/mcp/tools/index.js +50 -0
- package/dist/mcp/tools/listAppointments.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/listAppointments.js +7 -19
- package/dist/mcp/tools/logout.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/logout.js +16 -14
- package/dist/mcp/tools/rcGetCallLogs.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/rcGetCallLogs.js +10 -8
- package/dist/mcp/tools/updateAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateAppointment.js +17 -22
- package/dist/mcp/tools/updateCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateCallLog.js +16 -26
- package/dist/models/accountDataModel.d.ts +3 -0
- package/dist/models/accountDataModel.js +39 -0
- package/dist/models/adminConfigModel.d.ts +2 -0
- package/dist/models/adminConfigModel.js +39 -0
- package/dist/models/cacheModel.d.ts +2 -0
- package/{models → dist/models}/cacheModel.js +7 -3
- package/dist/models/callDownListModel.d.ts +2 -0
- package/{models → dist/models}/callDownListModel.js +8 -4
- package/dist/models/callLogModel.d.ts +2 -0
- package/dist/models/callLogModel.js +43 -0
- package/dist/models/dynamo/connectorSchema.d.ts +2 -0
- package/dist/models/dynamo/connectorSchema.js +141 -0
- package/dist/models/dynamo/lockSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/lockSchema.js +5 -7
- package/dist/models/dynamo/noteCacheSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/noteCacheSchema.js +4 -6
- package/dist/models/llmSessionModel.d.ts +2 -0
- package/dist/models/llmSessionModel.js +21 -0
- package/dist/models/messageLogModel.d.ts +2 -0
- package/{models → dist/models}/messageLogModel.js +8 -4
- package/dist/models/sequelize.d.ts +2 -0
- package/dist/models/sequelize.js +68 -0
- package/dist/models/userModel.d.ts +2 -0
- package/dist/models/userModel.js +49 -0
- package/dist/package.json +100 -0
- package/dist/releaseNotes.json +1222 -0
- package/dist/tsconfig.json +14 -0
- package/dist/types/admin.d.ts +141 -0
- package/dist/types/analytics.d.ts +14 -0
- package/dist/types/appointment.d.ts +50 -0
- package/dist/types/auth.d.ts +137 -0
- package/dist/types/authSession.d.ts +35 -0
- package/dist/types/cacheCleanup.d.ts +12 -0
- package/dist/types/calldown.d.ts +54 -0
- package/dist/types/common.d.ts +46 -0
- package/dist/types/connector.d.ts +165 -0
- package/dist/types/contact.d.ts +125 -0
- package/dist/types/errorHandler.d.ts +60 -0
- package/dist/types/index.d.ts +76 -0
- package/dist/types/json.d.ts +9 -0
- package/dist/types/jwt.d.ts +8 -0
- package/dist/types/logging.d.ts +224 -0
- package/dist/types/managedAuth.d.ts +114 -0
- package/dist/types/managedOAuth.d.ts +59 -0
- package/dist/types/manifest.d.ts +120 -0
- package/dist/types/migration.d.ts +15 -0
- package/dist/types/plugin.d.ts +74 -0
- package/dist/types/ringcentral.d.ts +61 -0
- package/dist/types/s3ErrorLogReport.d.ts +16 -0
- package/dist/types/sharedSMSComposer.d.ts +105 -0
- package/dist/types/user.d.ts +46 -0
- package/dist/types/util.d.ts +7 -0
- package/package.json +34 -6
- package/releaseNotes.json +13 -1
- package/.env.test +0 -5
- package/connector/proxy/engine.js +0 -165
- package/connector/proxy/index.js +0 -500
- package/connector/registry.js +0 -252
- package/docs/README.md +0 -50
- package/docs/architecture.md +0 -94
- package/docs/connectors.md +0 -116
- package/docs/handlers.md +0 -128
- package/docs/libraries.md +0 -98
- package/docs/models.md +0 -146
- package/docs/routes.md +0 -119
- package/docs/tests.md +0 -73
- package/handlers/calldown.js +0 -99
- package/jest.config.js +0 -57
- package/lib/constants.js +0 -9
- package/lib/encode.js +0 -30
- package/lib/errorHandler.js +0 -218
- package/lib/jwt.js +0 -18
- package/lib/logger.js +0 -190
- package/lib/migrateCallLogsSchema.js +0 -237
- package/lib/ringcentral.js +0 -267
- package/mcp/README.md +0 -420
- package/mcp/tools/index.js +0 -51
- package/mcp/ui/App/App.tsx +0 -358
- package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
- package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
- package/mcp/ui/App/components/ConnectorList.tsx +0 -82
- package/mcp/ui/App/components/DebugPanel.tsx +0 -43
- package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
- package/mcp/ui/App/lib/callTool.ts +0 -130
- package/mcp/ui/App/lib/debugLog.ts +0 -41
- package/mcp/ui/App/lib/developerPortal.ts +0 -111
- package/mcp/ui/App/main.css +0 -6
- package/mcp/ui/App/root.tsx +0 -13
- package/mcp/ui/dist/index.html +0 -53
- package/mcp/ui/vite.config.ts +0 -16
- package/models/accountDataModel.js +0 -34
- package/models/adminConfigModel.js +0 -35
- package/models/callLogModel.js +0 -39
- package/models/dynamo/connectorSchema.js +0 -146
- package/models/llmSessionModel.js +0 -17
- package/models/sequelize.js +0 -17
- package/models/userModel.js +0 -45
- package/test/connector/developerPortal.test.js +0 -166
- package/test/connector/mock.test.js +0 -131
- package/test/connector/proxy/engine.test.js +0 -211
- package/test/connector/proxy/index.test.js +0 -525
- package/test/connector/proxy/sample.json +0 -162
- package/test/connector/registry.test.js +0 -416
- package/test/handlers/admin.test.js +0 -960
- package/test/handlers/appointment.test.js +0 -260
- package/test/handlers/auth.test.js +0 -1096
- package/test/handlers/calldown.test.js +0 -310
- package/test/handlers/contact.test.js +0 -1014
- package/test/handlers/disposition.test.js +0 -396
- package/test/handlers/log.test.js +0 -1847
- package/test/handlers/managedAuth.test.js +0 -458
- package/test/handlers/managedOAuth.test.js +0 -262
- package/test/handlers/plugin.test.js +0 -429
- package/test/handlers/user.test.js +0 -381
- package/test/index.test.js +0 -301
- package/test/lib/analytics.test.js +0 -146
- package/test/lib/authSession.test.js +0 -173
- package/test/lib/cacheCleanup.test.js +0 -127
- package/test/lib/callLogComposer.test.js +0 -1231
- package/test/lib/debugTracer.test.js +0 -328
- package/test/lib/encode.test.js +0 -59
- package/test/lib/errorHandler.test.js +0 -246
- package/test/lib/generalErrorMessage.test.js +0 -82
- package/test/lib/jwt.test.js +0 -176
- package/test/lib/logger.test.js +0 -206
- package/test/lib/oauth.test.js +0 -359
- package/test/lib/ringcentral.test.js +0 -467
- package/test/lib/s3ErrorLogReport.test.js +0 -187
- package/test/lib/sharedSMSComposer.test.js +0 -1084
- package/test/lib/util.test.js +0 -329
- package/test/mcp/mcpHandler.test.js +0 -73
- package/test/mcp/mcpHandlerMore.test.js +0 -384
- package/test/mcp/tools/appointmentTools.test.js +0 -362
- package/test/mcp/tools/checkAuthStatus.test.js +0 -83
- package/test/mcp/tools/createCallLog.test.js +0 -436
- package/test/mcp/tools/createContact.test.js +0 -58
- package/test/mcp/tools/createMessageLog.test.js +0 -595
- package/test/mcp/tools/doAuth.test.js +0 -113
- package/test/mcp/tools/findContactByName.test.js +0 -275
- package/test/mcp/tools/findContactByPhone.test.js +0 -296
- package/test/mcp/tools/getCallLog.test.js +0 -298
- package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
- package/test/mcp/tools/getPublicConnectors.test.js +0 -107
- package/test/mcp/tools/getSessionInfo.test.js +0 -127
- package/test/mcp/tools/logout.test.js +0 -233
- package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
- package/test/mcp/tools/updateCallLog.test.js +0 -360
- package/test/models/accountDataModel.test.js +0 -98
- package/test/models/callDownListModel.test.js +0 -125
- package/test/models/dynamo/connectorSchema.test.js +0 -189
- package/test/models/dynamo/lockSchema.test.js +0 -37
- package/test/models/dynamo/noteCacheSchema.test.js +0 -45
- package/test/models/llmSessionModel.test.js +0 -91
- package/test/models/models.test.js +0 -660
- package/test/routes/calldownRoutes.test.js +0 -224
- package/test/routes/coreRouterBroadRoutes.test.js +0 -855
- package/test/routes/dispositionRoutes.test.js +0 -192
- package/test/routes/managedAuthRoutes.test.js +0 -386
- package/test/routes/pluginRoutes.test.js +0 -262
- package/test/setup.js +0 -178
- /package/{mcp → dist/mcp}/ui/index.html +0 -0
- /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
- /package/{mcp → dist/mcp}/ui/package.json +0 -0
- /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const appointmentCore = /** @type {any} */ (require('../../handlers/appointment'));
|
|
5
7
|
/**
|
|
6
8
|
* MCP Tool: Create Appointment
|
|
7
9
|
*
|
|
8
10
|
* Creates a new appointment/event in the CRM platform.
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
12
|
const toolDefinition = {
|
|
12
13
|
name: 'createAppointment',
|
|
13
14
|
description: '⚠️ REQUIRES CRM CONNECTION. | Create a new appointment or event in the CRM platform. Returns the created appointment ID and details.',
|
|
@@ -62,7 +63,6 @@ const toolDefinition = {
|
|
|
62
63
|
destructiveHint: false
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
|
-
|
|
66
66
|
/**
|
|
67
67
|
* Execute the createAppointment tool
|
|
68
68
|
* @param {Object} args
|
|
@@ -72,47 +72,38 @@ const toolDefinition = {
|
|
|
72
72
|
* @param {string} args.startTimeUtc - ISO 8601 UTC start time
|
|
73
73
|
* @param {number} args.durationMinutes - Duration in minutes
|
|
74
74
|
* @param {Array} [args.contacts] - List of contact IDs or contact objects to invite
|
|
75
|
-
* @returns {
|
|
75
|
+
* @returns {Promise<any>} Result with created appointment ID and data
|
|
76
76
|
*/
|
|
77
77
|
async function execute(args) {
|
|
78
78
|
try {
|
|
79
79
|
const { jwtToken, title, summary, startTimeUtc, durationMinutes, contacts } = args;
|
|
80
|
-
|
|
81
80
|
if (!jwtToken) {
|
|
82
81
|
throw new Error('Please go to Settings and authorize CRM platform');
|
|
83
82
|
}
|
|
84
|
-
|
|
85
83
|
if (!title) {
|
|
86
84
|
throw new Error('title is required');
|
|
87
85
|
}
|
|
88
|
-
|
|
89
86
|
if (!startTimeUtc) {
|
|
90
87
|
throw new Error('startTimeUtc is required (ISO 8601 UTC format, e.g. "2026-05-10T14:00:00Z")');
|
|
91
88
|
}
|
|
92
|
-
|
|
93
89
|
if (durationMinutes == null) {
|
|
94
90
|
throw new Error('durationMinutes is required');
|
|
95
91
|
}
|
|
96
|
-
|
|
97
92
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
98
93
|
if (!decodedToken) {
|
|
99
94
|
throw new Error('Invalid JWT token');
|
|
100
95
|
}
|
|
101
96
|
const { id: userId, platform } = decodedToken;
|
|
102
|
-
|
|
103
97
|
if (!userId) {
|
|
104
98
|
throw new Error('Invalid JWT token: userId not found');
|
|
105
99
|
}
|
|
106
|
-
|
|
107
100
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
108
101
|
if (!platformModule) {
|
|
109
102
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
110
103
|
}
|
|
111
|
-
|
|
112
104
|
if (!platformModule.createAppointment) {
|
|
113
105
|
throw new Error(`createAppointment is not implemented for platform: ${platform}`);
|
|
114
106
|
}
|
|
115
|
-
|
|
116
107
|
const payload = {
|
|
117
108
|
title,
|
|
118
109
|
summary: summary ?? '',
|
|
@@ -120,13 +111,11 @@ async function execute(args) {
|
|
|
120
111
|
durationMinutes: Number(durationMinutes),
|
|
121
112
|
contacts: contacts ?? []
|
|
122
113
|
};
|
|
123
|
-
|
|
124
114
|
const { successful, appointmentId, appointment, returnMessage } = await appointmentCore.createAppointment({
|
|
125
115
|
platform,
|
|
126
116
|
userId,
|
|
127
117
|
payload
|
|
128
118
|
});
|
|
129
|
-
|
|
130
119
|
if (successful) {
|
|
131
120
|
return {
|
|
132
121
|
success: true,
|
|
@@ -152,6 +141,5 @@ async function execute(args) {
|
|
|
152
141
|
};
|
|
153
142
|
}
|
|
154
143
|
}
|
|
155
|
-
|
|
156
144
|
exports.definition = toolDefinition;
|
|
157
145
|
exports.execute = execute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const logCore = /** @type {any} */ (require('../../handlers/log'));
|
|
7
|
+
const contactCore = /** @type {any} */ (require('../../handlers/contact'));
|
|
8
|
+
const util = /** @type {any} */ (require('../../lib/util'));
|
|
9
|
+
const { CallLogModel: RawCallLogModel } = require('../../models/callLogModel');
|
|
10
|
+
const CallLogModel = /** @type {any} */ (RawCallLogModel);
|
|
11
|
+
const { buildCallLogSessionWhere: rawBuildCallLogSessionWhere, getCallLogExtensionNumber: rawGetCallLogExtensionNumber } = require('../../lib/callLogLookup');
|
|
12
|
+
const buildCallLogSessionWhere = /** @type {any} */ (rawBuildCallLogSessionWhere);
|
|
13
|
+
const getCallLogExtensionNumber = /** @type {any} */ (rawGetCallLogExtensionNumber);
|
|
8
14
|
/**
|
|
9
15
|
* MCP Tool: Create Call Log
|
|
10
|
-
*
|
|
16
|
+
*
|
|
11
17
|
* This tool creates a call log in the CRM platform.
|
|
12
18
|
*/
|
|
13
|
-
|
|
14
19
|
const toolDefinition = {
|
|
15
20
|
name: 'createCallLog',
|
|
16
21
|
description: '⚠️ REQUIRES CRM CONNECTION. | Create only one call log in the CRM platform. Returns the created log ID if successful. To use with `rcGetCallLogs`: pass a single item from the `records[]` array directly as `incomingData.logInfo`.',
|
|
@@ -183,7 +188,6 @@ const toolDefinition = {
|
|
|
183
188
|
destructiveHint: false
|
|
184
189
|
}
|
|
185
190
|
};
|
|
186
|
-
|
|
187
191
|
/**
|
|
188
192
|
* Execute the createCallLog tool
|
|
189
193
|
* @param {Object} args - The tool arguments
|
|
@@ -196,29 +200,25 @@ const toolDefinition = {
|
|
|
196
200
|
* @param {string} [args.incomingData.aiNote] - AI-generated call summary
|
|
197
201
|
* @param {string} [args.incomingData.transcript] - Call transcript
|
|
198
202
|
* @param {Object} [args.incomingData.additionalSubmission] - Platform-specific custom fields
|
|
199
|
-
* @param {string} args.contactId -
|
|
200
|
-
* @
|
|
203
|
+
* @param {string} [args.incomingData.contactId] - CRM contact ID to associate with the call
|
|
204
|
+
* @param {string} [args.contactId] - Optional CRM contact ID to associate with the call
|
|
205
|
+
* @returns {Promise<any>} Result object with created log ID
|
|
201
206
|
*/
|
|
202
207
|
async function execute(args) {
|
|
203
208
|
try {
|
|
204
209
|
const { jwtToken, incomingData } = args;
|
|
205
|
-
|
|
206
210
|
if (!jwtToken) {
|
|
207
211
|
throw new Error('Please go to Settings and authorize CRM platform');
|
|
208
212
|
}
|
|
209
|
-
|
|
210
213
|
if (!incomingData) {
|
|
211
214
|
throw new Error('Incoming data must be provided');
|
|
212
215
|
}
|
|
213
|
-
|
|
214
216
|
// Validate logInfo exists
|
|
215
217
|
if (!incomingData.logInfo) {
|
|
216
218
|
throw new Error('incomingData.logInfo is required');
|
|
217
219
|
}
|
|
218
|
-
|
|
219
220
|
const { logInfo } = incomingData;
|
|
220
221
|
const extensionNumber = getCallLogExtensionNumber(incomingData);
|
|
221
|
-
|
|
222
222
|
// Check in DB if the call log already exists
|
|
223
223
|
const existingCallLog = await CallLogModel.findOne({
|
|
224
224
|
where: buildCallLogSessionWhere({
|
|
@@ -229,35 +229,28 @@ async function execute(args) {
|
|
|
229
229
|
if (existingCallLog) {
|
|
230
230
|
throw new Error(`Call log already exists for session ${logInfo.sessionId}`);
|
|
231
231
|
}
|
|
232
|
-
|
|
233
232
|
// Decode JWT to get userId and platform
|
|
234
233
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
235
234
|
if (!decodedToken) {
|
|
236
235
|
throw new Error('Invalid JWT token');
|
|
237
236
|
}
|
|
238
237
|
const { id: userId, platform } = decodedToken;
|
|
239
|
-
|
|
240
238
|
if (!userId) {
|
|
241
239
|
throw new Error('Invalid JWT token: userId not found');
|
|
242
240
|
}
|
|
243
|
-
|
|
244
241
|
// Get the platform connector module
|
|
245
242
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
246
|
-
|
|
247
243
|
if (!platformModule) {
|
|
248
244
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
249
245
|
}
|
|
250
|
-
|
|
251
246
|
// Check if createCallLog is implemented
|
|
252
247
|
if (!platformModule.createCallLog) {
|
|
253
248
|
throw new Error(`createCallLog is not implemented for platform: ${platform}`);
|
|
254
249
|
}
|
|
255
|
-
|
|
256
250
|
// Calculate hashed account ID
|
|
257
251
|
const hashedAccountId = incomingData.logInfo?.accountId
|
|
258
252
|
? util.getHashValue(incomingData.logInfo.accountId, process.env.HASH_KEY)
|
|
259
253
|
: undefined;
|
|
260
|
-
|
|
261
254
|
// Get contact Id from conversation
|
|
262
255
|
let contactId = args.contactId ?? null;
|
|
263
256
|
// Get contact Id from conversation if not provided
|
|
@@ -281,13 +274,12 @@ async function execute(args) {
|
|
|
281
274
|
success: false,
|
|
282
275
|
message: 'Cannot find the contact. Please create the contact first.',
|
|
283
276
|
error: 'Failed to get contact with number ' + contactNumber
|
|
284
|
-
}
|
|
277
|
+
};
|
|
285
278
|
}
|
|
286
279
|
}
|
|
287
280
|
else {
|
|
288
281
|
incomingData.contactId = contactId;
|
|
289
282
|
}
|
|
290
|
-
|
|
291
283
|
// Call the createCallLog method
|
|
292
284
|
const { successful, logId, returnMessage } = await logCore.createCallLog({
|
|
293
285
|
platform,
|
|
@@ -296,7 +288,6 @@ async function execute(args) {
|
|
|
296
288
|
hashedAccountId,
|
|
297
289
|
isFromSSCL: false
|
|
298
290
|
});
|
|
299
|
-
|
|
300
291
|
if (successful) {
|
|
301
292
|
return {
|
|
302
293
|
success: true,
|
|
@@ -321,7 +312,5 @@ async function execute(args) {
|
|
|
321
312
|
};
|
|
322
313
|
}
|
|
323
314
|
}
|
|
324
|
-
|
|
325
315
|
exports.definition = toolDefinition;
|
|
326
316
|
exports.execute = execute;
|
|
327
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const contactCore = /** @type {any} */ (require('../../handlers/contact'));
|
|
5
7
|
/**
|
|
6
8
|
* MCP Tool: Create Contact
|
|
7
|
-
*
|
|
9
|
+
*
|
|
8
10
|
* This tool creates a new contact in the CRM platform.
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
12
|
const toolDefinition = {
|
|
12
13
|
name: 'createContact',
|
|
13
14
|
description: '⚠️ REQUIRES CRM CONNECTION. | Create a new contact in the CRM platform. Returns the created contact information if successful.',
|
|
@@ -31,54 +32,44 @@ const toolDefinition = {
|
|
|
31
32
|
destructiveHint: false
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
|
|
35
35
|
/**
|
|
36
36
|
* Execute the createContact tool
|
|
37
37
|
* @param {Object} args - The tool arguments
|
|
38
38
|
* @param {string} args.jwtToken - JWT token with user and platform info
|
|
39
39
|
* @param {string} args.phoneNumber - Phone number of the new contact
|
|
40
40
|
* @param {string} args.newContactName - Name of the new contact
|
|
41
|
-
* @returns {
|
|
41
|
+
* @returns {Promise<any>} Result object with created contact information
|
|
42
42
|
*/
|
|
43
43
|
async function execute(args) {
|
|
44
44
|
try {
|
|
45
45
|
const { jwtToken, phoneNumber, newContactName } = args;
|
|
46
|
-
|
|
47
46
|
if (!jwtToken) {
|
|
48
47
|
throw new Error('Please go to Settings and authorize CRM platform');
|
|
49
48
|
}
|
|
50
|
-
|
|
51
49
|
if (!phoneNumber) {
|
|
52
50
|
throw new Error('Phone number is required');
|
|
53
51
|
}
|
|
54
|
-
|
|
55
52
|
if (!newContactName) {
|
|
56
53
|
throw new Error('Contact name is required');
|
|
57
54
|
}
|
|
58
|
-
|
|
59
55
|
// Decode JWT to get userId and platform
|
|
60
56
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
61
57
|
if (!decodedToken) {
|
|
62
58
|
throw new Error('Invalid JWT token');
|
|
63
59
|
}
|
|
64
60
|
const { id: userId, platform } = decodedToken;
|
|
65
|
-
|
|
66
61
|
if (!userId) {
|
|
67
62
|
throw new Error('Invalid JWT token: userId not found');
|
|
68
63
|
}
|
|
69
|
-
|
|
70
64
|
// Get the platform connector module
|
|
71
65
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
72
|
-
|
|
73
66
|
if (!platformModule) {
|
|
74
67
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
// Check if createContact is implemented
|
|
78
70
|
if (!platformModule.createContact) {
|
|
79
71
|
throw new Error(`createContact is not implemented for platform: ${platform}`);
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
// Call the createContact method
|
|
83
74
|
const { successful, returnMessage, contact } = await contactCore.createContact({
|
|
84
75
|
platform,
|
|
@@ -86,7 +77,6 @@ async function execute(args) {
|
|
|
86
77
|
phoneNumber,
|
|
87
78
|
newContactName
|
|
88
79
|
});
|
|
89
|
-
|
|
90
80
|
if (successful) {
|
|
91
81
|
return {
|
|
92
82
|
success: true,
|
|
@@ -111,7 +101,5 @@ async function execute(args) {
|
|
|
111
101
|
};
|
|
112
102
|
}
|
|
113
103
|
}
|
|
114
|
-
|
|
115
104
|
exports.definition = toolDefinition;
|
|
116
105
|
exports.execute = execute;
|
|
117
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const logCore = /** @type {any} */ (require('../../handlers/log'));
|
|
5
7
|
/**
|
|
6
8
|
* MCP Tool: Create Message Log
|
|
7
|
-
*
|
|
9
|
+
*
|
|
8
10
|
* This tool creates message logs in the CRM platform.
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
12
|
const toolDefinition = {
|
|
12
13
|
name: 'createMessageLog',
|
|
13
14
|
description: '⚠️ REQUIRES AUTHENTICATION: User must first authenticate using the "auth" tool to obtain a JWT token before using this tool. | Create message logs in the CRM platform. Returns the created log IDs if successful.',
|
|
@@ -147,7 +148,7 @@ const toolDefinition = {
|
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
},
|
|
150
|
-
conversationId:{
|
|
151
|
+
conversationId: {
|
|
151
152
|
type: 'string',
|
|
152
153
|
description: 'Conversation ID'
|
|
153
154
|
},
|
|
@@ -167,7 +168,7 @@ const toolDefinition = {
|
|
|
167
168
|
type: 'string',
|
|
168
169
|
description: 'Conversation date'
|
|
169
170
|
},
|
|
170
|
-
creationTime:{
|
|
171
|
+
creationTime: {
|
|
171
172
|
type: 'number',
|
|
172
173
|
description: 'Conversation creation time'
|
|
173
174
|
}
|
|
@@ -203,60 +204,49 @@ const toolDefinition = {
|
|
|
203
204
|
required: ['jwtToken', 'incomingData']
|
|
204
205
|
}
|
|
205
206
|
};
|
|
206
|
-
|
|
207
207
|
/**
|
|
208
208
|
* Execute the createMessageLog tool
|
|
209
209
|
* @param {Object} args - The tool arguments
|
|
210
210
|
* @param {string} args.jwtToken - JWT token with user and platform info
|
|
211
211
|
* @param {Object} args.incomingData - Message log data
|
|
212
|
-
* @returns {
|
|
212
|
+
* @returns {Promise<any>} Result object with created log IDs
|
|
213
213
|
*/
|
|
214
214
|
async function execute(args) {
|
|
215
215
|
try {
|
|
216
216
|
const { jwtToken, incomingData } = args;
|
|
217
|
-
|
|
218
217
|
if (!jwtToken) {
|
|
219
218
|
throw new Error('Please go to Settings and authorize CRM platform');
|
|
220
219
|
}
|
|
221
|
-
|
|
222
220
|
if (!incomingData) {
|
|
223
221
|
throw new Error('Incoming data must be provided');
|
|
224
222
|
}
|
|
225
|
-
|
|
226
|
-
if(incomingData.conversation && !incomingData.logInfo) {
|
|
223
|
+
if (incomingData.conversation && !incomingData.logInfo) {
|
|
227
224
|
incomingData.logInfo = incomingData.conversation;
|
|
228
225
|
}
|
|
229
|
-
|
|
230
226
|
// Decode JWT to get userId and platform
|
|
231
227
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
232
228
|
if (!decodedToken) {
|
|
233
229
|
throw new Error('Invalid JWT token');
|
|
234
230
|
}
|
|
235
231
|
const { id: userId, platform } = decodedToken;
|
|
236
|
-
|
|
237
232
|
if (!userId) {
|
|
238
233
|
throw new Error('Invalid JWT token: userId not found');
|
|
239
234
|
}
|
|
240
|
-
|
|
241
235
|
// Get the platform connector module
|
|
242
236
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
243
|
-
|
|
244
237
|
if (!platformModule) {
|
|
245
238
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
246
239
|
}
|
|
247
|
-
|
|
248
240
|
// Check if createMessageLog is implemented
|
|
249
241
|
if (!platformModule.createMessageLog) {
|
|
250
242
|
throw new Error(`createMessageLog is not implemented for platform: ${platform}`);
|
|
251
243
|
}
|
|
252
|
-
|
|
253
244
|
// Call the createMessageLog method
|
|
254
|
-
const { successful, returnMessage, logIds } = await logCore.createMessageLog({
|
|
255
|
-
platform,
|
|
256
|
-
userId,
|
|
245
|
+
const { successful, returnMessage, logIds } = await logCore.createMessageLog({
|
|
246
|
+
platform,
|
|
247
|
+
userId,
|
|
257
248
|
incomingData
|
|
258
249
|
});
|
|
259
|
-
|
|
260
250
|
if (successful) {
|
|
261
251
|
return {
|
|
262
252
|
success: true,
|
|
@@ -281,7 +271,5 @@ async function execute(args) {
|
|
|
281
271
|
};
|
|
282
272
|
}
|
|
283
273
|
}
|
|
284
|
-
|
|
285
274
|
exports.definition = toolDefinition;
|
|
286
275
|
exports.execute = execute;
|
|
287
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const { createAuthSession: rawCreateAuthSession } = require('../../lib/authSession');
|
|
5
|
+
const createAuthSession = /** @type {any} */ (rawCreateAuthSession);
|
|
3
6
|
/**
|
|
4
7
|
* MCP Tool: Do Authentication (widget-only)
|
|
5
8
|
*
|
|
@@ -8,7 +11,6 @@ const { createAuthSession } = require('../../lib/authSession');
|
|
|
8
11
|
* then calls this endpoint in the background to register the session in the DB
|
|
9
12
|
* so the OAuth callback can resolve it.
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
14
|
const toolDefinition = {
|
|
13
15
|
name: 'doAuth',
|
|
14
16
|
description: 'Create a server-side OAuth session. Widget-only — not called by AI model.',
|
|
@@ -19,12 +21,16 @@ const toolDefinition = {
|
|
|
19
21
|
type: 'string',
|
|
20
22
|
description: 'Connector platform name'
|
|
21
23
|
},
|
|
24
|
+
sessionId: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Server-issued widget session ID'
|
|
27
|
+
},
|
|
22
28
|
hostname: {
|
|
23
29
|
type: 'string',
|
|
24
30
|
description: 'Resolved hostname for the CRM instance'
|
|
25
31
|
}
|
|
26
32
|
},
|
|
27
|
-
required: ['connectorName']
|
|
33
|
+
required: ['sessionId', 'connectorName']
|
|
28
34
|
},
|
|
29
35
|
annotations: {
|
|
30
36
|
readOnlyHint: false,
|
|
@@ -32,22 +38,21 @@ const toolDefinition = {
|
|
|
32
38
|
destructiveHint: false
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
|
-
|
|
36
41
|
async function execute(args) {
|
|
37
42
|
try {
|
|
38
|
-
const { sessionId, connectorName, hostname = '' } = args;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return { success: false, error: 'Missing required fields: sessionId, connectorName' };
|
|
43
|
+
const { sessionId, connectorName, hostname = '', rcExtensionId, openaiSessionId } = args;
|
|
44
|
+
if (!sessionId || !connectorName || !rcExtensionId) {
|
|
45
|
+
return { success: false, error: 'Missing required fields: sessionId, connectorName, rcExtensionId' };
|
|
42
46
|
}
|
|
43
|
-
|
|
44
47
|
await createAuthSession(sessionId, {
|
|
45
48
|
platform: connectorName,
|
|
46
49
|
hostname,
|
|
50
|
+
rcExtensionId,
|
|
51
|
+
openaiSessionId,
|
|
47
52
|
});
|
|
48
|
-
|
|
49
53
|
return { success: true };
|
|
50
|
-
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
51
56
|
return {
|
|
52
57
|
success: false,
|
|
53
58
|
error: error.message || 'Unknown error occurred',
|
|
@@ -55,6 +60,5 @@ async function execute(args) {
|
|
|
55
60
|
};
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
|
|
59
63
|
exports.definition = toolDefinition;
|
|
60
64
|
exports.execute = execute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const contactCore = /** @type {any} */ (require('../../handlers/contact'));
|
|
5
7
|
/**
|
|
6
8
|
* MCP Tool: Find Contact With Name
|
|
7
|
-
*
|
|
9
|
+
*
|
|
8
10
|
* This tool searches for a contact in the CRM platform by name.
|
|
9
11
|
* It uses the platform-specific connector to find matching contacts.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
13
|
const toolDefinition = {
|
|
13
14
|
name: 'findContactByName',
|
|
14
15
|
description: '⚠️ REQUIRES CRM CONNECTION. | Search for a contact in the CRM platform by name. Returns contact details if found.',
|
|
@@ -28,12 +29,12 @@ const toolDefinition = {
|
|
|
28
29
|
destructiveHint: false
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
|
|
32
32
|
/**
|
|
33
33
|
* Execute the findContactByName tool
|
|
34
34
|
* @param {Object} args - The tool arguments
|
|
35
35
|
* @param {string} args.name - Name to search for
|
|
36
|
-
* @
|
|
36
|
+
* @param {string} args.jwtToken - JWT token with user and platform info
|
|
37
|
+
* @returns {Promise<any>} Result object with contact information
|
|
37
38
|
*/
|
|
38
39
|
async function execute(args) {
|
|
39
40
|
try {
|
|
@@ -47,23 +48,18 @@ async function execute(args) {
|
|
|
47
48
|
throw new Error('Invalid JWT token');
|
|
48
49
|
}
|
|
49
50
|
const { id: userId, platform } = decodedToken;
|
|
50
|
-
|
|
51
51
|
if (!userId) {
|
|
52
52
|
throw new Error('Invalid JWT token: userId not found');
|
|
53
53
|
}
|
|
54
|
-
|
|
55
54
|
// Get the platform connector module
|
|
56
55
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
57
|
-
|
|
58
56
|
if (!platformModule) {
|
|
59
57
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
// Check if findContactByName is implemented
|
|
63
60
|
if (!platformModule.findContactWithName) {
|
|
64
61
|
throw new Error(`findContactByName is not implemented for platform: ${platform}`);
|
|
65
62
|
}
|
|
66
|
-
|
|
67
63
|
// Call the findContactByName method
|
|
68
64
|
const { successful, returnMessage, contact } = await contactCore.findContactWithName({ platform, userId, name });
|
|
69
65
|
if (successful) {
|
|
@@ -87,7 +83,5 @@ async function execute(args) {
|
|
|
87
83
|
};
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
|
-
|
|
91
86
|
exports.definition = toolDefinition;
|
|
92
87
|
exports.execute = execute;
|
|
93
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jwt = /** @type {any} */ (require('../../lib/jwt'));
|
|
5
|
+
const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
|
|
6
|
+
const contactCore = /** @type {any} */ (require('../../handlers/contact'));
|
|
5
7
|
/**
|
|
6
8
|
* MCP Tool: Find Contact
|
|
7
|
-
*
|
|
9
|
+
*
|
|
8
10
|
* This tool searches for a contact in the CRM platform by phone number.
|
|
9
11
|
* It uses the platform-specific connector to find matching contacts.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
13
|
const toolDefinition = {
|
|
13
14
|
name: 'findContactByPhone',
|
|
14
15
|
description: '⚠️ REQUIRES CRM CONNECTION. | Search for a contact in the CRM platform by phone number. Returns contact details if found.',
|
|
@@ -36,7 +37,6 @@ const toolDefinition = {
|
|
|
36
37
|
destructiveHint: false
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
|
-
|
|
40
40
|
/**
|
|
41
41
|
* Execute the findContactByPhone tool
|
|
42
42
|
* @param {Object} args - The tool arguments
|
|
@@ -44,35 +44,29 @@ const toolDefinition = {
|
|
|
44
44
|
* @param {string} [args.phoneNumber] - Phone number to search for
|
|
45
45
|
* @param {string} [args.overridingFormat] - Overriding format to search for
|
|
46
46
|
* @param {string} [args.isExtension] - Whether the request is from an extension
|
|
47
|
-
* @returns {
|
|
47
|
+
* @returns {Promise<any>} Result object with contact information
|
|
48
48
|
*/
|
|
49
49
|
async function execute(args) {
|
|
50
50
|
try {
|
|
51
51
|
const { jwtToken, phoneNumber, overridingFormat, isExtension } = args;
|
|
52
|
-
|
|
53
52
|
// Decode JWT to get userId and platform
|
|
54
53
|
const decodedToken = jwt.decodeJwt(jwtToken);
|
|
55
54
|
if (!decodedToken) {
|
|
56
55
|
throw new Error('Invalid JWT token');
|
|
57
56
|
}
|
|
58
57
|
const { id: userId, platform } = decodedToken;
|
|
59
|
-
|
|
60
58
|
if (!userId) {
|
|
61
59
|
throw new Error('Invalid JWT token: userId not found');
|
|
62
60
|
}
|
|
63
|
-
|
|
64
61
|
// Get the platform connector module
|
|
65
62
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
66
|
-
|
|
67
63
|
if (!platformModule) {
|
|
68
64
|
throw new Error(`Platform connector not found for: ${platform}`);
|
|
69
65
|
}
|
|
70
|
-
|
|
71
66
|
// Check if findContactByPhone is implemented
|
|
72
67
|
if (!platformModule.findContact) {
|
|
73
68
|
throw new Error(`findContactByPhone is not implemented for platform: ${platform}`);
|
|
74
69
|
}
|
|
75
|
-
|
|
76
70
|
// Call the findContactByPhone method
|
|
77
71
|
const { successful, returnMessage, contact } = await contactCore.findContact({ platform, userId, phoneNumber, overridingFormat: overridingFormat ?? '', isExtension: isExtension ?? false });
|
|
78
72
|
if (successful) {
|
|
@@ -96,6 +90,5 @@ async function execute(args) {
|
|
|
96
90
|
};
|
|
97
91
|
}
|
|
98
92
|
}
|
|
99
|
-
|
|
100
93
|
exports.definition = toolDefinition;
|
|
101
94
|
exports.execute = execute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|