@astermind/cybernetic-chatbot-client 1.0.6

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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +667 -0
  3. package/dist/ApiClient.d.ts +86 -0
  4. package/dist/ApiClient.d.ts.map +1 -0
  5. package/dist/CyberneticCache.d.ts +56 -0
  6. package/dist/CyberneticCache.d.ts.map +1 -0
  7. package/dist/CyberneticClient.d.ts +207 -0
  8. package/dist/CyberneticClient.d.ts.map +1 -0
  9. package/dist/CyberneticLocalRAG.d.ts +59 -0
  10. package/dist/CyberneticLocalRAG.d.ts.map +1 -0
  11. package/dist/agentic/CyberneticAgent.d.ts +111 -0
  12. package/dist/agentic/CyberneticAgent.d.ts.map +1 -0
  13. package/dist/agentic/CyberneticIntentClassifier.d.ts +78 -0
  14. package/dist/agentic/CyberneticIntentClassifier.d.ts.map +1 -0
  15. package/dist/agentic/index.d.ts +13 -0
  16. package/dist/agentic/index.d.ts.map +1 -0
  17. package/dist/agentic/register.d.ts +32 -0
  18. package/dist/agentic/register.d.ts.map +1 -0
  19. package/dist/agentic/tools/ClickTool.d.ts +41 -0
  20. package/dist/agentic/tools/ClickTool.d.ts.map +1 -0
  21. package/dist/agentic/tools/FillTool.d.ts +59 -0
  22. package/dist/agentic/tools/FillTool.d.ts.map +1 -0
  23. package/dist/agentic/tools/NavigateTool.d.ts +87 -0
  24. package/dist/agentic/tools/NavigateTool.d.ts.map +1 -0
  25. package/dist/agentic/tools/ScrollTool.d.ts +74 -0
  26. package/dist/agentic/tools/ScrollTool.d.ts.map +1 -0
  27. package/dist/agentic/tools/index.d.ts +9 -0
  28. package/dist/agentic/tools/index.d.ts.map +1 -0
  29. package/dist/agentic/types.d.ts +112 -0
  30. package/dist/agentic/types.d.ts.map +1 -0
  31. package/dist/config.d.ts +10 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/cybernetic-chatbot-client-full.esm.js +3271 -0
  34. package/dist/cybernetic-chatbot-client-full.esm.js.map +1 -0
  35. package/dist/cybernetic-chatbot-client-full.min.js +2 -0
  36. package/dist/cybernetic-chatbot-client-full.min.js.map +1 -0
  37. package/dist/cybernetic-chatbot-client-full.umd.js +3296 -0
  38. package/dist/cybernetic-chatbot-client-full.umd.js.map +1 -0
  39. package/dist/cybernetic-chatbot-client.esm.js +3265 -0
  40. package/dist/cybernetic-chatbot-client.esm.js.map +1 -0
  41. package/dist/cybernetic-chatbot-client.min.js +2 -0
  42. package/dist/cybernetic-chatbot-client.min.js.map +1 -0
  43. package/dist/cybernetic-chatbot-client.umd.js +3290 -0
  44. package/dist/cybernetic-chatbot-client.umd.js.map +1 -0
  45. package/dist/full.d.ts +15 -0
  46. package/dist/full.d.ts.map +1 -0
  47. package/dist/index.d.ts +15 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/license/base64url.d.ts +24 -0
  50. package/dist/license/base64url.d.ts.map +1 -0
  51. package/dist/license/index.d.ts +5 -0
  52. package/dist/license/index.d.ts.map +1 -0
  53. package/dist/license/licenseManager.d.ts +124 -0
  54. package/dist/license/licenseManager.d.ts.map +1 -0
  55. package/dist/license/types.d.ts +72 -0
  56. package/dist/license/types.d.ts.map +1 -0
  57. package/dist/license/verifier.d.ts +19 -0
  58. package/dist/license/verifier.d.ts.map +1 -0
  59. package/dist/types.d.ts +163 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/package.json +85 -0
@@ -0,0 +1,86 @@
1
+ import type { Source, SystemSettings } from './types.js';
2
+ interface ChatRequest {
3
+ sessionId?: string;
4
+ context?: {
5
+ currentPage?: string;
6
+ pageTitle?: string;
7
+ };
8
+ }
9
+ interface ChatResponse {
10
+ reply: string;
11
+ sessionId: string;
12
+ sources: Source[];
13
+ usage: {
14
+ tokensUsed: number;
15
+ quotaRemaining: {
16
+ minute: number;
17
+ day: number;
18
+ };
19
+ };
20
+ }
21
+ interface StreamCallbacks {
22
+ onToken?: (token: string) => void;
23
+ onSources?: (sources: Source[]) => void;
24
+ onComplete?: (data: {
25
+ fullText: string;
26
+ sessionId?: string;
27
+ sources?: Source[];
28
+ }) => void;
29
+ onError?: (error: Error) => void;
30
+ }
31
+ interface StatusResponse {
32
+ status: string;
33
+ apiKey: {
34
+ id: string;
35
+ scopes: string[];
36
+ };
37
+ quota: {
38
+ perMinute: {
39
+ limit: number;
40
+ remaining: number;
41
+ };
42
+ perDay: {
43
+ limit: number;
44
+ remaining: number;
45
+ };
46
+ };
47
+ systemSettings?: SystemSettings;
48
+ }
49
+ /**
50
+ * HTTP/SSE client for AsterMind backend
51
+ */
52
+ export declare class ApiClient {
53
+ private baseUrl;
54
+ private apiKey;
55
+ constructor(baseUrl: string, apiKey: string);
56
+ /**
57
+ * Send chat message and get complete response
58
+ */
59
+ chat(message: string, options?: ChatRequest): Promise<ChatResponse>;
60
+ /**
61
+ * Send chat message with streaming response via SSE
62
+ */
63
+ chatStream(message: string, options: ChatRequest & StreamCallbacks): Promise<void>;
64
+ /**
65
+ * Get general documents for caching
66
+ */
67
+ getGeneralDocs(since?: string | null): Promise<Array<{
68
+ id: string;
69
+ title: string;
70
+ content: string;
71
+ updatedAt: string;
72
+ }>>;
73
+ /**
74
+ * Get API status, quota, and system settings
75
+ */
76
+ getStatus(): Promise<StatusResponse>;
77
+ /**
78
+ * Health check (no auth required)
79
+ */
80
+ health(): Promise<{
81
+ status: string;
82
+ timestamp: string;
83
+ }>;
84
+ }
85
+ export {};
86
+ //# sourceMappingURL=ApiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiClient.d.ts","sourceRoot":"","sources":["../src/ApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzD,UAAU,WAAW;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS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E,MAAM;IAK3C;;OAEG;IACG,IAAI,CACN,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,WAAW,GACtB,OAAO,CAAC,YAAY,CAAC;IAsBxB;;OAEG;IACG,UAAU,CACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,WAAW,GAAG,eAAe,GACvC,OAAO,CAAC,IAAI,CAAC;IAuEhB;;OAEG;IACG,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;QACvD,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IAqBH;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;IAc1C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CASjE"}
@@ -0,0 +1,56 @@
1
+ import type { CachedDocument, CacheStatus } from './types.js';
2
+ interface CacheConfig {
3
+ storage: 'indexeddb' | 'localstorage';
4
+ maxAge: number;
5
+ }
6
+ /**
7
+ * Document cache for offline RAG fallback
8
+ */
9
+ export declare class CyberneticCache {
10
+ private config;
11
+ private db;
12
+ private dbPromise;
13
+ private documentCount;
14
+ private lastSyncAt;
15
+ constructor(config: CacheConfig);
16
+ /**
17
+ * Load metadata from localStorage
18
+ */
19
+ private loadLocalStorageMetadata;
20
+ /**
21
+ * Initialize IndexedDB
22
+ */
23
+ private initDB;
24
+ /**
25
+ * Get database instance
26
+ */
27
+ private getDB;
28
+ /**
29
+ * Load cached metadata (count, last sync)
30
+ */
31
+ private loadMetadata;
32
+ /**
33
+ * Store documents in cache
34
+ */
35
+ store(documents: CachedDocument[]): Promise<void>;
36
+ /**
37
+ * Retrieve all cached documents
38
+ */
39
+ retrieve(): Promise<CachedDocument[]>;
40
+ /**
41
+ * Get last sync timestamp
42
+ */
43
+ getLastSync(): Promise<string | null>;
44
+ /**
45
+ * Get cache status
46
+ */
47
+ getStatus(): CacheStatus;
48
+ /**
49
+ * Clear all cached data
50
+ */
51
+ clear(): Promise<void>;
52
+ private storeLocalStorage;
53
+ private retrieveLocalStorage;
54
+ }
55
+ export {};
56
+ //# sourceMappingURL=CyberneticCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CyberneticCache.d.ts","sourceRoot":"","sources":["../src/CyberneticCache.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmB9D,UAAU,WAAW;IACjB,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,EAAE,CAAgD;IAC1D,OAAO,CAAC,SAAS,CAAyD;IAC1E,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,UAAU,CAAuB;gBAE7B,MAAM,EAAE,WAAW;IAW/B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAahC;;OAEG;YACW,MAAM;IAsBpB;;OAEG;YACW,KAAK;IAMnB;;OAEG;YACW,YAAY;IAU1B;;OAEG;IACG,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BvD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAS3C;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI3C;;OAEG;IACH,SAAS,IAAI,WAAW;IAaxB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,oBAAoB;CAQ/B"}
@@ -0,0 +1,207 @@
1
+ import { LicenseManager } from './license/index.js';
2
+ import type { CyberneticConfig, CyberneticResponse, CyberneticError, ConnectionStatus, AskOptions, StreamCallbacks, CacheStatus, SystemSettings, AgenticConfig } from './types.js';
3
+ import type { LicenseState } from './license/types.js';
4
+ /**
5
+ * Interface for agentic capabilities registration
6
+ * Used by registerAgenticCapabilities() helper from agentic module
7
+ */
8
+ export interface AgenticCapabilities {
9
+ /** CyberneticAgent class for DOM interactions */
10
+ agent: any;
11
+ /** CyberneticIntentClassifier class for intent detection */
12
+ intentClassifier?: any;
13
+ }
14
+ /**
15
+ * Cybernetic Chatbot Client
16
+ *
17
+ * Provides API access to AsterMind backend with offline fallback.
18
+ * Always returns a response, never throws exceptions.
19
+ */
20
+ export declare class CyberneticClient {
21
+ private config;
22
+ private apiClient;
23
+ private cache;
24
+ private localRAG;
25
+ private status;
26
+ private lastError;
27
+ private systemSettings;
28
+ private settingsLastChecked;
29
+ private readonly SETTINGS_CHECK_INTERVAL;
30
+ private agenticCapabilities;
31
+ private licenseManager;
32
+ constructor(config: CyberneticConfig);
33
+ /**
34
+ * Register agentic capabilities
35
+ * Called by registerAgenticCapabilities() helper from agentic module
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { CyberneticClient, registerAgenticCapabilities } from '@astermind/cybernetic-chatbot-client';
40
+ * const client = new CyberneticClient(config);
41
+ * registerAgenticCapabilities(client);
42
+ * ```
43
+ */
44
+ registerAgentic(capabilities: AgenticCapabilities): void;
45
+ /**
46
+ * Check if agentic capabilities are available and enabled
47
+ */
48
+ isAgenticEnabled(): boolean;
49
+ /**
50
+ * Get registered agentic capabilities (for advanced use)
51
+ */
52
+ getAgenticCapabilities(): AgenticCapabilities | null;
53
+ /**
54
+ * Get agentic configuration
55
+ */
56
+ getAgenticConfig(): AgenticConfig | null;
57
+ /**
58
+ * Classify user message intent for agentic action
59
+ * Only works if agentic capabilities are registered and enabled
60
+ *
61
+ * @param message - User's message to classify
62
+ * @returns Intent classification or null if agentic not available
63
+ */
64
+ classifyIntent(message: string): {
65
+ action: {
66
+ id: string;
67
+ type: string;
68
+ target: string;
69
+ confidence: number;
70
+ explanation?: string;
71
+ params?: Record<string, unknown>;
72
+ } | null;
73
+ shouldEscalate: boolean;
74
+ rawConfidence: number;
75
+ matchedPatterns?: string[];
76
+ } | null;
77
+ /**
78
+ * Execute an agent action
79
+ * Only works if agentic capabilities are registered and enabled
80
+ *
81
+ * @param action - Action to execute
82
+ * @returns Action result or error
83
+ */
84
+ executeAction(action: {
85
+ id: string;
86
+ type: string;
87
+ target: string;
88
+ confidence: number;
89
+ params?: Record<string, unknown>;
90
+ }): Promise<{
91
+ success: boolean;
92
+ message: string;
93
+ error?: string;
94
+ }>;
95
+ /**
96
+ * Smart ask - checks for action intent first, then falls back to RAG
97
+ * Combines agentic classification with standard RAG query
98
+ *
99
+ * @param message - User's message
100
+ * @param options - Optional request configuration
101
+ * @returns Object containing response, action, and/or action result
102
+ */
103
+ smartAsk(message: string, options?: AskOptions): Promise<{
104
+ response?: CyberneticResponse;
105
+ action?: {
106
+ id: string;
107
+ type: string;
108
+ target: string;
109
+ confidence: number;
110
+ explanation?: string;
111
+ params?: Record<string, unknown>;
112
+ };
113
+ actionResult?: {
114
+ success: boolean;
115
+ message: string;
116
+ error?: string;
117
+ };
118
+ }>;
119
+ /**
120
+ * Send a message to the chatbot
121
+ * Always returns a response, never throws
122
+ *
123
+ * @param message - User's message
124
+ * @param options - Optional request configuration
125
+ */
126
+ ask(message: string, options?: AskOptions): Promise<CyberneticResponse>;
127
+ /**
128
+ * Send a message with streaming response
129
+ *
130
+ * @param message - User's message
131
+ * @param callbacks - Streaming event callbacks
132
+ * @param options - Optional request configuration
133
+ */
134
+ askStream(message: string, callbacks: StreamCallbacks, options?: AskOptions): Promise<void>;
135
+ /**
136
+ * Sync documents to local cache for offline use
137
+ */
138
+ syncCache(): Promise<void>;
139
+ /**
140
+ * Get current connection status including system settings
141
+ */
142
+ getStatus(): {
143
+ connection: ConnectionStatus;
144
+ cache: CacheStatus;
145
+ lastError: CyberneticError | null;
146
+ systemSettings: SystemSettings | null;
147
+ license: LicenseState | null;
148
+ };
149
+ /**
150
+ * Get license manager for advanced license operations
151
+ */
152
+ getLicenseManager(): LicenseManager;
153
+ /**
154
+ * Clear local cache
155
+ */
156
+ clearCache(): Promise<void>;
157
+ /**
158
+ * Manually check if backend is reachable
159
+ */
160
+ checkConnection(): Promise<boolean>;
161
+ /**
162
+ * Check system status including maintenance mode
163
+ * Called periodically and before API calls
164
+ */
165
+ checkSystemStatus(): Promise<SystemSettings>;
166
+ /**
167
+ * Check if maintenance mode is active
168
+ */
169
+ isMaintenanceMode(): boolean;
170
+ /**
171
+ * Get maintenance message if in maintenance mode
172
+ */
173
+ getMaintenanceMessage(): string | undefined;
174
+ /**
175
+ * Validate cache using server-configured retention hours
176
+ */
177
+ isCacheValid(): boolean;
178
+ /**
179
+ * API call with retry logic
180
+ */
181
+ private apiWithRetry;
182
+ /**
183
+ * Fallback to local RAG processing
184
+ */
185
+ private fallbackAsk;
186
+ /**
187
+ * Monitor browser online/offline events
188
+ */
189
+ private monitorConnection;
190
+ /**
191
+ * Update connection status and notify listeners
192
+ */
193
+ private setStatus;
194
+ /**
195
+ * Normalize various error types to CyberneticError
196
+ */
197
+ private normalizeError;
198
+ /**
199
+ * Create standardized error response
200
+ */
201
+ private createErrorResponse;
202
+ /**
203
+ * Async sleep utility
204
+ */
205
+ private sleep;
206
+ }
207
+ //# sourceMappingURL=CyberneticClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CyberneticClient.d.ts","sourceRoot":"","sources":["../src/CyberneticClient.ts"],"names":[],"mappings":"AAMA,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,EAChB,MAAM,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,CAAC;IA4DhB;;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;;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;;OAEG;YACW,WAAW;IAgEzB;;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,59 @@
1
+ import type { CachedDocument } from './types.js';
2
+ interface LocalRAGResult {
3
+ answer: string;
4
+ sources: Array<{
5
+ title: string;
6
+ snippet: string;
7
+ score: number;
8
+ }>;
9
+ topScore: number;
10
+ }
11
+ /**
12
+ * Local RAG engine using TF-IDF similarity
13
+ *
14
+ * Provides offline fallback when backend is unavailable.
15
+ * Uses simple TF-IDF for document matching (no vector embeddings).
16
+ */
17
+ export declare class CyberneticLocalRAG {
18
+ private documents;
19
+ private idf;
20
+ private indexed;
21
+ /**
22
+ * Check if documents are indexed
23
+ */
24
+ isIndexed(): boolean;
25
+ /**
26
+ * Index documents for local search
27
+ */
28
+ index(documents: CachedDocument[]): Promise<void>;
29
+ /**
30
+ * Process query and generate response
31
+ */
32
+ ask(query: string): Promise<LocalRAGResult>;
33
+ /**
34
+ * Reset the index
35
+ */
36
+ reset(): void;
37
+ /**
38
+ * Tokenize text into words
39
+ */
40
+ private tokenize;
41
+ /**
42
+ * Compute term frequency
43
+ */
44
+ private computeTermFrequency;
45
+ /**
46
+ * Compute cosine similarity between two TF-IDF vectors
47
+ */
48
+ private cosineSimilarity;
49
+ /**
50
+ * Extract most relevant snippet from content
51
+ */
52
+ private extractRelevantSnippet;
53
+ /**
54
+ * Check if word is a stop word
55
+ */
56
+ private isStopWord;
57
+ }
58
+ export {};
59
+ //# sourceMappingURL=CyberneticLocalRAG.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CyberneticLocalRAG.d.ts","sourceRoot":"","sources":["../src/CyberneticLocalRAG.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,UAAU,cAAc;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,QAAQ,EAAE,MAAM,CAAC;CACpB;AAUD;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,GAAG,CAAkC;IAC7C,OAAO,CAAC,OAAO,CAAS;IAExB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACG,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CvD;;OAEG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAsDjD;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,OAAO,CAAC,QAAQ;IAQhB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAyB9B;;OAEG;IACH,OAAO,CAAC,UAAU;CAarB"}
@@ -0,0 +1,111 @@
1
+ import { CyberneticIntentClassifier } from './CyberneticIntentClassifier.js';
2
+ import type { AgentAction, ActionResult, IntentClassification, AgentConfig } from './types.js';
3
+ /**
4
+ * DOM interaction agent
5
+ *
6
+ * Executes actions on the host page based on classified intent.
7
+ * Supports navigation, form filling, clicking, scrolling, and more.
8
+ */
9
+ export declare class CyberneticAgent {
10
+ private config;
11
+ private classifier;
12
+ private highlightOverlay;
13
+ private actionCount;
14
+ private lastActionReset;
15
+ constructor(config: AgentConfig);
16
+ /**
17
+ * Interpret user message and determine action
18
+ *
19
+ * @param message - User's message to interpret
20
+ * @returns Intent classification with suggested action
21
+ */
22
+ interpretIntent(message: string): IntentClassification;
23
+ /**
24
+ * Execute an agent action
25
+ *
26
+ * @param action - The action to execute
27
+ * @returns Result of action execution
28
+ */
29
+ executeAction(action: AgentAction): Promise<ActionResult>;
30
+ /**
31
+ * Check if an action type is allowed by configuration
32
+ */
33
+ private isActionAllowed;
34
+ /**
35
+ * Check if selector is allowed (not blocked)
36
+ */
37
+ private isSelectorAllowed;
38
+ /**
39
+ * Navigate to a URL
40
+ */
41
+ private navigate;
42
+ /**
43
+ * Fill a form field
44
+ */
45
+ private fillForm;
46
+ /**
47
+ * Click an element
48
+ */
49
+ private clickElement;
50
+ /**
51
+ * Trigger a modal by clicking its trigger element
52
+ */
53
+ private triggerModal;
54
+ /**
55
+ * Scroll to an element
56
+ */
57
+ private scrollToElement;
58
+ /**
59
+ * Highlight an element with animation
60
+ */
61
+ highlightElement(selector: string): Promise<ActionResult>;
62
+ /**
63
+ * Execute a custom action callback
64
+ */
65
+ private executeCustomAction;
66
+ /**
67
+ * Check if URL is internal to the current site
68
+ */
69
+ private isInternalUrl;
70
+ /**
71
+ * Try client-side navigation for SPAs
72
+ */
73
+ private tryClientSideNavigation;
74
+ /**
75
+ * Validate navigation URL
76
+ */
77
+ private validateNavigationUrl;
78
+ /**
79
+ * Sanitize CSS selector to prevent injection
80
+ */
81
+ private sanitizeSelector;
82
+ /**
83
+ * Validate custom action is in whitelist
84
+ */
85
+ private isAllowedCustomAction;
86
+ /**
87
+ * Remove highlight overlay
88
+ */
89
+ private removeHighlight;
90
+ /**
91
+ * Inject required styles
92
+ */
93
+ private injectStyles;
94
+ /**
95
+ * Sleep utility
96
+ */
97
+ private sleep;
98
+ /**
99
+ * Get agent configuration
100
+ */
101
+ getConfig(): AgentConfig;
102
+ /**
103
+ * Get the intent classifier
104
+ */
105
+ getClassifier(): CyberneticIntentClassifier;
106
+ /**
107
+ * Reset action count (for testing)
108
+ */
109
+ resetActionCount(): void;
110
+ }
111
+ //# sourceMappingURL=CyberneticAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CyberneticAgent.d.ts","sourceRoot":"","sources":["../../src/agentic/CyberneticAgent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EACR,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACd,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,eAAe,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAU/B;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;IAItD;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAyD/D;;OAEG;IACH,OAAO,CAAC,eAAe;IAkBvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;YACW,QAAQ;IAqEtB;;OAEG;YACW,QAAQ;IAuFtB;;OAEG;YACW,YAAY;IA2D1B;;OAEG;YACW,YAAY;IAI1B;;OAEG;YACW,eAAe;IA6C7B;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAwE/D;;OAEG;YACW,mBAAmB;IA2BjC;;OAEG;IACH,OAAO,CAAC,aAAa;IAoBrB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAqB/B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,YAAY;IA6BpB;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;OAEG;IACH,SAAS,IAAI,WAAW;IAIxB;;OAEG;IACH,aAAa,IAAI,0BAA0B;IAI3C;;OAEG;IACH,gBAAgB,IAAI,IAAI;CAI3B"}
@@ -0,0 +1,78 @@
1
+ import type { IntentClassification, AgentConfig } from './types.js';
2
+ /**
3
+ * Intent classifier for agentic actions
4
+ *
5
+ * Classifies user messages to determine if they should trigger
6
+ * a local DOM action or be sent to the backend RAG.
7
+ */
8
+ export declare class CyberneticIntentClassifier {
9
+ private config;
10
+ private siteMapIndex;
11
+ private formIndex;
12
+ private modalIndex;
13
+ constructor(config: AgentConfig);
14
+ /**
15
+ * Build search indexes from configuration
16
+ */
17
+ private buildIndexes;
18
+ /**
19
+ * Classify user message intent
20
+ *
21
+ * @param message - User's message to classify
22
+ * @returns Classification result with action and confidence
23
+ */
24
+ classify(message: string): IntentClassification;
25
+ /**
26
+ * Build action from pattern match
27
+ */
28
+ private buildAction;
29
+ /**
30
+ * Extract target from regex match
31
+ */
32
+ private extractTarget;
33
+ /**
34
+ * Find site map match for target string
35
+ */
36
+ private findSiteMapMatch;
37
+ /**
38
+ * Fuzzy match against site map for unstructured queries
39
+ */
40
+ private fuzzyMatchSiteMap;
41
+ /**
42
+ * Match custom action keywords
43
+ */
44
+ private matchCustomAction;
45
+ /**
46
+ * Parse form fill intent
47
+ */
48
+ private parseFormIntent;
49
+ /**
50
+ * Find button selector by name
51
+ */
52
+ private findButtonSelector;
53
+ /**
54
+ * Find modal config by name
55
+ */
56
+ private findModalConfig;
57
+ /**
58
+ * Find scroll target selector
59
+ */
60
+ private findScrollTarget;
61
+ /**
62
+ * Find element by description
63
+ */
64
+ private findElementByDescription;
65
+ /**
66
+ * Generate unique selector for an element
67
+ */
68
+ private generateUniqueSelector;
69
+ /**
70
+ * Calculate string similarity (Jaccard index)
71
+ */
72
+ private calculateSimilarity;
73
+ /**
74
+ * Get configuration
75
+ */
76
+ getConfig(): AgentConfig;
77
+ }
78
+ //# sourceMappingURL=CyberneticIntentClassifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CyberneticIntentClassifier.d.ts","sourceRoot":"","sources":["../../src/agentic/CyberneticIntentClassifier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,oBAAoB,EAIpB,WAAW,EACd,MAAM,YAAY,CAAC;AAoCpB;;;;;GAKG;AACH,qBAAa,0BAA0B;IACnC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,UAAU,CAAkC;gBAExC,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACH,OAAO,CAAC,YAAY;IA6CpB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;IA6C/C;;OAEG;IACH,OAAO,CAAC,WAAW;IAwLnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA4BxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAyBzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA0BzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAwC1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqCxB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA4BhC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAgC9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,SAAS,IAAI,WAAW;CAG3B"}
@@ -0,0 +1,13 @@
1
+ export { CyberneticAgent } from './CyberneticAgent.js';
2
+ export { CyberneticIntentClassifier } from './CyberneticIntentClassifier.js';
3
+ export { registerAgenticCapabilities } from './register.js';
4
+ export type { ActionType, AgentAction, ActionResult, IntentClassification, SiteMapEntry, FormFieldConfig, ModalTriggerConfig, AgentConfig } from './types.js';
5
+ export { ClickTool } from './tools/ClickTool.js';
6
+ export type { ClickOptions } from './tools/ClickTool.js';
7
+ export { FillTool } from './tools/FillTool.js';
8
+ export type { FillOptions } from './tools/FillTool.js';
9
+ export { ScrollTool } from './tools/ScrollTool.js';
10
+ export type { ScrollOptions } from './tools/ScrollTool.js';
11
+ export { NavigateTool } from './tools/NavigateTool.js';
12
+ export type { NavigateOptions } from './tools/NavigateTool.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agentic/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAG5D,YAAY,EACR,UAAU,EACV,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,WAAW,EACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { CyberneticClient } from '../CyberneticClient.js';
2
+ /**
3
+ * Register agentic capabilities with a CyberneticClient
4
+ *
5
+ * This function is the bridge between core and agentic modules.
6
+ * It must be called after creating the client to enable agentic features.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { CyberneticClient, registerAgenticCapabilities } from '@astermind/cybernetic-chatbot-client';
11
+ *
12
+ * const client = new CyberneticClient({
13
+ * apiUrl: 'https://api.example.com',
14
+ * apiKey: 'am_xxx_123',
15
+ * agentic: {
16
+ * enabled: true,
17
+ * allowedActions: ['click', 'fill', 'scroll'],
18
+ * confirmActions: true
19
+ * }
20
+ * });
21
+ *
22
+ * // Register agentic capabilities
23
+ * registerAgenticCapabilities(client);
24
+ *
25
+ * // Now client supports agentic responses
26
+ * const response = await client.ask('Click the Add to Cart button');
27
+ * ```
28
+ *
29
+ * @param client - The CyberneticClient instance to register capabilities with
30
+ */
31
+ export declare function registerAgenticCapabilities(client: CyberneticClient): void;
32
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/agentic/register.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAuB,MAAM,wBAAwB,CAAC;AAIpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAM1E"}