@aiscene/core 8.0.1 → 8.0.3

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 (225) hide show
  1. package/dist/es/agent/agent.mjs +3 -3
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/task-builder.mjs +3 -3
  4. package/dist/es/agent/task-builder.mjs.map +1 -1
  5. package/dist/es/agent/task-cache.mjs +4 -4
  6. package/dist/es/agent/task-cache.mjs.map +1 -1
  7. package/dist/es/agent/tasks.mjs +4 -4
  8. package/dist/es/agent/tasks.mjs.map +1 -1
  9. package/dist/es/agent/utils.mjs +31 -14
  10. package/dist/es/agent/utils.mjs.map +1 -1
  11. package/dist/es/ai-model/auto-glm/actions.mjs +1 -1
  12. package/dist/es/ai-model/auto-glm/actions.mjs.map +1 -1
  13. package/dist/es/ai-model/auto-glm/parser.mjs +1 -1
  14. package/dist/es/ai-model/auto-glm/parser.mjs.map +1 -1
  15. package/dist/es/ai-model/auto-glm/planning.mjs +1 -1
  16. package/dist/es/ai-model/auto-glm/planning.mjs.map +1 -1
  17. package/dist/es/ai-model/auto-glm/prompt.mjs.map +1 -1
  18. package/dist/es/ai-model/auto-glm/util.mjs.map +1 -1
  19. package/dist/es/ai-model/connectivity.mjs +1 -1
  20. package/dist/es/ai-model/connectivity.mjs.map +1 -1
  21. package/dist/es/ai-model/inspect.mjs +4 -4
  22. package/dist/es/ai-model/inspect.mjs.map +1 -1
  23. package/dist/es/ai-model/llm-planning.mjs +3 -3
  24. package/dist/es/ai-model/llm-planning.mjs.map +1 -1
  25. package/dist/es/ai-model/prompt/common.mjs.map +1 -1
  26. package/dist/es/ai-model/prompt/describe.mjs +1 -1
  27. package/dist/es/ai-model/prompt/describe.mjs.map +1 -1
  28. package/dist/es/ai-model/prompt/extraction.mjs +1 -1
  29. package/dist/es/ai-model/prompt/extraction.mjs.map +1 -1
  30. package/dist/es/ai-model/prompt/llm-locator.mjs +1 -1
  31. package/dist/es/ai-model/prompt/llm-locator.mjs.map +1 -1
  32. package/dist/es/ai-model/prompt/llm-planning.mjs +2 -2
  33. package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -1
  34. package/dist/es/ai-model/prompt/llm-section-locator.mjs +1 -1
  35. package/dist/es/ai-model/prompt/llm-section-locator.mjs.map +1 -1
  36. package/dist/es/ai-model/prompt/playwright-generator.mjs +1 -1
  37. package/dist/es/ai-model/prompt/playwright-generator.mjs.map +1 -1
  38. package/dist/es/ai-model/prompt/ui-tars-planning.mjs +1 -1
  39. package/dist/es/ai-model/prompt/ui-tars-planning.mjs.map +1 -1
  40. package/dist/es/ai-model/prompt/yaml-generator.mjs +1 -1
  41. package/dist/es/ai-model/prompt/yaml-generator.mjs.map +1 -1
  42. package/dist/es/ai-model/service-caller/codex-app-server.mjs +2 -2
  43. package/dist/es/ai-model/service-caller/codex-app-server.mjs.map +1 -1
  44. package/dist/es/ai-model/service-caller/image-detail.mjs.map +1 -1
  45. package/dist/es/ai-model/service-caller/index.mjs +3 -3
  46. package/dist/es/ai-model/service-caller/index.mjs.map +1 -1
  47. package/dist/es/ai-model/ui-tars-planning.mjs +3 -3
  48. package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -1
  49. package/dist/es/common.mjs +4 -4
  50. package/dist/es/common.mjs.map +1 -1
  51. package/dist/es/device/index.mjs +1 -1
  52. package/dist/es/device/index.mjs.map +1 -1
  53. package/dist/es/dump/html-utils.mjs +1 -1
  54. package/dist/es/dump/html-utils.mjs.map +1 -1
  55. package/dist/es/index.mjs +1 -1
  56. package/dist/es/index.mjs.map +1 -1
  57. package/dist/es/report-generator.mjs +3 -3
  58. package/dist/es/report-generator.mjs.map +1 -1
  59. package/dist/es/report.mjs +2 -2
  60. package/dist/es/report.mjs.map +1 -1
  61. package/dist/es/screenshot-item.mjs +1 -1
  62. package/dist/es/screenshot-item.mjs.map +1 -1
  63. package/dist/es/service/index.mjs +3 -3
  64. package/dist/es/service/index.mjs.map +1 -1
  65. package/dist/es/service/utils.mjs +1 -1
  66. package/dist/es/service/utils.mjs.map +1 -1
  67. package/dist/es/skill/index.mjs +2 -2
  68. package/dist/es/skill/index.mjs.map +1 -1
  69. package/dist/es/task-runner.mjs +2 -2
  70. package/dist/es/task-runner.mjs.map +1 -1
  71. package/dist/es/task-timing.mjs +1 -1
  72. package/dist/es/task-timing.mjs.map +1 -1
  73. package/dist/es/tree.mjs +1 -1
  74. package/dist/es/tree.mjs.map +1 -1
  75. package/dist/es/types.mjs.map +1 -1
  76. package/dist/es/utils.mjs +5 -5
  77. package/dist/es/utils.mjs.map +1 -1
  78. package/dist/es/yaml/player.mjs +3 -3
  79. package/dist/es/yaml/player.mjs.map +1 -1
  80. package/dist/es/yaml/utils.mjs +2 -2
  81. package/dist/es/yaml/utils.mjs.map +1 -1
  82. package/dist/lib/agent/agent.js +3 -3
  83. package/dist/lib/agent/agent.js.map +1 -1
  84. package/dist/lib/agent/task-builder.js +3 -3
  85. package/dist/lib/agent/task-builder.js.map +1 -1
  86. package/dist/lib/agent/task-cache.js +4 -4
  87. package/dist/lib/agent/task-cache.js.map +1 -1
  88. package/dist/lib/agent/tasks.js +4 -4
  89. package/dist/lib/agent/tasks.js.map +1 -1
  90. package/dist/lib/agent/utils.js +31 -14
  91. package/dist/lib/agent/utils.js.map +1 -1
  92. package/dist/lib/ai-model/auto-glm/actions.js +1 -1
  93. package/dist/lib/ai-model/auto-glm/actions.js.map +1 -1
  94. package/dist/lib/ai-model/auto-glm/parser.js +1 -1
  95. package/dist/lib/ai-model/auto-glm/parser.js.map +1 -1
  96. package/dist/lib/ai-model/auto-glm/planning.js +1 -1
  97. package/dist/lib/ai-model/auto-glm/planning.js.map +1 -1
  98. package/dist/lib/ai-model/auto-glm/prompt.js.map +1 -1
  99. package/dist/lib/ai-model/auto-glm/util.js.map +1 -1
  100. package/dist/lib/ai-model/connectivity.js +1 -1
  101. package/dist/lib/ai-model/connectivity.js.map +1 -1
  102. package/dist/lib/ai-model/inspect.js +4 -4
  103. package/dist/lib/ai-model/inspect.js.map +1 -1
  104. package/dist/lib/ai-model/llm-planning.js +3 -3
  105. package/dist/lib/ai-model/llm-planning.js.map +1 -1
  106. package/dist/lib/ai-model/prompt/common.js.map +1 -1
  107. package/dist/lib/ai-model/prompt/describe.js +1 -1
  108. package/dist/lib/ai-model/prompt/describe.js.map +1 -1
  109. package/dist/lib/ai-model/prompt/extraction.js +1 -1
  110. package/dist/lib/ai-model/prompt/extraction.js.map +1 -1
  111. package/dist/lib/ai-model/prompt/llm-locator.js +1 -1
  112. package/dist/lib/ai-model/prompt/llm-locator.js.map +1 -1
  113. package/dist/lib/ai-model/prompt/llm-planning.js +2 -2
  114. package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -1
  115. package/dist/lib/ai-model/prompt/llm-section-locator.js +1 -1
  116. package/dist/lib/ai-model/prompt/llm-section-locator.js.map +1 -1
  117. package/dist/lib/ai-model/prompt/playwright-generator.js +1 -1
  118. package/dist/lib/ai-model/prompt/playwright-generator.js.map +1 -1
  119. package/dist/lib/ai-model/prompt/ui-tars-planning.js +1 -1
  120. package/dist/lib/ai-model/prompt/ui-tars-planning.js.map +1 -1
  121. package/dist/lib/ai-model/prompt/yaml-generator.js +1 -1
  122. package/dist/lib/ai-model/prompt/yaml-generator.js.map +1 -1
  123. package/dist/lib/ai-model/service-caller/codex-app-server.js +2 -2
  124. package/dist/lib/ai-model/service-caller/codex-app-server.js.map +1 -1
  125. package/dist/lib/ai-model/service-caller/image-detail.js.map +1 -1
  126. package/dist/lib/ai-model/service-caller/index.js +3 -3
  127. package/dist/lib/ai-model/service-caller/index.js.map +1 -1
  128. package/dist/lib/ai-model/ui-tars-planning.js +3 -3
  129. package/dist/lib/ai-model/ui-tars-planning.js.map +1 -1
  130. package/dist/lib/common.js +4 -4
  131. package/dist/lib/common.js.map +1 -1
  132. package/dist/lib/device/index.js +1 -1
  133. package/dist/lib/device/index.js.map +1 -1
  134. package/dist/lib/dump/html-utils.js +1 -1
  135. package/dist/lib/dump/html-utils.js.map +1 -1
  136. package/dist/lib/index.js +1 -1
  137. package/dist/lib/index.js.map +1 -1
  138. package/dist/lib/report-generator.js +3 -3
  139. package/dist/lib/report-generator.js.map +1 -1
  140. package/dist/lib/report.js +2 -2
  141. package/dist/lib/report.js.map +1 -1
  142. package/dist/lib/screenshot-item.js +1 -1
  143. package/dist/lib/screenshot-item.js.map +1 -1
  144. package/dist/lib/service/index.js +3 -3
  145. package/dist/lib/service/index.js.map +1 -1
  146. package/dist/lib/service/utils.js +1 -1
  147. package/dist/lib/service/utils.js.map +1 -1
  148. package/dist/lib/skill/index.js +2 -2
  149. package/dist/lib/skill/index.js.map +1 -1
  150. package/dist/lib/task-runner.js +2 -2
  151. package/dist/lib/task-runner.js.map +1 -1
  152. package/dist/lib/task-timing.js +1 -1
  153. package/dist/lib/task-timing.js.map +1 -1
  154. package/dist/lib/tree.js +1 -1
  155. package/dist/lib/tree.js.map +1 -1
  156. package/dist/lib/types.js +3 -3
  157. package/dist/lib/types.js.map +1 -1
  158. package/dist/lib/utils.js +5 -5
  159. package/dist/lib/utils.js.map +1 -1
  160. package/dist/lib/yaml/player.js +3 -3
  161. package/dist/lib/yaml/player.js.map +1 -1
  162. package/dist/lib/yaml/utils.js +2 -2
  163. package/dist/lib/yaml/utils.js.map +1 -1
  164. package/package.json +2 -2
  165. package/dist/types/agent/agent.d.ts +0 -216
  166. package/dist/types/agent/common.d.ts +0 -0
  167. package/dist/types/agent/execution-session.d.ts +0 -36
  168. package/dist/types/agent/index.d.ts +0 -9
  169. package/dist/types/agent/task-builder.d.ts +0 -34
  170. package/dist/types/agent/task-cache.d.ts +0 -49
  171. package/dist/types/agent/tasks.d.ts +0 -69
  172. package/dist/types/agent/ui-utils.d.ts +0 -14
  173. package/dist/types/agent/utils.d.ts +0 -25
  174. package/dist/types/ai-model/auto-glm/actions.d.ts +0 -78
  175. package/dist/types/ai-model/auto-glm/index.d.ts +0 -6
  176. package/dist/types/ai-model/auto-glm/parser.d.ts +0 -18
  177. package/dist/types/ai-model/auto-glm/planning.d.ts +0 -12
  178. package/dist/types/ai-model/auto-glm/prompt.d.ts +0 -27
  179. package/dist/types/ai-model/auto-glm/util.d.ts +0 -13
  180. package/dist/types/ai-model/connectivity.d.ts +0 -20
  181. package/dist/types/ai-model/conversation-history.d.ts +0 -105
  182. package/dist/types/ai-model/index.d.ts +0 -16
  183. package/dist/types/ai-model/inspect.d.ts +0 -67
  184. package/dist/types/ai-model/llm-planning.d.ts +0 -19
  185. package/dist/types/ai-model/prompt/common.d.ts +0 -2
  186. package/dist/types/ai-model/prompt/describe.d.ts +0 -1
  187. package/dist/types/ai-model/prompt/extraction.d.ts +0 -7
  188. package/dist/types/ai-model/prompt/llm-locator.d.ts +0 -3
  189. package/dist/types/ai-model/prompt/llm-planning.d.ts +0 -10
  190. package/dist/types/ai-model/prompt/llm-section-locator.d.ts +0 -3
  191. package/dist/types/ai-model/prompt/order-sensitive-judge.d.ts +0 -2
  192. package/dist/types/ai-model/prompt/playwright-generator.d.ts +0 -26
  193. package/dist/types/ai-model/prompt/ui-tars-planning.d.ts +0 -2
  194. package/dist/types/ai-model/prompt/util.d.ts +0 -33
  195. package/dist/types/ai-model/prompt/yaml-generator.d.ts +0 -102
  196. package/dist/types/ai-model/service-caller/codex-app-server.d.ts +0 -42
  197. package/dist/types/ai-model/service-caller/image-detail.d.ts +0 -2
  198. package/dist/types/ai-model/service-caller/index.d.ts +0 -49
  199. package/dist/types/ai-model/ui-tars-planning.d.ts +0 -72
  200. package/dist/types/common.d.ts +0 -288
  201. package/dist/types/device/device-options.d.ts +0 -145
  202. package/dist/types/device/index.d.ts +0 -2528
  203. package/dist/types/dump/html-utils.d.ts +0 -75
  204. package/dist/types/dump/index.d.ts +0 -5
  205. package/dist/types/dump/screenshot-restoration.d.ts +0 -8
  206. package/dist/types/dump/screenshot-store.d.ts +0 -49
  207. package/dist/types/index.d.ts +0 -21
  208. package/dist/types/report-cli.d.ts +0 -36
  209. package/dist/types/report-generator.d.ts +0 -81
  210. package/dist/types/report-markdown.d.ts +0 -24
  211. package/dist/types/report.d.ts +0 -52
  212. package/dist/types/screenshot-item.d.ts +0 -67
  213. package/dist/types/service/index.d.ts +0 -24
  214. package/dist/types/service/utils.d.ts +0 -2
  215. package/dist/types/skill/index.d.ts +0 -25
  216. package/dist/types/task-runner.d.ts +0 -50
  217. package/dist/types/task-timing.d.ts +0 -8
  218. package/dist/types/tree.d.ts +0 -4
  219. package/dist/types/types.d.ts +0 -681
  220. package/dist/types/utils.d.ts +0 -45
  221. package/dist/types/yaml/builder.d.ts +0 -2
  222. package/dist/types/yaml/index.d.ts +0 -4
  223. package/dist/types/yaml/player.d.ts +0 -34
  224. package/dist/types/yaml/utils.d.ts +0 -9
  225. package/dist/types/yaml.d.ts +0 -215
@@ -1,33 +0,0 @@
1
- import type { SubGoal } from '../../types';
2
- /**
3
- * Extract content from an XML tag in a string, searching from the end.
4
- * This approach handles cases where models prepend thinking content (like <think>...</think>)
5
- * before the actual response tags, or when there are incomplete/nested tags.
6
- *
7
- * Strategy: Find the LAST closing tag, then search backwards for the nearest opening tag.
8
- * This ensures we get the last complete tag pair, even if there are incomplete tags before it.
9
- *
10
- * @param xmlString - The XML string to parse
11
- * @param tagName - The name of the tag to extract (case-insensitive)
12
- * @returns The trimmed content of the tag, or undefined if not found
13
- */
14
- export declare function extractXMLTag(xmlString: string, tagName: string): string | undefined;
15
- /**
16
- * Parse sub-goals from XML content
17
- * Handles both formats:
18
- * - <sub-goal index="1" status="pending">description</sub-goal>
19
- * - <sub-goal index="1" status="finished" />
20
- */
21
- export declare function parseSubGoalsFromXML(xmlContent: string): SubGoal[];
22
- /**
23
- * Extract indexes of sub-goals marked as finished from <mark-sub-goal-done> content
24
- */
25
- export declare function parseMarkFinishedIndexes(xmlContent: string): number[];
26
- export declare const distanceThreshold = 16;
27
- export declare function distance(point1: {
28
- x: number;
29
- y: number;
30
- }, point2: {
31
- x: number;
32
- y: number;
33
- }): number;
@@ -1,102 +0,0 @@
1
- import type { StreamingAIResponse, StreamingCodeGenerationOptions } from '../../types';
2
- import type { IModelConfig } from '@midscene/shared/env';
3
- export interface EventCounts {
4
- navigation: number;
5
- click: number;
6
- input: number;
7
- scroll: number;
8
- total: number;
9
- }
10
- export interface InputDescription {
11
- description: string;
12
- value: string;
13
- }
14
- export interface ProcessedEvent {
15
- type: string;
16
- timestamp: number;
17
- url?: string;
18
- title?: string;
19
- elementDescription?: string;
20
- value?: string;
21
- pageInfo?: any;
22
- elementRect?: any;
23
- }
24
- export interface EventSummary {
25
- testName: string;
26
- startUrl: string;
27
- eventCounts: EventCounts;
28
- urls: string[];
29
- clickDescriptions: string[];
30
- inputDescriptions: InputDescription[];
31
- events: ProcessedEvent[];
32
- }
33
- export interface ChromeRecordedEvent {
34
- type: string;
35
- timestamp: number;
36
- url?: string;
37
- title?: string;
38
- elementDescription?: string;
39
- value?: string;
40
- pageInfo?: any;
41
- elementRect?: any;
42
- screenshotBefore?: string;
43
- screenshotAfter?: string;
44
- screenshotWithBox?: string;
45
- }
46
- export interface YamlGenerationOptions {
47
- testName?: string;
48
- includeTimestamps?: boolean;
49
- maxScreenshots?: number;
50
- description?: string;
51
- /** Language for human-readable YAML content (e.g. 'English', 'Chinese'). Keys and API names are kept as-is. */
52
- language?: string;
53
- }
54
- export interface FilteredEvents {
55
- navigationEvents: ChromeRecordedEvent[];
56
- clickEvents: ChromeRecordedEvent[];
57
- inputEvents: ChromeRecordedEvent[];
58
- scrollEvents: ChromeRecordedEvent[];
59
- }
60
- /**
61
- * Get screenshots from events for LLM context
62
- */
63
- export declare const getScreenshotsForLLM: (events: ChromeRecordedEvent[], maxScreenshots?: number) => string[];
64
- /**
65
- * Filter events by type for easier processing
66
- */
67
- export declare const filterEventsByType: (events: ChromeRecordedEvent[]) => FilteredEvents;
68
- /**
69
- * Create event counts summary
70
- */
71
- export declare const createEventCounts: (filteredEvents: FilteredEvents, totalEvents: number) => EventCounts;
72
- /**
73
- * Extract input descriptions from input events
74
- */
75
- export declare const extractInputDescriptions: (inputEvents: ChromeRecordedEvent[]) => InputDescription[];
76
- /**
77
- * Process events for LLM consumption
78
- */
79
- export declare const processEventsForLLM: (events: ChromeRecordedEvent[]) => ProcessedEvent[];
80
- /**
81
- * Prepare comprehensive event summary for LLM
82
- */
83
- export declare const prepareEventSummary: (events: ChromeRecordedEvent[], options?: {
84
- testName?: string;
85
- maxScreenshots?: number;
86
- }) => EventSummary;
87
- /**
88
- * Create message content for LLM with optional screenshots
89
- */
90
- export declare const createMessageContent: (promptText: string, screenshots?: string[], includeScreenshots?: boolean) => any[];
91
- /**
92
- * Validate events before processing
93
- */
94
- export declare const validateEvents: (events: ChromeRecordedEvent[]) => void;
95
- /**
96
- * Generates YAML test configuration from recorded events using AI
97
- */
98
- export declare const generateYamlTest: (events: ChromeRecordedEvent[], options: YamlGenerationOptions, modelConfig: IModelConfig) => Promise<string>;
99
- /**
100
- * Generates YAML test configuration from recorded events using AI with streaming support
101
- */
102
- export declare const generateYamlTestStream: (events: ChromeRecordedEvent[], options: YamlGenerationOptions & StreamingCodeGenerationOptions, modelConfig: IModelConfig) => Promise<StreamingAIResponse>;
@@ -1,42 +0,0 @@
1
- import type { AIUsageInfo, DeepThinkOption, StreamingCallback } from '../../types';
2
- import type { IModelConfig } from '@midscene/shared/env';
3
- import type { ChatCompletionMessageParam } from 'openai/resources/index';
4
- type CodexReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
5
- type CodexTextInput = {
6
- type: 'text';
7
- text: string;
8
- text_elements: any[];
9
- };
10
- type CodexImageInput = {
11
- type: 'image';
12
- url: string;
13
- };
14
- type CodexLocalImageInput = {
15
- type: 'localImage';
16
- path: string;
17
- };
18
- type CodexTurnInput = CodexTextInput | CodexImageInput | CodexLocalImageInput;
19
- type CodexTurnResult = {
20
- content: string;
21
- reasoning_content?: string;
22
- usage?: AIUsageInfo;
23
- isStreamed: boolean;
24
- };
25
- export declare const isCodexAppServerProvider: (baseURL?: string) => boolean;
26
- export declare const normalizeCodexLocalImagePath: (imageUrl: string, platform?: NodeJS.Platform) => string;
27
- export declare const resolveCodexReasoningEffort: ({ deepThink, modelConfig, }: {
28
- deepThink?: DeepThinkOption;
29
- modelConfig: IModelConfig;
30
- }) => CodexReasoningEffort | undefined;
31
- export declare const buildCodexTurnPayloadFromMessages: (messages: ChatCompletionMessageParam[]) => {
32
- developerInstructions?: string;
33
- input: CodexTurnInput[];
34
- };
35
- export declare function callAIWithCodexAppServer(messages: ChatCompletionMessageParam[], modelConfig: IModelConfig, options?: {
36
- stream?: boolean;
37
- onChunk?: StreamingCallback;
38
- deepThink?: DeepThinkOption;
39
- abortSignal?: AbortSignal;
40
- }): Promise<CodexTurnResult>;
41
- export declare function __shutdownCodexAppServerForTests(): Promise<void>;
42
- export {};
@@ -1,2 +0,0 @@
1
- import type { IModelConfig } from '@midscene/shared/env';
2
- export declare function shouldForceOriginalImageDetail(modelConfig: Pick<IModelConfig, 'intent' | 'modelFamily'>): boolean;
@@ -1,49 +0,0 @@
1
- import type { AIUsageInfo, DeepThinkOption } from '../../types';
2
- import type { StreamingCallback } from '../../types';
3
- export declare class AIResponseParseError extends Error {
4
- usage?: AIUsageInfo;
5
- rawResponse: string;
6
- constructor(message: string, rawResponse: string, usage?: AIUsageInfo);
7
- }
8
- import { type IModelConfig, type TModelFamily } from '@midscene/shared/env';
9
- import type { ChatCompletionMessageParam } from 'openai/resources/index';
10
- import type { AIArgs } from '../../common';
11
- export declare function callAI(messages: ChatCompletionMessageParam[], modelConfig: IModelConfig, options?: {
12
- stream?: boolean;
13
- onChunk?: StreamingCallback;
14
- deepThink?: DeepThinkOption;
15
- abortSignal?: AbortSignal;
16
- }): Promise<{
17
- content: string;
18
- reasoning_content?: string;
19
- usage?: AIUsageInfo;
20
- isStreamed: boolean;
21
- }>;
22
- export declare function callAIWithObjectResponse<T>(messages: ChatCompletionMessageParam[], modelConfig: IModelConfig, options?: {
23
- deepThink?: DeepThinkOption;
24
- abortSignal?: AbortSignal;
25
- }): Promise<{
26
- content: T;
27
- contentString: string;
28
- usage?: AIUsageInfo;
29
- reasoning_content?: string;
30
- }>;
31
- export declare function callAIWithStringResponse(msgs: AIArgs, modelConfig: IModelConfig, options?: {
32
- abortSignal?: AbortSignal;
33
- }): Promise<{
34
- content: string;
35
- usage?: AIUsageInfo;
36
- }>;
37
- export declare function extractJSONFromCodeBlock(response: string): string;
38
- export declare function preprocessDoubaoBboxJson(input: string): string;
39
- export declare function resolveReasoningConfig({ reasoningEnabled, reasoningEffort, reasoningBudget, modelFamily, }: {
40
- reasoningEnabled?: boolean;
41
- reasoningEffort?: string;
42
- reasoningBudget?: number;
43
- modelFamily?: TModelFamily;
44
- }): {
45
- config: Record<string, unknown>;
46
- debugMessage?: string;
47
- warningMessage?: string;
48
- };
49
- export declare function safeParseJson(input: string, modelFamily: TModelFamily | undefined): any;
@@ -1,72 +0,0 @@
1
- import type { PlanningAIResponse, UIContext } from '../types';
2
- import { type IModelConfig } from '@midscene/shared/env';
3
- import type { ConversationHistory } from './conversation-history';
4
- type ActionType = 'click' | 'left_double' | 'right_single' | 'drag' | 'type' | 'hotkey' | 'finished' | 'scroll' | 'wait';
5
- export declare function uiTarsPlanning(userInstruction: string, options: {
6
- conversationHistory: ConversationHistory;
7
- context: UIContext;
8
- modelConfig: IModelConfig;
9
- actionContext?: string;
10
- abortSignal?: AbortSignal;
11
- }): Promise<PlanningAIResponse>;
12
- interface BaseAction {
13
- action_type: ActionType;
14
- action_inputs: Record<string, any>;
15
- reflection: string | null;
16
- thought: string | null;
17
- }
18
- interface ClickAction extends BaseAction {
19
- action_type: 'click';
20
- action_inputs: {
21
- start_box: string;
22
- };
23
- }
24
- interface DragAction extends BaseAction {
25
- action_type: 'drag';
26
- action_inputs: {
27
- start_box: string;
28
- end_box: string;
29
- };
30
- }
31
- interface WaitAction extends BaseAction {
32
- action_type: 'wait';
33
- action_inputs: {
34
- time: string;
35
- };
36
- }
37
- interface LeftDoubleAction extends BaseAction {
38
- action_type: 'left_double';
39
- action_inputs: {
40
- start_box: string;
41
- };
42
- }
43
- interface RightSingleAction extends BaseAction {
44
- action_type: 'right_single';
45
- action_inputs: {
46
- start_box: string;
47
- };
48
- }
49
- interface TypeAction extends BaseAction {
50
- action_type: 'type';
51
- action_inputs: {
52
- content: string;
53
- };
54
- }
55
- interface HotkeyAction extends BaseAction {
56
- action_type: 'hotkey';
57
- action_inputs: {
58
- key: string;
59
- };
60
- }
61
- interface ScrollAction extends BaseAction {
62
- action_type: 'scroll';
63
- action_inputs: {
64
- direction: 'up' | 'down';
65
- };
66
- }
67
- interface FinishedAction extends BaseAction {
68
- action_type: 'finished';
69
- action_inputs: Record<string, never>;
70
- }
71
- export type Action = ClickAction | LeftDoubleAction | RightSingleAction | DragAction | TypeAction | HotkeyAction | ScrollAction | FinishedAction | WaitAction;
72
- export {};
@@ -1,288 +0,0 @@
1
- import type { BaseElement, DeviceAction, ElementTreeNode, MidsceneYamlFlowItem, PlanningAction, Rect, Size } from './types';
2
- import type { ChatCompletionMessageParam } from 'openai/resources/index';
3
- import type { PlanningLocateParam } from './types';
4
- import type { TModelFamily } from '@midscene/shared/env';
5
- import { z } from 'zod';
6
- export type AIArgs = ChatCompletionMessageParam[];
7
- type AdaptBboxInput = number[] | string[] | string | (number[] | string[])[];
8
- /**
9
- * Convert a point coordinate [0, 1000] to a small bbox [0, 1000]
10
- * Creates a small bbox around the center point in the same coordinate space
11
- *
12
- * @param x - X coordinate in [0, 1000] range
13
- * @param y - Y coordinate in [0, 1000] range
14
- * @param bboxSize - Size of the bbox to create (default: 20)
15
- * @returns [x1, y1, x2, y2] bbox in [0, 1000] coordinate space
16
- */
17
- export declare function pointToBbox(x: number, y: number, bboxSize?: number): [number, number, number, number];
18
- export declare function fillBboxParam(locate: PlanningLocateParam, width: number, height: number, modelFamily: TModelFamily | undefined): PlanningLocateParam;
19
- export declare function adaptQwen2_5Bbox(bbox: number[]): [number, number, number, number];
20
- export declare function adaptGpt5Bbox(bbox: number[] | string[] | string): [number, number, number, number];
21
- export declare function adaptDoubaoBbox(bbox: string[] | number[] | string, width: number, height: number): [number, number, number, number];
22
- export declare function adaptBbox(bbox: AdaptBboxInput, width: number, height: number, modelFamily: TModelFamily | undefined): [number, number, number, number];
23
- export declare function normalized01000(bbox: number[], width: number, height: number): [number, number, number, number];
24
- export declare function adaptGeminiBbox(bbox: number[], width: number, height: number): [number, number, number, number];
25
- export declare function adaptBboxToRect(bbox: number[], width: number, height: number, offsetX?: number, offsetY?: number, rightLimit?: number, bottomLimit?: number, modelFamily?: TModelFamily | undefined, scale?: number): Rect;
26
- export declare function mergeRects(rects: Rect[]): {
27
- left: number;
28
- top: number;
29
- width: number;
30
- height: number;
31
- };
32
- /**
33
- * Expand the search area to at least 400 x 400 pixels
34
- *
35
- * Step 1: Extend 100px on each side (top, right, bottom, left)
36
- * - If the element is near a boundary, expansion on that side will be limited
37
- * - No compensation is made for boundary limitations (this is intentional)
38
- *
39
- * Step 2: Ensure the area is at least 400x400 pixels
40
- * - Scale up proportionally from the center if needed
41
- * - Final result is clamped to screen boundaries
42
- */
43
- export declare function expandSearchArea(rect: Rect, screenSize: Size): Rect;
44
- export declare function markupImageForLLM(screenshotBase64: string, tree: ElementTreeNode<BaseElement>, size: Size): Promise<string>;
45
- export declare function buildYamlFlowFromPlans(plans: PlanningAction[], actionSpace: DeviceAction<any>[]): MidsceneYamlFlowItem[];
46
- export declare const PointSchema: z.ZodObject<{
47
- left: z.ZodNumber;
48
- top: z.ZodNumber;
49
- }, "strip", z.ZodTypeAny, {
50
- left: number;
51
- top: number;
52
- }, {
53
- left: number;
54
- top: number;
55
- }>;
56
- export declare const SizeSchema: z.ZodObject<{
57
- width: z.ZodNumber;
58
- height: z.ZodNumber;
59
- }, "strip", z.ZodTypeAny, {
60
- width: number;
61
- height: number;
62
- }, {
63
- width: number;
64
- height: number;
65
- }>;
66
- export declare const RectSchema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
67
- left: z.ZodNumber;
68
- top: z.ZodNumber;
69
- }, "strip", z.ZodTypeAny, {
70
- left: number;
71
- top: number;
72
- }, {
73
- left: number;
74
- top: number;
75
- }>, z.ZodObject<{
76
- width: z.ZodNumber;
77
- height: z.ZodNumber;
78
- }, "strip", z.ZodTypeAny, {
79
- width: number;
80
- height: number;
81
- }, {
82
- width: number;
83
- height: number;
84
- }>>, z.ZodObject<{
85
- zoom: z.ZodOptional<z.ZodNumber>;
86
- }, "strip", z.ZodTypeAny, {
87
- zoom?: number | undefined;
88
- }, {
89
- zoom?: number | undefined;
90
- }>>;
91
- export declare const TMultimodalPromptSchema: z.ZodObject<{
92
- images: z.ZodOptional<z.ZodArray<z.ZodObject<{
93
- name: z.ZodString;
94
- url: z.ZodString;
95
- }, "strip", z.ZodTypeAny, {
96
- name: string;
97
- url: string;
98
- }, {
99
- name: string;
100
- url: string;
101
- }>, "many">>;
102
- convertHttpImage2Base64: z.ZodOptional<z.ZodBoolean>;
103
- }, "strip", z.ZodTypeAny, {
104
- images?: {
105
- name: string;
106
- url: string;
107
- }[] | undefined;
108
- convertHttpImage2Base64?: boolean | undefined;
109
- }, {
110
- images?: {
111
- name: string;
112
- url: string;
113
- }[] | undefined;
114
- convertHttpImage2Base64?: boolean | undefined;
115
- }>;
116
- export declare const TUserPromptSchema: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
117
- prompt: z.ZodString;
118
- }, "strip", z.ZodTypeAny, {
119
- prompt: string;
120
- }, {
121
- prompt: string;
122
- }>, z.ZodObject<{
123
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
124
- name: z.ZodString;
125
- url: z.ZodString;
126
- }, "strip", z.ZodTypeAny, {
127
- name: string;
128
- url: string;
129
- }, {
130
- name: string;
131
- url: string;
132
- }>, "many">>>;
133
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
134
- }, "strip", z.ZodTypeAny, {
135
- images?: {
136
- name: string;
137
- url: string;
138
- }[] | undefined;
139
- convertHttpImage2Base64?: boolean | undefined;
140
- }, {
141
- images?: {
142
- name: string;
143
- url: string;
144
- }[] | undefined;
145
- convertHttpImage2Base64?: boolean | undefined;
146
- }>>]>;
147
- export type TMultimodalPrompt = z.infer<typeof TMultimodalPromptSchema>;
148
- export type TUserPrompt = z.infer<typeof TUserPromptSchema>;
149
- /**
150
- * Returns the schema for locator fields.
151
- * This now returns the input schema which is more permissive and suitable for validation.
152
- */
153
- export declare const getMidsceneLocationSchema: () => z.ZodObject<{
154
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
155
- prompt: z.ZodString;
156
- }, "strip", z.ZodTypeAny, {
157
- prompt: string;
158
- }, {
159
- prompt: string;
160
- }>, z.ZodObject<{
161
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
162
- name: z.ZodString;
163
- url: z.ZodString;
164
- }, "strip", z.ZodTypeAny, {
165
- name: string;
166
- url: string;
167
- }, {
168
- name: string;
169
- url: string;
170
- }>, "many">>>;
171
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
172
- }, "strip", z.ZodTypeAny, {
173
- images?: {
174
- name: string;
175
- url: string;
176
- }[] | undefined;
177
- convertHttpImage2Base64?: boolean | undefined;
178
- }, {
179
- images?: {
180
- name: string;
181
- url: string;
182
- }[] | undefined;
183
- convertHttpImage2Base64?: boolean | undefined;
184
- }>>]>;
185
- deepLocate: z.ZodOptional<z.ZodBoolean>;
186
- deepThink: z.ZodOptional<z.ZodBoolean>;
187
- cacheable: z.ZodOptional<z.ZodBoolean>;
188
- xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
189
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
190
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
191
- prompt: z.ZodString;
192
- }, "strip", z.ZodTypeAny, {
193
- prompt: string;
194
- }, {
195
- prompt: string;
196
- }>, z.ZodObject<{
197
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
198
- name: z.ZodString;
199
- url: z.ZodString;
200
- }, "strip", z.ZodTypeAny, {
201
- name: string;
202
- url: string;
203
- }, {
204
- name: string;
205
- url: string;
206
- }>, "many">>>;
207
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
208
- }, "strip", z.ZodTypeAny, {
209
- images?: {
210
- name: string;
211
- url: string;
212
- }[] | undefined;
213
- convertHttpImage2Base64?: boolean | undefined;
214
- }, {
215
- images?: {
216
- name: string;
217
- url: string;
218
- }[] | undefined;
219
- convertHttpImage2Base64?: boolean | undefined;
220
- }>>]>;
221
- deepLocate: z.ZodOptional<z.ZodBoolean>;
222
- deepThink: z.ZodOptional<z.ZodBoolean>;
223
- cacheable: z.ZodOptional<z.ZodBoolean>;
224
- xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
225
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
226
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
227
- prompt: z.ZodString;
228
- }, "strip", z.ZodTypeAny, {
229
- prompt: string;
230
- }, {
231
- prompt: string;
232
- }>, z.ZodObject<{
233
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
234
- name: z.ZodString;
235
- url: z.ZodString;
236
- }, "strip", z.ZodTypeAny, {
237
- name: string;
238
- url: string;
239
- }, {
240
- name: string;
241
- url: string;
242
- }>, "many">>>;
243
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
244
- }, "strip", z.ZodTypeAny, {
245
- images?: {
246
- name: string;
247
- url: string;
248
- }[] | undefined;
249
- convertHttpImage2Base64?: boolean | undefined;
250
- }, {
251
- images?: {
252
- name: string;
253
- url: string;
254
- }[] | undefined;
255
- convertHttpImage2Base64?: boolean | undefined;
256
- }>>]>;
257
- deepLocate: z.ZodOptional<z.ZodBoolean>;
258
- deepThink: z.ZodOptional<z.ZodBoolean>;
259
- cacheable: z.ZodOptional<z.ZodBoolean>;
260
- xpath: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
261
- }, z.ZodTypeAny, "passthrough">>;
262
- export declare const ifMidsceneLocatorField: (field: any) => boolean;
263
- export declare const dumpMidsceneLocatorField: (field: any) => string;
264
- export declare const findAllMidsceneLocatorField: (zodType?: z.ZodType<any>, requiredOnly?: boolean) => string[];
265
- export declare const dumpActionParam: (jsonObject: Record<string, any>, zodSchema: z.ZodType<any>) => Record<string, any>;
266
- /**
267
- * Parse and validate action parameters using Zod schema.
268
- * All fields are validated through Zod, EXCEPT locator fields which are skipped.
269
- * Default values defined in the schema are automatically applied.
270
- *
271
- * Locator fields are special business logic fields with complex validation requirements,
272
- * so they are intentionally excluded from Zod parsing and use existing validation logic.
273
- *
274
- * When shrunkShotToLogicalRatio is provided and !== 1, coordinates in locate fields
275
- * are transformed from screenshot space to logical space.
276
- */
277
- export declare const parseActionParam: (rawParam: Record<string, any> | undefined, zodSchema?: z.ZodType<any>, options?: {
278
- shrunkShotToLogicalRatio?: number;
279
- }) => Record<string, any> | undefined;
280
- export declare const finalizeActionName = "Finalize";
281
- /**
282
- * Get a readable time string for a given timestamp or the current time
283
- * @param format - Optional format string. Supports: YYYY, MM, DD, HH, mm, ss. Default: 'YYYY-MM-DD HH:mm:ss'
284
- * @param timestamp - Optional timestamp in milliseconds. If not provided, uses current system time.
285
- * @returns A formatted time string with format label
286
- */
287
- export declare const getReadableTimeString: (format?: string, timestamp?: number) => string;
288
- export {};