@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
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # Spirit Bot Widget
2
+
3
+ A type-safe widget library for integrating Spirit Bot into React and React Native applications. Published as a single package with platform-specific exports.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @echortech/bot-widget
9
+ ```
10
+
11
+ **Peer dependencies** (install what your platform needs):
12
+ ```bash
13
+ # Web
14
+ npm install react react-dom
15
+
16
+ # Mobile
17
+ npm install react react-native
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### React (Web)
23
+
24
+ ```tsx
25
+ import { ChatWidget, GreetingPopup } from '@echortech/bot-widget';
26
+
27
+ export function App() {
28
+ return (
29
+ <ChatWidget
30
+ jwtToken={userToken}
31
+ firmId={firmId}
32
+ botUrl="https://spirit-bot-service.example.com"
33
+ onError={(err) => console.error(err)}
34
+ />
35
+ );
36
+ }
37
+ ```
38
+
39
+ ### React Native (Mobile)
40
+
41
+ ```tsx
42
+ import { ChatWidget, GreetingModal } from '@echortech/bot-widget/native';
43
+
44
+ export function App() {
45
+ return (
46
+ <ChatWidget
47
+ jwtToken={userToken}
48
+ firmId={firmId}
49
+ botUrl="https://spirit-bot-service.example.com"
50
+ height={500}
51
+ onError={(err) => console.error(err)}
52
+ />
53
+ );
54
+ }
55
+ ```
56
+
57
+ ### Core Only (API Client / Types)
58
+
59
+ ```ts
60
+ import { BotAPIClient } from '@echortech/bot-widget/core';
61
+
62
+ const client = new BotAPIClient(botUrl, jwtToken, firmId);
63
+ const response = await client.sendMessage('Hello', chatId);
64
+ ```
65
+
66
+ ## Exports
67
+
68
+ | Import Path | What You Get |
69
+ |-------------|-------------|
70
+ | `@echortech/bot-widget` | React web components + core (types, API client, utils) |
71
+ | `@echortech/bot-widget/native` | React Native components + core |
72
+ | `@echortech/bot-widget/core` | Core only (types, BotAPIClient, utilities) |
73
+
74
+ ## Components
75
+
76
+ ### Web (`@echortech/bot-widget`)
77
+
78
+ - **`ChatWidget`** — Full chat interface with message history, auto-scroll, loading states, error display
79
+ - **`GreetingPopup`** — Contextual greeting notifications with priority badges and action buttons
80
+
81
+ ### Mobile (`@echortech/bot-widget/native`)
82
+
83
+ - **`ChatWidget`** — Mobile-optimized chat with `KeyboardAvoidingView` and gesture-friendly input
84
+ - **`GreetingModal`** — Modal-based greeting with `TouchableOpacity` actions
85
+
86
+ ### Configuration (All Components)
87
+
88
+ ```typescript
89
+ interface BotWidgetConfig {
90
+ jwtToken: string; // JWT token for authentication
91
+ firmId: string; // Firm ID header
92
+ botUrl: string; // Base URL of Spirit Bot Service
93
+ chatId?: number; // Chat session ID (default: 1001)
94
+ filingId?: string; // Optional filing context
95
+ taxYear?: number; // Optional tax year context
96
+ onError?: (error: BotAPIError) => void;
97
+ onSuccess?: (response: any) => void;
98
+ }
99
+ ```
100
+
101
+ ## API Client
102
+
103
+ The `BotAPIClient` handles all HTTP communication with the Spirit Bot Service:
104
+
105
+ | Method | Endpoint | Description |
106
+ |--------|----------|-------------|
107
+ | `sendMessage(message, chatId, context?)` | `POST /chat` | Send message, get bot response |
108
+ | `getGreeting()` | `POST /greet` | Get contextual greeting |
109
+ | `getDocumentsNeeded(chatId)` | `GET /filing/documents-needed` | List required documents |
110
+ | `getFormPath(chatId)` | `GET /filing/form-path` | Get smart form structure |
111
+ | `startIntake()` | `POST /filing/intake/start` | Start intake questionnaire |
112
+ | `answerIntakeQuestion(sessionId, answer)` | `POST /filing/intake/answer` | Answer intake question |
113
+ | `getProfile(chatId)` | `GET /filing/profile` | Get user profile |
114
+ | `healthCheck()` | `GET /health` | Service health check |
115
+
116
+ **Authentication**: JWT token in `Authorization: Bearer` header, firm ID in `x-firm-id` header — handled automatically.
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ pnpm install # Install dependencies
122
+ pnpm build # Build web + native
123
+ pnpm build:web # Build web only
124
+ pnpm build:native # Build native only
125
+ pnpm test # Run all tests (vitest + jest)
126
+ pnpm test:web # Run web + core tests only
127
+ pnpm test:native # Run React Native tests only
128
+ pnpm type-check # TypeScript type checking
129
+ pnpm dev # Watch mode
130
+ ```
131
+
132
+ ## Project Structure
133
+
134
+ ```
135
+ src/
136
+ core/ # Types, BotAPIClient, utility functions (shared by both platforms)
137
+ web/ # React components + CSS (ChatWidget, GreetingPopup)
138
+ native/ # React Native components (ChatWidget, GreetingModal)
139
+ ```
140
+
141
+ Both platforms compile separately (`tsconfig.web.json` / `tsconfig.native.json`) to handle different JSX modes, then output to `dist/web/` and `dist/native/`.
142
+
143
+ ## License
144
+
145
+ MIT
@@ -0,0 +1,57 @@
1
+ import { ChatResponse, GreetingResponse, DocumentsResponse, FormPathResponse, IntakeQuestion, UserProfile, HealthCheckResponse } from './types';
2
+ export declare class BotAPIClient {
3
+ private client;
4
+ private baseUrl;
5
+ private jwtToken;
6
+ private firmId;
7
+ constructor(baseUrl: string, jwtToken: string, firmId: string);
8
+ /**
9
+ * Send a message to the bot and receive a response
10
+ */
11
+ sendMessage(message: string, chatId: number, context?: {
12
+ filing_id?: string;
13
+ tax_year?: number;
14
+ }): Promise<ChatResponse>;
15
+ /**
16
+ * Get a proactive greeting based on user's current state
17
+ */
18
+ getGreeting(): Promise<GreetingResponse>;
19
+ /**
20
+ * Get list of documents user needs to upload
21
+ */
22
+ getDocumentsNeeded(chatId: number): Promise<DocumentsResponse>;
23
+ /**
24
+ * Get smart form routing based on user's profile
25
+ */
26
+ getFormPath(chatId: number): Promise<FormPathResponse>;
27
+ /**
28
+ * Start the 7-question intake questionnaire
29
+ */
30
+ startIntake(): Promise<IntakeQuestion>;
31
+ /**
32
+ * Record an answer and get the next question
33
+ */
34
+ answerIntakeQuestion(sessionId: string, answer: string): Promise<IntakeQuestion>;
35
+ /**
36
+ * Get completed intake profile
37
+ */
38
+ getProfile(chatId: number): Promise<UserProfile>;
39
+ /**
40
+ * Check bot service and dependencies health
41
+ */
42
+ healthCheck(): Promise<HealthCheckResponse>;
43
+ /**
44
+ * Update JWT token (for token refresh scenarios)
45
+ */
46
+ setToken(token: string): void;
47
+ /**
48
+ * Update firm ID
49
+ */
50
+ setFirmId(firmId: string): void;
51
+ /**
52
+ * Handle API errors
53
+ */
54
+ private handleError;
55
+ }
56
+ export default BotAPIClient;
57
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/core/api-client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EAEd,WAAW,EACX,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAEjB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAc7D;;OAEG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAClD,OAAO,CAAC,YAAY,CAAC;IAqBxB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAmB9C;;OAEG;IACG,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAkBpE;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkB5D;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;IAmB5C;;OAEG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC;IAwB1B;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAkBtD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAejD;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,OAAO,CAAC,WAAW;CAsBpB;AAED,eAAe,YAAY,CAAC"}
@@ -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 @@
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../src/core/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAczD,MAAM,OAAO,YAAY;IAMvB,YAAY,OAAe,EAAE,QAAgB,EAAE,MAAc;QAC3D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,OAAe,EACf,MAAc,EACd,OAAmD;QAEnD,IAAI,CAAC;YACH,MAAM,OAAO,GAAgB;gBAC3B,OAAO;gBACP,MAAM;gBACN,OAAO;aACR,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAe,OAAO,EAAE,OAAO,EAAE;gBACtE,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,IAAI,CAAC,QAAQ,EAAE;oBACxC,WAAW,EAAE,IAAI,CAAC,MAAM;iBACzB;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,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EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG;gBAC/C,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC;oBACtD,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;oBACtD,CAAC,CAAC,SAAS;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,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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H;AAGD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,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,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