@haylee-ai/chat-sdk 1.0.1

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/README.md ADDED
@@ -0,0 +1,2051 @@
1
+ # Haylee AI Chat SDK
2
+
3
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.6-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
4
+ [![npm version](https://img.shields.io/npm/v/@haylee-ai/chat-sdk.svg)](https://www.npmjs.com/package/@haylee-ai/chat-sdk)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
7
+ [![ESM](https://img.shields.io/badge/ESM-✓-black?logo=javascript)](https://nodejs.org/api/esm.html)
8
+
9
+ ## Getting Started
10
+
11
+ ### Installation
12
+
13
+ ```bash
14
+ npm install @haylee-ai/chat-sdk
15
+ # or
16
+ pnpm add @haylee-ai/chat-sdk
17
+ # or
18
+ yarn add @haylee-ai/chat-sdk
19
+ ```
20
+
21
+ ### Setup
22
+
23
+ Create a client with your API key. You can optionally specify a custom `baseUrl` (defaults to `http://localhost:3000/api/v1/chat`):
24
+
25
+ ```typescript
26
+ import { HayleeAI } from "@haylee-ai/chat-sdk";
27
+
28
+ const client = new HayleeAI({
29
+ baseUrl: "http://localhost:3000/api/v1/chat", // optional
30
+ });
31
+ ```
32
+
33
+ ### Basic Usage
34
+
35
+ Stream a message with optional conversation history:
36
+
37
+ ```typescript
38
+ await client.messages.stream(
39
+ {
40
+ message: "What are my latest campaigns?",
41
+ conversation_history: [
42
+ { role: "human", content: "Hello" },
43
+ { role: "ai", content: "Hi! How can I help with Meta Marketing?" },
44
+ ],
45
+ },
46
+ {
47
+ onLlmToken: (ev) => {
48
+ const text = ev.content?.[0]?.text ?? "";
49
+ if (text) process.stdout.write(text);
50
+ },
51
+ onSearchUpdate: (ev) => {
52
+ console.log("Search:", ev.content?.query, ev.status);
53
+ },
54
+ onError: (err) => {
55
+ console.error("Stream error:", err);
56
+ },
57
+ signal: abortController.signal,
58
+ }
59
+ );
60
+ ```
61
+
62
+
63
+ <a name="readmemd"></a>
64
+
65
+ **@haylee-ai/chat-sdk v1.0.0**
66
+
67
+ ***
68
+
69
+ # @haylee-ai/chat-sdk v1.0.0
70
+
71
+ ## Enumerations
72
+
73
+ - [EventKind](#enumerationseventkindmd)
74
+ - [Role](#enumerationsrolemd)
75
+ - [ToolStatus](#enumerationstoolstatusmd)
76
+
77
+ ## Classes
78
+
79
+ - [AuthenticationError](#classesauthenticationerrormd)
80
+ - [AuthorizationError](#classesauthorizationerrormd)
81
+ - [BaseEvent](#classesbaseeventmd)
82
+ - [CreateMessageDto](#classescreatemessagedtomd)
83
+ - [EndEvent](#classesendeventmd)
84
+ - [HayleeAI](#classeshayleeaimd)
85
+ - [HayleeAIClient](#classeshayleeaiclientmd)
86
+ - [HayleeAIError](#classeshayleeaierrormd)
87
+ - [IHistoryPayload](#classesihistorypayloadmd)
88
+ - [LlmTokenContent](#classesllmtokencontentmd)
89
+ - [LlmTokenEvent](#classesllmtokeneventmd)
90
+ - [MessageService](#classesmessageservicemd)
91
+ - [NotFoundError](#classesnotfounderrormd)
92
+ - [ValidationError](#classesvalidationerrormd)
93
+
94
+ ## Interfaces
95
+
96
+ - [MessageServiceOptions](#interfacesmessageserviceoptionsmd)
97
+ - [ToolContent](#interfacestoolcontentmd)
98
+ - [ToolEvent](#interfacestooleventmd)
99
+ - [ToolResultContent](#interfacestoolresultcontentmd)
100
+
101
+ ## Type Aliases
102
+
103
+ - [HayleeAIChatClientOptions](#type-aliaseshayleeaichatclientoptionsmd)
104
+
105
+
106
+ <a name="classesauthenticationerrormd"></a>
107
+
108
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
109
+
110
+ ***
111
+
112
+ [@haylee-ai/chat-sdk](#readmemd) / AuthenticationError
113
+
114
+ # Class: AuthenticationError
115
+
116
+ Defined in: src/errors/authentication.error.ts:3
117
+
118
+ ## Extends
119
+
120
+ - [`HayleeAIError`](#classeshayleeaierrormd)
121
+
122
+ ## Constructors
123
+
124
+ ### Constructor
125
+
126
+ > **new AuthenticationError**(`message`): `AuthenticationError`
127
+
128
+ Defined in: src/errors/authentication.error.ts:6
129
+
130
+ #### Parameters
131
+
132
+ ##### message
133
+
134
+ `string`
135
+
136
+ #### Returns
137
+
138
+ `AuthenticationError`
139
+
140
+ #### Overrides
141
+
142
+ [`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)
143
+
144
+ ## Properties
145
+
146
+ ### cause?
147
+
148
+ > `optional` **cause**: `unknown`
149
+
150
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
151
+
152
+ #### Inherited from
153
+
154
+ [`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)
155
+
156
+ ***
157
+
158
+ ### message
159
+
160
+ > **message**: `string`
161
+
162
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
163
+
164
+ #### Inherited from
165
+
166
+ [`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)
167
+
168
+ ***
169
+
170
+ ### name
171
+
172
+ > `readonly` **name**: `string` = `"AuthenticationError"`
173
+
174
+ Defined in: src/errors/authentication.error.ts:4
175
+
176
+ #### Overrides
177
+
178
+ [`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)
179
+
180
+ ***
181
+
182
+ ### stack?
183
+
184
+ > `optional` **stack**: `string`
185
+
186
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
187
+
188
+ #### Inherited from
189
+
190
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)
191
+
192
+ ***
193
+
194
+ ### stackTraceLimit
195
+
196
+ > `static` **stackTraceLimit**: `number`
197
+
198
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68
199
+
200
+ The `Error.stackTraceLimit` property specifies the number of stack frames
201
+ collected by a stack trace (whether generated by `new Error().stack` or
202
+ `Error.captureStackTrace(obj)`).
203
+
204
+ The default value is `10` but may be set to any valid JavaScript number. Changes
205
+ will affect any stack trace captured _after_ the value has been changed.
206
+
207
+ If set to a non-number value, or set to a negative number, stack traces will
208
+ not capture any frames.
209
+
210
+ #### Inherited from
211
+
212
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)
213
+
214
+ ## Methods
215
+
216
+ ### captureStackTrace()
217
+
218
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
219
+
220
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52
221
+
222
+ Creates a `.stack` property on `targetObject`, which when accessed returns
223
+ a string representing the location in the code at which
224
+ `Error.captureStackTrace()` was called.
225
+
226
+ ```js
227
+ const myObject = {};
228
+ Error.captureStackTrace(myObject);
229
+ myObject.stack; // Similar to `new Error().stack`
230
+ ```
231
+
232
+ The first line of the trace will be prefixed with
233
+ `${myObject.name}: ${myObject.message}`.
234
+
235
+ The optional `constructorOpt` argument accepts a function. If given, all frames
236
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
237
+ generated stack trace.
238
+
239
+ The `constructorOpt` argument is useful for hiding implementation
240
+ details of error generation from the user. For instance:
241
+
242
+ ```js
243
+ function a() {
244
+ b();
245
+ }
246
+
247
+ function b() {
248
+ c();
249
+ }
250
+
251
+ function c() {
252
+ // Create an error without stack trace to avoid calculating the stack trace twice.
253
+ const { stackTraceLimit } = Error;
254
+ Error.stackTraceLimit = 0;
255
+ const error = new Error();
256
+ Error.stackTraceLimit = stackTraceLimit;
257
+
258
+ // Capture the stack trace above function b
259
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
260
+ throw error;
261
+ }
262
+
263
+ a();
264
+ ```
265
+
266
+ #### Parameters
267
+
268
+ ##### targetObject
269
+
270
+ `object`
271
+
272
+ ##### constructorOpt?
273
+
274
+ `Function`
275
+
276
+ #### Returns
277
+
278
+ `void`
279
+
280
+ #### Inherited from
281
+
282
+ [`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)
283
+
284
+ ***
285
+
286
+ ### prepareStackTrace()
287
+
288
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
289
+
290
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56
291
+
292
+ #### Parameters
293
+
294
+ ##### err
295
+
296
+ `Error`
297
+
298
+ ##### stackTraces
299
+
300
+ `CallSite`[]
301
+
302
+ #### Returns
303
+
304
+ `any`
305
+
306
+ #### See
307
+
308
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
309
+
310
+ #### Inherited from
311
+
312
+ [`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)
313
+
314
+
315
+ <a name="classesauthorizationerrormd"></a>
316
+
317
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
318
+
319
+ ***
320
+
321
+ [@haylee-ai/chat-sdk](#readmemd) / AuthorizationError
322
+
323
+ # Class: AuthorizationError
324
+
325
+ Defined in: src/errors/authorization.error.ts:3
326
+
327
+ ## Extends
328
+
329
+ - [`HayleeAIError`](#classeshayleeaierrormd)
330
+
331
+ ## Constructors
332
+
333
+ ### Constructor
334
+
335
+ > **new AuthorizationError**(`message`): `AuthorizationError`
336
+
337
+ Defined in: src/errors/authorization.error.ts:6
338
+
339
+ #### Parameters
340
+
341
+ ##### message
342
+
343
+ `string`
344
+
345
+ #### Returns
346
+
347
+ `AuthorizationError`
348
+
349
+ #### Overrides
350
+
351
+ [`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)
352
+
353
+ ## Properties
354
+
355
+ ### cause?
356
+
357
+ > `optional` **cause**: `unknown`
358
+
359
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
360
+
361
+ #### Inherited from
362
+
363
+ [`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)
364
+
365
+ ***
366
+
367
+ ### message
368
+
369
+ > **message**: `string`
370
+
371
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
372
+
373
+ #### Inherited from
374
+
375
+ [`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)
376
+
377
+ ***
378
+
379
+ ### name
380
+
381
+ > `readonly` **name**: `string` = `"AuthorizationError"`
382
+
383
+ Defined in: src/errors/authorization.error.ts:4
384
+
385
+ #### Overrides
386
+
387
+ [`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)
388
+
389
+ ***
390
+
391
+ ### stack?
392
+
393
+ > `optional` **stack**: `string`
394
+
395
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
396
+
397
+ #### Inherited from
398
+
399
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)
400
+
401
+ ***
402
+
403
+ ### stackTraceLimit
404
+
405
+ > `static` **stackTraceLimit**: `number`
406
+
407
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68
408
+
409
+ The `Error.stackTraceLimit` property specifies the number of stack frames
410
+ collected by a stack trace (whether generated by `new Error().stack` or
411
+ `Error.captureStackTrace(obj)`).
412
+
413
+ The default value is `10` but may be set to any valid JavaScript number. Changes
414
+ will affect any stack trace captured _after_ the value has been changed.
415
+
416
+ If set to a non-number value, or set to a negative number, stack traces will
417
+ not capture any frames.
418
+
419
+ #### Inherited from
420
+
421
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)
422
+
423
+ ## Methods
424
+
425
+ ### captureStackTrace()
426
+
427
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
428
+
429
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52
430
+
431
+ Creates a `.stack` property on `targetObject`, which when accessed returns
432
+ a string representing the location in the code at which
433
+ `Error.captureStackTrace()` was called.
434
+
435
+ ```js
436
+ const myObject = {};
437
+ Error.captureStackTrace(myObject);
438
+ myObject.stack; // Similar to `new Error().stack`
439
+ ```
440
+
441
+ The first line of the trace will be prefixed with
442
+ `${myObject.name}: ${myObject.message}`.
443
+
444
+ The optional `constructorOpt` argument accepts a function. If given, all frames
445
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
446
+ generated stack trace.
447
+
448
+ The `constructorOpt` argument is useful for hiding implementation
449
+ details of error generation from the user. For instance:
450
+
451
+ ```js
452
+ function a() {
453
+ b();
454
+ }
455
+
456
+ function b() {
457
+ c();
458
+ }
459
+
460
+ function c() {
461
+ // Create an error without stack trace to avoid calculating the stack trace twice.
462
+ const { stackTraceLimit } = Error;
463
+ Error.stackTraceLimit = 0;
464
+ const error = new Error();
465
+ Error.stackTraceLimit = stackTraceLimit;
466
+
467
+ // Capture the stack trace above function b
468
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
469
+ throw error;
470
+ }
471
+
472
+ a();
473
+ ```
474
+
475
+ #### Parameters
476
+
477
+ ##### targetObject
478
+
479
+ `object`
480
+
481
+ ##### constructorOpt?
482
+
483
+ `Function`
484
+
485
+ #### Returns
486
+
487
+ `void`
488
+
489
+ #### Inherited from
490
+
491
+ [`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)
492
+
493
+ ***
494
+
495
+ ### prepareStackTrace()
496
+
497
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
498
+
499
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56
500
+
501
+ #### Parameters
502
+
503
+ ##### err
504
+
505
+ `Error`
506
+
507
+ ##### stackTraces
508
+
509
+ `CallSite`[]
510
+
511
+ #### Returns
512
+
513
+ `any`
514
+
515
+ #### See
516
+
517
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
518
+
519
+ #### Inherited from
520
+
521
+ [`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)
522
+
523
+
524
+ <a name="classesbaseeventmd"></a>
525
+
526
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
527
+
528
+ ***
529
+
530
+ [@haylee-ai/chat-sdk](#readmemd) / BaseEvent
531
+
532
+ # Class: BaseEvent
533
+
534
+ Defined in: src/messages/types.ts:12
535
+
536
+ Base event for Streaming
537
+ BaseEvent
538
+
539
+ ## Extended by
540
+
541
+ - [`LlmTokenEvent`](#classesllmtokeneventmd)
542
+ - [`ToolEvent`](#interfacestooleventmd)
543
+
544
+ ## Constructors
545
+
546
+ ### Constructor
547
+
548
+ > **new BaseEvent**(): `BaseEvent`
549
+
550
+ #### Returns
551
+
552
+ `BaseEvent`
553
+
554
+ ## Properties
555
+
556
+ ### kind
557
+
558
+ > **kind**: [`EventKind`](#enumerationseventkindmd)
559
+
560
+ Defined in: src/messages/types.ts:16
561
+
562
+ Used to separate streams
563
+
564
+ ***
565
+
566
+ ### node
567
+
568
+ > **node**: `string`
569
+
570
+ Defined in: src/messages/types.ts:20
571
+
572
+ Source node in langgraph
573
+
574
+
575
+ <a name="classescreatemessagedtomd"></a>
576
+
577
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
578
+
579
+ ***
580
+
581
+ [@haylee-ai/chat-sdk](#readmemd) / CreateMessageDto
582
+
583
+ # Class: CreateMessageDto
584
+
585
+ Defined in: src/types/chat.interface.ts:8
586
+
587
+ DTO for creating a message
588
+
589
+ ## Constructors
590
+
591
+ ### Constructor
592
+
593
+ > **new CreateMessageDto**(): `CreateMessageDto`
594
+
595
+ #### Returns
596
+
597
+ `CreateMessageDto`
598
+
599
+ ## Properties
600
+
601
+ ### conversation\_history
602
+
603
+ > **conversation\_history**: [`IHistoryPayload`](#classesihistorypayloadmd)[]
604
+
605
+ Defined in: src/types/chat.interface.ts:13
606
+
607
+ Array of messages
608
+
609
+ ***
610
+
611
+ ### message
612
+
613
+ > **message**: `string`
614
+
615
+ Defined in: src/types/chat.interface.ts:11
616
+
617
+ User message
618
+
619
+
620
+ <a name="classesendeventmd"></a>
621
+
622
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
623
+
624
+ ***
625
+
626
+ [@haylee-ai/chat-sdk](#readmemd) / EndEvent
627
+
628
+ # Class: EndEvent
629
+
630
+ Defined in: src/messages/types.ts:49
631
+
632
+ ## Constructors
633
+
634
+ ### Constructor
635
+
636
+ > **new EndEvent**(): `EndEvent`
637
+
638
+ #### Returns
639
+
640
+ `EndEvent`
641
+
642
+ ## Properties
643
+
644
+ ### success
645
+
646
+ > **success**: `boolean`
647
+
648
+ Defined in: src/messages/types.ts:50
649
+
650
+
651
+ <a name="classeshayleeaimd"></a>
652
+
653
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
654
+
655
+ ***
656
+
657
+ [@haylee-ai/chat-sdk](#readmemd) / HayleeAI
658
+
659
+ # Class: HayleeAI
660
+
661
+ Defined in: src/index.ts:7
662
+
663
+ Instantiate a new HayleeAI connection
664
+
665
+ ## Extends
666
+
667
+ - [`HayleeAIClient`](#classeshayleeaiclientmd)
668
+
669
+ ## Constructors
670
+
671
+ ### Constructor
672
+
673
+ > **new HayleeAI**(`options`): `HayleeAI`
674
+
675
+ Defined in: src/index.ts:13
676
+
677
+ #### Parameters
678
+
679
+ ##### options
680
+
681
+ [`HayleeAIChatClientOptions`](#type-aliaseshayleeaichatclientoptionsmd)
682
+
683
+ HayleeAIChatClientOptions
684
+
685
+ #### Returns
686
+
687
+ `HayleeAI`
688
+
689
+ #### Overrides
690
+
691
+ [`HayleeAIClient`](#classeshayleeaiclientmd).[`constructor`](#constructor)
692
+
693
+ ## Properties
694
+
695
+ ### messages
696
+
697
+ > **messages**: [`MessageService`](#classesmessageservicemd)
698
+
699
+ Defined in: src/index.ts:8
700
+
701
+ ## Methods
702
+
703
+ ### \_stream()
704
+
705
+ > **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>
706
+
707
+ Defined in: src/\_internal/client.ts:35
708
+
709
+ Internal stream callout
710
+
711
+ #### Parameters
712
+
713
+ ##### payload
714
+
715
+ [`CreateMessageDto`](#classescreatemessagedtomd)
716
+
717
+ Message DTO
718
+
719
+ ##### signal?
720
+
721
+ `AbortSignal`
722
+
723
+ Abort signal
724
+
725
+ #### Returns
726
+
727
+ `AsyncGenerator`\<`string`, `void`, `unknown`\>
728
+
729
+ #### Inherited from
730
+
731
+ [`HayleeAIClient`](#classeshayleeaiclientmd).[`_stream`](#_stream)
732
+
733
+
734
+ <a name="classeshayleeaiclientmd"></a>
735
+
736
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
737
+
738
+ ***
739
+
740
+ [@haylee-ai/chat-sdk](#readmemd) / HayleeAIClient
741
+
742
+ # Class: HayleeAIClient
743
+
744
+ Defined in: src/\_internal/client.ts:18
745
+
746
+ Internal HayleeAI Client. Do not use unless necessary.
747
+ HayleeAIClient
748
+
749
+ ## Extended by
750
+
751
+ - [`HayleeAI`](#classeshayleeaimd)
752
+
753
+ ## Constructors
754
+
755
+ ### Constructor
756
+
757
+ > **new HayleeAIClient**(`options`): `HayleeAIClient`
758
+
759
+ Defined in: src/\_internal/client.ts:26
760
+
761
+ #### Parameters
762
+
763
+ ##### options
764
+
765
+ [`HayleeAIChatClientOptions`](#type-aliaseshayleeaichatclientoptionsmd)
766
+
767
+ Auth, and baseURL
768
+
769
+ #### Returns
770
+
771
+ `HayleeAIClient`
772
+
773
+ ## Methods
774
+
775
+ ### \_stream()
776
+
777
+ > **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>
778
+
779
+ Defined in: src/\_internal/client.ts:35
780
+
781
+ Internal stream callout
782
+
783
+ #### Parameters
784
+
785
+ ##### payload
786
+
787
+ [`CreateMessageDto`](#classescreatemessagedtomd)
788
+
789
+ Message DTO
790
+
791
+ ##### signal?
792
+
793
+ `AbortSignal`
794
+
795
+ Abort signal
796
+
797
+ #### Returns
798
+
799
+ `AsyncGenerator`\<`string`, `void`, `unknown`\>
800
+
801
+
802
+ <a name="classeshayleeaierrormd"></a>
803
+
804
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
805
+
806
+ ***
807
+
808
+ [@haylee-ai/chat-sdk](#readmemd) / HayleeAIError
809
+
810
+ # Class: HayleeAIError
811
+
812
+ Defined in: src/errors/base.ts:1
813
+
814
+ ## Extends
815
+
816
+ - `Error`
817
+
818
+ ## Extended by
819
+
820
+ - [`ValidationError`](#classesvalidationerrormd)
821
+ - [`NotFoundError`](#classesnotfounderrormd)
822
+ - [`AuthorizationError`](#classesauthorizationerrormd)
823
+ - [`AuthenticationError`](#classesauthenticationerrormd)
824
+
825
+ ## Constructors
826
+
827
+ ### Constructor
828
+
829
+ > **new HayleeAIError**(`message`): `HayleeAIError`
830
+
831
+ Defined in: src/errors/base.ts:4
832
+
833
+ #### Parameters
834
+
835
+ ##### message
836
+
837
+ `string`
838
+
839
+ #### Returns
840
+
841
+ `HayleeAIError`
842
+
843
+ #### Overrides
844
+
845
+ `Error.constructor`
846
+
847
+ ## Properties
848
+
849
+ ### cause?
850
+
851
+ > `optional` **cause**: `unknown`
852
+
853
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
854
+
855
+ #### Inherited from
856
+
857
+ `Error.cause`
858
+
859
+ ***
860
+
861
+ ### message
862
+
863
+ > **message**: `string`
864
+
865
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
866
+
867
+ #### Inherited from
868
+
869
+ `Error.message`
870
+
871
+ ***
872
+
873
+ ### name
874
+
875
+ > `readonly` **name**: `string` = `"HayleeAIError"`
876
+
877
+ Defined in: src/errors/base.ts:2
878
+
879
+ #### Overrides
880
+
881
+ `Error.name`
882
+
883
+ ***
884
+
885
+ ### stack?
886
+
887
+ > `optional` **stack**: `string`
888
+
889
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
890
+
891
+ #### Inherited from
892
+
893
+ `Error.stack`
894
+
895
+ ***
896
+
897
+ ### stackTraceLimit
898
+
899
+ > `static` **stackTraceLimit**: `number`
900
+
901
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68
902
+
903
+ The `Error.stackTraceLimit` property specifies the number of stack frames
904
+ collected by a stack trace (whether generated by `new Error().stack` or
905
+ `Error.captureStackTrace(obj)`).
906
+
907
+ The default value is `10` but may be set to any valid JavaScript number. Changes
908
+ will affect any stack trace captured _after_ the value has been changed.
909
+
910
+ If set to a non-number value, or set to a negative number, stack traces will
911
+ not capture any frames.
912
+
913
+ #### Inherited from
914
+
915
+ `Error.stackTraceLimit`
916
+
917
+ ## Methods
918
+
919
+ ### captureStackTrace()
920
+
921
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
922
+
923
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52
924
+
925
+ Creates a `.stack` property on `targetObject`, which when accessed returns
926
+ a string representing the location in the code at which
927
+ `Error.captureStackTrace()` was called.
928
+
929
+ ```js
930
+ const myObject = {};
931
+ Error.captureStackTrace(myObject);
932
+ myObject.stack; // Similar to `new Error().stack`
933
+ ```
934
+
935
+ The first line of the trace will be prefixed with
936
+ `${myObject.name}: ${myObject.message}`.
937
+
938
+ The optional `constructorOpt` argument accepts a function. If given, all frames
939
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
940
+ generated stack trace.
941
+
942
+ The `constructorOpt` argument is useful for hiding implementation
943
+ details of error generation from the user. For instance:
944
+
945
+ ```js
946
+ function a() {
947
+ b();
948
+ }
949
+
950
+ function b() {
951
+ c();
952
+ }
953
+
954
+ function c() {
955
+ // Create an error without stack trace to avoid calculating the stack trace twice.
956
+ const { stackTraceLimit } = Error;
957
+ Error.stackTraceLimit = 0;
958
+ const error = new Error();
959
+ Error.stackTraceLimit = stackTraceLimit;
960
+
961
+ // Capture the stack trace above function b
962
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
963
+ throw error;
964
+ }
965
+
966
+ a();
967
+ ```
968
+
969
+ #### Parameters
970
+
971
+ ##### targetObject
972
+
973
+ `object`
974
+
975
+ ##### constructorOpt?
976
+
977
+ `Function`
978
+
979
+ #### Returns
980
+
981
+ `void`
982
+
983
+ #### Inherited from
984
+
985
+ `Error.captureStackTrace`
986
+
987
+ ***
988
+
989
+ ### prepareStackTrace()
990
+
991
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
992
+
993
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56
994
+
995
+ #### Parameters
996
+
997
+ ##### err
998
+
999
+ `Error`
1000
+
1001
+ ##### stackTraces
1002
+
1003
+ `CallSite`[]
1004
+
1005
+ #### Returns
1006
+
1007
+ `any`
1008
+
1009
+ #### See
1010
+
1011
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1012
+
1013
+ #### Inherited from
1014
+
1015
+ `Error.prepareStackTrace`
1016
+
1017
+
1018
+ <a name="classesihistorypayloadmd"></a>
1019
+
1020
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1021
+
1022
+ ***
1023
+
1024
+ [@haylee-ai/chat-sdk](#readmemd) / IHistoryPayload
1025
+
1026
+ # Class: IHistoryPayload
1027
+
1028
+ Defined in: src/types/chat.interface.ts:30
1029
+
1030
+ History payload
1031
+
1032
+ ## Constructors
1033
+
1034
+ ### Constructor
1035
+
1036
+ > **new IHistoryPayload**(): `IHistoryPayload`
1037
+
1038
+ #### Returns
1039
+
1040
+ `IHistoryPayload`
1041
+
1042
+ ## Properties
1043
+
1044
+ ### content
1045
+
1046
+ > **content**: `string`
1047
+
1048
+ Defined in: src/types/chat.interface.ts:34
1049
+
1050
+ Content of message
1051
+
1052
+ ***
1053
+
1054
+ ### role
1055
+
1056
+ > **role**: [`Role`](#enumerationsrolemd)
1057
+
1058
+ Defined in: src/types/chat.interface.ts:32
1059
+
1060
+ Role of message sender
1061
+
1062
+
1063
+ <a name="classesllmtokencontentmd"></a>
1064
+
1065
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1066
+
1067
+ ***
1068
+
1069
+ [@haylee-ai/chat-sdk](#readmemd) / LlmTokenContent
1070
+
1071
+ # Class: LlmTokenContent
1072
+
1073
+ Defined in: src/messages/types.ts:27
1074
+
1075
+ LLmTokenContent
1076
+
1077
+ ## Constructors
1078
+
1079
+ ### Constructor
1080
+
1081
+ > **new LlmTokenContent**(): `LlmTokenContent`
1082
+
1083
+ #### Returns
1084
+
1085
+ `LlmTokenContent`
1086
+
1087
+ ## Properties
1088
+
1089
+ ### text
1090
+
1091
+ > **text**: `string`
1092
+
1093
+ Defined in: src/messages/types.ts:35
1094
+
1095
+ ***
1096
+
1097
+ ### type
1098
+
1099
+ > **type**: `"text"`
1100
+
1101
+ Defined in: src/messages/types.ts:31
1102
+
1103
+
1104
+ <a name="classesllmtokeneventmd"></a>
1105
+
1106
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1107
+
1108
+ ***
1109
+
1110
+ [@haylee-ai/chat-sdk](#readmemd) / LlmTokenEvent
1111
+
1112
+ # Class: LlmTokenEvent
1113
+
1114
+ Defined in: src/messages/types.ts:38
1115
+
1116
+ Base event for Streaming
1117
+ BaseEvent
1118
+
1119
+ ## Extends
1120
+
1121
+ - [`BaseEvent`](#classesbaseeventmd)
1122
+
1123
+ ## Constructors
1124
+
1125
+ ### Constructor
1126
+
1127
+ > **new LlmTokenEvent**(): `LlmTokenEvent`
1128
+
1129
+ #### Returns
1130
+
1131
+ `LlmTokenEvent`
1132
+
1133
+ #### Inherited from
1134
+
1135
+ [`BaseEvent`](#classesbaseeventmd).[`constructor`](#constructor)
1136
+
1137
+ ## Properties
1138
+
1139
+ ### content
1140
+
1141
+ > **content**: [`LlmTokenContent`](#classesllmtokencontentmd)[]
1142
+
1143
+ Defined in: src/messages/types.ts:42
1144
+
1145
+ ***
1146
+
1147
+ ### kind
1148
+
1149
+ > **kind**: [`EventKind`](#enumerationseventkindmd)
1150
+
1151
+ Defined in: src/messages/types.ts:16
1152
+
1153
+ Used to separate streams
1154
+
1155
+ #### Inherited from
1156
+
1157
+ [`BaseEvent`](#classesbaseeventmd).[`kind`](#kind)
1158
+
1159
+ ***
1160
+
1161
+ ### model
1162
+
1163
+ > **model**: `string`
1164
+
1165
+ Defined in: src/messages/types.ts:46
1166
+
1167
+ ***
1168
+
1169
+ ### node
1170
+
1171
+ > **node**: `string`
1172
+
1173
+ Defined in: src/messages/types.ts:20
1174
+
1175
+ #### Inherited from
1176
+
1177
+ [`BaseEvent`](#classesbaseeventmd).[`node`](#node)
1178
+
1179
+
1180
+ <a name="classesmessageservicemd"></a>
1181
+
1182
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1183
+
1184
+ ***
1185
+
1186
+ [@haylee-ai/chat-sdk](#readmemd) / MessageService
1187
+
1188
+ # Class: MessageService
1189
+
1190
+ Defined in: src/messages/message.service.ts:44
1191
+
1192
+ ## Constructors
1193
+
1194
+ ### Constructor
1195
+
1196
+ > **new MessageService**(`client`): `MessageService`
1197
+
1198
+ Defined in: src/messages/message.service.ts:46
1199
+
1200
+ #### Parameters
1201
+
1202
+ ##### client
1203
+
1204
+ [`HayleeAIClient`](#classeshayleeaiclientmd)
1205
+
1206
+ #### Returns
1207
+
1208
+ `MessageService`
1209
+
1210
+ ## Methods
1211
+
1212
+ ### stream()
1213
+
1214
+ > **stream**(`payload`, `options?`): `Promise`\<`void`\>
1215
+
1216
+ Defined in: src/messages/message.service.ts:52
1217
+
1218
+ #### Parameters
1219
+
1220
+ ##### payload
1221
+
1222
+ [`CreateMessageDto`](#classescreatemessagedtomd)
1223
+
1224
+ The create message payload
1225
+
1226
+ ##### options?
1227
+
1228
+ [`MessageServiceOptions`](#interfacesmessageserviceoptionsmd)
1229
+
1230
+ Config for streaming
1231
+
1232
+ #### Returns
1233
+
1234
+ `Promise`\<`void`\>
1235
+
1236
+
1237
+ <a name="classesnotfounderrormd"></a>
1238
+
1239
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1240
+
1241
+ ***
1242
+
1243
+ [@haylee-ai/chat-sdk](#readmemd) / NotFoundError
1244
+
1245
+ # Class: NotFoundError
1246
+
1247
+ Defined in: src/errors/not-found.error.ts:3
1248
+
1249
+ ## Extends
1250
+
1251
+ - [`HayleeAIError`](#classeshayleeaierrormd)
1252
+
1253
+ ## Constructors
1254
+
1255
+ ### Constructor
1256
+
1257
+ > **new NotFoundError**(`message`): `NotFoundError`
1258
+
1259
+ Defined in: src/errors/not-found.error.ts:6
1260
+
1261
+ #### Parameters
1262
+
1263
+ ##### message
1264
+
1265
+ `string`
1266
+
1267
+ #### Returns
1268
+
1269
+ `NotFoundError`
1270
+
1271
+ #### Overrides
1272
+
1273
+ [`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)
1274
+
1275
+ ## Properties
1276
+
1277
+ ### cause?
1278
+
1279
+ > `optional` **cause**: `unknown`
1280
+
1281
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
1282
+
1283
+ #### Inherited from
1284
+
1285
+ [`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)
1286
+
1287
+ ***
1288
+
1289
+ ### message
1290
+
1291
+ > **message**: `string`
1292
+
1293
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
1294
+
1295
+ #### Inherited from
1296
+
1297
+ [`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)
1298
+
1299
+ ***
1300
+
1301
+ ### name
1302
+
1303
+ > `readonly` **name**: `string` = `"NotFoundError"`
1304
+
1305
+ Defined in: src/errors/not-found.error.ts:4
1306
+
1307
+ #### Overrides
1308
+
1309
+ [`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)
1310
+
1311
+ ***
1312
+
1313
+ ### stack?
1314
+
1315
+ > `optional` **stack**: `string`
1316
+
1317
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
1318
+
1319
+ #### Inherited from
1320
+
1321
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)
1322
+
1323
+ ***
1324
+
1325
+ ### stackTraceLimit
1326
+
1327
+ > `static` **stackTraceLimit**: `number`
1328
+
1329
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68
1330
+
1331
+ The `Error.stackTraceLimit` property specifies the number of stack frames
1332
+ collected by a stack trace (whether generated by `new Error().stack` or
1333
+ `Error.captureStackTrace(obj)`).
1334
+
1335
+ The default value is `10` but may be set to any valid JavaScript number. Changes
1336
+ will affect any stack trace captured _after_ the value has been changed.
1337
+
1338
+ If set to a non-number value, or set to a negative number, stack traces will
1339
+ not capture any frames.
1340
+
1341
+ #### Inherited from
1342
+
1343
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)
1344
+
1345
+ ## Methods
1346
+
1347
+ ### captureStackTrace()
1348
+
1349
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
1350
+
1351
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52
1352
+
1353
+ Creates a `.stack` property on `targetObject`, which when accessed returns
1354
+ a string representing the location in the code at which
1355
+ `Error.captureStackTrace()` was called.
1356
+
1357
+ ```js
1358
+ const myObject = {};
1359
+ Error.captureStackTrace(myObject);
1360
+ myObject.stack; // Similar to `new Error().stack`
1361
+ ```
1362
+
1363
+ The first line of the trace will be prefixed with
1364
+ `${myObject.name}: ${myObject.message}`.
1365
+
1366
+ The optional `constructorOpt` argument accepts a function. If given, all frames
1367
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
1368
+ generated stack trace.
1369
+
1370
+ The `constructorOpt` argument is useful for hiding implementation
1371
+ details of error generation from the user. For instance:
1372
+
1373
+ ```js
1374
+ function a() {
1375
+ b();
1376
+ }
1377
+
1378
+ function b() {
1379
+ c();
1380
+ }
1381
+
1382
+ function c() {
1383
+ // Create an error without stack trace to avoid calculating the stack trace twice.
1384
+ const { stackTraceLimit } = Error;
1385
+ Error.stackTraceLimit = 0;
1386
+ const error = new Error();
1387
+ Error.stackTraceLimit = stackTraceLimit;
1388
+
1389
+ // Capture the stack trace above function b
1390
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
1391
+ throw error;
1392
+ }
1393
+
1394
+ a();
1395
+ ```
1396
+
1397
+ #### Parameters
1398
+
1399
+ ##### targetObject
1400
+
1401
+ `object`
1402
+
1403
+ ##### constructorOpt?
1404
+
1405
+ `Function`
1406
+
1407
+ #### Returns
1408
+
1409
+ `void`
1410
+
1411
+ #### Inherited from
1412
+
1413
+ [`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)
1414
+
1415
+ ***
1416
+
1417
+ ### prepareStackTrace()
1418
+
1419
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
1420
+
1421
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56
1422
+
1423
+ #### Parameters
1424
+
1425
+ ##### err
1426
+
1427
+ `Error`
1428
+
1429
+ ##### stackTraces
1430
+
1431
+ `CallSite`[]
1432
+
1433
+ #### Returns
1434
+
1435
+ `any`
1436
+
1437
+ #### See
1438
+
1439
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1440
+
1441
+ #### Inherited from
1442
+
1443
+ [`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)
1444
+
1445
+
1446
+ <a name="classesvalidationerrormd"></a>
1447
+
1448
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1449
+
1450
+ ***
1451
+
1452
+ [@haylee-ai/chat-sdk](#readmemd) / ValidationError
1453
+
1454
+ # Class: ValidationError
1455
+
1456
+ Defined in: src/errors/validation.error.ts:3
1457
+
1458
+ ## Extends
1459
+
1460
+ - [`HayleeAIError`](#classeshayleeaierrormd)
1461
+
1462
+ ## Constructors
1463
+
1464
+ ### Constructor
1465
+
1466
+ > **new ValidationError**(`message`, `details?`): `ValidationError`
1467
+
1468
+ Defined in: src/errors/validation.error.ts:5
1469
+
1470
+ #### Parameters
1471
+
1472
+ ##### message
1473
+
1474
+ `string`
1475
+
1476
+ ##### details?
1477
+
1478
+ `any`
1479
+
1480
+ #### Returns
1481
+
1482
+ `ValidationError`
1483
+
1484
+ #### Overrides
1485
+
1486
+ [`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)
1487
+
1488
+ ## Properties
1489
+
1490
+ ### cause?
1491
+
1492
+ > `optional` **cause**: `unknown`
1493
+
1494
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
1495
+
1496
+ #### Inherited from
1497
+
1498
+ [`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)
1499
+
1500
+ ***
1501
+
1502
+ ### details?
1503
+
1504
+ > `optional` **details**: `any`
1505
+
1506
+ Defined in: src/errors/validation.error.ts:5
1507
+
1508
+ ***
1509
+
1510
+ ### message
1511
+
1512
+ > **message**: `string`
1513
+
1514
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
1515
+
1516
+ #### Inherited from
1517
+
1518
+ [`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)
1519
+
1520
+ ***
1521
+
1522
+ ### name
1523
+
1524
+ > `readonly` **name**: `string` = `"ValidationError"`
1525
+
1526
+ Defined in: src/errors/validation.error.ts:4
1527
+
1528
+ #### Overrides
1529
+
1530
+ [`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)
1531
+
1532
+ ***
1533
+
1534
+ ### stack?
1535
+
1536
+ > `optional` **stack**: `string`
1537
+
1538
+ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
1539
+
1540
+ #### Inherited from
1541
+
1542
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)
1543
+
1544
+ ***
1545
+
1546
+ ### stackTraceLimit
1547
+
1548
+ > `static` **stackTraceLimit**: `number`
1549
+
1550
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68
1551
+
1552
+ The `Error.stackTraceLimit` property specifies the number of stack frames
1553
+ collected by a stack trace (whether generated by `new Error().stack` or
1554
+ `Error.captureStackTrace(obj)`).
1555
+
1556
+ The default value is `10` but may be set to any valid JavaScript number. Changes
1557
+ will affect any stack trace captured _after_ the value has been changed.
1558
+
1559
+ If set to a non-number value, or set to a negative number, stack traces will
1560
+ not capture any frames.
1561
+
1562
+ #### Inherited from
1563
+
1564
+ [`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)
1565
+
1566
+ ## Methods
1567
+
1568
+ ### captureStackTrace()
1569
+
1570
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
1571
+
1572
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52
1573
+
1574
+ Creates a `.stack` property on `targetObject`, which when accessed returns
1575
+ a string representing the location in the code at which
1576
+ `Error.captureStackTrace()` was called.
1577
+
1578
+ ```js
1579
+ const myObject = {};
1580
+ Error.captureStackTrace(myObject);
1581
+ myObject.stack; // Similar to `new Error().stack`
1582
+ ```
1583
+
1584
+ The first line of the trace will be prefixed with
1585
+ `${myObject.name}: ${myObject.message}`.
1586
+
1587
+ The optional `constructorOpt` argument accepts a function. If given, all frames
1588
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
1589
+ generated stack trace.
1590
+
1591
+ The `constructorOpt` argument is useful for hiding implementation
1592
+ details of error generation from the user. For instance:
1593
+
1594
+ ```js
1595
+ function a() {
1596
+ b();
1597
+ }
1598
+
1599
+ function b() {
1600
+ c();
1601
+ }
1602
+
1603
+ function c() {
1604
+ // Create an error without stack trace to avoid calculating the stack trace twice.
1605
+ const { stackTraceLimit } = Error;
1606
+ Error.stackTraceLimit = 0;
1607
+ const error = new Error();
1608
+ Error.stackTraceLimit = stackTraceLimit;
1609
+
1610
+ // Capture the stack trace above function b
1611
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
1612
+ throw error;
1613
+ }
1614
+
1615
+ a();
1616
+ ```
1617
+
1618
+ #### Parameters
1619
+
1620
+ ##### targetObject
1621
+
1622
+ `object`
1623
+
1624
+ ##### constructorOpt?
1625
+
1626
+ `Function`
1627
+
1628
+ #### Returns
1629
+
1630
+ `void`
1631
+
1632
+ #### Inherited from
1633
+
1634
+ [`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)
1635
+
1636
+ ***
1637
+
1638
+ ### prepareStackTrace()
1639
+
1640
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
1641
+
1642
+ Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56
1643
+
1644
+ #### Parameters
1645
+
1646
+ ##### err
1647
+
1648
+ `Error`
1649
+
1650
+ ##### stackTraces
1651
+
1652
+ `CallSite`[]
1653
+
1654
+ #### Returns
1655
+
1656
+ `any`
1657
+
1658
+ #### See
1659
+
1660
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1661
+
1662
+ #### Inherited from
1663
+
1664
+ [`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)
1665
+
1666
+
1667
+ <a name="enumerationseventkindmd"></a>
1668
+
1669
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1670
+
1671
+ ***
1672
+
1673
+ [@haylee-ai/chat-sdk](#readmemd) / EventKind
1674
+
1675
+ # Enumeration: EventKind
1676
+
1677
+ Defined in: src/messages/types.ts:1
1678
+
1679
+ ## Enumeration Members
1680
+
1681
+ ### LLM\_TOKEN
1682
+
1683
+ > **LLM\_TOKEN**: `"llm_token"`
1684
+
1685
+ Defined in: src/messages/types.ts:2
1686
+
1687
+ ***
1688
+
1689
+ ### TOOLS
1690
+
1691
+ > **TOOLS**: `"tools"`
1692
+
1693
+ Defined in: src/messages/types.ts:3
1694
+
1695
+
1696
+ <a name="enumerationsrolemd"></a>
1697
+
1698
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1699
+
1700
+ ***
1701
+
1702
+ [@haylee-ai/chat-sdk](#readmemd) / Role
1703
+
1704
+ # Enumeration: Role
1705
+
1706
+ Defined in: src/types/chat.interface.ts:19
1707
+
1708
+ ## Enumeration Members
1709
+
1710
+ ### AI
1711
+
1712
+ > **AI**: `"ai"`
1713
+
1714
+ Defined in: src/types/chat.interface.ts:21
1715
+
1716
+ ***
1717
+
1718
+ ### HUMAN
1719
+
1720
+ > **HUMAN**: `"human"`
1721
+
1722
+ Defined in: src/types/chat.interface.ts:20
1723
+
1724
+
1725
+ <a name="enumerationstoolstatusmd"></a>
1726
+
1727
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1728
+
1729
+ ***
1730
+
1731
+ [@haylee-ai/chat-sdk](#readmemd) / ToolStatus
1732
+
1733
+ # Enumeration: ToolStatus
1734
+
1735
+ Defined in: src/messages/types.ts:61
1736
+
1737
+ ## Enumeration Members
1738
+
1739
+ ### END
1740
+
1741
+ > **END**: `"END"`
1742
+
1743
+ Defined in: src/messages/types.ts:63
1744
+
1745
+ ***
1746
+
1747
+ ### ERROR
1748
+
1749
+ > **ERROR**: `"ERROR"`
1750
+
1751
+ Defined in: src/messages/types.ts:64
1752
+
1753
+ ***
1754
+
1755
+ ### START
1756
+
1757
+ > **START**: `"START"`
1758
+
1759
+ Defined in: src/messages/types.ts:62
1760
+
1761
+
1762
+ <a name="interfacesmessageserviceoptionsmd"></a>
1763
+
1764
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1765
+
1766
+ ***
1767
+
1768
+ [@haylee-ai/chat-sdk](#readmemd) / MessageServiceOptions
1769
+
1770
+ # Interface: MessageServiceOptions
1771
+
1772
+ Defined in: src/messages/message.service.ts:12
1773
+
1774
+ ## Properties
1775
+
1776
+ ### signal?
1777
+
1778
+ > `optional` **signal**: `AbortSignal`
1779
+
1780
+ Defined in: src/messages/message.service.ts:41
1781
+
1782
+ AbortSignal for terminating the upstream stream
1783
+
1784
+ ## Methods
1785
+
1786
+ ### onEnd()?
1787
+
1788
+ > `optional` **onEnd**(`ev`): `void`
1789
+
1790
+ Defined in: src/messages/message.service.ts:22
1791
+
1792
+ triggers upon stream end
1793
+
1794
+ #### Parameters
1795
+
1796
+ ##### ev
1797
+
1798
+ [`EndEvent`](#classesendeventmd)
1799
+
1800
+ EndEvent
1801
+
1802
+ #### Returns
1803
+
1804
+ `void`
1805
+
1806
+ ***
1807
+
1808
+ ### onError()?
1809
+
1810
+ > `optional` **onError**(`err`): `void`
1811
+
1812
+ Defined in: src/messages/message.service.ts:37
1813
+
1814
+ Streams errors on runtime
1815
+
1816
+ #### Parameters
1817
+
1818
+ ##### err
1819
+
1820
+ `unknown`
1821
+
1822
+ #### Returns
1823
+
1824
+ `void`
1825
+
1826
+ ***
1827
+
1828
+ ### onLlmToken()?
1829
+
1830
+ > `optional` **onLlmToken**(`ev`): `void`
1831
+
1832
+ Defined in: src/messages/message.service.ts:17
1833
+
1834
+ Streams llm tokens for output
1835
+
1836
+ #### Parameters
1837
+
1838
+ ##### ev
1839
+
1840
+ [`LlmTokenEvent`](#classesllmtokeneventmd)
1841
+
1842
+ #### Returns
1843
+
1844
+ `void`
1845
+
1846
+ ***
1847
+
1848
+ ### onToolEnd()?
1849
+
1850
+ > `optional` **onToolEnd**(`ev`): `void`
1851
+
1852
+ Defined in: src/messages/message.service.ts:32
1853
+
1854
+ Streams tool end updates
1855
+
1856
+ #### Parameters
1857
+
1858
+ ##### ev
1859
+
1860
+ [`ToolEvent`](#interfacestooleventmd)
1861
+
1862
+ ToolEvent
1863
+
1864
+ #### Returns
1865
+
1866
+ `void`
1867
+
1868
+ ***
1869
+
1870
+ ### onToolStart()?
1871
+
1872
+ > `optional` **onToolStart**(`ev`): `void`
1873
+
1874
+ Defined in: src/messages/message.service.ts:27
1875
+
1876
+ Streams tool start updates
1877
+
1878
+ #### Parameters
1879
+
1880
+ ##### ev
1881
+
1882
+ [`ToolEvent`](#interfacestooleventmd)
1883
+
1884
+ ToolEvent
1885
+
1886
+ #### Returns
1887
+
1888
+ `void`
1889
+
1890
+
1891
+ <a name="interfacestoolcontentmd"></a>
1892
+
1893
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1894
+
1895
+ ***
1896
+
1897
+ [@haylee-ai/chat-sdk](#readmemd) / ToolContent
1898
+
1899
+ # Interface: ToolContent
1900
+
1901
+ Defined in: src/messages/types.ts:67
1902
+
1903
+ ## Properties
1904
+
1905
+ ### params
1906
+
1907
+ > **params**: `unknown`
1908
+
1909
+ Defined in: src/messages/types.ts:68
1910
+
1911
+
1912
+ <a name="interfacestooleventmd"></a>
1913
+
1914
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
1915
+
1916
+ ***
1917
+
1918
+ [@haylee-ai/chat-sdk](#readmemd) / ToolEvent
1919
+
1920
+ # Interface: ToolEvent
1921
+
1922
+ Defined in: src/messages/types.ts:53
1923
+
1924
+ Base event for Streaming
1925
+ BaseEvent
1926
+
1927
+ ## Extends
1928
+
1929
+ - [`BaseEvent`](#classesbaseeventmd)
1930
+
1931
+ ## Properties
1932
+
1933
+ ### content?
1934
+
1935
+ > `optional` **content**: [`ToolContent`](#interfacestoolcontentmd)
1936
+
1937
+ Defined in: src/messages/types.ts:54
1938
+
1939
+ ***
1940
+
1941
+ ### kind
1942
+
1943
+ > **kind**: [`EventKind`](#enumerationseventkindmd)
1944
+
1945
+ Defined in: src/messages/types.ts:16
1946
+
1947
+ Used to separate streams
1948
+
1949
+ #### Inherited from
1950
+
1951
+ [`BaseEvent`](#classesbaseeventmd).[`kind`](#kind)
1952
+
1953
+ ***
1954
+
1955
+ ### name
1956
+
1957
+ > **name**: `string`
1958
+
1959
+ Defined in: src/messages/types.ts:55
1960
+
1961
+ ***
1962
+
1963
+ ### node
1964
+
1965
+ > **node**: `string`
1966
+
1967
+ Defined in: src/messages/types.ts:20
1968
+
1969
+ #### Inherited from
1970
+
1971
+ [`BaseEvent`](#classesbaseeventmd).[`node`](#node)
1972
+
1973
+ ***
1974
+
1975
+ ### results
1976
+
1977
+ > **results**: [`ToolResultContent`](#interfacestoolresultcontentmd)[]
1978
+
1979
+ Defined in: src/messages/types.ts:58
1980
+
1981
+ ***
1982
+
1983
+ ### status
1984
+
1985
+ > **status**: [`ToolStatus`](#enumerationstoolstatusmd)
1986
+
1987
+ Defined in: src/messages/types.ts:57
1988
+
1989
+ ***
1990
+
1991
+ ### tool\_call\_id?
1992
+
1993
+ > `optional` **tool\_call\_id**: `string`
1994
+
1995
+ Defined in: src/messages/types.ts:56
1996
+
1997
+
1998
+ <a name="interfacestoolresultcontentmd"></a>
1999
+
2000
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
2001
+
2002
+ ***
2003
+
2004
+ [@haylee-ai/chat-sdk](#readmemd) / ToolResultContent
2005
+
2006
+ # Interface: ToolResultContent
2007
+
2008
+ Defined in: src/messages/types.ts:71
2009
+
2010
+ ## Properties
2011
+
2012
+ ### content
2013
+
2014
+ > **content**: `any`
2015
+
2016
+ Defined in: src/messages/types.ts:75
2017
+
2018
+ ***
2019
+
2020
+ ### type
2021
+
2022
+ > **type**: `string`
2023
+
2024
+ Defined in: src/messages/types.ts:73
2025
+
2026
+
2027
+ <a name="type-aliaseshayleeaichatclientoptionsmd"></a>
2028
+
2029
+ [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
2030
+
2031
+ ***
2032
+
2033
+ [@haylee-ai/chat-sdk](#readmemd) / HayleeAIChatClientOptions
2034
+
2035
+ # Type Alias: HayleeAIChatClientOptions
2036
+
2037
+ > **HayleeAIChatClientOptions** = `object`
2038
+
2039
+ Defined in: src/\_internal/client.ts:9
2040
+
2041
+ Options for the HayleeAI Client
2042
+
2043
+ ## Properties
2044
+
2045
+ ### baseUrl?
2046
+
2047
+ > `optional` **baseUrl**: `string`
2048
+
2049
+ Defined in: src/\_internal/client.ts:10
2050
+
2051
+ Optional base URL, defaults to production