@haylee-ai/chat-sdk 1.0.2 → 1.0.3

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 CHANGED
@@ -84,7 +84,6 @@ await client.messages.stream(
84
84
  - [HayleeAI](#classeshayleeaimd)
85
85
  - [HayleeAIClient](#classeshayleeaiclientmd)
86
86
  - [HayleeAIError](#classeshayleeaierrormd)
87
- - [IHistoryPayload](#classesihistorypayloadmd)
88
87
  - [LlmTokenContent](#classesllmtokencontentmd)
89
88
  - [LlmTokenEvent](#classesllmtokeneventmd)
90
89
  - [MessageService](#classesmessageservicemd)
@@ -113,7 +112,7 @@ await client.messages.stream(
113
112
 
114
113
  # Class: AuthenticationError
115
114
 
116
- Defined in: [src/errors/authentication.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/authentication.error.ts#L3)
115
+ Defined in: [src/errors/authentication.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/authentication.error.ts#L3)
117
116
 
118
117
  ## Extends
119
118
 
@@ -125,7 +124,7 @@ Defined in: [src/errors/authentication.error.ts:3](https://github.com/vonuyvicoo
125
124
 
126
125
  > **new AuthenticationError**(`message`): `AuthenticationError`
127
126
 
128
- Defined in: [src/errors/authentication.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/authentication.error.ts#L6)
127
+ Defined in: [src/errors/authentication.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/authentication.error.ts#L6)
129
128
 
130
129
  #### Parameters
131
130
 
@@ -171,7 +170,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
171
170
 
172
171
  > `readonly` **name**: `string` = `"AuthenticationError"`
173
172
 
174
- Defined in: [src/errors/authentication.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/authentication.error.ts#L4)
173
+ Defined in: [src/errors/authentication.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/authentication.error.ts#L4)
175
174
 
176
175
  #### Overrides
177
176
 
@@ -322,7 +321,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
322
321
 
323
322
  # Class: AuthorizationError
324
323
 
325
- Defined in: [src/errors/authorization.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/authorization.error.ts#L3)
324
+ Defined in: [src/errors/authorization.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/authorization.error.ts#L3)
326
325
 
327
326
  ## Extends
328
327
 
@@ -334,7 +333,7 @@ Defined in: [src/errors/authorization.error.ts:3](https://github.com/vonuyvicoo/
334
333
 
335
334
  > **new AuthorizationError**(`message`): `AuthorizationError`
336
335
 
337
- Defined in: [src/errors/authorization.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/authorization.error.ts#L6)
336
+ Defined in: [src/errors/authorization.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/authorization.error.ts#L6)
338
337
 
339
338
  #### Parameters
340
339
 
@@ -380,7 +379,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
380
379
 
381
380
  > `readonly` **name**: `string` = `"AuthorizationError"`
382
381
 
383
- Defined in: [src/errors/authorization.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/authorization.error.ts#L4)
382
+ Defined in: [src/errors/authorization.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/authorization.error.ts#L4)
384
383
 
385
384
  #### Overrides
386
385
 
@@ -531,7 +530,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
531
530
 
532
531
  # Class: BaseEvent
533
532
 
534
- Defined in: [src/messages/types.ts:12](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L12)
533
+ Defined in: [src/messages/types.ts:12](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L12)
535
534
 
536
535
  Base event for Streaming
537
536
  BaseEvent
@@ -557,7 +556,7 @@ Base event for Streaming
557
556
 
558
557
  > **kind**: [`EventKind`](#enumerationseventkindmd)
559
558
 
560
- Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L16)
559
+ Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L16)
561
560
 
562
561
  Used to separate streams
563
562
 
@@ -567,7 +566,7 @@ Used to separate streams
567
566
 
568
567
  > **node**: `string`
569
568
 
570
- Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L20)
569
+ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L20)
571
570
 
572
571
  Source node in langgraph
573
572
 
@@ -582,7 +581,7 @@ Source node in langgraph
582
581
 
583
582
  # Class: CreateMessageDto
584
583
 
585
- Defined in: [src/types/chat.interface.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L8)
584
+ Defined in: [src/types/chat.interface.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/types/chat.interface.ts#L8)
586
585
 
587
586
  DTO for creating a message
588
587
 
@@ -598,21 +597,11 @@ DTO for creating a message
598
597
 
599
598
  ## Properties
600
599
 
601
- ### conversation\_history
602
-
603
- > **conversation\_history**: [`IHistoryPayload`](#classesihistorypayloadmd)[]
604
-
605
- Defined in: [src/types/chat.interface.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L13)
606
-
607
- Array of messages
608
-
609
- ***
610
-
611
600
  ### message
612
601
 
613
602
  > **message**: `string`
614
603
 
615
- Defined in: [src/types/chat.interface.ts:11](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L11)
604
+ Defined in: [src/types/chat.interface.ts:11](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/types/chat.interface.ts#L11)
616
605
 
617
606
  User message
618
607
 
@@ -627,7 +616,7 @@ User message
627
616
 
628
617
  # Class: EndEvent
629
618
 
630
- Defined in: [src/messages/types.ts:49](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L49)
619
+ Defined in: [src/messages/types.ts:49](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L49)
631
620
 
632
621
  ## Constructors
633
622
 
@@ -645,7 +634,7 @@ Defined in: [src/messages/types.ts:49](https://github.com/vonuyvicoo/haylee-ai-c
645
634
 
646
635
  > **success**: `boolean`
647
636
 
648
- Defined in: [src/messages/types.ts:50](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L50)
637
+ Defined in: [src/messages/types.ts:50](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L50)
649
638
 
650
639
 
651
640
  <a name="classeshayleeaimd"></a>
@@ -658,7 +647,7 @@ Defined in: [src/messages/types.ts:50](https://github.com/vonuyvicoo/haylee-ai-c
658
647
 
659
648
  # Class: HayleeAI
660
649
 
661
- Defined in: [src/index.ts:7](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/index.ts#L7)
650
+ Defined in: [src/index.ts:7](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/index.ts#L7)
662
651
 
663
652
  Instantiate a new HayleeAI connection
664
653
 
@@ -672,7 +661,7 @@ Instantiate a new HayleeAI connection
672
661
 
673
662
  > **new HayleeAI**(`options`): `HayleeAI`
674
663
 
675
- Defined in: [src/index.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/index.ts#L13)
664
+ Defined in: [src/index.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/index.ts#L13)
676
665
 
677
666
  #### Parameters
678
667
 
@@ -696,7 +685,7 @@ HayleeAIChatClientOptions
696
685
 
697
686
  > **messages**: [`MessageService`](#classesmessageservicemd)
698
687
 
699
- Defined in: [src/index.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/index.ts#L8)
688
+ Defined in: [src/index.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/index.ts#L8)
700
689
 
701
690
  ## Methods
702
691
 
@@ -704,7 +693,7 @@ Defined in: [src/index.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/bl
704
693
 
705
694
  > **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>
706
695
 
707
- Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/_internal/client.ts#L35)
696
+ Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/_internal/client.ts#L35)
708
697
 
709
698
  Internal stream callout
710
699
 
@@ -741,7 +730,7 @@ Abort signal
741
730
 
742
731
  # Class: HayleeAIClient
743
732
 
744
- Defined in: [src/\_internal/client.ts:18](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/_internal/client.ts#L18)
733
+ Defined in: [src/\_internal/client.ts:18](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/_internal/client.ts#L18)
745
734
 
746
735
  Internal HayleeAI Client. Do not use unless necessary.
747
736
  HayleeAIClient
@@ -756,7 +745,7 @@ Internal HayleeAI Client. Do not use unless necessary.
756
745
 
757
746
  > **new HayleeAIClient**(`options`): `HayleeAIClient`
758
747
 
759
- Defined in: [src/\_internal/client.ts:26](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/_internal/client.ts#L26)
748
+ Defined in: [src/\_internal/client.ts:26](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/_internal/client.ts#L26)
760
749
 
761
750
  #### Parameters
762
751
 
@@ -776,7 +765,7 @@ Auth, and baseURL
776
765
 
777
766
  > **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>
778
767
 
779
- Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/_internal/client.ts#L35)
768
+ Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/_internal/client.ts#L35)
780
769
 
781
770
  Internal stream callout
782
771
 
@@ -809,7 +798,7 @@ Abort signal
809
798
 
810
799
  # Class: HayleeAIError
811
800
 
812
- Defined in: [src/errors/base.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/base.ts#L1)
801
+ Defined in: [src/errors/base.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/base.ts#L1)
813
802
 
814
803
  ## Extends
815
804
 
@@ -828,7 +817,7 @@ Defined in: [src/errors/base.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-
828
817
 
829
818
  > **new HayleeAIError**(`message`): `HayleeAIError`
830
819
 
831
- Defined in: [src/errors/base.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/base.ts#L4)
820
+ Defined in: [src/errors/base.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/base.ts#L4)
832
821
 
833
822
  #### Parameters
834
823
 
@@ -874,7 +863,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
874
863
 
875
864
  > `readonly` **name**: `string` = `"HayleeAIError"`
876
865
 
877
- Defined in: [src/errors/base.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/base.ts#L2)
866
+ Defined in: [src/errors/base.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/base.ts#L2)
878
867
 
879
868
  #### Overrides
880
869
 
@@ -1015,51 +1004,6 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1015
1004
  `Error.prepareStackTrace`
1016
1005
 
1017
1006
 
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](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L30)
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](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L34)
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](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L32)
1059
-
1060
- Role of message sender
1061
-
1062
-
1063
1007
  <a name="classesllmtokencontentmd"></a>
1064
1008
 
1065
1009
  [**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
@@ -1070,7 +1014,7 @@ Role of message sender
1070
1014
 
1071
1015
  # Class: LlmTokenContent
1072
1016
 
1073
- Defined in: [src/messages/types.ts:27](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L27)
1017
+ Defined in: [src/messages/types.ts:27](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L27)
1074
1018
 
1075
1019
  LLmTokenContent
1076
1020
 
@@ -1090,7 +1034,7 @@ LLmTokenContent
1090
1034
 
1091
1035
  > **text**: `string`
1092
1036
 
1093
- Defined in: [src/messages/types.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L35)
1037
+ Defined in: [src/messages/types.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L35)
1094
1038
 
1095
1039
  ***
1096
1040
 
@@ -1098,7 +1042,7 @@ Defined in: [src/messages/types.ts:35](https://github.com/vonuyvicoo/haylee-ai-c
1098
1042
 
1099
1043
  > **type**: `"text"`
1100
1044
 
1101
- Defined in: [src/messages/types.ts:31](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L31)
1045
+ Defined in: [src/messages/types.ts:31](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L31)
1102
1046
 
1103
1047
 
1104
1048
  <a name="classesllmtokeneventmd"></a>
@@ -1111,7 +1055,7 @@ Defined in: [src/messages/types.ts:31](https://github.com/vonuyvicoo/haylee-ai-c
1111
1055
 
1112
1056
  # Class: LlmTokenEvent
1113
1057
 
1114
- Defined in: [src/messages/types.ts:38](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L38)
1058
+ Defined in: [src/messages/types.ts:38](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L38)
1115
1059
 
1116
1060
  Base event for Streaming
1117
1061
  BaseEvent
@@ -1140,7 +1084,7 @@ Base event for Streaming
1140
1084
 
1141
1085
  > **content**: [`LlmTokenContent`](#classesllmtokencontentmd)[]
1142
1086
 
1143
- Defined in: [src/messages/types.ts:42](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L42)
1087
+ Defined in: [src/messages/types.ts:42](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L42)
1144
1088
 
1145
1089
  ***
1146
1090
 
@@ -1148,7 +1092,7 @@ Defined in: [src/messages/types.ts:42](https://github.com/vonuyvicoo/haylee-ai-c
1148
1092
 
1149
1093
  > **kind**: [`EventKind`](#enumerationseventkindmd)
1150
1094
 
1151
- Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L16)
1095
+ Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L16)
1152
1096
 
1153
1097
  Used to separate streams
1154
1098
 
@@ -1162,7 +1106,7 @@ Used to separate streams
1162
1106
 
1163
1107
  > **model**: `string`
1164
1108
 
1165
- Defined in: [src/messages/types.ts:46](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L46)
1109
+ Defined in: [src/messages/types.ts:46](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L46)
1166
1110
 
1167
1111
  ***
1168
1112
 
@@ -1170,7 +1114,7 @@ Defined in: [src/messages/types.ts:46](https://github.com/vonuyvicoo/haylee-ai-c
1170
1114
 
1171
1115
  > **node**: `string`
1172
1116
 
1173
- Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L20)
1117
+ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L20)
1174
1118
 
1175
1119
  #### Inherited from
1176
1120
 
@@ -1187,7 +1131,7 @@ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-c
1187
1131
 
1188
1132
  # Class: MessageService
1189
1133
 
1190
- Defined in: [src/messages/message.service.ts:50](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L50)
1134
+ Defined in: [src/messages/message.service.ts:49](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L49)
1191
1135
 
1192
1136
  ## Constructors
1193
1137
 
@@ -1195,7 +1139,7 @@ Defined in: [src/messages/message.service.ts:50](https://github.com/vonuyvicoo/h
1195
1139
 
1196
1140
  > **new MessageService**(`client`): `MessageService`
1197
1141
 
1198
- Defined in: [src/messages/message.service.ts:52](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L52)
1142
+ Defined in: [src/messages/message.service.ts:51](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L51)
1199
1143
 
1200
1144
  #### Parameters
1201
1145
 
@@ -1213,7 +1157,7 @@ Defined in: [src/messages/message.service.ts:52](https://github.com/vonuyvicoo/h
1213
1157
 
1214
1158
  > **stream**(`payload`, `options?`): `Promise`\<`void`\>
1215
1159
 
1216
- Defined in: [src/messages/message.service.ts:58](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L58)
1160
+ Defined in: [src/messages/message.service.ts:57](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L57)
1217
1161
 
1218
1162
  #### Parameters
1219
1163
 
@@ -1244,7 +1188,7 @@ Config for streaming
1244
1188
 
1245
1189
  # Class: NotFoundError
1246
1190
 
1247
- Defined in: [src/errors/not-found.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/not-found.error.ts#L3)
1191
+ Defined in: [src/errors/not-found.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/not-found.error.ts#L3)
1248
1192
 
1249
1193
  ## Extends
1250
1194
 
@@ -1256,7 +1200,7 @@ Defined in: [src/errors/not-found.error.ts:3](https://github.com/vonuyvicoo/hayl
1256
1200
 
1257
1201
  > **new NotFoundError**(`message`): `NotFoundError`
1258
1202
 
1259
- Defined in: [src/errors/not-found.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/not-found.error.ts#L6)
1203
+ Defined in: [src/errors/not-found.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/not-found.error.ts#L6)
1260
1204
 
1261
1205
  #### Parameters
1262
1206
 
@@ -1302,7 +1246,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
1302
1246
 
1303
1247
  > `readonly` **name**: `string` = `"NotFoundError"`
1304
1248
 
1305
- Defined in: [src/errors/not-found.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/not-found.error.ts#L4)
1249
+ Defined in: [src/errors/not-found.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/not-found.error.ts#L4)
1306
1250
 
1307
1251
  #### Overrides
1308
1252
 
@@ -1453,7 +1397,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1453
1397
 
1454
1398
  # Class: ValidationError
1455
1399
 
1456
- Defined in: [src/errors/validation.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/validation.error.ts#L3)
1400
+ Defined in: [src/errors/validation.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/validation.error.ts#L3)
1457
1401
 
1458
1402
  ## Extends
1459
1403
 
@@ -1465,7 +1409,7 @@ Defined in: [src/errors/validation.error.ts:3](https://github.com/vonuyvicoo/hay
1465
1409
 
1466
1410
  > **new ValidationError**(`message`, `details?`): `ValidationError`
1467
1411
 
1468
- Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/validation.error.ts#L5)
1412
+ Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/validation.error.ts#L5)
1469
1413
 
1470
1414
  #### Parameters
1471
1415
 
@@ -1503,7 +1447,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
1503
1447
 
1504
1448
  > `optional` **details**: `any`
1505
1449
 
1506
- Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/validation.error.ts#L5)
1450
+ Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/validation.error.ts#L5)
1507
1451
 
1508
1452
  ***
1509
1453
 
@@ -1523,7 +1467,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
1523
1467
 
1524
1468
  > `readonly` **name**: `string` = `"ValidationError"`
1525
1469
 
1526
- Defined in: [src/errors/validation.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/errors/validation.error.ts#L4)
1470
+ Defined in: [src/errors/validation.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/errors/validation.error.ts#L4)
1527
1471
 
1528
1472
  #### Overrides
1529
1473
 
@@ -1674,7 +1618,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
1674
1618
 
1675
1619
  # Enumeration: EventKind
1676
1620
 
1677
- Defined in: [src/messages/types.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L1)
1621
+ Defined in: [src/messages/types.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L1)
1678
1622
 
1679
1623
  ## Enumeration Members
1680
1624
 
@@ -1682,7 +1626,7 @@ Defined in: [src/messages/types.ts:1](https://github.com/vonuyvicoo/haylee-ai-ch
1682
1626
 
1683
1627
  > **LLM\_TOKEN**: `"llm_token"`
1684
1628
 
1685
- Defined in: [src/messages/types.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L2)
1629
+ Defined in: [src/messages/types.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L2)
1686
1630
 
1687
1631
  ***
1688
1632
 
@@ -1690,7 +1634,7 @@ Defined in: [src/messages/types.ts:2](https://github.com/vonuyvicoo/haylee-ai-ch
1690
1634
 
1691
1635
  > **TOOLS**: `"tools"`
1692
1636
 
1693
- Defined in: [src/messages/types.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L3)
1637
+ Defined in: [src/messages/types.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L3)
1694
1638
 
1695
1639
 
1696
1640
  <a name="enumerationsrolemd"></a>
@@ -1703,7 +1647,7 @@ Defined in: [src/messages/types.ts:3](https://github.com/vonuyvicoo/haylee-ai-ch
1703
1647
 
1704
1648
  # Enumeration: Role
1705
1649
 
1706
- Defined in: [src/types/chat.interface.ts:19](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L19)
1650
+ Defined in: [src/types/chat.interface.ts:17](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/types/chat.interface.ts#L17)
1707
1651
 
1708
1652
  ## Enumeration Members
1709
1653
 
@@ -1711,7 +1655,7 @@ Defined in: [src/types/chat.interface.ts:19](https://github.com/vonuyvicoo/hayle
1711
1655
 
1712
1656
  > **AI**: `"ai"`
1713
1657
 
1714
- Defined in: [src/types/chat.interface.ts:21](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L21)
1658
+ Defined in: [src/types/chat.interface.ts:19](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/types/chat.interface.ts#L19)
1715
1659
 
1716
1660
  ***
1717
1661
 
@@ -1719,7 +1663,7 @@ Defined in: [src/types/chat.interface.ts:21](https://github.com/vonuyvicoo/hayle
1719
1663
 
1720
1664
  > **HUMAN**: `"human"`
1721
1665
 
1722
- Defined in: [src/types/chat.interface.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L20)
1666
+ Defined in: [src/types/chat.interface.ts:18](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/types/chat.interface.ts#L18)
1723
1667
 
1724
1668
 
1725
1669
  <a name="enumerationstoolstatusmd"></a>
@@ -1732,7 +1676,7 @@ Defined in: [src/types/chat.interface.ts:20](https://github.com/vonuyvicoo/hayle
1732
1676
 
1733
1677
  # Enumeration: ToolStatus
1734
1678
 
1735
- Defined in: [src/messages/types.ts:62](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L62)
1679
+ Defined in: [src/messages/types.ts:62](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L62)
1736
1680
 
1737
1681
  ## Enumeration Members
1738
1682
 
@@ -1740,7 +1684,7 @@ Defined in: [src/messages/types.ts:62](https://github.com/vonuyvicoo/haylee-ai-c
1740
1684
 
1741
1685
  > **END**: `"END"`
1742
1686
 
1743
- Defined in: [src/messages/types.ts:64](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L64)
1687
+ Defined in: [src/messages/types.ts:64](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L64)
1744
1688
 
1745
1689
  ***
1746
1690
 
@@ -1748,7 +1692,7 @@ Defined in: [src/messages/types.ts:64](https://github.com/vonuyvicoo/haylee-ai-c
1748
1692
 
1749
1693
  > **ERROR**: `"ERROR"`
1750
1694
 
1751
- Defined in: [src/messages/types.ts:65](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L65)
1695
+ Defined in: [src/messages/types.ts:65](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L65)
1752
1696
 
1753
1697
  ***
1754
1698
 
@@ -1756,7 +1700,7 @@ Defined in: [src/messages/types.ts:65](https://github.com/vonuyvicoo/haylee-ai-c
1756
1700
 
1757
1701
  > **START**: `"START"`
1758
1702
 
1759
- Defined in: [src/messages/types.ts:63](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L63)
1703
+ Defined in: [src/messages/types.ts:63](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L63)
1760
1704
 
1761
1705
 
1762
1706
  <a name="interfacesmessageserviceoptionsmd"></a>
@@ -1769,7 +1713,7 @@ Defined in: [src/messages/types.ts:63](https://github.com/vonuyvicoo/haylee-ai-c
1769
1713
 
1770
1714
  # Interface: MessageServiceOptions
1771
1715
 
1772
- Defined in: [src/messages/message.service.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L13)
1716
+ Defined in: [src/messages/message.service.ts:12](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L12)
1773
1717
 
1774
1718
  ## Properties
1775
1719
 
@@ -1777,7 +1721,7 @@ Defined in: [src/messages/message.service.ts:13](https://github.com/vonuyvicoo/h
1777
1721
 
1778
1722
  > `optional` **signal**: `AbortSignal`
1779
1723
 
1780
- Defined in: [src/messages/message.service.ts:47](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L47)
1724
+ Defined in: [src/messages/message.service.ts:46](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L46)
1781
1725
 
1782
1726
  AbortSignal for terminating the upstream stream
1783
1727
 
@@ -1787,7 +1731,7 @@ AbortSignal for terminating the upstream stream
1787
1731
 
1788
1732
  > `optional` **onEnd**(`ev`): `void`
1789
1733
 
1790
- Defined in: [src/messages/message.service.ts:23](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L23)
1734
+ Defined in: [src/messages/message.service.ts:22](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L22)
1791
1735
 
1792
1736
  triggers upon stream end
1793
1737
 
@@ -1809,7 +1753,7 @@ EndEvent
1809
1753
 
1810
1754
  > `optional` **onError**(`err`): `void`
1811
1755
 
1812
- Defined in: [src/messages/message.service.ts:43](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L43)
1756
+ Defined in: [src/messages/message.service.ts:42](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L42)
1813
1757
 
1814
1758
  Streams errors on runtime
1815
1759
 
@@ -1829,7 +1773,7 @@ Streams errors on runtime
1829
1773
 
1830
1774
  > `optional` **onLlmToken**(`ev`): `void`
1831
1775
 
1832
- Defined in: [src/messages/message.service.ts:18](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L18)
1776
+ Defined in: [src/messages/message.service.ts:17](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L17)
1833
1777
 
1834
1778
  Streams llm tokens for output
1835
1779
 
@@ -1849,7 +1793,7 @@ Streams llm tokens for output
1849
1793
 
1850
1794
  > `optional` **onToolEnd**(`ev`): `void`
1851
1795
 
1852
- Defined in: [src/messages/message.service.ts:33](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L33)
1796
+ Defined in: [src/messages/message.service.ts:32](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L32)
1853
1797
 
1854
1798
  Streams tool end updates
1855
1799
 
@@ -1871,7 +1815,7 @@ ToolEvent
1871
1815
 
1872
1816
  > `optional` **onToolError**(`ev`): `void`
1873
1817
 
1874
- Defined in: [src/messages/message.service.ts:38](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L38)
1818
+ Defined in: [src/messages/message.service.ts:37](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L37)
1875
1819
 
1876
1820
  Streams tool errors
1877
1821
 
@@ -1893,7 +1837,7 @@ ToolEvent
1893
1837
 
1894
1838
  > `optional` **onToolStart**(`ev`): `void`
1895
1839
 
1896
- Defined in: [src/messages/message.service.ts:28](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/message.service.ts#L28)
1840
+ Defined in: [src/messages/message.service.ts:27](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/message.service.ts#L27)
1897
1841
 
1898
1842
  Streams tool start updates
1899
1843
 
@@ -1920,7 +1864,7 @@ ToolEvent
1920
1864
 
1921
1865
  # Interface: ToolContent
1922
1866
 
1923
- Defined in: [src/messages/types.ts:68](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L68)
1867
+ Defined in: [src/messages/types.ts:68](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L68)
1924
1868
 
1925
1869
  ## Properties
1926
1870
 
@@ -1928,7 +1872,7 @@ Defined in: [src/messages/types.ts:68](https://github.com/vonuyvicoo/haylee-ai-c
1928
1872
 
1929
1873
  > **params**: `unknown`
1930
1874
 
1931
- Defined in: [src/messages/types.ts:69](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L69)
1875
+ Defined in: [src/messages/types.ts:69](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L69)
1932
1876
 
1933
1877
 
1934
1878
  <a name="interfacestooleventmd"></a>
@@ -1941,7 +1885,7 @@ Defined in: [src/messages/types.ts:69](https://github.com/vonuyvicoo/haylee-ai-c
1941
1885
 
1942
1886
  # Interface: ToolEvent
1943
1887
 
1944
- Defined in: [src/messages/types.ts:53](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L53)
1888
+ Defined in: [src/messages/types.ts:53](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L53)
1945
1889
 
1946
1890
  Base event for Streaming
1947
1891
  BaseEvent
@@ -1956,7 +1900,7 @@ Base event for Streaming
1956
1900
 
1957
1901
  > `optional` **content**: [`ToolContent`](#interfacestoolcontentmd)
1958
1902
 
1959
- Defined in: [src/messages/types.ts:54](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L54)
1903
+ Defined in: [src/messages/types.ts:54](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L54)
1960
1904
 
1961
1905
  ***
1962
1906
 
@@ -1964,7 +1908,7 @@ Defined in: [src/messages/types.ts:54](https://github.com/vonuyvicoo/haylee-ai-c
1964
1908
 
1965
1909
  > `optional` **error**: `unknown`
1966
1910
 
1967
- Defined in: [src/messages/types.ts:59](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L59)
1911
+ Defined in: [src/messages/types.ts:59](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L59)
1968
1912
 
1969
1913
  ***
1970
1914
 
@@ -1972,7 +1916,7 @@ Defined in: [src/messages/types.ts:59](https://github.com/vonuyvicoo/haylee-ai-c
1972
1916
 
1973
1917
  > **kind**: [`EventKind`](#enumerationseventkindmd)
1974
1918
 
1975
- Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L16)
1919
+ Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L16)
1976
1920
 
1977
1921
  Used to separate streams
1978
1922
 
@@ -1986,7 +1930,7 @@ Used to separate streams
1986
1930
 
1987
1931
  > **name**: `string`
1988
1932
 
1989
- Defined in: [src/messages/types.ts:55](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L55)
1933
+ Defined in: [src/messages/types.ts:55](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L55)
1990
1934
 
1991
1935
  ***
1992
1936
 
@@ -1994,7 +1938,7 @@ Defined in: [src/messages/types.ts:55](https://github.com/vonuyvicoo/haylee-ai-c
1994
1938
 
1995
1939
  > **node**: `string`
1996
1940
 
1997
- Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L20)
1941
+ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L20)
1998
1942
 
1999
1943
  #### Inherited from
2000
1944
 
@@ -2006,7 +1950,7 @@ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-c
2006
1950
 
2007
1951
  > **results**: [`ToolResultContent`](#interfacestoolresultcontentmd)[]
2008
1952
 
2009
- Defined in: [src/messages/types.ts:58](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L58)
1953
+ Defined in: [src/messages/types.ts:58](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L58)
2010
1954
 
2011
1955
  ***
2012
1956
 
@@ -2014,7 +1958,7 @@ Defined in: [src/messages/types.ts:58](https://github.com/vonuyvicoo/haylee-ai-c
2014
1958
 
2015
1959
  > **status**: [`ToolStatus`](#enumerationstoolstatusmd)
2016
1960
 
2017
- Defined in: [src/messages/types.ts:57](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L57)
1961
+ Defined in: [src/messages/types.ts:57](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L57)
2018
1962
 
2019
1963
  ***
2020
1964
 
@@ -2022,7 +1966,7 @@ Defined in: [src/messages/types.ts:57](https://github.com/vonuyvicoo/haylee-ai-c
2022
1966
 
2023
1967
  > `optional` **tool\_call\_id**: `string`
2024
1968
 
2025
- Defined in: [src/messages/types.ts:56](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L56)
1969
+ Defined in: [src/messages/types.ts:56](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L56)
2026
1970
 
2027
1971
 
2028
1972
  <a name="interfacestoolresultcontentmd"></a>
@@ -2035,7 +1979,7 @@ Defined in: [src/messages/types.ts:56](https://github.com/vonuyvicoo/haylee-ai-c
2035
1979
 
2036
1980
  # Interface: ToolResultContent
2037
1981
 
2038
- Defined in: [src/messages/types.ts:72](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L72)
1982
+ Defined in: [src/messages/types.ts:72](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L72)
2039
1983
 
2040
1984
  ## Properties
2041
1985
 
@@ -2043,7 +1987,7 @@ Defined in: [src/messages/types.ts:72](https://github.com/vonuyvicoo/haylee-ai-c
2043
1987
 
2044
1988
  > **content**: `any`
2045
1989
 
2046
- Defined in: [src/messages/types.ts:76](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L76)
1990
+ Defined in: [src/messages/types.ts:76](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L76)
2047
1991
 
2048
1992
  ***
2049
1993
 
@@ -2051,7 +1995,7 @@ Defined in: [src/messages/types.ts:76](https://github.com/vonuyvicoo/haylee-ai-c
2051
1995
 
2052
1996
  > **type**: `string`
2053
1997
 
2054
- Defined in: [src/messages/types.ts:74](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/messages/types.ts#L74)
1998
+ Defined in: [src/messages/types.ts:74](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/messages/types.ts#L74)
2055
1999
 
2056
2000
 
2057
2001
  <a name="type-aliaseshayleeaichatclientoptionsmd"></a>
@@ -2066,7 +2010,7 @@ Defined in: [src/messages/types.ts:74](https://github.com/vonuyvicoo/haylee-ai-c
2066
2010
 
2067
2011
  > **HayleeAIChatClientOptions** = `object`
2068
2012
 
2069
- Defined in: [src/\_internal/client.ts:9](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/_internal/client.ts#L9)
2013
+ Defined in: [src/\_internal/client.ts:9](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/_internal/client.ts#L9)
2070
2014
 
2071
2015
  Options for the HayleeAI Client
2072
2016
 
@@ -2076,6 +2020,6 @@ Options for the HayleeAI Client
2076
2020
 
2077
2021
  > `optional` **baseUrl**: `string`
2078
2022
 
2079
- Defined in: [src/\_internal/client.ts:10](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/_internal/client.ts#L10)
2023
+ Defined in: [src/\_internal/client.ts:10](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/fd2d1ef69d1739bc478a0d05d3c743cbf53f2452/src/_internal/client.ts#L10)
2080
2024
 
2081
2025
  Optional base URL, defaults to production
package/dist/index.cjs CHANGED
@@ -37,7 +37,6 @@ __export(index_exports, {
37
37
  HayleeAI: () => HayleeAI,
38
38
  HayleeAIClient: () => HayleeAIClient,
39
39
  HayleeAIError: () => HayleeAIError,
40
- IHistoryPayload: () => IHistoryPayload,
41
40
  LlmTokenContent: () => LlmTokenContent,
42
41
  LlmTokenEvent: () => LlmTokenEvent,
43
42
  MessageService: () => MessageService,
@@ -268,8 +267,6 @@ var AuthenticationError = class _AuthenticationError extends HayleeAIError {
268
267
  var import_class_validator = require("class-validator");
269
268
  var CreateMessageDto = class {
270
269
  message;
271
- /* Array of messages */
272
- conversation_history;
273
270
  };
274
271
  __decorateClass([
275
272
  (0, import_class_validator.IsString)()
@@ -279,16 +276,6 @@ var Role = /* @__PURE__ */ ((Role2) => {
279
276
  Role2["AI"] = "ai";
280
277
  return Role2;
281
278
  })(Role || {});
282
- var IHistoryPayload = class {
283
- role;
284
- content;
285
- };
286
- __decorateClass([
287
- (0, import_class_validator.IsEnum)(Role)
288
- ], IHistoryPayload.prototype, "role", 2);
289
- __decorateClass([
290
- (0, import_class_validator.IsString)()
291
- ], IHistoryPayload.prototype, "content", 2);
292
279
 
293
280
  // src/index.ts
294
281
  var HayleeAI = class extends HayleeAIClient {
@@ -312,7 +299,6 @@ var HayleeAI = class extends HayleeAIClient {
312
299
  HayleeAI,
313
300
  HayleeAIClient,
314
301
  HayleeAIError,
315
- IHistoryPayload,
316
302
  LlmTokenContent,
317
303
  LlmTokenEvent,
318
304
  MessageService,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts"],"sourcesContent":["import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n","import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\nimport { type } from \"os\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsEnum, IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n /* Array of messages */\n conversation_history!: IHistoryPayload[];\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n/**\n * History payload\n * @property role - Role of message sender\n * @property content - Content of message\n */\nexport class IHistoryPayload {\n @IsEnum(Role)\n role!: Role;\n @IsString()\n content!: string;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,gCAAiC;AAgB1B,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAIR,YAAY,SAAoC;AAC5C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QAAQ,SAA2B,QAAsB;AAC5D,UAAM,QAAkB,CAAC;AACzB,QAAI,UAA+B;AACnC,QAAI,OAAO;AAEX,oDAAiB,GAAG,KAAK,OAAO,IAAI;AAAA,MAChC,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,MACA,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,OAAO;AAAA,MAC5B,gBAAgB;AAAA,MAChB,UAAU,IAAI;AACV,cAAM,KAAK,GAAG,IAAI;AAClB,kBAAU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src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts"],"sourcesContent":["import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n","import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AuB;AAAA,EAG1B;AACJ;AADI;AAAA,MADC,iCAAS;AAAA,GAFD,iBAGT;AAMG,IAAK,OAAL,kBAAKC,UAAL;AACH,EAAAA,MAAA,WAAQ;AACR,EAAAA,MAAA,QAAK;AAFG,SAAAA;AAAA,GAAA;;;AXVZ,IAAM,WAAN,cAAuB,eAAe;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKP,YAAY,SAAmC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW,IAAI,eAAe,IAAI;AAAA,EAC3C;AACJ;","names":["EventKind","ToolStatus","Role"]}
package/dist/index.d.cts CHANGED
@@ -5,21 +5,11 @@
5
5
  */
6
6
  declare class CreateMessageDto {
7
7
  message: string;
8
- conversation_history: IHistoryPayload[];
9
8
  }
10
9
  declare enum Role {
11
10
  HUMAN = "human",
12
11
  AI = "ai"
13
12
  }
14
- /**
15
- * History payload
16
- * @property role - Role of message sender
17
- * @property content - Content of message
18
- */
19
- declare class IHistoryPayload {
20
- role: Role;
21
- content: string;
22
- }
23
13
 
24
14
  /**
25
15
  * Options for the HayleeAI Client
@@ -204,4 +194,4 @@ declare class HayleeAI extends HayleeAIClient {
204
194
  constructor(options: HayleeAIChatClientOptions);
205
195
  }
206
196
 
207
- export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError, IHistoryPayload, LlmTokenContent, LlmTokenEvent, MessageService, type MessageServiceOptions, NotFoundError, Role, type ToolContent, type ToolEvent, type ToolResultContent, ToolStatus, ValidationError };
197
+ export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError, LlmTokenContent, LlmTokenEvent, MessageService, type MessageServiceOptions, NotFoundError, Role, type ToolContent, type ToolEvent, type ToolResultContent, ToolStatus, ValidationError };
package/dist/index.d.ts CHANGED
@@ -5,21 +5,11 @@
5
5
  */
6
6
  declare class CreateMessageDto {
7
7
  message: string;
8
- conversation_history: IHistoryPayload[];
9
8
  }
10
9
  declare enum Role {
11
10
  HUMAN = "human",
12
11
  AI = "ai"
13
12
  }
14
- /**
15
- * History payload
16
- * @property role - Role of message sender
17
- * @property content - Content of message
18
- */
19
- declare class IHistoryPayload {
20
- role: Role;
21
- content: string;
22
- }
23
13
 
24
14
  /**
25
15
  * Options for the HayleeAI Client
@@ -204,4 +194,4 @@ declare class HayleeAI extends HayleeAIClient {
204
194
  constructor(options: HayleeAIChatClientOptions);
205
195
  }
206
196
 
207
- export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError, IHistoryPayload, LlmTokenContent, LlmTokenEvent, MessageService, type MessageServiceOptions, NotFoundError, Role, type ToolContent, type ToolEvent, type ToolResultContent, ToolStatus, ValidationError };
197
+ export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError, LlmTokenContent, LlmTokenEvent, MessageService, type MessageServiceOptions, NotFoundError, Role, type ToolContent, type ToolEvent, type ToolResultContent, ToolStatus, ValidationError };
package/dist/index.js CHANGED
@@ -226,11 +226,9 @@ var AuthenticationError = class _AuthenticationError extends HayleeAIError {
226
226
  };
227
227
 
228
228
  // src/types/chat.interface.ts
229
- import { IsEnum, IsString } from "class-validator";
229
+ import { IsString } from "class-validator";
230
230
  var CreateMessageDto = class {
231
231
  message;
232
- /* Array of messages */
233
- conversation_history;
234
232
  };
235
233
  __decorateClass([
236
234
  IsString()
@@ -240,16 +238,6 @@ var Role = /* @__PURE__ */ ((Role2) => {
240
238
  Role2["AI"] = "ai";
241
239
  return Role2;
242
240
  })(Role || {});
243
- var IHistoryPayload = class {
244
- role;
245
- content;
246
- };
247
- __decorateClass([
248
- IsEnum(Role)
249
- ], IHistoryPayload.prototype, "role", 2);
250
- __decorateClass([
251
- IsString()
252
- ], IHistoryPayload.prototype, "content", 2);
253
241
 
254
242
  // src/index.ts
255
243
  var HayleeAI = class extends HayleeAIClient {
@@ -272,7 +260,6 @@ export {
272
260
  HayleeAI,
273
261
  HayleeAIClient,
274
262
  HayleeAIError,
275
- IHistoryPayload,
276
263
  LlmTokenContent,
277
264
  LlmTokenEvent,
278
265
  MessageService,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts","../src/index.ts"],"sourcesContent":["import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\nimport { type } from \"os\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsEnum, IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n /* Array of messages */\n conversation_history!: IHistoryPayload[];\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n/**\n * History payload\n * @property role - Role of message sender\n * @property content - Content of message\n */\nexport class IHistoryPayload {\n @IsEnum(Role)\n role!: Role;\n @IsString()\n content!: string;\n};\n","import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,wBAAwB;AAgB1B,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAIR,YAAY,SAAoC;AAC5C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QAAQ,SAA2B,QAAsB;AAC5D,UAAM,QAAkB,CAAC;AACzB,QAAI,UAA+B;AACnC,QAAI,OAAO;AAEX,qBAAiB,GAAG,KAAK,OAAO,IAAI;AAAA,MAChC,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,MACA,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,OAAO;AAAA,MAC5B,gBAAgB;AAAA,MAChB,UAAU,IAAI;AACV,cAAM,KAAK,GAAG,IAAI;AAClB,kBAAU;AAAA,MACd;AAAA,MACA,UAAU;AACN,eAAO;AACP,kBAAU;AAAA,MACd;AAAA,MACA,QAAQ,KAAK;AACT,eAAO;AACP,kBAAU;AACV,cAAM;AAAA,MACV;AAAA,MACA;AAAA,IACJ,CAAC;AAED,QAAI,QAAQ;AACR,aAAO,iBAAiB,SAAS,MAAM;AACnC,eAAO;AACP,kBAAU;AAAA,MACd,CAAC;AAAA,IACL;AAEA,WAAO,CA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ACJ;;;ACPO,IAAM,qBAAN,MAAM,4BAA2B,cAAc;AAAA,EAClC,OAAe;AAAA,EAE/B,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,oBAAmB,SAAS;AAAA,EAC5D;AACJ;;;ACPO,IAAM,sBAAN,MAAM,6BAA4B,cAAc;AAAA,EACnC,OAAe;AAAA,EAE/B,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,qBAAoB,SAAS;AAAA,EAC7D;AACJ;;;ACTA,SAAS,QAAQ,gBAAgB;AAO1B,IAAM,mBAAN,MAAuB;AAAA,EAG1B;AAAA;AAAA,EAEA;AACJ;AAHI;AAAA,EADC,SAAS;AAAA,GAFD,iBAGT;AAQG,IAAK,OAAL,kBAAKC,UAAL;AACH,EAAAA,MAAA,WAAQ;AACR,EAAAA,MAAA,QAAK;AAFG,SAAAA;AAAA,GAAA;AAWL,IAAM,kBAAN,MAAsB;AAAA,EAEzB;AAAA,EAEA;AACJ;AAHI;AAAA,EADC,OAAO,IAAI;AAAA,GADH,gBAET;AAEA;AAAA,EADC,SAAS;AAAA,GAHD,gBAIT;;;AC3BJ,IAAM,WAAN,cAAuB,eAAe;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKP,YAAY,SAAmC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW,IAAI,eAAe,IAAI;AAAA,EAC3C;AACJ;","names":["EventKind","ToolStatus","Role"]}
1
+ {"version":3,"sources":["../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts","../src/index.ts"],"sourcesContent":["import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n","import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,wBAAwB;AAgB1B,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAIR,YAAY,SAAoC;AAC5C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QAAQ,SAA2B,QAAsB;AAC5D,UAAM,QAAkB,CAAC;AACzB,QAAI,UAA+B;AACnC,QAAI,OAAO;AAEX,qBAAiB,GAAG,KAAK,OAAO,IAAI;AAAA,MAChC,SAAS;A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
1
  {
2
2
  "name": "@haylee-ai/chat-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Haylee AI Chat SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",