@sqaitech/visualizer 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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/es/assets/sqai-logo.mjs +2 -0
  4. package/dist/es/component/blackboard/index.css +33 -0
  5. package/dist/es/component/blackboard/index.mjs +278 -0
  6. package/dist/es/component/config-selector/index.mjs +104 -0
  7. package/dist/es/component/context-preview/index.mjs +38 -0
  8. package/dist/es/component/env-config/index.mjs +112 -0
  9. package/dist/es/component/env-config-reminder/index.css +22 -0
  10. package/dist/es/component/env-config-reminder/index.mjs +28 -0
  11. package/dist/es/component/form-field/index.mjs +163 -0
  12. package/dist/es/component/history-selector/index.css +135 -0
  13. package/dist/es/component/history-selector/index.mjs +170 -0
  14. package/dist/es/component/index.mjs +1 -0
  15. package/dist/es/component/logo/index.css +13 -0
  16. package/dist/es/component/logo/index.mjs +21 -0
  17. package/dist/es/component/misc/index.mjs +94 -0
  18. package/dist/es/component/nav-actions/index.mjs +32 -0
  19. package/dist/es/component/nav-actions/style.css +35 -0
  20. package/dist/es/component/player/index.css +185 -0
  21. package/dist/es/component/player/index.mjs +856 -0
  22. package/dist/es/component/playground/index.css +431 -0
  23. package/dist/es/component/playground/index.mjs +8 -0
  24. package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
  25. package/dist/es/component/playground-result/index.css +34 -0
  26. package/dist/es/component/playground-result/index.mjs +62 -0
  27. package/dist/es/component/prompt-input/index.css +391 -0
  28. package/dist/es/component/prompt-input/index.mjs +730 -0
  29. package/dist/es/component/service-mode-control/index.mjs +105 -0
  30. package/dist/es/component/shiny-text/index.css +75 -0
  31. package/dist/es/component/shiny-text/index.mjs +15 -0
  32. package/dist/es/component/universal-playground/index.css +341 -0
  33. package/dist/es/component/universal-playground/index.mjs +302 -0
  34. package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
  35. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +207 -0
  36. package/dist/es/component/universal-playground/providers/storage-provider.mjs +210 -0
  37. package/dist/es/hooks/usePlaygroundExecution.mjs +180 -0
  38. package/dist/es/hooks/usePlaygroundState.mjs +203 -0
  39. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
  40. package/dist/es/hooks/useServerValid.mjs +30 -0
  41. package/dist/es/icons/avatar.mjs +28 -0
  42. package/dist/es/icons/close.mjs +19 -0
  43. package/dist/es/icons/global-perspective.mjs +16 -0
  44. package/dist/es/icons/history.mjs +30 -0
  45. package/dist/es/icons/magnifying-glass.mjs +39 -0
  46. package/dist/es/icons/player-setting.mjs +26 -0
  47. package/dist/es/icons/setting.mjs +20 -0
  48. package/dist/es/icons/show-marker.mjs +16 -0
  49. package/dist/es/index.mjs +25 -0
  50. package/dist/es/static/image/sqai-logo.png +0 -0
  51. package/dist/es/store/history.mjs +89 -0
  52. package/dist/es/store/store.mjs +186 -0
  53. package/dist/es/types.mjs +70 -0
  54. package/dist/es/utils/color.mjs +35 -0
  55. package/dist/es/utils/constants.mjs +99 -0
  56. package/dist/es/utils/index.mjs +10 -0
  57. package/dist/es/utils/pixi-loader.mjs +16 -0
  58. package/dist/es/utils/playground-utils.mjs +67 -0
  59. package/dist/es/utils/replay-scripts.mjs +312 -0
  60. package/dist/lib/assets/sqai-logo.js +24 -0
  61. package/dist/lib/component/blackboard/index.css +33 -0
  62. package/dist/lib/component/blackboard/index.js +321 -0
  63. package/dist/lib/component/config-selector/index.js +148 -0
  64. package/dist/lib/component/context-preview/index.js +83 -0
  65. package/dist/lib/component/env-config/index.js +146 -0
  66. package/dist/lib/component/env-config-reminder/index.css +22 -0
  67. package/dist/lib/component/env-config-reminder/index.js +62 -0
  68. package/dist/lib/component/form-field/index.js +209 -0
  69. package/dist/lib/component/history-selector/index.css +135 -0
  70. package/dist/lib/component/history-selector/index.js +216 -0
  71. package/dist/lib/component/index.js +60 -0
  72. package/dist/lib/component/logo/index.css +13 -0
  73. package/dist/lib/component/logo/index.js +68 -0
  74. package/dist/lib/component/misc/index.js +150 -0
  75. package/dist/lib/component/nav-actions/index.js +66 -0
  76. package/dist/lib/component/nav-actions/style.css +35 -0
  77. package/dist/lib/component/player/index.css +185 -0
  78. package/dist/lib/component/player/index.js +902 -0
  79. package/dist/lib/component/playground/index.css +431 -0
  80. package/dist/lib/component/playground/index.js +113 -0
  81. package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
  82. package/dist/lib/component/playground-result/index.css +34 -0
  83. package/dist/lib/component/playground-result/index.js +106 -0
  84. package/dist/lib/component/prompt-input/index.css +391 -0
  85. package/dist/lib/component/prompt-input/index.js +774 -0
  86. package/dist/lib/component/service-mode-control/index.js +139 -0
  87. package/dist/lib/component/shiny-text/index.css +75 -0
  88. package/dist/lib/component/shiny-text/index.js +49 -0
  89. package/dist/lib/component/universal-playground/index.css +341 -0
  90. package/dist/lib/component/universal-playground/index.js +350 -0
  91. package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
  92. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +247 -0
  93. package/dist/lib/component/universal-playground/providers/storage-provider.js +268 -0
  94. package/dist/lib/hooks/usePlaygroundExecution.js +214 -0
  95. package/dist/lib/hooks/usePlaygroundState.js +237 -0
  96. package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
  97. package/dist/lib/hooks/useServerValid.js +64 -0
  98. package/dist/lib/icons/avatar.js +62 -0
  99. package/dist/lib/icons/close.js +53 -0
  100. package/dist/lib/icons/global-perspective.js +50 -0
  101. package/dist/lib/icons/history.js +64 -0
  102. package/dist/lib/icons/magnifying-glass.js +73 -0
  103. package/dist/lib/icons/player-setting.js +60 -0
  104. package/dist/lib/icons/setting.js +54 -0
  105. package/dist/lib/icons/show-marker.js +50 -0
  106. package/dist/lib/index.js +187 -0
  107. package/dist/lib/static/image/sqai-logo.png +0 -0
  108. package/dist/lib/store/history.js +96 -0
  109. package/dist/lib/store/store.js +196 -0
  110. package/dist/lib/types.js +116 -0
  111. package/dist/lib/utils/color.js +75 -0
  112. package/dist/lib/utils/constants.js +154 -0
  113. package/dist/lib/utils/index.js +63 -0
  114. package/dist/lib/utils/pixi-loader.js +56 -0
  115. package/dist/lib/utils/playground-utils.js +110 -0
  116. package/dist/lib/utils/replay-scripts.js +355 -0
  117. package/dist/types/component/blackboard/index.d.ts +15 -0
  118. package/dist/types/component/config-selector/index.d.ts +9 -0
  119. package/dist/types/component/context-preview/index.d.ts +9 -0
  120. package/dist/types/component/env-config/index.d.ts +6 -0
  121. package/dist/types/component/env-config-reminder/index.d.ts +6 -0
  122. package/dist/types/component/form-field/index.d.ts +17 -0
  123. package/dist/types/component/history-selector/index.d.ts +10 -0
  124. package/dist/types/component/index.d.ts +1 -0
  125. package/dist/types/component/logo/index.d.ts +5 -0
  126. package/dist/types/component/misc/index.d.ts +6 -0
  127. package/dist/types/component/nav-actions/index.d.ts +10 -0
  128. package/dist/types/component/player/index.d.ts +13 -0
  129. package/dist/types/component/playground/index.d.ts +7 -0
  130. package/dist/types/component/playground-result/index.d.ts +20 -0
  131. package/dist/types/component/prompt-input/index.d.ts +22 -0
  132. package/dist/types/component/service-mode-control/index.d.ts +6 -0
  133. package/dist/types/component/shiny-text/index.d.ts +12 -0
  134. package/dist/types/component/universal-playground/index.d.ts +4 -0
  135. package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
  136. package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
  137. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
  138. package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
  139. package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
  140. package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
  141. package/dist/types/hooks/useServerValid.d.ts +1 -0
  142. package/dist/types/index.d.ts +27 -0
  143. package/dist/types/store/history.d.ts +16 -0
  144. package/dist/types/store/store.d.ts +36 -0
  145. package/dist/types/types.d.ts +161 -0
  146. package/dist/types/utils/color.d.ts +4 -0
  147. package/dist/types/utils/constants.d.ts +74 -0
  148. package/dist/types/utils/index.d.ts +4 -0
  149. package/dist/types/utils/pixi-loader.d.ts +5 -0
  150. package/dist/types/utils/playground-utils.d.ts +6 -0
  151. package/dist/types/utils/replay-scripts.d.ts +34 -0
  152. package/package.json +85 -0
@@ -0,0 +1,6 @@
1
+ export declare function EnvConfig({ showTooltipWhenEmpty, showModelName, tooltipPlacement, mode, }: {
2
+ showTooltipWhenEmpty?: boolean;
3
+ showModelName?: boolean;
4
+ tooltipPlacement?: 'bottom' | 'top';
5
+ mode?: 'icon' | 'text';
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import './index.less';
2
+ interface EnvConfigReminderProps {
3
+ className?: string;
4
+ }
5
+ export declare const EnvConfigReminder: React.FC<EnvConfigReminderProps>;
6
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { z } from '@sqaitech/core';
2
+ import type React from 'react';
3
+ interface FormFieldProps {
4
+ name: string;
5
+ label: string;
6
+ fieldSchema: z.ZodTypeAny;
7
+ isRequired: boolean;
8
+ isLocateField: boolean;
9
+ marginBottom: number;
10
+ placeholder?: string;
11
+ }
12
+ export declare const TextField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
13
+ export declare const LocateField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
14
+ export declare const EnumField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
15
+ export declare const NumberField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
16
+ export declare const BooleanField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
17
+ export {};
@@ -0,0 +1,10 @@
1
+ import type React from 'react';
2
+ import type { HistoryItem } from '../../store/history';
3
+ import './index.less';
4
+ interface HistorySelectorProps {
5
+ onSelect: (history: HistoryItem) => void;
6
+ history: HistoryItem[];
7
+ currentType: string;
8
+ }
9
+ export declare const HistorySelector: React.FC<HistorySelectorProps>;
10
+ export {};
@@ -0,0 +1 @@
1
+ export * from '../types';
@@ -0,0 +1,5 @@
1
+ import './index.less';
2
+ export declare const LogoUrl: any;
3
+ export declare const Logo: ({ hideLogo }: {
4
+ hideLogo?: boolean;
5
+ }) => import("react").JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ export declare function timeCostStrElement(timeCost?: number): React.JSX.Element;
3
+ export declare const iconForStatus: (status: string) => React.JSX.Element;
4
+ export declare const errorMessageServerNotReady: React.JSX.Element;
5
+ export declare const serverLaunchTip: (notReadyMessage?: React.ReactNode | string) => React.JSX.Element;
6
+ export declare const emptyResultTip: React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import './style.less';
2
+ export interface NavActionsProps {
3
+ showEnvConfig?: boolean;
4
+ showTooltipWhenEmpty?: boolean;
5
+ showModelName?: boolean;
6
+ githubUrl?: string;
7
+ helpUrl?: string;
8
+ className?: string;
9
+ }
10
+ export declare function NavActions({ showEnvConfig, showTooltipWhenEmpty, showModelName, githubUrl, helpUrl, className, }: NavActionsProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import 'pixi.js/unsafe-eval';
2
+ import './index.less';
3
+ import type { AnimationScript } from '../../utils/replay-scripts';
4
+ export declare function Player(props?: {
5
+ replayScripts?: AnimationScript[];
6
+ imageWidth?: number;
7
+ imageHeight?: number;
8
+ reportFileContent?: string | null;
9
+ key?: string | number;
10
+ fitMode?: 'width' | 'height';
11
+ autoZoom?: boolean;
12
+ elementsVisible?: boolean;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export { ContextPreview } from '../context-preview';
2
+ export { PlaygroundResultView } from '../playground-result';
3
+ export { PromptInput } from '../prompt-input';
4
+ export { useServerValid } from '../../hooks/useServerValid';
5
+ export { ServiceModeControl } from '../service-mode-control';
6
+ export * from '../../types';
7
+ export { useEnvConfig } from '../../store/store';
@@ -0,0 +1,20 @@
1
+ import type React from 'react';
2
+ import type { PlaygroundResult as PlaygroundResultType } from '../../types';
3
+ import type { ServiceModeType } from '../../types';
4
+ import type { ReplayScriptsInfo } from '../../utils/replay-scripts';
5
+ import './index.less';
6
+ interface PlaygroundResultProps {
7
+ result: PlaygroundResultType | null;
8
+ loading: boolean;
9
+ serverValid?: boolean;
10
+ serviceMode: ServiceModeType;
11
+ replayScriptsInfo: ReplayScriptsInfo | null;
12
+ replayCounter: number;
13
+ loadingProgressText: string;
14
+ verticalMode?: boolean;
15
+ notReadyMessage?: React.ReactNode | string;
16
+ fitMode?: 'width' | 'height';
17
+ autoZoom?: boolean;
18
+ }
19
+ export declare const PlaygroundResultView: React.FC<PlaygroundResultProps>;
20
+ export {};
@@ -0,0 +1,22 @@
1
+ import './index.less';
2
+ import React from 'react';
3
+ import type { RunType } from '../../types';
4
+ import type { ServiceModeType } from '../../types';
5
+ import './index.less';
6
+ import type { DeviceAction } from '@sqaitech/core';
7
+ interface PromptInputProps {
8
+ runButtonEnabled: boolean;
9
+ form: any;
10
+ serviceMode: ServiceModeType;
11
+ selectedType: RunType;
12
+ dryMode: boolean;
13
+ stoppable: boolean;
14
+ loading: boolean;
15
+ onRun: () => void;
16
+ onStop: () => void;
17
+ clearPromptAfterRun?: boolean;
18
+ hideDomAndScreenshotOptions?: boolean;
19
+ actionSpace: DeviceAction<any>[];
20
+ }
21
+ export declare const PromptInput: React.FC<PromptInputProps>;
22
+ export {};
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ interface ServiceModeControlProps {
3
+ serviceMode: 'Server' | 'In-Browser';
4
+ }
5
+ export declare const ServiceModeControl: React.FC<ServiceModeControlProps>;
6
+ export {};
@@ -0,0 +1,12 @@
1
+ import type React from 'react';
2
+ import './index.less';
3
+ type ColorTheme = 'blue' | 'purple' | 'green' | 'rainbow';
4
+ interface ShinyTextProps {
5
+ text: string;
6
+ disabled?: boolean;
7
+ speed?: number;
8
+ className?: string;
9
+ colorTheme?: ColorTheme;
10
+ }
11
+ declare const ShinyText: React.FC<ShinyTextProps>;
12
+ export default ShinyText;
@@ -0,0 +1,4 @@
1
+ import type { UniversalPlaygroundProps } from '../../types';
2
+ import './index.less';
3
+ export declare function UniversalPlayground({ playgroundSDK, storage, contextProvider, config: componentConfig, branding, className, dryMode, showContextPreview, }: UniversalPlaygroundProps): import("react").JSX.Element;
4
+ export default UniversalPlayground;
@@ -0,0 +1,37 @@
1
+ import type { UIContext } from '@sqaitech/core';
2
+ import type { ContextProvider } from '../../../types';
3
+ /**
4
+ * Base context provider implementation
5
+ */
6
+ export declare abstract class BaseContextProvider implements ContextProvider {
7
+ protected cachedContext?: UIContext;
8
+ abstract getUIContext(): Promise<UIContext>;
9
+ refreshContext(): Promise<UIContext>;
10
+ }
11
+ /**
12
+ * Agent-based context provider for local execution modes
13
+ */
14
+ export declare class AgentContextProvider extends BaseContextProvider {
15
+ private getAgent;
16
+ private options?;
17
+ constructor(getAgent: () => any, options?: {
18
+ forceSameTabNavigation?: boolean;
19
+ } | undefined);
20
+ getUIContext(): Promise<UIContext>;
21
+ }
22
+ /**
23
+ * Static context provider for pre-determined UI contexts
24
+ */
25
+ export declare class StaticContextProvider extends BaseContextProvider {
26
+ private context;
27
+ constructor(context: UIContext);
28
+ getUIContext(): Promise<UIContext>;
29
+ refreshContext(): Promise<UIContext>;
30
+ }
31
+ /**
32
+ * No-op context provider for cases where context preview is disabled
33
+ */
34
+ export declare class NoOpContextProvider implements ContextProvider {
35
+ getUIContext(): Promise<UIContext>;
36
+ refreshContext(): Promise<UIContext>;
37
+ }
@@ -0,0 +1,71 @@
1
+ import type { InfoListItem, StorageProvider } from '../../../types';
2
+ /**
3
+ * IndexedDB Storage implementation for playground message persistence
4
+ * Provides much larger storage capacity compared to localStorage
5
+ */
6
+ export declare class IndexedDBStorageProvider implements StorageProvider {
7
+ private dbManager;
8
+ private namespace;
9
+ private messagesCleanup;
10
+ private resultsCleanup;
11
+ constructor(namespace?: string);
12
+ /**
13
+ * Save messages to IndexedDB
14
+ */
15
+ saveMessages(messages: InfoListItem[]): Promise<void>;
16
+ /**
17
+ * Load messages from IndexedDB
18
+ */
19
+ loadMessages(): Promise<InfoListItem[]>;
20
+ /**
21
+ * Clear all messages from IndexedDB
22
+ */
23
+ clearMessages(): Promise<void>;
24
+ /**
25
+ * Save a single result to IndexedDB with compression
26
+ */
27
+ saveResult(id: string, result: InfoListItem): Promise<void>;
28
+ /**
29
+ * Load a single result from IndexedDB
30
+ */
31
+ loadResult(id: string): Promise<InfoListItem | null>;
32
+ /**
33
+ * Compress result data for storage while preserving playback functionality
34
+ */
35
+ private compressResultForStorage;
36
+ /**
37
+ * Compress screenshot if it exceeds size threshold
38
+ */
39
+ private compressScreenshotIfNeeded;
40
+ /**
41
+ * Get storage statistics
42
+ */
43
+ getStorageStats(): Promise<{
44
+ messageCount: number;
45
+ resultCount: number;
46
+ }>;
47
+ /**
48
+ * Manually trigger cleanup
49
+ */
50
+ cleanup(): Promise<void>;
51
+ }
52
+ /**
53
+ * Memory-based storage provider for IndexedDB fallback
54
+ */
55
+ export declare class MemoryStorageProvider implements StorageProvider {
56
+ private messages;
57
+ private results;
58
+ saveMessages(messages: InfoListItem[]): Promise<void>;
59
+ loadMessages(): Promise<InfoListItem[]>;
60
+ clearMessages(): Promise<void>;
61
+ saveResult(id: string, result: InfoListItem): Promise<void>;
62
+ }
63
+ /**
64
+ * No-op storage provider for disabled storage
65
+ */
66
+ export declare class NoOpStorageProvider implements StorageProvider {
67
+ saveMessages(_messages: InfoListItem[]): Promise<void>;
68
+ loadMessages(): Promise<InfoListItem[]>;
69
+ clearMessages(): Promise<void>;
70
+ saveResult(_id: string, _result: InfoListItem): Promise<void>;
71
+ }
@@ -0,0 +1,58 @@
1
+ import type { InfoListItem, StorageProvider } from '../../../types';
2
+ import { MemoryStorageProvider as IndexedDBMemoryStorageProvider, NoOpStorageProvider as IndexedDBNoOpStorageProvider, IndexedDBStorageProvider } from './indexeddb-storage-provider';
3
+ /**
4
+ * Local Storage implementation for playground message persistence
5
+ */
6
+ export declare class LocalStorageProvider implements StorageProvider {
7
+ private readonly messagesKey;
8
+ private readonly resultsKey;
9
+ private readonly maxStorageItems;
10
+ constructor(namespace?: string);
11
+ /**
12
+ * Check available storage space
13
+ */
14
+ private checkStorageSpace;
15
+ saveMessages(messages: InfoListItem[]): Promise<void>;
16
+ loadMessages(): Promise<InfoListItem[]>;
17
+ clearMessages(): Promise<void>;
18
+ saveResult(id: string, result: InfoListItem): Promise<void>;
19
+ /**
20
+ * Handle quota exceeded by clearing old data
21
+ */
22
+ private handleQuotaExceeded;
23
+ }
24
+ /**
25
+ * Memory-only storage implementation for non-persistent scenarios
26
+ */
27
+ export declare class MemoryStorageProvider implements StorageProvider {
28
+ private messages;
29
+ private results;
30
+ saveMessages(messages: InfoListItem[]): Promise<void>;
31
+ loadMessages(): Promise<InfoListItem[]>;
32
+ clearMessages(): Promise<void>;
33
+ saveResult(id: string, result: InfoListItem): Promise<void>;
34
+ }
35
+ /**
36
+ * No-op storage implementation for cases where persistence is disabled
37
+ */
38
+ export declare class NoOpStorageProvider implements StorageProvider {
39
+ saveMessages(_messages: InfoListItem[]): Promise<void>;
40
+ loadMessages(): Promise<InfoListItem[]>;
41
+ clearMessages(): Promise<void>;
42
+ saveResult(_id: string, _result: InfoListItem): Promise<void>;
43
+ }
44
+ /**
45
+ * Storage type enumeration
46
+ */
47
+ export declare enum StorageType {
48
+ INDEXEDDB = "indexeddb",
49
+ LOCALSTORAGE = "localStorage",
50
+ MEMORY = "memory",
51
+ NONE = "none"
52
+ }
53
+ /**
54
+ * Factory function to create the appropriate storage provider
55
+ */
56
+ export declare function createStorageProvider(type?: StorageType, namespace?: string): StorageProvider;
57
+ export declare function detectBestStorageType(): StorageType;
58
+ export { IndexedDBStorageProvider, IndexedDBMemoryStorageProvider, IndexedDBNoOpStorageProvider, };
@@ -0,0 +1,10 @@
1
+ import type { DeviceAction } from '@sqaitech/core';
2
+ import type { FormValue, InfoListItem, PlaygroundSDKLike, StorageProvider } from '../types';
3
+ /**
4
+ * Hook for handling playground execution logic
5
+ */
6
+ export declare function usePlaygroundExecution(playgroundSDK: PlaygroundSDKLike | null, storage: StorageProvider | undefined | null, actionSpace: DeviceAction<unknown>[], loading: boolean, setLoading: (loading: boolean) => void, infoList: InfoListItem[], setInfoList: React.Dispatch<React.SetStateAction<InfoListItem[]>>, replayCounter: number, setReplayCounter: React.Dispatch<React.SetStateAction<number>>, verticalMode: boolean, currentRunningIdRef: React.MutableRefObject<number | null>, interruptedFlagRef: React.MutableRefObject<Record<number, boolean>>): {
7
+ handleRun: (value: FormValue) => Promise<void>;
8
+ handleStop: () => Promise<void>;
9
+ canStop: boolean;
10
+ };
@@ -0,0 +1,26 @@
1
+ import type { DeviceAction, UIContext } from '@sqaitech/core';
2
+ import type { ContextProvider, InfoListItem, PlaygroundSDKLike, StorageProvider } from '../types';
3
+ /**
4
+ * Hook for managing playground state
5
+ */
6
+ export declare function usePlaygroundState(playgroundSDK: PlaygroundSDKLike | null, storage?: StorageProvider | null, contextProvider?: ContextProvider): {
7
+ loading: boolean;
8
+ setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
9
+ infoList: InfoListItem[];
10
+ setInfoList: import("react").Dispatch<import("react").SetStateAction<InfoListItem[]>>;
11
+ actionSpace: DeviceAction<unknown>[];
12
+ actionSpaceLoading: boolean;
13
+ uiContextPreview: UIContext<import("@sqaitech/core").BaseElement> | undefined;
14
+ setUiContextPreview: import("react").Dispatch<import("react").SetStateAction<UIContext<import("@sqaitech/core").BaseElement> | undefined>>;
15
+ showScrollToBottomButton: boolean;
16
+ verticalMode: boolean;
17
+ replayCounter: number;
18
+ setReplayCounter: import("react").Dispatch<import("react").SetStateAction<number>>;
19
+ infoListRef: import("react").RefObject<HTMLDivElement>;
20
+ currentRunningIdRef: import("react").MutableRefObject<number | null>;
21
+ interruptedFlagRef: import("react").MutableRefObject<Record<number, boolean>>;
22
+ clearInfoList: () => Promise<void>;
23
+ refreshContext: () => Promise<void>;
24
+ handleScrollToBottom: () => void;
25
+ scrollToBottom: () => void;
26
+ };
@@ -0,0 +1,16 @@
1
+ import type { GLOBAL_ENV_KEYS, MODEL_ENV_KEYS } from '@sqaitech/shared/env';
2
+ /**
3
+ * Safely override AI configuration with built-in error handling
4
+ * @param newConfig - The configuration to override
5
+ * @param extendMode - Whether to extend or replace the config (default: false)
6
+ * @param showErrorMessage - Whether to show error message in UI (default: true)
7
+ * @returns boolean indicating success
8
+ */
9
+ export declare function safeOverrideAIConfig(newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean, showErrorMessage?: boolean): boolean;
10
+ /**
11
+ * React Hook for safely overriding AI config with error handling
12
+ * Useful for components that need to handle config changes
13
+ */
14
+ export declare function useSafeOverrideAIConfig(): {
15
+ applyConfig: (newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean, showErrorMessage?: boolean) => boolean;
16
+ };
@@ -0,0 +1 @@
1
+ export declare const useServerValid: (shouldRun?: boolean) => boolean;
@@ -0,0 +1,27 @@
1
+ import './component/playground/index.less';
2
+ import './component/universal-playground/index.less';
3
+ export { type AnimationScript, type ReplayScriptsInfo, allScriptsFromDump, generateAnimationScripts, } from './utils/replay-scripts';
4
+ export { useEnvConfig } from './store/store';
5
+ export { colorForName, highlightColorForType, globalThemeConfig, } from './utils/color';
6
+ export { EnvConfig } from './component/env-config';
7
+ export { EnvConfigReminder } from './component/env-config-reminder';
8
+ export { NavActions } from './component/nav-actions';
9
+ export type { NavActionsProps } from './component/nav-actions';
10
+ export { Logo } from './component/logo';
11
+ export { iconForStatus, timeCostStrElement } from './component/misc';
12
+ export { useServerValid } from './hooks/useServerValid';
13
+ export { useSafeOverrideAIConfig, safeOverrideAIConfig, } from './hooks/useSafeOverrideAIConfig';
14
+ export { PlaygroundResultView } from './component/playground-result';
15
+ export type { PlaygroundResult } from './types';
16
+ export { ServiceModeControl } from './component/service-mode-control';
17
+ export { ContextPreview } from './component/context-preview';
18
+ export { PromptInput } from './component/prompt-input';
19
+ export { Player } from './component/player';
20
+ export { Blackboard } from './component/blackboard';
21
+ export { actionNameForType, staticAgentFromContext, getPlaceholderForType, } from './utils/playground-utils';
22
+ export { timeStr, filterBase64Value } from './utils';
23
+ export { default as ShinyText } from './component/shiny-text';
24
+ export { UniversalPlayground, default as UniversalPlaygroundDefault, } from './component/universal-playground';
25
+ export type { UniversalPlaygroundProps, PlaygroundSDKLike, StorageProvider, ContextProvider, UniversalPlaygroundConfig, PlaygroundBranding, InfoListItem, FormValue, ExecutionOptions, ProgressCallback, } from './types';
26
+ export { LocalStorageProvider, MemoryStorageProvider, NoOpStorageProvider, IndexedDBStorageProvider, createStorageProvider, detectBestStorageType, StorageType, } from './component/universal-playground/providers/storage-provider';
27
+ export { BaseContextProvider, AgentContextProvider, StaticContextProvider, NoOpContextProvider, } from './component/universal-playground/providers/context-provider';
@@ -0,0 +1,16 @@
1
+ import * as Z from 'zustand';
2
+ export interface HistoryItem {
3
+ type: string;
4
+ prompt: string;
5
+ params?: Record<string, any>;
6
+ timestamp: number;
7
+ }
8
+ export type HistoryState = Record<string, HistoryItem[]>;
9
+ export declare const useHistoryStore: Z.UseBoundStore<Z.StoreApi<{
10
+ history: HistoryState;
11
+ lastSelectedType: string;
12
+ clearHistory: (type: string) => void;
13
+ addHistory: (historyItem: HistoryItem) => void;
14
+ getHistoryForType: (type: string) => HistoryItem[];
15
+ setLastSelectedType: (type: string) => void;
16
+ }>>;
@@ -0,0 +1,36 @@
1
+ import * as Z from 'zustand';
2
+ export declare const useBlackboardPreference: Z.UseBoundStore<Z.StoreApi<{
3
+ backgroundVisible: boolean;
4
+ elementsVisible: boolean;
5
+ autoZoom: boolean;
6
+ setBackgroundVisible: (visible: boolean) => void;
7
+ setElementsVisible: (visible: boolean) => void;
8
+ setAutoZoom: (enabled: boolean) => void;
9
+ }>>;
10
+ /**
11
+ * Service Mode
12
+ *
13
+ * - Server: use a node server to run the code
14
+ * - In-Browser: use browser's fetch API to run the code
15
+ * - In-Browser-Extension: use browser's fetch API to run the code, but the page is running in the extension context
16
+ */
17
+ export type ServiceModeType = 'Server' | 'In-Browser' | 'In-Browser-Extension';
18
+ export declare const useEnvConfig: Z.UseBoundStore<Z.StoreApi<{
19
+ serviceMode: ServiceModeType;
20
+ setServiceMode: (serviceMode: ServiceModeType) => void;
21
+ config: Record<string, string>;
22
+ configString: string;
23
+ setConfig: (config: Record<string, string>) => void;
24
+ loadConfig: (configString: string) => void;
25
+ syncFromStorage: () => void;
26
+ forceSameTabNavigation: boolean;
27
+ setForceSameTabNavigation: (forceSameTabNavigation: boolean) => void;
28
+ deepThink: boolean;
29
+ setDeepThink: (deepThink: boolean) => void;
30
+ screenshotIncluded: boolean;
31
+ setScreenshotIncluded: (screenshotIncluded: boolean) => void;
32
+ domIncluded: boolean | "visible-only";
33
+ setDomIncluded: (domIncluded: boolean | "visible-only") => void;
34
+ popupTab: "playground" | "bridge" | "recorder";
35
+ setPopupTab: (tab: "playground" | "bridge" | "recorder") => void;
36
+ }>>;
@@ -0,0 +1,161 @@
1
+ import type { DeviceAction, UIContext } from '@sqaitech/core';
2
+ import type { ComponentType } from 'react';
3
+ export interface ZodType {
4
+ _def?: {
5
+ typeName: 'ZodOptional' | 'ZodDefault' | 'ZodNullable' | 'ZodObject' | 'ZodEnum' | 'ZodNumber' | 'ZodString' | 'ZodBoolean';
6
+ innerType?: ZodType;
7
+ defaultValue?: () => unknown;
8
+ shape?: () => Record<string, ZodType>;
9
+ values?: string[];
10
+ description?: string;
11
+ };
12
+ description?: string;
13
+ }
14
+ export interface ZodObjectSchema extends ZodType {
15
+ shape: Record<string, ZodType>;
16
+ parse: (data: unknown) => unknown;
17
+ }
18
+ export interface ZodEnumSchema extends ZodType {
19
+ _def: {
20
+ typeName: 'ZodEnum';
21
+ values: string[];
22
+ };
23
+ }
24
+ export interface ZodNumberSchema extends ZodType {
25
+ _def: {
26
+ typeName: 'ZodNumber';
27
+ };
28
+ }
29
+ export interface ZodBooleanSchema extends ZodType {
30
+ _def: {
31
+ typeName: 'ZodBoolean';
32
+ };
33
+ }
34
+ export interface ZodRuntimeAccess extends ZodType {
35
+ shape?: Record<string, ZodType>;
36
+ description?: string;
37
+ typeName?: string;
38
+ type?: string;
39
+ }
40
+ export interface ActionSpaceItem extends Omit<DeviceAction<any>, 'paramSchema'> {
41
+ paramSchema?: ZodObjectSchema;
42
+ }
43
+ export interface FormParams {
44
+ [key: string]: string | number | boolean | null | undefined;
45
+ }
46
+ export declare const VALIDATION_CONSTANTS: {
47
+ readonly ZOD_TYPES: {
48
+ readonly OPTIONAL: "ZodOptional";
49
+ readonly DEFAULT: "ZodDefault";
50
+ readonly NULLABLE: "ZodNullable";
51
+ readonly OBJECT: "ZodObject";
52
+ readonly ENUM: "ZodEnum";
53
+ readonly NUMBER: "ZodNumber";
54
+ readonly STRING: "ZodString";
55
+ readonly BOOLEAN: "ZodBoolean";
56
+ };
57
+ readonly FIELD_FLAGS: {
58
+ readonly LOCATION: "midscene_location_field_flag";
59
+ };
60
+ readonly DEFAULT_VALUES: {
61
+ readonly ACTION_TYPE: "aiAction";
62
+ readonly TIMEOUT_MS: 15000;
63
+ readonly CHECK_INTERVAL_MS: 3000;
64
+ };
65
+ };
66
+ export declare const isZodObjectSchema: (schema: unknown) => schema is ZodObjectSchema;
67
+ export declare const isLocateField: (field: ZodType) => boolean;
68
+ export declare const unwrapZodType: (field: ZodType) => {
69
+ actualField: ZodType;
70
+ isOptional: boolean;
71
+ hasDefault: boolean;
72
+ };
73
+ export declare const extractDefaultValue: (field: ZodType) => unknown;
74
+ import type { GroupedActionDump, WebUIContext } from '@sqaitech/core';
75
+ import type { ExecutionOptions, PlaygroundAgent } from '@sqaitech/playground';
76
+ export interface PlaygroundResult {
77
+ result: any;
78
+ dump?: GroupedActionDump | null;
79
+ reportHTML?: string | null;
80
+ error: string | null;
81
+ }
82
+ export interface PlaygroundProps {
83
+ getAgent: (forceSameTabNavigation?: boolean) => PlaygroundAgent | null;
84
+ hideLogo?: boolean;
85
+ showContextPreview?: boolean;
86
+ dryMode?: boolean;
87
+ }
88
+ export interface StaticPlaygroundProps {
89
+ context: WebUIContext | null;
90
+ }
91
+ export type ServiceModeType = 'Server' | 'In-Browser' | 'In-Browser-Extension';
92
+ export type RunType = 'aiAction' | 'aiQuery' | 'aiAssert' | 'aiTap' | 'aiDoubleClick' | 'aiHover' | 'aiInput' | 'aiRightClick' | 'aiKeyboardPress' | 'aiScroll' | 'aiLocate' | 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk' | 'aiWaitFor';
93
+ export interface ReplayScriptsInfo {
94
+ scripts: any[];
95
+ width?: number;
96
+ height?: number;
97
+ sdkVersion?: string;
98
+ modelBriefs: string[];
99
+ }
100
+ export interface FormValue {
101
+ type: string;
102
+ prompt?: string;
103
+ params?: Record<string, unknown>;
104
+ }
105
+ export type { ExecutionOptions };
106
+ export type ProgressCallback = (step: string, status?: 'loading' | 'completed' | 'error') => void;
107
+ export interface PlaygroundSDKLike {
108
+ executeAction(actionType: string, value: FormValue, options: ExecutionOptions): Promise<unknown>;
109
+ getActionSpace(context?: any): Promise<DeviceAction<unknown>[]>;
110
+ onProgressUpdate?: (callback: ProgressCallback) => void;
111
+ cancelExecution?(requestId: string): Promise<void>;
112
+ overrideConfig?(config: any): Promise<void>;
113
+ checkStatus?(): Promise<boolean>;
114
+ id?: string;
115
+ }
116
+ export interface StorageProvider {
117
+ saveMessages?(messages: InfoListItem[]): Promise<void>;
118
+ loadMessages?(): Promise<InfoListItem[]>;
119
+ clearMessages?(): Promise<void>;
120
+ saveResult?(id: string, result: InfoListItem): Promise<void>;
121
+ }
122
+ export interface ContextProvider {
123
+ getUIContext?(): Promise<UIContext>;
124
+ refreshContext?(): Promise<UIContext>;
125
+ }
126
+ export interface InfoListItem {
127
+ id: string;
128
+ type: 'user' | 'system' | 'result' | 'progress' | 'separator';
129
+ content: string;
130
+ timestamp: Date;
131
+ result?: PlaygroundResult | null;
132
+ loading?: boolean;
133
+ replayScriptsInfo?: ReplayScriptsInfo | null;
134
+ replayCounter?: number;
135
+ loadingProgressText?: string;
136
+ verticalMode?: boolean;
137
+ }
138
+ export interface UniversalPlaygroundConfig {
139
+ showContextPreview?: boolean;
140
+ storageNamespace?: string;
141
+ layout?: 'vertical' | 'horizontal';
142
+ showVersionInfo?: boolean;
143
+ enableScrollToBottom?: boolean;
144
+ serverMode?: boolean;
145
+ showEnvConfigReminder?: boolean;
146
+ }
147
+ export interface PlaygroundBranding {
148
+ title?: string;
149
+ icon?: ComponentType<any>;
150
+ version?: string;
151
+ }
152
+ export interface UniversalPlaygroundProps {
153
+ playgroundSDK: PlaygroundSDKLike | null;
154
+ storage?: StorageProvider;
155
+ contextProvider?: ContextProvider;
156
+ config?: UniversalPlaygroundConfig;
157
+ branding?: PlaygroundBranding;
158
+ className?: string;
159
+ dryMode?: boolean;
160
+ showContextPreview?: boolean;
161
+ }
@@ -0,0 +1,4 @@
1
+ import type { ThemeConfig } from 'antd';
2
+ export declare function colorForName(name: string): string;
3
+ export declare function highlightColorForType(type: 'searchArea' | 'element'): string;
4
+ export declare function globalThemeConfig(): ThemeConfig;