@midscene/core 0.30.2-beta-20251003133504.0 → 0.30.2-beta-20251009120232.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.
@@ -29,11 +29,23 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
29
29
  * Flag to track if VL model warning has been shown
30
30
  */
31
31
  private hasWarnedNonVLModel;
32
+ /**
33
+ * Screenshot scale factor derived from actual screenshot dimensions
34
+ */
35
+ private screenshotScale?;
36
+ /**
37
+ * Internal promise to deduplicate screenshot scale computation
38
+ */
39
+ private screenshotScalePromise?;
32
40
  get page(): InterfaceType;
33
41
  /**
34
42
  * Ensures VL model warning is shown once when needed
35
43
  */
36
44
  private ensureVLModelWarning;
45
+ /**
46
+ * Lazily compute the ratio between the physical screenshot width and the logical page width
47
+ */
48
+ private getScreenshotScale;
37
49
  constructor(interfaceInstance: InterfaceType, opts?: AgentOpt);
38
50
  getActionSpace(): Promise<DeviceAction[]>;
39
51
  getUIContext(action?: InsightAction): Promise<UIContext>;
@@ -93,7 +105,7 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
93
105
  } & LocatorValidatorOption): Promise<AgentDescribeElementAtPointResult>;
94
106
  verifyLocator(prompt: string, locateOpt: LocateOption | undefined, expectCenter: [number, number], verifyLocateOption?: LocatorValidatorOption): Promise<LocateValidatorResult>;
95
107
  aiLocate(prompt: TUserPrompt, opt?: LocateOption): Promise<Pick<LocateResultElement, "center" | "rect"> & {
96
- scale: number;
108
+ dpr?: number;
97
109
  }>;
98
110
  aiAssert(assertion: TUserPrompt, msg?: string, opt?: AgentAssertOpt & InsightExtractOption): Promise<{
99
111
  pass: boolean;
@@ -130,7 +142,7 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
130
142
  private processCacheConfig;
131
143
  /**
132
144
  * Manually flush cache to file
133
- * Only meaningful in read-only mode, other modes will throw error
145
+ * Only supported in read-only mode where writes are deferred by default
134
146
  */
135
147
  flushCache(): Promise<void>;
136
148
  }
@@ -30,8 +30,12 @@ export declare class TaskCache {
30
30
  isCacheResultUsed: boolean;
31
31
  cacheOriginalLength: number;
32
32
  readOnlyMode: boolean;
33
+ writeOnlyMode: boolean;
33
34
  private matchedCacheIndices;
34
- constructor(cacheId: string, isCacheResultUsed: boolean, cacheFilePath?: string, readOnlyMode?: boolean);
35
+ constructor(cacheId: string, isCacheResultUsed: boolean, cacheFilePath?: string, options?: {
36
+ readOnly?: boolean;
37
+ writeOnly?: boolean;
38
+ });
35
39
  matchCache(prompt: TUserPrompt, type: 'plan' | 'locate'): MatchCacheResult<PlanningCache | LocateCache> | undefined;
36
40
  matchPlanCache(prompt: string): MatchCacheResult<PlanningCache> | undefined;
37
41
  matchLocateCache(prompt: TUserPrompt): MatchCacheResult<LocateCache> | undefined;
@@ -23,7 +23,7 @@ export declare class TaskExecutor {
23
23
  });
24
24
  private recordScreenshot;
25
25
  private prependExecutorWithScreenshot;
26
- convertPlanToExecutable(plans: PlanningAction[], modelConfig: IModelConfig): Promise<{
26
+ convertPlanToExecutable(plans: PlanningAction[], modelConfig: IModelConfig, cacheable?: boolean): Promise<{
27
27
  tasks: ExecutionTaskApply<any, any, any, any>[];
28
28
  }>;
29
29
  private setupPlanningContext;
@@ -33,7 +33,7 @@ export declare class TaskExecutor {
33
33
  private createPlanningTask;
34
34
  runPlans(title: string, plans: PlanningAction[], modelConfig: IModelConfig): Promise<ExecutionResult>;
35
35
  private getReplanningCycleLimit;
36
- action(userPrompt: string, modelConfig: IModelConfig, actionContext?: string): Promise<ExecutionResult<{
36
+ action(userPrompt: string, modelConfig: IModelConfig, actionContext?: string, cacheable?: boolean): Promise<ExecutionResult<{
37
37
  yamlFlow?: MidsceneYamlFlowItem[];
38
38
  } | undefined>>;
39
39
  private createTypeQueryTask;
@@ -382,7 +382,7 @@ export type WebUIContext = UIContext<WebElementInfo>;
382
382
  * Agent
383
383
  */
384
384
  export type CacheConfig = {
385
- strategy?: 'read-only' | 'read-write';
385
+ strategy?: 'read-only' | 'read-write' | 'write-only';
386
386
  id: string;
387
387
  };
388
388
  export type Cache = false | true | CacheConfig;
@@ -168,4 +168,12 @@ export interface MidsceneYamlConfigResult {
168
168
  report?: string | null;
169
169
  error?: string;
170
170
  duration?: number;
171
+ /**
172
+ * Type of result:
173
+ * - 'success': All tasks completed successfully
174
+ * - 'failed': Execution failed (player error)
175
+ * - 'partialFailed': Some tasks failed but execution continued (continueOnError)
176
+ * - 'notExecuted': Not executed due to previous failures
177
+ */
178
+ resultType?: 'success' | 'failed' | 'partialFailed' | 'notExecuted';
171
179
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/core",
3
3
  "description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
4
- "version": "0.30.2-beta-20251003133504.0",
4
+ "version": "0.30.2-beta-20251009120232.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "main": "./dist/lib/index.js",
@@ -87,8 +87,8 @@
87
87
  "zod": "3.24.3",
88
88
  "semver": "7.5.2",
89
89
  "js-yaml": "4.1.0",
90
- "@midscene/recorder": "0.30.2-beta-20251003133504.0",
91
- "@midscene/shared": "0.30.2-beta-20251003133504.0"
90
+ "@midscene/recorder": "0.30.2-beta-20251009120232.0",
91
+ "@midscene/shared": "0.30.2-beta-20251009120232.0"
92
92
  },
93
93
  "devDependencies": {
94
94
  "@rslib/core": "^0.11.2",