@midscene/core 1.11.0 → 1.11.1-beta-20260819031908.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 (56) hide show
  1. package/dist/es/agent/agent.mjs +11 -13
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/tasks.mjs +14 -6
  4. package/dist/es/agent/tasks.mjs.map +1 -1
  5. package/dist/es/agent/utils.mjs +1 -1
  6. package/dist/es/ai-model/prompt/planning/multi-turn-example.mjs +10 -10
  7. package/dist/es/ai-model/prompt/planning/multi-turn-example.mjs.map +1 -1
  8. package/dist/es/ai-model/prompt/planning/planning-response-example.mjs +4 -3
  9. package/dist/es/ai-model/prompt/planning/planning-response-example.mjs.map +1 -1
  10. package/dist/es/ai-model/prompt/planning/system-prompt.mjs +14 -10
  11. package/dist/es/ai-model/prompt/planning/system-prompt.mjs.map +1 -1
  12. package/dist/es/ai-model/workflows/grounding/planning-action-locate.mjs +1 -0
  13. package/dist/es/ai-model/workflows/grounding/planning-action-locate.mjs.map +1 -1
  14. package/dist/es/ai-model/workflows/planning/index.mjs +2 -2
  15. package/dist/es/ai-model/workflows/planning/planning-action-log.mjs +22 -0
  16. package/dist/es/ai-model/workflows/planning/planning-action-log.mjs.map +1 -0
  17. package/dist/es/ai-model/workflows/planning/standard-planning-parser.mjs +22 -3
  18. package/dist/es/ai-model/workflows/planning/standard-planning-parser.mjs.map +1 -1
  19. package/dist/es/ai-model/workflows/planning/standard-planning.mjs +19 -5
  20. package/dist/es/ai-model/workflows/planning/standard-planning.mjs.map +1 -1
  21. package/dist/es/types.mjs.map +1 -1
  22. package/dist/es/utils.mjs +2 -2
  23. package/dist/lib/agent/agent.js +11 -13
  24. package/dist/lib/agent/agent.js.map +1 -1
  25. package/dist/lib/agent/tasks.js +14 -6
  26. package/dist/lib/agent/tasks.js.map +1 -1
  27. package/dist/lib/agent/utils.js +1 -1
  28. package/dist/lib/ai-model/prompt/planning/multi-turn-example.js +10 -10
  29. package/dist/lib/ai-model/prompt/planning/multi-turn-example.js.map +1 -1
  30. package/dist/lib/ai-model/prompt/planning/planning-response-example.js +4 -3
  31. package/dist/lib/ai-model/prompt/planning/planning-response-example.js.map +1 -1
  32. package/dist/lib/ai-model/prompt/planning/system-prompt.js +14 -10
  33. package/dist/lib/ai-model/prompt/planning/system-prompt.js.map +1 -1
  34. package/dist/lib/ai-model/workflows/grounding/planning-action-locate.js +1 -0
  35. package/dist/lib/ai-model/workflows/grounding/planning-action-locate.js.map +1 -1
  36. package/dist/lib/ai-model/workflows/planning/index.js +3 -0
  37. package/dist/lib/ai-model/workflows/planning/planning-action-log.js +56 -0
  38. package/dist/lib/ai-model/workflows/planning/planning-action-log.js.map +1 -0
  39. package/dist/lib/ai-model/workflows/planning/standard-planning-parser.js +26 -4
  40. package/dist/lib/ai-model/workflows/planning/standard-planning-parser.js.map +1 -1
  41. package/dist/lib/ai-model/workflows/planning/standard-planning.js +18 -4
  42. package/dist/lib/ai-model/workflows/planning/standard-planning.js.map +1 -1
  43. package/dist/lib/types.js.map +1 -1
  44. package/dist/lib/utils.js +2 -2
  45. package/dist/types/agent/agent.d.ts +2 -1
  46. package/dist/types/agent/tasks.d.ts +2 -2
  47. package/dist/types/ai-model/prompt/planning/multi-turn-example.d.ts +3 -1
  48. package/dist/types/ai-model/prompt/planning/planning-response-example.d.ts +2 -2
  49. package/dist/types/ai-model/prompt/planning/system-prompt.d.ts +2 -0
  50. package/dist/types/ai-model/workflows/planning/index.d.ts +1 -1
  51. package/dist/types/ai-model/workflows/planning/planning-action-log.d.ts +2 -0
  52. package/dist/types/ai-model/workflows/planning/standard-planning-parser.d.ts +14 -2
  53. package/dist/types/ai-model/workflows/planning/types.d.ts +2 -2
  54. package/dist/types/device/index.d.ts +14 -14
  55. package/dist/types/types.d.ts +2 -1
  56. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import type { TUserPrompt } from '../ai-model/index';
2
2
  import Service from '../service/index';
3
- import { type ActionParam, type ActionReturn, type AgentAssertResult, type AgentOpt, type AgentProgressListener, type AgentWaitForOpt, type AssertOptions, type DeepThinkOption, type DeviceAction, ExecutionDump, type InsightAPI, type LocateOption, type LocateResultElement, type OnTaskStartTip, type QueryOptions, type RecordToReportOptions, ReportActionDump, type ScrollParam, type ServiceAction, type ServiceExtractParam, type UIContext } from '../types';
3
+ import { type ActionParam, type ActionReturn, type AgentAssertResult, type AgentOpt, type AgentProgressListener, type AgentWaitForOpt, type AiActEffort, type AssertOptions, type DeepThinkOption, type DeviceAction, ExecutionDump, type InsightAPI, type LocateOption, type LocateResultElement, type OnTaskStartTip, type QueryOptions, type RecordToReportOptions, ReportActionDump, type ScrollParam, type ServiceAction, type ServiceExtractParam, type UIContext } from '../types';
4
4
  import type { AbstractInterface } from '../device';
5
5
  import type { TaskRunner } from '../task-runner';
6
6
  import { ModelConfigManager } from '@midscene/shared/env';
@@ -13,6 +13,7 @@ export type AiActOptions = {
13
13
  cacheable?: boolean;
14
14
  fileChooserAccept?: string | string[];
15
15
  fileChooserAllowedDir?: string;
16
+ effort?: AiActEffort;
16
17
  deepThink?: DeepThinkOption;
17
18
  deepLocate?: boolean;
18
19
  abortSignal?: AbortSignal;
@@ -4,7 +4,7 @@ import type { AbstractInterface } from '../device';
4
4
  import type Service from '../service';
5
5
  import type { TaskRunner } from '../task-runner';
6
6
  import { TaskExecutionError } from '../task-runner';
7
- import type { DeviceAction, ExecutionTask, ExecutionTaskApply, ExecutionTaskProgressOptions, MidsceneYamlFlowItem, PlanningAction, PlanningActionParamWaitFor, ServiceExtractOption, ServiceExtractParam, UIContext } from '../types';
7
+ import type { AiActEffort, DeviceAction, ExecutionTask, ExecutionTaskApply, ExecutionTaskProgressOptions, MidsceneYamlFlowItem, PlanningAction, PlanningActionParamWaitFor, ServiceExtractOption, ServiceExtractParam, UIContext } from '../types';
8
8
  import { type AgentProgressPublisher } from './progress';
9
9
  import type { TaskCache } from './task-cache';
10
10
  export { locatePlanForLocate } from './task-builder';
@@ -94,7 +94,7 @@ export declare class TaskExecutor {
94
94
  runPlans(title: string, plans: PlanningAction[], planningModel: ModelRuntime, defaultModel: ModelRuntime, options?: {
95
95
  uiContext?: UIContext;
96
96
  }): Promise<ExecutionResult>;
97
- action(userPrompt: TUserPrompt, planningModel: ModelRuntime, defaultModel: ModelRuntime, includeLocateInPlanning: boolean, aiActContext?: string, cacheable?: boolean, replanningCycleLimitOverride?: number, imagesIncludeCount?: number, deepThink?: boolean, fileChooserAccept?: string[], deepLocate?: boolean, abortSignal?: AbortSignal, reportOptions?: ActionReportOptions): Promise<ExecutionResult<{
97
+ action(userPrompt: TUserPrompt, planningModel: ModelRuntime, defaultModel: ModelRuntime, aiActContext?: string, cacheable?: boolean, replanningCycleLimitOverride?: number, effort?: AiActEffort, fileChooserAccept?: string[], deepLocate?: boolean, abortSignal?: AbortSignal, reportOptions?: ActionReportOptions): Promise<ExecutionResult<{
98
98
  yamlFlow?: MidsceneYamlFlowItem[];
99
99
  output?: string;
100
100
  } | undefined>>;
@@ -1,7 +1,9 @@
1
1
  import type { LocateResultPromptSpec } from '../../shared/model-locate-result';
2
2
  import type { PlanningActionOutputProtocol } from './action-output-protocol';
3
- export declare const buildPlanningMultiTurnExample: ({ includeSubGoals, locatePromptSpec, actionOutputProtocol, }: {
3
+ export declare const buildPlanningMultiTurnExample: ({ includeSubGoals, includeThought, includeLog, locatePromptSpec, actionOutputProtocol, }: {
4
4
  includeSubGoals: boolean;
5
+ includeThought: boolean;
6
+ includeLog: boolean;
5
7
  locatePromptSpec?: LocateResultPromptSpec;
6
8
  actionOutputProtocol: PlanningActionOutputProtocol;
7
9
  }) => string;
@@ -5,7 +5,7 @@ type PlanningSubGoalExample = {
5
5
  description: string;
6
6
  };
7
7
  type PlanningResponseActionExample = {
8
- log: string;
8
+ log?: string;
9
9
  actionExample: string | undefined;
10
10
  complete?: never;
11
11
  };
@@ -18,7 +18,7 @@ type PlanningResponseCompleteExample = {
18
18
  actionExample?: never;
19
19
  };
20
20
  type BuildPlanningResponseExampleInput = {
21
- planning: string;
21
+ planning?: string;
22
22
  updateSubGoals?: PlanningSubGoalExample[];
23
23
  markSubGoalsDone?: number[];
24
24
  memory?: string;
@@ -4,6 +4,8 @@ import { type PlanningActionOutputProtocol } from './action-output-protocol';
4
4
  type BuildStandardPlanningSystemPromptInput = {
5
5
  actionSpace: DeviceAction<any>[];
6
6
  includeSubGoals?: boolean;
7
+ includeThought?: boolean;
8
+ includeLog?: boolean;
7
9
  actionOutputProtocol?: PlanningActionOutputProtocol;
8
10
  } & ({
9
11
  includeLocateInPlanning: true;
@@ -1,3 +1,3 @@
1
1
  export { ConversationHistory, type ConversationHistoryOptions, } from './conversation-history';
2
2
  export { standardPlan } from './standard-planning';
3
- export { parseXMLPlanningResponse } from './standard-planning-parser';
3
+ export { parseStandardPlanningResponse, parseXMLPlanningResponse, } from './standard-planning-parser';
@@ -0,0 +1,2 @@
1
+ import type { DeviceAction, PlanningAction } from '../../../types';
2
+ export declare function buildPlanningActionLog(action: PlanningAction, actionSpace: DeviceAction<any>[]): string;
@@ -1,4 +1,4 @@
1
- import type { RawResponsePlanningAIResponse, SubGoal } from '../../../types';
1
+ import type { DeviceAction, RawResponsePlanningAIResponse, SubGoal } from '../../../types';
2
2
  import type { JsonParser } from '../../shared/json';
3
3
  /**
4
4
  * Parse sub-goals from XML content.
@@ -13,4 +13,16 @@ export declare function parseSubGoalsFromXML(xmlContent: string): SubGoal[];
13
13
  */
14
14
  export declare function parseMarkFinishedIndexes(xmlContent: string): number[];
15
15
  /** Parse an XML model response into a planning response. */
16
- export declare function parseXMLPlanningResponse(xmlString: string, jsonParser: JsonParser): RawResponsePlanningAIResponse;
16
+ export declare function parseXMLPlanningResponse(xmlString: string, jsonParser: JsonParser, options: {
17
+ includeThought: boolean;
18
+ }): RawResponsePlanningAIResponse;
19
+ type ParseStandardPlanningResponseOptions = {
20
+ includeThought: boolean;
21
+ } & ({
22
+ logSource?: 'model';
23
+ } | {
24
+ logSource: 'action';
25
+ actionSpace: DeviceAction<any>[];
26
+ });
27
+ export declare function parseStandardPlanningResponse(xmlString: string, jsonParser: JsonParser, options: ParseStandardPlanningResponseOptions): RawResponsePlanningAIResponse;
28
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { TUserPrompt } from '../../../common';
2
- import type { DeviceAction, PlanningAIResponse, UIContext } from '../../../types';
2
+ import type { AiActEffort, DeviceAction, PlanningAIResponse, UIContext } from '../../../types';
3
3
  import type { ChatCompletionUserMessageParam } from 'openai/resources/index';
4
4
  import type { ModelRuntime } from '../../models';
5
5
  import type { ConversationHistory } from './conversation-history';
@@ -11,7 +11,7 @@ export interface PlanOptions {
11
11
  conversationHistory: ConversationHistory;
12
12
  includeLocateInPlanning: boolean;
13
13
  imagesIncludeCount?: number;
14
- deepThink?: boolean;
14
+ effort: AiActEffort;
15
15
  referenceImageMessages?: ChatCompletionUserMessageParam[];
16
16
  abortSignal?: AbortSignal;
17
17
  }
@@ -347,8 +347,8 @@ export declare const actionTapParamSchema: z.ZodObject<{
347
347
  }[] | undefined;
348
348
  convertHttpImage2Base64?: boolean | undefined;
349
349
  });
350
- deepLocate?: boolean | undefined;
351
350
  deepThink?: boolean | undefined;
351
+ deepLocate?: boolean | undefined;
352
352
  cacheable?: boolean | undefined;
353
353
  xpath?: string | boolean | undefined;
354
354
  } & {
@@ -365,8 +365,8 @@ export declare const actionTapParamSchema: z.ZodObject<{
365
365
  }[] | undefined;
366
366
  convertHttpImage2Base64?: boolean | undefined;
367
367
  });
368
- deepLocate?: boolean | undefined;
369
368
  deepThink?: boolean | undefined;
369
+ deepLocate?: boolean | undefined;
370
370
  cacheable?: boolean | undefined;
371
371
  xpath?: string | boolean | undefined;
372
372
  } & {
@@ -509,8 +509,8 @@ export declare const actionRightClickParamSchema: z.ZodObject<{
509
509
  }[] | undefined;
510
510
  convertHttpImage2Base64?: boolean | undefined;
511
511
  });
512
- deepLocate?: boolean | undefined;
513
512
  deepThink?: boolean | undefined;
513
+ deepLocate?: boolean | undefined;
514
514
  cacheable?: boolean | undefined;
515
515
  xpath?: string | boolean | undefined;
516
516
  } & {
@@ -527,8 +527,8 @@ export declare const actionRightClickParamSchema: z.ZodObject<{
527
527
  }[] | undefined;
528
528
  convertHttpImage2Base64?: boolean | undefined;
529
529
  });
530
- deepLocate?: boolean | undefined;
531
530
  deepThink?: boolean | undefined;
531
+ deepLocate?: boolean | undefined;
532
532
  cacheable?: boolean | undefined;
533
533
  xpath?: string | boolean | undefined;
534
534
  } & {
@@ -660,8 +660,8 @@ export declare const actionDoubleClickParamSchema: z.ZodObject<{
660
660
  }[] | undefined;
661
661
  convertHttpImage2Base64?: boolean | undefined;
662
662
  });
663
- deepLocate?: boolean | undefined;
664
663
  deepThink?: boolean | undefined;
664
+ deepLocate?: boolean | undefined;
665
665
  cacheable?: boolean | undefined;
666
666
  xpath?: string | boolean | undefined;
667
667
  } & {
@@ -678,8 +678,8 @@ export declare const actionDoubleClickParamSchema: z.ZodObject<{
678
678
  }[] | undefined;
679
679
  convertHttpImage2Base64?: boolean | undefined;
680
680
  });
681
- deepLocate?: boolean | undefined;
682
681
  deepThink?: boolean | undefined;
682
+ deepLocate?: boolean | undefined;
683
683
  cacheable?: boolean | undefined;
684
684
  xpath?: string | boolean | undefined;
685
685
  } & {
@@ -811,8 +811,8 @@ export declare const actionHoverParamSchema: z.ZodObject<{
811
811
  }[] | undefined;
812
812
  convertHttpImage2Base64?: boolean | undefined;
813
813
  });
814
- deepLocate?: boolean | undefined;
815
814
  deepThink?: boolean | undefined;
815
+ deepLocate?: boolean | undefined;
816
816
  cacheable?: boolean | undefined;
817
817
  xpath?: string | boolean | undefined;
818
818
  } & {
@@ -829,8 +829,8 @@ export declare const actionHoverParamSchema: z.ZodObject<{
829
829
  }[] | undefined;
830
830
  convertHttpImage2Base64?: boolean | undefined;
831
831
  });
832
- deepLocate?: boolean | undefined;
833
832
  deepThink?: boolean | undefined;
833
+ deepLocate?: boolean | undefined;
834
834
  cacheable?: boolean | undefined;
835
835
  xpath?: string | boolean | undefined;
836
836
  } & {
@@ -1670,8 +1670,8 @@ export declare const actionDragAndDropParamSchema: z.ZodObject<{
1670
1670
  }[] | undefined;
1671
1671
  convertHttpImage2Base64?: boolean | undefined;
1672
1672
  });
1673
- deepLocate?: boolean | undefined;
1674
1673
  deepThink?: boolean | undefined;
1674
+ deepLocate?: boolean | undefined;
1675
1675
  cacheable?: boolean | undefined;
1676
1676
  xpath?: string | boolean | undefined;
1677
1677
  } & {
@@ -1687,8 +1687,8 @@ export declare const actionDragAndDropParamSchema: z.ZodObject<{
1687
1687
  }[] | undefined;
1688
1688
  convertHttpImage2Base64?: boolean | undefined;
1689
1689
  });
1690
- deepLocate?: boolean | undefined;
1691
1690
  deepThink?: boolean | undefined;
1691
+ deepLocate?: boolean | undefined;
1692
1692
  cacheable?: boolean | undefined;
1693
1693
  xpath?: string | boolean | undefined;
1694
1694
  } & {
@@ -1705,8 +1705,8 @@ export declare const actionDragAndDropParamSchema: z.ZodObject<{
1705
1705
  }[] | undefined;
1706
1706
  convertHttpImage2Base64?: boolean | undefined;
1707
1707
  });
1708
- deepLocate?: boolean | undefined;
1709
1708
  deepThink?: boolean | undefined;
1709
+ deepLocate?: boolean | undefined;
1710
1710
  cacheable?: boolean | undefined;
1711
1711
  xpath?: string | boolean | undefined;
1712
1712
  } & {
@@ -1722,8 +1722,8 @@ export declare const actionDragAndDropParamSchema: z.ZodObject<{
1722
1722
  }[] | undefined;
1723
1723
  convertHttpImage2Base64?: boolean | undefined;
1724
1724
  });
1725
- deepLocate?: boolean | undefined;
1726
1725
  deepThink?: boolean | undefined;
1726
+ deepLocate?: boolean | undefined;
1727
1727
  cacheable?: boolean | undefined;
1728
1728
  xpath?: string | boolean | undefined;
1729
1729
  } & {
@@ -1857,8 +1857,8 @@ export declare const ActionLongPressParamSchema: z.ZodObject<{
1857
1857
  }[] | undefined;
1858
1858
  convertHttpImage2Base64?: boolean | undefined;
1859
1859
  });
1860
- deepLocate?: boolean | undefined;
1861
1860
  deepThink?: boolean | undefined;
1861
+ deepLocate?: boolean | undefined;
1862
1862
  cacheable?: boolean | undefined;
1863
1863
  xpath?: string | boolean | undefined;
1864
1864
  } & {
@@ -1876,8 +1876,8 @@ export declare const ActionLongPressParamSchema: z.ZodObject<{
1876
1876
  }[] | undefined;
1877
1877
  convertHttpImage2Base64?: boolean | undefined;
1878
1878
  });
1879
- deepLocate?: boolean | undefined;
1880
1879
  deepThink?: boolean | undefined;
1880
+ deepLocate?: boolean | undefined;
1881
1881
  cacheable?: boolean | undefined;
1882
1882
  xpath?: string | boolean | undefined;
1883
1883
  } & {
@@ -147,6 +147,7 @@ export interface LocateResult {
147
147
  rect?: Rect;
148
148
  }
149
149
  export type ThinkingLevel = 'off' | 'medium' | 'high';
150
+ export type AiActEffort = 'fast' | 'balance' | 'deepThink';
150
151
  export type DeepThinkOption = 'unset' | true | false;
151
152
  export interface ServiceTaskInfo {
152
153
  durationMs: number;
@@ -524,7 +525,7 @@ export interface ExecutionTaskPlanningParam {
524
525
  replanningCycleLimit?: number;
525
526
  aiActContext?: string;
526
527
  imagesIncludeCount?: number;
527
- deepThink?: DeepThinkOption;
528
+ effort?: AiActEffort;
528
529
  subGoalStatus?: string;
529
530
  memoriesStatus?: string;
530
531
  }
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.11.0",
4
+ "version": "1.11.1-beta-20260819031908.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "main": "./dist/lib/index.js",
@@ -115,7 +115,7 @@
115
115
  "semver": "7.5.2",
116
116
  "undici": "^6.0.0",
117
117
  "zod": "^3.25.1",
118
- "@midscene/shared": "1.11.0"
118
+ "@midscene/shared": "1.11.1-beta-20260819031908.0"
119
119
  },
120
120
  "devDependencies": {
121
121
  "@rslib/core": "^0.18.3",