@xapp/stentor-service-generative-ai 1.83.0 → 1.89.0

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 (82) hide show
  1. package/package.json +6 -6
  2. package/lib/AWSBedrockService.d.ts +0 -67
  3. package/lib/AWSBedrockService.js +0 -133
  4. package/lib/AWSBedrockService.js.map +0 -1
  5. package/lib/ClaudeService.d.ts +0 -77
  6. package/lib/ClaudeService.js +0 -142
  7. package/lib/ClaudeService.js.map +0 -1
  8. package/lib/FallbackLLMService.d.ts +0 -46
  9. package/lib/FallbackLLMService.js +0 -83
  10. package/lib/FallbackLLMService.js.map +0 -1
  11. package/lib/GenerativeAIService.d.ts +0 -40
  12. package/lib/GenerativeAIService.js +0 -108
  13. package/lib/GenerativeAIService.js.map +0 -1
  14. package/lib/OpenAIService.d.ts +0 -33
  15. package/lib/OpenAIService.js +0 -76
  16. package/lib/OpenAIService.js.map +0 -1
  17. package/lib/http/HTTPService.d.ts +0 -18
  18. package/lib/http/HTTPService.js +0 -4
  19. package/lib/http/HTTPService.js.map +0 -1
  20. package/lib/http/NodeHTTPService.d.ts +0 -8
  21. package/lib/http/NodeHTTPService.js +0 -70
  22. package/lib/http/NodeHTTPService.js.map +0 -1
  23. package/lib/http/index.d.ts +0 -3
  24. package/lib/http/index.js +0 -20
  25. package/lib/http/index.js.map +0 -1
  26. package/lib/index.d.ts +0 -10
  27. package/lib/index.js +0 -27
  28. package/lib/index.js.map +0 -1
  29. package/lib/models/ChatSummary.d.ts +0 -10
  30. package/lib/models/ChatSummary.js +0 -4
  31. package/lib/models/ChatSummary.js.map +0 -1
  32. package/lib/models/EmailAnalysis.d.ts +0 -73
  33. package/lib/models/EmailAnalysis.js +0 -4
  34. package/lib/models/EmailAnalysis.js.map +0 -1
  35. package/lib/models/GenerativeAIService.d.ts +0 -55
  36. package/lib/models/GenerativeAIService.js +0 -3
  37. package/lib/models/GenerativeAIService.js.map +0 -1
  38. package/lib/models/LLMService.d.ts +0 -24
  39. package/lib/models/LLMService.js +0 -4
  40. package/lib/models/LLMService.js.map +0 -1
  41. package/lib/models/LeadAnalysis.d.ts +0 -105
  42. package/lib/models/LeadAnalysis.js +0 -4
  43. package/lib/models/LeadAnalysis.js.map +0 -1
  44. package/lib/models/Prompt.d.ts +0 -37
  45. package/lib/models/Prompt.js +0 -8
  46. package/lib/models/Prompt.js.map +0 -1
  47. package/lib/models/PromptGenerator.d.ts +0 -6
  48. package/lib/models/PromptGenerator.js +0 -4
  49. package/lib/models/PromptGenerator.js.map +0 -1
  50. package/lib/models/ResponseParser.d.ts +0 -5
  51. package/lib/models/ResponseParser.js +0 -4
  52. package/lib/models/ResponseParser.js.map +0 -1
  53. package/lib/models/WebsiteAnalysis.d.ts +0 -48
  54. package/lib/models/WebsiteAnalysis.js +0 -4
  55. package/lib/models/WebsiteAnalysis.js.map +0 -1
  56. package/lib/models/errors.d.ts +0 -7
  57. package/lib/models/errors.js +0 -15
  58. package/lib/models/errors.js.map +0 -1
  59. package/lib/models/index.d.ts +0 -9
  60. package/lib/models/index.js +0 -26
  61. package/lib/models/index.js.map +0 -1
  62. package/lib/prompts/AnalyzeEmail.d.ts +0 -36
  63. package/lib/prompts/AnalyzeEmail.js +0 -385
  64. package/lib/prompts/AnalyzeEmail.js.map +0 -1
  65. package/lib/prompts/AnalyzeLead.d.ts +0 -59
  66. package/lib/prompts/AnalyzeLead.js +0 -396
  67. package/lib/prompts/AnalyzeLead.js.map +0 -1
  68. package/lib/prompts/AnalyzeWebsite.d.ts +0 -10
  69. package/lib/prompts/AnalyzeWebsite.js +0 -176
  70. package/lib/prompts/AnalyzeWebsite.js.map +0 -1
  71. package/lib/prompts/ChatSummary.d.ts +0 -62
  72. package/lib/prompts/ChatSummary.js +0 -67
  73. package/lib/prompts/ChatSummary.js.map +0 -1
  74. package/lib/prompts/index.d.ts +0 -4
  75. package/lib/prompts/index.js +0 -21
  76. package/lib/prompts/index.js.map +0 -1
  77. package/lib/utils/extractJSON.d.ts +0 -10
  78. package/lib/utils/extractJSON.js +0 -17
  79. package/lib/utils/extractJSON.js.map +0 -1
  80. package/lib/utils/standardizeTerms.d.ts +0 -15
  81. package/lib/utils/standardizeTerms.js +0 -53
  82. package/lib/utils/standardizeTerms.js.map +0 -1
@@ -1,105 +0,0 @@
1
- /*! Copyright (c) 2024, XAPP AI */
2
- /**
3
- * Categorizes the nature of the customer's interaction with the business.
4
- *
5
- * See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
6
- *
7
- * @remarks
8
- * - BILLING_ISSUE: Concerns about charges, refunds, pricing discrepancies, or payments
9
- * - CANCELLATION: Asking to cancel an appointment, service, subscription, or contract
10
- * - COMPLAINT: Dissatisfaction with business, product, or service quality (excluding billing/scheduling)
11
- * - COMPLIMENT: Positive feedback about the business, staff, or product
12
- * - CONTACT_REQUEST: Request for contact without actionable details (use only for vague "call me" requests)
13
- * - EMPLOYMENT_INQUIRY: Questions about jobs, openings, hiring, or how to apply
14
- * - MISSED_APPOINTMENT: Reporting a no-show, missed call/visit, or confirmation confusion
15
- * - QUESTION: General inquiry about business/services without requesting service or quote
16
- * - QUOTE_REQUEST: Requesting a price, cost, estimate, quote, or ballpark figure
17
- * - RESCHEDULE_REQUEST: Asking to change date/time of existing appointment or scheduled service
18
- * - SERVICE_REQUEST: Requesting service, repair, installation, maintenance, inspection, or scheduling
19
- * - SPAM: Unsolicited, irrelevant, deceptive, or low-value content
20
- * - TEST: Test message, placeholder text, or internal system check
21
- * - OTHER: Content cannot be reasonably determined
22
- */
23
- export type ContactType = "BILLING_ISSUE" | "CANCELLATION" | "COMPLAINT" | "COMPLIMENT" | "CONTACT_REQUEST" | "EMPLOYMENT_INQUIRY" | "MISSED_APPOINTMENT" | "QUESTION" | "QUOTE_REQUEST" | "RESCHEDULE_REQUEST" | "SERVICE_REQUEST" | "SPAM" | "TEST" | "OTHER";
24
- /**
25
- * Describes what kind of work the customer is requesting (high-level categorization).
26
- *
27
- * See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
28
- *
29
- * @remarks
30
- * - CLEANING: Cleaning work (house, windows, ducts, carpet, gutters)
31
- * - CONSULTATION: Requesting advice or guidance only, not execution
32
- * - INSPECTION: Evaluation or assessment to check a condition or issue
33
- * - INSTALLATION: New installation of a product or system
34
- * - MAINTENANCE: Routine or recurring upkeep
35
- * - REFINISH: Refinishing surfaces (floors, cabinets, painting, staining)
36
- * - REMODEL: Renovating or improving an existing structure or space
37
- * - REPAIR: Fixing an existing product or system
38
- * - SUPPORT: Help with an issue or appointment related to service but not the work itself
39
- * - TRANSPORT: Moving, hauling, or delivering items
40
- * - TREATMENT: Active service to resolve or prevent an issue (pest control, mold remediation, etc.)
41
- * - OTHER: Work that doesn't fit the above categories
42
- */
43
- export type ServiceType = "CLEANING" | "CONSULTATION" | "INSPECTION" | "INSTALLATION" | "MAINTENANCE" | "REFINISH" | "REMODEL" | "REPAIR" | "SUPPORT" | "TRANSPORT" | "TREATMENT" | "OTHER";
44
- /**
45
- * Identifies the specific trade or industry relevant to the request.
46
- *
47
- * See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
48
- *
49
- * @remarks
50
- * Some categories have aliases (e.g., electrical/electrician, gutter/gutters) for flexibility.
51
- */
52
- export type JobType = "appliance_repair" | "blinds" | "carpentry" | "cleaning" | "construction" | "contractor" | "drywall" | "electrical" | "electrician" | "fencing" | "flooring" | "gutter" | "gutters" | "handyman" | "house_cleaning" | "hvac" | "junk_removal" | "landscaping" | "landscaper" | "legal_services" | "masonry" | "mold_remediation" | "moving" | "painting" | "painter" | "pest_control" | "plumbing" | "pressure_washing" | "remodeling" | "restoration" | "roofing" | "roofer" | "siding" | "tree_services" | "wildlife_control" | "window_cleaning" | "window_installation" | "windows_doors" | "other";
53
- /**
54
- * Indicates how quickly the issue should be addressed based on the nature of the problem.
55
- *
56
- * See LEAD_ANALYSIS_GUIDE.md for detailed definitions and examples.
57
- *
58
- * @remarks
59
- * - LOW: Not time-sensitive, can be addressed at business's convenience
60
- * - MEDIUM: Not time-sensitive, can be addressed within a couple of weeks
61
- * - HIGH: Not life-threatening but should be addressed within a few days (may lead to property damage)
62
- * - URGENT: Life-threatening or causing property damage, should be addressed ASAP (potentially same day)
63
- * - NOT_SPECIFIED: Urgency could not be determined from available information
64
- *
65
- * Note: Urgency is determined by the nature of the issue itself, not solely by customer's stated urgency.
66
- */
67
- export type UrgencyType = "LOW" | "MEDIUM" | "HIGH" | "URGENT" | "NOT_SPECIFIED";
68
- export interface LeadAnalysis {
69
- /**
70
- * The version of the analysis that was performed. This changes when major changes are made to the analysis process. It can be used to determine if the analysis is up to date and needs to be re-run.
71
- */
72
- analysisVersion?: string;
73
- /**
74
- * A description of the kind of message that was sent to the user.
75
- */
76
- contactType?: ContactType;
77
- /**
78
- * A description of the kind of service that the user is requesting.
79
- */
80
- serviceType?: ServiceType;
81
- /**
82
- * The type of job that the user is requesting.
83
- */
84
- jobType?: JobType;
85
- /**
86
- * The urgency of the message if it is necessary.
87
- */
88
- urgency?: UrgencyType;
89
- /**
90
- * Whether the lead is considered high value meaning it can generate significant revenue for the customer.
91
- */
92
- highValueLead?: boolean;
93
- /**
94
- * A summary of the conversation and the lead analysis.
95
- */
96
- summary?: string;
97
- /**
98
- * A 2 - 3 word concise summary of the lead, main use for this is in a word cloud and on the lead list item dashboard.
99
- */
100
- conciseSummary?: string;
101
- /**
102
- * An analysis of how the LLM came to its conclusion.
103
- */
104
- analysis?: string;
105
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- /*! Copyright (c) 2024, XAPP AI */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- //# sourceMappingURL=LeadAnalysis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LeadAnalysis.js","sourceRoot":"","sources":["../../src/models/LeadAnalysis.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -1,37 +0,0 @@
1
- /*! Copyright (c) 2024, XAPP AI */
2
- export type PromptType = "completions";
3
- export interface Prompt {
4
- type: PromptType;
5
- }
6
- export type CompletionContentMessageType = "text" | "json_object";
7
- export interface CompletionResponseFormatText {
8
- type: "text";
9
- }
10
- export interface CompletionResponseFormatJSONObject {
11
- type: "json_object";
12
- }
13
- export interface CompletionResponseFormatJSONSchema {
14
- type: "json_schema";
15
- /**
16
- * JSON schema for the response following the JSON schema specification
17
- */
18
- json_schema: object;
19
- }
20
- export type CompletionResponseFormat = CompletionResponseFormatText | CompletionResponseFormatJSONObject | CompletionResponseFormatJSONSchema;
21
- export type CompletionContentMessage = string;
22
- export interface CompletionMessage {
23
- role: string;
24
- content: CompletionContentMessage;
25
- }
26
- export interface CompletionPrompt extends Prompt {
27
- type: "completions";
28
- messages: CompletionMessage[];
29
- model: string;
30
- response_format: CompletionResponseFormat;
31
- max_tokens: number;
32
- temperature: number;
33
- top_p: number;
34
- frequency_penalty: number;
35
- presence_penalty: number;
36
- }
37
- export declare function isCompletionPrompt(prompt: Prompt): prompt is CompletionPrompt;
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../src/models/Prompt.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AA+ClC,gDAEC;AAFD,SAAgB,kBAAkB,CAAC,MAAc;IAC7C,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,aAAa,CAAC;AAC1C,CAAC"}
@@ -1,6 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- /*! Copyright (c) 2024, XAPP AI */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- //# sourceMappingURL=PromptGenerator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PromptGenerator.js","sourceRoot":"","sources":["../../src/models/PromptGenerator.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -1,5 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- /*! Copyright (c) 2024, XAPP AI */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- //# sourceMappingURL=ResponseParser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ResponseParser.js","sourceRoot":"","sources":["../../src/models/ResponseParser.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -1,48 +0,0 @@
1
- /*! Copyright (c) 2025, XAPP AI */
2
- export type BusinessCategory = "business-coaching" | "consulting" | "contact-capture" | "financial-services" | "home-services-cleaning" | "home-services-contractors" | "home-services-outdoor" | "insurance" | "legal-services" | "life-coaching" | "radio" | "real-estate" | "technology-services" | "travel";
3
- export interface BusinessAddress {
4
- /**
5
- * The full address as it was found on the website.
6
- */
7
- formatted?: string;
8
- /**
9
- * Street address, street number and street name.
10
- */
11
- streetAddress?: string;
12
- /**
13
- * The postal (zip) code
14
- */
15
- postalCode?: string;
16
- /**
17
- * City, Town or Locality. This is typically from the "city" of "city", "state"
18
- */
19
- locality?: string;
20
- /**
21
- * Typically the state.
22
- */
23
- region?: string;
24
- /**
25
- * The country
26
- */
27
- country?: string;
28
- }
29
- export interface WebsiteAnalysis {
30
- organization_name?: string;
31
- parked_domain?: boolean;
32
- email?: {
33
- email: string;
34
- purpose?: string;
35
- }[];
36
- phone_numbers?: {
37
- number: string;
38
- purpose?: string;
39
- }[];
40
- addresses?: BusinessAddress[];
41
- services?: string[];
42
- calls_to_action?: {
43
- url?: string;
44
- callToAction: string;
45
- }[];
46
- description?: string;
47
- industry_category?: BusinessCategory;
48
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- /*! Copyright (c) 2025, XAPP AI */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- //# sourceMappingURL=WebsiteAnalysis.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebsiteAnalysis.js","sourceRoot":"","sources":["../../src/models/WebsiteAnalysis.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -1,7 +0,0 @@
1
- /*! Copyright (c) 2024, XAPP AI */
2
- /**
3
- * Error thrown when an unknown prompt type is provided to an LLM service
4
- */
5
- export declare class InvalidPromptTypeError extends Error {
6
- constructor(type: string);
7
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- /*! Copyright (c) 2024, XAPP AI */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InvalidPromptTypeError = void 0;
5
- /**
6
- * Error thrown when an unknown prompt type is provided to an LLM service
7
- */
8
- class InvalidPromptTypeError extends Error {
9
- constructor(type) {
10
- super(`Unknown prompt type: ${type}`);
11
- this.name = "InvalidPromptTypeError";
12
- }
13
- }
14
- exports.InvalidPromptTypeError = InvalidPromptTypeError;
15
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/models/errors.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AAElC;;GAEG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAC7C,YAAY,IAAY;QACpB,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACzC,CAAC;CACJ;AALD,wDAKC"}
@@ -1,9 +0,0 @@
1
- /*! Copyright (c) 2026, XAPP AI */
2
- export * from "./EmailAnalysis";
3
- export * from "./errors";
4
- export * from './GenerativeAIService';
5
- export * from './LeadAnalysis';
6
- export * from "./LLMService";
7
- export * from "./Prompt";
8
- export * from "./PromptGenerator";
9
- export * from "./ResponseParser";
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*! Copyright (c) 2026, 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("./EmailAnalysis"), exports);
19
- __exportStar(require("./errors"), exports);
20
- __exportStar(require("./GenerativeAIService"), exports);
21
- __exportStar(require("./LeadAnalysis"), exports);
22
- __exportStar(require("./LLMService"), exports);
23
- __exportStar(require("./Prompt"), exports);
24
- __exportStar(require("./PromptGenerator"), exports);
25
- __exportStar(require("./ResponseParser"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;;;;;AAElC,kDAAgC;AAChC,2CAAyB;AACzB,wDAAsC;AACtC,iDAA+B;AAC/B,+CAA6B;AAC7B,2CAAyB;AACzB,oDAAkC;AAClC,mDAAiC"}
@@ -1,36 +0,0 @@
1
- /*! Copyright (c) 2026, XAPP AI */
2
- import type { CompletionPrompt, PromptGenerator, ResponseParser } from "../models";
3
- import type { EmailAnalysisInput, EmailLeadAnalysis } from "../models/EmailAnalysis";
4
- export declare const ANALYZE_EMAIL_VERSION = "1.1.0";
5
- export interface AnalyzeEmailProps {
6
- businessDescription?: string;
7
- highValueLeadDescription?: string;
8
- email: EmailAnalysisInput;
9
- }
10
- export type AnalyzeEmailLLMOverrides = Partial<Pick<CompletionPrompt, "model" | "max_tokens" | "temperature" | "top_p" | "frequency_penalty" | "presence_penalty">>;
11
- /**
12
- * Converts an email (with optional thread history) into the messages array for an LLM completion prompt.
13
- *
14
- * Thread history messages are prepended in order, with customer messages as "user" and
15
- * agent/FSM-CRM messages as "assistant". The current email is always the final "user" message.
16
- *
17
- * @param system - The system instruction message.
18
- * @param email - The email to analyze.
19
- */
20
- export declare function emailThreadToMessages(system: string, email: EmailAnalysisInput): {
21
- role: "system" | "user" | "assistant";
22
- content: string;
23
- }[];
24
- /**
25
- * Generates a prompt that can be used in an LLM to analyze an inbound email for a business.
26
- *
27
- * Combines lead classification (contactType, serviceType, jobType, urgency) with contact
28
- * information extraction in a single LLM call, returning an `EmailLeadAnalysis`.
29
- *
30
- * Handles:
31
- * - Direct customer emails
32
- * - FSM/CRM lead notification emails (Jobber, ServiceTitan, Housecall Pro, etc.)
33
- * - Email threads with prior conversation history
34
- */
35
- export declare const generateAnalyzeEmail: PromptGenerator<AnalyzeEmailProps, AnalyzeEmailLLMOverrides, CompletionPrompt>;
36
- export declare const analyzeEmailResponseParse: ResponseParser<EmailLeadAnalysis>;