@astermind/cybernetic-chatbot-client 2.2.77 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CyberneticClient.d.ts +54 -1
- package/dist/CyberneticClient.d.ts.map +1 -1
- package/dist/SalesApiClient.d.ts +64 -0
- package/dist/SalesApiClient.d.ts.map +1 -0
- package/dist/cybernetic-chatbot-client-full.esm.js +177 -32
- package/dist/cybernetic-chatbot-client-full.esm.js.map +1 -1
- package/dist/cybernetic-chatbot-client-full.min.js +1 -1
- package/dist/cybernetic-chatbot-client-full.min.js.map +1 -1
- package/dist/cybernetic-chatbot-client-full.umd.js +177 -32
- package/dist/cybernetic-chatbot-client-full.umd.js.map +1 -1
- package/dist/cybernetic-chatbot-client.esm.js +178 -33
- package/dist/cybernetic-chatbot-client.esm.js.map +1 -1
- package/dist/cybernetic-chatbot-client.min.js +1 -1
- package/dist/cybernetic-chatbot-client.min.js.map +1 -1
- package/dist/cybernetic-chatbot-client.umd.js +178 -32
- package/dist/cybernetic-chatbot-client.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/license/licenseManager.d.ts +3 -5
- package/dist/license/licenseManager.d.ts.map +1 -1
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SalesApiClient } from './SalesApiClient.js';
|
|
1
2
|
import { CyberneticOfflineStorage } from './CyberneticOfflineStorage.js';
|
|
2
3
|
import type { StoredMessage } from './CyberneticSessionStorage.js';
|
|
3
4
|
import { LicenseManager } from './license/index.js';
|
|
4
|
-
import type { CyberneticConfig, CyberneticResponse, CyberneticError, ConnectionStatus, AskOptions, StreamCallbacks, CacheStatus, SystemSettings, AgenticConfig, SourcesConfig } from './types.js';
|
|
5
|
+
import type { CyberneticConfig, CyberneticResponse, CyberneticError, ConnectionStatus, AskOptions, StreamCallbacks, CacheStatus, SystemSettings, AgenticConfig, SourcesConfig, SalesChatResponse, VisitorInitResponse, LeadCaptureResponse } from './types.js';
|
|
5
6
|
import type { LicenseState } from './license/types.js';
|
|
6
7
|
/**
|
|
7
8
|
* Interface for agentic capabilities registration
|
|
@@ -34,6 +35,7 @@ export declare class CyberneticClient {
|
|
|
34
35
|
private licenseManager;
|
|
35
36
|
private offlineStorage;
|
|
36
37
|
private omegaRAG;
|
|
38
|
+
private salesClient;
|
|
37
39
|
private sessionStorage;
|
|
38
40
|
private offlineWarningShown;
|
|
39
41
|
constructor(config: CyberneticConfig);
|
|
@@ -205,6 +207,57 @@ export declare class CyberneticClient {
|
|
|
205
207
|
* Optionally sets a new sessionId immediately.
|
|
206
208
|
*/
|
|
207
209
|
startNewSession(sessionId?: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Check if sales mode is enabled
|
|
212
|
+
*/
|
|
213
|
+
isSalesModeEnabled(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Get the sales API client for direct access
|
|
216
|
+
*/
|
|
217
|
+
getSalesClient(): SalesApiClient | null;
|
|
218
|
+
/**
|
|
219
|
+
* Send a sales-aware chat message.
|
|
220
|
+
* Returns the assistant reply with sales context (lead score, CTA buttons, etc.).
|
|
221
|
+
* Requires salesMode to be enabled in config.
|
|
222
|
+
*/
|
|
223
|
+
salesChat(message: string, options?: {
|
|
224
|
+
sessionId?: string;
|
|
225
|
+
visitorId?: string;
|
|
226
|
+
conversationId?: string;
|
|
227
|
+
pageUrl?: string;
|
|
228
|
+
}): Promise<SalesChatResponse>;
|
|
229
|
+
/**
|
|
230
|
+
* Initialize or resume a visitor session.
|
|
231
|
+
* Call on first page load to register the visitor with the backend.
|
|
232
|
+
* Requires salesMode to be enabled in config.
|
|
233
|
+
*/
|
|
234
|
+
initVisitor(visitorId: string, pageUrl: string, referrer?: string, utmParams?: Record<string, string>): Promise<VisitorInitResponse>;
|
|
235
|
+
/**
|
|
236
|
+
* Track a page view event for a visitor.
|
|
237
|
+
* Call when the visitor navigates to a new page.
|
|
238
|
+
* Requires salesMode to be enabled in config.
|
|
239
|
+
*/
|
|
240
|
+
trackPageView(visitorId: string, url: string, title: string, timeOnPageMs?: number, scrollDepth?: number): Promise<{
|
|
241
|
+
success: boolean;
|
|
242
|
+
}>;
|
|
243
|
+
/**
|
|
244
|
+
* Submit a lead capture form.
|
|
245
|
+
* Creates or updates a lead record in the backend.
|
|
246
|
+
* Requires salesMode to be enabled in config.
|
|
247
|
+
*/
|
|
248
|
+
captureLeadForm(data: {
|
|
249
|
+
email: string;
|
|
250
|
+
firstName?: string;
|
|
251
|
+
lastName?: string;
|
|
252
|
+
company?: string;
|
|
253
|
+
role?: string;
|
|
254
|
+
useCase?: string;
|
|
255
|
+
budgetRange?: string;
|
|
256
|
+
timeline?: string;
|
|
257
|
+
visitorId?: string;
|
|
258
|
+
playbookId?: string;
|
|
259
|
+
customFields?: Record<string, any>;
|
|
260
|
+
}): Promise<LeadCaptureResponse>;
|
|
208
261
|
/**
|
|
209
262
|
* Send a message to the chatbot
|
|
210
263
|
* Always returns a response, never throws
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CyberneticClient.d.ts","sourceRoot":"","sources":["../src/CyberneticClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CyberneticClient.d.ts","sourceRoot":"","sources":["../src/CyberneticClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACR,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EAIb,aA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;IAsF7E;;;;;;OAMG;IACG,SAAS,CACX,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC;IAkFhB;;;OAGG;YACW,YAAY;IAqD1B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBhC;;OAEG;IACH,SAAS,IAAI;QACT,UAAU,EAAE,gBAAgB,CAAC;QAC7B,KAAK,EAAE,WAAW,CAAC;QACnB,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;QAClC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;QACtC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;KAChC;IAUD;;OAEG;IACH,iBAAiB,IAAI,cAAc;IAInC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;;OAGG;IACH,OAAO,IAAI,IAAI;IAOf;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAazC;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IA8BlD;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACH,qBAAqB,IAAI,MAAM,GAAG,SAAS;IAI3C;;OAEG;IACH,YAAY,IAAI,OAAO;IAevB;;OAEG;YACW,YAAY;IAuC1B;;;OAGG;YACW,WAAW;IAgIzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBzB;;OAEG;IACH,OAAO,CAAC,SAAS;IAOjB;;OAEG;IACH,OAAO,CAAC,cAAc;IA0CtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;OAEG;IACH,OAAO,CAAC,KAAK;CAGhB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { SalesChatResponse, VisitorInitResponse, LeadCaptureResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Client for the Sales Agent external API endpoints.
|
|
4
|
+
* Handles visitor tracking, sales-aware chat, and lead capture.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SalesApiClient {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private apiKey;
|
|
9
|
+
constructor(apiUrl: string, apiKey: string);
|
|
10
|
+
/**
|
|
11
|
+
* Initialize or resume a visitor session.
|
|
12
|
+
* Call on first page load to register the visitor with the backend.
|
|
13
|
+
*/
|
|
14
|
+
initVisitor(visitorId: string, pageUrl: string, referrer?: string, utmParams?: Record<string, string>): Promise<VisitorInitResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Track a page view event.
|
|
17
|
+
* Call when the visitor navigates to a new page.
|
|
18
|
+
*/
|
|
19
|
+
trackPageView(visitorId: string, url: string, title: string, timeOnPageMs?: number, scrollDepth?: number): Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Associate a visitor with identity data (email, name, etc.).
|
|
24
|
+
* Call when the visitor provides identifying information.
|
|
25
|
+
*/
|
|
26
|
+
identifyVisitor(visitorId: string, data: {
|
|
27
|
+
email?: string;
|
|
28
|
+
firstName?: string;
|
|
29
|
+
lastName?: string;
|
|
30
|
+
company?: string;
|
|
31
|
+
role?: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
profile: any;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Send a sales-aware chat message.
|
|
37
|
+
* Returns the assistant reply along with sales context (lead score, CTA buttons, etc.).
|
|
38
|
+
*/
|
|
39
|
+
salesChat(message: string, options?: {
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
visitorId?: string;
|
|
42
|
+
conversationId?: string;
|
|
43
|
+
pageUrl?: string;
|
|
44
|
+
}): Promise<SalesChatResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Submit a lead capture form.
|
|
47
|
+
* Creates or updates a lead record in the backend.
|
|
48
|
+
*/
|
|
49
|
+
captureLeadForm(data: {
|
|
50
|
+
email: string;
|
|
51
|
+
firstName?: string;
|
|
52
|
+
lastName?: string;
|
|
53
|
+
company?: string;
|
|
54
|
+
role?: string;
|
|
55
|
+
useCase?: string;
|
|
56
|
+
budgetRange?: string;
|
|
57
|
+
timeline?: string;
|
|
58
|
+
visitorId?: string;
|
|
59
|
+
playbookId?: string;
|
|
60
|
+
customFields?: Record<string, any>;
|
|
61
|
+
}): Promise<LeadCaptureResponse>;
|
|
62
|
+
private post;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=SalesApiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SalesApiClient.d.ts","sourceRoot":"","sources":["../src/SalesApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM1C;;;OAGG;IACG,WAAW,CACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,OAAO,CAAC,mBAAmB,CAAC;IAS/B;;;OAGG;IACG,aAAa,CACf,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAUhC;;;OAGG;IACG,eAAe,CACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;QACF,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,GACF,OAAO,CAAC;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IAO5B;;;OAGG;IACG,SAAS,CACX,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KACf,GACP,OAAO,CAAC,iBAAiB,CAAC;IAO7B;;;OAGG;IACG,eAAe,CAAC,IAAI,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACtC,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAMlB,IAAI;CAkBrB"}
|
|
@@ -213,6 +213,89 @@ class ApiClient {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
// src/SalesApiClient.ts
|
|
217
|
+
// API client for Sales Agent external endpoints (/api/external/sales/*)
|
|
218
|
+
/**
|
|
219
|
+
* Client for the Sales Agent external API endpoints.
|
|
220
|
+
* Handles visitor tracking, sales-aware chat, and lead capture.
|
|
221
|
+
*/
|
|
222
|
+
class SalesApiClient {
|
|
223
|
+
constructor(apiUrl, apiKey) {
|
|
224
|
+
// Normalize base URL (strip trailing slash)
|
|
225
|
+
this.baseUrl = apiUrl.replace(/\/$/, '');
|
|
226
|
+
this.apiKey = apiKey;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Initialize or resume a visitor session.
|
|
230
|
+
* Call on first page load to register the visitor with the backend.
|
|
231
|
+
*/
|
|
232
|
+
async initVisitor(visitorId, pageUrl, referrer, utmParams) {
|
|
233
|
+
return this.post('visitor/init', {
|
|
234
|
+
visitorId,
|
|
235
|
+
pageUrl,
|
|
236
|
+
referrer,
|
|
237
|
+
utmParams,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Track a page view event.
|
|
242
|
+
* Call when the visitor navigates to a new page.
|
|
243
|
+
*/
|
|
244
|
+
async trackPageView(visitorId, url, title, timeOnPageMs, scrollDepth) {
|
|
245
|
+
return this.post('visitor/pageview', {
|
|
246
|
+
visitorId,
|
|
247
|
+
url,
|
|
248
|
+
title,
|
|
249
|
+
timeOnPageMs,
|
|
250
|
+
scrollDepth,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Associate a visitor with identity data (email, name, etc.).
|
|
255
|
+
* Call when the visitor provides identifying information.
|
|
256
|
+
*/
|
|
257
|
+
async identifyVisitor(visitorId, data) {
|
|
258
|
+
return this.post('visitor/identify', {
|
|
259
|
+
visitorId,
|
|
260
|
+
...data,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Send a sales-aware chat message.
|
|
265
|
+
* Returns the assistant reply along with sales context (lead score, CTA buttons, etc.).
|
|
266
|
+
*/
|
|
267
|
+
async salesChat(message, options = {}) {
|
|
268
|
+
return this.post('chat', {
|
|
269
|
+
message,
|
|
270
|
+
...options,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Submit a lead capture form.
|
|
275
|
+
* Creates or updates a lead record in the backend.
|
|
276
|
+
*/
|
|
277
|
+
async captureLeadForm(data) {
|
|
278
|
+
return this.post('lead/capture', data);
|
|
279
|
+
}
|
|
280
|
+
// ─── Private ─────────────────────────────────────────────────────────────────
|
|
281
|
+
async post(path, body) {
|
|
282
|
+
const url = `${this.baseUrl}/api/external/sales/${path}`;
|
|
283
|
+
const response = await fetch(url, {
|
|
284
|
+
method: 'POST',
|
|
285
|
+
headers: {
|
|
286
|
+
'Content-Type': 'application/json',
|
|
287
|
+
'X-Api-Key': this.apiKey,
|
|
288
|
+
},
|
|
289
|
+
body: JSON.stringify(body),
|
|
290
|
+
});
|
|
291
|
+
if (!response.ok) {
|
|
292
|
+
const err = await response.json().catch(() => ({ error: 'Unknown error' }));
|
|
293
|
+
throw new Error(err.error || `Sales API error: ${response.status}`);
|
|
294
|
+
}
|
|
295
|
+
return response.json();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
216
299
|
const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
|
|
217
300
|
|
|
218
301
|
let idbProxyableTypes;
|
|
@@ -2174,8 +2257,10 @@ const REQUIRED_FEATURES = {
|
|
|
2174
2257
|
/**
|
|
2175
2258
|
* License enforcement message shown in production when license is invalid
|
|
2176
2259
|
*/
|
|
2177
|
-
|
|
2178
|
-
|
|
2260
|
+
// TODO: Re-enable when license key system is fully implemented
|
|
2261
|
+
// const LICENSE_WARNING_MESSAGE =
|
|
2262
|
+
// '\n\n---\n⚠️ License Notice: Your AsterMind license key needs to be updated. ' +
|
|
2263
|
+
// 'Please contact support@astermind.ai or visit https://astermind.ai/license to renew your license.';
|
|
2179
2264
|
/**
|
|
2180
2265
|
* Detect current environment based on URL and other signals
|
|
2181
2266
|
*/
|
|
@@ -2243,7 +2328,8 @@ class LicenseManager {
|
|
|
2243
2328
|
constructor(config = {}) {
|
|
2244
2329
|
this.state = null;
|
|
2245
2330
|
this.verificationPromise = null;
|
|
2246
|
-
|
|
2331
|
+
// TODO: Re-enable when license key system is fully implemented
|
|
2332
|
+
// private hasLoggedWarning = false;
|
|
2247
2333
|
this.loggedMissingFeatures = new Set();
|
|
2248
2334
|
this.config = config;
|
|
2249
2335
|
this.environment = config.environment || detectEnvironment();
|
|
@@ -2320,25 +2406,30 @@ class LicenseManager {
|
|
|
2320
2406
|
* @returns Modified response (or original if license valid)
|
|
2321
2407
|
*/
|
|
2322
2408
|
processResponse(response) {
|
|
2323
|
-
// License
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
//
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
//
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
//
|
|
2341
|
-
|
|
2409
|
+
// TODO: License enforcement disabled until license key system is fully implemented
|
|
2410
|
+
return response;
|
|
2411
|
+
// // License not verified yet - allow through
|
|
2412
|
+
// if (!this.state) {
|
|
2413
|
+
// return response;
|
|
2414
|
+
// }
|
|
2415
|
+
//
|
|
2416
|
+
// // Valid license - no modification
|
|
2417
|
+
// if (this.isValid() && !this.state.inGracePeriod) {
|
|
2418
|
+
// return response;
|
|
2419
|
+
// }
|
|
2420
|
+
//
|
|
2421
|
+
// // Handle based on enforcement mode
|
|
2422
|
+
// if (this.enforcementMode === 'soft') {
|
|
2423
|
+
// // Development: just log warning (once)
|
|
2424
|
+
// if (!this.hasLoggedWarning) {
|
|
2425
|
+
// this.logDevelopmentWarning();
|
|
2426
|
+
// this.hasLoggedWarning = true;
|
|
2427
|
+
// }
|
|
2428
|
+
// return response;
|
|
2429
|
+
// }
|
|
2430
|
+
//
|
|
2431
|
+
// // Production: append warning to response
|
|
2432
|
+
// return response + LICENSE_WARNING_MESSAGE;
|
|
2342
2433
|
}
|
|
2343
2434
|
/**
|
|
2344
2435
|
* Get a human-readable license status message
|
|
@@ -2370,7 +2461,7 @@ class LicenseManager {
|
|
|
2370
2461
|
*/
|
|
2371
2462
|
async reVerify() {
|
|
2372
2463
|
this.state = null;
|
|
2373
|
-
this.hasLoggedWarning = false;
|
|
2464
|
+
// this.hasLoggedWarning = false;
|
|
2374
2465
|
this.loggedMissingFeatures.clear();
|
|
2375
2466
|
return this.verify();
|
|
2376
2467
|
}
|
|
@@ -2475,15 +2566,6 @@ class LicenseManager {
|
|
|
2475
2566
|
break;
|
|
2476
2567
|
}
|
|
2477
2568
|
}
|
|
2478
|
-
/**
|
|
2479
|
-
* Log development-only warning
|
|
2480
|
-
*/
|
|
2481
|
-
logDevelopmentWarning() {
|
|
2482
|
-
console.warn('[Cybernetic License] Running in development mode with ' +
|
|
2483
|
-
`${this.state?.status || 'unknown'} license. ` +
|
|
2484
|
-
'In production, a warning will be appended to chatbot responses. ' +
|
|
2485
|
-
'Get a license at https://astermind.ai/license');
|
|
2486
|
-
}
|
|
2487
2569
|
}
|
|
2488
2570
|
/**
|
|
2489
2571
|
* Create a pre-configured license manager and verify immediately
|
|
@@ -2517,6 +2599,8 @@ class CyberneticClient {
|
|
|
2517
2599
|
this.offlineStorage = null;
|
|
2518
2600
|
// Omega RAG (optional, loaded dynamically)
|
|
2519
2601
|
this.omegaRAG = null;
|
|
2602
|
+
// Sales API client (optional, enabled via salesMode config)
|
|
2603
|
+
this.salesClient = null;
|
|
2520
2604
|
// Track if offline warning has been shown
|
|
2521
2605
|
this.offlineWarningShown = false;
|
|
2522
2606
|
// Resolve WebSocket URL (explicit → env → auto-derived from apiUrl)
|
|
@@ -2586,6 +2670,10 @@ class CyberneticClient {
|
|
|
2586
2670
|
// Silent failure on init - cache may be stale but usable
|
|
2587
2671
|
});
|
|
2588
2672
|
}
|
|
2673
|
+
// Initialize sales client if configured
|
|
2674
|
+
if (config.salesMode?.enabled) {
|
|
2675
|
+
this.salesClient = new SalesApiClient(config.apiUrl, config.apiKey);
|
|
2676
|
+
}
|
|
2589
2677
|
// Initialize offline vector support if configured
|
|
2590
2678
|
if (this.config.offline?.enabled) {
|
|
2591
2679
|
this.initializeOffline(this.config.offline).catch((error) => {
|
|
@@ -2900,6 +2988,63 @@ class CyberneticClient {
|
|
|
2900
2988
|
startNewSession(sessionId) {
|
|
2901
2989
|
this.sessionStorage.startNewSession(sessionId);
|
|
2902
2990
|
}
|
|
2991
|
+
// ==================== SALES API METHODS ====================
|
|
2992
|
+
/**
|
|
2993
|
+
* Check if sales mode is enabled
|
|
2994
|
+
*/
|
|
2995
|
+
isSalesModeEnabled() {
|
|
2996
|
+
return this.salesClient !== null;
|
|
2997
|
+
}
|
|
2998
|
+
/**
|
|
2999
|
+
* Get the sales API client for direct access
|
|
3000
|
+
*/
|
|
3001
|
+
getSalesClient() {
|
|
3002
|
+
return this.salesClient;
|
|
3003
|
+
}
|
|
3004
|
+
/**
|
|
3005
|
+
* Send a sales-aware chat message.
|
|
3006
|
+
* Returns the assistant reply with sales context (lead score, CTA buttons, etc.).
|
|
3007
|
+
* Requires salesMode to be enabled in config.
|
|
3008
|
+
*/
|
|
3009
|
+
async salesChat(message, options = {}) {
|
|
3010
|
+
if (!this.salesClient) {
|
|
3011
|
+
throw new Error('Sales mode is not enabled. Set salesMode.enabled = true in config.');
|
|
3012
|
+
}
|
|
3013
|
+
return this.salesClient.salesChat(message, options);
|
|
3014
|
+
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Initialize or resume a visitor session.
|
|
3017
|
+
* Call on first page load to register the visitor with the backend.
|
|
3018
|
+
* Requires salesMode to be enabled in config.
|
|
3019
|
+
*/
|
|
3020
|
+
async initVisitor(visitorId, pageUrl, referrer, utmParams) {
|
|
3021
|
+
if (!this.salesClient) {
|
|
3022
|
+
throw new Error('Sales mode is not enabled. Set salesMode.enabled = true in config.');
|
|
3023
|
+
}
|
|
3024
|
+
return this.salesClient.initVisitor(visitorId, pageUrl, referrer, utmParams);
|
|
3025
|
+
}
|
|
3026
|
+
/**
|
|
3027
|
+
* Track a page view event for a visitor.
|
|
3028
|
+
* Call when the visitor navigates to a new page.
|
|
3029
|
+
* Requires salesMode to be enabled in config.
|
|
3030
|
+
*/
|
|
3031
|
+
async trackPageView(visitorId, url, title, timeOnPageMs, scrollDepth) {
|
|
3032
|
+
if (!this.salesClient) {
|
|
3033
|
+
throw new Error('Sales mode is not enabled. Set salesMode.enabled = true in config.');
|
|
3034
|
+
}
|
|
3035
|
+
return this.salesClient.trackPageView(visitorId, url, title, timeOnPageMs, scrollDepth);
|
|
3036
|
+
}
|
|
3037
|
+
/**
|
|
3038
|
+
* Submit a lead capture form.
|
|
3039
|
+
* Creates or updates a lead record in the backend.
|
|
3040
|
+
* Requires salesMode to be enabled in config.
|
|
3041
|
+
*/
|
|
3042
|
+
async captureLeadForm(data) {
|
|
3043
|
+
if (!this.salesClient) {
|
|
3044
|
+
throw new Error('Sales mode is not enabled. Set salesMode.enabled = true in config.');
|
|
3045
|
+
}
|
|
3046
|
+
return this.salesClient.captureLeadForm(data);
|
|
3047
|
+
}
|
|
2903
3048
|
// ==================== CORE METHODS ====================
|
|
2904
3049
|
/**
|
|
2905
3050
|
* Send a message to the chatbot
|