guideai-app 0.4.3-9 → 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.
Files changed (40) hide show
  1. package/dist/GuideAI.js +1 -1
  2. package/dist/GuideAI.js.map +1 -1
  3. package/dist/components/AnimatedSettingsItem.d.ts +9 -0
  4. package/dist/components/Microphone.d.ts +1 -2
  5. package/dist/components/MuteButton.d.ts +1 -5
  6. package/dist/components/ResetButton.d.ts +2 -6
  7. package/dist/components/SettingsMenu.d.ts +16 -0
  8. package/dist/components/SettingsToggle.d.ts +7 -0
  9. package/dist/components/TranscriptBox.d.ts +4 -2
  10. package/dist/components/TranscriptToggle.d.ts +1 -4
  11. package/dist/hooks/index.d.ts +3 -0
  12. package/dist/hooks/useGuideAIAPI.d.ts +22 -0
  13. package/dist/hooks/useTranscriptState.d.ts +21 -0
  14. package/dist/hooks/useWebRTC.d.ts +63 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/types/GuideAI.types.d.ts +1 -2
  17. package/dist/utils/api.d.ts +16 -12
  18. package/dist/utils/constants.d.ts +17 -3
  19. package/dist/utils/conversationManager.d.ts +89 -0
  20. package/dist/utils/dataChannel.d.ts +25 -27
  21. package/dist/utils/elementInteractions.d.ts +1 -1
  22. package/dist/utils/isChromeExtension.d.ts +5 -0
  23. package/dist/utils/localStorageHelper.d.ts +57 -0
  24. package/dist/utils/logger.d.ts +7 -7
  25. package/dist/utils/messageStorage.d.ts +3 -5
  26. package/dist/utils/positionUtils.d.ts +39 -0
  27. package/dist/utils/webrtcConnection.d.ts +56 -0
  28. package/dist/visualContext/VisualContextScheduler.d.ts +11 -14
  29. package/dist/visualContext/domChangeTracker.d.ts +16 -0
  30. package/dist/visualContext/index.d.ts +8 -1
  31. package/dist/visualContext/types.d.ts +4 -0
  32. package/dist/visualContext/useVisualContext.d.ts +32 -0
  33. package/package.json +4 -2
  34. package/dist/metric/event-listner.d.ts +0 -143
  35. package/dist/metric/index.d.ts +0 -2
  36. package/dist/metric/metadata-tracker.d.ts +0 -50
  37. package/dist/types/metadata.types.d.ts +0 -48
  38. package/dist/utils/gemini.d.ts +0 -5
  39. package/dist/utils/highlightAndClick.d.ts +0 -3
  40. package/dist/utils/hoverAndClick.d.ts +0 -4
@@ -0,0 +1,9 @@
1
+ interface AnimatedSettingsItemProps {
2
+ visible: boolean;
3
+ gap: number;
4
+ isLast?: boolean;
5
+ children: React.ReactNode;
6
+ React: typeof import('react');
7
+ }
8
+ declare const AnimatedSettingsItem: ({ visible, gap, isLast, children, React }: AnimatedSettingsItemProps) => import("react").JSX.Element;
9
+ export default AnimatedSettingsItem;
@@ -3,7 +3,6 @@ interface MicrophoneProps {
3
3
  componentRef: React.RefObject<HTMLDivElement>;
4
4
  baseStyles: React.CSSProperties;
5
5
  hasInteracted: boolean;
6
- ephemeralToken: string | null;
7
6
  popupPosition: PopupPosition;
8
7
  showOnboarding: boolean;
9
8
  handleOnboardingComplete: () => void;
@@ -16,5 +15,5 @@ interface MicrophoneProps {
16
15
  isMuted: boolean;
17
16
  React: typeof import('react');
18
17
  }
19
- declare const Microphone: ({ componentRef, baseStyles, hasInteracted, ephemeralToken, popupPosition, showOnboarding, handleOnboardingComplete, handleOnboardingClose, isConnecting, status, handleToggleConversation, showTranscript, hasMic, isMuted, React }: MicrophoneProps) => import("react").JSX.Element;
18
+ declare const Microphone: ({ componentRef, baseStyles, hasInteracted, popupPosition, showOnboarding, handleOnboardingComplete, handleOnboardingClose, isConnecting, status, handleToggleConversation, showTranscript, hasMic, isMuted, React }: MicrophoneProps) => import("react").JSX.Element;
20
19
  export default Microphone;
@@ -1,15 +1,11 @@
1
- import { TranscriptPosition, MicButtonPosition } from '../types/GuideAI.types';
2
1
  interface MuteButtonProps {
3
- transcriptPosition: TranscriptPosition;
4
- micPosition?: MicButtonPosition;
5
2
  hasMic: boolean;
6
3
  isMuted?: boolean;
7
4
  handleToggleMute?: () => void;
8
- isConversationActive?: boolean;
9
5
  React: typeof import('react');
10
6
  }
11
7
  declare const MuteButton: {
12
- ({ transcriptPosition, micPosition, hasMic, isMuted, handleToggleMute, isConversationActive, React }: MuteButtonProps): import("react").JSX.Element | null;
8
+ ({ hasMic, isMuted, handleToggleMute, React }: MuteButtonProps): import("react").JSX.Element;
13
9
  displayName: string;
14
10
  };
15
11
  export default MuteButton;
@@ -1,13 +1,9 @@
1
- import { TranscriptPosition, MicButtonPosition } from '../types/GuideAI.types';
2
1
  interface ResetButtonProps {
3
- transcriptPosition: TranscriptPosition;
4
- micPosition?: MicButtonPosition;
5
- isConversationActive?: boolean;
6
- handleResetChatHistory?: () => void;
2
+ handleResetChat?: () => void;
7
3
  React: typeof import('react');
8
4
  }
9
5
  declare const ResetButton: {
10
- ({ transcriptPosition, micPosition, isConversationActive, handleResetChatHistory, React }: ResetButtonProps): import("react").JSX.Element | null;
6
+ ({ handleResetChat, React }: ResetButtonProps): import("react").JSX.Element;
11
7
  displayName: string;
12
8
  };
13
9
  export default ResetButton;
@@ -0,0 +1,16 @@
1
+ import { TranscriptPosition, MicButtonPosition } from '../types/GuideAI.types';
2
+ interface SettingsMenuProps {
3
+ handleResetChat?: () => void;
4
+ hasMic: boolean;
5
+ isMuted: boolean;
6
+ handleToggleMute: () => void;
7
+ showTranscript: boolean;
8
+ handleToggleTranscript: () => void;
9
+ showSettings: boolean;
10
+ setShowSettings?: (value: boolean) => void;
11
+ transcriptPosition: TranscriptPosition;
12
+ micPosition?: MicButtonPosition;
13
+ React: typeof import('react');
14
+ }
15
+ declare const SettingsMenu: ({ handleResetChat, hasMic, isMuted, handleToggleMute, showTranscript, handleToggleTranscript, showSettings, setShowSettings, transcriptPosition, micPosition, React }: SettingsMenuProps) => import("react").JSX.Element;
16
+ export default SettingsMenu;
@@ -0,0 +1,7 @@
1
+ interface SettingsToggleProps {
2
+ showSettings: boolean;
3
+ setShowSettings?: (value: boolean) => void;
4
+ React: typeof import('react');
5
+ }
6
+ declare const SettingsToggle: ({ showSettings, setShowSettings, React }: SettingsToggleProps) => import("react").JSX.Element;
7
+ export default SettingsToggle;
@@ -18,12 +18,14 @@ interface TranscriptBoxProps {
18
18
  isMuted?: boolean;
19
19
  handleToggleMute?: () => void;
20
20
  isConversationActive?: boolean;
21
- handleResetChatHistory?: () => void;
21
+ handleResetChat?: () => void;
22
+ showSettings?: boolean;
23
+ setShowSettings?: (value: boolean) => void;
22
24
  isDataChannelOpen?: boolean;
23
25
  React: typeof import('react');
24
26
  }
25
27
  declare const TranscriptBox: {
26
- ({ allMessages, showTranscript, handleCloseTranscript, showToggleButton, handleToggleTranscript, showTextInput, textInput, setTextInput, handleTextSubmit, handleTextKeyPress, textPlaceholder, micPosition, transcriptPosition, hasMic, isMuted, handleToggleMute, isConversationActive, handleResetChatHistory, isDataChannelOpen, React }: TranscriptBoxProps): import("react").JSX.Element | null;
28
+ ({ allMessages, showTranscript, handleCloseTranscript, handleToggleTranscript, showTextInput, textInput, setTextInput, handleTextSubmit, handleTextKeyPress, textPlaceholder, micPosition, transcriptPosition, hasMic, isMuted, handleToggleMute, isConversationActive, handleResetChat, showSettings, setShowSettings, isDataChannelOpen, React }: TranscriptBoxProps): import("react").JSX.Element | null;
27
29
  displayName: string;
28
30
  };
29
31
  export default TranscriptBox;
@@ -1,10 +1,7 @@
1
- import { TranscriptPosition, MicButtonPosition } from '../types/GuideAI.types';
2
1
  interface TranscriptToggleProps {
3
- transcriptPosition: TranscriptPosition;
4
- micPosition?: MicButtonPosition;
5
2
  showTranscript: boolean;
6
3
  handleToggleTranscript?: () => void;
7
4
  React: typeof import('react');
8
5
  }
9
- declare const TranscriptToggle: ({ transcriptPosition, micPosition, showTranscript, handleToggleTranscript, React }: TranscriptToggleProps) => import("react").JSX.Element;
6
+ declare const TranscriptToggle: ({ showTranscript, handleToggleTranscript, React }: TranscriptToggleProps) => import("react").JSX.Element;
10
7
  export default TranscriptToggle;
@@ -0,0 +1,3 @@
1
+ export { useGuideAIAPI } from './useGuideAIAPI';
2
+ export { useTranscriptState } from './useTranscriptState';
3
+ export { useWebRTC } from './useWebRTC';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Exposes GuideAI methods globally on window for external access.
3
+ */
4
+ import type { UseEffectHook } from '../types/GuideAI.types';
5
+ export interface UseGuideAIAPIParams {
6
+ useEffect: UseEffectHook;
7
+ organizationKey: string;
8
+ setShowTranscript: (value: React.SetStateAction<boolean>) => void;
9
+ showTranscript: boolean;
10
+ setInputMode: (mode: 'voice' | 'text') => void;
11
+ setShowTextInput: (value: React.SetStateAction<boolean>) => void;
12
+ inputMode: 'voice' | 'text';
13
+ setTextInput: (value: React.SetStateAction<string>) => void;
14
+ inputOptions?: {
15
+ enableTextInput?: boolean;
16
+ };
17
+ isConversationActive: boolean;
18
+ handleToggleInputMode: () => void;
19
+ handleTextSubmit: (text?: string) => Promise<void>;
20
+ visualContextWindowAPI: any;
21
+ }
22
+ export declare function useGuideAIAPI(params: UseGuideAIAPIParams): void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Manages transcript/message state: sync from storage, streaming updates.
3
+ */
4
+ import type { StoredMessage } from '../utils/messageStorage';
5
+ import type { RecordingStatus } from '../types/GuideAI.types';
6
+ export interface UseTranscriptStateParams {
7
+ hooks: {
8
+ useRef: <T>(initialValue: T) => {
9
+ current: T;
10
+ };
11
+ useCallback: <T extends (...args: any[]) => any>(callback: T, deps: any[]) => T;
12
+ };
13
+ organizationKey: string;
14
+ setAllMessages: React.Dispatch<React.SetStateAction<StoredMessage[]>>;
15
+ setStatus: (status: RecordingStatus) => void;
16
+ }
17
+ export declare function useTranscriptState(params: UseTranscriptStateParams): {
18
+ syncMessagesFromStorage: () => StoredMessage[];
19
+ cleanupStreamingMessageState: () => void;
20
+ updateStreamingMessage: (text: string) => void;
21
+ };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * WebRTC connection management hook.
3
+ * Handles peer connection, data channel, audio element refs, cleanup, and initialization.
4
+ */
5
+ import { WebRTCConnection } from '../utils/webrtcConnection';
6
+ import { DataChannelManager } from '../utils/dataChannel';
7
+ import { ConversationManager } from '../utils/conversationManager';
8
+ import type { RecordingStatus } from '../types/GuideAI.types';
9
+ import type { GuideAIEnvironment } from '../types/GuideAI.types';
10
+ import type { StoredMessage } from '../utils/messageStorage';
11
+ export interface UseWebRTCParams {
12
+ hooks: {
13
+ useRef: <T>(initialValue: T) => {
14
+ current: T;
15
+ };
16
+ useCallback: <T extends (...args: any[]) => any>(callback: T, deps: any[]) => T;
17
+ };
18
+ organizationKey: string;
19
+ environment: GuideAIEnvironment;
20
+ setIsDataChannelOpen: (open: boolean) => void;
21
+ setIsConnecting: (connecting: boolean) => void;
22
+ setStatus: (status: RecordingStatus) => void;
23
+ handleHighlightThenClick: (out: any) => Promise<boolean>;
24
+ handleHoverThenClick: (out: any) => Promise<boolean>;
25
+ handleHover: (out: any) => Promise<boolean>;
26
+ handleGoToAElmLink: (linkText: string, delay?: number) => Promise<boolean>;
27
+ handleResetChatRef: {
28
+ current: () => Promise<void>;
29
+ };
30
+ endConversationSessionRef: {
31
+ current: () => void;
32
+ };
33
+ updateStreamingMessage: (text: string) => void;
34
+ cleanupStreamingMessageState: () => void;
35
+ allMessages: StoredMessage[];
36
+ status: RecordingStatus;
37
+ conversationManagerRef: {
38
+ current: ConversationManager | null;
39
+ };
40
+ onMessageLogged: () => void;
41
+ }
42
+ export declare function useWebRTC(params: UseWebRTCParams): {
43
+ peerConnectionRef: {
44
+ current: RTCPeerConnection | null;
45
+ };
46
+ dataChannelManagerRef: {
47
+ current: DataChannelManager | null;
48
+ };
49
+ mediaStreamRef: {
50
+ current: MediaStream | null;
51
+ };
52
+ audioElementRef: {
53
+ current: HTMLAudioElement | null;
54
+ };
55
+ webrtcConnectionRef: {
56
+ current: WebRTCConnection | null;
57
+ };
58
+ conversationIdRef: {
59
+ current: string | null;
60
+ };
61
+ cleanupWebRTC: () => void;
62
+ initializeWebRTC: (audioStream: MediaStream | null) => Promise<boolean>;
63
+ };
package/dist/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export type { GuideAIProps, GuideAIEnvironment } from './types/GuideAI.types';
6
6
  export * from './visualContext';
7
7
  export * from './visualContext/types';
8
8
  export { getSessionId, clearSessionId, peekSessionId } from './utils/session';
9
+ export { STORAGE_KEYS } from './utils/localStorageHelper';
@@ -1,5 +1,5 @@
1
1
  import { VisualContextConfig } from '../visualContext/types';
2
- export type RecordingStatus = 'idle' | 'recording' | 'processing' | 'playing';
2
+ export type RecordingStatus = 'idle' | 'recording' | 'active' | 'processing' | 'playing';
3
3
  export type UseStateHook = <T>(initialState: T | (() => T)) => [T, (value: T | ((prev: T) => T)) => void];
4
4
  export type UseEffectHook = (effect: () => void | (() => void), deps?: any[]) => void;
5
5
  export type UseRefHook = <T>(initialValue: T) => {
@@ -29,7 +29,6 @@ export interface GuideAIProps {
29
29
  position?: GuideAIPosition;
30
30
  transcript?: {
31
31
  enabled?: boolean;
32
- showToggleButton?: boolean;
33
32
  position?: TranscriptPosition;
34
33
  };
35
34
  input?: {
@@ -1,21 +1,25 @@
1
1
  import { GuideAIEnvironment } from '../types/GuideAI.types';
2
- interface Workflow {
2
+ import { MessageData } from './conversationManager';
3
+ export declare function getApiHeaders(): Record<string, string>;
4
+ export interface Workflow {
3
5
  id: string;
4
6
  name: string;
5
7
  triggers: string[];
6
8
  organizationKey: string;
7
9
  prompt: string;
8
- archived: boolean;
9
- createdAt: string;
10
- updatedAt: string;
10
+ archived?: boolean;
11
+ createdAt?: string;
12
+ updatedAt?: string;
11
13
  }
12
- interface ConversationData {
13
- tokenExpiresAt: number;
14
+ export interface InitializeWebRTCPayload {
15
+ sdp: string;
16
+ organizationKey: string;
17
+ user?: string;
18
+ conversationId?: string;
19
+ }
20
+ export interface InitializeWebRTCResponse {
21
+ answerSdp: string;
14
22
  id: string;
15
- ephemeralToken: string;
16
- prompt: string;
17
- workflows: Workflow[];
18
23
  }
19
- export declare const createNewConversation: (organizationKey: string, workflowKey?: string, environment?: GuideAIEnvironment) => Promise<ConversationData | null>;
20
- export type { Workflow };
21
- export declare const logMessage: (content: string, sender: "GUIDEAI" | "HUMAN", conversationId: string | null, organizationKey: string, environment?: GuideAIEnvironment) => Promise<void>;
24
+ export declare const initializeWebRTC: (endpoint: string, payload: InitializeWebRTCPayload) => Promise<InitializeWebRTCResponse>;
25
+ export declare const logMessage: (messageData: MessageData, conversationId: string | null, organizationKey: string, user?: string, environment?: GuideAIEnvironment) => Promise<void>;
@@ -1,8 +1,22 @@
1
1
  export declare const DEFAULT_PROMPT = "you are Guide AI.\n Your role is to answer any question directly and succinctly that a user has. NEVER DIRECTLY MENTION THE SCREENSHOT, but use its information as much as possible to target your responses.\n If nothing is asked, then your goal is to generally assist them.\n IMPORTANT: NEVER answer in more than 10 words. Always be concise and limit answers to 1 sentence maximum. Be simple and as short as possible.\n Your job is to help them get it done through asking more and more targeted specific questions.";
2
- export declare const GUIDE_AI_API_BASE_PROD = "https://www.getguide.ai/api";
2
+ export declare const GUIDE_AI_API_BASE_PROD = "https://app.getguide.ai/api";
3
3
  export declare const GUIDE_AI_API_BASE_DEV = "https://dev.getguide.ai/api";
4
4
  export declare const GUIDE_AI_API_BASE_LOCAL = "http://localhost:3000/api";
5
5
  export declare const getApiBaseUrl: (environment?: "development" | "production" | "local") => string;
6
- export declare const GUIDE_AI_API_BASE = "https://www.getguide.ai/api";
7
- export declare const OPENAI_REALTIME_BASE = "https://api.openai.com/v1/realtime";
6
+ export declare const GUIDE_AI_API_BASE = "https://app.getguide.ai/api";
7
+ export declare const OPENAI_REALTIME_BASE = "https://api.openai.com/v1/realtime/calls";
8
8
  export type ElementInteractionType = "HIGHLIGHT" | "HOVERANDCLICK";
9
+ export declare const UI_LAYOUT: {
10
+ /** Mic/icon wrapper size - matches .guideai-icon-wrapper */
11
+ readonly micButtonSize: 50;
12
+ /** Space between mic top and lowest toggle bottom */
13
+ readonly toggleAboveMicGap: 12;
14
+ /** Gap between stacked buttons (e.g. transcript above settings) */
15
+ readonly stackedButtonGap: 8;
16
+ /** Horizontal offset from edge when using right/left positioning */
17
+ readonly horizontalEdgeOffset: 6;
18
+ /** Default bottom when micPosition is not provided */
19
+ readonly defaultBottom: 20;
20
+ /** Default horizontal offset when position is not provided */
21
+ readonly defaultHorizontalOffset: 40;
22
+ };
@@ -0,0 +1,89 @@
1
+ import { GuideAIEnvironment } from '../types/GuideAI.types';
2
+ /**
3
+ * Message type options
4
+ */
5
+ export type MessageType = 'log' | 'voice' | 'text' | 'action' | 'error' | 'screenshot';
6
+ /**
7
+ * Sender type options
8
+ */
9
+ export type MessageSender = 'GUIDEAI' | 'HUMAN' | 'SYSTEM';
10
+ /**
11
+ * Message data structure for API
12
+ */
13
+ export interface MessageData {
14
+ content: string;
15
+ sender: MessageSender;
16
+ type: MessageType;
17
+ url?: string;
18
+ session?: string;
19
+ logdata?: any;
20
+ }
21
+ /**
22
+ * ConversationManager class
23
+ * Centralized message logging with validation and automatic field population
24
+ */
25
+ export declare class ConversationManager {
26
+ private organizationKey;
27
+ private conversationId;
28
+ private environment?;
29
+ private allMessages;
30
+ private onMessageLogged?;
31
+ constructor(organizationKey: string, conversationId: string | null, environment?: GuideAIEnvironment, onMessageLogged?: () => void);
32
+ /**
33
+ * Update conversation ID (called when conversation is created/updated)
34
+ */
35
+ setConversationId(conversationId: string | null): void;
36
+ /**
37
+ * Update session ID in localStorage
38
+ */
39
+ updateSessionId(sessionId: string | null): void;
40
+ /**
41
+ * Refresh messages from storage
42
+ */
43
+ refreshMessages(): void;
44
+ /**
45
+ * Primary utility function for logging messages
46
+ * Handles validation, duplicate checking, and field population
47
+ */
48
+ private logMessage;
49
+ /**
50
+ * Private wrapper for logMessage - defaults type to voice
51
+ */
52
+ private logVoiceMessage;
53
+ /**
54
+ * Public wrapper - log user voice message
55
+ */
56
+ logUserVoiceMessage(content: string): Promise<void>;
57
+ /**
58
+ * Public wrapper - log GuideAI voice message
59
+ */
60
+ logGuideAIMessage(content: string): Promise<void>;
61
+ /**
62
+ * Public wrapper - log data message (type defaults to 'log')
63
+ */
64
+ logDataMessage(content: string, data?: any, type?: any): void;
65
+ /**
66
+ * Private wrapper for logMessage - defaults type to text
67
+ */
68
+ private logTextMessage;
69
+ /**
70
+ * Public wrapper - log user text message
71
+ */
72
+ logUserTextMessage(content: string): Promise<void>;
73
+ /**
74
+ * Public wrapper - log action message
75
+ */
76
+ logActionMessage(content: string, data?: any): void;
77
+ /**
78
+ * Public wrapper - log debug message
79
+ */
80
+ logDebugMessage(content: string, data?: any): void;
81
+ /**
82
+ * Public wrapper - log error message
83
+ */
84
+ logErrorMessage(content: string, data?: any): void;
85
+ /**
86
+ * Public wrapper - log visual context message
87
+ */
88
+ logVisualContextMessage(content: string, data?: any): void;
89
+ }
@@ -1,12 +1,11 @@
1
- import { Workflow } from './api';
2
1
  import { StoredMessage } from './messageStorage';
3
- export type RecordingStatus = 'idle' | 'recording' | 'processing' | 'playing';
2
+ import { ConversationManager } from './conversationManager';
3
+ export type RecordingStatus = 'idle' | 'recording' | 'active' | 'processing' | 'playing';
4
4
  export declare const IGNORE_MESSAGE_TYPES: string[];
5
5
  export interface DataChannelCallbacks {
6
6
  setIsDataChannelOpen: (open: boolean) => void;
7
7
  setIsConnecting: (connecting: boolean) => void;
8
8
  setStatus: (status: RecordingStatus) => void;
9
- handleLogMessage: (content: string, sender: 'GUIDEAI' | 'HUMAN') => Promise<void>;
10
9
  handleHighlightThenClick: (out: any) => Promise<boolean>;
11
10
  handleHoverThenClick: (out: any) => Promise<boolean>;
12
11
  handleHover: (out: any) => Promise<boolean>;
@@ -14,39 +13,29 @@ export interface DataChannelCallbacks {
14
13
  onDataChannelClose: (pc: RTCPeerConnection) => void;
15
14
  onDataChannelError: (event: Event) => void;
16
15
  onDataChannelMessageError: (message: any) => void;
16
+ updateStreamingMessage: (delta: string) => void;
17
+ /** Reset streaming state when a new response starts (call on response.created) */
18
+ resetStreamingMessage?: () => void;
17
19
  allMessages: StoredMessage[];
18
20
  status: RecordingStatus;
19
- hasMic: boolean;
20
21
  organizationKey: string;
21
- prompt: string | null;
22
- workflows: Workflow[];
23
- hasCreatedConversationRef: {
24
- current: boolean;
25
- };
26
- errorHandlingTimeoutRefs: {
27
- current: Set<NodeJS.Timeout>;
28
- };
29
- updateStreamingMessage: (delta: string) => void;
30
- finalizeStreamingMessage: (finalText?: string) => void;
31
- streamingMessageRef: {
32
- current: string;
33
- };
34
- isStreamingRef: {
35
- current: boolean;
36
- };
37
- streamingMessageIdRef: {
38
- current: number | null;
22
+ /** Ref to ConversationManager - use .current when logging (set in onSessionData before data channel opens) */
23
+ conversationManagerRef: {
24
+ current: ConversationManager | null;
39
25
  };
26
+ updateSessionId?: (sessionId: string | null) => void;
40
27
  }
41
28
  export interface DataChannelConfig {
42
29
  audioStream: MediaStream | null;
43
30
  callbacks: DataChannelCallbacks;
44
31
  }
32
+ export declare const BUFFERED_AMOUNT_THRESHOLD = 65536;
45
33
  export declare class DataChannelManager {
46
34
  private dataChannel;
47
35
  private peerConnection;
48
36
  private callbacks;
49
37
  private audioStream;
38
+ private sendQueue;
50
39
  constructor(config: DataChannelConfig);
51
40
  /**
52
41
  * Create a new data channel on the peer connection
@@ -65,13 +54,26 @@ export declare class DataChannelManager {
65
54
  */
66
55
  private handleMessage;
67
56
  /**
68
- * Send a message through the data channel
57
+ * Flush queued messages when buffer has drained
58
+ */
59
+ private flushSendQueue;
60
+ /**
61
+ * Send a message through the data channel.
62
+ * Queues the message if bufferedAmount exceeds threshold; it will be sent when buffer drains.
69
63
  */
70
64
  sendMessage(message: any): void;
71
65
  /**
72
66
  * Check if the data channel is open and ready
73
67
  */
74
68
  isOpen(): boolean;
69
+ /**
70
+ * Get the current buffered amount in bytes
71
+ */
72
+ getBufferedAmount(): number;
73
+ /**
74
+ * Check if the send buffer is full (above threshold)
75
+ */
76
+ isBufferFull(): boolean;
75
77
  /**
76
78
  * Get the current data channel
77
79
  */
@@ -80,8 +82,4 @@ export declare class DataChannelManager {
80
82
  * Close and cleanup the data channel
81
83
  */
82
84
  close(): void;
83
- /**
84
- * Cleanup all resources
85
- */
86
- cleanup(): void;
87
85
  }
@@ -5,7 +5,7 @@ export interface ToolInput {
5
5
  }
6
6
  export declare const HOVER_EFFECT_KEEP_ALIVE_TIME = 3000;
7
7
  export declare const createHoverEffect: (element: Element, initialRect: DOMRect, cursorElement?: HTMLElement | null, duration?: number) => Promise<void>;
8
- export declare const clickElement: (element: Element, rect: DOMRect, withEffects?: boolean) => Promise<void>;
8
+ export declare const clickElement: (element: Element, rect: DOMRect, withEffects?: boolean, cursorElement?: HTMLElement | null) => Promise<void>;
9
9
  export declare const parseCustomSelector: (selector: string) => {
10
10
  type: "text" | "css" | "xpath";
11
11
  cssSelector?: string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detects if the code is running inside a Chrome extension content script.
3
+ * Used for audio setup and other extension-specific behavior.
4
+ */
5
+ export declare function isChromeExtension(): boolean;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Centralized localStorage helper
3
+ * Tracks all localStorage keys used in the application
4
+ */
5
+ declare const STORAGE_KEYS: {
6
+ readonly USER_UUID: "guideAI_userUUID";
7
+ readonly SESSION_ID: "guideAI_sessionId";
8
+ readonly CONVERSATION: "guideAI_conversation";
9
+ readonly HAS_INTERACTED: "guideAI_hasInteracted";
10
+ readonly IS_MUTED: "guideAI_isMuted";
11
+ readonly LOGGER_ENABLED: "guideAI_loggerEnabled";
12
+ };
13
+ /**
14
+ * Check if localStorage is available
15
+ */
16
+ export declare const isLocalStorageAvailable: () => boolean;
17
+ /**
18
+ * Get or create user UUID
19
+ * Creates a new UUID if one doesn't exist
20
+ */
21
+ export declare const getUserUUID: () => string;
22
+ /**
23
+ * Get session ID (active OpenAI session)
24
+ */
25
+ export declare const getSessionId: () => string | null;
26
+ /**
27
+ * Set session ID
28
+ */
29
+ export declare const setSessionId: (sessionId: string | null) => void;
30
+ /**
31
+ * Get has interacted flag
32
+ */
33
+ export declare const getHasInteracted: () => boolean;
34
+ /**
35
+ * Set has interacted flag
36
+ */
37
+ export declare const setHasInteracted: (value: boolean) => void;
38
+ /**
39
+ * Get is muted flag
40
+ */
41
+ export declare const getIsMuted: () => boolean;
42
+ /**
43
+ * Set is muted flag
44
+ */
45
+ export declare const setIsMuted: (value: boolean) => void;
46
+ /**
47
+ * Get logger enabled flag (used by Logger to persist enable state)
48
+ */
49
+ export declare const getLoggerEnabled: () => boolean;
50
+ /**
51
+ * Set logger enabled flag
52
+ */
53
+ export declare const setLoggerEnabled: (value: boolean) => void;
54
+ /**
55
+ * Export storage keys for reference (read-only)
56
+ */
57
+ export { STORAGE_KEYS };
@@ -1,4 +1,4 @@
1
- type Component = 'GuideAI' | 'API' | 'TranscriptBox' | 'Onboarding' | 'VisualContext' | 'MessageStorage' | 'DataChannel';
1
+ type Component = 'GuideAI' | 'API' | 'TranscriptBox' | 'Onboarding' | 'VisualContext' | 'MessageStorage' | 'DataChannel' | 'ConversationManager' | 'LocalStorageHelper' | 'WebRTCConnection';
2
2
  declare class Logger {
3
3
  private static formatMessage;
4
4
  private static checkLoggingEnabled;
@@ -9,15 +9,15 @@ declare class Logger {
9
9
  */
10
10
  static init(): void;
11
11
  /**
12
- * Enable logging from console
13
- * Usage: GuideAILogger.enable()
12
+ * Enable logging from console, or for a specific component.
13
+ * Usage: GuideAILogger.enable() or GuideAILogger.enable('API')
14
14
  */
15
- static enable(): void;
15
+ static enable(component?: Component): void;
16
16
  /**
17
- * Disable logging from console
18
- * Usage: GuideAILogger.disable()
17
+ * Disable logging from console, or for a specific component.
18
+ * Usage: GuideAILogger.disable() or GuideAILogger.disable('API')
19
19
  */
20
- static disable(): void;
20
+ static disable(component?: Component): void;
21
21
  /**
22
22
  * Enable or disable logging for a specific component
23
23
  * Usage: GuideAILogger.setComponentEnabled('API', true)
@@ -1,6 +1,6 @@
1
1
  export interface StoredMessage {
2
2
  content: string;
3
- sender: 'GUIDEAI' | 'HUMAN';
3
+ sender: 'GUIDEAI' | 'HUMAN' | 'SYSTEM';
4
4
  timestamp: number;
5
5
  }
6
6
  export interface StoredConversation {
@@ -11,15 +11,13 @@ export interface StoredConversation {
11
11
  organizationKey: string;
12
12
  keyExpiresAt?: number;
13
13
  sessionExpiresAt?: number;
14
+ user?: string;
14
15
  }
15
16
  export declare const CONVERSATION_STORAGE_KEY = "guideAI_conversation";
16
17
  export declare const CONVERSATION_EXPIRY_MINUTES = 30;
17
18
  export declare const MAX_STORED_MESSAGES = 100;
18
19
  export declare const isLocalStorageAvailable: () => boolean;
19
- export declare const initializeConversationStorage: (organizationKey: string, conversationId: string, conversationKey: string, keyExpiresAt: number) => void;
20
- export declare const getConversationKey: (organizationKey: string) => string | null | undefined;
21
- export declare const resetConversationKey: (organizationKey: string) => void;
22
- export declare const isKeyExpired: (organizationKey: string) => boolean;
20
+ export declare const initializeConversationStorage: (organizationKey: string, conversationId: string) => void;
23
21
  export declare const isSessionExpired: (organizationKey: string) => boolean;
24
22
  export declare const isConversationExpired: (organizationKey: string) => boolean;
25
23
  export declare const updateSessionExpiresAt: (organizationKey: string, sessionExpiresAt: number) => void;