@activepieces/piece-chat-aid 0.0.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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-chat-aid
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-chat-aid` to build the library.
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@activepieces/piece-chat-aid",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@sinclair/typebox": "0.34.11",
9
+ "axios": "1.8.3",
10
+ "axios-retry": "4.4.1",
11
+ "deepmerge-ts": "7.1.0",
12
+ "form-data": "4.0.4",
13
+ "mime-types": "2.1.35",
14
+ "nanoid": "3.3.8",
15
+ "semver": "7.6.0",
16
+ "socket.io-client": "4.8.1",
17
+ "tslib": "^2.3.0",
18
+ "zod": "3.25.76",
19
+ "@activepieces/pieces-common": "0.8.1",
20
+ "@activepieces/pieces-framework": "0.20.2",
21
+ "@activepieces/shared": "0.25.2"
22
+ },
23
+ "resolutions": {
24
+ "rollup": "npm:@rollup/wasm-node"
25
+ }
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const chatAid: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chatAid = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("./lib/common/auth");
7
+ const add_custom_sources_1 = require("./lib/actions/add-custom-sources");
8
+ const ask_questions_1 = require("./lib/actions/ask-questions");
9
+ const get_custom_source_by_id_1 = require("./lib/actions/get-custom-source-by-id");
10
+ const shared_1 = require("@activepieces/shared");
11
+ const pieces_common_1 = require("@activepieces/pieces-common");
12
+ const client_1 = require("./lib/common/client");
13
+ exports.chatAid = (0, pieces_framework_1.createPiece)({
14
+ displayName: 'Chat Aid',
15
+ description: 'AI-powered assistant for your knowledge base.',
16
+ auth: auth_1.ChatAidAuth,
17
+ minimumSupportedRelease: '0.36.1',
18
+ logoUrl: 'https://cdn.activepieces.com/pieces/chat-aid.png',
19
+ categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
20
+ authors: ['sanket-a11y'],
21
+ actions: [
22
+ add_custom_sources_1.addCustomSources,
23
+ ask_questions_1.askQuestions,
24
+ get_custom_source_by_id_1.getCustomSourceById,
25
+ (0, pieces_common_1.createCustomApiCallAction)({
26
+ baseUrl: () => client_1.BASE_URL,
27
+ auth: auth_1.ChatAidAuth,
28
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
29
+ return ({
30
+ Authorization: `${auth}`,
31
+ });
32
+ }),
33
+ }),
34
+ ],
35
+ triggers: [],
36
+ });
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/chat-aid/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,4CAAgD;AAChD,yEAAoE;AACpE,+DAA2D;AAC3D,mFAA4E;AAC5E,iDAAqD;AACrD,+DAAwE;AACxE,gDAA+C;AAElC,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,+CAA+C;IAC5D,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,kDAAkD;IAC3D,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,OAAO,EAAE;QACP,qCAAgB;QAChB,4BAAY;QACZ,6CAAmB;QACnB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAQ;YACvB,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,GAAG,IAAI,EAAE;iBACzB,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const addCustomSources: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ files: import("@activepieces/pieces-framework").ArrayProperty<true>;
3
+ teamId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ }>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addCustomSources = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const client_1 = require("../common/client");
9
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
10
+ exports.addCustomSources = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.ChatAidAuth,
12
+ name: 'addCustomSources',
13
+ displayName: 'Add Custom Sources',
14
+ description: 'Upload one or more files as custom sources for training',
15
+ props: {
16
+ files: pieces_framework_1.Property.Array({
17
+ displayName: 'Files',
18
+ description: 'One or more files to upload (PDF, Word, Text, Markdown, HTML, Excel, CSV, PowerPoint, PNG, JPEG, GIF)',
19
+ properties: {
20
+ file: pieces_framework_1.Property.File({
21
+ displayName: 'File',
22
+ description: 'File to upload',
23
+ required: true,
24
+ }),
25
+ },
26
+ required: true,
27
+ }),
28
+ teamId: pieces_framework_1.Property.ShortText({
29
+ displayName: 'Team ID',
30
+ description: 'Optional team ID (defaults to org-wide)',
31
+ required: false,
32
+ }),
33
+ },
34
+ run(context) {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ const files = context.propsValue.files || [];
37
+ const teamId = context.propsValue.teamId;
38
+ if (!files || files.length === 0) {
39
+ throw new Error('At least one file is required');
40
+ }
41
+ const formData = new form_data_1.default();
42
+ files.forEach((fileObj) => {
43
+ const file = fileObj.file;
44
+ const fileBuffer = file.base64 ? Buffer.from(file.base64, 'base64') : file.data;
45
+ formData.append('files', fileBuffer, file.filename);
46
+ });
47
+ let path = '/external/sources/custom';
48
+ if (teamId) {
49
+ path += `?teamId=${encodeURIComponent(teamId)}`;
50
+ }
51
+ const request = {
52
+ method: pieces_common_1.HttpMethod.POST,
53
+ url: `${client_1.BASE_URL}${path}`,
54
+ headers: {
55
+ Authorization: context.auth,
56
+ 'Content-Type': 'multipart/form-data',
57
+ },
58
+ body: formData,
59
+ };
60
+ const response = yield pieces_common_1.httpClient.sendRequest(request);
61
+ return response.body;
62
+ });
63
+ },
64
+ });
65
+ //# sourceMappingURL=add-custom-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-custom-sources.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chat-aid/src/lib/actions/add-custom-sources.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,yCAA6C;AAC7C,+DAAkF;AAClF,6CAA4C;AAC5C,kEAAiC;AAMpB,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,yDAAyD;IACtE,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACpB,WAAW,EAAE,OAAO;YACpB,WAAW,EACT,uGAAuG;YACzG,UAAU,EAAE;gBACV,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;oBAClB,WAAW,EAAE,MAAM;oBACnB,WAAW,EAAE,gBAAgB;oBAC7B,QAAQ,EAAE,IA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c;oBACrC,cAAc,EAAE,qBAAqB;iBACtC;gBACD,IAAI,EAAE,QAAQ;aACf,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAQ,OAAO,CAAC,CAAC;YAE9D,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const askQuestions: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ prompt: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
+ parentTs: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ messageTs: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ }>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.askQuestions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const client_1 = require("../common/client");
9
+ exports.askQuestions = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.ChatAidAuth,
11
+ name: 'askQuestions',
12
+ displayName: 'Ask Questions',
13
+ description: 'Query your Chat Aid knowledge base and receive AI-generated answers with source citations',
14
+ props: {
15
+ prompt: pieces_framework_1.Property.LongText({
16
+ displayName: 'Question',
17
+ description: 'The question to ask the knowledge base',
18
+ required: true,
19
+ }),
20
+ parentTs: pieces_framework_1.Property.ShortText({
21
+ displayName: 'Parent Timestamp',
22
+ description: 'Optional Unix timestamp for conversation threading. Use the same value for related questions in a conversation.',
23
+ required: false,
24
+ }),
25
+ messageTs: pieces_framework_1.Property.ShortText({
26
+ displayName: 'Message Timestamp',
27
+ description: 'Optional Unix timestamp of current message. Use with parentTs for follow-up questions in a conversation.',
28
+ required: false,
29
+ }),
30
+ },
31
+ run(context) {
32
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
+ const { prompt, parentTs, messageTs } = context.propsValue;
34
+ const requestBody = {
35
+ prompt,
36
+ };
37
+ if (parentTs) {
38
+ requestBody['parentTs'] = parentTs;
39
+ }
40
+ if (messageTs) {
41
+ requestBody['messageTs'] = messageTs;
42
+ }
43
+ const submitResponse = yield (0, client_1.makeRequest)(context.auth, pieces_common_1.HttpMethod.POST, '/chat/completions/custom', requestBody);
44
+ if (!submitResponse.ok) {
45
+ throw new Error(`Failed to submit question: ${submitResponse}`);
46
+ }
47
+ const { promptId, pollEndpoint, timeInterval } = submitResponse;
48
+ const start = Date.now();
49
+ const timeoutMs = 120 * 1000;
50
+ const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
51
+ while (Date.now() - start < timeoutMs) {
52
+ yield sleep(timeInterval * 1000);
53
+ const pollResponse = yield pieces_common_1.httpClient.sendRequest({
54
+ method: pieces_common_1.HttpMethod.GET,
55
+ url: pollEndpoint,
56
+ headers: {
57
+ Authorization: context.auth,
58
+ },
59
+ });
60
+ const pollData = pollResponse.body;
61
+ if (!pollData.ok) {
62
+ throw new Error(`Poll request failed: ${pollData}`);
63
+ }
64
+ const { canPoll } = pollData.data;
65
+ if (!canPoll) {
66
+ return {
67
+ pollData,
68
+ };
69
+ }
70
+ }
71
+ throw new Error('Polling timeout: Answer not ready within 60 seconds');
72
+ });
73
+ },
74
+ });
75
+ //# sourceMappingURL=ask-questions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-questions.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chat-aid/src/lib/actions/ask-questions.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA6C;AAC7C,+DAAqE;AACrE,6CAA+C;AAElC,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,eAAe;IAC5B,WAAW,EACT,2FAA2F;IAC7F,KAAK,EAAE;Q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AAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;YAExE,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,SAAS,EAAE,CAAC;gBACtC,MAAM,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;gBAEjC,MAAM,YAAY,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBAChD,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,YAAY;oBACjB,OAAO,EAAE;wBACP,aAAa,EAAE,OAAO,CAAC,IAAc;qBACtC;iBACF,CAAC,CAAC;gBAEH,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC;gBAEnC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;gBACtD,CAAC;gBAED,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC;gBAElC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,OAAO;wBACL,QAAQ;qBACT,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const getCustomSourceById: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ sourceId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ }>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomSourceById = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const client_1 = require("../common/client");
9
+ exports.getCustomSourceById = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.ChatAidAuth,
11
+ name: 'getCustomSourceById',
12
+ displayName: 'Get Custom Source by ID',
13
+ description: 'Retrieve single source details by ID',
14
+ props: {
15
+ sourceId: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Source ID',
17
+ description: 'The ID of the custom source to retrieve',
18
+ required: true,
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ const sourceId = context.propsValue.sourceId;
24
+ const response = yield (0, client_1.makeRequest)(context.auth, pieces_common_1.HttpMethod.GET, `/external/sources/custom/${encodeURIComponent(sourceId)}`, undefined);
25
+ return response;
26
+ });
27
+ },
28
+ });
29
+ //# sourceMappingURL=get-custom-source-by-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-custom-source-by-id.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chat-aid/src/lib/actions/get-custom-source-by-id.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA6C;AAC7C,+DAAyD;AACzD,6CAA+C;AAElC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,yBAAyB;IACtC,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,QAAkB,CAAC;YAEvD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,OAAO,CAAC,IAAc,EACtB,0BAAU,CAAC,GAAG,EACd,4BAA4B,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAC1D,SAAS,CACV,CAAC;YAEF,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const ChatAidAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatAidAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const client_1 = require("./client");
8
+ exports.ChatAidAuth = pieces_framework_1.PieceAuth.SecretText({
9
+ displayName: 'Chat Aid API Key',
10
+ description: `
11
+ Generate your API key in the dashboard: https://app.chataid.com/settings/automations
12
+ `,
13
+ required: true,
14
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
15
+ if (auth) {
16
+ try {
17
+ yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, '/external/sources/custom', {});
18
+ return {
19
+ valid: true,
20
+ };
21
+ }
22
+ catch (error) {
23
+ return {
24
+ valid: false,
25
+ error: 'Invalid Api Key',
26
+ };
27
+ }
28
+ }
29
+ return {
30
+ valid: false,
31
+ error: 'Invalid Api Key',
32
+ };
33
+ }),
34
+ });
35
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chat-aid/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAqE;AAErE,+DAAyD;AACzD,qCAAuC;AAE1B,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE;;CAEd;IACC,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAA,oBAAW,EACf,IAAc,EACd,0BAAU,CAAC,GAAG,EACd,0BAA0B,EAC1B,EAAE,CACH,CAAC;gBACF,OAAO;oBACL,KAAK,EAAE,IAAI;iBACZ,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,iBAAiB;iBACzB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,iBAAiB;SACzB,CAAC;IACJ,CAAC,CAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { HttpMethod } from '@activepieces/pieces-common';
2
+ export declare const BASE_URL = "https://api.chataid.com";
3
+ export declare function makeRequest(api_key: string, method: HttpMethod, path: string, body?: unknown): Promise<any>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_URL = void 0;
4
+ exports.makeRequest = makeRequest;
5
+ const tslib_1 = require("tslib");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ exports.BASE_URL = `https://api.chataid.com`;
8
+ function makeRequest(api_key, method, path, body) {
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ try {
11
+ const headers = {
12
+ Authorization: `${api_key}`,
13
+ };
14
+ if (body && !(body instanceof FormData)) {
15
+ headers['Content-Type'] = 'application/json';
16
+ }
17
+ const response = yield pieces_common_1.httpClient.sendRequest({
18
+ method,
19
+ url: `${exports.BASE_URL}${path}`,
20
+ headers,
21
+ body,
22
+ });
23
+ return response.body;
24
+ }
25
+ catch (error) {
26
+ const errorMessage = error instanceof Error ? error.message : String(error);
27
+ throw new Error(`Unexpected error: ${errorMessage}`);
28
+ }
29
+ });
30
+ }
31
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chat-aid/src/lib/common/client.ts"],"names":[],"mappings":";;;AAIA,kCA0BC;;AA9BD,+DAAqE;AAExD,QAAA,QAAQ,GAAG,yBAAyB,CAAC;AAElD,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAkB,EAClB,IAAY,EACZ,IAAc;;QAEd,IAAI,CAAC;YACH,MAAM,OAAO,GAA2B;gBACtC,aAAa,EAAE,GAAG,OAAO,EAAE;aAC5B,CAAC;YAEF,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,YAAY,QAAQ,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;YAC/C,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM;gBACN,GAAG,EAAE,GAAG,gBAAQ,GAAG,IAAI,EAAE;gBACzB,OAAO;gBACP,IAAI;aACL,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CAAA"}