@xapp/stentor-service-generative-ai 1.76.20 → 1.77.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.
@@ -17,7 +17,7 @@ export interface AWSBedrockServiceProps {
17
17
  /**
18
18
  * The Bedrock model ID or inference profile to use.
19
19
  * Newer models require inference profiles (prefixed with region, e.g., "us.").
20
- * @default "us.anthropic.claude-3-5-haiku-20241022-v1:0"
20
+ * @default "us.anthropic.claude-haiku-4-5-20251001-v1:0"
21
21
  */
22
22
  modelId?: string;
23
23
  }
@@ -34,7 +34,7 @@ class AWSBedrockService {
34
34
  region: props.region || "us-east-1",
35
35
  credentials: props.credentials,
36
36
  });
37
- this.modelId = props.modelId || "us.anthropic.claude-3-5-haiku-20241022-v1:0";
37
+ this.modelId = props.modelId || "us.anthropic.claude-haiku-4-5-20251001-v1:0";
38
38
  }
39
39
  /**
40
40
  * Generate a response from the LLM based on the provided prompt
@@ -89,9 +89,14 @@ class AWSBedrockService {
89
89
  anthropic_version: BEDROCK_API_VERSION,
90
90
  messages: messages,
91
91
  max_tokens: prompt.max_tokens || 1024,
92
- temperature: prompt.temperature,
93
- top_p: prompt.top_p,
94
92
  };
93
+ // Claude models do not allow both temperature and top_p simultaneously
94
+ if (prompt.temperature !== undefined) {
95
+ requestBody.temperature = prompt.temperature;
96
+ }
97
+ else if (prompt.top_p !== undefined) {
98
+ requestBody.top_p = prompt.top_p;
99
+ }
95
100
  if (systemPrompt) {
96
101
  requestBody.system = systemPrompt;
97
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AWSBedrockService.js","sourceRoot":"","sources":["../src/AWSBedrockService.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;AAElC,4EAIyC;AAEzC,qCAAkD;AA8ClD,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAa,iBAAiB;IAK1B,YAAY,KAA6B;QACrC,IAAI,CAAC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AI,CAAC,YAAY,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrG,MAAM,IAAI,KAAK,CAAC,uCAAuC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAC3F,CAAC;YAED,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClD,CAAC;KAAA;;AA5GL,8CA6GC;AA1G2B,6BAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
@@ -1,15 +1,9 @@
1
- /*! Copyright (c) 2024, XAPP AI */
1
+ /*! Copyright (c) 2026, XAPP AI */
2
2
  import type { ExternalLead } from "stentor-models";
3
- import type { AnalyzeWebsiteData, IGenerativeAIService, LeadAnalysis, LLMService, LLMServiceResponse, Prompt } from "./models";
3
+ import type { AnalyzeLeadOptions, AnalyzeWebsiteData, IGenerativeAIService, LeadAnalysis, LLMService, LLMServiceResponse, Prompt } from "./models";
4
+ import type { EmailAnalysisInput, EmailLeadAnalysis } from "./models/EmailAnalysis";
4
5
  import type { ChatSummary } from "./models/ChatSummary";
5
6
  import { WebsiteAnalysis } from "./models/WebsiteAnalysis";
6
- export interface BaseOptions {
7
- timeout?: number;
8
- }
9
- export interface AnalyzeLeadOptions extends BaseOptions {
10
- businessDescription?: string;
11
- highValueLeadDescription?: string;
12
- }
13
7
  export declare class GenerativeAIService implements IGenerativeAIService {
14
8
  private readonly llmService;
15
9
  constructor(llmService: LLMService);
@@ -25,6 +19,17 @@ export declare class GenerativeAIService implements IGenerativeAIService {
25
19
  * @param lead
26
20
  */
27
21
  analyzeLead(lead: ExternalLead, options?: AnalyzeLeadOptions): Promise<LeadAnalysis>;
22
+ /**
23
+ * Analyze an inbound email (or email thread) to classify and extract lead information.
24
+ *
25
+ * Combines lead classification (contactType, serviceType, jobType, urgency) with
26
+ * structured contact extraction in a single LLM call. Handles direct customer emails,
27
+ * FSM/CRM lead notification emails, and multi-email threads.
28
+ *
29
+ * @param email - The email content and optional thread history to analyze.
30
+ * @param options - Optional business context and LLM call options.
31
+ */
32
+ analyzeEmail(email: EmailAnalysisInput, options?: AnalyzeLeadOptions): Promise<EmailLeadAnalysis>;
28
33
  /**
29
34
  * Summarize a chat transcript
30
35
  * @param transcript
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.GenerativeAIService = void 0;
13
+ const AnalyzeEmail_1 = require("./prompts/AnalyzeEmail");
13
14
  const AnalyzeLead_1 = require("./prompts/AnalyzeLead");
14
15
  const prompts_1 = require("./prompts");
15
16
  const AnalyzeWebsite_1 = require("./prompts/AnalyzeWebsite");
@@ -49,11 +50,39 @@ class GenerativeAIService {
49
50
  if (!(options === null || options === void 0 ? void 0 : options.highValueLeadDescription)) {
50
51
  delete analysis.highValueLead;
51
52
  }
52
- // ADDING VERSION
53
53
  analysis.analysisVersion = "1.2.0"; // Update this version when the analysis process changes
54
54
  return analysis;
55
55
  });
56
56
  }
57
+ /**
58
+ * Analyze an inbound email (or email thread) to classify and extract lead information.
59
+ *
60
+ * Combines lead classification (contactType, serviceType, jobType, urgency) with
61
+ * structured contact extraction in a single LLM call. Handles direct customer emails,
62
+ * FSM/CRM lead notification emails, and multi-email threads.
63
+ *
64
+ * @param email - The email content and optional thread history to analyze.
65
+ * @param options - Optional business context and LLM call options.
66
+ */
67
+ analyzeEmail(email, options) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ const prompt = (0, AnalyzeEmail_1.generateAnalyzeEmail)({
70
+ businessDescription: (options === null || options === void 0 ? void 0 : options.businessDescription) || "",
71
+ highValueLeadDescription: (options === null || options === void 0 ? void 0 : options.highValueLeadDescription) || "",
72
+ email
73
+ });
74
+ const llmResponse = yield this.llmService.generate(prompt, {
75
+ timeout: options === null || options === void 0 ? void 0 : options.timeout
76
+ });
77
+ const analysis = (0, AnalyzeEmail_1.analyzeEmailResponseParse)(llmResponse.text);
78
+ // remove highValueLead if a description is not provided
79
+ if (!(options === null || options === void 0 ? void 0 : options.highValueLeadDescription)) {
80
+ delete analysis.highValueLead;
81
+ }
82
+ analysis.analysisVersion = AnalyzeEmail_1.ANALYZE_EMAIL_VERSION;
83
+ return analysis;
84
+ });
85
+ }
57
86
  /**
58
87
  * Summarize a chat transcript
59
88
  * @param transcript
@@ -1 +1 @@
1
- {"version":3,"file":"GenerativeAIService.js","sourceRoot":"","sources":["../src/GenerativeAIService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,uDAAsF;AACtF,uCAAkG;AAGlG,6DAA+F;AAW/F,MAAa,mBAAmB;IAG5B,YAAY,UAAsB;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACG,YAAY,CAAC,MAAc;;YAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;KAAA;IAED;;;;OAIG;IACG,WAAW,CAAC,IAAkB,EAAE,OAA4B;;YAC9D,MAAM,MAAM,GAAG,IAAA,iCAAmB,EAAC;gBAC/B,OAAO,EAAE,IAAI,CAAC,MAAM;gBACpB,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,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC9B,CAAC,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACvD,OAAO,EAAE,OAAO,aAAP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,CAAC,CAAC;QACzD,CAAC;KAAA;CACJ;AA/FD,kDA+FC"}
@@ -0,0 +1,66 @@
1
+ /*! Copyright (c) 2026, XAPP AI */
2
+ import type { LeadAnalysis } from "./LeadAnalysis";
3
+ export interface EmailThreadMessage {
4
+ role: "customer" | "agent" | "fsm_crm";
5
+ content: string;
6
+ timestamp?: string;
7
+ }
8
+ export interface EmailSender {
9
+ name?: string;
10
+ email: string;
11
+ }
12
+ /**
13
+ * Represents an inbound email (or email thread) to be analyzed.
14
+ */
15
+ export interface EmailAnalysisInput {
16
+ /**
17
+ * The email subject line.
18
+ */
19
+ subject: string;
20
+ /**
21
+ * The email body text. May include an email signature or quoted reply chains — the
22
+ * LLM is instructed to ignore those sections.
23
+ */
24
+ body: string;
25
+ /**
26
+ * The sender of the current (most recent) email.
27
+ */
28
+ from?: EmailSender;
29
+ /**
30
+ * Prior messages in the email thread, oldest first. Used to provide conversation
31
+ * context when the current email is a reply in an ongoing thread.
32
+ */
33
+ threadHistory?: EmailThreadMessage[];
34
+ }
35
+ /**
36
+ * Structured contact information extracted from an email body, particularly useful
37
+ * for FSM/CRM system notification emails (Jobber, ServiceTitan, Housecall Pro, etc.)
38
+ * that embed lead data in a structured text format.
39
+ */
40
+ export interface ExtractedContactInfo {
41
+ fullName?: string;
42
+ phone?: string;
43
+ email?: string;
44
+ address?: string;
45
+ city?: string;
46
+ state?: string;
47
+ zip?: string;
48
+ propertyType?: "residential" | "commercial";
49
+ preferredContactTime?: string;
50
+ /**
51
+ * Confidence score from 0.0 (low) to 1.0 (high) indicating how confident the LLM
52
+ * is in the extracted contact information.
53
+ */
54
+ confidence: number;
55
+ }
56
+ /**
57
+ * Extends the standard LeadAnalysis with email-specific contact extraction fields.
58
+ * Returned by `GenerativeAIService.analyzeEmail()`.
59
+ */
60
+ export interface EmailLeadAnalysis extends LeadAnalysis {
61
+ /**
62
+ * Contact information extracted from the email body. Only populated when the LLM
63
+ * can identify structured contact data (e.g., in FSM/CRM notification emails).
64
+ */
65
+ extractedContact?: ExtractedContactInfo;
66
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2026, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=EmailAnalysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailAnalysis.js","sourceRoot":"","sources":["../../src/models/EmailAnalysis.ts"],"names":[],"mappings":";AAAA,kCAAkC"}
@@ -1,5 +1,6 @@
1
- /*! Copyright (c) 2024, XAPP AI */
1
+ /*! Copyright (c) 2026, XAPP AI */
2
2
  import type { ExternalLead } from "stentor-models";
3
+ import type { EmailAnalysisInput, EmailLeadAnalysis } from "./EmailAnalysis";
3
4
  import type { LeadAnalysis } from "./LeadAnalysis";
4
5
  import type { WebsiteAnalysis } from "./WebsiteAnalysis";
5
6
  import type { ChatSummary } from "./ChatSummary";
@@ -8,6 +9,13 @@ import { LLMServiceResponse } from "./LLMService";
8
9
  export type AnalyzeWebsiteData = {
9
10
  url: string;
10
11
  };
12
+ export interface BaseOptions {
13
+ timeout?: number;
14
+ }
15
+ export interface AnalyzeLeadOptions extends BaseOptions {
16
+ businessDescription?: string;
17
+ highValueLeadDescription?: string;
18
+ }
11
19
  export interface IGenerativeAIService {
12
20
  /**
13
21
  * Executes a custom prompt that the user is responsible for creating and parsing.
@@ -20,6 +28,17 @@ export interface IGenerativeAIService {
20
28
  * @param lead
21
29
  */
22
30
  analyzeLead(lead: ExternalLead): Promise<LeadAnalysis>;
31
+ /**
32
+ * Analyze an inbound email (or email thread) to classify and extract lead information.
33
+ *
34
+ * Combines lead classification (contactType, serviceType, jobType, urgency) with
35
+ * structured contact extraction in a single LLM call. Handles direct customer emails,
36
+ * FSM/CRM lead notification emails, and multi-email threads.
37
+ *
38
+ * @param email - The email content and optional thread history to analyze.
39
+ * @param options - Optional business context and LLM call options.
40
+ */
41
+ analyzeEmail(email: EmailAnalysisInput, options?: AnalyzeLeadOptions): Promise<EmailLeadAnalysis>;
23
42
  /**
24
43
  * Summarize a chat transcript
25
44
  * @param transcript
@@ -1,4 +1,5 @@
1
- /*! Copyright (c) 2024, XAPP AI */
1
+ /*! Copyright (c) 2026, XAPP AI */
2
+ export * from "./EmailAnalysis";
2
3
  export * from "./errors";
3
4
  export * from './GenerativeAIService';
4
5
  export * from './LeadAnalysis';
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- /*! Copyright (c) 2024, XAPP AI */
2
+ /*! Copyright (c) 2026, XAPP AI */
3
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
4
  if (k2 === undefined) k2 = k;
5
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./EmailAnalysis"), exports);
18
19
  __exportStar(require("./errors"), exports);
19
20
  __exportStar(require("./GenerativeAIService"), exports);
20
21
  __exportStar(require("./LeadAnalysis"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;;;;;AAElC,2CAAyB;AACzB,wDAAsC;AACtC,iDAA+B;AAC/B,+CAA6B;AAC7B,2CAAyB;AACzB,oDAAkC;AAClC,mDAAiC"}
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"}
@@ -0,0 +1,36 @@
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.0.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>;
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2026, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.analyzeEmailResponseParse = exports.generateAnalyzeEmail = exports.ANALYZE_EMAIL_VERSION = void 0;
5
+ exports.emailThreadToMessages = emailThreadToMessages;
6
+ const AnalyzeLead_1 = require("./AnalyzeLead");
7
+ const extractJSON_1 = require("../utils/extractJSON");
8
+ exports.ANALYZE_EMAIL_VERSION = "1.0.0";
9
+ /**
10
+ * Converts an email (with optional thread history) into the messages array for an LLM completion prompt.
11
+ *
12
+ * Thread history messages are prepended in order, with customer messages as "user" and
13
+ * agent/FSM-CRM messages as "assistant". The current email is always the final "user" message.
14
+ *
15
+ * @param system - The system instruction message.
16
+ * @param email - The email to analyze.
17
+ */
18
+ function emailThreadToMessages(system, email) {
19
+ const messages = [
20
+ { role: "system", content: system }
21
+ ];
22
+ if (email.threadHistory && email.threadHistory.length > 0) {
23
+ for (const msg of email.threadHistory) {
24
+ // customer → user; agent and fsm_crm system messages both map to assistant
25
+ const role = msg.role === "customer" ? "user" : "assistant";
26
+ messages.push({ role, content: msg.content });
27
+ }
28
+ }
29
+ // Build the current email as the final user message
30
+ let currentEmailContent = `Subject: ${email.subject}`;
31
+ if (email.from) {
32
+ const fromStr = email.from.name ? `${email.from.name} <${email.from.email}>` : email.from.email;
33
+ currentEmailContent += `\nFrom: ${fromStr}`;
34
+ }
35
+ currentEmailContent += `\n\n${email.body}`;
36
+ messages.push({ role: "user", content: currentEmailContent });
37
+ return messages;
38
+ }
39
+ /**
40
+ * Generates a prompt that can be used in an LLM to analyze an inbound email for a business.
41
+ *
42
+ * Combines lead classification (contactType, serviceType, jobType, urgency) with contact
43
+ * information extraction in a single LLM call, returning an `EmailLeadAnalysis`.
44
+ *
45
+ * Handles:
46
+ * - Direct customer emails
47
+ * - FSM/CRM lead notification emails (Jobber, ServiceTitan, Housecall Pro, etc.)
48
+ * - Email threads with prior conversation history
49
+ */
50
+ const generateAnalyzeEmail = ({ businessDescription, highValueLeadDescription, email }, overrides) => {
51
+ const hasBusinessDescription = !!businessDescription;
52
+ const hasHighValueLeadDescription = !!highValueLeadDescription;
53
+ let intro = `You are a knowledgeable employee of a business.`;
54
+ if (hasBusinessDescription) {
55
+ intro = `
56
+ You are a knowledgeable employee of a business with the following description:
57
+
58
+ ===
59
+ ${businessDescription}
60
+ ===`;
61
+ }
62
+ let highValueLeadInstruction = "A high value lead description was not provided, do not return highValueLead.";
63
+ if (hasHighValueLeadDescription) {
64
+ highValueLeadInstruction = `A high value lead is defined as:
65
+ ===
66
+ ${(0, AnalyzeLead_1.getHighValueLeadDescription)(highValueLeadDescription)}
67
+ ===`;
68
+ }
69
+ const system = `
70
+ ${intro}
71
+
72
+ Your job is to analyze the following inbound email received by the business and classify it.
73
+
74
+ IMPORTANT INSTRUCTIONS:
75
+ - Focus on the most recent/primary email content only. Ignore quoted reply chains (lines starting with ">"), forwarded content, and blocks beginning with "On ... wrote:" or "---Original Message---".
76
+ - Ignore email signatures, unsubscribe footers, physical address blocks, and legal disclaimers — unless the address or phone is the only contact info present.
77
+ - Some emails are system notifications from FSM/CRM tools (e.g., Jobber, ServiceTitan, Housecall Pro). These often embed lead data in a structured text format like "Contact name: X", "Phone: Y", "Email: Z". Extract that contact data and treat the embedded customer as the actual lead.
78
+
79
+ You will return your analysis as a JSON object with the following properties:
80
+
81
+ - contactType
82
+ - serviceType
83
+ - jobType
84
+ - urgency
85
+ - analysis
86
+ - summary
87
+ - conciseSummary
88
+ - extractedContact
89
+
90
+ Provide your analysis of why you made these decisions which will be placed in the value "analysis". Include why you made decisions for contactType, serviceType, jobType and urgency. The analysis should be concise and provide enough detail to understand your reasoning. The analysis should not exceed 500 characters.
91
+
92
+ "contactType" definitions are as follows:
93
+ BILLING_ISSUE: Concerns about charges, refunds, pricing discrepancies, or payments (e.g., "I was billed incorrectly", "I want a refund").
94
+ CANCELLATION: Asking to cancel an appointment, service, subscription, or contract.
95
+ COMPLAINT: Dissatisfaction with the business, product, or service quality, excluding billing or scheduling issues.
96
+ COMPLIMENT: Positive feedback about the business, staff, or product.
97
+ CONTACT_REQUEST: A request for someone to contact the customer, without describing any service need, issue, quote request, scheduling intent, problem, or other specific purpose. Use only when the customer gives no actionable details (e.g., "please call me"). Do NOT use if the message includes a request for service, repair, installation, inspection, maintenance, scheduling, rescheduling, a quote, or reporting an issue.
98
+ EMPLOYMENT_INQUIRY: Questions about jobs, openings, hiring, or how to apply.
99
+ MISSED_APPOINTMENT: Reporting a no-show, missed call/visit, or confusion about appointment status or confirmation.
100
+ QUESTION: A general question about the business, services, products, availability, or policies, without requesting service or a quote. Requires a human reply.
101
+ QUOTE_REQUEST: Requesting a price, cost, estimate, quote, or ballpark figure for a product or service.
102
+ RESCHEDULE_REQUEST: Asking to change, move, or adjust the date or time of an existing appointment or scheduled service.
103
+ SERVICE_REQUEST: Requesting service, repair, installation, maintenance, inspection, booking/scheduling, or any assistance with a problem or issue. Includes any request for someone to come out, fix something, inspect something, or schedule a visit.
104
+ SPAM: Unsolicited, irrelevant, deceptive, generic, or low-value content. Includes people offering cost estimation or takeoff services, marketing/multimedia/SEO vendors, people offering to buy the business, debt relief companies, generic copy-pasted messages, gibberish, or fake/incomplete contact info.
105
+ TEST: A test message, placeholder text, or internal system check (e.g., "test", "asdf").
106
+ OTHER: Content cannot be reasonably determined from the email.
107
+
108
+ When multiple could apply, prefer BILLING_ISSUE, RESCHEDULE_REQUEST, CANCELLATION, or MISSED_APPOINTMENT over COMPLAINT or CONTACT_REQUEST.
109
+
110
+
111
+ The definitions of each "serviceType" value are as follows:
112
+ CLEANING: Cleaning work (e.g., house, windows, ducts, carpet, gutters). Note: overlaps with jobType=cleaning but here describes the type of work performed.
113
+ CONSULTATION: Requesting advice or guidance only, not execution (e.g., legal, design, remodel planning).
114
+ INSPECTION: Evaluation or check to assess a condition or issue (e.g., termite, mold, roof, crawlspace, safety, pre-sale).
115
+ INSTALLATION: New install of a product or system.
116
+ MAINTENANCE: Routine or recurring upkeep (e.g., HVAC tune-up, landscaping, gutter service).
117
+ REFINISH: Refinishing surfaces (e.g., floors, cabinets). Can include painting, staining, or other surface treatments. Use with jobType=painting when applicable.
118
+ REMODEL: Renovating or improving an existing structure or space. Note: overlaps with jobType=remodeling but here describes the type of work performed.
119
+ REPAIR: Fixing an existing product or system.
120
+ SUPPORT: Help with an issue or appointment related to the service but not the work itself (e.g., service follow-up, account help).
121
+ TRANSPORT: Requests to move, haul, or deliver items (e.g., moving services, relocation, junk removal, large delivery).
122
+ TREATMENT: Active service to resolve or prevent an issue (e.g., pest treatment, mold remediation, lawn spraying, rodent removal, recurring pest plans).
123
+ OTHER: Anything not covered above. If multiple apply, pick the most specific.
124
+
125
+ jobType definitions are as follows:
126
+ appliance_repair: Appliance repair services.
127
+ blinds: Window blinds and shades installation services.
128
+ carpentry: Carpentry or woodworking services.
129
+ cleaning: General cleaning services (house, carpet, duct, etc.).
130
+ construction: General construction services.
131
+ contractor: General contracting services (same as construction).
132
+ drywall: Drywall installation or repair.
133
+ electrical: Electrical work or services.
134
+ electrician: Electrical work or services (same as electrical).
135
+ fencing: Fence installation or repair.
136
+ flooring: Flooring installation, refinishing, or repair (hardwood, tile, etc.).
137
+ gutter: Gutter installation, rerouting, or cleaning.
138
+ gutters: Gutter services (same as gutter).
139
+ handyman: General home repair and maintenance services.
140
+ house_cleaning: House cleaning services (same as cleaning).
141
+ hvac: Heating, ventilation, or air conditioning services.
142
+ junk_removal: Junk and debris removal services.
143
+ landscaping: Landscaping or yard services.
144
+ landscaper: Landscaping services (same as landscaping).
145
+ legal_services: Legal services.
146
+ masonry: Masonry, brick, stone, or tuckpointing work.
147
+ mold_remediation: Mold inspection, removal, or remediation services.
148
+ moving: Moving or relocation services.
149
+ painting: Painting services.
150
+ painter: Painting services (same as painting).
151
+ pest_control: Pest control services (insects, termites, rodents).
152
+ plumbing: Plumbing services.
153
+ pressure_washing: Pressure washing and power washing services.
154
+ remodeling: Remodeling or renovation (kitchen, bathroom, home).
155
+ restoration: Water, fire, or damage restoration services.
156
+ roofing: Roofing services.
157
+ roofer: Roofing services (same as roofing).
158
+ siding: Siding installation or repair services.
159
+ tree_services: Tree removal, trimming, and care services.
160
+ wildlife_control: Wildlife removal or exclusion services (e.g., raccoons, squirrels, bats).
161
+ window_cleaning: Window cleaning services.
162
+ window_installation: Window installation or replacement services.
163
+ windows_doors: Window or door installation or replacement.
164
+ other: Services that do not fit above.
165
+
166
+ The definitions of each "urgency" value are as follows:
167
+ LOW: The interaction requests a service that is not time sensitive at all and can be addressed at the business's convenience.
168
+ MEDIUM: The interaction requests a service that is not time sensitive and can be addressed within a couple weeks.
169
+ HIGH: The interaction requests some service that is not life threatening, but should be addressed within a few days. It may lead to property damage or other issues if not addressed in a timely manner.
170
+ URGENT: The interaction requests some service that is life threatening or is causing property damage. It should be addressed as soon as possible, potentially same day. The longer the business waits to address the issue, the more damage will occur.
171
+ NOT_SPECIFIED: The urgency of the lead could not be determined by the content of the email.
172
+
173
+ Note about "urgency": This isn't necessarily the customer stating that the issue is urgent, but rather the nature of the issue itself.
174
+
175
+ ${highValueLeadInstruction}
176
+
177
+ Provide a summary of the email which will be placed in the value "summary". The summary should not exceed 250 characters.
178
+
179
+ Provide a concise 2–3 word phrase describing the main topic or service request of the lead. Use context from the business description, jobType, and serviceType if available. Use information from the email subject and body and leverage the sender's words as much as possible. Focus on meaningful keywords related to the issue or service, not greetings or filler words. Return this in the value "conciseSummary".
180
+ Examples:
181
+ - Subject: "Need AC repair" → "AC repair"
182
+ - Body: "scorpion and cricket issues" → "scorpion cricket issues"
183
+ - Body: "Contact name: John Smith, Service: Plumbing repair" → "plumbing repair"
184
+
185
+ For "extractedContact", extract any structured contact information found in the email body (especially from FSM/CRM notification formats like "Contact name: X", "Phone: Y"). Set "confidence" between 0.0 and 1.0 based on how confident you are in the extracted data. Return null for extractedContact if no meaningful contact information is present.
186
+ `;
187
+ const messages = emailThreadToMessages(system, email);
188
+ const max_tokens = 768;
189
+ return Object.assign(Object.assign({ model: "gpt-4o-mini", max_tokens, frequency_penalty: 0, temperature: 1, top_p: 1, presence_penalty: 0 }, overrides), { response_format: {
190
+ type: "json_schema",
191
+ json_schema: {
192
+ name: "analyze_email",
193
+ strict: false,
194
+ schema: {
195
+ type: "object",
196
+ additionalProperties: false,
197
+ required: [
198
+ "contactType",
199
+ "jobType",
200
+ "serviceType",
201
+ "urgency",
202
+ "highValueLead",
203
+ "conciseSummary",
204
+ "summary",
205
+ "analysis",
206
+ "extractedContact"
207
+ ],
208
+ properties: {
209
+ contactType: {
210
+ type: "string",
211
+ enum: [
212
+ "BILLING_ISSUE",
213
+ "CANCELLATION",
214
+ "COMPLAINT",
215
+ "COMPLIMENT",
216
+ "CONTACT_REQUEST",
217
+ "EMPLOYMENT_INQUIRY",
218
+ "MISSED_APPOINTMENT",
219
+ "QUESTION",
220
+ "QUOTE_REQUEST",
221
+ "RESCHEDULE_REQUEST",
222
+ "SERVICE_REQUEST",
223
+ "SPAM",
224
+ "TEST",
225
+ "OTHER"
226
+ ]
227
+ },
228
+ jobType: {
229
+ type: "string",
230
+ enum: [
231
+ "appliance_repair",
232
+ "blinds",
233
+ "carpentry",
234
+ "cleaning",
235
+ "construction",
236
+ "contractor",
237
+ "drywall",
238
+ "electrical",
239
+ "electrician",
240
+ "fencing",
241
+ "flooring",
242
+ "gutter",
243
+ "gutters",
244
+ "handyman",
245
+ "house_cleaning",
246
+ "hvac",
247
+ "junk_removal",
248
+ "landscaping",
249
+ "landscaper",
250
+ "legal_services",
251
+ "masonry",
252
+ "mold_remediation",
253
+ "moving",
254
+ "painting",
255
+ "painter",
256
+ "pest_control",
257
+ "plumbing",
258
+ "pressure_washing",
259
+ "remodeling",
260
+ "restoration",
261
+ "roofing",
262
+ "roofer",
263
+ "siding",
264
+ "tree_services",
265
+ "wildlife_control",
266
+ "window_cleaning",
267
+ "window_installation",
268
+ "windows_doors",
269
+ "other"
270
+ ]
271
+ },
272
+ serviceType: {
273
+ type: "string",
274
+ enum: [
275
+ "CLEANING",
276
+ "CONSULTATION",
277
+ "INSPECTION",
278
+ "INSTALLATION",
279
+ "MAINTENANCE",
280
+ "REFINISH",
281
+ "REMODEL",
282
+ "REPAIR",
283
+ "SUPPORT",
284
+ "TRANSPORT",
285
+ "TREATMENT",
286
+ "OTHER"
287
+ ]
288
+ },
289
+ urgency: {
290
+ type: "string",
291
+ enum: ["LOW", "MEDIUM", "HIGH", "URGENT", "NOT_SPECIFIED"]
292
+ },
293
+ highValueLead: {
294
+ type: "boolean"
295
+ },
296
+ summary: {
297
+ type: "string"
298
+ },
299
+ conciseSummary: {
300
+ type: "string"
301
+ },
302
+ analysis: {
303
+ type: "string"
304
+ },
305
+ extractedContact: {
306
+ type: ["object", "null"],
307
+ properties: {
308
+ fullName: { type: "string" },
309
+ phone: { type: "string" },
310
+ email: { type: "string" },
311
+ address: { type: "string" },
312
+ city: { type: "string" },
313
+ state: { type: "string" },
314
+ zip: { type: "string" },
315
+ propertyType: { type: "string", enum: ["residential", "commercial"] },
316
+ preferredContactTime: { type: "string" },
317
+ confidence: { type: "number" }
318
+ }
319
+ }
320
+ }
321
+ }
322
+ }
323
+ }, type: "completions", messages });
324
+ };
325
+ exports.generateAnalyzeEmail = generateAnalyzeEmail;
326
+ const defaultEmailLeadAnalysis = {
327
+ contactType: "OTHER",
328
+ urgency: "NOT_SPECIFIED",
329
+ highValueLead: false,
330
+ summary: "A summary could not be generated.",
331
+ analysis: "An analysis could not be generated."
332
+ };
333
+ const analyzeEmailResponseParse = (response) => {
334
+ try {
335
+ const { contactType, jobType, serviceType, urgency, highValueLead, summary, analysis, conciseSummary, extractedContact } = JSON.parse((0, extractJSON_1.extractJSON)(response));
336
+ const draftAnalysis = Object.assign(Object.assign({}, defaultEmailLeadAnalysis), { contactType: (contactType === null || contactType === void 0 ? void 0 : contactType.toUpperCase()) || defaultEmailLeadAnalysis.contactType, urgency: (urgency === null || urgency === void 0 ? void 0 : urgency.toUpperCase()) || defaultEmailLeadAnalysis.urgency, highValueLead: (highValueLead === null || highValueLead === void 0 ? void 0 : highValueLead.toString().toLocaleLowerCase()) === "true" || defaultEmailLeadAnalysis.highValueLead, summary: summary || defaultEmailLeadAnalysis.summary, analysis: analysis || defaultEmailLeadAnalysis.analysis });
337
+ if (conciseSummary) {
338
+ draftAnalysis.conciseSummary = conciseSummary;
339
+ }
340
+ if (jobType) {
341
+ draftAnalysis.jobType = jobType.toLowerCase();
342
+ }
343
+ if (serviceType) {
344
+ draftAnalysis.serviceType = serviceType.toUpperCase();
345
+ }
346
+ if (extractedContact) {
347
+ const contact = extractedContact;
348
+ // Only include if at least one meaningful contact field is present
349
+ if (contact.fullName || contact.phone || contact.email) {
350
+ // Clamp confidence to [0, 1], defaulting to 0 if omitted by the LLM
351
+ contact.confidence = typeof contact.confidence === "number"
352
+ ? Math.max(0, Math.min(1, contact.confidence))
353
+ : 0;
354
+ draftAnalysis.extractedContact = contact;
355
+ }
356
+ }
357
+ return draftAnalysis;
358
+ }
359
+ catch (e) {
360
+ return Object.assign({}, defaultEmailLeadAnalysis);
361
+ }
362
+ };
363
+ exports.analyzeEmailResponseParse = analyzeEmailResponseParse;
364
+ //# sourceMappingURL=AnalyzeEmail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyzeEmail.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeEmail.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AA6BlC,sDA2BC;AAnDD,+CAA4D;AAC5D,sDAAmD;AAEtC,QAAA,qBAAqB,GAAG,OAAO,CAAC;AAY7C;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACjC,MAAc,EACd,KAAyB;IAEzB,MAAM,QAAQ,GAAiE;QAC3E,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;KACtC,CAAC;IAEF,IAAI,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxD,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACpC,2EAA2E;YAC3E,MAAM,IAAI,GAAyB,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;YAClF,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,O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AAM,IAAI,wBAAwB,CAAC,aAAa,EACtG,OAAO,EAAE,OAAO,IAAI,wBAAwB,CAAC,OAAO,EACpD,QAAQ,EAAE,QAAQ,IAAI,wBAAwB,CAAC,QAAQ,GAC1D,CAAC;QAEF,IAAI,cAAc,EAAE,CAAC;YACjB,aAAa,CAAC,cAAc,GAAG,cAAc,CAAC;QAClD,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACV,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,EAAkC,CAAC;QAClF,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACd,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAsC,CAAC;QAC9F,CAAC;QAED,IAAI,gBAAgB,EAAE,CAAC;YACnB,MAAM,OAAO,GAAG,gBAAwC,CAAC;YACzD,mEAAmE;YACnE,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBACrD,oEAAoE;gBACpE,OAAO,CAAC,UAAU,GAAG,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;oBACvD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;oBAC9C,CAAC,CAAC,CAAC,CAAC;gBACR,aAAa,CAAC,gBAAgB,GAAG,OAAO,CAAC;YAC7C,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,yBAAY,wBAAwB,EAAG;IAC3C,CAAC;AACL,CAAC,CAAC;AA3CW,QAAA,yBAAyB,6BA2CpC"}
@@ -6,6 +6,7 @@ exports.transcriptToMessages = transcriptToMessages;
6
6
  exports.parseFields = parseFields;
7
7
  exports.getHighValueLeadDescription = getHighValueLeadDescription;
8
8
  const stentor_utils_1 = require("stentor-utils");
9
+ const extractJSON_1 = require("../utils/extractJSON");
9
10
  function getName(profile) {
10
11
  // Sorting these based on priority.
11
12
  return (profile === null || profile === void 0 ? void 0 : profile.name) || (profile === null || profile === void 0 ? void 0 : profile.email) || (profile === null || profile === void 0 ? void 0 : profile.phone) || "Unknown";
@@ -374,7 +375,7 @@ const defaultLeadAnalysis = {
374
375
  };
375
376
  const analyzeLeadResponseParse = (response) => {
376
377
  try {
377
- const { contactType, jobType, serviceType, urgency, highValueLead, summary, analysis, conciseSummary } = JSON.parse(response);
378
+ const { contactType, jobType, serviceType, urgency, highValueLead, summary, analysis, conciseSummary } = JSON.parse((0, extractJSON_1.extractJSON)(response));
378
379
  const draftAnalysis = Object.assign(Object.assign({}, defaultLeadAnalysis), { contactType: (contactType === null || contactType === void 0 ? void 0 : contactType.toUpperCase()) || defaultLeadAnalysis.contactType, urgency: (urgency === null || urgency === void 0 ? void 0 : urgency.toUpperCase()) || defaultLeadAnalysis.urgency, highValueLead: (highValueLead === null || highValueLead === void 0 ? void 0 : highValueLead.toString().toLocaleLowerCase()) === "true" || defaultLeadAnalysis.highValueLead, summary: summary || defaultLeadAnalysis.summary, analysis: analysis || defaultLeadAnalysis.analysis });
379
380
  if (conciseSummary) {
380
381
  draftAnalysis.conciseSummary = conciseSummary;
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyzeLead.js","sourceRoot":"","sources":["../../src/prompts/AnalyzeLead.ts"],"names":[],"mappings":";;;AAgCA,kDAMC;AASD,oDA8BC;AAOD,kCAaC;AAQD,kEAEC;AAzGD,iDAAkD;AAmBlD,SAAS,OAAO,CAAC,OAA+C;IAC5D,mCAAmC;IACnC,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,KAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,IAAI,SAAS,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBA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AAC;QACtC,MAAM,aAAa,mCACZ,mBAAmB,KACtB,WAAW,EAAE,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAkC,KAAI,mBAAmB,CAAC,WAAW,EAC3G,OAAO,EAAE,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAA8B,KAAI,mBAAmB,CAAC,OAAO,EAC3F,aAAa,EACT,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,GAAG,iBAAiB,EAAE,MAAK,MAAM,IAAI,mBAAmB,CAAC,aAAa,EACjG,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,IAAI,mBAAmB,CAAC,QAAQ,GACrD,CAAC;QAEF,IAAI,cAAc,EAAE,CAAC;YACjB,aAAa,CAAC,cAAc,GAAG,cAAc,CAAC;QAClD,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACV,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,EAA6B,CAAC;QAC7E,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACd,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAiC,CAAC;QACzF,CAAC;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,yBAAY,mBAAmB,EAAG;IACtC,CAAC;AACL,CAAC,CAAC;AA9BW,QAAA,wBAAwB,4BA8BnC"}
@@ -1,3 +1,4 @@
1
1
  /*! Copyright (c) 2024, XAPP AI */
2
+ export * from "./AnalyzeEmail";
2
3
  export * from "./AnalyzeLead";
3
4
  export * from "./ChatSummary";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./AnalyzeEmail"), exports);
18
19
  __exportStar(require("./AnalyzeLead"), exports);
19
20
  __exportStar(require("./ChatSummary"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;;;;;AAElC,gDAA8B;AAC9B,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;;;;;;;;;;;;;;AAElC,iDAA+B;AAC/B,gDAA8B;AAC9B,gDAA8B"}
@@ -0,0 +1,10 @@
1
+ /*! Copyright (c) 2026, XAPP AI */
2
+ /**
3
+ * Extracts a JSON string from an LLM response that may be wrapped in markdown
4
+ * code fences (e.g., ```json ... ```). Falls back to the raw response if no
5
+ * fences are found.
6
+ *
7
+ * This is necessary because Claude (Bedrock/Anthropic API) does not support
8
+ * `response_format: json_schema` and may wrap JSON output in markdown fences.
9
+ */
10
+ export declare function extractJSON(response: string): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2026, XAPP AI */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.extractJSON = extractJSON;
5
+ /**
6
+ * Extracts a JSON string from an LLM response that may be wrapped in markdown
7
+ * code fences (e.g., ```json ... ```). Falls back to the raw response if no
8
+ * fences are found.
9
+ *
10
+ * This is necessary because Claude (Bedrock/Anthropic API) does not support
11
+ * `response_format: json_schema` and may wrap JSON output in markdown fences.
12
+ */
13
+ function extractJSON(response) {
14
+ const match = response.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);
15
+ return match ? match[1].trim() : response;
16
+ }
17
+ //# sourceMappingURL=extractJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractJSON.js","sourceRoot":"","sources":["../../src/utils/extractJSON.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAUlC,kCAGC;AAXD;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC9C,CAAC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.76.20",
7
+ "version": "1.77.0",
8
8
  "description": "Generative AI Service",
9
9
  "types": "lib/index",
10
10
  "main": "lib/index",
@@ -19,12 +19,12 @@
19
19
  "@types/lodash": "4.17.24",
20
20
  "@xapp/config": "0.3.0",
21
21
  "chai": "4.5.0",
22
- "dotenv": "17.2.3",
22
+ "dotenv": "17.3.1",
23
23
  "mocha": "11.7.5",
24
- "stentor-logger": "1.69.14",
24
+ "stentor-logger": "1.69.19",
25
25
  "stentor-models": "1.69.14",
26
26
  "stentor-service-fetch": "1.69.14",
27
- "stentor-utils": "1.69.14",
27
+ "stentor-utils": "1.69.19",
28
28
  "ts-node": "10.9.2",
29
29
  "typescript": "5.9.3"
30
30
  },
@@ -46,5 +46,5 @@
46
46
  "test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\"",
47
47
  "ftest": "mocha --recursive -r ts-node/register \"./src/**/*.ftest.ts\""
48
48
  },
49
- "gitHead": "eb73aa3f295500557f9673c6caddd6e9b5083cbf"
49
+ "gitHead": "265da4d3b96b8e302396c54be8fb64fd8bf4e8c5"
50
50
  }