@midscene/core 1.0.1-beta-20251103074550.0 → 1.0.1-beta-20251104075048.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.
- package/dist/es/agent/agent.mjs +67 -43
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/execution-session.mjs.map +1 -1
- package/dist/es/agent/task-builder.mjs +4 -4
- package/dist/es/agent/task-builder.mjs.map +1 -1
- package/dist/es/agent/tasks.mjs +27 -27
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/ui-utils.mjs +5 -6
- package/dist/es/agent/ui-utils.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/service/index.mjs +1 -1
- package/dist/es/service/index.mjs.map +1 -1
- package/dist/es/task-runner.mjs +42 -7
- package/dist/es/task-runner.mjs.map +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +2 -2
- package/dist/lib/agent/agent.js +66 -42
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/execution-session.js.map +1 -1
- package/dist/lib/agent/task-builder.js +4 -4
- package/dist/lib/agent/task-builder.js.map +1 -1
- package/dist/lib/agent/tasks.js +29 -26
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/ui-utils.js +5 -6
- package/dist/lib/agent/ui-utils.js.map +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/service/index.js +1 -1
- package/dist/lib/service/index.js.map +1 -1
- package/dist/lib/task-runner.js +44 -6
- package/dist/lib/task-runner.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/types/agent/agent.d.ts +4 -2
- package/dist/types/agent/execution-session.d.ts +7 -4
- package/dist/types/agent/tasks.d.ts +7 -0
- package/dist/types/task-runner.d.ts +15 -3
- package/dist/types/types.d.ts +9 -2
- package/dist/types/yaml.d.ts +0 -1
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ActionParam, type ActionReturn, type AgentAssertOpt, type AgentDescribeElementAtPointResult, type AgentOpt, type AgentWaitForOpt, type DeviceAction, type ExecutionDump, type GroupedActionDump, type LocateOption, type LocateResultElement, type LocateValidatorResult, type LocatorValidatorOption, type OnTaskStartTip, type ScrollParam, Service, type ServiceAction, type ServiceExtractOption, type ServiceExtractParam, type TUserPrompt, type UIContext } from '../index';
|
|
2
2
|
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
|
|
3
3
|
import type { AbstractInterface } from '../device';
|
|
4
|
+
import type { TaskRunner } from '../task-runner';
|
|
4
5
|
import { ModelConfigManager } from '@midscene/shared/env';
|
|
5
6
|
import { TaskCache } from './task-cache';
|
|
6
7
|
import { TaskExecutor } from './tasks';
|
|
@@ -37,6 +38,7 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
|
|
|
37
38
|
* Internal promise to deduplicate screenshot scale computation
|
|
38
39
|
*/
|
|
39
40
|
private screenshotScalePromise?;
|
|
41
|
+
private executionDumpIndexByRunner;
|
|
40
42
|
get page(): InterfaceType;
|
|
41
43
|
/**
|
|
42
44
|
* Ensures VL model warning is shown once when needed
|
|
@@ -52,12 +54,12 @@ export declare class Agent<InterfaceType extends AbstractInterface = AbstractInt
|
|
|
52
54
|
_snapshotContext(): Promise<UIContext>;
|
|
53
55
|
setAIActionContext(prompt: string): Promise<void>;
|
|
54
56
|
resetDump(): GroupedActionDump;
|
|
55
|
-
appendExecutionDump(execution: ExecutionDump): void;
|
|
57
|
+
appendExecutionDump(execution: ExecutionDump, runner?: TaskRunner): void;
|
|
56
58
|
dumpDataString(): string;
|
|
57
59
|
reportHTMLString(): string;
|
|
58
60
|
writeOutActionDumps(): void;
|
|
59
61
|
private callbackOnTaskStartTip;
|
|
60
|
-
private
|
|
62
|
+
private handleRunnerAfterFlush;
|
|
61
63
|
wrapActionInActionSpace<T extends DeviceAction>(name: string): (param: ActionParam<T>) => Promise<ActionReturn<T>>;
|
|
62
64
|
callActionInActionSpace<T = any>(type: string, opt?: T): Promise<any>;
|
|
63
65
|
aiTap(locatePrompt: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { TaskRunner } from '../task-runner';
|
|
1
|
+
import { type TaskExecutionError, TaskRunner } from '../task-runner';
|
|
2
2
|
import type { ExecutionTaskApply, ExecutionTaskProgressOptions, UIContext } from '../types';
|
|
3
|
+
type ExecutionSessionOptions = ExecutionTaskProgressOptions & {
|
|
4
|
+
tasks?: ExecutionTaskApply[];
|
|
5
|
+
onTaskUpdate?: (runner: TaskRunner, error?: TaskExecutionError) => Promise<void> | void;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Thin wrapper around {@link TaskRunner} that represents a single linear execution run.
|
|
5
9
|
*/
|
|
6
10
|
export declare class ExecutionSession {
|
|
7
11
|
private readonly runner;
|
|
8
|
-
constructor(name: string, contextProvider: () => Promise<UIContext>, options?:
|
|
9
|
-
tasks?: ExecutionTaskApply[];
|
|
10
|
-
});
|
|
12
|
+
constructor(name: string, contextProvider: () => Promise<UIContext>, options?: ExecutionSessionOptions);
|
|
11
13
|
append(tasks: ExecutionTaskApply[] | ExecutionTaskApply): Promise<void>;
|
|
12
14
|
appendAndRun(tasks: ExecutionTaskApply[] | ExecutionTaskApply): Promise<{
|
|
13
15
|
output: any;
|
|
@@ -25,3 +27,4 @@ export declare class ExecutionSession {
|
|
|
25
27
|
}>;
|
|
26
28
|
getRunner(): TaskRunner;
|
|
27
29
|
}
|
|
30
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import type { TMultimodalPrompt, TUserPrompt } from '../ai-model/common';
|
|
|
2
2
|
import type { AbstractInterface } from '../device';
|
|
3
3
|
import type Service from '../service';
|
|
4
4
|
import type { TaskRunner } from '../task-runner';
|
|
5
|
+
import { TaskExecutionError } from '../task-runner';
|
|
5
6
|
import type { ExecutionTaskApply, ExecutionTaskProgressOptions, MidsceneYamlFlowItem, PlanningAction, PlanningActionParamSleep, PlanningActionParamWaitFor, ServiceExtractOption, ServiceExtractParam } from '../types';
|
|
6
7
|
import { type IModelConfig } from '@midscene/shared/env';
|
|
7
8
|
import type { TaskCache } from './task-cache';
|
|
@@ -11,6 +12,10 @@ interface ExecutionResult<OutputType = any> {
|
|
|
11
12
|
thought?: string;
|
|
12
13
|
runner: TaskRunner;
|
|
13
14
|
}
|
|
15
|
+
interface TaskExecutorHooks {
|
|
16
|
+
onTaskUpdate?: (runner: TaskRunner, error?: TaskExecutionError) => Promise<void> | void;
|
|
17
|
+
}
|
|
18
|
+
export { TaskExecutionError };
|
|
14
19
|
export declare class TaskExecutor {
|
|
15
20
|
interface: AbstractInterface;
|
|
16
21
|
service: Service;
|
|
@@ -18,12 +23,14 @@ export declare class TaskExecutor {
|
|
|
18
23
|
private readonly taskBuilder;
|
|
19
24
|
private conversationHistory;
|
|
20
25
|
onTaskStartCallback?: ExecutionTaskProgressOptions['onTaskStart'];
|
|
26
|
+
private readonly hooks?;
|
|
21
27
|
replanningCycleLimit?: number;
|
|
22
28
|
get page(): AbstractInterface;
|
|
23
29
|
constructor(interfaceInstance: AbstractInterface, service: Service, opts: {
|
|
24
30
|
taskCache?: TaskCache;
|
|
25
31
|
onTaskStart?: ExecutionTaskProgressOptions['onTaskStart'];
|
|
26
32
|
replanningCycleLimit?: number;
|
|
33
|
+
hooks?: TaskExecutorHooks;
|
|
27
34
|
});
|
|
28
35
|
private createExecutionSession;
|
|
29
36
|
convertPlanToExecutable(plans: PlanningAction[], modelConfig: IModelConfig, options?: {
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { ExecutionDump, ExecutionTask, ExecutionTaskApply, ExecutionTaskProgressOptions, UIContext } from './types';
|
|
2
|
+
type TaskRunnerInitOptions = ExecutionTaskProgressOptions & {
|
|
3
|
+
tasks?: ExecutionTaskApply[];
|
|
4
|
+
onTaskUpdate?: (runner: TaskRunner, error?: TaskExecutionError) => Promise<void> | void;
|
|
5
|
+
};
|
|
2
6
|
export declare class TaskRunner {
|
|
3
7
|
name: string;
|
|
4
8
|
tasks: ExecutionTask[];
|
|
5
9
|
status: 'init' | 'pending' | 'running' | 'completed' | 'error';
|
|
6
10
|
onTaskStart?: ExecutionTaskProgressOptions['onTaskStart'];
|
|
7
11
|
private readonly uiContextBuilder;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
private readonly onTaskUpdate?;
|
|
13
|
+
constructor(name: string, uiContextBuilder: () => Promise<UIContext>, options?: TaskRunnerInitOptions);
|
|
14
|
+
private emitOnTaskUpdate;
|
|
11
15
|
private lastUiContext?;
|
|
12
16
|
private getUiContext;
|
|
13
17
|
private captureScreenshot;
|
|
@@ -31,3 +35,11 @@ export declare class TaskRunner {
|
|
|
31
35
|
runner: TaskRunner;
|
|
32
36
|
}>;
|
|
33
37
|
}
|
|
38
|
+
export declare class TaskExecutionError extends Error {
|
|
39
|
+
runner: TaskRunner;
|
|
40
|
+
errorTask: ExecutionTask | null;
|
|
41
|
+
constructor(message: string, runner: TaskRunner, errorTask: ExecutionTask | null, options?: {
|
|
42
|
+
cause?: unknown;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -229,7 +229,7 @@ export interface ExecutionRecorderItem {
|
|
|
229
229
|
screenshot?: string;
|
|
230
230
|
timing?: string;
|
|
231
231
|
}
|
|
232
|
-
export type ExecutionTaskType = 'Planning' | 'Insight' | 'Action
|
|
232
|
+
export type ExecutionTaskType = 'Planning' | 'Insight' | 'Action Space' | 'Log';
|
|
233
233
|
export interface ExecutorContext {
|
|
234
234
|
task: ExecutionTask;
|
|
235
235
|
element?: LocateResultElement | null;
|
|
@@ -294,7 +294,7 @@ export interface ExecutionTaskInsightAssertionParam {
|
|
|
294
294
|
}
|
|
295
295
|
export type ExecutionTaskInsightAssertionApply = ExecutionTaskApply<'Insight', ExecutionTaskInsightAssertionParam, ServiceAssertionResponse, ExecutionTaskInsightDump>;
|
|
296
296
|
export type ExecutionTaskInsightAssertion = ExecutionTask<ExecutionTaskInsightAssertionApply>;
|
|
297
|
-
export type ExecutionTaskActionApply<ActionParam = any> = ExecutionTaskApply<'Action', ActionParam, void, void>;
|
|
297
|
+
export type ExecutionTaskActionApply<ActionParam = any> = ExecutionTaskApply<'Action Space', ActionParam, void, void>;
|
|
298
298
|
export type ExecutionTaskAction = ExecutionTask<ExecutionTaskActionApply>;
|
|
299
299
|
export type ExecutionTaskLogApply<LogParam = {
|
|
300
300
|
content: string;
|
|
@@ -305,6 +305,13 @@ export type ExecutionTaskPlanningApply = ExecutionTaskApply<'Planning', {
|
|
|
305
305
|
aiActionContext?: string;
|
|
306
306
|
}, PlanningAIResponse>;
|
|
307
307
|
export type ExecutionTaskPlanning = ExecutionTask<ExecutionTaskPlanningApply>;
|
|
308
|
+
export type ExecutionTaskPlanningLocateParam = PlanningLocateParam;
|
|
309
|
+
export interface ExecutionTaskPlanningLocateOutput {
|
|
310
|
+
element: LocateResultElement | null;
|
|
311
|
+
}
|
|
312
|
+
export type ExecutionTaskPlanningDump = ServiceDump;
|
|
313
|
+
export type ExecutionTaskPlanningLocateApply = ExecutionTaskApply<'Planning', ExecutionTaskPlanningLocateParam, ExecutionTaskPlanningLocateOutput, ExecutionTaskPlanningDump>;
|
|
314
|
+
export type ExecutionTaskPlanningLocate = ExecutionTask<ExecutionTaskPlanningLocateApply>;
|
|
308
315
|
export interface GroupedActionDump {
|
|
309
316
|
sdkVersion: string;
|
|
310
317
|
groupName: string;
|
package/dist/types/yaml.d.ts
CHANGED
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-
|
|
4
|
+
"version": "1.0.1-beta-20251104075048.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
|
"zod": "3.24.3",
|
|
90
90
|
"semver": "7.5.2",
|
|
91
91
|
"js-yaml": "4.1.0",
|
|
92
|
-
"@midscene/shared": "1.0.1-beta-
|
|
92
|
+
"@midscene/shared": "1.0.1-beta-20251104075048.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@rslib/core": "^0.11.2",
|