@midscene/playground 0.28.5 → 0.28.6

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.
@@ -1,4 +1,3 @@
1
- import { PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
2
1
  import { BasePlaygroundAdapter } from "./base.mjs";
3
2
  function _define_property(obj, key, value) {
4
3
  if (key in obj) Object.defineProperty(obj, key, {
@@ -293,7 +292,7 @@ class RemoteExecutionAdapter extends BasePlaygroundAdapter {
293
292
  return null;
294
293
  }
295
294
  }
296
- constructor(serverUrl = `http://localhost:${PLAYGROUND_SERVER_PORT}`){
295
+ constructor(serverUrl){
297
296
  super(), _define_property(this, "serverUrl", void 0), _define_property(this, "progressPolling", new Map()), _define_property(this, "progressCallback", void 0);
298
297
  this.serverUrl = serverUrl;
299
298
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapters/remote-execution.mjs","sources":["webpack://@midscene/playground/./src/adapters/remote-execution.ts"],"sourcesContent":["import type { DeviceAction } from '@midscene/core';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport type { ExecutionOptions, FormValue, ValidationResult } from '../types';\nimport { BasePlaygroundAdapter } from './base';\n\nexport class RemoteExecutionAdapter extends BasePlaygroundAdapter {\n private serverUrl?: string;\n private progressPolling = new Map<string, NodeJS.Timeout>();\n private progressCallback?: (tip: string) => void;\n\n constructor(serverUrl = `http://localhost:${PLAYGROUND_SERVER_PORT}`) {\n super();\n this.serverUrl = serverUrl;\n }\n\n // Override validateParams for remote execution\n // Since schemas from server are JSON-serialized and lack .parse() method\n validateParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n if (!action?.paramSchema) {\n return { valid: true };\n }\n\n const needsStructuredParams = this.actionNeedsStructuredParams(action);\n\n if (!needsStructuredParams) {\n return { valid: true };\n }\n\n if (!value.params) {\n return { valid: false, errorMessage: 'Parameters are required' };\n }\n\n // For remote execution, perform basic validation without .parse()\n // Check if required fields are present\n if (action.paramSchema && typeof action.paramSchema === 'object') {\n const schema = action.paramSchema as any;\n if (schema.shape || schema.type === 'ZodObject') {\n const shape = schema.shape || {};\n const missingFields = Object.keys(shape).filter((key) => {\n const fieldDef = shape[key];\n // Check if field is required (not optional)\n const isOptional =\n fieldDef?.isOptional ||\n fieldDef?._def?.innerType || // ZodOptional\n fieldDef?._def?.typeName === 'ZodOptional';\n return (\n !isOptional &&\n (value.params![key] === undefined || value.params![key] === '')\n );\n });\n\n if (missingFields.length > 0) {\n return {\n valid: false,\n errorMessage: `Missing required parameters: ${missingFields.join(', ')}`,\n };\n }\n }\n }\n\n return { valid: true };\n }\n\n async parseStructuredParams(\n action: DeviceAction<unknown>,\n params: Record<string, unknown>,\n options: ExecutionOptions,\n ): Promise<unknown[]> {\n if (!this.hasValidSchema(action)) {\n return [params.prompt || '', options];\n }\n\n // Remote execution format: merge options and valid params into a single object\n return [{ ...options, ...this.filterValidParams(params) }];\n }\n\n formatErrorMessage(error: any): string {\n const message = error?.message || '';\n\n // Handle Android-specific errors\n const androidErrors = [\n {\n keyword: 'adb',\n message:\n 'ADB connection error. Please ensure device is connected and USB debugging is enabled.',\n },\n {\n keyword: 'UIAutomator',\n message:\n 'UIAutomator error. Please ensure the UIAutomator server is running on the device.',\n },\n ];\n\n const androidError = androidErrors.find(({ keyword }) =>\n message.includes(keyword),\n );\n if (androidError) {\n return androidError.message;\n }\n\n return this.formatBasicErrorMessage(error);\n }\n\n // Remote execution adapter - simplified interface\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n // If serverUrl is provided, use server-side execution\n if (this.serverUrl && typeof window !== 'undefined') {\n return this.executeViaServer(actionType, value, options);\n }\n\n throw new Error(\n 'Remote execution adapter requires server URL for execution',\n );\n }\n\n // Remote execution via server - uses same endpoint as requestPlaygroundServer\n private async executeViaServer(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const payload: Record<string, unknown> = {\n type: actionType,\n prompt: value.prompt,\n ...this.buildOptionalPayloadParams(options, value),\n };\n\n // Add context only if it exists (server can handle single agent case without context)\n if (options.context) {\n payload.context = options.context;\n }\n\n // Start progress polling if callback is set and requestId exists\n if (options.requestId && this.progressCallback) {\n this.startProgressPolling(options.requestId, this.progressCallback);\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => 'Unknown error');\n throw new Error(\n `Server request failed (${response.status}): ${errorText}`,\n );\n }\n\n const result = await response.json();\n\n // Stop progress polling when execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n } catch (error) {\n // Stop progress polling on error\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n console.error('Execute via server failed:', error);\n throw error;\n }\n }\n\n // Helper method to build optional payload parameters\n private buildOptionalPayloadParams(\n options: ExecutionOptions,\n value: FormValue,\n ): Record<string, unknown> {\n const optionalParams: Record<string, unknown> = {};\n\n // Add optional parameters only if they have meaningful values\n const optionalFields = [\n { key: 'requestId', value: options.requestId },\n { key: 'deepThink', value: options.deepThink },\n { key: 'screenshotIncluded', value: options.screenshotIncluded },\n { key: 'domIncluded', value: options.domIncluded },\n { key: 'params', value: value.params },\n ] as const;\n\n optionalFields.forEach(({ key, value }) => {\n if (value !== undefined && value !== null && value !== '') {\n optionalParams[key] = value;\n }\n });\n\n return optionalParams;\n }\n\n // Helper method to check if action has a valid schema\n private hasValidSchema(action: DeviceAction<unknown>): boolean {\n return !!(action?.paramSchema && 'shape' in action.paramSchema);\n }\n\n // Get action space from server with fallback\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Try server first if available\n if (this.serverUrl && typeof window !== 'undefined') {\n try {\n const response = await fetch(`${this.serverUrl}/action-space`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ context }),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to get action space: ${response.statusText}`);\n }\n\n const result = await response.json();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from server:', error);\n // Fall through to context fallback\n }\n }\n\n // Fallback: try context.actionSpace if available\n if (context && typeof context === 'object' && 'actionSpace' in context) {\n try {\n const actionSpaceMethod = (\n context as { actionSpace: () => Promise<DeviceAction<unknown>[]> }\n ).actionSpace;\n const result = await actionSpaceMethod();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from context:', error);\n }\n }\n\n return [];\n }\n\n // Uses base implementation for validateParams and createDisplayContent\n\n // Server communication methods\n async checkStatus(): Promise<boolean> {\n if (!this.serverUrl) {\n return false;\n }\n\n try {\n const res = await fetch(`${this.serverUrl}/status`);\n return res.status === 200;\n } catch (error) {\n console.warn('Server status check failed:', error);\n return false;\n }\n }\n\n async overrideConfig(aiConfig: Record<string, unknown>): Promise<void> {\n if (!this.serverUrl) {\n throw new Error('Server URL not configured');\n }\n\n // Map visualizer config keys to environment variable names\n const mappedConfig: Record<string, unknown> = {};\n\n // Map visualizer config keys to their corresponding environment variable names\n const configKeyMapping: Record<string, string> = {\n deepThink: 'MIDSCENE_FORCE_DEEP_THINK',\n // screenshotIncluded and domIncluded are execution options, not global config\n // They will be passed through ExecutionOptions in executeAction\n\n // Most config keys are already in the correct environment variable format\n // so we don't need to map them. The frontend stores config as OPENAI_API_KEY, etc.\n };\n\n // Convert visualizer config to environment variable format\n Object.entries(aiConfig).forEach(([key, value]) => {\n if (key === 'screenshotIncluded' || key === 'domIncluded') {\n // These are execution options, not global config - skip them here\n return;\n }\n\n const mappedKey = configKeyMapping[key] || key;\n // Environment variables must be strings - convert all values to strings\n mappedConfig[mappedKey] = String(value);\n });\n\n try {\n const response = await fetch(`${this.serverUrl}/config`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ aiConfig: mappedConfig }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to override server config: ${response.statusText}`,\n );\n }\n } catch (error) {\n console.error('Failed to override server config:', error);\n throw error;\n }\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (!this.serverUrl) {\n return { tip: undefined };\n }\n\n if (!requestId?.trim()) {\n console.warn('Invalid requestId provided for task progress');\n return { tip: undefined };\n }\n\n try {\n const response = await fetch(\n `${this.serverUrl}/task-progress/${encodeURIComponent(requestId)}`,\n );\n\n if (!response.ok) {\n console.warn(`Task progress request failed: ${response.statusText}`);\n return { tip: undefined };\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to poll task progress:', error);\n return { tip: undefined };\n }\n }\n\n // Cancel task\n async cancelTask(\n requestId: string,\n ): Promise<{ error?: string; success?: boolean }> {\n // Stop progress polling\n this.stopProgressPolling(requestId);\n\n if (!this.serverUrl) {\n return { error: 'No server URL configured' };\n }\n\n if (!requestId?.trim()) {\n return { error: 'Invalid request ID' };\n }\n\n try {\n const res = await fetch(\n `${this.serverUrl}/cancel/${encodeURIComponent(requestId)}`,\n {\n method: 'POST',\n },\n );\n\n if (!res.ok) {\n return { error: `Cancel request failed: ${res.statusText}` };\n }\n\n const result = await res.json();\n return { success: true, ...result };\n } catch (error) {\n console.error('Failed to cancel task:', error);\n return { error: 'Failed to cancel task' };\n }\n }\n\n // Progress callback management\n setProgressCallback(callback: (tip: string) => void): void {\n this.progressCallback = callback;\n }\n\n // Start progress polling\n private startProgressPolling(\n requestId: string,\n callback: (tip: string) => void,\n ): void {\n // Don't start multiple polling for the same request\n if (this.progressPolling.has(requestId)) {\n return;\n }\n\n let lastTip = '';\n const interval = setInterval(async () => {\n try {\n const progress = await this.getTaskProgress(requestId);\n if (progress?.tip?.trim?.() && progress.tip !== lastTip) {\n lastTip = progress.tip;\n callback(progress.tip);\n }\n } catch (error) {\n // Silently ignore progress polling errors to avoid spam\n console.debug('Progress polling error:', error);\n }\n }, 500); // Poll every 500ms\n\n this.progressPolling.set(requestId, interval);\n }\n\n // Stop progress polling\n private stopProgressPolling(requestId: string): void {\n const interval = this.progressPolling.get(requestId);\n if (interval) {\n clearInterval(interval);\n this.progressPolling.delete(requestId);\n }\n }\n\n // Get screenshot from server\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (!this.serverUrl) {\n return null;\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/screenshot`);\n\n if (!response.ok) {\n console.warn(`Screenshot request failed: ${response.statusText}`);\n return null;\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to get screenshot:', error);\n return null;\n }\n }\n}\n"],"names":["RemoteExecutionAdapter","BasePlaygroundAdapter","value","action","needsStructuredParams","schema","shape","missingFields","Object","key","_fieldDef__def","_fieldDef__def1","fieldDef","isOptional","undefined","params","options","error","message","androidErrors","androidError","keyword","actionType","window","Error","payload","response","fetch","JSON","errorText","result","console","optionalParams","optionalFields","context","Array","actionSpaceMethod","res","aiConfig","mappedConfig","configKeyMapping","mappedKey","String","requestId","encodeURIComponent","callback","lastTip","interval","setInterval","_progress_tip","progress","clearInterval","serverUrl","PLAYGROUND_SERVER_PORT","Map"],"mappings":";;;;;;;;;;;;AAKO,MAAMA,+BAA+BC;IAY1C,eACEC,KAAgB,EAChBC,MAAyC,EACvB;QAClB,IAAI,CAACA,CAAAA,QAAAA,SAAAA,KAAAA,IAAAA,OAAQ,WAAW,AAAD,GACrB,OAAO;YAAE,OAAO;QAAK;QAGvB,MAAMC,wBAAwB,IAAI,CAAC,2BAA2B,CAACD;QAE/D,IAAI,CAACC,uBACH,OAAO;YAAE,OAAO;QAAK;QAGvB,IAAI,CAACF,MAAM,MAAM,EACf,OAAO;YAAE,OAAO;YAAO,cAAc;QAA0B;QAKjE,IAAIC,OAAO,WAAW,IAAI,AAA8B,YAA9B,OAAOA,OAAO,WAAW,EAAe;YAChE,MAAME,SAASF,OAAO,WAAW;YACjC,IAAIE,OAAO,KAAK,IAAIA,AAAg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,MAAMI,WAAW,IAAI,CAAC,eAAe,CAAC,GAAG,CAACJ;QAC1C,IAAII,UAAU;YACZI,cAAcJ;YACd,IAAI,CAAC,eAAe,CAAC,MAAM,CAACJ;QAC9B;IACF;IAGA,MAAM,gBAGI;QACR,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,OAAO;QAGT,IAAI;YACF,MAAMjB,WAAW,MAAMC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAE3D,IAAI,CAACD,SAAS,EAAE,EAAE;gBAChBK,QAAQ,IAAI,CAAC,CAAC,2BAA2B,EAAEL,SAAS,UAAU,EAAE;gBAChE,OAAO;YACT;YAEA,OAAO,MAAMA,SAAS,IAAI;QAC5B,EAAE,OAAOT,OAAO;YACdc,QAAQ,KAAK,CAAC,6BAA6Bd;YAC3C,OAAO;QACT;IACF;IA/aA,YAAYmC,YAAY,CAAC,iBAAiB,EAAEC,wBAAwB,CAAE;QACpE,KAAK,IALP,uBAAQ,aAAR,SACA,uBAAQ,mBAAkB,IAAIC,QAC9B,uBAAQ,oBAAR;QAIE,IAAI,CAAC,SAAS,GAAGF;IACnB;AA6aF"}
1
+ {"version":3,"file":"adapters/remote-execution.mjs","sources":["webpack://@midscene/playground/./src/adapters/remote-execution.ts"],"sourcesContent":["import type { DeviceAction } from '@midscene/core';\nimport type { ExecutionOptions, FormValue, ValidationResult } from '../types';\nimport { BasePlaygroundAdapter } from './base';\n\nexport class RemoteExecutionAdapter extends BasePlaygroundAdapter {\n private serverUrl?: string;\n private progressPolling = new Map<string, NodeJS.Timeout>();\n private progressCallback?: (tip: string) => void;\n\n constructor(serverUrl: string) {\n super();\n this.serverUrl = serverUrl;\n }\n\n // Override validateParams for remote execution\n // Since schemas from server are JSON-serialized and lack .parse() method\n validateParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n if (!action?.paramSchema) {\n return { valid: true };\n }\n\n const needsStructuredParams = this.actionNeedsStructuredParams(action);\n\n if (!needsStructuredParams) {\n return { valid: true };\n }\n\n if (!value.params) {\n return { valid: false, errorMessage: 'Parameters are required' };\n }\n\n // For remote execution, perform basic validation without .parse()\n // Check if required fields are present\n if (action.paramSchema && typeof action.paramSchema === 'object') {\n const schema = action.paramSchema as any;\n if (schema.shape || schema.type === 'ZodObject') {\n const shape = schema.shape || {};\n const missingFields = Object.keys(shape).filter((key) => {\n const fieldDef = shape[key];\n // Check if field is required (not optional)\n const isOptional =\n fieldDef?.isOptional ||\n fieldDef?._def?.innerType || // ZodOptional\n fieldDef?._def?.typeName === 'ZodOptional';\n return (\n !isOptional &&\n (value.params![key] === undefined || value.params![key] === '')\n );\n });\n\n if (missingFields.length > 0) {\n return {\n valid: false,\n errorMessage: `Missing required parameters: ${missingFields.join(', ')}`,\n };\n }\n }\n }\n\n return { valid: true };\n }\n\n async parseStructuredParams(\n action: DeviceAction<unknown>,\n params: Record<string, unknown>,\n options: ExecutionOptions,\n ): Promise<unknown[]> {\n if (!this.hasValidSchema(action)) {\n return [params.prompt || '', options];\n }\n\n // Remote execution format: merge options and valid params into a single object\n return [{ ...options, ...this.filterValidParams(params) }];\n }\n\n formatErrorMessage(error: any): string {\n const message = error?.message || '';\n\n // Handle Android-specific errors\n const androidErrors = [\n {\n keyword: 'adb',\n message:\n 'ADB connection error. Please ensure device is connected and USB debugging is enabled.',\n },\n {\n keyword: 'UIAutomator',\n message:\n 'UIAutomator error. Please ensure the UIAutomator server is running on the device.',\n },\n ];\n\n const androidError = androidErrors.find(({ keyword }) =>\n message.includes(keyword),\n );\n if (androidError) {\n return androidError.message;\n }\n\n return this.formatBasicErrorMessage(error);\n }\n\n // Remote execution adapter - simplified interface\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n // If serverUrl is provided, use server-side execution\n if (this.serverUrl && typeof window !== 'undefined') {\n return this.executeViaServer(actionType, value, options);\n }\n\n throw new Error(\n 'Remote execution adapter requires server URL for execution',\n );\n }\n\n // Remote execution via server - uses same endpoint as requestPlaygroundServer\n private async executeViaServer(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const payload: Record<string, unknown> = {\n type: actionType,\n prompt: value.prompt,\n ...this.buildOptionalPayloadParams(options, value),\n };\n\n // Add context only if it exists (server can handle single agent case without context)\n if (options.context) {\n payload.context = options.context;\n }\n\n // Start progress polling if callback is set and requestId exists\n if (options.requestId && this.progressCallback) {\n this.startProgressPolling(options.requestId, this.progressCallback);\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => 'Unknown error');\n throw new Error(\n `Server request failed (${response.status}): ${errorText}`,\n );\n }\n\n const result = await response.json();\n\n // Stop progress polling when execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n } catch (error) {\n // Stop progress polling on error\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n console.error('Execute via server failed:', error);\n throw error;\n }\n }\n\n // Helper method to build optional payload parameters\n private buildOptionalPayloadParams(\n options: ExecutionOptions,\n value: FormValue,\n ): Record<string, unknown> {\n const optionalParams: Record<string, unknown> = {};\n\n // Add optional parameters only if they have meaningful values\n const optionalFields = [\n { key: 'requestId', value: options.requestId },\n { key: 'deepThink', value: options.deepThink },\n { key: 'screenshotIncluded', value: options.screenshotIncluded },\n { key: 'domIncluded', value: options.domIncluded },\n { key: 'params', value: value.params },\n ] as const;\n\n optionalFields.forEach(({ key, value }) => {\n if (value !== undefined && value !== null && value !== '') {\n optionalParams[key] = value;\n }\n });\n\n return optionalParams;\n }\n\n // Helper method to check if action has a valid schema\n private hasValidSchema(action: DeviceAction<unknown>): boolean {\n return !!(action?.paramSchema && 'shape' in action.paramSchema);\n }\n\n // Get action space from server with fallback\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Try server first if available\n if (this.serverUrl && typeof window !== 'undefined') {\n try {\n const response = await fetch(`${this.serverUrl}/action-space`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ context }),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to get action space: ${response.statusText}`);\n }\n\n const result = await response.json();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from server:', error);\n // Fall through to context fallback\n }\n }\n\n // Fallback: try context.actionSpace if available\n if (context && typeof context === 'object' && 'actionSpace' in context) {\n try {\n const actionSpaceMethod = (\n context as { actionSpace: () => Promise<DeviceAction<unknown>[]> }\n ).actionSpace;\n const result = await actionSpaceMethod();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from context:', error);\n }\n }\n\n return [];\n }\n\n // Uses base implementation for validateParams and createDisplayContent\n\n // Server communication methods\n async checkStatus(): Promise<boolean> {\n if (!this.serverUrl) {\n return false;\n }\n\n try {\n const res = await fetch(`${this.serverUrl}/status`);\n return res.status === 200;\n } catch (error) {\n console.warn('Server status check failed:', error);\n return false;\n }\n }\n\n async overrideConfig(aiConfig: Record<string, unknown>): Promise<void> {\n if (!this.serverUrl) {\n throw new Error('Server URL not configured');\n }\n\n // Map visualizer config keys to environment variable names\n const mappedConfig: Record<string, unknown> = {};\n\n // Map visualizer config keys to their corresponding environment variable names\n const configKeyMapping: Record<string, string> = {\n deepThink: 'MIDSCENE_FORCE_DEEP_THINK',\n // screenshotIncluded and domIncluded are execution options, not global config\n // They will be passed through ExecutionOptions in executeAction\n\n // Most config keys are already in the correct environment variable format\n // so we don't need to map them. The frontend stores config as OPENAI_API_KEY, etc.\n };\n\n // Convert visualizer config to environment variable format\n Object.entries(aiConfig).forEach(([key, value]) => {\n if (key === 'screenshotIncluded' || key === 'domIncluded') {\n // These are execution options, not global config - skip them here\n return;\n }\n\n const mappedKey = configKeyMapping[key] || key;\n // Environment variables must be strings - convert all values to strings\n mappedConfig[mappedKey] = String(value);\n });\n\n try {\n const response = await fetch(`${this.serverUrl}/config`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ aiConfig: mappedConfig }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to override server config: ${response.statusText}`,\n );\n }\n } catch (error) {\n console.error('Failed to override server config:', error);\n throw error;\n }\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (!this.serverUrl) {\n return { tip: undefined };\n }\n\n if (!requestId?.trim()) {\n console.warn('Invalid requestId provided for task progress');\n return { tip: undefined };\n }\n\n try {\n const response = await fetch(\n `${this.serverUrl}/task-progress/${encodeURIComponent(requestId)}`,\n );\n\n if (!response.ok) {\n console.warn(`Task progress request failed: ${response.statusText}`);\n return { tip: undefined };\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to poll task progress:', error);\n return { tip: undefined };\n }\n }\n\n // Cancel task\n async cancelTask(\n requestId: string,\n ): Promise<{ error?: string; success?: boolean }> {\n // Stop progress polling\n this.stopProgressPolling(requestId);\n\n if (!this.serverUrl) {\n return { error: 'No server URL configured' };\n }\n\n if (!requestId?.trim()) {\n return { error: 'Invalid request ID' };\n }\n\n try {\n const res = await fetch(\n `${this.serverUrl}/cancel/${encodeURIComponent(requestId)}`,\n {\n method: 'POST',\n },\n );\n\n if (!res.ok) {\n return { error: `Cancel request failed: ${res.statusText}` };\n }\n\n const result = await res.json();\n return { success: true, ...result };\n } catch (error) {\n console.error('Failed to cancel task:', error);\n return { error: 'Failed to cancel task' };\n }\n }\n\n // Progress callback management\n setProgressCallback(callback: (tip: string) => void): void {\n this.progressCallback = callback;\n }\n\n // Start progress polling\n private startProgressPolling(\n requestId: string,\n callback: (tip: string) => void,\n ): void {\n // Don't start multiple polling for the same request\n if (this.progressPolling.has(requestId)) {\n return;\n }\n\n let lastTip = '';\n const interval = setInterval(async () => {\n try {\n const progress = await this.getTaskProgress(requestId);\n if (progress?.tip?.trim?.() && progress.tip !== lastTip) {\n lastTip = progress.tip;\n callback(progress.tip);\n }\n } catch (error) {\n // Silently ignore progress polling errors to avoid spam\n console.debug('Progress polling error:', error);\n }\n }, 500); // Poll every 500ms\n\n this.progressPolling.set(requestId, interval);\n }\n\n // Stop progress polling\n private stopProgressPolling(requestId: string): void {\n const interval = this.progressPolling.get(requestId);\n if (interval) {\n clearInterval(interval);\n this.progressPolling.delete(requestId);\n }\n }\n\n // Get screenshot from server\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (!this.serverUrl) {\n return null;\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/screenshot`);\n\n if (!response.ok) {\n console.warn(`Screenshot request failed: ${response.statusText}`);\n return null;\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to get screenshot:', error);\n return null;\n }\n }\n}\n"],"names":["RemoteExecutionAdapter","BasePlaygroundAdapter","value","action","needsStructuredParams","schema","shape","missingFields","Object","key","_fieldDef__def","_fieldDef__def1","fieldDef","isOptional","undefined","params","options","error","message","androidErrors","androidError","keyword","actionType","window","Error","payload","response","fetch","JSON","errorText","result","console","optionalParams","optionalFields","context","Array","actionSpaceMethod","res","aiConfig","mappedConfig","configKeyMapping","mappedKey","String","requestId","encodeURIComponent","callback","lastTip","interval","setInterval","_progress_tip","progress","clearInterval","serverUrl","Map"],"mappings":";;;;;;;;;;;AAIO,MAAMA,+BAA+BC;IAY1C,eACEC,KAAgB,EAChBC,MAAyC,EACvB;QAClB,IAAI,CAACA,CAAAA,QAAAA,SAAAA,KAAAA,IAAAA,OAAQ,WAAW,AAAD,GACrB,OAAO;YAAE,OAAO;QAAK;QAGvB,MAAMC,wBAAwB,IAAI,CAAC,2BAA2B,CAACD;QAE/D,IAAI,CAACC,uBACH,OAAO;YAAE,OAAO;QAAK;QAGvB,IAAI,CAACF,MAAM,MAAM,EACf,OAAO;YAAE,OAAO;YAAO,cAAc;QAA0B;QAKjE,IAAIC,OAAO,WAAW,IAAI,AAA8B,YAA9B,OAAOA,OAA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AAC,eAAe,CAAC,GAAG,CAAC0B,WAAWI;IACtC;IAGQ,oBAAoBJ,SAAiB,EAAQ;QACnD,MAAMI,WAAW,IAAI,CAAC,eAAe,CAAC,GAAG,CAACJ;QAC1C,IAAII,UAAU;YACZI,cAAcJ;YACd,IAAI,CAAC,eAAe,CAAC,MAAM,CAACJ;QAC9B;IACF;IAGA,MAAM,gBAGI;QACR,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,OAAO;QAGT,IAAI;YACF,MAAMjB,WAAW,MAAMC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAE3D,IAAI,CAACD,SAAS,EAAE,EAAE;gBAChBK,QAAQ,IAAI,CAAC,CAAC,2BAA2B,EAAEL,SAAS,UAAU,EAAE;gBAChE,OAAO;YACT;YAEA,OAAO,MAAMA,SAAS,IAAI;QAC5B,EAAE,OAAOT,OAAO;YACdc,QAAQ,KAAK,CAAC,6BAA6Bd;YAC3C,OAAO;QACT;IACF;IA/aA,YAAYmC,SAAiB,CAAE;QAC7B,KAAK,IALP,uBAAQ,aAAR,SACA,uBAAQ,mBAAkB,IAAIC,QAC9B,uBAAQ,oBAAR;QAIE,IAAI,CAAC,SAAS,GAAGD;IACnB;AA6aF"}
@@ -19,7 +19,7 @@ class PlaygroundSDK {
19
19
  return new LocalExecutionAdapter(agent);
20
20
  case 'remote-execution':
21
21
  {
22
- const finalServerUrl = serverUrl || ('undefined' != typeof window ? window.location.origin : `http://localhost:${PLAYGROUND_SERVER_PORT}`);
22
+ const finalServerUrl = serverUrl || ('undefined' != typeof window && window.location.protocol.includes('http') ? window.location.origin : `http://localhost:${PLAYGROUND_SERVER_PORT}`);
23
23
  return new RemoteExecutionAdapter(finalServerUrl);
24
24
  }
25
25
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"sdk/index.mjs","sources":["webpack://@midscene/playground/./src/sdk/index.ts"],"sourcesContent":["import type { DeviceAction } from '@midscene/core';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport type { BasePlaygroundAdapter } from '../adapters/base';\nimport { LocalExecutionAdapter } from '../adapters/local-execution';\nimport { RemoteExecutionAdapter } from '../adapters/remote-execution';\nimport type {\n ExecutionOptions,\n FormValue,\n PlaygroundAgent,\n PlaygroundConfig,\n ValidationResult,\n} from '../types';\n\nexport class PlaygroundSDK {\n private adapter: BasePlaygroundAdapter;\n\n constructor(config: PlaygroundConfig) {\n this.adapter = this.createAdapter(\n config.type,\n config.serverUrl,\n config.agent,\n );\n }\n\n private createAdapter(\n type: string,\n serverUrl?: string,\n agent?: PlaygroundAgent,\n ): BasePlaygroundAdapter {\n switch (type) {\n case 'local-execution':\n if (!agent) {\n throw new Error('Agent is required for local execution');\n }\n return new LocalExecutionAdapter(agent);\n case 'remote-execution': {\n // Use provided serverUrl first, then fallback to current page origin or default\n const finalServerUrl =\n serverUrl ||\n (typeof window !== 'undefined'\n ? window.location.origin\n : `http://localhost:${PLAYGROUND_SERVER_PORT}`);\n\n return new RemoteExecutionAdapter(finalServerUrl);\n }\n default:\n throw new Error(`Unsupported execution type: ${type}`);\n }\n }\n\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const result = await this.adapter.executeAction(actionType, value, options);\n\n // Stop any active polling for this request after execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n }\n\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Both adapters now accept context parameter\n // Local will prioritize internal agent, Remote will use server + fallback\n return this.adapter.getActionSpace(context);\n }\n\n validateStructuredParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n return this.adapter.validateParams(value, action);\n }\n\n formatErrorMessage(error: any): string {\n return this.adapter.formatErrorMessage(error);\n }\n\n createDisplayContent(\n value: FormValue,\n needsStructuredParams: boolean,\n action: DeviceAction<unknown> | undefined,\n ): string {\n return this.adapter.createDisplayContent(\n value,\n needsStructuredParams,\n action,\n );\n }\n\n // Server communication methods (for remote execution)\n async checkStatus(): Promise<boolean> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.checkStatus();\n }\n return true; // For local execution, always return true\n }\n\n async overrideConfig(aiConfig: any): Promise<void> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.overrideConfig(aiConfig);\n }\n // For local execution, this is a no-op\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n if (this.adapter instanceof LocalExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n return { tip: undefined }; // Fallback\n }\n\n // Cancel task (for remote execution)\n async cancelTask(requestId: string): Promise<any> {\n // Stop progress polling for this request\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.cancelTask(requestId);\n }\n return { error: 'Cancel task not supported in local execution mode' };\n }\n\n // Progress callback management\n onProgressUpdate(callback: (tip: string) => void): void {\n // Pass the callback to the adapter if it supports it\n if (this.adapter instanceof RemoteExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n }\n }\n\n // Start progress polling for remote execution (deprecated - now handled by adapter)\n startProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n // when executeAction is called with a requestId\n console.warn(\n 'startProgressPolling is deprecated - polling is now automatic',\n );\n }\n\n // Stop progress polling for a specific request (deprecated - now handled by adapter)\n stopProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n console.warn(\n 'stopProgressPolling is deprecated - polling cleanup is now automatic',\n );\n }\n\n // Cancel execution - supports both remote and local\n async cancelExecution(requestId: string): Promise<void> {\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n await this.adapter.cancelTask(requestId);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n // For local execution, we might need to implement agent cancellation\n console.warn('Local execution cancellation not fully implemented');\n }\n }\n\n // Screenshot method for remote execution\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getScreenshot();\n }\n return null; // For local execution, not supported yet\n }\n}\n"],"names":["PlaygroundSDK","type","serverUrl","agent","Error","LocalExecutionAdapter","finalServerUrl","window","PLAYGROUND_SERVER_PORT","RemoteExecutionAdapter","actionType","value","options","result","context","action","error","needsStructuredParams","aiConfig","requestId","undefined","callback","console","config"],"mappings":";;;;;;;;;;;;;AAaO,MAAMA;IAWH,cACNC,IAAY,EACZC,SAAkB,EAClBC,KAAuB,EACA;QACvB,OAAQF;YACN,KAAK;gBACH,IAAI,CAACE,OACH,MAAM,IAAIC,MAAM;gBAElB,OAAO,IAAIC,sBAAsBF;YACnC,KAAK;gBAAoB;oBAEvB,MAAMG,iBACJJ,aACC,CAAkB,eAAlB,OAAOK,SACJA,OAAO,QAAQ,CAAC,MAAM,GACtB,CAAC,iBAAiB,EAAEC,wBAAuB;oBAEjD,OAAO,IAAIC,uBAAuBH;gBACpC;YACA;gBACE,MAAM,IAAIF,MAAM,CAAC,4BAA4B,EAAEH,MAAM;QACzD;IACF;IAEA,MAAM,cACJS,UAAkB,EAClBC,KAAgB,EAChBC,OAAyB,EACP;QAClB,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAACH,YAAYC,OAAOC;QAGnE,IAAIA,QAAQ,SAAS,EACnB,IAAI,CAAC,mBAAmB,CAACA,QAAQ,SAAS;QAG5C,OAAOC;IACT;IAEA,MAAM,eAAeC,OAAiB,EAAoC;QAGxE,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAACA;IACrC;IAEA,yBACEH,KAAgB,EAChBI,MAAyC,EACvB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAACJ,OAAOI;IAC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AAI,CACV;IAEJ;IAGA,MAAM,gBAAgBH,SAAiB,EAAiB;QACtD,IAAI,CAAC,mBAAmB,CAACA;QAEzB,IAAI,IAAI,CAAC,OAAO,YAAYV,wBAC1B,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAACU;aACzB,IAAI,IAAI,CAAC,OAAO,YAAYd,uBAEjCiB,QAAQ,IAAI,CAAC;IAEjB;IAGA,MAAM,gBAGI;QACR,IAAI,IAAI,CAAC,OAAO,YAAYb,wBAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa;QAEnC,OAAO;IACT;IAlKA,YAAYc,MAAwB,CAAE;QAFtC,uBAAQ,WAAR;QAGE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAC/BA,OAAO,IAAI,EACXA,OAAO,SAAS,EAChBA,OAAO,KAAK;IAEhB;AA6JF"}
1
+ {"version":3,"file":"sdk/index.mjs","sources":["webpack://@midscene/playground/./src/sdk/index.ts"],"sourcesContent":["import type { DeviceAction } from '@midscene/core';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport type { BasePlaygroundAdapter } from '../adapters/base';\nimport { LocalExecutionAdapter } from '../adapters/local-execution';\nimport { RemoteExecutionAdapter } from '../adapters/remote-execution';\nimport type {\n ExecutionOptions,\n FormValue,\n PlaygroundAgent,\n PlaygroundConfig,\n ValidationResult,\n} from '../types';\n\nexport class PlaygroundSDK {\n private adapter: BasePlaygroundAdapter;\n\n constructor(config: PlaygroundConfig) {\n this.adapter = this.createAdapter(\n config.type,\n config.serverUrl,\n config.agent,\n );\n }\n\n private createAdapter(\n type: string,\n serverUrl?: string,\n agent?: PlaygroundAgent,\n ): BasePlaygroundAdapter {\n switch (type) {\n case 'local-execution':\n if (!agent) {\n throw new Error('Agent is required for local execution');\n }\n return new LocalExecutionAdapter(agent);\n case 'remote-execution': {\n // Use provided serverUrl first, then fallback to localhost if current page origin is file:// or default\n const finalServerUrl =\n serverUrl ||\n (typeof window !== 'undefined' &&\n window.location.protocol.includes('http')\n ? window.location.origin\n : `http://localhost:${PLAYGROUND_SERVER_PORT}`);\n\n return new RemoteExecutionAdapter(finalServerUrl);\n }\n default:\n throw new Error(`Unsupported execution type: ${type}`);\n }\n }\n\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const result = await this.adapter.executeAction(actionType, value, options);\n\n // Stop any active polling for this request after execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n }\n\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Both adapters now accept context parameter\n // Local will prioritize internal agent, Remote will use server + fallback\n return this.adapter.getActionSpace(context);\n }\n\n validateStructuredParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n return this.adapter.validateParams(value, action);\n }\n\n formatErrorMessage(error: any): string {\n return this.adapter.formatErrorMessage(error);\n }\n\n createDisplayContent(\n value: FormValue,\n needsStructuredParams: boolean,\n action: DeviceAction<unknown> | undefined,\n ): string {\n return this.adapter.createDisplayContent(\n value,\n needsStructuredParams,\n action,\n );\n }\n\n // Server communication methods (for remote execution)\n async checkStatus(): Promise<boolean> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.checkStatus();\n }\n return true; // For local execution, always return true\n }\n\n async overrideConfig(aiConfig: any): Promise<void> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.overrideConfig(aiConfig);\n }\n // For local execution, this is a no-op\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n if (this.adapter instanceof LocalExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n return { tip: undefined }; // Fallback\n }\n\n // Cancel task (for remote execution)\n async cancelTask(requestId: string): Promise<any> {\n // Stop progress polling for this request\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.cancelTask(requestId);\n }\n return { error: 'Cancel task not supported in local execution mode' };\n }\n\n // Progress callback management\n onProgressUpdate(callback: (tip: string) => void): void {\n // Pass the callback to the adapter if it supports it\n if (this.adapter instanceof RemoteExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n }\n }\n\n // Start progress polling for remote execution (deprecated - now handled by adapter)\n startProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n // when executeAction is called with a requestId\n console.warn(\n 'startProgressPolling is deprecated - polling is now automatic',\n );\n }\n\n // Stop progress polling for a specific request (deprecated - now handled by adapter)\n stopProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n console.warn(\n 'stopProgressPolling is deprecated - polling cleanup is now automatic',\n );\n }\n\n // Cancel execution - supports both remote and local\n async cancelExecution(requestId: string): Promise<void> {\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n await this.adapter.cancelTask(requestId);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n // For local execution, we might need to implement agent cancellation\n console.warn('Local execution cancellation not fully implemented');\n }\n }\n\n // Screenshot method for remote execution\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getScreenshot();\n }\n return null; // For local execution, not supported yet\n }\n}\n"],"names":["PlaygroundSDK","type","serverUrl","agent","Error","LocalExecutionAdapter","finalServerUrl","window","PLAYGROUND_SERVER_PORT","RemoteExecutionAdapter","actionType","value","options","result","context","action","error","needsStructuredParams","aiConfig","requestId","undefined","callback","console","config"],"mappings":";;;;;;;;;;;;;AAaO,MAAMA;IAWH,cACNC,IAAY,EACZC,SAAkB,EAClBC,KAAuB,EACA;QACvB,OAAQF;YACN,KAAK;gBACH,IAAI,CAACE,OACH,MAAM,IAAIC,MAAM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,EACXA,OAAO,SAAS,EAChBA,OAAO,KAAK;IAEhB;AA8JF"}
@@ -26,7 +26,6 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  RemoteExecutionAdapter: ()=>RemoteExecutionAdapter
28
28
  });
29
- const constants_namespaceObject = require("@midscene/shared/constants");
30
29
  const external_base_js_namespaceObject = require("./base.js");
31
30
  function _define_property(obj, key, value) {
32
31
  if (key in obj) Object.defineProperty(obj, key, {
@@ -321,7 +320,7 @@ class RemoteExecutionAdapter extends external_base_js_namespaceObject.BasePlaygr
321
320
  return null;
322
321
  }
323
322
  }
324
- constructor(serverUrl = `http://localhost:${constants_namespaceObject.PLAYGROUND_SERVER_PORT}`){
323
+ constructor(serverUrl){
325
324
  super(), _define_property(this, "serverUrl", void 0), _define_property(this, "progressPolling", new Map()), _define_property(this, "progressCallback", void 0);
326
325
  this.serverUrl = serverUrl;
327
326
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adapters/remote-execution.js","sources":["webpack://@midscene/playground/webpack/runtime/define_property_getters","webpack://@midscene/playground/webpack/runtime/has_own_property","webpack://@midscene/playground/webpack/runtime/make_namespace_object","webpack://@midscene/playground/./src/adapters/remote-execution.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { DeviceAction } from '@midscene/core';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport type { ExecutionOptions, FormValue, ValidationResult } from '../types';\nimport { BasePlaygroundAdapter } from './base';\n\nexport class RemoteExecutionAdapter extends BasePlaygroundAdapter {\n private serverUrl?: string;\n private progressPolling = new Map<string, NodeJS.Timeout>();\n private progressCallback?: (tip: string) => void;\n\n constructor(serverUrl = `http://localhost:${PLAYGROUND_SERVER_PORT}`) {\n super();\n this.serverUrl = serverUrl;\n }\n\n // Override validateParams for remote execution\n // Since schemas from server are JSON-serialized and lack .parse() method\n validateParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n if (!action?.paramSchema) {\n return { valid: true };\n }\n\n const needsStructuredParams = this.actionNeedsStructuredParams(action);\n\n if (!needsStructuredParams) {\n return { valid: true };\n }\n\n if (!value.params) {\n return { valid: false, errorMessage: 'Parameters are required' };\n }\n\n // For remote execution, perform basic validation without .parse()\n // Check if required fields are present\n if (action.paramSchema && typeof action.paramSchema === 'object') {\n const schema = action.paramSchema as any;\n if (schema.shape || schema.type === 'ZodObject') {\n const shape = schema.shape || {};\n const missingFields = Object.keys(shape).filter((key) => {\n const fieldDef = shape[key];\n // Check if field is required (not optional)\n const isOptional =\n fieldDef?.isOptional ||\n fieldDef?._def?.innerType || // ZodOptional\n fieldDef?._def?.typeName === 'ZodOptional';\n return (\n !isOptional &&\n (value.params![key] === undefined || value.params![key] === '')\n );\n });\n\n if (missingFields.length > 0) {\n return {\n valid: false,\n errorMessage: `Missing required parameters: ${missingFields.join(', ')}`,\n };\n }\n }\n }\n\n return { valid: true };\n }\n\n async parseStructuredParams(\n action: DeviceAction<unknown>,\n params: Record<string, unknown>,\n options: ExecutionOptions,\n ): Promise<unknown[]> {\n if (!this.hasValidSchema(action)) {\n return [params.prompt || '', options];\n }\n\n // Remote execution format: merge options and valid params into a single object\n return [{ ...options, ...this.filterValidParams(params) }];\n }\n\n formatErrorMessage(error: any): string {\n const message = error?.message || '';\n\n // Handle Android-specific errors\n const androidErrors = [\n {\n keyword: 'adb',\n message:\n 'ADB connection error. Please ensure device is connected and USB debugging is enabled.',\n },\n {\n keyword: 'UIAutomator',\n message:\n 'UIAutomator error. Please ensure the UIAutomator server is running on the device.',\n },\n ];\n\n const androidError = androidErrors.find(({ keyword }) =>\n message.includes(keyword),\n );\n if (androidError) {\n return androidError.message;\n }\n\n return this.formatBasicErrorMessage(error);\n }\n\n // Remote execution adapter - simplified interface\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n // If serverUrl is provided, use server-side execution\n if (this.serverUrl && typeof window !== 'undefined') {\n return this.executeViaServer(actionType, value, options);\n }\n\n throw new Error(\n 'Remote execution adapter requires server URL for execution',\n );\n }\n\n // Remote execution via server - uses same endpoint as requestPlaygroundServer\n private async executeViaServer(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const payload: Record<string, unknown> = {\n type: actionType,\n prompt: value.prompt,\n ...this.buildOptionalPayloadParams(options, value),\n };\n\n // Add context only if it exists (server can handle single agent case without context)\n if (options.context) {\n payload.context = options.context;\n }\n\n // Start progress polling if callback is set and requestId exists\n if (options.requestId && this.progressCallback) {\n this.startProgressPolling(options.requestId, this.progressCallback);\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => 'Unknown error');\n throw new Error(\n `Server request failed (${response.status}): ${errorText}`,\n );\n }\n\n const result = await response.json();\n\n // Stop progress polling when execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n } catch (error) {\n // Stop progress polling on error\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n console.error('Execute via server failed:', error);\n throw error;\n }\n }\n\n // Helper method to build optional payload parameters\n private buildOptionalPayloadParams(\n options: ExecutionOptions,\n value: FormValue,\n ): Record<string, unknown> {\n const optionalParams: Record<string, unknown> = {};\n\n // Add optional parameters only if they have meaningful values\n const optionalFields = [\n { key: 'requestId', value: options.requestId },\n { key: 'deepThink', value: options.deepThink },\n { key: 'screenshotIncluded', value: options.screenshotIncluded },\n { key: 'domIncluded', value: options.domIncluded },\n { key: 'params', value: value.params },\n ] as const;\n\n optionalFields.forEach(({ key, value }) => {\n if (value !== undefined && value !== null && value !== '') {\n optionalParams[key] = value;\n }\n });\n\n return optionalParams;\n }\n\n // Helper method to check if action has a valid schema\n private hasValidSchema(action: DeviceAction<unknown>): boolean {\n return !!(action?.paramSchema && 'shape' in action.paramSchema);\n }\n\n // Get action space from server with fallback\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Try server first if available\n if (this.serverUrl && typeof window !== 'undefined') {\n try {\n const response = await fetch(`${this.serverUrl}/action-space`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ context }),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to get action space: ${response.statusText}`);\n }\n\n const result = await response.json();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from server:', error);\n // Fall through to context fallback\n }\n }\n\n // Fallback: try context.actionSpace if available\n if (context && typeof context === 'object' && 'actionSpace' in context) {\n try {\n const actionSpaceMethod = (\n context as { actionSpace: () => Promise<DeviceAction<unknown>[]> }\n ).actionSpace;\n const result = await actionSpaceMethod();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from context:', error);\n }\n }\n\n return [];\n }\n\n // Uses base implementation for validateParams and createDisplayContent\n\n // Server communication methods\n async checkStatus(): Promise<boolean> {\n if (!this.serverUrl) {\n return false;\n }\n\n try {\n const res = await fetch(`${this.serverUrl}/status`);\n return res.status === 200;\n } catch (error) {\n console.warn('Server status check failed:', error);\n return false;\n }\n }\n\n async overrideConfig(aiConfig: Record<string, unknown>): Promise<void> {\n if (!this.serverUrl) {\n throw new Error('Server URL not configured');\n }\n\n // Map visualizer config keys to environment variable names\n const mappedConfig: Record<string, unknown> = {};\n\n // Map visualizer config keys to their corresponding environment variable names\n const configKeyMapping: Record<string, string> = {\n deepThink: 'MIDSCENE_FORCE_DEEP_THINK',\n // screenshotIncluded and domIncluded are execution options, not global config\n // They will be passed through ExecutionOptions in executeAction\n\n // Most config keys are already in the correct environment variable format\n // so we don't need to map them. The frontend stores config as OPENAI_API_KEY, etc.\n };\n\n // Convert visualizer config to environment variable format\n Object.entries(aiConfig).forEach(([key, value]) => {\n if (key === 'screenshotIncluded' || key === 'domIncluded') {\n // These are execution options, not global config - skip them here\n return;\n }\n\n const mappedKey = configKeyMapping[key] || key;\n // Environment variables must be strings - convert all values to strings\n mappedConfig[mappedKey] = String(value);\n });\n\n try {\n const response = await fetch(`${this.serverUrl}/config`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ aiConfig: mappedConfig }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to override server config: ${response.statusText}`,\n );\n }\n } catch (error) {\n console.error('Failed to override server config:', error);\n throw error;\n }\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (!this.serverUrl) {\n return { tip: undefined };\n }\n\n if (!requestId?.trim()) {\n console.warn('Invalid requestId provided for task progress');\n return { tip: undefined };\n }\n\n try {\n const response = await fetch(\n `${this.serverUrl}/task-progress/${encodeURIComponent(requestId)}`,\n );\n\n if (!response.ok) {\n console.warn(`Task progress request failed: ${response.statusText}`);\n return { tip: undefined };\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to poll task progress:', error);\n return { tip: undefined };\n }\n }\n\n // Cancel task\n async cancelTask(\n requestId: string,\n ): Promise<{ error?: string; success?: boolean }> {\n // Stop progress polling\n this.stopProgressPolling(requestId);\n\n if (!this.serverUrl) {\n return { error: 'No server URL configured' };\n }\n\n if (!requestId?.trim()) {\n return { error: 'Invalid request ID' };\n }\n\n try {\n const res = await fetch(\n `${this.serverUrl}/cancel/${encodeURIComponent(requestId)}`,\n {\n method: 'POST',\n },\n );\n\n if (!res.ok) {\n return { error: `Cancel request failed: ${res.statusText}` };\n }\n\n const result = await res.json();\n return { success: true, ...result };\n } catch (error) {\n console.error('Failed to cancel task:', error);\n return { error: 'Failed to cancel task' };\n }\n }\n\n // Progress callback management\n setProgressCallback(callback: (tip: string) => void): void {\n this.progressCallback = callback;\n }\n\n // Start progress polling\n private startProgressPolling(\n requestId: string,\n callback: (tip: string) => void,\n ): void {\n // Don't start multiple polling for the same request\n if (this.progressPolling.has(requestId)) {\n return;\n }\n\n let lastTip = '';\n const interval = setInterval(async () => {\n try {\n const progress = await this.getTaskProgress(requestId);\n if (progress?.tip?.trim?.() && progress.tip !== lastTip) {\n lastTip = progress.tip;\n callback(progress.tip);\n }\n } catch (error) {\n // Silently ignore progress polling errors to avoid spam\n console.debug('Progress polling error:', error);\n }\n }, 500); // Poll every 500ms\n\n this.progressPolling.set(requestId, interval);\n }\n\n // Stop progress polling\n private stopProgressPolling(requestId: string): void {\n const interval = this.progressPolling.get(requestId);\n if (interval) {\n clearInterval(interval);\n this.progressPolling.delete(requestId);\n }\n }\n\n // Get screenshot from server\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (!this.serverUrl) {\n return null;\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/screenshot`);\n\n if (!response.ok) {\n console.warn(`Screenshot request failed: ${response.statusText}`);\n return null;\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to get screenshot:', error);\n return null;\n }\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","RemoteExecutionAdapter","BasePlaygroundAdapter","value","action","needsStructuredParams","schema","shape","missingFields","_fieldDef__def","_fieldDef__def1","fieldDef","isOptional","undefined","params","options","error","message","androidErrors","androidError","keyword","actionType","window","Error","payload","response","fetch","JSON","errorText","result","console","optionalParams","optionalFields","context","Array","actionSpaceMethod","res","aiConfig","mappedConfig","configKeyMapping","mappedKey","String","requestId","encodeURIComponent","callback","lastTip","interval","setInterval","_progress_tip","progress","clearInterval","server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,CAAC,MAAM,CAACJ;QAC9B;IACF;IAGA,MAAM,gBAGI;QACR,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,OAAO;QAGT,IAAI;YACF,MAAMjB,WAAW,MAAMC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAE3D,IAAI,CAACD,SAAS,EAAE,EAAE;gBAChBK,QAAQ,IAAI,CAAC,CAAC,2BAA2B,EAAEL,SAAS,UAAU,EAAE;gBAChE,OAAO;YACT;YAEA,OAAO,MAAMA,SAAS,IAAI;QAC5B,EAAE,OAAOT,OAAO;YACdc,QAAQ,KAAK,CAAC,6BAA6Bd;YAC3C,OAAO;QACT;IACF;IA/aA,YAAYmC,YAAY,CAAC,iBAAiB,EAAEC,0BAAAA,sBAAsBA,EAAE,CAAE;QACpE,KAAK,IALP,uBAAQ,aAAR,SACA,uBAAQ,mBAAkB,IAAIC,QAC9B,uBAAQ,oBAAR;QAIE,IAAI,CAAC,SAAS,GAAGF;IACnB;AA6aF"}
1
+ {"version":3,"file":"adapters/remote-execution.js","sources":["webpack://@midscene/playground/webpack/runtime/define_property_getters","webpack://@midscene/playground/webpack/runtime/has_own_property","webpack://@midscene/playground/webpack/runtime/make_namespace_object","webpack://@midscene/playground/./src/adapters/remote-execution.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { DeviceAction } from '@midscene/core';\nimport type { ExecutionOptions, FormValue, ValidationResult } from '../types';\nimport { BasePlaygroundAdapter } from './base';\n\nexport class RemoteExecutionAdapter extends BasePlaygroundAdapter {\n private serverUrl?: string;\n private progressPolling = new Map<string, NodeJS.Timeout>();\n private progressCallback?: (tip: string) => void;\n\n constructor(serverUrl: string) {\n super();\n this.serverUrl = serverUrl;\n }\n\n // Override validateParams for remote execution\n // Since schemas from server are JSON-serialized and lack .parse() method\n validateParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n if (!action?.paramSchema) {\n return { valid: true };\n }\n\n const needsStructuredParams = this.actionNeedsStructuredParams(action);\n\n if (!needsStructuredParams) {\n return { valid: true };\n }\n\n if (!value.params) {\n return { valid: false, errorMessage: 'Parameters are required' };\n }\n\n // For remote execution, perform basic validation without .parse()\n // Check if required fields are present\n if (action.paramSchema && typeof action.paramSchema === 'object') {\n const schema = action.paramSchema as any;\n if (schema.shape || schema.type === 'ZodObject') {\n const shape = schema.shape || {};\n const missingFields = Object.keys(shape).filter((key) => {\n const fieldDef = shape[key];\n // Check if field is required (not optional)\n const isOptional =\n fieldDef?.isOptional ||\n fieldDef?._def?.innerType || // ZodOptional\n fieldDef?._def?.typeName === 'ZodOptional';\n return (\n !isOptional &&\n (value.params![key] === undefined || value.params![key] === '')\n );\n });\n\n if (missingFields.length > 0) {\n return {\n valid: false,\n errorMessage: `Missing required parameters: ${missingFields.join(', ')}`,\n };\n }\n }\n }\n\n return { valid: true };\n }\n\n async parseStructuredParams(\n action: DeviceAction<unknown>,\n params: Record<string, unknown>,\n options: ExecutionOptions,\n ): Promise<unknown[]> {\n if (!this.hasValidSchema(action)) {\n return [params.prompt || '', options];\n }\n\n // Remote execution format: merge options and valid params into a single object\n return [{ ...options, ...this.filterValidParams(params) }];\n }\n\n formatErrorMessage(error: any): string {\n const message = error?.message || '';\n\n // Handle Android-specific errors\n const androidErrors = [\n {\n keyword: 'adb',\n message:\n 'ADB connection error. Please ensure device is connected and USB debugging is enabled.',\n },\n {\n keyword: 'UIAutomator',\n message:\n 'UIAutomator error. Please ensure the UIAutomator server is running on the device.',\n },\n ];\n\n const androidError = androidErrors.find(({ keyword }) =>\n message.includes(keyword),\n );\n if (androidError) {\n return androidError.message;\n }\n\n return this.formatBasicErrorMessage(error);\n }\n\n // Remote execution adapter - simplified interface\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n // If serverUrl is provided, use server-side execution\n if (this.serverUrl && typeof window !== 'undefined') {\n return this.executeViaServer(actionType, value, options);\n }\n\n throw new Error(\n 'Remote execution adapter requires server URL for execution',\n );\n }\n\n // Remote execution via server - uses same endpoint as requestPlaygroundServer\n private async executeViaServer(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const payload: Record<string, unknown> = {\n type: actionType,\n prompt: value.prompt,\n ...this.buildOptionalPayloadParams(options, value),\n };\n\n // Add context only if it exists (server can handle single agent case without context)\n if (options.context) {\n payload.context = options.context;\n }\n\n // Start progress polling if callback is set and requestId exists\n if (options.requestId && this.progressCallback) {\n this.startProgressPolling(options.requestId, this.progressCallback);\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => 'Unknown error');\n throw new Error(\n `Server request failed (${response.status}): ${errorText}`,\n );\n }\n\n const result = await response.json();\n\n // Stop progress polling when execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n } catch (error) {\n // Stop progress polling on error\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n console.error('Execute via server failed:', error);\n throw error;\n }\n }\n\n // Helper method to build optional payload parameters\n private buildOptionalPayloadParams(\n options: ExecutionOptions,\n value: FormValue,\n ): Record<string, unknown> {\n const optionalParams: Record<string, unknown> = {};\n\n // Add optional parameters only if they have meaningful values\n const optionalFields = [\n { key: 'requestId', value: options.requestId },\n { key: 'deepThink', value: options.deepThink },\n { key: 'screenshotIncluded', value: options.screenshotIncluded },\n { key: 'domIncluded', value: options.domIncluded },\n { key: 'params', value: value.params },\n ] as const;\n\n optionalFields.forEach(({ key, value }) => {\n if (value !== undefined && value !== null && value !== '') {\n optionalParams[key] = value;\n }\n });\n\n return optionalParams;\n }\n\n // Helper method to check if action has a valid schema\n private hasValidSchema(action: DeviceAction<unknown>): boolean {\n return !!(action?.paramSchema && 'shape' in action.paramSchema);\n }\n\n // Get action space from server with fallback\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Try server first if available\n if (this.serverUrl && typeof window !== 'undefined') {\n try {\n const response = await fetch(`${this.serverUrl}/action-space`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ context }),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to get action space: ${response.statusText}`);\n }\n\n const result = await response.json();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from server:', error);\n // Fall through to context fallback\n }\n }\n\n // Fallback: try context.actionSpace if available\n if (context && typeof context === 'object' && 'actionSpace' in context) {\n try {\n const actionSpaceMethod = (\n context as { actionSpace: () => Promise<DeviceAction<unknown>[]> }\n ).actionSpace;\n const result = await actionSpaceMethod();\n return Array.isArray(result) ? result : [];\n } catch (error) {\n console.error('Failed to get action space from context:', error);\n }\n }\n\n return [];\n }\n\n // Uses base implementation for validateParams and createDisplayContent\n\n // Server communication methods\n async checkStatus(): Promise<boolean> {\n if (!this.serverUrl) {\n return false;\n }\n\n try {\n const res = await fetch(`${this.serverUrl}/status`);\n return res.status === 200;\n } catch (error) {\n console.warn('Server status check failed:', error);\n return false;\n }\n }\n\n async overrideConfig(aiConfig: Record<string, unknown>): Promise<void> {\n if (!this.serverUrl) {\n throw new Error('Server URL not configured');\n }\n\n // Map visualizer config keys to environment variable names\n const mappedConfig: Record<string, unknown> = {};\n\n // Map visualizer config keys to their corresponding environment variable names\n const configKeyMapping: Record<string, string> = {\n deepThink: 'MIDSCENE_FORCE_DEEP_THINK',\n // screenshotIncluded and domIncluded are execution options, not global config\n // They will be passed through ExecutionOptions in executeAction\n\n // Most config keys are already in the correct environment variable format\n // so we don't need to map them. The frontend stores config as OPENAI_API_KEY, etc.\n };\n\n // Convert visualizer config to environment variable format\n Object.entries(aiConfig).forEach(([key, value]) => {\n if (key === 'screenshotIncluded' || key === 'domIncluded') {\n // These are execution options, not global config - skip them here\n return;\n }\n\n const mappedKey = configKeyMapping[key] || key;\n // Environment variables must be strings - convert all values to strings\n mappedConfig[mappedKey] = String(value);\n });\n\n try {\n const response = await fetch(`${this.serverUrl}/config`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ aiConfig: mappedConfig }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to override server config: ${response.statusText}`,\n );\n }\n } catch (error) {\n console.error('Failed to override server config:', error);\n throw error;\n }\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (!this.serverUrl) {\n return { tip: undefined };\n }\n\n if (!requestId?.trim()) {\n console.warn('Invalid requestId provided for task progress');\n return { tip: undefined };\n }\n\n try {\n const response = await fetch(\n `${this.serverUrl}/task-progress/${encodeURIComponent(requestId)}`,\n );\n\n if (!response.ok) {\n console.warn(`Task progress request failed: ${response.statusText}`);\n return { tip: undefined };\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to poll task progress:', error);\n return { tip: undefined };\n }\n }\n\n // Cancel task\n async cancelTask(\n requestId: string,\n ): Promise<{ error?: string; success?: boolean }> {\n // Stop progress polling\n this.stopProgressPolling(requestId);\n\n if (!this.serverUrl) {\n return { error: 'No server URL configured' };\n }\n\n if (!requestId?.trim()) {\n return { error: 'Invalid request ID' };\n }\n\n try {\n const res = await fetch(\n `${this.serverUrl}/cancel/${encodeURIComponent(requestId)}`,\n {\n method: 'POST',\n },\n );\n\n if (!res.ok) {\n return { error: `Cancel request failed: ${res.statusText}` };\n }\n\n const result = await res.json();\n return { success: true, ...result };\n } catch (error) {\n console.error('Failed to cancel task:', error);\n return { error: 'Failed to cancel task' };\n }\n }\n\n // Progress callback management\n setProgressCallback(callback: (tip: string) => void): void {\n this.progressCallback = callback;\n }\n\n // Start progress polling\n private startProgressPolling(\n requestId: string,\n callback: (tip: string) => void,\n ): void {\n // Don't start multiple polling for the same request\n if (this.progressPolling.has(requestId)) {\n return;\n }\n\n let lastTip = '';\n const interval = setInterval(async () => {\n try {\n const progress = await this.getTaskProgress(requestId);\n if (progress?.tip?.trim?.() && progress.tip !== lastTip) {\n lastTip = progress.tip;\n callback(progress.tip);\n }\n } catch (error) {\n // Silently ignore progress polling errors to avoid spam\n console.debug('Progress polling error:', error);\n }\n }, 500); // Poll every 500ms\n\n this.progressPolling.set(requestId, interval);\n }\n\n // Stop progress polling\n private stopProgressPolling(requestId: string): void {\n const interval = this.progressPolling.get(requestId);\n if (interval) {\n clearInterval(interval);\n this.progressPolling.delete(requestId);\n }\n }\n\n // Get screenshot from server\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (!this.serverUrl) {\n return null;\n }\n\n try {\n const response = await fetch(`${this.serverUrl}/screenshot`);\n\n if (!response.ok) {\n console.warn(`Screenshot request failed: ${response.statusText}`);\n return null;\n }\n\n return await response.json();\n } catch (error) {\n console.error('Failed to get screenshot:', error);\n return null;\n }\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","RemoteExecutionAdapter","BasePlaygroundAdapter","value","action","needsStructuredParams","schema","shape","missingFields","_fieldDef__def","_fieldDef__def1","fieldDef","isOptional","undefined","params","options","error","message","androidErrors","androidError","keyword","actionType","window","Error","payload","response","fetch","JSON","errorText","result","console","optionalParams","optionalFields","context","Array","actionSpaceMethod","res","aiConfig","mappedConfig","configKeyMapping","mappedKey","String","requestId","encodeURIComponent","callback","lastTip","interval","setInterval","_progress_tip","progress","clearInterval","serverUrl","Map"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAA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,IAAI,CAAC,SAAS,EACjB,OAAO;QAGT,IAAI;YACF,MAAMjB,WAAW,MAAMC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAE3D,IAAI,CAACD,SAAS,EAAE,EAAE;gBAChBK,QAAQ,IAAI,CAAC,CAAC,2BAA2B,EAAEL,SAAS,UAAU,EAAE;gBAChE,OAAO;YACT;YAEA,OAAO,MAAMA,SAAS,IAAI;QAC5B,EAAE,OAAOT,OAAO;YACdc,QAAQ,KAAK,CAAC,6BAA6Bd;YAC3C,OAAO;QACT;IACF;IA/aA,YAAYmC,SAAiB,CAAE;QAC7B,KAAK,IALP,uBAAQ,aAAR,SACA,uBAAQ,mBAAkB,IAAIC,QAC9B,uBAAQ,oBAAR;QAIE,IAAI,CAAC,SAAS,GAAGD;IACnB;AA6aF"}
@@ -47,7 +47,7 @@ class PlaygroundSDK {
47
47
  return new local_execution_js_namespaceObject.LocalExecutionAdapter(agent);
48
48
  case 'remote-execution':
49
49
  {
50
- const finalServerUrl = serverUrl || ('undefined' != typeof window ? window.location.origin : `http://localhost:${constants_namespaceObject.PLAYGROUND_SERVER_PORT}`);
50
+ const finalServerUrl = serverUrl || ('undefined' != typeof window && window.location.protocol.includes('http') ? window.location.origin : `http://localhost:${constants_namespaceObject.PLAYGROUND_SERVER_PORT}`);
51
51
  return new remote_execution_js_namespaceObject.RemoteExecutionAdapter(finalServerUrl);
52
52
  }
53
53
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"sdk/index.js","sources":["webpack://@midscene/playground/webpack/runtime/define_property_getters","webpack://@midscene/playground/webpack/runtime/has_own_property","webpack://@midscene/playground/webpack/runtime/make_namespace_object","webpack://@midscene/playground/./src/sdk/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { DeviceAction } from '@midscene/core';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport type { BasePlaygroundAdapter } from '../adapters/base';\nimport { LocalExecutionAdapter } from '../adapters/local-execution';\nimport { RemoteExecutionAdapter } from '../adapters/remote-execution';\nimport type {\n ExecutionOptions,\n FormValue,\n PlaygroundAgent,\n PlaygroundConfig,\n ValidationResult,\n} from '../types';\n\nexport class PlaygroundSDK {\n private adapter: BasePlaygroundAdapter;\n\n constructor(config: PlaygroundConfig) {\n this.adapter = this.createAdapter(\n config.type,\n config.serverUrl,\n config.agent,\n );\n }\n\n private createAdapter(\n type: string,\n serverUrl?: string,\n agent?: PlaygroundAgent,\n ): BasePlaygroundAdapter {\n switch (type) {\n case 'local-execution':\n if (!agent) {\n throw new Error('Agent is required for local execution');\n }\n return new LocalExecutionAdapter(agent);\n case 'remote-execution': {\n // Use provided serverUrl first, then fallback to current page origin or default\n const finalServerUrl =\n serverUrl ||\n (typeof window !== 'undefined'\n ? window.location.origin\n : `http://localhost:${PLAYGROUND_SERVER_PORT}`);\n\n return new RemoteExecutionAdapter(finalServerUrl);\n }\n default:\n throw new Error(`Unsupported execution type: ${type}`);\n }\n }\n\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const result = await this.adapter.executeAction(actionType, value, options);\n\n // Stop any active polling for this request after execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n }\n\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Both adapters now accept context parameter\n // Local will prioritize internal agent, Remote will use server + fallback\n return this.adapter.getActionSpace(context);\n }\n\n validateStructuredParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n return this.adapter.validateParams(value, action);\n }\n\n formatErrorMessage(error: any): string {\n return this.adapter.formatErrorMessage(error);\n }\n\n createDisplayContent(\n value: FormValue,\n needsStructuredParams: boolean,\n action: DeviceAction<unknown> | undefined,\n ): string {\n return this.adapter.createDisplayContent(\n value,\n needsStructuredParams,\n action,\n );\n }\n\n // Server communication methods (for remote execution)\n async checkStatus(): Promise<boolean> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.checkStatus();\n }\n return true; // For local execution, always return true\n }\n\n async overrideConfig(aiConfig: any): Promise<void> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.overrideConfig(aiConfig);\n }\n // For local execution, this is a no-op\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n if (this.adapter instanceof LocalExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n return { tip: undefined }; // Fallback\n }\n\n // Cancel task (for remote execution)\n async cancelTask(requestId: string): Promise<any> {\n // Stop progress polling for this request\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.cancelTask(requestId);\n }\n return { error: 'Cancel task not supported in local execution mode' };\n }\n\n // Progress callback management\n onProgressUpdate(callback: (tip: string) => void): void {\n // Pass the callback to the adapter if it supports it\n if (this.adapter instanceof RemoteExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n }\n }\n\n // Start progress polling for remote execution (deprecated - now handled by adapter)\n startProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n // when executeAction is called with a requestId\n console.warn(\n 'startProgressPolling is deprecated - polling is now automatic',\n );\n }\n\n // Stop progress polling for a specific request (deprecated - now handled by adapter)\n stopProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n console.warn(\n 'stopProgressPolling is deprecated - polling cleanup is now automatic',\n );\n }\n\n // Cancel execution - supports both remote and local\n async cancelExecution(requestId: string): Promise<void> {\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n await this.adapter.cancelTask(requestId);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n // For local execution, we might need to implement agent cancellation\n console.warn('Local execution cancellation not fully implemented');\n }\n }\n\n // Screenshot method for remote execution\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getScreenshot();\n }\n return null; // For local execution, not supported yet\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","PlaygroundSDK","type","serverUrl","agent","Error","LocalExecutionAdapter","finalServerUrl","window","PLAYGROUND_SERVER_PORT","RemoteExecutionAdapter","actionType","value","options","result","context","action","error","needsStructuredParams","aiConfig","requestId","undefined","callback","console","config"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;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AYd,mCAAAA,qBAAqBA,EAEtDiB,QAAQ,IAAI,CAAC;IAEjB;IAGA,MAAM,gBAGI;QACR,IAAI,IAAI,CAAC,OAAO,YAAYb,oCAAAA,sBAAsBA,EAChD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa;QAEnC,OAAO;IACT;IAlKA,YAAYc,MAAwB,CAAE;QAFtC,uBAAQ,WAAR;QAGE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAC/BA,OAAO,IAAI,EACXA,OAAO,SAAS,EAChBA,OAAO,KAAK;IAEhB;AA6JF"}
1
+ {"version":3,"file":"sdk/index.js","sources":["webpack://@midscene/playground/webpack/runtime/define_property_getters","webpack://@midscene/playground/webpack/runtime/has_own_property","webpack://@midscene/playground/webpack/runtime/make_namespace_object","webpack://@midscene/playground/./src/sdk/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { DeviceAction } from '@midscene/core';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport type { BasePlaygroundAdapter } from '../adapters/base';\nimport { LocalExecutionAdapter } from '../adapters/local-execution';\nimport { RemoteExecutionAdapter } from '../adapters/remote-execution';\nimport type {\n ExecutionOptions,\n FormValue,\n PlaygroundAgent,\n PlaygroundConfig,\n ValidationResult,\n} from '../types';\n\nexport class PlaygroundSDK {\n private adapter: BasePlaygroundAdapter;\n\n constructor(config: PlaygroundConfig) {\n this.adapter = this.createAdapter(\n config.type,\n config.serverUrl,\n config.agent,\n );\n }\n\n private createAdapter(\n type: string,\n serverUrl?: string,\n agent?: PlaygroundAgent,\n ): BasePlaygroundAdapter {\n switch (type) {\n case 'local-execution':\n if (!agent) {\n throw new Error('Agent is required for local execution');\n }\n return new LocalExecutionAdapter(agent);\n case 'remote-execution': {\n // Use provided serverUrl first, then fallback to localhost if current page origin is file:// or default\n const finalServerUrl =\n serverUrl ||\n (typeof window !== 'undefined' &&\n window.location.protocol.includes('http')\n ? window.location.origin\n : `http://localhost:${PLAYGROUND_SERVER_PORT}`);\n\n return new RemoteExecutionAdapter(finalServerUrl);\n }\n default:\n throw new Error(`Unsupported execution type: ${type}`);\n }\n }\n\n async executeAction(\n actionType: string,\n value: FormValue,\n options: ExecutionOptions,\n ): Promise<unknown> {\n const result = await this.adapter.executeAction(actionType, value, options);\n\n // Stop any active polling for this request after execution completes\n if (options.requestId) {\n this.stopProgressPolling(options.requestId);\n }\n\n return result;\n }\n\n async getActionSpace(context?: unknown): Promise<DeviceAction<unknown>[]> {\n // Both adapters now accept context parameter\n // Local will prioritize internal agent, Remote will use server + fallback\n return this.adapter.getActionSpace(context);\n }\n\n validateStructuredParams(\n value: FormValue,\n action: DeviceAction<unknown> | undefined,\n ): ValidationResult {\n return this.adapter.validateParams(value, action);\n }\n\n formatErrorMessage(error: any): string {\n return this.adapter.formatErrorMessage(error);\n }\n\n createDisplayContent(\n value: FormValue,\n needsStructuredParams: boolean,\n action: DeviceAction<unknown> | undefined,\n ): string {\n return this.adapter.createDisplayContent(\n value,\n needsStructuredParams,\n action,\n );\n }\n\n // Server communication methods (for remote execution)\n async checkStatus(): Promise<boolean> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.checkStatus();\n }\n return true; // For local execution, always return true\n }\n\n async overrideConfig(aiConfig: any): Promise<void> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.overrideConfig(aiConfig);\n }\n // For local execution, this is a no-op\n }\n\n async getTaskProgress(requestId: string): Promise<{ tip?: string }> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n if (this.adapter instanceof LocalExecutionAdapter) {\n return this.adapter.getTaskProgress(requestId);\n }\n return { tip: undefined }; // Fallback\n }\n\n // Cancel task (for remote execution)\n async cancelTask(requestId: string): Promise<any> {\n // Stop progress polling for this request\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.cancelTask(requestId);\n }\n return { error: 'Cancel task not supported in local execution mode' };\n }\n\n // Progress callback management\n onProgressUpdate(callback: (tip: string) => void): void {\n // Pass the callback to the adapter if it supports it\n if (this.adapter instanceof RemoteExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n this.adapter.setProgressCallback(callback);\n }\n }\n\n // Start progress polling for remote execution (deprecated - now handled by adapter)\n startProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n // when executeAction is called with a requestId\n console.warn(\n 'startProgressPolling is deprecated - polling is now automatic',\n );\n }\n\n // Stop progress polling for a specific request (deprecated - now handled by adapter)\n stopProgressPolling(requestId: string): void {\n // This method is now handled by the RemoteExecutionAdapter automatically\n console.warn(\n 'stopProgressPolling is deprecated - polling cleanup is now automatic',\n );\n }\n\n // Cancel execution - supports both remote and local\n async cancelExecution(requestId: string): Promise<void> {\n this.stopProgressPolling(requestId);\n\n if (this.adapter instanceof RemoteExecutionAdapter) {\n await this.adapter.cancelTask(requestId);\n } else if (this.adapter instanceof LocalExecutionAdapter) {\n // For local execution, we might need to implement agent cancellation\n console.warn('Local execution cancellation not fully implemented');\n }\n }\n\n // Screenshot method for remote execution\n async getScreenshot(): Promise<{\n screenshot: string;\n timestamp: number;\n } | null> {\n if (this.adapter instanceof RemoteExecutionAdapter) {\n return this.adapter.getScreenshot();\n }\n return null; // For local execution, not supported yet\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","PlaygroundSDK","type","serverUrl","agent","Error","LocalExecutionAdapter","finalServerUrl","window","PLAYGROUND_SERVER_PORT","RemoteExecutionAdapter","actionType","value","options","result","context","action","error","needsStructuredParams","aiConfig","requestId","undefined","callback","console","config"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;ACOO,MAAMI;IAWH,cACNC,IAAY,EACZC,SAAkB,EAClBC,KAAuB,EACA;QACvB,OAAQF;YACN,KAAK;gBACH,IAAI,CAACE,OACH,MAAM,IAAIC,MAAM;gBAElB,OAAO,IAAIC,mCAAAA,qBAAqBA,CAACF;YACnC,KAAK;gBAAoB;oBAEvB,MAAMG,iBACJJ,aACC,CAAkB,eAAlB,OAAOK,UACRA,OAAO,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAC9BA,OAAO,QAAQ,CAAC,MAAM,GACtB,CAAC,iBAAiB,EAAEC,0BAAAA,sBAAsBA,EAAC;oBAEjD,OAAO,IAAIC,oCAAAA,sBAAsBA,CAACH;gBACpC;YACA;gBACE,MAAM,IAAIF,MAAM,CAAC,4BAA4B,EAAE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private progressCallback?;
8
- constructor(serverUrl?: string);
8
+ constructor(serverUrl: string);
9
9
  validateParams(value: FormValue, action: DeviceAction<unknown> | undefined): ValidationResult;
10
10
  parseStructuredParams(action: DeviceAction<unknown>, params: Record<string, unknown>, options: ExecutionOptions): Promise<unknown[]>;
11
11
  formatErrorMessage(error: any): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/playground",
3
- "version": "0.28.5",
3
+ "version": "0.28.6",
4
4
  "description": "Midscene playground utilities for web integration",
5
5
  "author": "midscene team",
6
6
  "license": "MIT",
@@ -23,8 +23,8 @@
23
23
  "dotenv": "16.4.5",
24
24
  "express": "^4.21.2",
25
25
  "open": "10.1.0",
26
- "@midscene/shared": "0.28.5",
27
- "@midscene/core": "0.28.5"
26
+ "@midscene/core": "0.28.6",
27
+ "@midscene/shared": "0.28.6"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@rslib/core": "^0.11.2",
package/static/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.f566a9ed.js"></script><script defer src="/static/js/345.c34b9bb0.js"></script><script defer src="/static/js/index.e17a7825.js"></script><link href="/static/css/index.e69eb607.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.f566a9ed.js"></script><script defer src="/static/js/591.95560d2e.js"></script><script defer src="/static/js/index.498dbe2d.js"></script><link href="/static/css/index.ac4cc11d.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
@@ -0,0 +1,2 @@
1
+ body{margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px}.app-container{background-color:#f5f5f5;flex-direction:column;width:100%;height:100vh;display:flex}.app-content{height:100vh;overflow:hidden}.app-grid-layout{height:100%;display:flex}.app-grid-layout .ant-row{flex-wrap:nowrap;flex:1;width:100%;height:100%;display:flex}.app-panel{background-color:#fff;border-radius:0;height:100%;transition:box-shadow .3s;overflow:hidden;box-shadow:0 1px 2px #0000000d}.app-panel:hover{box-shadow:0 2px 8px #00000017}.app-panel.left-panel{flex-direction:column;flex:none;width:480px;height:100%;display:flex;overflow:hidden}.app-panel.right-panel{border-radius:0;flex:1;overflow:hidden;box-shadow:-4px 0 20px #0000000a}.panel-content{flex-direction:column;height:100%;padding:12px 24px 24px;display:flex;overflow:auto}.panel-content.left-panel-content{flex-direction:column;height:100%;display:flex;overflow:hidden}.panel-content.left-panel-content .playground-panel-header{flex-shrink:0;padding:16px 16px 0}.panel-content.left-panel-content .playground-panel-header .header-row{justify-content:space-between;align-items:center;gap:10px;margin-bottom:16px;display:flex}.panel-content.left-panel-content .playground-panel-header h2{color:#1890ff;margin:0 0 16px;font-size:18px;font-weight:600}.panel-content.left-panel-content .playground-panel-playground{flex-direction:column;flex:1;min-height:0;padding:0 16px 16px;display:flex}.panel-content.left-panel-content .playground-panel-playground .playground-container{background:#fff;border:1px solid #0000001f;border-radius:8px;flex:1;overflow:hidden}.panel-content.right-panel-content{border-radius:0}.server-offline-container{background:#f5f5f5;justify-content:center;align-items:center;height:100vh;display:flex}.server-offline-container .server-offline-message{text-align:center;background:#fff;border-radius:8px;max-width:600px;padding:48px 24px;box-shadow:0 2px 8px #0000000f}.server-offline-container .server-offline-message h1{color:#1890ff;margin:16px 0 8px;font-size:24px;font-weight:600}.server-offline-container .server-offline-message .server-status{justify-content:center;align-items:center;gap:6px;margin-bottom:24px;font-size:14px;display:flex}.server-offline-container .server-offline-message .server-status .status-dot{border-radius:50%;width:8px;height:8px;display:inline-block}.server-offline-container .server-offline-message .server-status.offline{color:#ff4d4f}.server-offline-container .server-offline-message .server-status.offline .status-dot{background:#ff4d4f}.server-offline-container .server-offline-message h2{color:#1890ff;margin-bottom:16px;font-size:32px}.server-offline-container .server-offline-message p{color:#666;margin-bottom:24px;font-size:16px;line-height:1.6}.server-offline-container .server-offline-message .start-command{background:#f6f8fa;border:1px solid #e1e4e8;border-radius:8px;margin:24px 0;padding:16px 24px;font-family:Monaco,Menlo,Ubuntu Mono,monospace}.server-offline-container .server-offline-message .start-command code{color:#1890ff;font-size:16px;font-weight:600}.server-offline-container .server-offline-message .server-info{color:#999;font-size:14px}.server-offline-container .server-offline-message .server-info a{color:#1890ff;text-decoration:none}.server-offline-container .server-offline-message .server-info a:hover{text-decoration:underline}.screenshot-viewer{flex-direction:column;height:100%;display:flex}.screenshot-viewer.offline,.screenshot-viewer.loading,.screenshot-viewer.error{text-align:center;color:#666;justify-content:center;align-items:center}.screenshot-viewer.offline .screenshot-placeholder h3,.screenshot-viewer.loading .screenshot-placeholder h3,.screenshot-viewer.error .screenshot-placeholder h3{color:#1890ff;margin-bottom:12px;font-size:18px}.screenshot-viewer.offline .screenshot-placeholder p,.screenshot-viewer.loading .screenshot-placeholder p,.screenshot-viewer.error .screenshot-placeholder p{color:#666;margin:0}.screenshot-viewer.offline .screenshot-placeholder p.error-message,.screenshot-viewer.loading .screenshot-placeholder p.error-message,.screenshot-viewer.error .screenshot-placeholder p.error-message{color:#ff4d4f}.screenshot-viewer .screenshot-header{border-bottom:1px solid #e8e8e8;justify-content:space-between;align-items:center;margin-bottom:16px;padding-bottom:12px;display:flex}.screenshot-viewer .screenshot-header .screenshot-title{flex-direction:column;gap:4px;display:flex}.screenshot-viewer .screenshot-header .screenshot-title h3{color:#1890ff;margin:0;font-size:16px}.screenshot-viewer .screenshot-header .screenshot-title .last-update-time{color:#999;font-size:12px}.screenshot-viewer .screenshot-header .screenshot-controls{align-items:center;gap:8px;display:flex}.screenshot-viewer .screenshot-header .screenshot-controls .operation-indicator{color:#1890ff;align-items:center;gap:4px;font-size:12px;display:flex}.screenshot-viewer .screenshot-container{background:#fafafa;border:1px solid #e8e8e8;border-radius:8px;flex:1;justify-content:center;align-items:center;display:flex;overflow:hidden}.screenshot-viewer .screenshot-container .screenshot-image{object-fit:contain;border-radius:4px;max-width:100%;height:auto;max-height:100%}.screenshot-viewer .screenshot-container .screenshot-placeholder{text-align:center;color:#999}.playground-container .playground-container{height:100%}.playground-container .playground-container .bottom-input-section,.playground-container .playground-container .version-info-section{background:#fff}@media (max-width:1200px){.app-panel.left-panel{width:420px}}@media (max-width:768px){.app-grid-layout .ant-row{flex-direction:column}.app-panel.left-panel{flex:none;width:100%;height:60%}.app-panel.right-panel{border-top:1px solid #00000014;border-left:none;flex:none;width:100%;height:40%}.server-offline-container .server-offline-message{margin:16px;padding:32px 16px}.server-offline-container .server-offline-message h1{font-size:20px}.server-offline-container .server-offline-message h2{font-size:24px}.server-offline-container .server-offline-message .start-command{padding:12px 16px}.server-offline-container .server-offline-message .start-command code{font-size:14px}}.logo img{vertical-align:baseline;height:30px;vertical-align:-webkit-baseline-middle;line-height:30px}.logo-with-star-wrapper{flex-direction:row;justify-content:space-between;display:flex}.blackboard .footer{color:#aaa}.blackboard ul{padding-left:0}.blackboard li{list-style:none}.blackboard .bottom-tip{height:30px}.blackboard .bottom-tip-item{color:#aaa;text-overflow:ellipsis;word-wrap:break-word;max-width:500px}.blackboard-filter{margin:10px 0}.blackboard-main-content canvas{box-sizing:border-box;border:1px solid #888;width:100%}.shiny-text{color:#0000;letter-spacing:.5px;text-shadow:0 1px 2px #0000000d;background-image:linear-gradient(45deg,#2b83ff,#6a11cb,#2575fc,#4481eb);background-size:300%;-webkit-background-clip:text;background-clip:text;font-weight:600;animation:8s infinite textGradient;display:inline-block;position:relative;overflow:hidden}.shiny-text:after{content:"";width:120%;height:120%;animation:shine var(--animation-duration,5s)cubic-bezier(.25,.1,.25,1)infinite;z-index:1;pointer-events:none;background:linear-gradient(90deg,#fff0 0%,#ffffff1a 10%,#fff9 50%,#ffffff1a 90%,#fff0 100%);position:absolute;top:-10%;left:-150%;transform:skew(-20deg)translateY(0)}.shiny-text.disabled{background:#2b83ff;-webkit-background-clip:text;background-clip:text;animation:none}.shiny-text.disabled:after{animation:none;display:none}@keyframes shine{0%{opacity:.7;left:-150%}20%{opacity:1}80%{opacity:1}to{opacity:.7;left:250%}}@keyframes textGradient{0%{background-position:0%}50%{background-position:100%}to{background-position:0%}}.env-config-reminder{background:#fff2e8;border-radius:12px;align-items:center;gap:12px;margin-bottom:12px;padding:12px 16px;display:flex}.env-config-reminder .reminder-icon{color:#fa541c;width:16px;height:16px}.env-config-reminder .reminder-text{color:#000;flex:1;font-size:14px}.player-container{box-sizing:border-box;background:#f2f4f7;border:1px solid #f2f4f7;border-radius:8px;flex-direction:column;width:100%;max-width:100%;height:100%;min-height:300px;max-height:100%;margin:0 auto;padding:12px;line-height:100%;display:flex;position:relative;overflow:visible}.player-container[data-fit-mode=height]{background:#fff}.player-container[data-fit-mode=height] .canvas-container{background-color:#f2f4f7}.player-container .canvas-container{width:100%;min-height:200px;aspect-ratio:var(--canvas-aspect-ratio,16/9);background-color:#fff;border-top-left-radius:16px;border-top-right-radius:16px;flex:none;justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.player-container .canvas-container canvas{box-sizing:border-box;object-fit:contain;border:none;width:100%;max-width:100%;height:auto;max-height:100%;margin:0 auto;display:block}.player-container .canvas-container[data-fit-mode=height]{aspect-ratio:unset;flex:auto;height:auto;min-height:0}.player-container .canvas-container[data-fit-mode=height] canvas{width:auto;max-width:100%;height:100%;max-height:100%}.player-container .canvas-container[data-fit-mode=width]{aspect-ratio:var(--canvas-aspect-ratio,16/9)}.player-container .canvas-container[data-fit-mode=width] canvas{width:100%;height:auto}.player-container .player-timeline-wrapper{flex:none;width:100%;height:4px;margin-bottom:2px;position:relative}.player-container .player-timeline{background:#666;flex-shrink:0;width:100%;height:4px;position:relative}.player-container .player-timeline .player-timeline-progress{background:#2b83ff;height:4px;transition-timing-function:linear;position:absolute;top:0;left:0}.player-container .player-tools-wrapper{box-sizing:border-box;flex:none;width:100%;height:72px;padding:15px 16px;position:relative}.player-container .player-tools{color:#000;box-sizing:border-box;flex-direction:row;flex-shrink:0;justify-content:space-between;width:100%;max-width:100%;height:42px;font-size:14px;display:flex;overflow:hidden}.player-container .player-tools .ant-spin{color:#333}.player-container .player-tools .player-control{flex-direction:row;flex-grow:1;align-items:center;display:flex;overflow:hidden}.player-container .player-tools .status-icon{border-radius:8px;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;margin-left:10px;transition:all .2s;display:flex}.player-container .player-tools .status-icon:hover{cursor:pointer;background:#f0f0f0}.player-container .player-tools .status-text{flex-direction:column;flex-grow:1;flex-shrink:1;justify-content:space-between;width:0;min-width:0;height:100%;display:flex;position:relative;overflow:hidden}.player-container .player-tools .title{font-weight:600}.player-container .player-tools .title,.player-container .player-tools .subtitle{text-overflow:ellipsis;white-space:nowrap;width:100%;overflow:hidden}.player-container .player-tools .player-tools-item{flex-direction:column;justify-content:center;height:100%;display:flex}.result-wrapper{justify-content:center;align-items:center;height:100%;margin:4px 0;display:flex}.result-wrapper .loading-container{flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;display:flex}.result-wrapper .loading-container .loading-progress-text{color:#888;margin-top:8px;font-size:12px}.result-wrapper pre{white-space:pre-wrap;text-wrap:unset;word-wrap:break-word;overflow-wrap:break-word;background:#f2f4f7;border-radius:8px;margin:0;padding:14px;overflow:scroll}.playground-container{background:#fff;flex-direction:column;width:100%;height:100vh;display:flex}.playground-container .command-form{flex-direction:column;width:100%;height:100%;padding:0 12px;display:flex}.playground-container .context-preview-section{border-bottom:1px solid #f0f0f0;flex-shrink:0;padding:16px}.playground-container .middle-dialog-area{flex-direction:column;flex:1;min-height:0;display:flex;position:relative;overflow:hidden}.playground-container .middle-dialog-area .clear-button-container{z-index:10;position:absolute;top:8px;right:12px}.playground-container .middle-dialog-area .clear-button-container .clear-button{opacity:.7;transition:opacity .2s}.playground-container .middle-dialog-area .clear-button-container .clear-button:hover{opacity:1}.playground-container .middle-dialog-area .info-list-container{scrollbar-width:none;flex:1;padding-top:16px;padding-bottom:16px;overflow:hidden auto}.playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item{border-bottom:none;padding:0}.playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item .ant-card{border:1px solid #f0f0f0;border-radius:8px;box-shadow:0 1px 3px #0000001a}.playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item .ant-card:hover{box-shadow:0 2px 6px #00000026}.playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item .ant-card .ant-card-body{padding:12px}.playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-empty-text{color:#999;font-style:italic}.playground-container .middle-dialog-area .info-list-container::-webkit-scrollbar{display:none}.playground-container .middle-dialog-area .info-list-container .list-item{background:0 0;border:none;padding:0}.playground-container .middle-dialog-area .scroll-to-bottom-button{z-index:10;background:#fff;position:absolute;bottom:10px;right:0;box-shadow:0 4px 8px #0000000a}.playground-container .middle-dialog-area .scroll-to-bottom-button:hover{background:#1890ff}.playground-container .middle-dialog-area .scroll-to-bottom-button:hover .anticon{color:#fff}.playground-container .middle-dialog-area .scroll-to-bottom-button .anticon{color:#333;font-size:16px}.playground-container .user-message-container{justify-content:flex-end;width:100%;margin:20px 0 30px;display:flex}.playground-container .user-message-container .user-message-bubble{color:#000000d9;text-align:center;background:#f2f4f7;border-radius:12px;max-width:80%;padding:12px 16px;font-size:14px;font-weight:400;display:inline-block}.playground-container .progress-action-item{color:#000;background:#f2f4f7;border-radius:8px;justify-content:space-between;height:36px;margin:4px 0;padding:0 12px;font-size:14px;line-height:36px;display:flex}.playground-container .progress-action-item .progress-status-icon{margin-left:4px}.playground-container .progress-action-item .progress-status-icon.loading{color:#1890ff}.playground-container .progress-action-item .progress-status-icon.completed{color:#52c41a}.playground-container .progress-action-item .progress-status-icon.error{color:#ff4d4f;font-weight:700}.playground-container .progress-description{color:#000;padding:8px 0;font-size:14px;line-height:22px;display:inline-block}.playground-container .system-message-container{flex-direction:column;display:flex}.playground-container .system-message-container .system-message-header{align-items:center;gap:8px;margin:12px 0;display:flex}.playground-container .system-message-container .system-message-header .system-message-title{font-size:12px;font-weight:400;line-height:100%}.playground-container .system-message-container .system-message-content{color:#000000d9;font-size:14px}.playground-container .system-message-container .system-message-content .system-message-text{color:#000000d9;font-size:14px;line-height:25px}.playground-container .system-message-container .system-message-content .error-message{color:#e51723;word-break:break-word;background-color:#fff;border:none;border-radius:0;align-items:flex-start;margin-bottom:16px;padding:0;font-size:14px;display:flex}.playground-container .system-message-container .system-message-content .error-message .divider{background-color:#e6e8eb;flex-shrink:0;align-self:stretch;width:1px;min-height:20px;margin:0 8px 0 0}.playground-container .system-message-container .system-message-content .loading-progress-text{color:#666;background:#f6f8fa;border-left:3px solid #1890ff;border-radius:4px;margin-top:8px;padding:8px 12px;font-size:13px}.playground-container .new-conversation-separator{flex-shrink:0;justify-content:center;align-items:center;padding:20px 0;display:flex;position:relative}.playground-container .new-conversation-separator .separator-line{background-color:#e8e8e8;height:1px;position:absolute;top:50%;left:0;right:0}.playground-container .new-conversation-separator .separator-text-container{z-index:1;background-color:#fff;padding:0 16px;position:relative}.playground-container .new-conversation-separator .separator-text-container .separator-text{color:#999;background-color:#fff;font-size:12px}.playground-container .bottom-input-section{background-color:#fff;flex-shrink:0;padding:16px 0 0}.playground-container .version-info-section{flex-shrink:0;justify-content:center;align-items:center;height:38px;display:flex}.playground-container .version-text{color:#999;text-align:center;font-size:12px}.playground-container .hidden-result-ref{display:none}.playground-container .playground-description{margin-bottom:32px}.playground-container .playground-description .description-zh{color:#333;margin:0 0 8px;font-size:16px;line-height:1.5}.playground-container .playground-description .description-en{color:#666;margin:0;font-size:14px;line-height:1.5}.playground-container .config-section{margin-bottom:24px}.playground-container .config-section .config-title{color:#333;margin:0 0 16px;font-size:18px;font-weight:600}.playground-container .config-section .config-item{align-items:center;gap:8px;margin-bottom:12px;display:flex}.playground-container .config-section .config-item .config-check{color:#52c41a;font-size:16px}.playground-container .config-section .config-item .config-label{color:#333;font-size:14px}.playground-container .config-section .config-link{color:#1890ff;font-size:14px;text-decoration:none}.playground-container .config-section .config-link:hover{text-decoration:underline}.prompt-input-wrapper{width:100%}.prompt-input-wrapper .mode-radio-group-wrapper{justify-content:space-between;align-items:center;display:flex}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group{align-items:center;height:100%;display:flex}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper{height:24px;box-shadow:none;background-color:#f7f7f7;border:none;border-radius:11px;margin-right:8px;padding:0 8px;font-size:12px;line-height:24px}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper:before{display:none}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper:focus-within{outline:none}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper.ant-radio-button-wrapper-checked{color:#fff;background-color:#2b83ff;border-color:#2b83ff}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper.ant-radio-button-wrapper-checked:hover{color:#fff}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button{height:24px;box-shadow:none;background-color:#f7f7f7;border:none;border-radius:11px;align-items:center;gap:2px;max-width:160px;padding:0 8px;font-size:12px;display:inline-flex}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button .ant-btn-content{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button:hover{background-color:#e6e6e6}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button.selected-from-dropdown{color:#fff;background-color:#2b83ff;font-weight:500}.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button.selected-from-dropdown:hover{background-color:#2b83ff}.prompt-input-wrapper .mode-radio-group-wrapper .action-icons{align-items:center;display:flex}.prompt-input-wrapper .main-side-console-input{margin-top:10px;position:relative}.prompt-input-wrapper .main-side-console-input .main-side-console-input-textarea{white-space:pre-wrap;scrollbar-width:thin;background:#fff;border:1px solid #f2f4f7;border-radius:12px;padding:12px 16px;line-height:21px;transition:background-color .2s;overflow-y:auto}@keyframes hue-shift{0%{filter:hue-rotate()}to{filter:hue-rotate(360deg)}}.prompt-input-wrapper .main-side-console-input .main-side-console-input-textarea:focus-within{background:linear-gradient(#fff,#fff) padding-box padding-box,linear-gradient(135deg,#4285f4 0%,#06f 25%,#7b02c5 50%,#ea4335 75%,#ff7043 100%) border-box;border:1px solid #0000}.prompt-input-wrapper .main-side-console-input .main-side-console-input-textarea::-webkit-scrollbar{width:6px}.prompt-input-wrapper .main-side-console-input .main-side-console-input-textarea::-webkit-scrollbar-thumb{background-color:#0003;border-radius:3px}.prompt-input-wrapper .main-side-console-input.loading .main-side-console-input-textarea{background:linear-gradient(#fff,#fff) padding-box padding-box,linear-gradient(135deg,#4285f4 0%,#06f 25%,#7b02c5 50%,#ea4335 75%,#ff7043 100%) border-box;border:1px solid #0000;animation:5s linear infinite hue-shift}.prompt-input-wrapper .main-side-console-input .ant-form-item-control-input-content{z-index:999;border:3px solid #0000;border-radius:14px}.prompt-input-wrapper .main-side-console-input:focus-within .ant-form-item-control-input-content{border-color:#2b83ff29}.prompt-input-wrapper .main-side-console-input.disabled .form-controller-wrapper{background-color:#0000}.prompt-input-wrapper .ant-form-item-with-help+.form-controller-wrapper{bottom:22px}.prompt-input-wrapper .ant-input{padding-bottom:40px}.prompt-input-wrapper .form-controller-wrapper{box-sizing:border-box;background-color:#fff;flex-direction:row;justify-content:flex-end;align-items:flex-end;gap:8px;width:calc(100% - 32px);padding:12px 0;line-height:32px;transition:background-color .2s;display:flex;position:absolute;bottom:1px;left:16px}.prompt-input-wrapper .settings-wrapper{color:#777;flex-flow:wrap;gap:2px;display:flex}.prompt-input-wrapper .settings-wrapper.settings-wrapper-hover{color:#3b3b3b}.prompt-input-wrapper .structured-params-container{background:linear-gradient(#fff,#fff) padding-box padding-box,linear-gradient(135deg,#4285f4 0%,#06f 25%,#7b02c5 50%,#ea4335 75%,#ff7043 100%) border-box;border:1px solid #0000;border-radius:12px;padding:16px 16px 56px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item{flex-direction:column;display:flex}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label{text-align:left;flex-basis:auto;padding-bottom:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label{color:#000000d9;height:auto;font-size:12px;font-weight:500;line-height:1.5}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:after{color:#ff4d4f;font-family:SimSun,sans-serif;font-size:12px;line-height:1;display:inline-block}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{margin-left:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{margin-left:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{margin-left:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:not(:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{margin-left:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{margin-left:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{margin-right:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:-moz-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{margin-right:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label>label:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{margin-right:4px}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-control{flex:1;margin-top:0}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-row{flex-direction:column}.prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-control-input{min-height:auto}.prompt-input-wrapper .structured-params-container .structured-params .ant-input,.prompt-input-wrapper .structured-params-container .structured-params .ant-input-number,.prompt-input-wrapper .structured-params-container .structured-params .ant-select{border:1px solid #e1e5e9;border-radius:6px;width:100%}.prompt-input-wrapper .structured-params-container .structured-params .ant-input:hover,.prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:hover,.prompt-input-wrapper .structured-params-container .structured-params .ant-select:hover{border-color:#40a9ff}.prompt-input-wrapper .structured-params-container .structured-params .ant-input:focus,.prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:focus,.prompt-input-wrapper .structured-params-container .structured-params .ant-select:focus,.prompt-input-wrapper .structured-params-container .structured-params .ant-input:focus-within,.prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:focus-within,.prompt-input-wrapper .structured-params-container .structured-params .ant-select:focus-within{border-color:#40a9ff;box-shadow:0 0 0 2px #1890ff33}.prompt-input-wrapper .structured-params-container .structured-params textarea.ant-input{padding-bottom:5px}.prompt-input-wrapper .structured-params-container .structured-params .ant-input-number .ant-input-number-input{box-shadow:none;border:none}.prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:hover .ant-input-number-input{box-shadow:none}.prompt-input-wrapper .structured-params-container .structured-params .ant-select{min-width:120px}.prompt-input-wrapper .structured-params-container .structured-params .ant-select .ant-select-selector{box-shadow:none;border:none}.prompt-input-wrapper .structured-params-container .structured-params .ant-select:hover .ant-select-selector,.prompt-input-wrapper .structured-params-container .structured-params .ant-select.ant-select-focused .ant-select-selector{box-shadow:none}.prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group{width:100%}.prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group .ant-radio-button-wrapper{border:1px solid #e1e5e9;border-radius:6px;height:32px;margin-right:4px;font-size:12px;line-height:30px}.prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group .ant-radio-button-wrapper.ant-radio-button-wrapper-checked{color:#fff;background-color:#2b83ff;border-color:#2b83ff}.selector-trigger{cursor:pointer;width:24px;height:24px;transition:all .2s}.selector-trigger .action-icon{color:#000000d9;font-size:14px;transition:all .2s}.selector-trigger .action-icon:hover{color:#2b83ff}.history-modal-container{border-radius:12px 12px 0 0;flex-direction:column;height:70vh;display:flex;overflow:hidden}.history-modal-container .history-modal-header{justify-content:space-between;align-items:center;height:48px;padding:0 25px;line-height:48px;display:flex}.history-modal-container .history-modal-header .close-button{justify-content:center;align-items:center;margin-right:-4px;padding:4px;display:flex}.history-modal-container .history-modal-header .close-button .anticon{color:#999;font-size:18px}.history-modal-container .history-modal-header .close-button:hover .anticon{color:#666}.history-modal-container .history-search-section{background:#fff;padding:16px 20px}.history-modal-container .history-search-section .search-input-wrapper{color:#00000040;align-items:center;gap:12px;display:flex}.history-modal-container .history-search-section .search-input-wrapper .search-input{background:#f1f2f3;border:none;border-radius:16px;flex:1;height:36px}.history-modal-container .history-search-section .search-input-wrapper .search-input .ant-input{box-shadow:none;background:0 0;border:none}.history-modal-container .history-search-section .search-input-wrapper .search-input:hover,.history-modal-container .history-search-section .search-input-wrapper .search-input:focus-within{background:#fff;border-color:#d9d9d9}.history-modal-container .history-search-section .search-input-wrapper .clear-button{color:#1890ff;height:auto;padding:0}.history-modal-container .history-search-section .search-input-wrapper .clear-button:hover{color:#40a9ff}.history-modal-container .history-content{flex:1;padding:0 25px 25px;overflow-y:auto}.history-modal-container .history-content .history-group{margin-bottom:10px}.history-modal-container .history-content .history-group .history-group-title{color:#00000073;height:40px;font-size:12px;font-weight:400;line-height:40px}.history-modal-container .history-content .history-group .history-item{cursor:pointer;color:#000000d9;white-space:nowrap;text-overflow:ellipsis;height:40px;font-size:14px;line-height:40px;overflow:hidden}.history-modal-container .history-content .history-group .history-item:hover{background:#f2f4f7;margin:0 -8px;padding:0 8px}.history-modal-container .history-content .no-results{text-align:center;color:#999;padding:40px 20px}.ant-modal-wrap .ant-modal-content{animation:.3s cubic-bezier(.4,0,.2,1) forwards slideUpFromBottom!important}@keyframes slideUpFromBottom{0%{opacity:0;transform:translateY(100%)}to{opacity:1;transform:translateY(0)}}
2
+ /*# sourceMappingURL=index.ac4cc11d.css.map*/