@midscene/core 1.0.1-beta-20251209024153.0 → 1.0.1-beta-20251211095502.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.
@@ -5,6 +5,10 @@ import type { TaskRunner } from '../task-runner';
5
5
  import { ModelConfigManager } from '@midscene/shared/env';
6
6
  import { TaskCache } from './task-cache';
7
7
  import { TaskExecutor } from './tasks';
8
+ type AiActOptions = {
9
+ cacheable?: boolean;
10
+ planningStrategy?: 'fast' | 'standard' | 'max';
11
+ };
8
12
  export declare class Agent<InterfaceType extends AbstractInterface = AbstractInterface> {
9
13
  interface: InterfaceType;
10
14
  service: Service;
@@ -19,7 +23,9 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
19
23
  dryMode: boolean;
20
24
  onTaskStartTip?: OnTaskStartTip;
21
25
  taskCache?: TaskCache;
22
- onDumpUpdate?: (dump: string) => void;
26
+ private dumpUpdateListeners;
27
+ get onDumpUpdate(): ((dump: string, executionDump?: ExecutionDump) => void) | undefined;
28
+ set onDumpUpdate(callback: ((dump: string, executionDump?: ExecutionDump) => void) | undefined);
23
29
  destroyed: boolean;
24
30
  modelConfigManager: ModelConfigManager;
25
31
  /**
@@ -53,7 +59,11 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
53
59
  getActionSpace(): Promise<DeviceAction[]>;
54
60
  getUIContext(action?: ServiceAction): Promise<UIContext>;
55
61
  _snapshotContext(): Promise<UIContext>;
62
+ /**
63
+ * @deprecated Use {@link setAIActContext} instead.
64
+ */
56
65
  setAIActionContext(prompt: string): Promise<void>;
66
+ setAIActContext(prompt: string): Promise<void>;
57
67
  resetDump(): GroupedActionDump;
58
68
  appendExecutionDump(execution: ExecutionDump, runner?: TaskRunner): void;
59
69
  dumpDataString(): string;
@@ -93,10 +103,7 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
93
103
  * @deprecated Use aiScroll(locatePrompt, opt) instead where opt contains the scroll parameters
94
104
  */
95
105
  aiScroll(scrollParam: ScrollParam, locatePrompt?: TUserPrompt, opt?: LocateOption): Promise<any>;
96
- aiAct(taskPrompt: string, opt?: {
97
- cacheable?: boolean;
98
- planningStrategy?: 'fast' | 'standard' | 'max';
99
- }): Promise<{
106
+ aiAct(taskPrompt: string, opt?: AiActOptions): Promise<{
100
107
  result: Record<string, any>;
101
108
  } | {
102
109
  yamlFlow?: import("../yaml").MidsceneYamlFlowItem[];
@@ -104,9 +111,7 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
104
111
  /**
105
112
  * @deprecated Use {@link Agent.aiAct} instead.
106
113
  */
107
- aiAction(taskPrompt: string, opt?: {
108
- cacheable?: boolean;
109
- }): Promise<{
114
+ aiAction(taskPrompt: string, opt?: AiActOptions): Promise<{
110
115
  result: Record<string, any>;
111
116
  } | {
112
117
  yamlFlow?: import("../yaml").MidsceneYamlFlowItem[];
@@ -140,6 +145,21 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
140
145
  result: Record<string, any>;
141
146
  }>;
142
147
  evaluateJavaScript(script: string): Promise<any>;
148
+ /**
149
+ * Add a dump update listener
150
+ * @param listener Listener function
151
+ * @returns A remove function that can be called to remove this listener
152
+ */
153
+ addDumpUpdateListener(listener: (dump: string, executionDump?: ExecutionDump) => void): () => void;
154
+ /**
155
+ * Remove a dump update listener
156
+ * @param listener The listener function to remove
157
+ */
158
+ removeDumpUpdateListener(listener: (dump: string, executionDump?: ExecutionDump) => void): void;
159
+ /**
160
+ * Clear all dump update listeners
161
+ */
162
+ clearDumpUpdateListeners(): void;
143
163
  destroy(): Promise<void>;
144
164
  recordToReport(title?: string, opt?: {
145
165
  content: string;
@@ -178,3 +198,4 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
178
198
  }): Promise<void>;
179
199
  }
180
200
  export declare const createAgent: (interfaceInstance: AbstractInterface, opts?: AgentOpt) => Agent<AbstractInterface>;
201
+ export {};
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": "1.0.1-beta-20251209024153.0",
4
+ "version": "1.0.1-beta-20251211095502.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "main": "./dist/lib/index.js",
@@ -89,7 +89,7 @@
89
89
  "semver": "7.5.2",
90
90
  "js-yaml": "4.1.0",
91
91
  "zod": "3.24.3",
92
- "@midscene/shared": "1.0.1-beta-20251209024153.0"
92
+ "@midscene/shared": "1.0.1-beta-20251211095502.0"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@rslib/core": "^0.18.3",