@midscene/playground 1.9.8 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/es/index.mjs +3 -2
  2. package/dist/es/launcher.mjs +4 -3
  3. package/dist/es/launcher.mjs.map +1 -1
  4. package/dist/es/recorder-ai-service.mjs +2 -0
  5. package/dist/es/recorder-ui-describer-prompt.mjs +56 -0
  6. package/dist/es/recorder-ui-describer-prompt.mjs.map +1 -0
  7. package/dist/es/recorder-ui-describer.mjs +392 -0
  8. package/dist/es/recorder-ui-describer.mjs.map +1 -0
  9. package/dist/es/server.mjs +32 -8
  10. package/dist/es/server.mjs.map +1 -1
  11. package/dist/lib/index.js +19 -6
  12. package/dist/lib/launcher.js +3 -2
  13. package/dist/lib/launcher.js.map +1 -1
  14. package/dist/lib/recorder-ai-service.js +38 -0
  15. package/dist/lib/recorder-ai-service.js.map +1 -0
  16. package/dist/lib/recorder-ui-describer-prompt.js +90 -0
  17. package/dist/lib/recorder-ui-describer-prompt.js.map +1 -0
  18. package/dist/lib/recorder-ui-describer.js +432 -0
  19. package/dist/lib/recorder-ui-describer.js.map +1 -0
  20. package/dist/lib/server.js +40 -7
  21. package/dist/lib/server.js.map +1 -1
  22. package/dist/types/index.d.ts +2 -1
  23. package/dist/types/recorder-ai-service.d.ts +1 -0
  24. package/dist/types/recorder-ui-describer-prompt.d.ts +1 -0
  25. package/dist/types/recorder-ui-describer.d.ts +20 -0
  26. package/dist/types/server.d.ts +4 -0
  27. package/package.json +9 -3
  28. package/static/index.html +1 -1
  29. package/static/static/js/index.9c67d55f.js +951 -0
  30. package/static/static/js/index.9c67d55f.js.map +1 -0
  31. package/static/static/js/index.44b83907.js +0 -948
  32. package/static/static/js/index.44b83907.js.map +0 -1
  33. /package/static/static/js/{index.44b83907.js.LICENSE.txt → index.9c67d55f.js.LICENSE.txt} +0 -0
@@ -1,5 +1,6 @@
1
1
  export { dataExtractionAPIs, noReplayAPIs, validationAPIs, formatErrorMessage, validateStructuredParams, executeAction, } from './common';
2
- export { PlaygroundServer } from './server';
2
+ export { buildPlaygroundBrowserUrl, PlaygroundServer } from './server';
3
+ export { describeRecorderUIEvent, describeRecorderUIEvents, getRecorderUIEventTargetRect, type DescribeRecorderUIEventInput, type DescribeRecorderUIEventOptions, type DescribeRecorderUIEventResult, } from './recorder-ui-describer';
3
4
  export { playgroundForAgent } from './launcher';
4
5
  export { playgroundForAgentFactory } from './launcher';
5
6
  export { playgroundForSessionManager } from './launcher';
@@ -0,0 +1 @@
1
+ export { callAIWithObjectResponse } from '@midscene/core/ai-model';
@@ -0,0 +1 @@
1
+ export declare const RECORDER_UI_DESCRIBER_SYSTEM_PROMPT = "You convert Studio preview recorder UI events into semantic replay instructions.\n\nThe recorder works from screenshots and mapped real-device coordinates only. Infer stable UI intent from the highlighted BEFORE screenshot. The AFTER screenshot is contextual evidence for state changes and scroll destinations.\n\nOutput JSON only:\n{\n \"elementDescription\": \"short stable target/region description\",\n \"replayInstruction\": \"one executable natural-language replay step\",\n \"actionSummary\": \"short timeline summary\",\n \"scrollDestinationDescription\": \"for scroll only: concrete newly visible destination content or goal\",\n \"confidence\": \"high\" | \"medium\" | \"low\",\n \"error\"?: \"only if no useful visual description can be inferred\"\n}\n\nRules:\n- Do NOT output coordinates as the main description.\n- Do NOT mention \"near coordinates\", \"nearby element\", \"near point\", \"red marker\", highlighted box, highlighted element, or screenshot.\n- Prefer stable target descriptions in this order: exact stable control text > stable label > role + stable section/context > icon purpose > visual position.\n- Treat placeholder or hint text that can change by user, time, data, or context as dynamic. Do not use dynamic hint values as the primary target description; prefer role + stable region + intent.\n- For repeated collections, treat item identity text as dynamic unless the user is clearly verifying that exact item. This includes any list/grid/table/feed/menu or repeated record surface. Do not output descriptions like \"<role> titled/named '<content>'\"; prefer stable role + region + selection intent.\n- Keep quoted UI text in the original UI language when it is a stable control label.\n- Apply the platform guidance from the user event:\n - Web: button, input, link, menu item, tab, dialog, aria-label, placeholder, form section.\n - Mobile: tab, list item, text field, icon button, navigation bar, bottom bar, sheet, card, screen section.\n - Desktop/computer: menu item, toolbar button, dialog field, sidebar item, window control, file row, application region.\n- Pointer action rules:\n - Preserve event.actionType semantics. Tap, DoubleClick, LongPress, and RightClick must not all become Click.\n - Tap replayInstruction format: Tap on the element described as \"<elementDescription>\".\n - DoubleClick replayInstruction format: Double click on the element described as \"<elementDescription>\".\n - LongPress replayInstruction format: Long press the element described as \"<elementDescription>\".\n - RightClick replayInstruction format: Right click on the element described as \"<elementDescription>\".\n - Click replayInstruction format: Click on the element described as \"<elementDescription>\".\n- Input-specific rules:\n - The highlighted BEFORE screenshot marks the field that receives the text.\n - The screenshot after the action may show the typed value; use it only to confirm the field, never as the field description.\n - elementDescription must identify the field itself by stable field role, nearby label, region, section, or sequence intent.\n - Never use \"AI is analyzing element\", the typed value, the page title alone, or a generic \"input field\" as elementDescription.\n - For consecutive input events, distinguish fields by stable role, section, order, current focus, filled/empty state, and neighboring actions instead of reusing the same generic field description.\n - Input replayInstruction format: Input \"<value>\" into the element described as \"<elementDescription>\".\n- Scroll target quality bar:\n - elementDescription describes the scrollable page, panel, list, table, or section at the highlighted scroll point.\n - When multiple scrollable regions are visible, preserve the specific region where the scroll happened, such as left/right/top/bottom panel, navigation area, content pane, dialog body, table, list, or menu. Do not generalize a panel/list scroll into the whole page.\n - scrollDestinationDescription is required and describes what the scroll is trying to reveal or reach, using newly visible headings, section titles, list items, or stable content from the AFTER screenshot.\n - Prefer descriptions like \"Playwright integration documentation page, scrolling toward the API reference section\" or \"Android API documentation page, scrolling to the installation steps section\".\n - Do NOT write generic phrases like \"more content\", \"the page\", \"current screen\", or \"main scrollable area\".\n- Scroll replayInstruction format: Scroll the page/region with description \"<elementDescription>\" by value \"<recorded value>\" until \"<scrollDestinationDescription>\" is visible.\n- Scroll actionSummary format: Scroll <elementDescription> toward <scrollDestinationDescription>.\n- Drag/Swipe rules:\n - Drag replayInstruction format: Drag through the area described as \"<elementDescription>\".\n - Swipe replayInstruction format: Swipe through the area described as \"<elementDescription>\".\n - Describe start/end regions or the dragged UI control; do not describe only the gesture path.\n- KeyboardPress replayInstruction format: Press \"<value>\" on the element described as \"<elementDescription>\".\n- If uncertain, provide the best concrete visible text/role/context description. Set confidence to \"low\"; do not fall back to coordinates.";
@@ -0,0 +1,20 @@
1
+ import type { Rect } from '@midscene/core';
2
+ import { type IModelConfig } from '@midscene/shared/env';
3
+ import type { MidsceneRecorderEvent, MidsceneRecorderTarget } from '@midscene/shared/recorder';
4
+ export interface DescribeRecorderUIEventInput {
5
+ event: MidsceneRecorderEvent;
6
+ target?: MidsceneRecorderTarget;
7
+ }
8
+ export interface DescribeRecorderUIEventOptions {
9
+ maxRetries?: number;
10
+ retryDelayMs?: number;
11
+ concurrency?: number;
12
+ }
13
+ export interface DescribeRecorderUIEventResult {
14
+ event: MidsceneRecorderEvent;
15
+ usedFallback: boolean;
16
+ error?: string;
17
+ }
18
+ export declare function getRecorderUIEventTargetRect(event: MidsceneRecorderEvent): Rect | null;
19
+ export declare function describeRecorderUIEvent(input: DescribeRecorderUIEventInput, modelConfig: IModelConfig | Record<string, unknown>, options?: DescribeRecorderUIEventOptions): Promise<DescribeRecorderUIEventResult>;
20
+ export declare function describeRecorderUIEvents(inputs: DescribeRecorderUIEventInput[], modelConfig: IModelConfig | Record<string, unknown>, options?: DescribeRecorderUIEventOptions): Promise<DescribeRecorderUIEventResult[]>;
@@ -5,6 +5,10 @@ import express from 'express';
5
5
  import type { PlaygroundPreviewDescriptor, PlaygroundSessionState, PreparedPlaygroundPlatform } from './platform';
6
6
  import { type PlaygroundRuntimeInfo } from './runtime-metadata';
7
7
  import 'dotenv/config';
8
+ /** Default `0.0.0.0`. Override via `MIDSCENE_PLAYGROUND_HOST` (e.g. `127.0.0.1`). */
9
+ export declare function resolvePlaygroundListenHost(): string;
10
+ export declare function resolvePlaygroundBrowserHost(): string;
11
+ export declare function buildPlaygroundBrowserUrl(host: string, port: number): string;
8
12
  /**
9
13
  * Recursively serialize a Zod field into a plain object that preserves
10
14
  * the `_def` metadata the client relies on (typeName, innerType, values,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/playground",
3
- "version": "1.9.8",
3
+ "version": "1.10.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/midscene.git",
@@ -20,6 +20,12 @@
20
20
  "require": "./dist/lib/index.js",
21
21
  "import": "./dist/es/index.mjs",
22
22
  "default": "./dist/es/index.mjs"
23
+ },
24
+ "./recorder-ui-describer": {
25
+ "types": "./dist/types/recorder-ui-describer.d.ts",
26
+ "require": "./dist/lib/recorder-ui-describer.js",
27
+ "import": "./dist/es/recorder-ui-describer.mjs",
28
+ "default": "./dist/es/recorder-ui-describer.mjs"
23
29
  }
24
30
  },
25
31
  "files": [
@@ -32,8 +38,8 @@
32
38
  "express": "^4.21.2",
33
39
  "open": "10.1.0",
34
40
  "uuid": "11.1.0",
35
- "@midscene/core": "1.9.8",
36
- "@midscene/shared": "1.9.8"
41
+ "@midscene/core": "1.10.0",
42
+ "@midscene/shared": "1.10.0"
37
43
  },
38
44
  "devDependencies": {
39
45
  "@rslib/core": "^0.18.3",
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.7b1abe58.js"></script><script defer src="/static/js/905.8d12588e.js"></script><script defer src="/static/js/index.44b83907.js"></script><link href="/static/css/index.1293237f.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.7b1abe58.js"></script><script defer src="/static/js/905.8d12588e.js"></script><script defer src="/static/js/index.9c67d55f.js"></script><link href="/static/css/index.1293237f.css" rel="stylesheet"></head><body><div id="root"></div></body></html>