@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.
Files changed (287) hide show
  1. package/README.md +17 -16
  2. package/dist/connector/developerPortal.d.ts +6 -0
  3. package/{connector → dist/connector}/developerPortal.js +29 -12
  4. package/dist/connector/mock.d.ts +1 -0
  5. package/{connector → dist/connector}/mock.js +33 -17
  6. package/dist/connector/proxy/engine.d.ts +10 -0
  7. package/dist/connector/proxy/engine.js +222 -0
  8. package/dist/connector/proxy/index.d.ts +5 -0
  9. package/dist/connector/proxy/index.js +511 -0
  10. package/dist/connector/registry.d.ts +1 -0
  11. package/dist/connector/registry.js +243 -0
  12. package/dist/handlers/admin.d.ts +1 -0
  13. package/{handlers → dist/handlers}/admin.js +137 -78
  14. package/dist/handlers/appointment.d.ts +9 -0
  15. package/{handlers → dist/handlers}/appointment.js +58 -29
  16. package/dist/handlers/auth.d.ts +9 -0
  17. package/{handlers → dist/handlers}/auth.js +68 -40
  18. package/dist/handlers/calldown.d.ts +10 -0
  19. package/dist/handlers/calldown.js +134 -0
  20. package/dist/handlers/contact.d.ts +1 -0
  21. package/{handlers → dist/handlers}/contact.js +61 -39
  22. package/dist/handlers/disposition.d.ts +1 -0
  23. package/{handlers → dist/handlers}/disposition.js +20 -10
  24. package/dist/handlers/log.d.ts +1 -0
  25. package/{handlers → dist/handlers}/log.js +91 -124
  26. package/dist/handlers/managedAuth.d.ts +1 -0
  27. package/{handlers → dist/handlers}/managedAuth.js +134 -61
  28. package/dist/handlers/managedOAuth.d.ts +13 -0
  29. package/{handlers → dist/handlers}/managedOAuth.js +102 -30
  30. package/dist/handlers/plugin.d.ts +1 -0
  31. package/{handlers → dist/handlers}/plugin.js +59 -27
  32. package/dist/handlers/user.d.ts +1 -0
  33. package/{handlers → dist/handlers}/user.js +45 -27
  34. package/dist/index.d.ts +1 -0
  35. package/{index.js → dist/index.js} +548 -450
  36. package/dist/jest.config.d.ts +1 -0
  37. package/dist/jest.config.js +65 -0
  38. package/dist/lib/analytics.d.ts +4 -0
  39. package/{lib → dist/lib}/analytics.js +8 -6
  40. package/dist/lib/authSession.d.ts +5 -0
  41. package/{lib → dist/lib}/authSession.js +15 -43
  42. package/dist/lib/cacheCleanup.d.ts +4 -0
  43. package/{lib → dist/lib}/cacheCleanup.js +5 -17
  44. package/dist/lib/callLogComposer.d.ts +109 -0
  45. package/{lib → dist/lib}/callLogComposer.js +157 -197
  46. package/dist/lib/callLogLookup.d.ts +6 -0
  47. package/{lib → dist/lib}/callLogLookup.js +12 -34
  48. package/dist/lib/constants.d.ts +6 -0
  49. package/dist/lib/constants.js +9 -0
  50. package/dist/lib/debugTracer.d.ts +17 -0
  51. package/{lib → dist/lib}/debugTracer.js +7 -83
  52. package/dist/lib/encode.d.ts +3 -0
  53. package/dist/lib/encode.js +50 -0
  54. package/dist/lib/errorHandler.d.ts +7 -0
  55. package/dist/lib/errorHandler.js +161 -0
  56. package/dist/lib/generalErrorMessage.d.ts +7 -0
  57. package/{lib → dist/lib}/generalErrorMessage.js +6 -6
  58. package/dist/lib/jwt.d.ts +4 -0
  59. package/dist/lib/jwt.js +18 -0
  60. package/dist/lib/logger.d.ts +24 -0
  61. package/dist/lib/logger.js +126 -0
  62. package/dist/lib/migrateCallLogsSchema.d.ts +32 -0
  63. package/dist/lib/migrateCallLogsSchema.js +339 -0
  64. package/dist/lib/oauth.d.ts +4 -0
  65. package/{lib → dist/lib}/oauth.js +157 -160
  66. package/dist/lib/ringcentral.d.ts +24 -0
  67. package/dist/lib/ringcentral.js +226 -0
  68. package/dist/lib/s3ErrorLogReport.d.ts +4 -0
  69. package/{lib → dist/lib}/s3ErrorLogReport.js +11 -23
  70. package/dist/lib/sharedSMSComposer.d.ts +7 -0
  71. package/{lib → dist/lib}/sharedSMSComposer.js +21 -107
  72. package/dist/lib/util.d.ts +7 -0
  73. package/{lib → dist/lib}/util.js +9 -20
  74. package/dist/mcp/lib/oauthError.d.ts +1 -0
  75. package/dist/mcp/lib/oauthError.js +25 -0
  76. package/dist/mcp/lib/validator.d.ts +1 -0
  77. package/{mcp → dist/mcp}/lib/validator.js +16 -20
  78. package/dist/mcp/lib/widgetSessionToken.d.ts +1 -0
  79. package/dist/mcp/lib/widgetSessionToken.js +46 -0
  80. package/dist/mcp/mcpHandler.d.ts +8 -0
  81. package/{mcp → dist/mcp}/mcpHandler.js +98 -88
  82. package/dist/mcp/tools/cancelAppointment.d.ts +1 -0
  83. package/{mcp → dist/mcp}/tools/cancelAppointment.js +7 -16
  84. package/dist/mcp/tools/checkAuthStatus.d.ts +1 -0
  85. package/{mcp → dist/mcp}/tools/checkAuthStatus.js +21 -14
  86. package/dist/mcp/tools/confirmAppointment.d.ts +1 -0
  87. package/{mcp → dist/mcp}/tools/confirmAppointment.js +7 -16
  88. package/dist/mcp/tools/createAppointment.d.ts +1 -0
  89. package/{mcp → dist/mcp}/tools/createAppointment.js +7 -19
  90. package/dist/mcp/tools/createCallLog.d.ts +1 -0
  91. package/{mcp → dist/mcp}/tools/createCallLog.js +18 -29
  92. package/dist/mcp/tools/createContact.d.ts +1 -0
  93. package/{mcp → dist/mcp}/tools/createContact.js +8 -20
  94. package/dist/mcp/tools/createMessageLog.d.ts +1 -0
  95. package/{mcp → dist/mcp}/tools/createMessageLog.js +14 -26
  96. package/dist/mcp/tools/doAuth.d.ts +1 -0
  97. package/{mcp → dist/mcp}/tools/doAuth.js +17 -13
  98. package/dist/mcp/tools/findContactByName.d.ts +1 -0
  99. package/{mcp → dist/mcp}/tools/findContactByName.js +9 -15
  100. package/dist/mcp/tools/findContactByPhone.d.ts +1 -0
  101. package/{mcp → dist/mcp}/tools/findContactByPhone.js +8 -15
  102. package/dist/mcp/tools/getCallLog.d.ts +1 -0
  103. package/{mcp → dist/mcp}/tools/getCallLog.js +12 -21
  104. package/dist/mcp/tools/getGoogleFilePicker.d.ts +1 -0
  105. package/{mcp → dist/mcp}/tools/getGoogleFilePicker.js +9 -18
  106. package/dist/mcp/tools/getHelp.d.ts +1 -0
  107. package/{mcp → dist/mcp}/tools/getHelp.js +5 -6
  108. package/dist/mcp/tools/getPublicConnectors.d.ts +1 -0
  109. package/{mcp → dist/mcp}/tools/getPublicConnectors.js +19 -18
  110. package/dist/mcp/tools/getSessionInfo.d.ts +1 -0
  111. package/{mcp → dist/mcp}/tools/getSessionInfo.js +10 -16
  112. package/dist/mcp/tools/index.d.ts +8 -0
  113. package/dist/mcp/tools/index.js +50 -0
  114. package/dist/mcp/tools/listAppointments.d.ts +1 -0
  115. package/{mcp → dist/mcp}/tools/listAppointments.js +7 -19
  116. package/dist/mcp/tools/logout.d.ts +1 -0
  117. package/{mcp → dist/mcp}/tools/logout.js +16 -14
  118. package/dist/mcp/tools/rcGetCallLogs.d.ts +1 -0
  119. package/{mcp → dist/mcp}/tools/rcGetCallLogs.js +10 -8
  120. package/dist/mcp/tools/updateAppointment.d.ts +1 -0
  121. package/{mcp → dist/mcp}/tools/updateAppointment.js +17 -22
  122. package/dist/mcp/tools/updateCallLog.d.ts +1 -0
  123. package/{mcp → dist/mcp}/tools/updateCallLog.js +16 -26
  124. package/dist/models/accountDataModel.d.ts +3 -0
  125. package/dist/models/accountDataModel.js +39 -0
  126. package/dist/models/adminConfigModel.d.ts +2 -0
  127. package/dist/models/adminConfigModel.js +39 -0
  128. package/dist/models/cacheModel.d.ts +2 -0
  129. package/{models → dist/models}/cacheModel.js +7 -3
  130. package/dist/models/callDownListModel.d.ts +2 -0
  131. package/{models → dist/models}/callDownListModel.js +8 -4
  132. package/dist/models/callLogModel.d.ts +2 -0
  133. package/dist/models/callLogModel.js +43 -0
  134. package/dist/models/dynamo/connectorSchema.d.ts +2 -0
  135. package/dist/models/dynamo/connectorSchema.js +141 -0
  136. package/dist/models/dynamo/lockSchema.d.ts +2 -0
  137. package/{models → dist/models}/dynamo/lockSchema.js +5 -7
  138. package/dist/models/dynamo/noteCacheSchema.d.ts +2 -0
  139. package/{models → dist/models}/dynamo/noteCacheSchema.js +4 -6
  140. package/dist/models/llmSessionModel.d.ts +2 -0
  141. package/dist/models/llmSessionModel.js +21 -0
  142. package/dist/models/messageLogModel.d.ts +2 -0
  143. package/{models → dist/models}/messageLogModel.js +8 -4
  144. package/dist/models/sequelize.d.ts +2 -0
  145. package/dist/models/sequelize.js +68 -0
  146. package/dist/models/userModel.d.ts +2 -0
  147. package/dist/models/userModel.js +49 -0
  148. package/dist/package.json +100 -0
  149. package/dist/releaseNotes.json +1222 -0
  150. package/dist/tsconfig.json +14 -0
  151. package/dist/types/admin.d.ts +141 -0
  152. package/dist/types/analytics.d.ts +14 -0
  153. package/dist/types/appointment.d.ts +50 -0
  154. package/dist/types/auth.d.ts +137 -0
  155. package/dist/types/authSession.d.ts +35 -0
  156. package/dist/types/cacheCleanup.d.ts +12 -0
  157. package/dist/types/calldown.d.ts +54 -0
  158. package/dist/types/common.d.ts +46 -0
  159. package/dist/types/connector.d.ts +165 -0
  160. package/dist/types/contact.d.ts +125 -0
  161. package/dist/types/errorHandler.d.ts +60 -0
  162. package/dist/types/index.d.ts +76 -0
  163. package/dist/types/json.d.ts +9 -0
  164. package/dist/types/jwt.d.ts +8 -0
  165. package/dist/types/logging.d.ts +224 -0
  166. package/dist/types/managedAuth.d.ts +114 -0
  167. package/dist/types/managedOAuth.d.ts +59 -0
  168. package/dist/types/manifest.d.ts +120 -0
  169. package/dist/types/migration.d.ts +15 -0
  170. package/dist/types/plugin.d.ts +74 -0
  171. package/dist/types/ringcentral.d.ts +61 -0
  172. package/dist/types/s3ErrorLogReport.d.ts +16 -0
  173. package/dist/types/sharedSMSComposer.d.ts +105 -0
  174. package/dist/types/user.d.ts +46 -0
  175. package/dist/types/util.d.ts +7 -0
  176. package/package.json +34 -6
  177. package/releaseNotes.json +13 -1
  178. package/.env.test +0 -5
  179. package/connector/proxy/engine.js +0 -165
  180. package/connector/proxy/index.js +0 -500
  181. package/connector/registry.js +0 -252
  182. package/docs/README.md +0 -50
  183. package/docs/architecture.md +0 -94
  184. package/docs/connectors.md +0 -116
  185. package/docs/handlers.md +0 -128
  186. package/docs/libraries.md +0 -98
  187. package/docs/models.md +0 -146
  188. package/docs/routes.md +0 -119
  189. package/docs/tests.md +0 -73
  190. package/handlers/calldown.js +0 -99
  191. package/jest.config.js +0 -57
  192. package/lib/constants.js +0 -9
  193. package/lib/encode.js +0 -30
  194. package/lib/errorHandler.js +0 -218
  195. package/lib/jwt.js +0 -18
  196. package/lib/logger.js +0 -190
  197. package/lib/migrateCallLogsSchema.js +0 -237
  198. package/lib/ringcentral.js +0 -267
  199. package/mcp/README.md +0 -420
  200. package/mcp/tools/index.js +0 -51
  201. package/mcp/ui/App/App.tsx +0 -358
  202. package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
  203. package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
  204. package/mcp/ui/App/components/ConnectorList.tsx +0 -82
  205. package/mcp/ui/App/components/DebugPanel.tsx +0 -43
  206. package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
  207. package/mcp/ui/App/lib/callTool.ts +0 -130
  208. package/mcp/ui/App/lib/debugLog.ts +0 -41
  209. package/mcp/ui/App/lib/developerPortal.ts +0 -111
  210. package/mcp/ui/App/main.css +0 -6
  211. package/mcp/ui/App/root.tsx +0 -13
  212. package/mcp/ui/dist/index.html +0 -53
  213. package/mcp/ui/vite.config.ts +0 -16
  214. package/models/accountDataModel.js +0 -34
  215. package/models/adminConfigModel.js +0 -35
  216. package/models/callLogModel.js +0 -39
  217. package/models/dynamo/connectorSchema.js +0 -146
  218. package/models/llmSessionModel.js +0 -17
  219. package/models/sequelize.js +0 -17
  220. package/models/userModel.js +0 -45
  221. package/test/connector/developerPortal.test.js +0 -166
  222. package/test/connector/mock.test.js +0 -131
  223. package/test/connector/proxy/engine.test.js +0 -211
  224. package/test/connector/proxy/index.test.js +0 -525
  225. package/test/connector/proxy/sample.json +0 -162
  226. package/test/connector/registry.test.js +0 -416
  227. package/test/handlers/admin.test.js +0 -960
  228. package/test/handlers/appointment.test.js +0 -260
  229. package/test/handlers/auth.test.js +0 -1096
  230. package/test/handlers/calldown.test.js +0 -310
  231. package/test/handlers/contact.test.js +0 -1014
  232. package/test/handlers/disposition.test.js +0 -396
  233. package/test/handlers/log.test.js +0 -1847
  234. package/test/handlers/managedAuth.test.js +0 -458
  235. package/test/handlers/managedOAuth.test.js +0 -262
  236. package/test/handlers/plugin.test.js +0 -429
  237. package/test/handlers/user.test.js +0 -381
  238. package/test/index.test.js +0 -301
  239. package/test/lib/analytics.test.js +0 -146
  240. package/test/lib/authSession.test.js +0 -173
  241. package/test/lib/cacheCleanup.test.js +0 -127
  242. package/test/lib/callLogComposer.test.js +0 -1231
  243. package/test/lib/debugTracer.test.js +0 -328
  244. package/test/lib/encode.test.js +0 -59
  245. package/test/lib/errorHandler.test.js +0 -246
  246. package/test/lib/generalErrorMessage.test.js +0 -82
  247. package/test/lib/jwt.test.js +0 -176
  248. package/test/lib/logger.test.js +0 -206
  249. package/test/lib/oauth.test.js +0 -359
  250. package/test/lib/ringcentral.test.js +0 -467
  251. package/test/lib/s3ErrorLogReport.test.js +0 -187
  252. package/test/lib/sharedSMSComposer.test.js +0 -1084
  253. package/test/lib/util.test.js +0 -329
  254. package/test/mcp/mcpHandler.test.js +0 -73
  255. package/test/mcp/mcpHandlerMore.test.js +0 -384
  256. package/test/mcp/tools/appointmentTools.test.js +0 -362
  257. package/test/mcp/tools/checkAuthStatus.test.js +0 -83
  258. package/test/mcp/tools/createCallLog.test.js +0 -436
  259. package/test/mcp/tools/createContact.test.js +0 -58
  260. package/test/mcp/tools/createMessageLog.test.js +0 -595
  261. package/test/mcp/tools/doAuth.test.js +0 -113
  262. package/test/mcp/tools/findContactByName.test.js +0 -275
  263. package/test/mcp/tools/findContactByPhone.test.js +0 -296
  264. package/test/mcp/tools/getCallLog.test.js +0 -298
  265. package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
  266. package/test/mcp/tools/getPublicConnectors.test.js +0 -107
  267. package/test/mcp/tools/getSessionInfo.test.js +0 -127
  268. package/test/mcp/tools/logout.test.js +0 -233
  269. package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
  270. package/test/mcp/tools/updateCallLog.test.js +0 -360
  271. package/test/models/accountDataModel.test.js +0 -98
  272. package/test/models/callDownListModel.test.js +0 -125
  273. package/test/models/dynamo/connectorSchema.test.js +0 -189
  274. package/test/models/dynamo/lockSchema.test.js +0 -37
  275. package/test/models/dynamo/noteCacheSchema.test.js +0 -45
  276. package/test/models/llmSessionModel.test.js +0 -91
  277. package/test/models/models.test.js +0 -660
  278. package/test/routes/calldownRoutes.test.js +0 -224
  279. package/test/routes/coreRouterBroadRoutes.test.js +0 -855
  280. package/test/routes/dispositionRoutes.test.js +0 -192
  281. package/test/routes/managedAuthRoutes.test.js +0 -386
  282. package/test/routes/pluginRoutes.test.js +0 -262
  283. package/test/setup.js +0 -178
  284. /package/{mcp → dist/mcp}/ui/index.html +0 -0
  285. /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
  286. /package/{mcp → dist/mcp}/ui/package.json +0 -0
  287. /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
@@ -1,13 +1,14 @@
1
- const jwt = require('../../lib/jwt');
2
- const connectorRegistry = require('../../connector/registry');
3
- const logCore = require('../../handlers/log');
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: Get Call Log
7
- *
9
+ *
8
10
  * This tool retrieves call logs from the CRM platform by session IDs.
9
11
  */
10
-
11
12
  const toolDefinition = {
12
13
  name: 'getCallLog',
13
14
  description: '⚠️ REQUIRES AUTHENTICATION: User must first authenticate using the "auth" tool to obtain a JWT token before using this tool. | Get call logs from the CRM platform by session IDs. Returns log details if found.',
@@ -35,7 +36,6 @@ const toolDefinition = {
35
36
  required: ['jwtToken', 'sessionIds']
36
37
  }
37
38
  };
38
-
39
39
  /**
40
40
  * Execute the getCallLog tool
41
41
  * @param {Object} args - The tool arguments
@@ -43,47 +43,40 @@ const toolDefinition = {
43
43
  * @param {string} args.sessionIds - Session IDs to retrieve, seprated by commas
44
44
  * @param {string} [args.extensionNumber] - RingCentral extension number used to scope the lookup.
45
45
  * @param {boolean} [args.requireDetails] - Whether to require detailed log information. If true, will call CRM API. Otherwise will just query in our own database.
46
- * @returns {Object} Result object with call log information
46
+ * @returns {Promise<any>} Result object with call log information
47
47
  */
48
48
  async function execute(args) {
49
49
  try {
50
50
  const { jwtToken, sessionIds, extensionNumber, requireDetails = false } = args;
51
-
52
51
  // Decode JWT to get userId and platform
53
52
  const decodedToken = jwt.decodeJwt(jwtToken);
54
53
  if (!decodedToken) {
55
54
  throw new Error('Invalid JWT token');
56
55
  }
57
56
  const { id: userId, platform } = decodedToken;
58
-
59
57
  if (!userId) {
60
58
  throw new Error('Invalid JWT token: userId not found');
61
59
  }
62
-
63
60
  // Get the platform connector module
64
61
  const platformModule = connectorRegistry.getConnector(platform);
65
-
66
62
  if (!platformModule) {
67
63
  throw new Error(`Platform connector not found for: ${platform}`);
68
64
  }
69
-
70
65
  // Check if getCallLog is implemented
71
66
  if (!platformModule.getCallLog) {
72
67
  throw new Error(`getCallLog is not implemented for platform: ${platform}`);
73
68
  }
74
-
75
69
  // Call the getCallLog method
76
70
  const getCallLogParams = {
77
- userId,
78
- sessionIds,
79
- platform,
80
- requireDetails
71
+ userId,
72
+ sessionIds,
73
+ platform,
74
+ requireDetails
81
75
  };
82
76
  if (extensionNumber) {
83
77
  getCallLogParams.extensionNumber = extensionNumber;
84
78
  }
85
79
  const { successful, logs, returnMessage } = await logCore.getCallLog(getCallLogParams);
86
-
87
80
  if (successful) {
88
81
  return {
89
82
  success: true,
@@ -105,7 +98,5 @@ async function execute(args) {
105
98
  };
106
99
  }
107
100
  }
108
-
109
101
  exports.definition = toolDefinition;
110
102
  exports.execute = execute;
111
-
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,16 @@
1
- const jwt = require('../../lib/jwt');
2
- const { UserModel } = require('../../models/userModel');
3
- const axios = require('axios');
4
-
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const jwt = /** @type {any} */ (require('../../lib/jwt'));
5
+ const { UserModel: RawUserModel } = require('../../models/userModel');
6
+ const UserModel = /** @type {any} */ (RawUserModel);
7
+ const axios = /** @type {any} */ (require('axios'));
5
8
  /**
6
9
  * MCP Tool: Get Google File Picker
7
- *
10
+ *
8
11
  * Returns the URL for the Google Sheets file picker.
9
12
  * The user must visit this URL in a browser to select a Google Sheet.
10
13
  */
11
-
12
14
  const toolDefinition = {
13
15
  name: 'getGoogleFilePicker',
14
16
  description: '⚠️ REQUIRES CRM CONNECTION. | Returns a URL for the Google Sheets file picker (1st preference) OR create a new sheet with input sheet name (2nd preference). The user should open this URL in their browser to select a Google Sheet for logging.',
@@ -28,46 +30,38 @@ const toolDefinition = {
28
30
  destructiveHint: false
29
31
  }
30
32
  };
31
-
32
33
  /**
33
34
  * Execute the getGoogleFilePicker tool
34
35
  * @param {Object} args - The tool arguments
35
36
  * @param {string} args.jwtToken - JWT token containing userId
36
37
  * @param {string} args.sheetName - Name of the new sheet to create
37
- * @returns {Object} Result object with file picker URL
38
+ * @returns {Promise<any>} Result object with file picker URL
38
39
  */
39
40
  async function execute(args) {
40
41
  try {
41
42
  const { jwtToken, sheetName } = args;
42
-
43
43
  if (!jwtToken) {
44
44
  return {
45
45
  success: false,
46
46
  error: 'JWT token is required. Please connect to the CRM first using getPublicConnectors.'
47
47
  };
48
48
  }
49
-
50
49
  // Decode JWT to get userId
51
50
  const unAuthData = jwt.decodeJwt(jwtToken);
52
-
53
51
  if (!unAuthData?.id) {
54
52
  return {
55
53
  success: false,
56
54
  error: 'Invalid JWT token: userId not found'
57
55
  };
58
56
  }
59
-
60
57
  // Find the user
61
58
  const user = await UserModel.findByPk(unAuthData.id);
62
-
63
59
  if (!user) {
64
60
  return {
65
61
  success: false,
66
62
  error: 'User not found. Please connect to the CRM first using getPublicConnectors.'
67
63
  };
68
64
  }
69
-
70
-
71
65
  if (sheetName) {
72
66
  const createSheetResponse = await axios.post(`${process.env.APP_SERVER}/googleSheets/sheet?jwtToken=${jwtToken}`, { name: sheetName });
73
67
  return createSheetResponse.data;
@@ -75,7 +69,6 @@ async function execute(args) {
75
69
  else {
76
70
  // Generate the file picker URL
77
71
  const filePickerUrl = `${process.env.APP_SERVER}/googleSheets/filePicker?token=${jwtToken}`;
78
-
79
72
  return {
80
73
  success: true,
81
74
  data: {
@@ -93,7 +86,5 @@ async function execute(args) {
93
86
  };
94
87
  }
95
88
  }
96
-
97
89
  exports.definition = toolDefinition;
98
90
  exports.execute = execute;
99
-
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,12 @@
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
1
4
  /**
2
5
  * MCP Tool: Get Help
3
- *
6
+ *
4
7
  * This tool provides users with a friendly guide to available capabilities
5
8
  * and how to get started with the RingCentral CRM integration.
6
9
  */
7
-
8
10
  const toolDefinition = {
9
11
  name: 'getHelp',
10
12
  description: 'Get a quick guide on what this integration can do and how to get started.',
@@ -19,10 +21,9 @@ const toolDefinition = {
19
21
  destructiveHint: false
20
22
  }
21
23
  };
22
-
23
24
  /**
24
25
  * Execute the getHelp tool
25
- * @returns {Object} Result object with help information
26
+ * @returns {Promise<any>} Result object with help information
26
27
  */
27
28
  async function execute() {
28
29
  return {
@@ -37,7 +38,5 @@ async function execute() {
37
38
  }
38
39
  };
39
40
  }
40
-
41
41
  exports.definition = toolDefinition;
42
42
  exports.execute = execute;
43
-
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,14 @@
1
- const axios = require('axios');
2
- const { Op } = require('sequelize');
3
- const { UserModel } = require('../../models/userModel');
4
- const { getHashValue } = require('../../lib/util');
5
-
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const axios = /** @type {any} */ (require('axios'));
5
+ const { Op } = /** @type {any} */ (require('sequelize'));
6
+ const { UserModel: RawUserModel } = require('../../models/userModel');
7
+ const UserModel = /** @type {any} */ (RawUserModel);
8
+ const { getHashValue: rawGetHashValue } = require('../../lib/util');
9
+ const getHashValue = /** @type {any} */ (rawGetHashValue);
10
+ const { createWidgetSessionToken: rawCreateWidgetSessionToken } = require('../lib/widgetSessionToken');
11
+ const createWidgetSessionToken = /** @type {any} */ (rawCreateWidgetSessionToken);
6
12
  /**
7
13
  * MCP Tool: Get Public Connectors
8
14
  *
@@ -11,7 +17,6 @@ const { getHashValue } = require('../../lib/util');
11
17
  * This tool only needs to resolve the RC account ID (for private connector
12
18
  * support) and return the server URL for widget-to-server tool calls.
13
19
  */
14
-
15
20
  const toolDefinition = {
16
21
  name: 'getPublicConnectors',
17
22
  description: 'Get available connectors. Returns an interactive widget - do NOT summarize or list the results in text, just show the widget.',
@@ -26,35 +31,32 @@ const toolDefinition = {
26
31
  destructiveHint: false
27
32
  },
28
33
  _meta: {
29
- // openai/outputTemplate is injected at registration time by mcpHandler.js
34
+ // openai/outputTemplate is injected at registration time by mcpHandler.ts
30
35
  // using the module-level WIDGET_URI — do not hardcode a version here.
31
36
  "openai/toolBehavior": 'interactive',
32
37
  "openai/widgetAccessible": true
33
38
  }
34
39
  };
35
-
36
40
  /**
37
41
  * Execute the getPublicConnectors tool.
38
42
  * Uses the RC access token (injected by mcpHandler) to resolve the account ID,
39
43
  * which the widget needs to fetch private connectors directly from the developer portal.
44
+ * @param {{ rcAccessToken?: string, openaiSessionId?: string }=} params - Injected MCP session parameters
45
+ * @returns {Promise<any>} Result object with connector metadata
40
46
  */
41
47
  async function execute({ rcAccessToken, openaiSessionId } = {}) {
42
48
  let rcExtensionId = null;
43
49
  let rcAccountId = null;
44
-
45
50
  if (rcAccessToken) {
46
51
  try {
47
- const resp = await axios.get(
48
- 'https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~',
49
- { headers: { Authorization: `Bearer ${rcAccessToken}` } }
50
- );
52
+ const resp = await axios.get('https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~', { headers: { Authorization: `Bearer ${rcAccessToken}` } });
51
53
  rcExtensionId = resp.data?.id ?? null;
52
54
  rcAccountId = resp.data?.account?.id ?? null;
53
- } catch {
55
+ }
56
+ catch {
54
57
  // Non-fatal: widget will only show public connectors
55
58
  }
56
59
  }
57
-
58
60
  // Check if user session already exists from Chrome extension
59
61
  const hashedRcExtensionId = getHashValue(rcExtensionId, process.env.HASH_KEY);
60
62
  const user = await UserModel.findOne({
@@ -74,7 +76,7 @@ async function execute({ rcAccessToken, openaiSessionId } = {}) {
74
76
  error: true,
75
77
  errorMessage: `You are already connected to ${user.platform}. It's controlled from App Connect Chrome extension.`
76
78
  }
77
- }
79
+ };
78
80
  }
79
81
  else {
80
82
  // Case: user doesn't exist, return structured content for widget
@@ -84,11 +86,10 @@ async function execute({ rcAccessToken, openaiSessionId } = {}) {
84
86
  rcExtensionId,
85
87
  rcAccountId,
86
88
  openaiSessionId: openaiSessionId ?? null,
89
+ widgetSessionToken: createWidgetSessionToken({ rcExtensionId, openaiSessionId: openaiSessionId ?? null }),
87
90
  }
88
91
  };
89
92
  }
90
-
91
93
  }
92
-
93
94
  exports.definition = toolDefinition;
94
95
  exports.execute = execute;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,13 +1,16 @@
1
- const jwt = require('../../lib/jwt');
2
- const { UserModel } = require('../../models/userModel');
3
- const { RingCentral } = require('../../lib/ringcentral');
4
-
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const jwt = /** @type {any} */ (require('../../lib/jwt'));
5
+ const { UserModel: RawUserModel } = require('../../models/userModel');
6
+ const UserModel = /** @type {any} */ (RawUserModel);
7
+ const { RingCentral: RawRingCentral } = require('../../lib/ringcentral');
8
+ const RingCentral = /** @type {any} */ (RawRingCentral);
5
9
  /**
6
10
  * MCP Tool: Get Session Info
7
11
  *
8
12
  * Returns non-sensitive information about the current MCP/CRM session.
9
13
  */
10
-
11
14
  const toolDefinition = {
12
15
  name: 'getSessionInfo',
13
16
  description: 'Get the current user session info, including RingCentral identity and CRM connection status.',
@@ -22,7 +25,6 @@ const toolDefinition = {
22
25
  destructiveHint: false
23
26
  }
24
27
  };
25
-
26
28
  /**
27
29
  * Execute the getSessionInfo tool
28
30
  * @param {Object} args - Tool arguments injected by mcpHandler
@@ -30,21 +32,14 @@ const toolDefinition = {
30
32
  * @param {string} [args.rcExtensionId] - Verified RingCentral extension identifier
31
33
  * @param {string} [args.jwtToken] - CRM JWT token
32
34
  * @param {string} [args.rcAccessToken] - RingCentral access token
33
- * @returns {Object} Result object with session information
35
+ * @returns {Promise<any>} Result object with session information
34
36
  */
35
37
  async function execute(args = {}) {
36
38
  try {
37
- const {
38
- openaiSessionId = null,
39
- rcExtensionId = null,
40
- jwtToken,
41
- rcAccessToken,
42
- } = args;
43
-
39
+ const { openaiSessionId = null, rcExtensionId = null, jwtToken, rcAccessToken, } = args;
44
40
  const decodedToken = jwtToken ? jwt.decodeJwt(jwtToken) : null;
45
41
  const userId = decodedToken?.id ?? null;
46
42
  const user = userId ? await UserModel.findByPk(userId) : null;
47
-
48
43
  let rcExtensionInfo = null;
49
44
  if (rcExtensionId && rcAccessToken) {
50
45
  const rcSDK = new RingCentral({
@@ -85,6 +80,5 @@ async function execute(args = {}) {
85
80
  };
86
81
  }
87
82
  }
88
-
89
83
  exports.definition = toolDefinition;
90
84
  exports.execute = execute;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * MCP Tools Index
3
+ *
4
+ * Two separate registries:
5
+ * - tools: Registered in the MCP server — visible to and callable by the AI model
6
+ * - widgetTools: Only accessible via POST /mcp/widget-tool-call — hidden from the AI model
7
+ */
8
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Tools Index
4
+ *
5
+ * Two separate registries:
6
+ * - tools: Registered in the MCP server — visible to and callable by the AI model
7
+ * - widgetTools: Only accessible via POST /mcp/widget-tool-call — hidden from the AI model
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ // @ts-check
11
+ const getHelp = /** @type {any} */ (require('./getHelp'));
12
+ const getPublicConnectors = /** @type {any} */ (require('./getPublicConnectors'));
13
+ const getSessionInfo = /** @type {any} */ (require('./getSessionInfo'));
14
+ const doAuth = /** @type {any} */ (require('./doAuth'));
15
+ const checkAuthStatus = /** @type {any} */ (require('./checkAuthStatus'));
16
+ const logout = /** @type {any} */ (require('./logout'));
17
+ const findContact = /** @type {any} */ (require('./findContactByPhone'));
18
+ const findContactWithName = /** @type {any} */ (require('./findContactByName'));
19
+ const createCallLog = /** @type {any} */ (require('./createCallLog'));
20
+ const rcGetCallLogs = /** @type {any} */ (require('./rcGetCallLogs'));
21
+ // const getGoogleFilePicker = require('./getGoogleFilePicker');
22
+ const createContact = /** @type {any} */ (require('./createContact'));
23
+ const createAppointment = /** @type {any} */ (require('./createAppointment'));
24
+ const updateAppointment = /** @type {any} */ (require('./updateAppointment'));
25
+ const confirmAppointment = /** @type {any} */ (require('./confirmAppointment'));
26
+ const cancelAppointment = /** @type {any} */ (require('./cancelAppointment'));
27
+ const listAppointments = /** @type {any} */ (require('./listAppointments'));
28
+ // AI-visible MCP tools — registered in the MCP server
29
+ module.exports.tools = [
30
+ getHelp,
31
+ getPublicConnectors,
32
+ getSessionInfo,
33
+ logout,
34
+ findContact,
35
+ findContactWithName,
36
+ createCallLog,
37
+ rcGetCallLogs,
38
+ // getGoogleFilePicker,
39
+ createContact,
40
+ listAppointments,
41
+ createAppointment,
42
+ updateAppointment,
43
+ confirmAppointment,
44
+ cancelAppointment,
45
+ ];
46
+ // Widget-only tools — callable via /mcp/widget-tool-call, NOT registered as MCP tools
47
+ module.exports.widgetTools = [
48
+ doAuth,
49
+ checkAuthStatus,
50
+ ];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,15 @@
1
- const jwt = require('../../lib/jwt');
2
- const connectorRegistry = require('../../connector/registry');
3
- const appointmentCore = require('../../handlers/appointment');
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: List Appointments
7
9
  *
8
10
  * Fetches appointments/events from the CRM platform.
9
11
  * Accepts a named filter (upcoming, today, past, all) or a custom date range.
10
12
  */
11
-
12
13
  const toolDefinition = {
13
14
  name: 'listAppointments',
14
15
  description: '⚠️ REQUIRES CRM CONNECTION. | List appointments or events from the CRM platform. Use the `filter` param to get upcoming, today\'s, past, or all appointments. For a specific window, supply `startDate` and `endDate` (YYYY-MM-DD) directly.',
@@ -48,7 +49,6 @@ const toolDefinition = {
48
49
  destructiveHint: false
49
50
  }
50
51
  };
51
-
52
52
  /**
53
53
  * Build a YYYY-MM-DD string offset by `days` from today.
54
54
  */
@@ -57,11 +57,9 @@ function offsetDate(days) {
57
57
  d.setDate(d.getDate() + days);
58
58
  return d.toISOString().slice(0, 10);
59
59
  }
60
-
61
60
  function todayStr() {
62
61
  return new Date().toISOString().slice(0, 10);
63
62
  }
64
-
65
63
  /**
66
64
  * Resolve the range object from the filter name or explicit dates.
67
65
  */
@@ -84,7 +82,6 @@ function resolveRange({ filter, startDate, endDate }) {
84
82
  return { startDate: offsetDate(-90), endDate: offsetDate(90) };
85
83
  }
86
84
  }
87
-
88
85
  /**
89
86
  * Execute the listAppointments tool
90
87
  * @param {Object} args
@@ -93,37 +90,30 @@ function resolveRange({ filter, startDate, endDate }) {
93
90
  * @param {string} [args.startDate] - Custom range start (YYYY-MM-DD), used when filter="custom"
94
91
  * @param {string} [args.endDate] - Custom range end (YYYY-MM-DD), used when filter="custom"
95
92
  * @param {boolean} [args.mineOnly] - Restrict to the current user's appointments
96
- * @returns {Object} Result with appointment list
93
+ * @returns {Promise<any>} Result with appointment list
97
94
  */
98
95
  async function execute(args) {
99
96
  try {
100
97
  const { jwtToken, filter, startDate, endDate, mineOnly } = args;
101
-
102
98
  if (!jwtToken) {
103
99
  throw new Error('Please go to Settings and authorize CRM platform');
104
100
  }
105
-
106
101
  const decodedToken = jwt.decodeJwt(jwtToken);
107
102
  if (!decodedToken) {
108
103
  throw new Error('Invalid JWT token');
109
104
  }
110
105
  const { id: userId, platform } = decodedToken;
111
-
112
106
  if (!userId) {
113
107
  throw new Error('Invalid JWT token: userId not found');
114
108
  }
115
-
116
109
  const platformModule = connectorRegistry.getConnector(platform);
117
110
  if (!platformModule) {
118
111
  throw new Error(`Platform connector not found for: ${platform}`);
119
112
  }
120
-
121
113
  if (!platformModule.listAppointments) {
122
114
  throw new Error(`listAppointments is not implemented for platform: ${platform}`);
123
115
  }
124
-
125
116
  const range = resolveRange({ filter, startDate, endDate });
126
-
127
117
  const { successful, appointments, returnMessage } = await appointmentCore.listAppointments({
128
118
  platform,
129
119
  userId,
@@ -131,7 +121,6 @@ async function execute(args) {
131
121
  mineOnly: mineOnly ?? false,
132
122
  forceSync: false
133
123
  });
134
-
135
124
  if (successful) {
136
125
  return {
137
126
  success: true,
@@ -158,6 +147,5 @@ async function execute(args) {
158
147
  };
159
148
  }
160
149
  }
161
-
162
150
  exports.definition = toolDefinition;
163
151
  exports.execute = execute;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,17 +1,20 @@
1
- const jwt = require('../../lib/jwt');
2
- const { UserModel } = require('../../models/userModel');
3
- const { LlmSessionModel } = require('../../models/llmSessionModel');
4
- const { CacheModel } = require('../../models/cacheModel');
5
- const connectorRegistry = require('../../connector/registry');
6
-
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const jwt = /** @type {any} */ (require('../../lib/jwt'));
5
+ const { UserModel: RawUserModel } = require('../../models/userModel');
6
+ const UserModel = /** @type {any} */ (RawUserModel);
7
+ const { LlmSessionModel: RawLlmSessionModel } = require('../../models/llmSessionModel');
8
+ const LlmSessionModel = /** @type {any} */ (RawLlmSessionModel);
9
+ const { CacheModel: RawCacheModel } = require('../../models/cacheModel');
10
+ const CacheModel = /** @type {any} */ (RawCacheModel);
11
+ const connectorRegistry = /** @type {any} */ (require('../../connector/registry'));
7
12
  const RC_EXTENSION_CACHE_KEY = 'rcExtensionId';
8
-
9
13
  /**
10
14
  * MCP Tool: Logout
11
- *
15
+ *
12
16
  * This tool logs out the user from the CRM platform.
13
17
  */
14
-
15
18
  const toolDefinition = {
16
19
  name: 'logout',
17
20
  description: 'Logout the user from the CRM platform.',
@@ -25,19 +28,19 @@ const toolDefinition = {
25
28
  destructiveHint: true
26
29
  }
27
30
  };
28
-
29
31
  function isMissingSessionTableError(error) {
30
32
  const message = error?.message || '';
31
33
  return message.includes('no such table: llmSessions')
32
34
  || message.includes('relation "llmSessions" does not exist')
33
35
  || message.includes("relation 'llmSessions' does not exist");
34
36
  }
35
-
36
37
  /**
37
38
  * Execute the logout tool
38
39
  * @param {Object} args - The tool arguments
39
40
  * @param {string} args.jwtToken - JWT token containing userId and platform information. Injected automatically by the server after CRM connection.
40
- * @returns {Object} Result object with logout information
41
+ * @param {string} [args.rcExtensionId] - Optional RC extension session ID injected by the MCP handler
42
+ * @param {string} [args.openaiSessionId] - Optional OpenAI session ID injected by the MCP handler
43
+ * @returns {Promise<any>} Result object with logout information
41
44
  */
42
45
  async function execute(args) {
43
46
  try {
@@ -84,7 +87,7 @@ async function execute(args) {
84
87
  data: {
85
88
  message: "IMPORTANT: Logout successful. Clear jwtToken, connectorManifest, connectorDisplayName, hostname and connectorName in memory. User is logged out from the CRM platform.",
86
89
  }
87
- }
90
+ };
88
91
  }
89
92
  catch (error) {
90
93
  return {
@@ -94,6 +97,5 @@ async function execute(args) {
94
97
  };
95
98
  }
96
99
  }
97
-
98
100
  exports.definition = toolDefinition;
99
101
  exports.execute = execute;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,11 @@
1
- const { RingCentral } = require('../../lib/ringcentral');
2
- const jwt = require('../../lib/jwt');
3
- const { CallLogModel } = require('../../models/callLogModel');
4
-
1
+ "use strict";
2
+ // @ts-check
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const { RingCentral: RawRingCentral } = require('../../lib/ringcentral');
5
+ const RingCentral = /** @type {any} */ (RawRingCentral);
6
+ const jwt = /** @type {any} */ (require('../../lib/jwt'));
7
+ const { CallLogModel: RawCallLogModel } = require('../../models/callLogModel');
8
+ const CallLogModel = /** @type {any} */ (RawCallLogModel);
5
9
  const toolDefinition = {
6
10
  name: 'rcGetCallLogs',
7
11
  description: '⚠️ REQUIRES CRM CONNECTION. | Get call logs from RingCentral. Returns a `records[]` array. Each item in `records` is a complete RingCentral call log object that can be passed DIRECTLY as `incomingData.logInfo` to the `createCallLog` tool — no field renaming or restructuring needed.',
@@ -24,8 +28,7 @@ const toolDefinition = {
24
28
  openWorldHint: true,
25
29
  destructiveHint: false
26
30
  }
27
- }
28
-
31
+ };
29
32
  async function execute(args) {
30
33
  try {
31
34
  const { jwtToken, rcAccessToken, timeFrom, timeTo } = args;
@@ -57,9 +60,8 @@ async function execute(args) {
57
60
  return {
58
61
  success: false,
59
62
  error: e.message
60
- }
63
+ };
61
64
  }
62
65
  }
63
-
64
66
  exports.definition = toolDefinition;
65
67
  exports.execute = execute;
@@ -0,0 +1 @@
1
+ export {};