@admin-layout/demo-perplexity-browser 12.2.4-alpha.0 → 12.2.4-alpha.12
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/lib/api/index.d.ts +2 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/llm.d.ts +34 -0
- package/lib/api/llm.d.ts.map +1 -0
- package/lib/api/llm.js +200 -0
- package/lib/api/llm.js.map +1 -0
- package/lib/api/stt.d.ts +21 -0
- package/lib/api/stt.d.ts.map +1 -0
- package/lib/api/stt.js +111 -0
- package/lib/api/stt.js.map +1 -0
- package/lib/components/AttachmentPreview.d.ts +10 -0
- package/lib/components/AttachmentPreview.d.ts.map +1 -0
- package/lib/components/AttachmentPreview.js +50 -0
- package/lib/components/AttachmentPreview.js.map +1 -0
- package/lib/components/AudioRecorder.d.ts +8 -0
- package/lib/components/AudioRecorder.d.ts.map +1 -0
- package/lib/components/AudioRecorder.js +221 -0
- package/lib/components/AudioRecorder.js.map +1 -0
- package/lib/components/AudioVisualizer.d.ts +7 -0
- package/lib/components/AudioVisualizer.d.ts.map +1 -0
- package/lib/components/AudioVisualizer.js +116 -0
- package/lib/components/AudioVisualizer.js.map +1 -0
- package/lib/components/ChatFiles.d.ts +8 -0
- package/lib/components/ChatFiles.d.ts.map +1 -0
- package/lib/components/ChatFiles.js +76 -0
- package/lib/components/ChatFiles.js.map +1 -0
- package/lib/components/ChatScreenshot.d.ts +7 -0
- package/lib/components/ChatScreenshot.d.ts.map +1 -0
- package/lib/components/ChatScreenshot.js +113 -0
- package/lib/components/ChatScreenshot.js.map +1 -0
- package/lib/components/SearchBar.d.ts +9 -1
- package/lib/components/SearchBar.d.ts.map +1 -1
- package/lib/components/SearchBar.js +176 -240
- package/lib/components/SearchBar.js.map +1 -1
- package/lib/config/constants.d.ts +108 -0
- package/lib/config/constants.d.ts.map +1 -0
- package/lib/config/constants.js +115 -0
- package/lib/config/constants.js.map +1 -0
- package/lib/config/env.d.ts +20 -0
- package/lib/config/env.d.ts.map +1 -0
- package/lib/config/env.js +22 -0
- package/lib/config/env.js.map +1 -0
- package/lib/config/index.d.ts +4 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/config/providers.d.ts +54 -0
- package/lib/config/providers.d.ts.map +1 -0
- package/lib/config/providers.js +65 -0
- package/lib/config/providers.js.map +1 -0
- package/lib/pages/home/HomePage.d.ts +1 -3
- package/lib/pages/home/HomePage.d.ts.map +1 -1
- package/lib/pages/home/HomePage.js +232 -4
- package/lib/pages/home/HomePage.js.map +1 -1
- package/lib/platform/browser.d.ts +18 -0
- package/lib/platform/browser.d.ts.map +1 -0
- package/lib/platform/context.d.ts +76 -0
- package/lib/platform/context.d.ts.map +1 -0
- package/lib/platform/index.d.ts +25 -0
- package/lib/platform/index.d.ts.map +1 -0
- package/lib/platform/tauri.d.ts +35 -0
- package/lib/platform/tauri.d.ts.map +1 -0
- package/lib/platform/types.d.ts +164 -0
- package/lib/platform/types.d.ts.map +1 -0
- package/lib/state/chatMachine.d.ts +148 -0
- package/lib/state/chatMachine.d.ts.map +1 -0
- package/lib/state/chatMachine.js +458 -0
- package/lib/state/chatMachine.js.map +1 -0
- package/lib/state/index.d.ts +3 -0
- package/lib/state/index.d.ts.map +1 -0
- package/lib/state/useChatWithPlatform.d.ts +43 -0
- package/lib/state/useChatWithPlatform.d.ts.map +1 -0
- package/lib/types/chat.d.ts +56 -0
- package/lib/types/chat.d.ts.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/utils/chatStorage.d.ts +25 -0
- package/lib/utils/chatStorage.d.ts.map +1 -0
- package/lib/utils/chatStorage.js +17 -0
- package/lib/utils/chatStorage.js.map +1 -0
- package/package.json +10 -6
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Services React Context
|
|
3
|
+
*
|
|
4
|
+
* Provides platform services to React components via context.
|
|
5
|
+
* This allows the chat machine and other components to access platform-specific
|
|
6
|
+
* functionality without direct imports.
|
|
7
|
+
*/
|
|
8
|
+
import React, { type ReactNode } from 'react';
|
|
9
|
+
import type { IPlatformServices, PlatformInfo } from './types';
|
|
10
|
+
interface PlatformContextValue {
|
|
11
|
+
/** Platform services instance */
|
|
12
|
+
services: IPlatformServices;
|
|
13
|
+
/** Platform information */
|
|
14
|
+
platform: PlatformInfo;
|
|
15
|
+
/** Whether platform services are initialized */
|
|
16
|
+
isInitialized: boolean;
|
|
17
|
+
/** Any initialization error */
|
|
18
|
+
error: Error | null;
|
|
19
|
+
/** Whether running in Tauri desktop environment */
|
|
20
|
+
isDesktop: boolean;
|
|
21
|
+
/** Whether running in browser environment */
|
|
22
|
+
isBrowser: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface PlatformProviderProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
/** Optional custom platform services for testing */
|
|
27
|
+
services?: IPlatformServices;
|
|
28
|
+
}
|
|
29
|
+
export declare function PlatformProvider({ children, services: customServices }: PlatformProviderProps): React.ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* Hook to access the full platform context
|
|
32
|
+
*/
|
|
33
|
+
export declare function usePlatform(): PlatformContextValue;
|
|
34
|
+
/**
|
|
35
|
+
* Hook to access platform services directly
|
|
36
|
+
*/
|
|
37
|
+
export declare function usePlatformServices(): IPlatformServices;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to get screenshot functionality
|
|
40
|
+
*/
|
|
41
|
+
export declare function useScreenshot(): {
|
|
42
|
+
captureScreen: () => Promise<import("./types").ScreenshotResult>;
|
|
43
|
+
captureSelectedArea: () => Promise<import("./types").ScreenshotResult>;
|
|
44
|
+
cancelCapture: () => Promise<void>;
|
|
45
|
+
isAvailable: () => Promise<boolean>;
|
|
46
|
+
/** Desktop has better screenshot support */
|
|
47
|
+
hasAreaSelection: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Hook to get microphone functionality
|
|
51
|
+
*/
|
|
52
|
+
export declare function useMicrophone(): {
|
|
53
|
+
startRecording: (options?: Parameters<(options?: import("./types").MicrophoneOptions) => Promise<void>>[0]) => Promise<void>;
|
|
54
|
+
stopRecording: () => Promise<import("./types").MicrophoneRecordingResult>;
|
|
55
|
+
cancelRecording: () => Promise<void>;
|
|
56
|
+
status: "error" | "recording" | "idle" | "processing";
|
|
57
|
+
isRecording: boolean;
|
|
58
|
+
isProcessing: boolean;
|
|
59
|
+
isAvailable: () => Promise<boolean>;
|
|
60
|
+
requestPermission: () => Promise<boolean>;
|
|
61
|
+
/** Desktop has VAD support */
|
|
62
|
+
hasVoiceActivityDetection: boolean;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Hook to get storage functionality
|
|
66
|
+
*/
|
|
67
|
+
export declare function useStorage(): {
|
|
68
|
+
loadChat: () => Promise<import("./types").StoredMessage[] | null>;
|
|
69
|
+
saveChat: (messages: import("./types").StoredMessage[]) => Promise<void>;
|
|
70
|
+
clearChat: () => Promise<void>;
|
|
71
|
+
get: <T>(key: string) => Promise<T | null>;
|
|
72
|
+
set: <T>(key: string, value: T) => Promise<void>;
|
|
73
|
+
delete: (key: string) => Promise<void>;
|
|
74
|
+
};
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/platform/context.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,EAAwE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAiB/D,UAAU,oBAAoB;IAC1B,iCAAiC;IACjC,QAAQ,EAAE,iBAAiB,CAAC;IAE5B,2BAA2B;IAC3B,QAAQ,EAAE,YAAY,CAAC;IAEvB,gDAAgD;IAChD,aAAa,EAAE,OAAO,CAAC;IAEvB,+BAA+B;IAC/B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IAEnB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;CACtB;AAYD,UAAU,qBAAqB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAwDlH;AAMD;;GAEG;AACH,wBAAgB,WAAW,IAAI,oBAAoB,CAMlD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,iBAAiB,CAGvD;AAED;;GAEG;AACH,wBAAgB,aAAa;;;;;IAgCrB,4CAA4C;;EAGnD;AAED;;GAEG;AACH,wBAAgB,aAAa;+BAaJ,UAAU,kEAA2C,CAAC,CAAC,CAAC;;;;;;;;IAuBzE,8BAA8B;;EAGrC;AAED;;GAEG;AACH,wBAAgB,UAAU;;;;;;;EAWzB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Services Index
|
|
3
|
+
*
|
|
4
|
+
* This module provides the main entry point for platform services.
|
|
5
|
+
* It automatically detects the platform and provides the appropriate implementation.
|
|
6
|
+
*/
|
|
7
|
+
export * from './types';
|
|
8
|
+
export { BrowserPlatformServices, getBrowserPlatformServices } from './browser';
|
|
9
|
+
export { TauriPlatformServices, getTauriPlatformServices } from './tauri';
|
|
10
|
+
export { PlatformProvider, usePlatform, usePlatformServices, useScreenshot, useMicrophone, useStorage, } from './context';
|
|
11
|
+
export { isTauri, getPlatformInfo } from './types';
|
|
12
|
+
import type { IPlatformServices } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Get the appropriate platform services for the current environment
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPlatformServices(): IPlatformServices;
|
|
17
|
+
/**
|
|
18
|
+
* Get or create the platform services singleton
|
|
19
|
+
*/
|
|
20
|
+
export declare function getPlatformServicesInstance(): IPlatformServices;
|
|
21
|
+
/**
|
|
22
|
+
* Reset the platform services instance (useful for testing)
|
|
23
|
+
*/
|
|
24
|
+
export declare function resetPlatformServices(): void;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/platform/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAG1E,OAAO,EACH,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,UAAU,GACb,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,iBAAiB,CAQvD;AAKD;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,iBAAiB,CAK/D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAK5C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tauri (Desktop) Platform Services Implementation
|
|
3
|
+
*
|
|
4
|
+
* This module provides Tauri-specific implementations for storage, screenshot,
|
|
5
|
+
* and microphone functionality using Rust backend commands.
|
|
6
|
+
*
|
|
7
|
+
* Based on the patterns from pluely/src-tauri and adminide-stack.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: Some commands require the corresponding Rust implementation.
|
|
10
|
+
* If a command is not available, we fall back to browser APIs.
|
|
11
|
+
*
|
|
12
|
+
* Required Rust commands for full functionality:
|
|
13
|
+
* - capture_to_base64: Full screen capture
|
|
14
|
+
* - start_screen_capture: Start area selection overlay
|
|
15
|
+
* - capture_selected_area: Capture selected region
|
|
16
|
+
* - close_overlay_window: Cancel capture
|
|
17
|
+
* - start_system_audio_capture: Start microphone recording with VAD
|
|
18
|
+
* - stop_system_audio_capture: Stop recording
|
|
19
|
+
* - manual_stop_continuous: Manual stop for continuous mode
|
|
20
|
+
* - check_system_audio_access: Check microphone permission
|
|
21
|
+
* - request_system_audio_access: Request microphone permission
|
|
22
|
+
* - secure_storage_get/save/remove: Secure storage operations
|
|
23
|
+
*/
|
|
24
|
+
import type { IPlatformServices, IStorageService, IScreenshotService, IMicrophoneService, PlatformInfo } from './types';
|
|
25
|
+
export declare class TauriPlatformServices implements IPlatformServices {
|
|
26
|
+
readonly platform: PlatformInfo;
|
|
27
|
+
readonly storage: IStorageService;
|
|
28
|
+
readonly screenshot: IScreenshotService;
|
|
29
|
+
readonly microphone: IMicrophoneService;
|
|
30
|
+
constructor();
|
|
31
|
+
initialize(): Promise<void>;
|
|
32
|
+
dispose(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare function getTauriPlatformServices(): TauriPlatformServices;
|
|
35
|
+
//# sourceMappingURL=tauri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tauri.d.ts","sourceRoot":"","sources":["../../src/platform/tauri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EACR,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EASf,MAAM,SAAS,CAAC;AA+xBjB,qBAAa,qBAAsB,YAAW,iBAAiB;IAC3D,SAAgB,QAAQ,EAAE,YAAY,CAAC;IACvC,SAAgB,OAAO,EAAE,eAAe,CAAC;IACzC,SAAgB,UAAU,EAAE,kBAAkB,CAAC;IAC/C,SAAgB,UAAU,EAAE,kBAAkB,CAAC;;IASzC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAKjC;AAKD,wBAAgB,wBAAwB,IAAI,qBAAqB,CAKhE"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Services Types
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define the contract for platform-specific implementations.
|
|
5
|
+
* The same XState machine can work with different implementations depending on
|
|
6
|
+
* whether we're running in a browser or Tauri desktop environment.
|
|
7
|
+
*/
|
|
8
|
+
export type StoredAttachment = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
type: 'file' | 'screenshot';
|
|
12
|
+
};
|
|
13
|
+
export type StoredMessage = {
|
|
14
|
+
role: 'user' | 'assistant' | 'system';
|
|
15
|
+
content: string;
|
|
16
|
+
attachments?: StoredAttachment[];
|
|
17
|
+
};
|
|
18
|
+
export type StoredChat = {
|
|
19
|
+
id: string;
|
|
20
|
+
messages: StoredMessage[];
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
};
|
|
23
|
+
export type ScreenshotResult = {
|
|
24
|
+
/** Base64 encoded image data (without data URL prefix) */
|
|
25
|
+
base64: string;
|
|
26
|
+
/** Full data URL for display purposes */
|
|
27
|
+
dataUrl: string;
|
|
28
|
+
/** Timestamp when screenshot was taken */
|
|
29
|
+
timestamp: number;
|
|
30
|
+
};
|
|
31
|
+
export type ScreenshotOptions = {
|
|
32
|
+
/** Whether to open selection overlay for partial screenshot */
|
|
33
|
+
selectArea?: boolean;
|
|
34
|
+
/** Monitor index for multi-monitor setups */
|
|
35
|
+
monitorIndex?: number;
|
|
36
|
+
};
|
|
37
|
+
export type MicrophoneRecordingResult = {
|
|
38
|
+
/** Audio data as base64 encoded WAV */
|
|
39
|
+
base64: string;
|
|
40
|
+
/** Audio blob for playback or processing */
|
|
41
|
+
blob: Blob;
|
|
42
|
+
/** Duration in seconds */
|
|
43
|
+
duration: number;
|
|
44
|
+
/** Sample rate of the recording */
|
|
45
|
+
sampleRate: number;
|
|
46
|
+
};
|
|
47
|
+
export type MicrophoneOptions = {
|
|
48
|
+
/** Device ID if a specific device is desired */
|
|
49
|
+
deviceId?: string;
|
|
50
|
+
/** Sample rate for recording */
|
|
51
|
+
sampleRate?: number;
|
|
52
|
+
/** Whether to enable voice activity detection */
|
|
53
|
+
vadEnabled?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export type MicrophoneStatus = 'idle' | 'recording' | 'processing' | 'error';
|
|
56
|
+
export type PlatformType = 'browser' | 'tauri';
|
|
57
|
+
export type PlatformInfo = {
|
|
58
|
+
type: PlatformType;
|
|
59
|
+
os: 'macos' | 'windows' | 'linux' | 'web';
|
|
60
|
+
version?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Storage Service Interface
|
|
64
|
+
* Handles persistent storage of chat messages and data
|
|
65
|
+
*/
|
|
66
|
+
export interface IStorageService {
|
|
67
|
+
/** Load chat history */
|
|
68
|
+
loadChat(): Promise<StoredMessage[] | null>;
|
|
69
|
+
/** Save chat messages */
|
|
70
|
+
saveChat(messages: StoredMessage[]): Promise<void>;
|
|
71
|
+
/** Clear all chat history */
|
|
72
|
+
clearChat(): Promise<void>;
|
|
73
|
+
/** Get a generic value by key */
|
|
74
|
+
get<T>(key: string): Promise<T | null>;
|
|
75
|
+
/** Set a generic value by key */
|
|
76
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
77
|
+
/** Delete a value by key */
|
|
78
|
+
delete(key: string): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Screenshot Service Interface
|
|
82
|
+
* Handles screen capture functionality
|
|
83
|
+
*/
|
|
84
|
+
export interface IScreenshotService {
|
|
85
|
+
/** Check if screenshot capability is available */
|
|
86
|
+
isAvailable(): Promise<boolean>;
|
|
87
|
+
/** Capture the entire screen or selected monitor */
|
|
88
|
+
captureScreen(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
89
|
+
/** Capture a selected area (opens overlay for selection) */
|
|
90
|
+
captureSelectedArea(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
91
|
+
/** Cancel any ongoing capture operation */
|
|
92
|
+
cancelCapture(): Promise<void>;
|
|
93
|
+
/** Listen for captured selection events (for Tauri overlay flow) */
|
|
94
|
+
onCapturedSelection?(callback: (result: ScreenshotResult) => void): () => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Microphone Service Interface
|
|
98
|
+
* Handles audio recording functionality
|
|
99
|
+
*/
|
|
100
|
+
export interface IMicrophoneService {
|
|
101
|
+
/** Check if microphone access is available */
|
|
102
|
+
isAvailable(): Promise<boolean>;
|
|
103
|
+
/** Request microphone permission */
|
|
104
|
+
requestPermission(): Promise<boolean>;
|
|
105
|
+
/** Start recording */
|
|
106
|
+
startRecording(options?: MicrophoneOptions): Promise<void>;
|
|
107
|
+
/** Stop recording and get the result */
|
|
108
|
+
stopRecording(): Promise<MicrophoneRecordingResult>;
|
|
109
|
+
/** Cancel recording without returning data */
|
|
110
|
+
cancelRecording(): Promise<void>;
|
|
111
|
+
/** Get current recording status */
|
|
112
|
+
getStatus(): MicrophoneStatus;
|
|
113
|
+
/** Listen for speech detection events (for VAD) */
|
|
114
|
+
onSpeechDetected?(callback: (result: MicrophoneRecordingResult) => void): () => void;
|
|
115
|
+
/** Listen for status changes */
|
|
116
|
+
onStatusChange?(callback: (status: MicrophoneStatus) => void): () => void;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Platform Service Interface
|
|
120
|
+
* Main service that provides access to all platform-specific functionality
|
|
121
|
+
*/
|
|
122
|
+
export interface IPlatformServices {
|
|
123
|
+
/** Platform information */
|
|
124
|
+
platform: PlatformInfo;
|
|
125
|
+
/** Storage service */
|
|
126
|
+
storage: IStorageService;
|
|
127
|
+
/** Screenshot service */
|
|
128
|
+
screenshot: IScreenshotService;
|
|
129
|
+
/** Microphone service */
|
|
130
|
+
microphone: IMicrophoneService;
|
|
131
|
+
/** Initialize all services */
|
|
132
|
+
initialize(): Promise<void>;
|
|
133
|
+
/** Cleanup all services */
|
|
134
|
+
dispose(): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Type definitions for Tauri v2 global API
|
|
138
|
+
* This matches the pattern used in pluely and adminide-stack
|
|
139
|
+
*/
|
|
140
|
+
export interface TauriGlobal {
|
|
141
|
+
core: {
|
|
142
|
+
invoke: <T = unknown>(cmd: string, args?: Record<string, unknown>) => Promise<T>;
|
|
143
|
+
};
|
|
144
|
+
event: {
|
|
145
|
+
listen: <T>(event: string, handler: (event: {
|
|
146
|
+
payload: T;
|
|
147
|
+
}) => void) => Promise<() => void>;
|
|
148
|
+
emit: (event: string, payload?: unknown) => Promise<void>;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
declare global {
|
|
152
|
+
interface Window {
|
|
153
|
+
__TAURI__?: TauriGlobal;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Check if running in Tauri environment
|
|
158
|
+
*/
|
|
159
|
+
export declare function isTauri(): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Get current platform info
|
|
162
|
+
*/
|
|
163
|
+
export declare function getPlatformInfo(): PlatformInfo;
|
|
164
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;I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AAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC,CAAA;SAAE,KAAK,IAAI,KAAK,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QAC5F,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC7D,CAAC;CACL;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,CAAC,EAAE,WAAW,CAAC;KAC3B;CACJ;AAMD;;GAEG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAEjC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAoB9C"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat State Machine
|
|
3
|
+
*
|
|
4
|
+
* This XState machine manages the chat state and is platform-agnostic.
|
|
5
|
+
* It uses injected platform services for storage, screenshot, and microphone
|
|
6
|
+
* functionality, allowing the same machine to work on both browser and Tauri desktop.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* - The machine itself is pure and doesn't import any platform-specific code
|
|
10
|
+
* - Platform services are passed via the machine's input or context factory
|
|
11
|
+
* - Actions use the services from context for persistence
|
|
12
|
+
*/
|
|
13
|
+
import type { ChatMessage } from '../types/chat';
|
|
14
|
+
import type { IPlatformServices, IStorageService } from '../platform/types';
|
|
15
|
+
export type AttachedFile = {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
base64?: string;
|
|
20
|
+
dataUrl?: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
};
|
|
23
|
+
export type MessageAttachment = {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
type: 'file' | 'screenshot';
|
|
27
|
+
dataUrl?: string;
|
|
28
|
+
};
|
|
29
|
+
export type Message = {
|
|
30
|
+
role: 'user' | 'assistant' | 'system';
|
|
31
|
+
content: string;
|
|
32
|
+
attachedFiles?: AttachedFile[];
|
|
33
|
+
attachments?: MessageAttachment[];
|
|
34
|
+
};
|
|
35
|
+
export type ChatContext = {
|
|
36
|
+
storageService: IStorageService | null;
|
|
37
|
+
systemPrompt: string;
|
|
38
|
+
screenshot: string | null;
|
|
39
|
+
attachedFiles: AttachedFile[];
|
|
40
|
+
messages: Message[];
|
|
41
|
+
response: string;
|
|
42
|
+
isStreaming: boolean;
|
|
43
|
+
error: string | null;
|
|
44
|
+
};
|
|
45
|
+
export type ChatEvent = {
|
|
46
|
+
type: 'INPUT_SYSTEMPROMPT';
|
|
47
|
+
value: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'INPUT_SCREENSHOT';
|
|
50
|
+
value: string | null;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'INPUT_FILES';
|
|
53
|
+
value: AttachedFile[];
|
|
54
|
+
} | {
|
|
55
|
+
type: 'SEND_MESSAGE';
|
|
56
|
+
content: string;
|
|
57
|
+
attachments?: MessageAttachment[];
|
|
58
|
+
} | {
|
|
59
|
+
type: 'STREAM_CHUNK';
|
|
60
|
+
chunk: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'STREAM_COMPLETE';
|
|
63
|
+
response: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'STREAM_ERROR';
|
|
66
|
+
error: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'LOAD_MESSAGES';
|
|
69
|
+
messages: Message[];
|
|
70
|
+
} | {
|
|
71
|
+
type: 'CLEAR_MESSAGES';
|
|
72
|
+
} | {
|
|
73
|
+
type: 'CLEAR_ATTACHMENTS';
|
|
74
|
+
} | {
|
|
75
|
+
type: 'RETRY';
|
|
76
|
+
} | {
|
|
77
|
+
type: 'CAPTURE_SCREENSHOT';
|
|
78
|
+
} | {
|
|
79
|
+
type: 'SCREENSHOT_CAPTURED';
|
|
80
|
+
base64: string;
|
|
81
|
+
dataUrl: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: 'SCREENSHOT_ERROR';
|
|
84
|
+
error: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'START_RECORDING';
|
|
87
|
+
} | {
|
|
88
|
+
type: 'STOP_RECORDING';
|
|
89
|
+
} | {
|
|
90
|
+
type: 'RECORDING_COMPLETE';
|
|
91
|
+
transcription: string;
|
|
92
|
+
} | {
|
|
93
|
+
type: 'RECORDING_ERROR';
|
|
94
|
+
error: string;
|
|
95
|
+
};
|
|
96
|
+
export type ChatInput = {
|
|
97
|
+
storageService?: IStorageService;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Create the chat machine with optional platform services
|
|
101
|
+
* @param platformServices - Optional platform services for storage, etc.
|
|
102
|
+
*/
|
|
103
|
+
export declare function createChatMachine(platformServices?: IPlatformServices): import("xstate").StateMachine<ChatContext, ChatEvent, {
|
|
104
|
+
[x: string]: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<import("xstate").EventObject, ChatContext, import("xstate").EventObject>>;
|
|
105
|
+
}, {
|
|
106
|
+
src: "sendToAI";
|
|
107
|
+
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, ChatContext, import("xstate").EventObject>;
|
|
108
|
+
id: string;
|
|
109
|
+
}, {
|
|
110
|
+
type: "persistMessages";
|
|
111
|
+
params: unknown;
|
|
112
|
+
} | {
|
|
113
|
+
type: "clearStoredChat";
|
|
114
|
+
params: unknown;
|
|
115
|
+
}, never, never, "error" | "idle" | "sending", string, ChatInput, {}, import("xstate").EventObject, import("xstate").MetaObject, {
|
|
116
|
+
id: "chat";
|
|
117
|
+
states: {
|
|
118
|
+
readonly idle: {};
|
|
119
|
+
readonly sending: {};
|
|
120
|
+
readonly error: {};
|
|
121
|
+
};
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Default chat machine (backward compatible - no platform services injected)
|
|
125
|
+
* For new code, use createChatMachine(platformServices) instead
|
|
126
|
+
*/
|
|
127
|
+
export declare const chatMachine: import("xstate").StateMachine<ChatContext, ChatEvent, {
|
|
128
|
+
[x: string]: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<import("xstate").EventObject, ChatContext, import("xstate").EventObject>>;
|
|
129
|
+
}, {
|
|
130
|
+
src: "sendToAI";
|
|
131
|
+
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, ChatContext, import("xstate").EventObject>;
|
|
132
|
+
id: string;
|
|
133
|
+
}, {
|
|
134
|
+
type: "persistMessages";
|
|
135
|
+
params: unknown;
|
|
136
|
+
} | {
|
|
137
|
+
type: "clearStoredChat";
|
|
138
|
+
params: unknown;
|
|
139
|
+
}, never, never, "error" | "idle" | "sending", string, ChatInput, {}, import("xstate").EventObject, import("xstate").MetaObject, {
|
|
140
|
+
id: "chat";
|
|
141
|
+
states: {
|
|
142
|
+
readonly idle: {};
|
|
143
|
+
readonly sending: {};
|
|
144
|
+
readonly error: {};
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
147
|
+
export type { ChatMessage };
|
|
148
|
+
//# sourceMappingURL=chatMachine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatMachine.d.ts","sourceRoot":"","sources":["../../src/state/chatMachine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAM3F,MAAM,MAAM,YAAY,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAA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