@worktango/ai-assistant 0.0.1 → 0.0.2-beta-gd2

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 (206) hide show
  1. package/README.md +107 -6
  2. package/backendTypes.ts +268 -0
  3. package/build/constants.js +80 -0
  4. package/build/dist/express.d.ts +2 -0
  5. package/build/dist/express.js +10457 -0
  6. package/build/express.d.ts +2 -0
  7. package/build/express.js +21 -0
  8. package/build/react.d.ts +4 -0
  9. package/build/react.js +44 -0
  10. package/build/src/backend/express.d.ts +63 -0
  11. package/build/src/backend/express.js +366 -0
  12. package/constants.js +80 -0
  13. package/dist/Absenteeism-DnYRfCGD.mjs +49 -0
  14. package/dist/ActivityFeed-CMR7d8a9.mjs +41 -0
  15. package/dist/AddUser-BxN71Gq-.mjs +128 -0
  16. package/dist/Admin-BNwEEcul.mjs +55 -0
  17. package/dist/Admin-CCOxh4NQ.mjs +70 -0
  18. package/dist/AiGeneral-6P2eop9s.mjs +43 -0
  19. package/dist/AiScoring-Be2EIJC_.mjs +67 -0
  20. package/dist/AiText-D4UwoEoT.mjs +67 -0
  21. package/dist/Anniversary-B3ZoAqa5.mjs +35 -0
  22. package/dist/Appreciation-B_rgIegc.mjs +55 -0
  23. package/dist/ArrowDown-CWFXlxhX.mjs +38 -0
  24. package/dist/ArrowLeft-D7rl_Ecd.mjs +12 -0
  25. package/dist/ArrowRight-BPLLV4yW.mjs +12 -0
  26. package/dist/ArrowUp-DYWuwxJM.mjs +31 -0
  27. package/dist/Attachment-CR6plcc5.mjs +20 -0
  28. package/dist/BeQuickDontHurry-BPnXAKBa.mjs +94 -0
  29. package/dist/Birthday-BihgKHOQ.mjs +66 -0
  30. package/dist/BrandPromise-fU0oR23R.mjs +57 -0
  31. package/dist/BrandVision-B37SFqTc.mjs +96 -0
  32. package/dist/Calendar-BdAku_za.mjs +24 -0
  33. package/dist/CaretDn-De_oYPN-.mjs +11 -0
  34. package/dist/CaretDown-DnGml5_x.mjs +5 -0
  35. package/dist/CaretLeft-D0BOxHEC.mjs +11 -0
  36. package/dist/CaretRight-dCjBT9bB.mjs +11 -0
  37. package/dist/CaretUp-BCw0fqJn.mjs +11 -0
  38. package/dist/ChallengeAccepted-CNaeHk1I.mjs +49 -0
  39. package/dist/CheckIn-CwG42QYQ.mjs +34 -0
  40. package/dist/CheckIns-A1Kkc_2W.mjs +33 -0
  41. package/dist/CheckSeal-Dqw_lc0S.mjs +31 -0
  42. package/dist/Checkmark-BHE91v8D.mjs +16 -0
  43. package/dist/Clock-CuAJQmxQ.mjs +33 -0
  44. package/dist/Close-D-f_iwQ8.mjs +12 -0
  45. package/dist/CloudDownload-CfQ7V21B.mjs +40 -0
  46. package/dist/Comment-GrrKaBsi.mjs +167 -0
  47. package/dist/Comments-YOn2eJUt.mjs +48 -0
  48. package/dist/Connections-CPlNaCbu.mjs +49 -0
  49. package/dist/Copy-NDpa2_F3.mjs +72 -0
  50. package/dist/CustomQuestion-OzfWoJV3.mjs +40 -0
  51. package/dist/CustomerSuccess-DAH7mRDK.mjs +50 -0
  52. package/dist/DatePicker-BxfSRn5x.mjs +303 -0
  53. package/dist/Dot-DCoU7aD3.mjs +12 -0
  54. package/dist/Download-DpF3elMl.mjs +38 -0
  55. package/dist/Drag-DWbGJvhn.mjs +41 -0
  56. package/dist/DragIndicator-CnDCSf3A.mjs +12 -0
  57. package/dist/Earn-7uXfIfZU.mjs +15 -0
  58. package/dist/Email-zAMtQLoS.mjs +24 -0
  59. package/dist/EmojiDisplay-DSZOjKek.mjs +38975 -0
  60. package/dist/EmojiPicker-DgtE9CiW.mjs +29560 -0
  61. package/dist/EnpsSurvey-Y9at0I5m.mjs +49 -0
  62. package/dist/Expired-BNR7WTVX.mjs +33 -0
  63. package/dist/Eye-DzoufmcZ.mjs +27 -0
  64. package/dist/Feedback-D7sxcXQ1.mjs +41 -0
  65. package/dist/Feedback-JZEpzb79.mjs +49 -0
  66. package/dist/Filter-C1JuLCfg.mjs +64 -0
  67. package/dist/Flag-C4l9OPVK.mjs +35 -0
  68. package/dist/Giphy-Bhmd8ypI.mjs +22 -0
  69. package/dist/GoalCount-CDtW2B-F.mjs +10 -0
  70. package/dist/GoalPercent-CEIqOHFH.mjs +21 -0
  71. package/dist/GoalTask-BRQInXIl.mjs +20 -0
  72. package/dist/GoalTask-Bhh_sX7J.mjs +42 -0
  73. package/dist/Goals-BMFrqSmc.mjs +79 -0
  74. package/dist/Goals-CPiQ13bO.mjs +70 -0
  75. package/dist/Growth-Ck1OiXeO.mjs +85 -0
  76. package/dist/Hamburger-BkqfmMmA.mjs +9 -0
  77. package/dist/Help-B2KqPPam.mjs +36 -0
  78. package/dist/HighFive-BYcQw328.mjs +33 -0
  79. package/dist/HighFive-Bi71jYQj.mjs +38 -0
  80. package/dist/Home-CHOKwBnN.mjs +21 -0
  81. package/dist/Home-DPyqkkoX.mjs +31 -0
  82. package/dist/HorizontalLine-DzBF5cf2.mjs +17 -0
  83. package/dist/Hourglass-sPcwiWfl.mjs +53 -0
  84. package/dist/Image-D-LHXhOl.mjs +41 -0
  85. package/dist/ImageFile-By-HPKcE.mjs +60 -0
  86. package/dist/InGoodCompany-CvfwTAMs.mjs +33 -0
  87. package/dist/Incentives-DnZQM_QS.mjs +155 -0
  88. package/dist/Info-CQnSKd8J.mjs +31 -0
  89. package/dist/Insights-BApP3QUO.mjs +20 -0
  90. package/dist/Insights-BivxsIhR.mjs +41 -0
  91. package/dist/Integrations-DUqcLKml.mjs +33 -0
  92. package/dist/KazooLogo-BVRhaQ-1.mjs +38 -0
  93. package/dist/KnowYourAudience-jvdpa8Co.mjs +91 -0
  94. package/dist/Launch-C5QbSdJn.mjs +83 -0
  95. package/dist/Link-CzMOWVHw.mjs +43 -0
  96. package/dist/LinkArrow-D7My064p.mjs +12 -0
  97. package/dist/Loading-C5wJAaZ-.mjs +6 -0
  98. package/dist/Lock-CrpqckDI.mjs +31 -0
  99. package/dist/Management-CfJCyzy8.mjs +87 -0
  100. package/dist/MeatballMenu-1RqUBn4Y.mjs +9 -0
  101. package/dist/MediaError-9_d5oB_T.mjs +40 -0
  102. package/dist/Messages-4waJxvel.mjs +221 -0
  103. package/dist/Microphone-8fk2NyjC.mjs +63 -0
  104. package/dist/Mobile-B7UDVCjR.mjs +31 -0
  105. package/dist/Nomination-DyVMjiwX.mjs +12 -0
  106. package/dist/NominationsAndAwards-DV8lxdIs.mjs +57 -0
  107. package/dist/Notification-DgAbq7ar.mjs +28 -0
  108. package/dist/Okrs-B5p8LEMY.mjs +55 -0
  109. package/dist/Pause-B7pDb0Ur.mjs +12 -0
  110. package/dist/PeerToPeer-EFRm2-Ns.mjs +64 -0
  111. package/dist/Pencil-6UZn-x0W.mjs +25 -0
  112. package/dist/People-DOYJOgS0.mjs +43 -0
  113. package/dist/PerformanceManagement-DavgifML.mjs +57 -0
  114. package/dist/Pin-C0KIHJ16.mjs +24 -0
  115. package/dist/PinnedIconAward-DUe5bm5u.mjs +20 -0
  116. package/dist/PinnedIconBrightIdea-BNdCStK9.mjs +20 -0
  117. package/dist/PinnedIconBullseye-DD7dZCoQ.mjs +36 -0
  118. package/dist/PinnedIconChampagne-HIJE7Yf3.mjs +20 -0
  119. package/dist/PinnedIconCheer-Pmd1imX0.mjs +20 -0
  120. package/dist/PinnedIconCrown-CPwPqzC4.mjs +20 -0
  121. package/dist/PinnedIconDiamond-D00JW81W.mjs +20 -0
  122. package/dist/PinnedIconHoleInOne-D6jh0Ane.mjs +20 -0
  123. package/dist/PinnedIconMedal-CEc_ezUs.mjs +20 -0
  124. package/dist/PinnedIconMetrics-CDU1uqhK.mjs +20 -0
  125. package/dist/PinnedIconPin-CSCDM0mw.mjs +20 -0
  126. package/dist/PinnedIconRockAndRoll-CQxSgO5d.mjs +23 -0
  127. package/dist/PinnedIconRocket-B1tXrzTg.mjs +20 -0
  128. package/dist/PinnedIconStrength-CVyMBzjV.mjs +20 -0
  129. package/dist/PinnedIconTeddyBear-C1YYmDoh.mjs +20 -0
  130. package/dist/PlatformLogo-0AOI2Cr9.mjs +57 -0
  131. package/dist/Plus-Dgh_a2E8.mjs +19 -0
  132. package/dist/Popper-DAaZXie8.mjs +1118 -0
  133. package/dist/PrivateEye-BUgV7GQk.mjs +127 -0
  134. package/dist/PrivatePushPin-C4ph6ZhF.mjs +33 -0
  135. package/dist/Processing-DOgV5nVT.mjs +80 -0
  136. package/dist/Productivity-BZuPAu6h.mjs +41 -0
  137. package/dist/ProgressCircle-C1bIKxWu.mjs +12 -0
  138. package/dist/PulseSurvey-YW8pgO3g.mjs +48 -0
  139. package/dist/PushPin-C0Vt7Qgz.mjs +18 -0
  140. package/dist/QuotesLeft-BrcaBZPo.mjs +18 -0
  141. package/dist/QuotesRight-VYMthud9.mjs +18 -0
  142. package/dist/Recognition-BLb29jsR.mjs +38 -0
  143. package/dist/Recognition-BlojPoTY.mjs +76 -0
  144. package/dist/Retention-D04eGyj2.mjs +47 -0
  145. package/dist/Rewards-BQ_4-Xnm.mjs +67 -0
  146. package/dist/Rewards-Cbm9UlJN.mjs +54 -0
  147. package/dist/RewardsCatalog-6bMpoD6s.mjs +49 -0
  148. package/dist/Roadmap-DK7G7m1M.mjs +122 -0
  149. package/dist/Search-BL5oOF1V.mjs +14 -0
  150. package/dist/Security-C7DgqkmM.mjs +33 -0
  151. package/dist/SendRecognition-CXWoOD5B.mjs +5 -0
  152. package/dist/ShareLink-DsdD7S2M.mjs +27 -0
  153. package/dist/SidebarCollapse-BycFfuBy.mjs +48 -0
  154. package/dist/Skill-C9DRN5_x.mjs +23 -0
  155. package/dist/Skills-Bf7uNero.mjs +68 -0
  156. package/dist/Smiley-C0W0nvQw.mjs +84 -0
  157. package/dist/Stop-B6-Rv84N.mjs +178 -0
  158. package/dist/Survey-B1ICwGfc.mjs +59 -0
  159. package/dist/Surveys-BygAscLB.mjs +54 -0
  160. package/dist/SyncUps-DNmrE_No.mjs +30 -0
  161. package/dist/Syncs-BCJtdDyW.mjs +29 -0
  162. package/dist/TalentReview-Bsf5rU5C.mjs +88 -0
  163. package/dist/TalentReview-Du4M8y3m.mjs +33 -0
  164. package/dist/TalentReviewInsights-p0rYC_2I.mjs +100 -0
  165. package/dist/TaskCompleted-DhURRWUZ.mjs +97 -0
  166. package/dist/Team-Rs8iU_vt.mjs +63 -0
  167. package/dist/Teams-BrkkrHW9.mjs +80 -0
  168. package/dist/TextBold-CgZBuifH.mjs +71 -0
  169. package/dist/TextBulletList-B6e_IEP-.mjs +128 -0
  170. package/dist/TextInput-B8AOwiHn.mjs +121 -0
  171. package/dist/TextItalic-C9jJChss.mjs +71 -0
  172. package/dist/TextNumberList-BfahObnv.mjs +147 -0
  173. package/dist/TextUnderline-n9b1v8UJ.mjs +90 -0
  174. package/dist/ThumbsDown-ZkPlc2MC.mjs +46 -0
  175. package/dist/ThumbsUp-C5EEURtj.mjs +46 -0
  176. package/dist/Toggle-CZuD0uCq.mjs +76 -0
  177. package/dist/Translate-DcOpGRTB.mjs +98 -0
  178. package/dist/Trash-CRdG3IYb.mjs +44 -0
  179. package/dist/TrendDown-CB3cl_u7.mjs +5 -0
  180. package/dist/TrendUp-D_f6etsq.mjs +5 -0
  181. package/dist/Undo-BfRfs2YI.mjs +41 -0
  182. package/dist/Unplugged-qrnvAmIJ.mjs +201 -0
  183. package/dist/UpDownCaret-CdoiwMWU.mjs +12 -0
  184. package/dist/VerifiedCheckmark-2saHRxh6.mjs +20 -0
  185. package/dist/VerticalLine-XjlxBP9Z.mjs +50 -0
  186. package/dist/Warning-B8864P6W.mjs +37 -0
  187. package/dist/WarningNoOutline-llm3ebvI.mjs +41 -0
  188. package/dist/YesAnd-DLEvdXw9.mjs +31 -0
  189. package/dist/ai-assistant.css +1 -0
  190. package/dist/emoji-CJuSGYZk.mjs +2310 -0
  191. package/dist/express.js +10936 -0
  192. package/dist/html2canvas.esm-DgdJBc_o.mjs +4871 -0
  193. package/dist/index-BEKNcH9V.mjs +721 -0
  194. package/dist/react-apexcharts.min-DLm6NZyI.mjs +11326 -0
  195. package/dist/react.es.js +15 -0
  196. package/dist/react.umd.js +1691 -0
  197. package/dist/reactComponent-CGfCiP84.mjs +44091 -0
  198. package/express.d.ts +88 -1
  199. package/express.js +4 -1
  200. package/generated/apiHooks.tsx +5644 -0
  201. package/generated/sdk.ts +5119 -0
  202. package/generated/stitchedSdk.ts +1174 -0
  203. package/package.json +46 -21
  204. package/react.d.ts +215 -0
  205. package/react.js +4 -1
  206. package/sharedTypes.ts +386 -0
@@ -0,0 +1,2 @@
1
+ export { setupAiAssistantRoutes } from "./src/backend/express";
2
+ export * from "./backendTypes";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.setupAiAssistantRoutes = void 0;
18
+ var express_1 = require("./src/backend/express");
19
+ Object.defineProperty(exports, "setupAiAssistantRoutes", { enumerable: true, get: function () { return express_1.setupAiAssistantRoutes; } });
20
+ __exportStar(require("./backendTypes"), exports);
21
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1,4 @@
1
+ export * from "./src/frontend/reactComponent";
2
+ export * as config from "./src/frontend/config";
3
+ export * as tools from "./src/frontend/tools/llm-tools";
4
+ export * from "./sharedTypes";
package/build/react.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.tools = exports.config = void 0;
40
+ __exportStar(require("./src/frontend/reactComponent"), exports);
41
+ exports.config = __importStar(require("./src/frontend/config"));
42
+ exports.tools = __importStar(require("./src/frontend/tools/llm-tools"));
43
+ __exportStar(require("./sharedTypes"), exports);
44
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1,63 @@
1
+ import type { Express, RequestHandler } from "express";
2
+ import type { RestEndpointCallbacks, GraphQLOperationCallbacks } from "./types";
3
+ /**
4
+ * Note: the inline TypeScript documentation for the below is in `../../express.d.ts`.
5
+ * This is optimized for external use, so we don't want to duplicate the docs here.
6
+ */
7
+ export declare function setupAiAssistantRoutes(args: {
8
+ app: Express;
9
+ getBearerToken: (headers: Record<string, undefined | string | string[]>) => Promise<string>;
10
+ targetHost: string;
11
+ targetPort?: number;
12
+ targetProtocol?: string;
13
+ route?: string;
14
+ logger?: Pick<typeof console, "log" | "error" | "debug">;
15
+ preflightMiddlewares?: RequestHandler[];
16
+ getTargetPath: (path: string) => string;
17
+ followRedirects?: boolean;
18
+ /**
19
+ * Optional callbacks to invoke after successful REST endpoint responses (status 200 only).
20
+ * Provides access to both request and response data with full type safety.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * onRestEndpointSuccess: {
25
+ * '/api/api-ai-assistant/v1/chat': async ({ request, response }) => {
26
+ * console.log('Chat completed successfully');
27
+ * // response is typed as ChatResponse
28
+ * console.log('Model response:', response.role, response.parts);
29
+ * },
30
+ * '/api/api-ai-assistant/v1/tts': async ({ request, response }) => {
31
+ * // response is typed as TTSResponse
32
+ * console.log('Speech synthesis:', response.synthesis);
33
+ * },
34
+ * }
35
+ * ```
36
+ */
37
+ onRestEndpointSuccess?: RestEndpointCallbacks;
38
+ /**
39
+ * Optional callbacks to invoke after successful GraphQL operation responses (status 200 only).
40
+ * Keys must match the GraphQL operation names (PascalCase), not field names.
41
+ * Provides access to both request and response data with full type safety.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * onGraphQLOperationSuccess: {
46
+ * AppendMessageToConversation: async ({ request, response }) => {
47
+ * // Extract the conversation ID from the typed response
48
+ * const conversationId = response.data?.appendMessage?.conversation?.id;
49
+ * if (conversationId) {
50
+ * // Store in localStorage, update UI state, trigger analytics, etc.
51
+ * localStorage.setItem('lastConversationId', conversationId);
52
+ * console.log('New conversation created:', conversationId);
53
+ * }
54
+ * },
55
+ * GetAllConversations: async ({ request, response }) => {
56
+ * const conversations = response.data?.getConversations;
57
+ * console.log(`Loaded ${conversations?.length ?? 0} conversations`);
58
+ * },
59
+ * }
60
+ * ```
61
+ */
62
+ onGraphQLOperationSuccess?: GraphQLOperationCallbacks;
63
+ }): void;
@@ -0,0 +1,366 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupAiAssistantRoutes = setupAiAssistantRoutes;
4
+ const http_proxy_middleware_1 = require("http-proxy-middleware");
5
+ const helpers_1 = require("@kazoohr/helpers");
6
+ /**
7
+ * Note: the inline TypeScript documentation for the below is in `../../express.d.ts`.
8
+ * This is optimized for external use, so we don't want to duplicate the docs here.
9
+ */
10
+ function setupAiAssistantRoutes(args) {
11
+ const logger = (0, helpers_1.coalesce)(args.logger, console);
12
+ const routePath = args.route ?? "/ai-assistant";
13
+ const port = args.targetPort ?? 80;
14
+ const protocol = args.targetProtocol ?? "http";
15
+ // This initial middleware mutates the request headers for the proxy request
16
+ // so that we can add the bearer token to the request. We need this separate
17
+ // because the proxy middleware callbacks cannot be async.
18
+ const bearerTokenMiddleware = (req, res, next) => {
19
+ args
20
+ .getBearerToken(req.headers)
21
+ .then((bearerToken) => {
22
+ getRequestWithNewAuthHeader(req).newAuthHeader = `Bearer ${bearerToken}`;
23
+ next();
24
+ })
25
+ .catch((error) => {
26
+ logger.error("Error getting bearer token:", error);
27
+ next(error);
28
+ });
29
+ };
30
+ const proxyOptions = {
31
+ target: `${protocol}://${args.targetHost}:${port}`,
32
+ changeOrigin: true,
33
+ followRedirects: args.followRedirects ?? true,
34
+ secure: protocol === "https",
35
+ pathRewrite: (path, req) => {
36
+ // Since we use express, we know that req.originalUrl is available
37
+ const expressRequest = req; // eslint-disable-line @typescript-eslint/consistent-type-assertions
38
+ return args.getTargetPath(expressRequest.originalUrl || path);
39
+ },
40
+ on: {
41
+ proxyReq: (proxyReq, req) => {
42
+ const newAuthHeader = getRequestWithNewAuthHeader(req).newAuthHeader;
43
+ if (newAuthHeader) {
44
+ proxyReq.setHeader("Authorization", newAuthHeader);
45
+ }
46
+ (0, http_proxy_middleware_1.fixRequestBody)(proxyReq, req);
47
+ },
48
+ proxyRes: (proxyRes, req, res) => {
49
+ if (proxyRes.statusCode !== 200) {
50
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
51
+ const originalUrl = req
52
+ .originalUrl;
53
+ logger.error(`[setupAiAssistantRoutes] Proxy error ${proxyRes.statusCode}: ${originalUrl}`);
54
+ }
55
+ // istanbul ignore else - noop, normal request
56
+ if (req.headers.accept === "text/event-stream") {
57
+ res.writeHead(res.statusCode, {
58
+ "Content-Type": "text/event-stream",
59
+ "Cache-Control": "no-transform",
60
+ Connection: "keep-alive",
61
+ });
62
+ }
63
+ // Handle callbacks for successful responses
64
+ if (proxyRes.statusCode === 200 &&
65
+ (args.onRestEndpointSuccess || args.onGraphQLOperationSuccess)) {
66
+ handleSuccessCallback({
67
+ proxyRes,
68
+ req,
69
+ logger,
70
+ onRestEndpointSuccess: args.onRestEndpointSuccess,
71
+ onGraphQLOperationSuccess: args.onGraphQLOperationSuccess,
72
+ });
73
+ }
74
+ },
75
+ error: (err, req, res) => {
76
+ logger.error("[setupAiAssistantRoutes] Proxy error:", err);
77
+ if ("headersSent" in res && !res.headersSent) {
78
+ res.statusCode = 502;
79
+ res.write("Bad Gateway");
80
+ res.end();
81
+ }
82
+ },
83
+ },
84
+ };
85
+ logger.debug("[setupAiAssistantRoutes] Setting up AI Assistant proxy:", proxyOptions);
86
+ const proxy = (0, http_proxy_middleware_1.createProxyMiddleware)(proxyOptions);
87
+ args.app.use(routePath, ...(0, helpers_1.coalesce)(args.preflightMiddlewares, []), bearerTokenMiddleware, proxy);
88
+ }
89
+ /**
90
+ * This function gets around needing to add new global types that are only
91
+ * needed for this one function.
92
+ */
93
+ function getRequestWithNewAuthHeader(req) {
94
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
95
+ return req;
96
+ }
97
+ /**
98
+ * Handles success callbacks by buffering the response and invoking the
99
+ * appropriate callback based on the request type
100
+ */
101
+ function handleSuccessCallback(args) {
102
+ const { proxyRes, req, logger, onRestEndpointSuccess, onGraphQLOperationSuccess, } = args;
103
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
104
+ const expressRequest = req;
105
+ const targetPath = expressRequest.path || expressRequest.url || "";
106
+ const requestBody = expressRequest.body;
107
+ // Buffer the response data
108
+ const chunks = [];
109
+ proxyRes.on("data", (chunk) => {
110
+ chunks.push(chunk);
111
+ });
112
+ proxyRes.on("end", () => {
113
+ processBufferedResponse({
114
+ chunks,
115
+ requestBody,
116
+ targetPath,
117
+ expressRequest,
118
+ logger,
119
+ onRestEndpointSuccess,
120
+ onGraphQLOperationSuccess,
121
+ });
122
+ });
123
+ }
124
+ /**
125
+ * Processes the buffered response and routes to appropriate callbacks
126
+ */
127
+ function processBufferedResponse(args) {
128
+ const { chunks, requestBody, targetPath, expressRequest, logger, onRestEndpointSuccess, onGraphQLOperationSuccess, } = args;
129
+ try {
130
+ const responseBody = Buffer.concat(chunks).toString("utf8");
131
+ // Skip callback if response is empty
132
+ if (!responseBody) {
133
+ return;
134
+ }
135
+ const parsedResponse = tryParseJSON(responseBody, logger);
136
+ if (!parsedResponse) {
137
+ return;
138
+ }
139
+ routeCallback({
140
+ requestBody,
141
+ parsedResponse,
142
+ targetPath,
143
+ expressRequest,
144
+ logger,
145
+ onRestEndpointSuccess,
146
+ onGraphQLOperationSuccess,
147
+ });
148
+ }
149
+ catch (error) {
150
+ // Don't let callback errors break the proxy
151
+ logger.error("[setupAiAssistantRoutes] Error in success callback:", error);
152
+ }
153
+ }
154
+ /**
155
+ * Routes the parsed response to the appropriate callback handler
156
+ */
157
+ function routeCallback(args) {
158
+ const { requestBody, parsedResponse, targetPath, expressRequest, logger, onRestEndpointSuccess, onGraphQLOperationSuccess, } = args;
159
+ const isGraphQLRequest = isGraphQLRequestBody(requestBody);
160
+ if (isGraphQLRequest && onGraphQLOperationSuccess) {
161
+ handleGraphQLCallback({
162
+ requestBody,
163
+ parsedResponse,
164
+ expressRequest,
165
+ onGraphQLOperationSuccess,
166
+ logger,
167
+ });
168
+ }
169
+ else if (!isGraphQLRequest && onRestEndpointSuccess) {
170
+ handleRestCallback({
171
+ targetPath,
172
+ requestBody,
173
+ parsedResponse,
174
+ expressRequest,
175
+ onRestEndpointSuccess,
176
+ logger,
177
+ });
178
+ }
179
+ }
180
+ /**
181
+ * Attempts to parse JSON response body
182
+ */
183
+ function tryParseJSON(responseBody, logger) {
184
+ try {
185
+ return JSON.parse(responseBody);
186
+ }
187
+ catch (error) {
188
+ // If it's not JSON (e.g., streaming response), skip callback
189
+ logger.debug("[setupAiAssistantRoutes] Response is not JSON, skipping callback");
190
+ return undefined;
191
+ }
192
+ }
193
+ /**
194
+ * Checks if an object has GraphQL operation fields
195
+ */
196
+ function hasGraphQLFields(item) {
197
+ return (typeof item === "object" &&
198
+ item !== null &&
199
+ ("operationName" in item || "query" in item));
200
+ }
201
+ /**
202
+ * Checks if request body indicates a GraphQL request
203
+ */
204
+ function isGraphQLRequestBody(requestBody) {
205
+ // Handle single GraphQL operation
206
+ if (!Array.isArray(requestBody)) {
207
+ return hasGraphQLFields(requestBody);
208
+ }
209
+ // Handle batched GraphQL operations
210
+ if (requestBody.length > 0) {
211
+ return hasGraphQLFields(requestBody[0]);
212
+ }
213
+ return false;
214
+ }
215
+ /**
216
+ * Handles GraphQL operation callbacks
217
+ */
218
+ function handleGraphQLCallback(args) {
219
+ const { requestBody, parsedResponse, expressRequest, onGraphQLOperationSuccess, logger, } = args;
220
+ // Handle batched GraphQL requests
221
+ if (Array.isArray(requestBody)) {
222
+ handleBatchedGraphQLCallbacks({
223
+ requestBodies: requestBody,
224
+ parsedResponse,
225
+ expressRequest,
226
+ onGraphQLOperationSuccess,
227
+ logger,
228
+ });
229
+ return;
230
+ }
231
+ // Handle single GraphQL request
232
+ const operationName = extractGraphQLOperationName(requestBody, logger);
233
+ if (!operationName) {
234
+ return;
235
+ }
236
+ const callback = onGraphQLOperationSuccess[operationName];
237
+ if (callback) {
238
+ invokeGraphQLCallback({
239
+ callback,
240
+ requestBody,
241
+ parsedResponse,
242
+ expressRequest,
243
+ operationName,
244
+ logger,
245
+ });
246
+ }
247
+ }
248
+ /**
249
+ * Handles batched GraphQL operation callbacks
250
+ */
251
+ function handleBatchedGraphQLCallbacks(args) {
252
+ const { requestBodies, parsedResponse, expressRequest, onGraphQLOperationSuccess, logger, } = args;
253
+ // Response should also be an array for batched requests
254
+ const responses = Array.isArray(parsedResponse)
255
+ ? parsedResponse
256
+ : [parsedResponse];
257
+ // Process each operation in the batch
258
+ requestBodies.forEach((requestBody, index) => {
259
+ const operationName = extractGraphQLOperationName(requestBody, logger);
260
+ if (!operationName) {
261
+ return;
262
+ }
263
+ const callback = onGraphQLOperationSuccess[operationName];
264
+ if (!callback) {
265
+ return;
266
+ }
267
+ // Match the request with its corresponding response
268
+ const response = responses[index] || parsedResponse;
269
+ invokeGraphQLCallback({
270
+ callback,
271
+ requestBody,
272
+ parsedResponse: response,
273
+ expressRequest,
274
+ operationName,
275
+ logger,
276
+ });
277
+ });
278
+ }
279
+ /**
280
+ * Extracts the GraphQL operation name from request body
281
+ */
282
+ function extractGraphQLOperationName(requestBody, logger) {
283
+ if (typeof requestBody !== "object" || requestBody === null) {
284
+ return undefined;
285
+ }
286
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
287
+ const body = requestBody;
288
+ // First, check if operationName is explicitly provided
289
+ if (body.operationName) {
290
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
291
+ return body.operationName;
292
+ }
293
+ // Try to extract from query string
294
+ if (body.query) {
295
+ const match = body.query.match(/(?:query|mutation)\s+(\w+)/);
296
+ if (match) {
297
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
298
+ return match[1];
299
+ }
300
+ }
301
+ logger.debug("[setupAiAssistantRoutes] Could not determine GraphQL operation name");
302
+ return undefined;
303
+ }
304
+ /**
305
+ * Invokes a GraphQL callback with the provided context
306
+ * Type assertion is necessary because callbacks have specific request/response types
307
+ * but we're working with unknown at runtime
308
+ */
309
+ function invokeGraphQLCallback(args) {
310
+ const { callback, requestBody, parsedResponse, expressRequest, operationName, logger, } = args;
311
+ const context = {
312
+ request: {
313
+ path: expressRequest.path || expressRequest.url || "",
314
+ method: expressRequest.method || "POST",
315
+ body: requestBody,
316
+ },
317
+ response: parsedResponse,
318
+ };
319
+ // Type assertion needed: callback expects specific CallbackContext types,
320
+ // but we can only provide CallbackContext<unknown, unknown> at runtime
321
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
322
+ const typedCallback = callback;
323
+ Promise.resolve(typedCallback(context)).catch((error) => {
324
+ logger.error(`[setupAiAssistantRoutes] Error in GraphQL callback for ${operationName}:`, error);
325
+ });
326
+ }
327
+ /**
328
+ * Handles REST endpoint callbacks
329
+ */
330
+ function handleRestCallback(args) {
331
+ const { targetPath, requestBody, parsedResponse, expressRequest, onRestEndpointSuccess, logger, } = args;
332
+ const matchingPath = findMatchingRestEndpoint(targetPath, onRestEndpointSuccess);
333
+ if (!matchingPath) {
334
+ return;
335
+ }
336
+ const callback = onRestEndpointSuccess[matchingPath];
337
+ if (callback) {
338
+ // Empty string fallback for path is unreachable since targetPath and expressRequest.path come from same source
339
+ /* istanbul ignore next */
340
+ const requestPath = expressRequest.path || expressRequest.url || "";
341
+ const context = {
342
+ request: {
343
+ path: requestPath,
344
+ method: expressRequest.method || "POST",
345
+ body: requestBody,
346
+ },
347
+ response: parsedResponse,
348
+ };
349
+ // Type assertion needed: callback expects specific CallbackContext types,
350
+ // but we can only provide CallbackContext<unknown, unknown> at runtime
351
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
352
+ const typedCallback = callback;
353
+ Promise.resolve(typedCallback(context)).catch((error) => {
354
+ logger.error(`[setupAiAssistantRoutes] Error in REST callback for ${matchingPath}:`, error);
355
+ });
356
+ }
357
+ }
358
+ /**
359
+ * Finds a matching REST endpoint path from the callbacks
360
+ */
361
+ function findMatchingRestEndpoint(targetPath, callbacks) {
362
+ const match = Object.keys(callbacks).find((path) => targetPath.includes(path));
363
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
364
+ return match;
365
+ }
366
+ //# sourceMappingURL=express.js.map
package/constants.js ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * This file contains constants for the WorkTango Coach AI Assistant. It should
3
+ * contain no imports or dependencies: just constants and JSDoc types.
4
+ *
5
+ * We use it for sharing prompts and other data between systems in as light a way
6
+ * as possible.
7
+ */
8
+
9
+ export const workTangoCoachSystemInstruction = `You are a 'Leadership Coach'. Your purpose is to empower People Leaders by providing guidance, resources, and tools to enhance their leadership capabilities. You will assist users in various aspects of leadership development, from problem-solving to goal setting and self-reflection. Sometimes you will be tasked with analyzing Survey Results. The Survey Results will inform the Coaching focus.
10
+
11
+ Purpose and Goals:
12
+
13
+ * **Guidance and Research:** Help users research and understand effective approaches to specific leadership challenges, issues, or topics.
14
+ * **Self-Assessment Support:** Assist users in conducting self-assessments to identify their strengths, weaknesses, and areas for development as leaders.
15
+ * **Goal Setting Facilitation:** Guide users through the process of setting clear, actionable, and measurable leadership goals.
16
+ * **Reflective Questioning:** Engage users in reflective exercises using 'Powerful Questions' to encourage introspection and deeper understanding of their leadership journey.
17
+ * **Knowledge Transfer:** Educate users on leadership theories, best practices, and effective strategies for leading teams and organizations.
18
+
19
+ Behaviors and Rules:
20
+
21
+ **Initial Engagement:**
22
+ - If asked about something specific, you can skip the formal introduction, otherwise:
23
+ - Greet the user warmly as their 'Leadership Coach' and express readiness to assist them in their growth as a Leader
24
+ - List common requests you're designed to handle (research, self-assessment, goal setting, reflection, teaching).
25
+ - Indicate that the session will be 5-10 mins
26
+ - Ask the user to specify which of these areas they'd like to focus on first, or if they have a different leadership challenge in mind.
27
+
28
+ **Interactive Support:**
29
+
30
+ - For research requests, ask clarifying questions to understand the specific challenge or topic, then provide concise, actionable insights or resources.
31
+ - For self-assessment, present frameworks or prompts, and encourage the user to share their thoughts, offering constructive feedback.
32
+ - For goal setting, help the user define SMART (Specific, - Measurable, Achievable, Relevant, Time-bound) goals, breaking them down into manageable steps.
33
+ - When using 'Powerful Questions', pose open-ended, thought-provoking questions that encourage deep reflection rather than simple 'yes/no' answers.
34
+ - When teaching, break down complex concepts into understandable segments, providing examples and real-world applications.
35
+
36
+ **Coaching Approach:**
37
+
38
+ - Aim for a 5-10 minute coaching session
39
+ - Maintain a supportive, encouraging, and non-judgmental demeanor.
40
+ - Propose paths forward and look for input on the relevance of what is being suggested
41
+ - Encourage active participation and critical thinking from the user.
42
+ - Keep responses concise and clear, generally within 2-3 sentences per turn, allowing for a dynamic conversation flow.
43
+ - Always end the conversation with a summary of the discussions and recommended actions for the People Leader
44
+
45
+ Overall Tone:
46
+
47
+ * **Empowering and Positive:** Foster a sense of capability and growth in the user.
48
+ * **Knowledgeable and Trustworthy:** Convey expertise in leadership principles and practices.
49
+ * **Patient and Understanding:** Recognize the complexities of leadership and support users through their challenges.
50
+ * **Action-Oriented:** Encourage practical application of learned concepts.
51
+ `;
52
+
53
+ /**
54
+ * @typedef {Object} AiAssistantSuggestedPrompt
55
+ * @property {string} title - The title of the suggested prompt.
56
+ * @property {string} [fullPrompt] - The full prompt to be used. If not provided, the title will be used as the prompt.
57
+ */
58
+
59
+ /**
60
+ * Globally-available suggested prompts used between platforms.
61
+ * @type {AiAssistantSuggestedPrompt[]}
62
+ */
63
+ export const workTangoCoachGlobalSuggestedPrompts = [
64
+ {
65
+ title:
66
+ "Help me research how to approach a specific challenge, issue or topic",
67
+ },
68
+ { title: "Help me set effective goals for my team" },
69
+ { title: "Help me structure better 1-on-1s with my team" },
70
+ { title: "Help me reflect with powerful questions" },
71
+ { title: "Help me have a difficult conversation with a team member" },
72
+ { title: "Help me delegate more effectively" },
73
+ { title: "Help me with a self assessment" },
74
+ {
75
+ title: "How do I adapt my leadership approach to different personalities?",
76
+ },
77
+ { title: "How do I keep my team motivated during a crunch period?" },
78
+ { title: "How do I make space for strategic thinking amid daily fires?" },
79
+ { title: "How can I communicate a tough change to my team with empathy?" },
80
+ ];
@@ -0,0 +1,49 @@
1
+ import { j as C } from "./reactComponent-CGfCiP84.mjs";
2
+ function e({
3
+ illustrationColor: t
4
+ }) {
5
+ return /* @__PURE__ */ C.jsxs(C.Fragment, { children: [
6
+ /* @__PURE__ */ C.jsx("title", { children: "Absenteeism illustration" }),
7
+ /* @__PURE__ */ C.jsx(
8
+ "path",
9
+ {
10
+ d: "M60 120C93.1371 120 120 93.1371 120 60C120 26.8629 93.1371 0 60 0C26.8629 0 0 26.8629 0 60C0 93.1371 26.8629 120 60 120Z",
11
+ fill: t
12
+ }
13
+ ),
14
+ /* @__PURE__ */ C.jsx(
15
+ "path",
16
+ {
17
+ d: "M26.0354 50.0576V89.2332C26.0368 90.4902 26.5367 91.6953 27.4256 92.5842C28.3144 93.473 29.5195 93.9729 30.7765 93.9743H89.2541C90.5111 93.9729 91.7162 93.473 92.6051 92.5842C93.4939 91.6953 93.9938 90.4902 93.9952 89.2332V50.0576H26.0354ZM72.6461 81.3799C72.9411 81.6955 73.102 82.1133 73.0947 82.5452C73.0875 82.9771 72.9127 83.3893 72.6072 83.6947C72.3018 84.0002 71.8896 84.175 71.4577 84.1822C71.0258 84.1895 70.6079 84.0286 70.2924 83.7336L60.6959 74.1345L51.0839 83.7336C50.9313 83.8968 50.7475 84.0276 50.5433 84.1182C50.3392 84.2089 50.1188 84.2575 49.8955 84.2613C49.6721 84.265 49.4503 84.2238 49.2432 84.14C49.0361 84.0563 48.848 83.9317 48.6901 83.7738C48.5321 83.6158 48.4075 83.4277 48.3238 83.2206C48.24 83.0135 48.1988 82.7917 48.2026 82.5683C48.2063 82.345 48.255 82.1247 48.3456 81.9205C48.4363 81.7163 48.5671 81.5325 48.7302 81.3799L58.3293 71.7809L48.7458 62.1844C48.5827 62.0318 48.4518 61.848 48.3612 61.6438C48.2705 61.4397 48.2219 61.2193 48.2181 60.996C48.2144 60.7726 48.2556 60.5508 48.3394 60.3437C48.4231 60.1366 48.5477 59.9485 48.7056 59.7906C48.8636 59.6326 49.0517 59.508 49.2588 59.4243C49.4659 59.3405 49.6877 59.2993 49.9111 59.303C50.1344 59.3068 50.3548 59.3555 50.5589 59.4461C50.7631 59.5368 50.9469 59.6676 51.0995 59.8307L60.6959 69.4298L70.295 59.8307C70.4476 59.6676 70.6314 59.5368 70.8356 59.4461C71.0397 59.3555 71.2601 59.3068 71.4834 59.303C71.7068 59.2993 71.9286 59.3405 72.1357 59.4243C72.3428 59.508 72.5309 59.6326 72.6889 59.7906C72.8468 59.9485 72.9714 60.1366 73.0551 60.3437C73.1389 60.5508 73.1801 60.7726 73.1764 60.996C73.1726 61.2193 73.124 61.4397 73.0333 61.6438C72.9426 61.848 72.8118 62.0318 72.6487 62.1844L63.034 71.7809L72.6461 81.3799Z",
18
+ fill: "white"
19
+ }
20
+ ),
21
+ /* @__PURE__ */ C.jsx(
22
+ "path",
23
+ {
24
+ opacity: "0.4",
25
+ d: "M89.2248 33.0134H80.7376V39.7081C80.7376 40.3144 80.4968 40.8959 80.068 41.3246C79.6393 41.7533 79.0578 41.9942 78.4515 41.9942C77.8452 41.9942 77.2637 41.7533 76.835 41.3246C76.4063 40.8959 76.1654 40.3144 76.1654 39.7081V33.0134H43.8092V39.7081C43.8092 40.3144 43.5683 40.8959 43.1396 41.3246C42.7108 41.7533 42.1294 41.9942 41.523 41.9942C40.9167 41.9942 40.3353 41.7533 39.9065 41.3246C39.4778 40.8959 39.2369 40.3144 39.2369 39.7081V33.0134H30.7446C29.4876 33.0148 28.2825 33.5148 27.3936 34.4036C26.5048 35.2924 26.0049 36.4975 26.0035 37.7545V46.7379H93.9633V37.7545C93.9626 36.4978 93.4632 35.2926 92.5748 34.4037C91.6864 33.5148 90.4816 33.0148 89.2248 33.0134V33.0134Z",
26
+ fill: "black"
27
+ }
28
+ ),
29
+ /* @__PURE__ */ C.jsx(
30
+ "path",
31
+ {
32
+ opacity: "0.7",
33
+ d: "M41.5184 41.3705C41.0774 41.3705 40.6545 41.1953 40.3427 40.8835C40.0309 40.5717 39.8558 40.1488 39.8558 39.7079V27.6824C39.8558 27.2414 40.0309 26.8185 40.3427 26.5067C40.6545 26.1949 41.0774 26.0198 41.5184 26.0198C41.9594 26.0198 42.3823 26.1949 42.6941 26.5067C43.0059 26.8185 43.181 27.2414 43.181 27.6824V39.7079C43.1803 40.1486 43.0049 40.5711 42.6933 40.8828C42.3816 41.1944 41.9591 41.3698 41.5184 41.3705V41.3705Z",
34
+ fill: "white"
35
+ }
36
+ ),
37
+ /* @__PURE__ */ C.jsx(
38
+ "path",
39
+ {
40
+ opacity: "0.7",
41
+ d: "M78.4519 41.3705C78.0111 41.3698 77.5886 41.1944 77.277 40.8828C76.9653 40.5711 76.7899 40.1486 76.7892 39.7079V27.6824C76.7892 27.2414 76.9644 26.8185 77.2762 26.5067C77.588 26.1949 78.0109 26.0198 78.4519 26.0198C78.8928 26.0198 79.3157 26.1949 79.6275 26.5067C79.9393 26.8185 80.1145 27.2414 80.1145 27.6824V39.7079C80.1138 40.1486 79.9384 40.5711 79.6268 40.8828C79.3151 41.1944 78.8926 41.3698 78.4519 41.3705V41.3705Z",
42
+ fill: "white"
43
+ }
44
+ )
45
+ ] });
46
+ }
47
+ export {
48
+ e as Absenteeism
49
+ };