@xapp/stentor-service-generative-ai 1.62.39

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 (42) hide show
  1. package/LICENSE.md +176 -0
  2. package/README.md +21 -0
  3. package/lib/GenerativeAIService.d.ts +17 -0
  4. package/lib/GenerativeAIService.js +36 -0
  5. package/lib/GenerativeAIService.js.map +1 -0
  6. package/lib/OpenAIService.d.ts +21 -0
  7. package/lib/OpenAIService.js +60 -0
  8. package/lib/OpenAIService.js.map +1 -0
  9. package/lib/http/HTTPService.d.ts +14 -0
  10. package/lib/http/HTTPService.js +4 -0
  11. package/lib/http/HTTPService.js.map +1 -0
  12. package/lib/http/NodeHTTPService.d.ts +9 -0
  13. package/lib/http/NodeHTTPService.js +62 -0
  14. package/lib/http/NodeHTTPService.js.map +1 -0
  15. package/lib/index.d.ts +2 -0
  16. package/lib/index.js +19 -0
  17. package/lib/index.js.map +1 -0
  18. package/lib/models/GenerativeAIService.d.ts +10 -0
  19. package/lib/models/GenerativeAIService.js +3 -0
  20. package/lib/models/GenerativeAIService.js.map +1 -0
  21. package/lib/models/LLMService.d.ts +15 -0
  22. package/lib/models/LLMService.js +4 -0
  23. package/lib/models/LLMService.js.map +1 -0
  24. package/lib/models/LeadAnalysis.d.ts +37 -0
  25. package/lib/models/LeadAnalysis.js +4 -0
  26. package/lib/models/LeadAnalysis.js.map +1 -0
  27. package/lib/models/Prompt.d.ts +28 -0
  28. package/lib/models/Prompt.js +8 -0
  29. package/lib/models/Prompt.js.map +1 -0
  30. package/lib/models/PromptGenerator.d.ts +6 -0
  31. package/lib/models/PromptGenerator.js +4 -0
  32. package/lib/models/PromptGenerator.js.map +1 -0
  33. package/lib/models/ResponseParser.d.ts +5 -0
  34. package/lib/models/ResponseParser.js +4 -0
  35. package/lib/models/ResponseParser.js.map +1 -0
  36. package/lib/models/index.d.ts +7 -0
  37. package/lib/models/index.js +24 -0
  38. package/lib/models/index.js.map +1 -0
  39. package/lib/prompts/AnalyzeLead.d.ts +40 -0
  40. package/lib/prompts/AnalyzeLead.js +88 -0
  41. package/lib/prompts/AnalyzeLead.js.map +1 -0
  42. package/package.json +42 -0
package/LICENSE.md ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ ## @xapp/stentor-service-jobber
2
+
3
+ Implementation with Jobber
4
+
5
+ ### Required Environment Variables
6
+
7
+ - JOBBER_BaseUrl=https://api.getjobber.com/api/graphql
8
+ - JOBBER_API_VERSION=[More Info](https://developer.getjobber.com/docs/using_jobbers_api/api_versioning/)
9
+
10
+
11
+ ### Sample .env File
12
+
13
+ You can create a local .env file for testing.
14
+ ```bash
15
+ JOBBER_AUTH_TOKEN=
16
+ ```
17
+
18
+ Grab your token from the GraphQL interface for Jobber, make a call and inspect the API call to get the `Authorization` header.
19
+
20
+ ### Documentation
21
+ - [Jobber Developer Docs](https://developer.getjobber.com/docs/)
@@ -0,0 +1,17 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import type { ExternalLead } from "stentor-models";
3
+ import type { GenerativeAIService as IGenerativeAIService, LeadAnalysis, LLMService } from "./models";
4
+ export interface AnalyzeLeadOptions {
5
+ businessDescription?: string;
6
+ highValueLeadDescription?: string;
7
+ }
8
+ export declare class GenerativeAIService implements IGenerativeAIService {
9
+ private readonly llmService;
10
+ constructor(llmService: LLMService);
11
+ /**
12
+ * Can take in an external lead and help summarize and classify.
13
+ *
14
+ * @param lead
15
+ */
16
+ analyzeLead(lead: ExternalLead, options?: AnalyzeLeadOptions): Promise<LeadAnalysis>;
17
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GenerativeAIService = void 0;
13
+ const AnalyzeLead_1 = require("./prompts/AnalyzeLead");
14
+ class GenerativeAIService {
15
+ constructor(llmService) {
16
+ this.llmService = llmService;
17
+ }
18
+ /**
19
+ * Can take in an external lead and help summarize and classify.
20
+ *
21
+ * @param lead
22
+ */
23
+ analyzeLead(lead, options) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const prompt = (0, AnalyzeLead_1.generateAnalyzeLead)({
26
+ businessDescription: (options === null || options === void 0 ? void 0 : options.businessDescription) || "",
27
+ highValueLeadDescription: (options === null || options === void 0 ? void 0 : options.highValueLeadDescription) || "",
28
+ transcript: lead.transcript
29
+ });
30
+ const llmResponse = yield this.llmService.generate(prompt);
31
+ return (0, AnalyzeLead_1.analyzeLeadResponseParse)(llmResponse.text);
32
+ });
33
+ }
34
+ }
35
+ exports.GenerativeAIService = GenerativeAIService;
36
+ //# sourceMappingURL=GenerativeAIService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenerativeAIService.js","sourceRoot":"","sources":["../src/GenerativeAIService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,uDAAsF;AAOtF,MAAa,mBAAmB;IAI5B,YAAY,UAAsB;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACG,WAAW,CAAC,IAAkB,EAAE,OAA4B;;YAC9D,MAAM,MAAM,GAAG,IAAA,iCAAmB,EAAC;gBAC/B,mBAAmB,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,KAAI,EAAE;gBACvD,wBAAwB,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,wBAAwB,KAAI,EAAE;gBACjE,UAAU,EAAE,IAAI,CAAC,UAAU;aAC9B,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAE3D,OAAO,IAAA,sCAAwB,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;KAAA;CACJ;AAxBD,kDAwBC"}
@@ -0,0 +1,21 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import type { LLMService, LLMServiceResponse, Prompt } from "./models";
3
+ import type { HTTPService } from "./http/HTTPService";
4
+ export type APIKeyGetter = () => string | Promise<string>;
5
+ export interface OpenAIServiceProps {
6
+ keyGetter: APIKeyGetter;
7
+ openAIUrl: string;
8
+ httpService: Pick<HTTPService, "post">;
9
+ }
10
+ export declare class InvalidPromptTypeError extends Error {
11
+ constructor(type: string);
12
+ }
13
+ export declare class OpenAIService implements LLMService {
14
+ private readonly keyGetter;
15
+ private readonly openAIUrl;
16
+ private readonly httpService;
17
+ constructor(props: OpenAIServiceProps);
18
+ generate(prompt: Prompt): Promise<LLMServiceResponse>;
19
+ completions(prompt: Prompt): Promise<LLMServiceResponse>;
20
+ private post;
21
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.OpenAIService = exports.InvalidPromptTypeError = void 0;
14
+ class InvalidPromptTypeError extends Error {
15
+ constructor(type) {
16
+ super(`Unknown prompt type: ${type}`);
17
+ this.name = "InvalidPromptTypeError";
18
+ }
19
+ }
20
+ exports.InvalidPromptTypeError = InvalidPromptTypeError;
21
+ class OpenAIService {
22
+ constructor(props) {
23
+ this.keyGetter = props.keyGetter;
24
+ this.openAIUrl = props.openAIUrl;
25
+ this.httpService = props.httpService;
26
+ }
27
+ generate(prompt) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const { type } = prompt;
30
+ if (type === "completions") {
31
+ return this.completions(prompt);
32
+ }
33
+ throw new InvalidPromptTypeError(type);
34
+ });
35
+ }
36
+ completions(prompt) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const response = yield this.post({
39
+ path: "v1/chat/completions",
40
+ body: Object.assign({}, prompt)
41
+ });
42
+ return { text: response.body };
43
+ });
44
+ }
45
+ post(props) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const apiKey = yield this.keyGetter();
48
+ const response = yield this.httpService.post({
49
+ url: `${this.openAIUrl}/${props.path}`,
50
+ body: props.body,
51
+ headers: {
52
+ "Authorization": `Bearer ${apiKey}`
53
+ }
54
+ });
55
+ return response;
56
+ });
57
+ }
58
+ }
59
+ exports.OpenAIService = OpenAIService;
60
+ //# sourceMappingURL=OpenAIService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenAIService.js","sourceRoot":"","sources":["../src/OpenAIService.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;AAalC,MAAa,sBAAuB,SAAQ,KAAK;IAE7C,YAAY,IAAY;QACpB,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACzC,CAAC;CACJ;AAND,wDAMC;AAED,MAAa,aAAa;IAMtB,YAAY,KAAyB;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACzC,CAAC;IAEK,QAAQ,CAAC,MAAc;;YACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;YACxB,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACpC,CAAC;YACD,MAAM,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;KAAA;IAEK,WAAW,CAAC,MAAc;;YAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;gBAC7B,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,oBACG,MAAM,CACZ;aACJ,CAAC,CAAC;YACH,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,CAAC;KAAA;IAEa,IAAI,CAAC,KAAiD;;YAChE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;gBACzC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE;gBACtC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE;oBACL,eAAe,EAAE,UAAU,MAAM,EAAE;iBACtC;aACJ,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ;AAzCD,sCAyCC"}
@@ -0,0 +1,14 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ export type Headers = Record<string, string | number>;
3
+ export interface PostProps {
4
+ url: string | URL;
5
+ body: string | object;
6
+ headers?: Headers;
7
+ }
8
+ export interface Response {
9
+ status: number;
10
+ body: string;
11
+ }
12
+ export interface HTTPService {
13
+ post(props: PostProps): Promise<Response>;
14
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=HTTPService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTTPService.js","sourceRoot":"","sources":["../../src/http/HTTPService.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -0,0 +1,9 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import { HTTPService, PostProps, Response } from "./HTTPService";
3
+ export declare class NodeHttpService implements HTTPService {
4
+ post(props: PostProps): Promise<Response>;
5
+ }
6
+ export declare class InvalidHTTPUrlError extends Error {
7
+ name: string;
8
+ constructor(url: string);
9
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InvalidHTTPUrlError = exports.NodeHttpService = void 0;
7
+ const http_1 = __importDefault(require("http"));
8
+ const https_1 = __importDefault(require("https"));
9
+ class NodeHttpService {
10
+ post(props) {
11
+ const url = new URL(props.url);
12
+ const http = retrieveHttp(url);
13
+ const bodyIsObject = typeof props.body !== "string";
14
+ const postData = typeof props.body === "string" ? props.body : JSON.stringify(props.body);
15
+ const baseHeaders = {
16
+ "Content-Length": Buffer.byteLength(postData)
17
+ };
18
+ if (bodyIsObject) {
19
+ baseHeaders["Content-Type"] = "application/json";
20
+ }
21
+ return new Promise((resolve, reject) => {
22
+ const request = http.request({
23
+ host: url.host,
24
+ port: url.toString().startsWith("https") ? 443 : 80,
25
+ path: url.pathname,
26
+ method: "POST",
27
+ headers: Object.assign(Object.assign({}, props.headers), baseHeaders)
28
+ }, (response) => {
29
+ let body = "";
30
+ response.setEncoding("utf-8");
31
+ response.on("data", (chunk) => body += chunk);
32
+ response.on("end", () => resolve({ body, status: response.statusCode }));
33
+ response.on("error", (err) => reject(err));
34
+ });
35
+ request.write(postData);
36
+ request.end();
37
+ });
38
+ }
39
+ }
40
+ exports.NodeHttpService = NodeHttpService;
41
+ class InvalidHTTPUrlError extends Error {
42
+ constructor(url) {
43
+ super(`Unable to decipher URL: ${url}`);
44
+ this.name = InvalidHTTPUrlError.name;
45
+ }
46
+ }
47
+ exports.InvalidHTTPUrlError = InvalidHTTPUrlError;
48
+ /**
49
+ * Retrieves the proper HTTP node module basd on the url.
50
+ * @param url
51
+ * @returns
52
+ */
53
+ function retrieveHttp(url) {
54
+ if (url.toString().startsWith("https")) {
55
+ return https_1.default;
56
+ }
57
+ else if (url.toString().startsWith("http")) {
58
+ return http_1.default;
59
+ }
60
+ throw new InvalidHTTPUrlError(url.toString());
61
+ }
62
+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1,19 @@
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
+ /*! Copyright (c) 2024, XAPP AI */
18
+ __exportStar(require("./GenerativeAIService"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,kCAAkC;AAClC,wDAAsC"}
@@ -0,0 +1,10 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import { ExternalLead } from "stentor-models";
3
+ import { LeadAnalysis } from "./LeadAnalysis";
4
+ export interface GenerativeAIService {
5
+ /**
6
+ * Analyze a lead to find summary
7
+ * @param lead
8
+ */
9
+ analyzeLead(lead: ExternalLead): Promise<LeadAnalysis>;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=GenerativeAIService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenerativeAIService.js","sourceRoot":"","sources":["../../src/models/GenerativeAIService.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import { Prompt } from "./Prompt";
3
+ export interface LLMServiceResponse {
4
+ text: string;
5
+ }
6
+ /**
7
+ * A service that can generate text based on a prompt sent to an LLM Service
8
+ */
9
+ export interface LLMService {
10
+ /**
11
+ * Generate a response based on the input
12
+ * @param input
13
+ */
14
+ generate(prompt: Prompt): Promise<LLMServiceResponse>;
15
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=LLMService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLMService.js","sourceRoot":"","sources":["../../src/models/LLMService.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -0,0 +1,37 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ /**
3
+ * QUESTION - The user is asking a question about the product or service.
4
+ * SPAM - The user is sending spam messages.
5
+ * COMPLAINT - The user is complaining about the product or service.
6
+ * CONTACT_REQUEST - The user is requesting contact from the company.
7
+ * COMPLIMENT - The user is giving a compliment about the product or service.
8
+ * EMPLOYMENT_INQUIRY - The user is inquiring about employment opportunities at the business.
9
+ * OTHER - The message does not fit in to any of the other categories presented.
10
+ */
11
+ export type ContactType = "QUESTION" | "SPAM" | "COMPLAINT" | "CONTACT_REQUEST" | "COMPLIMENT" | "EMPLOYMENT_INQUIRY" | "OTHER";
12
+ /**
13
+ * LOW - The message is not urgent and can be responded to at the convenience of the user.
14
+ * MEDIUM - The message is somewhat urgent and should be responded to within a few hours.
15
+ * HIGH - The message is urgent and should be responded to within an hour.
16
+ * URGENT - The message is extremely urgent and should be responded to immediately.
17
+ * NOT_SPECIFIED - The urgency of the message is not relavant.
18
+ */
19
+ export type UrgencyType = "LOW" | "MEDIUM" | "HIGH" | "URGENT" | "NOT_SPECIFIED";
20
+ export interface LeadAnalysis {
21
+ /**
22
+ * A description of the kind of message that was sent to the user.
23
+ */
24
+ contactType?: ContactType;
25
+ /**
26
+ * The urgency of the message if it is necessary.
27
+ */
28
+ urgency?: UrgencyType;
29
+ /**
30
+ * Whether the lead is considered high value meaning it can generate significant revenue for the customer.
31
+ */
32
+ highValueLead?: boolean;
33
+ /**
34
+ * A summary of the conversation and the lead analysis.
35
+ */
36
+ summary?: string;
37
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=LeadAnalysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LeadAnalysis.js","sourceRoot":"","sources":["../../src/models/LeadAnalysis.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -0,0 +1,28 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ export type PromptType = "completions";
3
+ export interface Prompt {
4
+ type: PromptType;
5
+ }
6
+ export type CompletionContentMessageType = "text";
7
+ export interface CompletionContentMessage {
8
+ text: string;
9
+ type: CompletionContentMessageType;
10
+ }
11
+ export interface CompletionMessage {
12
+ role: string;
13
+ content: CompletionContentMessage;
14
+ }
15
+ export interface CompletionPrompt extends Prompt {
16
+ type: "completions";
17
+ messages: CompletionMessage[];
18
+ model: string;
19
+ response_format: {
20
+ type: "text";
21
+ };
22
+ max_tokens: number;
23
+ temperature: number;
24
+ top_p: number;
25
+ frequency_penalty: number;
26
+ presence_penalty: number;
27
+ }
28
+ export declare function isCompletionPrompt(prompt: Prompt): prompt is CompletionPrompt;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isCompletionPrompt = isCompletionPrompt;
5
+ function isCompletionPrompt(prompt) {
6
+ return (prompt === null || prompt === void 0 ? void 0 : prompt.type) === "completions";
7
+ }
8
+ //# sourceMappingURL=Prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../src/models/Prompt.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAkClC,gDAEC;AAFD,SAAgB,kBAAkB,CAAC,MAAc;IAC7C,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,aAAa,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import { Prompt } from "./Prompt";
3
+ /**
4
+ * A generator that can return a prompt that is intended to be sent to an LLM Service.
5
+ */
6
+ export type PromptGenerator<PromptOptions, LLMOverrides extends object = {}, ReturnPrompt = Prompt> = (opts: PromptOptions, overrides?: LLMOverrides) => ReturnPrompt;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=PromptGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptGenerator.js","sourceRoot":"","sources":["../../src/models/PromptGenerator.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -0,0 +1,5 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ /**
3
+ * A parser that can parse a response from a service
4
+ */
5
+ export type ResponseParser<T> = (response: string) => T;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=ResponseParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResponseParser.js","sourceRoot":"","sources":["../../src/models/ResponseParser.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -0,0 +1,7 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ export * from './LeadAnalysis';
3
+ export * from './GenerativeAIService';
4
+ export * from "./ResponseParser";
5
+ export * from "./LLMService";
6
+ export * from "./PromptGenerator";
7
+ export * from "./Prompt";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./LeadAnalysis"), exports);
19
+ __exportStar(require("./GenerativeAIService"), exports);
20
+ __exportStar(require("./ResponseParser"), exports);
21
+ __exportStar(require("./LLMService"), exports);
22
+ __exportStar(require("./PromptGenerator"), exports);
23
+ __exportStar(require("./Prompt"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;;;;;AAElC,iDAA+B;AAC/B,wDAAsC;AACtC,mDAAiC;AACjC,+CAA6B;AAC7B,oDAAkC;AAClC,2CAAyB"}
@@ -0,0 +1,40 @@
1
+ /*! Copyright (c) 2024, XAPP AI */
2
+ import type { ExternalLead } from "stentor-models";
3
+ import type { ResponseParser } from "../models/ResponseParser";
4
+ import type { CompletionPrompt, LeadAnalysis, PromptGenerator } from "../models";
5
+ export interface TranscriptMessage {
6
+ text: string;
7
+ speaker: string;
8
+ }
9
+ export interface AnalyzeLeadProps {
10
+ businessDescription: string;
11
+ highValueLeadDescription: string | undefined;
12
+ transcript: ExternalLead["transcript"];
13
+ }
14
+ /**
15
+ * Converts a transcript from an external lead in to a series of strings.
16
+ *
17
+ * @param transcript
18
+ * @returns
19
+ */
20
+ export declare function translateTranscript(transcript: ExternalLead["transcript"]): string[];
21
+ /**
22
+ * Generates a default High Value Lead Description if the business does not provide one.
23
+ *
24
+ * @param app
25
+ * @returns
26
+ */
27
+ export declare function getHighValueLeadDescription(highValueLeadDescription: string | undefined): string;
28
+ export type AnalyzeLeadsLLMOverrides = Partial<Pick<CompletionPrompt, "model" | "max_tokens" | "temperature" | "top_p" | "frequency_penalty" | "presence_penalty">>;
29
+ /**
30
+ * Generates a prompt that can be used in an LLM to analyze a lead for a business.
31
+ *
32
+ * The expected output format from the LLM will be:
33
+ *
34
+ * <Contact Type>::<Urgency Type>::<High Value Lead (true/false)>::<Summary>
35
+ *
36
+ * @param lead - The lead to analyze with the business description and other options to customize the prompt.
37
+ * @returns
38
+ */
39
+ export declare const generateAnalyzeLead: PromptGenerator<AnalyzeLeadProps, AnalyzeLeadsLLMOverrides, CompletionPrompt>;
40
+ export declare const analyzeLeadResponseParse: ResponseParser<LeadAnalysis>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2024, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.analyzeLeadResponseParse = exports.generateAnalyzeLead = void 0;
5
+ exports.translateTranscript = translateTranscript;
6
+ exports.getHighValueLeadDescription = getHighValueLeadDescription;
7
+ function getName(profile) {
8
+ // Sorting these based on priority.
9
+ return profile.name || profile.email || profile.phone || "Unknown";
10
+ }
11
+ /**
12
+ * Converts a transcript from an external lead in to a series of strings.
13
+ *
14
+ * @param transcript
15
+ * @returns
16
+ */
17
+ function translateTranscript(transcript) {
18
+ return transcript.map(({ from, message }) => `${getName(from)}: ${message}`);
19
+ }
20
+ /**
21
+ * Generates a default High Value Lead Description if the business does not provide one.
22
+ *
23
+ * @param app
24
+ * @returns
25
+ */
26
+ function getHighValueLeadDescription(highValueLeadDescription) {
27
+ return highValueLeadDescription || "There is no description so this should always be false.";
28
+ }
29
+ /**
30
+ * Generates a prompt that can be used in an LLM to analyze a lead for a business.
31
+ *
32
+ * The expected output format from the LLM will be:
33
+ *
34
+ * <Contact Type>::<Urgency Type>::<High Value Lead (true/false)>::<Summary>
35
+ *
36
+ * @param lead - The lead to analyze with the business description and other options to customize the prompt.
37
+ * @returns
38
+ */
39
+ const generateAnalyzeLead = ({ businessDescription, highValueLeadDescription, transcript }, overrides) => {
40
+ return Object.assign(Object.assign({ model: "gpt-4o-mini", max_tokens: 256, frequency_penalty: 0, temperature: 1, top_p: 1, presence_penalty: 0 }, overrides), { response_format: {
41
+ type: "text"
42
+ }, type: "completions", messages: [{
43
+ role: "system",
44
+ content: {
45
+ type: "text",
46
+ text: `You are a business owner with the following business description\n\n` +
47
+ `${businessDescription}\n\n` +
48
+ `Based on the user's conversation, analyze the lead in relation to the type of business described.\n` +
49
+ `First determine if the if the lead is a question, spam, complaint, contact request, compliment, or employment inquiry.\n` +
50
+ `The definitions of each are as follows:\n` +
51
+ `QUESTION: The lead is asking a question about the business or product.\n` +
52
+ `SPAM: The lead is sending unsolicited messages.\n` +
53
+ `COMPLAINT: The lead is expressing dissatisfaction with the business or product.\n` +
54
+ `CONTACT_REQUEST: The lead is requesting contact from a person at the business.\n` +
55
+ `COMPLIMENT: The lead is expressing satisfaction with the business or product.\n` +
56
+ `EMPLOYMENT_INQUIRY: The lead is inquiring about employment opportunities.\n` +
57
+ `OTHER: The content of the lead could not be determined by the transcript provided.\n\n` +
58
+ `Next, determine the urgency of the lead. The urgency can be LOW, MEDIUM, HIGH, or URGENT which are defined as the following:\n` +
59
+ `LOW: The lead is not time sensitive and can be addressed at the convenience of the business.\n` +
60
+ `MEDIUM: The lead is somewhat time sensitive and should be addressed within a few days.\n` +
61
+ `HIGH: The lead is time sensitive and should be addressed within 24 hours.\n` +
62
+ `URGENT: The lead is extremely time sensitive and should be addressed immediately.\n` +
63
+ `NOT_SPECIFIED: The urgency of the lead could not be determined by the content of the transcript.\n\n` +
64
+ `Next, determine if the lead is a high value lead. A high value lead is defined as "${getHighValueLeadDescription(highValueLeadDescription)}".\n\n` +
65
+ `Finally, provide a summary of the conversation and the lead analysis. The summary should not exceed 500 characters.\n\n` +
66
+ `Please provide your analysis in the following format:\n\n` +
67
+ `<Contact Type>::<Urgency Type>::<High Value Lead (true/false)>::<Summary>`
68
+ }
69
+ }, {
70
+ role: "user",
71
+ content: {
72
+ type: "text",
73
+ text: translateTranscript(transcript).join("\n")
74
+ }
75
+ }] });
76
+ };
77
+ exports.generateAnalyzeLead = generateAnalyzeLead;
78
+ const analyzeLeadResponseParse = (response) => {
79
+ const [contactType, urgencyType, highValueLead, summary] = response.split("::");
80
+ return {
81
+ contactType: (contactType === null || contactType === void 0 ? void 0 : contactType.toUpperCase()) || "OTHER",
82
+ urgencyType: (urgencyType === null || urgencyType === void 0 ? void 0 : urgencyType.toUpperCase()) || "NOT_SPECIFIED",
83
+ highValueLead: (highValueLead === null || highValueLead === void 0 ? void 0 : highValueLead.toLocaleLowerCase()) === "true",
84
+ summary: summary || "A summary could not be generated."
85
+ };
86
+ };
87
+ exports.analyzeLeadResponseParse = analyzeLeadResponseParse;
88
+ //# sourceMappingURL=AnalyzeLead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyzeLead.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeLead.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AA4BlC,kDAEC;AAQD,kEAEC;AAvBD,SAAS,OAAO,CAAC,OAA8C;IAC3D,mCAAmC;IACnC,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,SAAS,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,UAAsC;IACtE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;AACjF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B,CAA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AC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhF,OAAO;QACH,WAAW,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAiC,KAAI,OAAO;QACjF,WAAW,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAA6B,KAAI,eAAe;QACrF,aAAa,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,iBAAiB,EAAE,MAAK,MAAM;QAC5D,OAAO,EAAE,OAAO,IAAI,mCAAmC;KAC1D,CAAC;AACN,CAAC,CAAA;AATY,QAAA,wBAAwB,4BASpC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@xapp/stentor-service-generative-ai",
3
+ "license": "Apache-2.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "version": "1.62.39",
8
+ "description": "Generative AI Service",
9
+ "types": "lib/index",
10
+ "main": "lib/index",
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "engines": {
15
+ "node": "^10 || ^12 || ^14 || ^16 || ^18 || ^20"
16
+ },
17
+ "devDependencies": {
18
+ "@types/chai": "4.3.17",
19
+ "@types/lodash": "4.17.7",
20
+ "@xapp/config": "0.2.3",
21
+ "chai": "4.5.0",
22
+ "dotenv": "16.4.5",
23
+ "mocha": "10.7.3",
24
+ "stentor-logger": "1.59.104",
25
+ "stentor-models": "1.59.102",
26
+ "stentor-service-fetch": "1.59.103",
27
+ "ts-node": "10.9.2",
28
+ "typescript": "5.5.4"
29
+ },
30
+ "peerDependencies": {
31
+ "stentor-logger": "1.x",
32
+ "stentor-models": "1.x",
33
+ "stentor-service-fetch": "1.x"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -d true -p .",
37
+ "clean": "rm -rf ./lib/*",
38
+ "test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\"",
39
+ "local": "npm run test"
40
+ },
41
+ "gitHead": "5c6af120ebb1a6023c8f31eeec7e1c85c9b91a54"
42
+ }