@echortech/bot-widget 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +145 -0
  2. package/dist/native/core/api-client.d.ts +57 -0
  3. package/dist/native/core/api-client.d.ts.map +1 -0
  4. package/dist/native/core/api-client.js +196 -0
  5. package/dist/native/core/api-client.js.map +1 -0
  6. package/dist/native/core/index.d.ts +4 -0
  7. package/dist/native/core/index.d.ts.map +1 -0
  8. package/dist/native/core/index.js +5 -0
  9. package/dist/native/core/index.js.map +1 -0
  10. package/dist/native/core/types.d.ts +109 -0
  11. package/dist/native/core/types.d.ts.map +1 -0
  12. package/dist/native/core/types.js +2 -0
  13. package/dist/native/core/types.js.map +1 -0
  14. package/dist/native/core/utils.d.ts +46 -0
  15. package/dist/native/core/utils.d.ts.map +1 -0
  16. package/dist/native/core/utils.js +127 -0
  17. package/dist/native/core/utils.js.map +1 -0
  18. package/dist/native/native/ChatWidget.d.ts +9 -0
  19. package/dist/native/native/ChatWidget.d.ts.map +1 -0
  20. package/dist/native/native/ChatWidget.js +265 -0
  21. package/dist/native/native/ChatWidget.js.map +1 -0
  22. package/dist/native/native/GreetingModal.d.ts +11 -0
  23. package/dist/native/native/GreetingModal.d.ts.map +1 -0
  24. package/dist/native/native/GreetingModal.js +228 -0
  25. package/dist/native/native/GreetingModal.js.map +1 -0
  26. package/dist/native/native/index.d.ts +4 -0
  27. package/dist/native/native/index.d.ts.map +1 -0
  28. package/dist/native/native/index.js +5 -0
  29. package/dist/native/native/index.js.map +1 -0
  30. package/dist/tsconfig.native.tsbuildinfo +1 -0
  31. package/dist/tsconfig.web.tsbuildinfo +1 -0
  32. package/dist/web/core/api-client.d.ts +57 -0
  33. package/dist/web/core/api-client.d.ts.map +1 -0
  34. package/dist/web/core/api-client.js +196 -0
  35. package/dist/web/core/api-client.js.map +1 -0
  36. package/dist/web/core/index.d.ts +4 -0
  37. package/dist/web/core/index.d.ts.map +1 -0
  38. package/dist/web/core/index.js +5 -0
  39. package/dist/web/core/index.js.map +1 -0
  40. package/dist/web/core/types.d.ts +109 -0
  41. package/dist/web/core/types.d.ts.map +1 -0
  42. package/dist/web/core/types.js +2 -0
  43. package/dist/web/core/types.js.map +1 -0
  44. package/dist/web/core/utils.d.ts +46 -0
  45. package/dist/web/core/utils.d.ts.map +1 -0
  46. package/dist/web/core/utils.js +127 -0
  47. package/dist/web/core/utils.js.map +1 -0
  48. package/dist/web/web/ChatWidget.css +240 -0
  49. package/dist/web/web/ChatWidget.d.ts +11 -0
  50. package/dist/web/web/ChatWidget.d.ts.map +1 -0
  51. package/dist/web/web/ChatWidget.js +72 -0
  52. package/dist/web/web/ChatWidget.js.map +1 -0
  53. package/dist/web/web/GreetingPopup.css +224 -0
  54. package/dist/web/web/GreetingPopup.d.ts +12 -0
  55. package/dist/web/web/GreetingPopup.d.ts.map +1 -0
  56. package/dist/web/web/GreetingPopup.js +71 -0
  57. package/dist/web/web/GreetingPopup.js.map +1 -0
  58. package/dist/web/web/index.d.ts +4 -0
  59. package/dist/web/web/index.d.ts.map +1 -0
  60. package/dist/web/web/index.js +5 -0
  61. package/dist/web/web/index.js.map +1 -0
  62. package/native/package.json +4 -0
  63. package/package.json +83 -0
@@ -0,0 +1,196 @@
1
+ import axios from 'axios';
2
+ export class BotAPIClient {
3
+ constructor(baseUrl, jwtToken, firmId) {
4
+ this.baseUrl = baseUrl;
5
+ this.jwtToken = jwtToken;
6
+ this.firmId = firmId;
7
+ this.client = axios.create({
8
+ baseURL: baseUrl,
9
+ timeout: 10000,
10
+ headers: {
11
+ 'Content-Type': 'application/json',
12
+ },
13
+ });
14
+ }
15
+ /**
16
+ * Send a message to the bot and receive a response
17
+ */
18
+ async sendMessage(message, chatId, context) {
19
+ try {
20
+ const request = {
21
+ message,
22
+ chatId,
23
+ context,
24
+ };
25
+ const response = await this.client.post('/chat', request, {
26
+ headers: {
27
+ Authorization: `Bearer ${this.jwtToken}`,
28
+ 'x-firm-id': this.firmId,
29
+ },
30
+ });
31
+ return response.data;
32
+ }
33
+ catch (error) {
34
+ throw this.handleError(error);
35
+ }
36
+ }
37
+ /**
38
+ * Get a proactive greeting based on user's current state
39
+ */
40
+ async getGreeting() {
41
+ try {
42
+ const response = await this.client.post('/greet', {}, {
43
+ headers: {
44
+ Authorization: `Bearer ${this.jwtToken}`,
45
+ 'x-firm-id': this.firmId,
46
+ },
47
+ });
48
+ return response.data;
49
+ }
50
+ catch (error) {
51
+ throw this.handleError(error);
52
+ }
53
+ }
54
+ /**
55
+ * Get list of documents user needs to upload
56
+ */
57
+ async getDocumentsNeeded(chatId) {
58
+ try {
59
+ const response = await this.client.get(`/filing/documents-needed?chatId=${chatId}`, {
60
+ headers: {
61
+ Authorization: `Bearer ${this.jwtToken}`,
62
+ 'x-firm-id': this.firmId,
63
+ },
64
+ });
65
+ return response.data;
66
+ }
67
+ catch (error) {
68
+ throw this.handleError(error);
69
+ }
70
+ }
71
+ /**
72
+ * Get smart form routing based on user's profile
73
+ */
74
+ async getFormPath(chatId) {
75
+ try {
76
+ const response = await this.client.get(`/filing/form-path?chatId=${chatId}`, {
77
+ headers: {
78
+ Authorization: `Bearer ${this.jwtToken}`,
79
+ 'x-firm-id': this.firmId,
80
+ },
81
+ });
82
+ return response.data;
83
+ }
84
+ catch (error) {
85
+ throw this.handleError(error);
86
+ }
87
+ }
88
+ /**
89
+ * Start the 7-question intake questionnaire
90
+ */
91
+ async startIntake() {
92
+ try {
93
+ const response = await this.client.post('/filing/intake/start', {}, {
94
+ headers: {
95
+ Authorization: `Bearer ${this.jwtToken}`,
96
+ 'x-firm-id': this.firmId,
97
+ },
98
+ });
99
+ return response.data;
100
+ }
101
+ catch (error) {
102
+ throw this.handleError(error);
103
+ }
104
+ }
105
+ /**
106
+ * Record an answer and get the next question
107
+ */
108
+ async answerIntakeQuestion(sessionId, answer) {
109
+ try {
110
+ const request = {
111
+ session_id: sessionId,
112
+ answer,
113
+ };
114
+ const response = await this.client.post('/filing/intake/answer', request, {
115
+ headers: {
116
+ Authorization: `Bearer ${this.jwtToken}`,
117
+ 'x-firm-id': this.firmId,
118
+ },
119
+ });
120
+ return response.data;
121
+ }
122
+ catch (error) {
123
+ throw this.handleError(error);
124
+ }
125
+ }
126
+ /**
127
+ * Get completed intake profile
128
+ */
129
+ async getProfile(chatId) {
130
+ try {
131
+ const response = await this.client.get(`/filing/profile?chatId=${chatId}`, {
132
+ headers: {
133
+ Authorization: `Bearer ${this.jwtToken}`,
134
+ 'x-firm-id': this.firmId,
135
+ },
136
+ });
137
+ return response.data;
138
+ }
139
+ catch (error) {
140
+ throw this.handleError(error);
141
+ }
142
+ }
143
+ /**
144
+ * Check bot service and dependencies health
145
+ */
146
+ async healthCheck() {
147
+ try {
148
+ const response = await this.client.get('/health', {
149
+ headers: {
150
+ Authorization: `Bearer ${this.jwtToken}`,
151
+ 'x-firm-id': this.firmId,
152
+ },
153
+ });
154
+ return response.data;
155
+ }
156
+ catch (error) {
157
+ throw this.handleError(error);
158
+ }
159
+ }
160
+ /**
161
+ * Update JWT token (for token refresh scenarios)
162
+ */
163
+ setToken(token) {
164
+ this.jwtToken = token;
165
+ }
166
+ /**
167
+ * Update firm ID
168
+ */
169
+ setFirmId(firmId) {
170
+ this.firmId = firmId;
171
+ }
172
+ /**
173
+ * Handle API errors
174
+ */
175
+ handleError(error) {
176
+ if (axios.isAxiosError(error)) {
177
+ const axiosError = error;
178
+ if (axiosError.response?.data) {
179
+ return axiosError.response.data;
180
+ }
181
+ return {
182
+ detail: axiosError.message || 'Unknown error occurred',
183
+ status_code: axiosError.response?.status || 500,
184
+ retry_after: axiosError.response?.headers['retry-after']
185
+ ? parseInt(axiosError.response.headers['retry-after'])
186
+ : undefined,
187
+ };
188
+ }
189
+ return {
190
+ detail: 'An unexpected error occurred',
191
+ status_code: 500,
192
+ };
193
+ }
194
+ }
195
+ export default BotAPIClient;
196
+ //# sourceMappingURL=api-client.js.map
@@ -0,0 +1 @@
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AM,EAAE,8BAA8B;YACtC,WAAW,EAAE,GAAG;SACjB,CAAC;IACJ,CAAC;CACF;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type { ChatMessage, ChatRequest, ChatResponse, ChatContext, GreetingRequest, GreetingResponse, AlertAction, Document, DocumentsResponse, FormSection, FormPathResponse, IntakeQuestion, IntakeAnswerRequest, UserProfile, HealthCheckResponse, BotAPIError, BotWidgetConfig, } from './types';
2
+ export { BotAPIClient, default } from './api-client';
3
+ export { formatTimestamp, isTokenExpired, getErrorMessage, debounce, throttle, isValidToken, getPriorityColor, getPriorityLabel, truncateText, isMessageTooLong, formatProgress, } from './utils';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,eAAe,GAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Export API client
2
+ export { BotAPIClient, default } from './api-client';
3
+ // Export utilities
4
+ export { formatTimestamp, isTokenExpired, getErrorMessage, debounce, throttle, isValidToken, getPriorityColor, getPriorityLabel, truncateText, isMessageTooLong, formatProgress, } from './utils';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAqBA,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAErD,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC"}
@@ -0,0 +1,109 @@
1
+ export interface ChatMessage {
2
+ role: 'user' | 'assistant' | 'system';
3
+ content: string;
4
+ timestamp?: string;
5
+ toolCalls?: string[];
6
+ responseTimeMs?: number;
7
+ }
8
+ export interface ChatRequest {
9
+ message: string;
10
+ chatId: number;
11
+ context?: ChatContext;
12
+ }
13
+ export interface ChatResponse {
14
+ reply: string;
15
+ toolCalls: string[];
16
+ responseTimeMs: number;
17
+ }
18
+ export interface ChatContext {
19
+ filing_id?: string;
20
+ tax_year?: number;
21
+ }
22
+ export interface GreetingRequest {
23
+ }
24
+ export interface AlertAction {
25
+ label: string;
26
+ type: 'navigate' | 'chat' | 'external';
27
+ target?: string;
28
+ message?: string;
29
+ }
30
+ export interface GreetingResponse {
31
+ greeting: string;
32
+ priority: 1 | 2 | 3 | 4 | 5;
33
+ alert_type: 'action_required' | 'deadline' | 'status' | 'nudge' | 'tip';
34
+ actions: AlertAction[];
35
+ filing_context?: {
36
+ filing_id: string;
37
+ tax_year: number;
38
+ };
39
+ }
40
+ export interface Document {
41
+ type: string;
42
+ priority: number;
43
+ status: 'required' | 'optional';
44
+ description: string;
45
+ count_expected: number;
46
+ count_uploaded: number;
47
+ deadline: string;
48
+ }
49
+ export interface DocumentsResponse {
50
+ documents: Document[];
51
+ overall_progress: string;
52
+ }
53
+ export interface FormSection {
54
+ name: string;
55
+ status: 'completed' | 'in_progress' | 'not_started';
56
+ guidance: string;
57
+ estimated_time_minutes: number;
58
+ }
59
+ export interface FormPathResponse {
60
+ sections: FormSection[];
61
+ }
62
+ export interface IntakeQuestion {
63
+ question_number: number;
64
+ question: string;
65
+ options: string[];
66
+ session_id: string;
67
+ }
68
+ export interface IntakeAnswerRequest {
69
+ session_id: string;
70
+ answer: string;
71
+ }
72
+ export interface UserProfile {
73
+ income_sources: string[];
74
+ dependents: number;
75
+ home_owner: boolean;
76
+ rrsp_contributor: boolean;
77
+ charitable_donor: boolean;
78
+ capital_gains: boolean;
79
+ completed_at: string;
80
+ }
81
+ export interface HealthCheckResponse {
82
+ status: 'healthy' | 'degraded' | 'unhealthy';
83
+ services: {
84
+ vllm: boolean;
85
+ nestjs: boolean;
86
+ supabase: boolean;
87
+ redis: boolean;
88
+ };
89
+ }
90
+ export interface BotAPIError {
91
+ detail: string;
92
+ status_code: number;
93
+ retry_after?: number;
94
+ }
95
+ export interface BotWidgetConfig {
96
+ jwtToken: string;
97
+ firmId: string;
98
+ botUrl: string;
99
+ chatId?: number;
100
+ filingId?: string;
101
+ taxYear?: number;
102
+ theme?: 'light' | 'dark';
103
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
104
+ enableGreeting?: boolean;
105
+ enableChat?: boolean;
106
+ onError?: (error: BotAPIError) => void;
107
+ onSuccess?: (data: any) => void;
108
+ }
109
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,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CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC;IACrE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,46 @@
1
+ import { BotAPIError } from './types';
2
+ /**
3
+ * Format timestamp to readable format
4
+ */
5
+ export declare function formatTimestamp(timestamp: string): string;
6
+ /**
7
+ * Check if token is expired (basic check)
8
+ */
9
+ export declare function isTokenExpired(token: string): boolean;
10
+ /**
11
+ * Handle API error and return user-friendly message
12
+ */
13
+ export declare function getErrorMessage(error: BotAPIError): string;
14
+ /**
15
+ * Debounce function for API calls
16
+ */
17
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
18
+ /**
19
+ * Throttle function for API calls
20
+ */
21
+ export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void;
22
+ /**
23
+ * Validate JWT token format
24
+ */
25
+ export declare function isValidToken(token: string): boolean;
26
+ /**
27
+ * Get priority color
28
+ */
29
+ export declare function getPriorityColor(priority: 1 | 2 | 3 | 4 | 5): string;
30
+ /**
31
+ * Get priority label
32
+ */
33
+ export declare function getPriorityLabel(priority: 1 | 2 | 3 | 4 | 5): string;
34
+ /**
35
+ * Truncate text to specified length
36
+ */
37
+ export declare function truncateText(text: string, length: number): string;
38
+ /**
39
+ * Check if message is too long
40
+ */
41
+ export declare function isMessageTooLong(message: string, maxLength?: number): boolean;
42
+ /**
43
+ * Format progress percentage
44
+ */
45
+ export declare function formatProgress(progress: string): number;
46
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQrD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAsB1D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAYlC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAUlC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAUpE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAUpE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,OAAO,CAEnF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGvD"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Format timestamp to readable format
3
+ */
4
+ export function formatTimestamp(timestamp) {
5
+ const date = new Date(timestamp);
6
+ return date.toLocaleTimeString('en-US', {
7
+ hour: 'numeric',
8
+ minute: '2-digit',
9
+ hour12: true,
10
+ });
11
+ }
12
+ /**
13
+ * Check if token is expired (basic check)
14
+ */
15
+ export function isTokenExpired(token) {
16
+ try {
17
+ const payload = JSON.parse(atob(token.split('.')[1]));
18
+ const expirationTime = payload.exp * 1000;
19
+ return Date.now() > expirationTime;
20
+ }
21
+ catch {
22
+ return true;
23
+ }
24
+ }
25
+ /**
26
+ * Handle API error and return user-friendly message
27
+ */
28
+ export function getErrorMessage(error) {
29
+ const statusCode = error.status_code;
30
+ if (statusCode === 401) {
31
+ return 'Your session expired. Please log in again.';
32
+ }
33
+ if (statusCode === 429) {
34
+ const retryAfter = error.retry_after || 3600;
35
+ const minutes = Math.ceil(retryAfter / 60);
36
+ return `Too many requests. Please try again in ${minutes} minute${minutes > 1 ? 's' : ''}.`;
37
+ }
38
+ if (statusCode === 503) {
39
+ return 'Bot service is temporarily unavailable. Please try again later.';
40
+ }
41
+ if (statusCode === 400) {
42
+ return 'Invalid request. Please check your input.';
43
+ }
44
+ return error.detail || 'An error occurred. Please try again.';
45
+ }
46
+ /**
47
+ * Debounce function for API calls
48
+ */
49
+ export function debounce(func, wait) {
50
+ let timeout;
51
+ return function executedFunction(...args) {
52
+ const later = () => {
53
+ clearTimeout(timeout);
54
+ func(...args);
55
+ };
56
+ clearTimeout(timeout);
57
+ timeout = setTimeout(later, wait);
58
+ };
59
+ }
60
+ /**
61
+ * Throttle function for API calls
62
+ */
63
+ export function throttle(func, limit) {
64
+ let inThrottle;
65
+ return function executedFunction(...args) {
66
+ if (!inThrottle) {
67
+ func(...args);
68
+ inThrottle = true;
69
+ setTimeout(() => (inThrottle = false), limit);
70
+ }
71
+ };
72
+ }
73
+ /**
74
+ * Validate JWT token format
75
+ */
76
+ export function isValidToken(token) {
77
+ const parts = token.split('.');
78
+ return parts.length === 3;
79
+ }
80
+ /**
81
+ * Get priority color
82
+ */
83
+ export function getPriorityColor(priority) {
84
+ const colors = {
85
+ 1: '#dc2626', // red - urgent
86
+ 2: '#f59e0b', // amber - high
87
+ 3: '#3b82f6', // blue - medium
88
+ 4: '#10b981', // green - low
89
+ 5: '#6b7280', // gray - info
90
+ };
91
+ return colors[priority] || colors[3];
92
+ }
93
+ /**
94
+ * Get priority label
95
+ */
96
+ export function getPriorityLabel(priority) {
97
+ const labels = {
98
+ 1: 'Urgent',
99
+ 2: 'High',
100
+ 3: 'Medium',
101
+ 4: 'Low',
102
+ 5: 'Info',
103
+ };
104
+ return labels[priority] || labels[3];
105
+ }
106
+ /**
107
+ * Truncate text to specified length
108
+ */
109
+ export function truncateText(text, length) {
110
+ if (text.length <= length)
111
+ return text;
112
+ return text.substring(0, length) + '...';
113
+ }
114
+ /**
115
+ * Check if message is too long
116
+ */
117
+ export function isMessageTooLong(message, maxLength = 2000) {
118
+ return message.length > maxLength;
119
+ }
120
+ /**
121
+ * Format progress percentage
122
+ */
123
+ export function formatProgress(progress) {
124
+ const match = progress.match(/(\d+)%/);
125
+ return match ? parseInt(match[1]) : 0;
126
+ }
127
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/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