@afncdelacru/brady-chat 0.4.7 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -33,13 +33,14 @@ interface BradyChatContextType {
33
33
  resetMode: () => void;
34
34
  calculatorOpen: boolean;
35
35
  setCalculatorOpen: (open: boolean) => void;
36
+ inputDisabled: boolean;
37
+ setInputDisabled: React.Dispatch<React.SetStateAction<boolean>>;
38
+ showModePrompts: boolean;
39
+ setShowModePrompts: React.Dispatch<React.SetStateAction<boolean>>;
36
40
  isHidden: boolean;
37
41
  setIsHidden: React.Dispatch<React.SetStateAction<boolean>>;
38
42
  hideBradyForModal: () => void;
39
43
  restoreBradyAfterModal: () => void;
40
- setUserText: (text: string) => void;
41
- userTextToSend?: string;
42
- setUserTextToSend?: (text: string | undefined) => void;
43
44
  }
44
45
  declare function BradyChatProvider({ children }: {
45
46
  children: ReactNode;
@@ -58,12 +59,8 @@ interface EnhancedBradyChatProps {
58
59
  * Typically you pass something like `/bradyIcon.png` from your app's public assets.
59
60
  */
60
61
  avatarSrc: string;
61
- /**
62
- * If set, will immediately set the input value and send it as a user message.
63
- */
64
- setUserText?: string;
65
62
  }
66
- declare function EnhancedBradyChat({ modeVariant, avatarSrc, setUserText }: EnhancedBradyChatProps): react_jsx_runtime.JSX.Element;
63
+ declare function EnhancedBradyChat({ modeVariant, avatarSrc }: EnhancedBradyChatProps): react_jsx_runtime.JSX.Element;
67
64
 
68
65
  declare const DEFAULT_BRADY_API_KEY: string;
69
66
  declare const API_URL: string;
@@ -86,4 +83,4 @@ interface BradyChatResponse {
86
83
  declare function sendBradyPrompt(messages: BradyMessage[], apiKey?: string): Promise<BradyChatResponse>;
87
84
  declare function checkBradyHealth(): Promise<boolean>;
88
85
 
89
- export { API_URL, type BradyChatContextType, BradyChatProvider, type BradyChatRequest, type BradyChatResponse, type BradyMessage, type ChatMessage, type ChatWorkflowType, DEFAULT_BRADY_API_KEY, EnhancedBradyChat, type EnhancedBradyChatProps, type ModeStep, type ModeType, checkBradyHealth, sendBradyPrompt, useBradyChat };
86
+ export { API_URL, BradyChatProvider, type BradyChatRequest, type BradyChatResponse, type BradyMessage, type ChatMessage, type ChatWorkflowType, DEFAULT_BRADY_API_KEY, EnhancedBradyChat, type EnhancedBradyChatProps, type ModeStep, type ModeType, checkBradyHealth, sendBradyPrompt, useBradyChat };
package/dist/index.d.ts CHANGED
@@ -33,13 +33,14 @@ interface BradyChatContextType {
33
33
  resetMode: () => void;
34
34
  calculatorOpen: boolean;
35
35
  setCalculatorOpen: (open: boolean) => void;
36
+ inputDisabled: boolean;
37
+ setInputDisabled: React.Dispatch<React.SetStateAction<boolean>>;
38
+ showModePrompts: boolean;
39
+ setShowModePrompts: React.Dispatch<React.SetStateAction<boolean>>;
36
40
  isHidden: boolean;
37
41
  setIsHidden: React.Dispatch<React.SetStateAction<boolean>>;
38
42
  hideBradyForModal: () => void;
39
43
  restoreBradyAfterModal: () => void;
40
- setUserText: (text: string) => void;
41
- userTextToSend?: string;
42
- setUserTextToSend?: (text: string | undefined) => void;
43
44
  }
44
45
  declare function BradyChatProvider({ children }: {
45
46
  children: ReactNode;
@@ -58,12 +59,8 @@ interface EnhancedBradyChatProps {
58
59
  * Typically you pass something like `/bradyIcon.png` from your app's public assets.
59
60
  */
60
61
  avatarSrc: string;
61
- /**
62
- * If set, will immediately set the input value and send it as a user message.
63
- */
64
- setUserText?: string;
65
62
  }
66
- declare function EnhancedBradyChat({ modeVariant, avatarSrc, setUserText }: EnhancedBradyChatProps): react_jsx_runtime.JSX.Element;
63
+ declare function EnhancedBradyChat({ modeVariant, avatarSrc }: EnhancedBradyChatProps): react_jsx_runtime.JSX.Element;
67
64
 
68
65
  declare const DEFAULT_BRADY_API_KEY: string;
69
66
  declare const API_URL: string;
@@ -86,4 +83,4 @@ interface BradyChatResponse {
86
83
  declare function sendBradyPrompt(messages: BradyMessage[], apiKey?: string): Promise<BradyChatResponse>;
87
84
  declare function checkBradyHealth(): Promise<boolean>;
88
85
 
89
- export { API_URL, type BradyChatContextType, BradyChatProvider, type BradyChatRequest, type BradyChatResponse, type BradyMessage, type ChatMessage, type ChatWorkflowType, DEFAULT_BRADY_API_KEY, EnhancedBradyChat, type EnhancedBradyChatProps, type ModeStep, type ModeType, checkBradyHealth, sendBradyPrompt, useBradyChat };
86
+ export { API_URL, BradyChatProvider, type BradyChatRequest, type BradyChatResponse, type BradyMessage, type ChatMessage, type ChatWorkflowType, DEFAULT_BRADY_API_KEY, EnhancedBradyChat, type EnhancedBradyChatProps, type ModeStep, type ModeType, checkBradyHealth, sendBradyPrompt, useBradyChat };
package/dist/index.js CHANGED
@@ -40,16 +40,14 @@ var initialMessages = [
40
40
  }
41
41
  ];
42
42
  function BradyChatProvider({ children }) {
43
- const [userTextToSend, setUserTextToSend] = (0, import_react.useState)(void 0);
44
- const setUserText = (text) => {
45
- setUserTextToSend(text);
46
- };
47
43
  const [workflowType, setWorkflowType] = (0, import_react.useState)("free");
48
44
  const [messages, setMessages] = (0, import_react.useState)(initialMessages);
49
45
  const [activeMode, setActiveMode] = (0, import_react.useState)("none");
50
46
  const [modeStep, setModeStep] = (0, import_react.useState)("initial");
51
47
  const [modeData, setModeData] = (0, import_react.useState)({});
52
48
  const [calculatorOpen, setCalculatorOpen] = (0, import_react.useState)(false);
49
+ const [inputDisabled, setInputDisabled] = (0, import_react.useState)(false);
50
+ const [showModePrompts, setShowModePrompts] = (0, import_react.useState)(false);
53
51
  const [isHidden, setIsHidden] = (0, import_react.useState)(true);
54
52
  const [wasBradyVisibleBeforeModal, setWasBradyVisibleBeforeModal] = (0, import_react.useState)(false);
55
53
  const hideBradyForModal = () => {
@@ -128,6 +126,9 @@ function BradyChatProvider({ children }) {
128
126
  setModeData({});
129
127
  setCalculatorOpen(false);
130
128
  setWorkflowType("free");
129
+ setMessages(initialMessages);
130
+ setInputDisabled(false);
131
+ setShowModePrompts(false);
131
132
  };
132
133
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
134
  BradyChatContext.Provider,
@@ -148,14 +149,14 @@ function BradyChatProvider({ children }) {
148
149
  resetMode,
149
150
  calculatorOpen,
150
151
  setCalculatorOpen,
152
+ inputDisabled,
153
+ setInputDisabled,
154
+ showModePrompts,
155
+ setShowModePrompts,
151
156
  isHidden,
152
157
  setIsHidden,
153
158
  hideBradyForModal,
154
- restoreBradyAfterModal,
155
- setUserText,
156
- // Expose userTextToSend and setUserTextToSend for EnhancedBradyChat
157
- userTextToSend,
158
- setUserTextToSend
159
+ restoreBradyAfterModal
159
160
  },
160
161
  children
161
162
  }
@@ -927,7 +928,7 @@ function ImageWithFallback(props) {
927
928
 
928
929
  // src/lib/EnhancedBradyChat.tsx
929
930
  var import_jsx_runtime8 = require("react/jsx-runtime");
930
- function EnhancedBradyChat({ modeVariant = "loan-officer", avatarSrc, setUserText }) {
931
+ function EnhancedBradyChat({ modeVariant = "loan-officer", avatarSrc }) {
931
932
  const [bradyHealthy, setBradyHealthy] = (0, import_react11.useState)(true);
932
933
  const {
933
934
  workflowType,
@@ -943,37 +944,15 @@ function EnhancedBradyChat({ modeVariant = "loan-officer", avatarSrc, setUserTex
943
944
  setCalculatorOpen,
944
945
  activateMode,
945
946
  resetMode,
947
+ inputDisabled,
948
+ setInputDisabled,
949
+ showModePrompts,
950
+ setShowModePrompts,
946
951
  isHidden,
947
- setIsHidden,
948
- // Add userTextToSend and setUserTextToSend from context
949
- setUserText: contextSetUserText,
950
- // @ts-ignore: context type not updated yet
951
- userTextToSend,
952
- // @ts-ignore: context type not updated yet
953
- setUserTextToSend
952
+ setIsHidden
954
953
  } = useBradyChat();
955
954
  const [inputValue, setInputValue] = (0, import_react11.useState)("");
956
- const [setUserTextSent, setSetUserTextSent] = (0, import_react11.useState)(void 0);
957
- (0, import_react11.useEffect)(() => {
958
- if (userTextToSend && userTextToSend !== setUserTextSent) {
959
- setInputValue(userTextToSend);
960
- setSetUserTextSent(userTextToSend);
961
- }
962
- }, [userTextToSend, setUserTextSent]);
963
- (0, import_react11.useEffect)(() => {
964
- if (setUserText && setUserText !== setUserTextSent) {
965
- setInputValue(setUserText);
966
- setSetUserTextSent(setUserText);
967
- }
968
- }, [setUserText, setUserTextSent]);
969
- (0, import_react11.useEffect)(() => {
970
- if ((setUserText && setUserTextSent === setUserText && inputValue === setUserText || userTextToSend && setUserTextSent === userTextToSend && inputValue === userTextToSend) && inputValue.trim()) {
971
- handleSend();
972
- }
973
- }, [inputValue, setUserText, setUserTextSent, userTextToSend]);
974
955
  const [showForm, setShowForm] = (0, import_react11.useState)(false);
975
- const [inputDisabled, setInputDisabled] = (0, import_react11.useState)(false);
976
- const [showModePrompts, setShowModePrompts] = (0, import_react11.useState)(false);
977
956
  const messagesEndRef = (0, import_react11.useRef)(null);
978
957
  const [suggestionLinks, setSuggestionLinks] = (0, import_react11.useState)(null);
979
958
  const isBranchManager = modeVariant === "branch-manager";
@@ -1178,9 +1157,6 @@ I'll focus on ways to increase ${isBranchManager ? "profit" : "income"} using ${
1178
1157
  const userText = inputValue;
1179
1158
  addMessage({ type: "user", text: userText });
1180
1159
  setInputValue("");
1181
- if (userTextToSend && setUserTextSent === userTextToSend && setUserTextToSend) {
1182
- setUserTextToSend(void 0);
1183
- }
1184
1160
  try {
1185
1161
  const apiResponse = await sendBradyPrompt([{ role: "user", content: userText }]);
1186
1162
  let mappedType = "brady";