@worktango/ai-assistant 0.0.1-bjarke-test-1
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/CHANGELOG.md +3 -0
- package/README.md +66 -0
- package/constants.js +80 -0
- package/dist/Absenteeism-DKQeCJFe.mjs +49 -0
- package/dist/ActivityFeed-By8N5rIb.mjs +41 -0
- package/dist/AddUser-B11fkZ1b.mjs +128 -0
- package/dist/Admin-BzXgXWQJ.mjs +70 -0
- package/dist/Admin-hmgARSaM.mjs +55 -0
- package/dist/AiGeneral-Zqk5YVTm.mjs +43 -0
- package/dist/AiScoring-4TYwpieo.mjs +67 -0
- package/dist/AiText-BBlRqpKx.mjs +67 -0
- package/dist/Anniversary-ClFTD-wm.mjs +35 -0
- package/dist/Appreciation-BVQGaA0c.mjs +55 -0
- package/dist/ArrowDown-BVSXvFfR.mjs +38 -0
- package/dist/ArrowLeft-DbaEIUq7.mjs +12 -0
- package/dist/ArrowRight-DOONcI-5.mjs +12 -0
- package/dist/ArrowUp-CTxeL6md.mjs +31 -0
- package/dist/Attachment-DEAehD_N.mjs +20 -0
- package/dist/BeQuickDontHurry-r6Culc0D.mjs +94 -0
- package/dist/Birthday-7k7juHp1.mjs +66 -0
- package/dist/BrandPromise-DUwoJq8L.mjs +57 -0
- package/dist/BrandVision-B--SF_5s.mjs +96 -0
- package/dist/Calendar-BmMPCdGU.mjs +24 -0
- package/dist/CaretDn-Cj9f7wWT.mjs +11 -0
- package/dist/CaretDown-t6-_N_zB.mjs +5 -0
- package/dist/CaretLeft-miiop37_.mjs +11 -0
- package/dist/CaretRight-Bh2TI6FC.mjs +11 -0
- package/dist/CaretUp-CLas6kjg.mjs +11 -0
- package/dist/ChallengeAccepted-Cng8-_fK.mjs +49 -0
- package/dist/CheckIn-Bl-qKH4C.mjs +34 -0
- package/dist/CheckIns-DV7ACWR5.mjs +33 -0
- package/dist/CheckSeal-BhlbCf0l.mjs +31 -0
- package/dist/Checkmark-B4cSN7b2.mjs +16 -0
- package/dist/Clock-XvAlJd99.mjs +33 -0
- package/dist/Close-BoBjL3p4.mjs +12 -0
- package/dist/CloudDownload-Clg2glDD.mjs +40 -0
- package/dist/Comment-Cf5rGrUx.mjs +167 -0
- package/dist/Comments-BYkIX7hT.mjs +48 -0
- package/dist/Connections-CwnwZDrV.mjs +49 -0
- package/dist/Copy-JNB9bFdv.mjs +72 -0
- package/dist/CustomQuestion-DQrhmFZS.mjs +40 -0
- package/dist/CustomerSuccess-BfQn-USd.mjs +50 -0
- package/dist/DatePicker-twIwWjdo.mjs +303 -0
- package/dist/Dot-B-_6My1H.mjs +12 -0
- package/dist/Download-CWdNedBI.mjs +38 -0
- package/dist/Drag-BuHlTvAq.mjs +41 -0
- package/dist/Earn-CNWl9C-l.mjs +15 -0
- package/dist/Email-xRqv17oP.mjs +24 -0
- package/dist/EmojiDisplay-BoJ_8qAH.mjs +38975 -0
- package/dist/EmojiPicker-BHvC2jWu.mjs +29560 -0
- package/dist/EnpsSurvey-B8z8O8_B.mjs +49 -0
- package/dist/Expired-BkxyeYB4.mjs +33 -0
- package/dist/Eye-wfJ3gugr.mjs +27 -0
- package/dist/Feedback-BQO85zin.mjs +41 -0
- package/dist/Feedback-Dbcfkhdz.mjs +49 -0
- package/dist/Filter-mDPAT1Q0.mjs +64 -0
- package/dist/Flag-sp2VUbeT.mjs +35 -0
- package/dist/Giphy-D16NK7zo.mjs +24 -0
- package/dist/GoalCount-8JeAFE3u.mjs +10 -0
- package/dist/GoalPercent-BGcEIQhs.mjs +21 -0
- package/dist/GoalTask-DAXx59x6.mjs +42 -0
- package/dist/GoalTask-mLnASf_8.mjs +20 -0
- package/dist/Goals-DUtWQwJX.mjs +70 -0
- package/dist/Goals-fZSGOH8N.mjs +79 -0
- package/dist/Growth-C2_i8Dvq.mjs +85 -0
- package/dist/Hamburger-ogKQ0icO.mjs +9 -0
- package/dist/Help-jNwLb0Dl.mjs +36 -0
- package/dist/HighFive-B0O5Eulz.mjs +33 -0
- package/dist/HighFive-D4Opvtug.mjs +38 -0
- package/dist/Home-B4EE5Idx.mjs +21 -0
- package/dist/Home-CqNj7K1M.mjs +31 -0
- package/dist/HorizontalLine-BbBf53W6.mjs +17 -0
- package/dist/Hourglass-iHsifZqr.mjs +53 -0
- package/dist/Image-DSetLMKV.mjs +43 -0
- package/dist/ImageFile-B4n34jW-.mjs +60 -0
- package/dist/InGoodCompany-B-Xk8gu5.mjs +33 -0
- package/dist/Incentives-C11BOIzL.mjs +155 -0
- package/dist/Info-DeAd4Zuu.mjs +31 -0
- package/dist/Insights-Bh1_-GX0.mjs +20 -0
- package/dist/Insights-F2UZ7b8W.mjs +41 -0
- package/dist/Integrations-CmwQxQrS.mjs +33 -0
- package/dist/KazooLogo-Bg5jXPnf.mjs +38 -0
- package/dist/KnowYourAudience-8qZIb7xO.mjs +91 -0
- package/dist/Launch-ejdSbw8E.mjs +83 -0
- package/dist/Link-DRaBcUGc.mjs +25 -0
- package/dist/LinkArrow-DJKirOsX.mjs +12 -0
- package/dist/Loading-BhldP995.mjs +6 -0
- package/dist/Lock-BarZzJ2S.mjs +31 -0
- package/dist/Management-BrwhLLmT.mjs +87 -0
- package/dist/MeatballMenu-D5Y89Jx4.mjs +9 -0
- package/dist/Messages-DMvc6ODT.mjs +221 -0
- package/dist/Microphone-Dc-Q7px0.mjs +63 -0
- package/dist/Mobile-CIFbEUH9.mjs +31 -0
- package/dist/Nomination-C4qAU5bv.mjs +12 -0
- package/dist/NominationsAndAwards-CU0jpyXa.mjs +57 -0
- package/dist/Notification-aDUSQq1T.mjs +28 -0
- package/dist/Okrs-BMNUw3fD.mjs +55 -0
- package/dist/Pause-CbwCN72J.mjs +12 -0
- package/dist/PeerToPeer-BTiJKyDt.mjs +64 -0
- package/dist/Pencil-BSvpXoVb.mjs +25 -0
- package/dist/People-XGY6RLRA.mjs +43 -0
- package/dist/PerformanceManagement-OrYGaeND.mjs +57 -0
- package/dist/Pin-6Nc7TvdN.mjs +24 -0
- package/dist/PinnedIconAward-DK8093FF.mjs +20 -0
- package/dist/PinnedIconBrightIdea-CFHgwd4R.mjs +20 -0
- package/dist/PinnedIconBullseye-BXKQGjtK.mjs +36 -0
- package/dist/PinnedIconChampagne-Dv4xSUse.mjs +20 -0
- package/dist/PinnedIconCheer-B0RxtPH0.mjs +20 -0
- package/dist/PinnedIconCrown-dXA0Ysol.mjs +20 -0
- package/dist/PinnedIconDiamond-B4UF8EM2.mjs +20 -0
- package/dist/PinnedIconHoleInOne-DWrob0u8.mjs +20 -0
- package/dist/PinnedIconMedal-DYd2l4l-.mjs +20 -0
- package/dist/PinnedIconMetrics-DERm0m5H.mjs +20 -0
- package/dist/PinnedIconPin-B0bhc8PT.mjs +20 -0
- package/dist/PinnedIconRockAndRoll-CkF-Gx5P.mjs +23 -0
- package/dist/PinnedIconRocket-DRy6Jw_X.mjs +20 -0
- package/dist/PinnedIconStrength-D9kesgYv.mjs +20 -0
- package/dist/PinnedIconTeddyBear-C5Hr-Ie6.mjs +20 -0
- package/dist/PlatformLogo-Cfq4S8f-.mjs +57 -0
- package/dist/Plus-BP-tHuVN.mjs +19 -0
- package/dist/Popper-DMsFtODL.mjs +1118 -0
- package/dist/PrivateEye-BBKvE027.mjs +127 -0
- package/dist/PrivatePushPin-DNYYGi4Q.mjs +33 -0
- package/dist/Processing-DgixJJ-S.mjs +80 -0
- package/dist/Productivity-DqwMh18D.mjs +41 -0
- package/dist/ProgressCircle-N_gD0yk-.mjs +12 -0
- package/dist/PulseSurvey-BYARcVSr.mjs +48 -0
- package/dist/PushPin-cF5m--74.mjs +18 -0
- package/dist/QuotesLeft-JZoCDmgA.mjs +18 -0
- package/dist/QuotesRight-C9gTKGRq.mjs +18 -0
- package/dist/Recognition-BognmIeU.mjs +76 -0
- package/dist/Recognition-DV-ClFpJ.mjs +38 -0
- package/dist/Retention-E6k3zAh3.mjs +47 -0
- package/dist/Rewards-CKU53Bqo.mjs +67 -0
- package/dist/Rewards-DWhEwtg0.mjs +54 -0
- package/dist/RewardsCatalog-DQlKPdIX.mjs +49 -0
- package/dist/Roadmap-Cl7Nr3XO.mjs +122 -0
- package/dist/Search-BnUeCylE.mjs +14 -0
- package/dist/Security-Bo7nEsGN.mjs +33 -0
- package/dist/SendRecognition-D5-4kvBC.mjs +5 -0
- package/dist/ShareLink-DpBhP3gn.mjs +27 -0
- package/dist/SidebarCollapse-D7l3VGdc.mjs +48 -0
- package/dist/Skill-BOjVWd4d.mjs +23 -0
- package/dist/Skills-DmX11BHE.mjs +68 -0
- package/dist/Smiley-ZHbi1wNI.mjs +45 -0
- package/dist/Stop-drrWjQXM.mjs +178 -0
- package/dist/Survey-D-70QZKK.mjs +59 -0
- package/dist/Surveys-08V_Fj9a.mjs +54 -0
- package/dist/SyncUps-DMtJQfXN.mjs +30 -0
- package/dist/Syncs-ChZZCH2o.mjs +29 -0
- package/dist/TalentReview-CSB7Yhh2.mjs +88 -0
- package/dist/TalentReview-CmIFEEyc.mjs +33 -0
- package/dist/TalentReviewInsights-DjljJNVH.mjs +100 -0
- package/dist/TaskCompleted-nB82zIUa.mjs +97 -0
- package/dist/Team-DNXsR8LD.mjs +63 -0
- package/dist/Teams-GxBqwt_y.mjs +80 -0
- package/dist/TextBold-BG_Er0Ve.mjs +71 -0
- package/dist/TextBulletList-DWGlU831.mjs +128 -0
- package/dist/TextInput-CjbXFoKC.mjs +121 -0
- package/dist/TextItalic-FDmV3Aje.mjs +71 -0
- package/dist/TextNumberList-D5O46X9h.mjs +147 -0
- package/dist/TextUnderline-D1t1CHRn.mjs +90 -0
- package/dist/Toggle-CAQo5Ucg.mjs +76 -0
- package/dist/Translate-RdwRh8fZ.mjs +98 -0
- package/dist/Trash-PoqFzwsL.mjs +44 -0
- package/dist/TrendDown-Dl6D7HCG.mjs +5 -0
- package/dist/TrendUp-rNelH68t.mjs +5 -0
- package/dist/Undo-XubKoMyD.mjs +41 -0
- package/dist/Unplugged-C928cUBf.mjs +201 -0
- package/dist/UpDownCaret-Dxh4h6OB.mjs +12 -0
- package/dist/VerticalLine-BENKSAJN.mjs +50 -0
- package/dist/Warning-BSirTzpc.mjs +37 -0
- package/dist/WarningNoOutline-PXMm83kK.mjs +41 -0
- package/dist/YesAnd-ChDb6w8R.mjs +31 -0
- package/dist/ai-assistant.css +1 -0
- package/dist/emoji-D6LQW50y.mjs +2310 -0
- package/dist/express.js +11375 -0
- package/dist/html2canvas.esm-DgdJBc_o.mjs +4871 -0
- package/dist/index-BEKNcH9V.mjs +721 -0
- package/dist/react-apexcharts.min-cfaSD7w7.mjs +11326 -0
- package/dist/react.es.js +12 -0
- package/dist/react.umd.js +1692 -0
- package/dist/reactComponent-yXda1vR_.mjs +43178 -0
- package/express.d.ts +55 -0
- package/express.js +4 -0
- package/package.json +60 -0
- package/react.d.ts +121 -0
- package/react.js +4 -0
- package/sharedTypes.ts +362 -0
package/express.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { RequestHandler, Request, Application } from "express";
|
|
2
|
+
|
|
3
|
+
export function setupAiAssistantRoutes(args: {
|
|
4
|
+
app: Application;
|
|
5
|
+
/**
|
|
6
|
+
* A function that returns the bearer token for the AI assistant to use for
|
|
7
|
+
* back-channel request proxying. This should be a JWT token that can be
|
|
8
|
+
* decoded on the `kazoo-web` application to authenticate the request.
|
|
9
|
+
*/
|
|
10
|
+
getBearerToken: (
|
|
11
|
+
headers: Record<string, undefined | string | string[]>
|
|
12
|
+
) => Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* The host of the application to proxy requests to.
|
|
15
|
+
*/
|
|
16
|
+
targetHost: string;
|
|
17
|
+
/**
|
|
18
|
+
* The port of the application to proxy requests to. Defaults to 80.
|
|
19
|
+
*/
|
|
20
|
+
targetPort?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The protocol of the application to proxy requests to. Defaults to "http".
|
|
23
|
+
*/
|
|
24
|
+
targetProtocol?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to follow redirects. Defaults to true.
|
|
27
|
+
*/
|
|
28
|
+
followRedirects?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The route path to the local service's AI assistant. Defaults to
|
|
31
|
+
* "/ai-assistant".
|
|
32
|
+
*/
|
|
33
|
+
route?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The logger to use for logging.
|
|
36
|
+
*/
|
|
37
|
+
logger?: Pick<typeof console, "log" | "error" | "debug">;
|
|
38
|
+
/**
|
|
39
|
+
* Middleware functions to run before the proxy request.
|
|
40
|
+
*/
|
|
41
|
+
preflightMiddlewares?: RequestHandler[];
|
|
42
|
+
/**
|
|
43
|
+
* A function that should return the target path for the proxy request, based
|
|
44
|
+
* on the incoming full path. The path returned will be appended to the
|
|
45
|
+
* target host and port to form the final URL.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* getTargetPath: (fullPath) => {
|
|
50
|
+
* return fullPath;
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
getTargetPath: (fullPath: string) => string;
|
|
55
|
+
}): void;
|
package/express.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@worktango/ai-assistant",
|
|
3
|
+
"version": "0.0.1-bjarke-test-1",
|
|
4
|
+
"files": [
|
|
5
|
+
"constants.js",
|
|
6
|
+
"dist",
|
|
7
|
+
"express.d.ts",
|
|
8
|
+
"express.js",
|
|
9
|
+
"react.d.ts",
|
|
10
|
+
"react.js",
|
|
11
|
+
"sharedTypes.ts"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"dev": "vite --config vite.config.ts src/dev",
|
|
15
|
+
"dev:backend": "nodemon express.js",
|
|
16
|
+
"build:backend": "esbuild src/backend/express.ts --bundle --platform=node --outfile=dist/express.js \"--external:express\"",
|
|
17
|
+
"build:frontend": "vite build",
|
|
18
|
+
"build:all": "rm -rf dist && yarn build:backend && yarn build:frontend && yarn ts-node -T scripts/injectCssIntoBuild.ts",
|
|
19
|
+
"prepareBuildForPublish": "yarn ts-node -T scripts/prepareBuildForPublish.ts",
|
|
20
|
+
"publish": "yarn build:all && yarn prepareBuildForPublish && yarn actuallyPublishPackage",
|
|
21
|
+
"actuallyPublishPackage": "yarn npm publish --access public --tolerate-republish",
|
|
22
|
+
"gql:generate": "gql-generate"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@apollo/client": "^3.0.0",
|
|
26
|
+
"@ricky0123/vad-react": "^0.0.28",
|
|
27
|
+
"@sinclair/typebox": "^0.34",
|
|
28
|
+
"apexcharts": "^4.7.0",
|
|
29
|
+
"classnames": "^2.2.6",
|
|
30
|
+
"dom-to-semantic-markdown": "^1.3",
|
|
31
|
+
"html2canvas": "^1.4.1",
|
|
32
|
+
"http-proxy-middleware": "^3",
|
|
33
|
+
"json-nd": "^1",
|
|
34
|
+
"lodash.clonedeep": "^4",
|
|
35
|
+
"micromark": "^4",
|
|
36
|
+
"micromark-extension-gfm-table": "^2.1.1",
|
|
37
|
+
"react-apexcharts": "^1.7.0",
|
|
38
|
+
"uuid": "^9"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
42
|
+
"esbuild": "^0.17.11",
|
|
43
|
+
"ts-node": "^10.9.2",
|
|
44
|
+
"typescript": "~5.8",
|
|
45
|
+
"vite": "~6.3.5"
|
|
46
|
+
},
|
|
47
|
+
"graphqlCodeGeneration": {
|
|
48
|
+
"apiHooks": {
|
|
49
|
+
"config": {
|
|
50
|
+
"enumsAsTypes": true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"$schema": "../../packages/build-tools/schema.json",
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"express": ">=4",
|
|
57
|
+
"react": ">=18",
|
|
58
|
+
"react-dom": ">=18"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/react.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { TSchema, Type, Static, TObject } from "@sinclair/typebox";
|
|
2
|
+
import {
|
|
3
|
+
AiAssistantProps,
|
|
4
|
+
ChatData,
|
|
5
|
+
ChatItem,
|
|
6
|
+
GetChatCompletionOptions,
|
|
7
|
+
GetStructuredResponseOptions,
|
|
8
|
+
ToolDeclaration,
|
|
9
|
+
AiAssistantSuggestedPromptsProps,
|
|
10
|
+
GetFollowUpSuggestions,
|
|
11
|
+
ChatDataFile,
|
|
12
|
+
AiAssistantControls,
|
|
13
|
+
FollowUpSuggestion,
|
|
14
|
+
} from "./sharedTypes";
|
|
15
|
+
|
|
16
|
+
export const getDefaultGetFollowUpSuggestions: (args: {
|
|
17
|
+
promptOverride?: string;
|
|
18
|
+
}) => GetFollowUpSuggestions;
|
|
19
|
+
|
|
20
|
+
export function AiAssistant(args: AiAssistantProps): JSX.Element;
|
|
21
|
+
|
|
22
|
+
export function AiAssistantSuggestedPrompts(
|
|
23
|
+
args: AiAssistantSuggestedPromptsProps
|
|
24
|
+
): JSX.Element;
|
|
25
|
+
|
|
26
|
+
export const tools: {
|
|
27
|
+
kazooTools: {
|
|
28
|
+
getRewardsAndRecognitionCurrentUserTool: ToolDeclaration;
|
|
29
|
+
};
|
|
30
|
+
sharedTools: {
|
|
31
|
+
doMathTool: ToolDeclaration;
|
|
32
|
+
getCurrentTimeTool: ToolDeclaration;
|
|
33
|
+
askSingleShotQuestion: ToolDeclaration;
|
|
34
|
+
analyzeCurrentPage: ToolDeclaration;
|
|
35
|
+
};
|
|
36
|
+
createTool<TParams extends TSchema = TSchema>(args: {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
parameters?: (t: typeof Type) => TParams;
|
|
40
|
+
fulfill: (args: Static<TParams>) => Promise<string | ChatDataFile>;
|
|
41
|
+
chatItemMatches?: (chatItem: ChatItem) => boolean;
|
|
42
|
+
}): ToolDeclaration;
|
|
43
|
+
} = {};
|
|
44
|
+
|
|
45
|
+
export const config: {
|
|
46
|
+
/**
|
|
47
|
+
* Get the URL for the LLM call.
|
|
48
|
+
*/
|
|
49
|
+
getLlmCallUrl: () => string;
|
|
50
|
+
/**
|
|
51
|
+
* Get the URL for the structured response call.
|
|
52
|
+
*/
|
|
53
|
+
getStructuredResponseUrl: () => string;
|
|
54
|
+
/**
|
|
55
|
+
* Get the URL for the Kazoo service.
|
|
56
|
+
*/
|
|
57
|
+
getKazooUrl: (urlPath: string) => string;
|
|
58
|
+
/**
|
|
59
|
+
* Get the URL for the Pulse service.
|
|
60
|
+
*/
|
|
61
|
+
getPulseUrl: (urlPath: string) => string;
|
|
62
|
+
/**
|
|
63
|
+
* Get the Pulse bearer token.
|
|
64
|
+
*/
|
|
65
|
+
getPulseBearerToken: () => string;
|
|
66
|
+
/**
|
|
67
|
+
* Set the strategy for getting Kazoo URLs.
|
|
68
|
+
*/
|
|
69
|
+
setKazooUrlStrategy: (strategy: (urlPath: string) => string) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Set the strategy for getting LLM call URLs.
|
|
72
|
+
*/
|
|
73
|
+
setLlmCallUrlStrategy: (strategy: (path: string) => string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Set the strategy for getting Pulse URLs.
|
|
76
|
+
*/
|
|
77
|
+
setPulseUrlStrategy: (strategy: (urlPath: string) => string) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Set the strategy for getting Pulse bearer tokens.
|
|
80
|
+
*/
|
|
81
|
+
setPulseBearerTokenStrategy: (strategy: () => string) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Set the strategy for getting structured response URLs.
|
|
84
|
+
*/
|
|
85
|
+
setStructuredResponseUrlStrategy: (
|
|
86
|
+
strategy: (path: string) => string
|
|
87
|
+
) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Set the main content selector for the page for when taking screenshots.
|
|
90
|
+
*/
|
|
91
|
+
setScreenshotMainContentSelector: (selector: string) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Get the main content selector for the page for when taking screenshots.
|
|
94
|
+
*/
|
|
95
|
+
getScreenshotMainContentSelector: () => string;
|
|
96
|
+
/**
|
|
97
|
+
* Set the strategy for getting synthesize URLs.
|
|
98
|
+
*/
|
|
99
|
+
setSynthesizeUrlStrategy: (strategy: () => string) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Set the strategy for getting transcribe URLs.
|
|
102
|
+
*/
|
|
103
|
+
setTranscribeUrlStrategy: (strategy: () => string) => void;
|
|
104
|
+
} = {};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Makes a structured response request to the LLM API.
|
|
108
|
+
*/
|
|
109
|
+
export function getStructuredResponse<T extends TSchema>(
|
|
110
|
+
args: GetStructuredResponseOptions<T>
|
|
111
|
+
): Promise<Static<T>>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Makes a chat completion request to the LLM API. Can be used both with streaming and non-streaming responses.
|
|
115
|
+
* For streaming responses, provides callbacks for handling chunks and errors.
|
|
116
|
+
*/
|
|
117
|
+
export function getChatCompletion(
|
|
118
|
+
args: GetChatCompletionOptions
|
|
119
|
+
): Promise<ChatData[]>;
|
|
120
|
+
|
|
121
|
+
export * from "./sharedTypes";
|
package/react.js
ADDED
package/sharedTypes.ts
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
// Don't import from the generated folder, as it is removed when we build and publish the package.
|
|
2
|
+
|
|
3
|
+
import type { Static, TSchema, Type } from "@sinclair/typebox";
|
|
4
|
+
|
|
5
|
+
export type Maybe<T> = T | undefined;
|
|
6
|
+
export interface Scalars {
|
|
7
|
+
ID: string;
|
|
8
|
+
String: string;
|
|
9
|
+
Boolean: boolean;
|
|
10
|
+
Int: number;
|
|
11
|
+
Float: number;
|
|
12
|
+
Upload: any;
|
|
13
|
+
/** All dates within this schema are ISO-8601 strings without time or timezone. */
|
|
14
|
+
Date: any;
|
|
15
|
+
/** All date-times are supposed to be are ISO-8601 strings, but we do accept input in other formats. That behavior will change and we will replace Date and DateTime's behavior with that of StrictDate. */
|
|
16
|
+
DateTime: any;
|
|
17
|
+
/** A datetime input and output type only accepts ISO-8601 dates. */
|
|
18
|
+
StrictDateTimeInput: string;
|
|
19
|
+
/** General-use Upload input scalar */
|
|
20
|
+
FileToUpload: any;
|
|
21
|
+
/** General-use scalar to use for fields of JSON data. See https://www.npmjs.com/package/graphql-type-json for more information. */
|
|
22
|
+
JSONObject: any;
|
|
23
|
+
/** Represents a rich text document in its native ProseMirror document format. This is a JSON object with a specific schema. Use a TipTap editor instance from the @kazoohr/richtext-components package to interact with this format. */
|
|
24
|
+
RichTextDocument: any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type AiAssistantConversationMessageRole =
|
|
28
|
+
/** A message that was sent by the LLM */
|
|
29
|
+
| "MODEL"
|
|
30
|
+
/** A message comes from tool calling. */
|
|
31
|
+
| "TOOL"
|
|
32
|
+
/** A message that was sent by the user. */
|
|
33
|
+
| "USER";
|
|
34
|
+
|
|
35
|
+
export interface Message {
|
|
36
|
+
__typename?: "Message";
|
|
37
|
+
/** The unique identifier of the message. */
|
|
38
|
+
id: Scalars["ID"];
|
|
39
|
+
/** The role of the message. */
|
|
40
|
+
role: AiAssistantConversationMessageRole;
|
|
41
|
+
/** The text content of the message. */
|
|
42
|
+
messageText: Scalars["String"];
|
|
43
|
+
/** The conversation that the message belongs to. */
|
|
44
|
+
conversationId: Scalars["String"];
|
|
45
|
+
/** Optional metadata for the message to store such as toolNames etc */
|
|
46
|
+
metadata?: Maybe<Scalars["JSONObject"]>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type AiAssistantSuggestedPromptsProps = {
|
|
50
|
+
suggestedPrompts: Record<string, AiAssistantSuggestedPrompt[]>;
|
|
51
|
+
onSelect: (prompt: AiAssistantSuggestedPrompt) => void | Promise<void>;
|
|
52
|
+
includeGlobalPrompts?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type AiAssistantSuggestedPrompt = {
|
|
56
|
+
title: string;
|
|
57
|
+
fullPrompt?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type SupportedTextModel = "small" | "medium" | "large";
|
|
61
|
+
|
|
62
|
+
export type ChatItem = {
|
|
63
|
+
role: "user" | "model" | "tool";
|
|
64
|
+
parts: ChatData[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type ToolDeclaration<TParams extends TSchema = TSchema> = {
|
|
68
|
+
name: string;
|
|
69
|
+
description: string;
|
|
70
|
+
parameters?: any;
|
|
71
|
+
chatItemMatches?: (chatItem: {
|
|
72
|
+
role: "user" | "model" | "tool";
|
|
73
|
+
parts: ChatData[];
|
|
74
|
+
}) => boolean;
|
|
75
|
+
fulfill: (result: Static<TParams>) => Promise<string | ChatDataFile>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Debug info added during the execution of the AI assistant.
|
|
80
|
+
*/
|
|
81
|
+
export type DebugInfo = {
|
|
82
|
+
time: Date;
|
|
83
|
+
message: string;
|
|
84
|
+
data?: any;
|
|
85
|
+
level: "info" | "error" | "warn";
|
|
86
|
+
}[];
|
|
87
|
+
|
|
88
|
+
export type PropRefs = {
|
|
89
|
+
onAfterLlmCall?: (messages: Omit<Message, "__typename">[]) => void;
|
|
90
|
+
onBeforeLlmCall?: () => void;
|
|
91
|
+
onError?: (error: Error) => void;
|
|
92
|
+
onChunkAdded?: () => void;
|
|
93
|
+
tools?: ToolDeclaration[];
|
|
94
|
+
model?: SupportedTextModel;
|
|
95
|
+
/**
|
|
96
|
+
* The current state of the chat.
|
|
97
|
+
*
|
|
98
|
+
* When to access this:
|
|
99
|
+
* - When you're in async handler functions
|
|
100
|
+
* - When you're in callbacks
|
|
101
|
+
*
|
|
102
|
+
* When NOT to access this:
|
|
103
|
+
* - When you're in anywhere in the UI state rendering path
|
|
104
|
+
*
|
|
105
|
+
* If you're rendering the UI, use the `messages` prop, please. This is for
|
|
106
|
+
* AI assistant state, which often requires up-to-date state for making
|
|
107
|
+
* updates.
|
|
108
|
+
*/
|
|
109
|
+
messages: ChatStateTree;
|
|
110
|
+
temperature?: number;
|
|
111
|
+
isMounted: boolean;
|
|
112
|
+
systemInstruction?: () => string | Promise<string>;
|
|
113
|
+
getConversationById: (
|
|
114
|
+
conversationId: string
|
|
115
|
+
) => ChatStateTree[string] | undefined;
|
|
116
|
+
getFollowUpSuggestions?: GetFollowUpSuggestions;
|
|
117
|
+
setFollowUpSuggestionsByConversationId: React.Dispatch<
|
|
118
|
+
React.SetStateAction<Record<string, FollowUpSuggestion[]>>
|
|
119
|
+
>;
|
|
120
|
+
handleSendUserMessage: (args: {
|
|
121
|
+
conversationId?: string;
|
|
122
|
+
messageText: string;
|
|
123
|
+
}) => Promise<void>;
|
|
124
|
+
setPrompt: (
|
|
125
|
+
conversationId: string | undefined,
|
|
126
|
+
prompt: string | ((prev: string) => string)
|
|
127
|
+
) => void;
|
|
128
|
+
onSelectedConversationChange?: (
|
|
129
|
+
conversationId: string | undefined,
|
|
130
|
+
messages: ChatStateTree
|
|
131
|
+
) => void;
|
|
132
|
+
selectedConversationId: string | undefined;
|
|
133
|
+
onSelectedConversationLoaded?: (
|
|
134
|
+
/**
|
|
135
|
+
* The conversation that loaded.
|
|
136
|
+
*/
|
|
137
|
+
conversationId: string | undefined,
|
|
138
|
+
/**
|
|
139
|
+
* The conversation that is currently selected
|
|
140
|
+
*/
|
|
141
|
+
selectedConversationId: string | undefined,
|
|
142
|
+
messages: ChatStateTree
|
|
143
|
+
) => void;
|
|
144
|
+
sendMessages: (conversationId: string) => Promise<boolean>;
|
|
145
|
+
setMessages: React.Dispatch<React.SetStateAction<ChatStateTree>>;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type ChatData =
|
|
149
|
+
| ChatDataText
|
|
150
|
+
| ChatDataToolCall
|
|
151
|
+
| ChatDataToolResult
|
|
152
|
+
| ChatDataFile;
|
|
153
|
+
|
|
154
|
+
export type ChatDataText = { type: "text"; text: string };
|
|
155
|
+
|
|
156
|
+
export type ChatDataFile = {
|
|
157
|
+
type: "file";
|
|
158
|
+
toolName: string;
|
|
159
|
+
fileUri: string;
|
|
160
|
+
mimeType: string;
|
|
161
|
+
args?: unknown;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export type ChatDataToolCall = {
|
|
165
|
+
type: "toolCall";
|
|
166
|
+
toolName: string;
|
|
167
|
+
args: Record<string, unknown>;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export type ChatDataToolResult = {
|
|
171
|
+
type: "toolResult";
|
|
172
|
+
toolName: string;
|
|
173
|
+
args?: unknown;
|
|
174
|
+
result: any;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export type ChatHistoryItem = {
|
|
178
|
+
title: string;
|
|
179
|
+
messages: any[];
|
|
180
|
+
[key: string]: any;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export type GetFollowUpSuggestions = (args: {
|
|
184
|
+
conversation: ChatStateTree[string];
|
|
185
|
+
}) => Promise<AiAssistantSuggestedPrompt[]>;
|
|
186
|
+
|
|
187
|
+
export type ChatHistory = Record<string, ChatHistoryItem[]>;
|
|
188
|
+
|
|
189
|
+
export type ChatSizes = "half" | "full";
|
|
190
|
+
|
|
191
|
+
export type AiAssistantControls = {
|
|
192
|
+
/**
|
|
193
|
+
* Set the prompt to use for the AI assistant.
|
|
194
|
+
* @param prompt - The prompt to set.
|
|
195
|
+
* @param submit - Whether to submit the prompt to the AI assistant once the new prompt is set.
|
|
196
|
+
*/
|
|
197
|
+
setPrompt?: (prompt: string, submit?: boolean) => void;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type AiAssistantProps = {
|
|
201
|
+
/**
|
|
202
|
+
* The title to display in the window. Default: "WorkTango AI Assistant".
|
|
203
|
+
*/
|
|
204
|
+
windowTitle?: React.ReactNode;
|
|
205
|
+
/**
|
|
206
|
+
* The full suite of tools to use for the AI assistant.
|
|
207
|
+
*/
|
|
208
|
+
tools?: ToolDeclaration<any>[];
|
|
209
|
+
/**
|
|
210
|
+
* Whether to enable debug mode. Default: false.
|
|
211
|
+
*/
|
|
212
|
+
enableDebug?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Whether to enable voice features. Default: false.
|
|
215
|
+
*/
|
|
216
|
+
enableVoiceFeatures?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The function to call when the AI assistant is closed.
|
|
219
|
+
*/
|
|
220
|
+
onClose: () => void;
|
|
221
|
+
/**
|
|
222
|
+
* This is a callback event that is invoked when the user sends a message.
|
|
223
|
+
*/
|
|
224
|
+
onSendMessage?: (message: string) => void;
|
|
225
|
+
/**
|
|
226
|
+
* Whether to show a close button in the chat window. Default: true.
|
|
227
|
+
*/
|
|
228
|
+
hasCloseButton?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* The zero state to display when the chat window is empty.
|
|
231
|
+
*/
|
|
232
|
+
chatWindowZeroState?: React.ReactNode;
|
|
233
|
+
/**
|
|
234
|
+
* Whether to show a button to toggle the chat size. Default: true.
|
|
235
|
+
*/
|
|
236
|
+
hasToggleChatSizeButton?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* If true, the chat history (list of past conversations) will be shown, by default
|
|
239
|
+
*/
|
|
240
|
+
hasChatHistory?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* The initial width of the chat window. Default: "default".
|
|
243
|
+
*/
|
|
244
|
+
startingWidth?: ChatSizes;
|
|
245
|
+
/**
|
|
246
|
+
* The system instruction to use for the AI assistant.
|
|
247
|
+
*/
|
|
248
|
+
systemInstruction?: () => string | Promise<string>;
|
|
249
|
+
/**
|
|
250
|
+
* The initial prompt to use for the AI assistant.
|
|
251
|
+
*/
|
|
252
|
+
initialPrompt?: string;
|
|
253
|
+
/**
|
|
254
|
+
* A ref to the controls object for the AI assistant. Used to allow some form
|
|
255
|
+
* of control over the AI assistant from outside the component, allowing things
|
|
256
|
+
* like recommended prompts to be set from outside the component.
|
|
257
|
+
*/
|
|
258
|
+
controls?: React.MutableRefObject<AiAssistantControls>;
|
|
259
|
+
/**
|
|
260
|
+
* Whether to show the chat history by default. Default: true.
|
|
261
|
+
*/
|
|
262
|
+
chatHistoryShownByDefault?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Otherwise, if there's a chat history, we start with the latest history, so
|
|
265
|
+
* the user can continue the previous conversation.
|
|
266
|
+
*/
|
|
267
|
+
startWithNewChat?: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* The minimum number of characters that must be entered before the user can
|
|
270
|
+
* submit a message. Default: 5.
|
|
271
|
+
*/
|
|
272
|
+
minimumCharacterCount?: number;
|
|
273
|
+
/**
|
|
274
|
+
* The ID of the conversation to start with. If not provided, a new conversation will be created.
|
|
275
|
+
*/
|
|
276
|
+
initialConversationId?: string;
|
|
277
|
+
/**
|
|
278
|
+
* Returns a set of follow-up suggestions for the given conversation.
|
|
279
|
+
*/
|
|
280
|
+
getFollowUpSuggestions?: GetFollowUpSuggestions;
|
|
281
|
+
/**
|
|
282
|
+
* Invoked with a raw string of the chat (in plain text) to get a possible title
|
|
283
|
+
*/
|
|
284
|
+
getChatTitle?: (chat: string) => Promise<string>;
|
|
285
|
+
/**
|
|
286
|
+
* The model size to use for the AI assistant. Default: "large".
|
|
287
|
+
*/
|
|
288
|
+
model?: SupportedTextModel;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export type ChatStateTree = Record<
|
|
292
|
+
string,
|
|
293
|
+
{
|
|
294
|
+
id: string;
|
|
295
|
+
title: string;
|
|
296
|
+
isUpdatingTitle?: boolean;
|
|
297
|
+
updatedAt: Date;
|
|
298
|
+
isLoading: boolean;
|
|
299
|
+
messages: Omit<Message, "__typename">[];
|
|
300
|
+
}
|
|
301
|
+
>;
|
|
302
|
+
|
|
303
|
+
// ChatItem augmented with some UI stuff
|
|
304
|
+
export type AugmentedChatItem = ChatItem & {
|
|
305
|
+
id?: string;
|
|
306
|
+
timestamp?: Date;
|
|
307
|
+
isPending?: boolean;
|
|
308
|
+
filterFromApiCalls?: boolean;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* If { loading: true }, a small loader will be shown. You can use this show a
|
|
313
|
+
* loading state in any place of the UI.
|
|
314
|
+
*/
|
|
315
|
+
export type FollowUpSuggestion =
|
|
316
|
+
| { type: "loading"; id?: string }
|
|
317
|
+
| {
|
|
318
|
+
type?: "suggestion";
|
|
319
|
+
/**
|
|
320
|
+
* A unique identifier for the follow-up suggestion. This will be used to keep user-level state for dismissed items.
|
|
321
|
+
*/
|
|
322
|
+
id: string;
|
|
323
|
+
/**
|
|
324
|
+
* The title of the follow-up suggestion. This will be displayed in the UI as a pill button, so keep it short.
|
|
325
|
+
*/
|
|
326
|
+
title: string;
|
|
327
|
+
/**
|
|
328
|
+
* The function to call when the follow-up suggestion is clicked.
|
|
329
|
+
*/
|
|
330
|
+
onClick: () => void;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export interface Conversation {
|
|
334
|
+
id: string;
|
|
335
|
+
title: string;
|
|
336
|
+
updatedAt?: Date;
|
|
337
|
+
messages: {
|
|
338
|
+
conversationId: string;
|
|
339
|
+
id: string;
|
|
340
|
+
messageText: string;
|
|
341
|
+
role: string;
|
|
342
|
+
}[];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export type GetStructuredResponseOptions<T extends TSchema> = {
|
|
346
|
+
model?: SupportedTextModel | undefined;
|
|
347
|
+
temperature?: number | undefined;
|
|
348
|
+
prompt: string;
|
|
349
|
+
schema: (t: typeof Type) => T;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
export type GetChatCompletionOptions = {
|
|
353
|
+
model?: SupportedTextModel | undefined;
|
|
354
|
+
temperature?: number | undefined;
|
|
355
|
+
systemInstruction?: string | undefined;
|
|
356
|
+
stream?: boolean;
|
|
357
|
+
messages: ChatItem[];
|
|
358
|
+
tools?: ToolDeclaration[] | undefined;
|
|
359
|
+
onChunk?: (chunk: ChatData) => void;
|
|
360
|
+
onError?: (error: Error) => void;
|
|
361
|
+
onComplete?: () => void;
|
|
362
|
+
};
|