@ui-tars-test/shared 0.3.2

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 (89) hide show
  1. package/dist/base/agent.d.ts +9 -0
  2. package/dist/base/agent.d.ts.map +1 -0
  3. package/dist/base/agent.js +54 -0
  4. package/dist/base/agent.js.map +1 -0
  5. package/dist/base/agent.mjs +10 -0
  6. package/dist/base/agent.mjs.map +1 -0
  7. package/dist/base/index.d.ts +4 -0
  8. package/dist/base/index.d.ts.map +1 -0
  9. package/dist/base/index.js +84 -0
  10. package/dist/base/index.js.map +1 -0
  11. package/dist/base/index.mjs +7 -0
  12. package/dist/base/operator.d.ts +140 -0
  13. package/dist/base/operator.d.ts.map +1 -0
  14. package/dist/base/operator.js +112 -0
  15. package/dist/base/operator.js.map +1 -0
  16. package/dist/base/operator.mjs +75 -0
  17. package/dist/base/operator.mjs.map +1 -0
  18. package/dist/base/parser.d.ts +11 -0
  19. package/dist/base/parser.d.ts.map +1 -0
  20. package/dist/base/parser.js +43 -0
  21. package/dist/base/parser.js.map +1 -0
  22. package/dist/base/parser.mjs +9 -0
  23. package/dist/base/parser.mjs.map +1 -0
  24. package/dist/types/actions.d.ts +224 -0
  25. package/dist/types/actions.d.ts.map +1 -0
  26. package/dist/types/actions.js +155 -0
  27. package/dist/types/actions.js.map +1 -0
  28. package/dist/types/actions.mjs +115 -0
  29. package/dist/types/actions.mjs.map +1 -0
  30. package/dist/types/agents.d.ts +108 -0
  31. package/dist/types/agents.d.ts.map +1 -0
  32. package/dist/types/agents.js +42 -0
  33. package/dist/types/agents.js.map +1 -0
  34. package/dist/types/agents.mjs +8 -0
  35. package/dist/types/agents.mjs.map +1 -0
  36. package/dist/types/archived.d.ts +44 -0
  37. package/dist/types/archived.d.ts.map +1 -0
  38. package/dist/types/archived.js +86 -0
  39. package/dist/types/archived.js.map +1 -0
  40. package/dist/types/archived.mjs +46 -0
  41. package/dist/types/archived.mjs.map +1 -0
  42. package/dist/types/index.d.ts +4 -0
  43. package/dist/types/index.d.ts.map +1 -0
  44. package/dist/types/index.js +84 -0
  45. package/dist/types/index.js.map +1 -0
  46. package/dist/types/index.mjs +7 -0
  47. package/dist/utils/actions.d.ts +15 -0
  48. package/dist/utils/actions.d.ts.map +1 -0
  49. package/dist/utils/actions.js +196 -0
  50. package/dist/utils/actions.js.map +1 -0
  51. package/dist/utils/actions.mjs +156 -0
  52. package/dist/utils/actions.mjs.map +1 -0
  53. package/dist/utils/coordinateNormalizer.d.ts +10 -0
  54. package/dist/utils/coordinateNormalizer.d.ts.map +1 -0
  55. package/dist/utils/coordinateNormalizer.js +59 -0
  56. package/dist/utils/coordinateNormalizer.js.map +1 -0
  57. package/dist/utils/coordinateNormalizer.mjs +25 -0
  58. package/dist/utils/coordinateNormalizer.mjs.map +1 -0
  59. package/dist/utils/index.d.ts +5 -0
  60. package/dist/utils/index.d.ts.map +1 -0
  61. package/dist/utils/index.js +93 -0
  62. package/dist/utils/index.js.map +1 -0
  63. package/dist/utils/index.mjs +8 -0
  64. package/dist/utils/sleep.d.ts +14 -0
  65. package/dist/utils/sleep.d.ts.map +1 -0
  66. package/dist/utils/sleep.js +45 -0
  67. package/dist/utils/sleep.js.map +1 -0
  68. package/dist/utils/sleep.mjs +11 -0
  69. package/dist/utils/sleep.mjs.map +1 -0
  70. package/dist/utils/systemPromptProcessor.d.ts +16 -0
  71. package/dist/utils/systemPromptProcessor.d.ts.map +1 -0
  72. package/dist/utils/systemPromptProcessor.js +61 -0
  73. package/dist/utils/systemPromptProcessor.js.map +1 -0
  74. package/dist/utils/systemPromptProcessor.mjs +24 -0
  75. package/dist/utils/systemPromptProcessor.mjs.map +1 -0
  76. package/package.json +66 -0
  77. package/src/base/agent.ts +13 -0
  78. package/src/base/index.ts +7 -0
  79. package/src/base/operator.ts +221 -0
  80. package/src/base/parser.ts +16 -0
  81. package/src/types/actions.ts +382 -0
  82. package/src/types/agents.ts +128 -0
  83. package/src/types/archived.ts +55 -0
  84. package/src/types/index.ts +8 -0
  85. package/src/utils/actions.ts +244 -0
  86. package/src/utils/coordinateNormalizer.ts +49 -0
  87. package/src/utils/index.ts +9 -0
  88. package/src/utils/sleep.ts +21 -0
  89. package/src/utils/systemPromptProcessor.ts +48 -0
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ function serializeAction(action) {
6
+ const { type, inputs } = action;
7
+ const params = Object.entries(inputs).map(([key, value])=>{
8
+ if ('string' == typeof value) return `${key}='${value}'`;
9
+ if ('object' == typeof value && null !== value) {
10
+ if (value.raw) return `${key}='(${value.raw.x}, ${value.raw.y})'`;
11
+ if (value.referenceBox) return `${key}='<bbox>${value.referenceBox.x1}, ${value.referenceBox.y1}, ${value.referenceBox.x2}, ${value.referenceBox.y2}</bbox>'`;
12
+ if (value.normalized) return `${key}='(${value.normalized.x}, ${value.normalized.y})'`;
13
+ }
14
+ if ('wait' === type && 'number' == typeof value) return `${key}='${value}s'`;
15
+ if ('navigate' === type && 'string' == typeof value) return `url='${value}'`;
16
+ return "unsupported";
17
+ }).join(', ');
18
+ return `${type}(${params})`;
19
+ }
20
+ const actionTypeMap = {
21
+ snapshot: 'screenshot',
22
+ screenshot: 'screenshot',
23
+ take_screenshot: 'screenshot',
24
+ takescreenshot: 'screenshot',
25
+ click: 'click',
26
+ left_click: 'click',
27
+ left_single: 'click',
28
+ leftclick: 'click',
29
+ leftsingle: 'click',
30
+ double_click: 'double_click',
31
+ left_double: 'double_click',
32
+ doubleclick: 'double_click',
33
+ leftdouble: 'double_click',
34
+ right_click: 'right_click',
35
+ right_single: 'right_click',
36
+ rightclick: 'right_click',
37
+ rightsingle: 'right_click',
38
+ middle_click: 'middle_click',
39
+ middle_single: 'middle_click',
40
+ middleclick: 'middle_click',
41
+ middlesingle: 'middle_click',
42
+ move: 'mouse_move',
43
+ move_to: 'mouse_move',
44
+ mouse_move: 'mouse_move',
45
+ moveto: 'mouse_move',
46
+ mousemove: 'mouse_move',
47
+ hover: 'mouse_move',
48
+ mouse_down: 'mouse_down',
49
+ mousedown: 'mouse_down',
50
+ mouse_up: 'mouse_up',
51
+ mouseup: 'mouse_up',
52
+ drag: 'drag',
53
+ select: 'drag',
54
+ left_click_drag: 'drag',
55
+ leftclickdrag: 'drag',
56
+ swipe: 'swipe',
57
+ scroll: 'scroll',
58
+ type: 'type',
59
+ hotkey: 'hotkey',
60
+ press: 'press',
61
+ release: 'release',
62
+ navigate: 'navigate',
63
+ navigate_back: 'navigate_back',
64
+ navigateback: 'navigate_back',
65
+ long_press: 'long_press',
66
+ longpress: 'long_press',
67
+ home: 'press_home',
68
+ press_home: 'press_home',
69
+ presshome: 'press_home',
70
+ back: 'press_back',
71
+ press_back: 'press_back',
72
+ pressback: 'press_back',
73
+ open: 'open_app',
74
+ open_app: 'open_app',
75
+ openapp: 'open_app',
76
+ wait: 'wait',
77
+ finished: 'finished',
78
+ call_user: 'call_user',
79
+ calluser: 'call_user'
80
+ };
81
+ function unifyActionType(name) {
82
+ name = name.toLowerCase();
83
+ return actionTypeMap[name] || name;
84
+ }
85
+ const actionInputNameMap = {
86
+ start: 'start',
87
+ start_box: 'start',
88
+ startbox: 'start',
89
+ start_point: 'start',
90
+ start_position: 'start',
91
+ start_coordinate: 'start',
92
+ start_coordinates: 'start',
93
+ end: 'end',
94
+ end_box: 'end',
95
+ endbox: 'end',
96
+ end_point: 'end',
97
+ end_position: 'end',
98
+ end_coordinate: 'end',
99
+ end_coordinates: 'end',
100
+ point: 'point',
101
+ position: 'point',
102
+ coordinate: 'point',
103
+ coordinates: 'point',
104
+ button: 'button',
105
+ mouse_button: 'button',
106
+ mousebutton: 'button',
107
+ direction: 'direction',
108
+ dir: 'direction',
109
+ scroll_direction: 'direction',
110
+ scrolldirection: 'direction',
111
+ content: 'content',
112
+ text: 'content',
113
+ input_text: 'content',
114
+ inputtext: 'content',
115
+ type: 'content',
116
+ key: 'key',
117
+ keyname: 'key',
118
+ hotkey: 'key',
119
+ keyboard_key: 'key',
120
+ keyboardkey: 'key',
121
+ url: 'url',
122
+ link: 'url',
123
+ website: 'url',
124
+ name: 'name',
125
+ appname: 'name',
126
+ app_name: 'name',
127
+ application: 'name',
128
+ time: 'time',
129
+ duration: 'time',
130
+ wait_time: 'time',
131
+ waittime: 'time',
132
+ delay: 'time'
133
+ };
134
+ const actionTypeSpecificMappings = {
135
+ navigate: {
136
+ content: 'url',
137
+ url: 'url'
138
+ },
139
+ open_app: {
140
+ content: 'name',
141
+ appname: 'name',
142
+ app_name: 'name',
143
+ name: 'name'
144
+ }
145
+ };
146
+ function unifyActionInputName(actionType, inputName) {
147
+ actionType = actionType.toLowerCase();
148
+ inputName = inputName.toLowerCase();
149
+ actionType = unifyActionType(actionType);
150
+ const typeSpecificMap = actionTypeSpecificMappings[actionType];
151
+ if (typeSpecificMap && typeSpecificMap[inputName]) return typeSpecificMap[inputName];
152
+ return actionInputNameMap[inputName] || inputName;
153
+ }
154
+ export { serializeAction, unifyActionInputName, unifyActionType };
155
+
156
+ //# sourceMappingURL=actions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/actions.mjs","sources":["webpack://@ui-tars-test/shared/./src/utils/actions.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { BaseAction } from '../types';\n\n/**\n * Serializes a BaseAction into a string representation\n * Format: \"actionType(param1='value1', param2='value2', ...)\"\n */\nexport function serializeAction<T extends string, I extends Record<string, any>>(\n action: BaseAction<T, I>,\n): string {\n const { type, inputs } = action;\n const params = Object.entries(inputs)\n .map(([key, value]) => {\n if (typeof value === 'string') {\n return `${key}='${value}'`;\n }\n if (typeof value === 'object' && value !== null) {\n if (value.raw) {\n return `${key}='(${value.raw.x}, ${value.raw.y})'`;\n }\n if (value.referenceBox) {\n return `${key}='<bbox>${value.referenceBox.x1}, ${value.referenceBox.y1}, ${value.referenceBox.x2}, ${value.referenceBox.y2}</bbox>'`;\n }\n if (value.normalized) {\n return `${key}='(${value.normalized.x}, ${value.normalized.y})'`;\n }\n }\n if (type === 'wait' && typeof value === 'number') {\n return `${key}='${value}s'`;\n }\n if (type === 'navigate' && typeof value === 'string') {\n return `url='${value}'`;\n }\n return `unsupported`;\n })\n .join(', ');\n return `${type}(${params})`;\n}\n\nconst actionTypeMap: Record<string, string> = {\n // ---- ScreenShotAction ----\n\n snapshot: 'screenshot',\n screenshot: 'screenshot',\n take_screenshot: 'screenshot',\n takescreenshot: 'screenshot',\n\n // ---- Mouse Actions ----\n\n // click\n click: 'click',\n left_click: 'click',\n left_single: 'click',\n leftclick: 'click',\n leftsingle: 'click',\n // double click\n double_click: 'double_click',\n left_double: 'double_click',\n doubleclick: 'double_click',\n leftdouble: 'double_click',\n // right click\n right_click: 'right_click',\n right_single: 'right_click',\n rightclick: 'right_click',\n rightsingle: 'right_click',\n // middle click\n middle_click: 'middle_click',\n middle_single: 'middle_click',\n middleclick: 'middle_click',\n middlesingle: 'middle_click',\n // mouse move\n move: 'mouse_move',\n move_to: 'mouse_move',\n mouse_move: 'mouse_move',\n moveto: 'mouse_move',\n mousemove: 'mouse_move',\n hover: 'mouse_move',\n // mouse down\n mouse_down: 'mouse_down',\n mousedown: 'mouse_down',\n // mouse up\n mouse_up: 'mouse_up',\n mouseup: 'mouse_up',\n // drag\n drag: 'drag',\n select: 'drag',\n left_click_drag: 'drag',\n leftclickdrag: 'drag',\n // swipe\n swipe: 'swipe',\n // scroll\n scroll: 'scroll',\n\n // ---- Keyboard Actions ----\n\n type: 'type',\n hotkey: 'hotkey',\n press: 'press',\n release: 'release',\n\n // ---- Browser Actions ----\n\n navigate: 'navigate',\n navigate_back: 'navigate_back',\n navigateback: 'navigate_back',\n\n // ---- App Actions ----\n\n // long press\n long_press: 'long_press',\n longpress: 'long_press',\n // home\n home: 'press_home',\n press_home: 'press_home',\n presshome: 'press_home',\n // back\n back: 'press_back',\n press_back: 'press_back',\n pressback: 'press_back',\n // open app\n open: 'open_app',\n open_app: 'open_app',\n openapp: 'open_app',\n\n // ---- Agent Actions ----\n\n wait: 'wait',\n finished: 'finished',\n call_user: 'call_user',\n calluser: 'call_user',\n};\n\nexport function unifyActionType(name: string) {\n name = name.toLowerCase();\n return actionTypeMap[name] || name;\n}\n\nconst actionInputNameMap: Record<string, string> = {\n // ---- Start related fields ----\n start: 'start',\n start_box: 'start',\n startbox: 'start',\n start_point: 'start',\n start_position: 'start',\n start_coordinate: 'start',\n start_coordinates: 'start',\n\n // ---- End related fields ----\n end: 'end',\n end_box: 'end',\n endbox: 'end',\n end_point: 'end',\n end_position: 'end',\n end_coordinate: 'end',\n end_coordinates: 'end',\n\n // ---- Point related fields ----\n point: 'point',\n position: 'point',\n coordinate: 'point',\n coordinates: 'point',\n\n // ---- Button related fields ----\n button: 'button',\n mouse_button: 'button',\n mousebutton: 'button',\n\n // ---- Direction related fields ----\n direction: 'direction',\n dir: 'direction',\n scroll_direction: 'direction',\n scrolldirection: 'direction',\n\n // ---- Content related fields ----\n content: 'content',\n text: 'content',\n input_text: 'content',\n inputtext: 'content',\n type: 'content',\n\n // ---- Key related fields ----\n key: 'key',\n keyname: 'key',\n hotkey: 'key',\n keyboard_key: 'key',\n keyboardkey: 'key',\n\n // ---- URL related fields ----\n url: 'url',\n link: 'url',\n website: 'url',\n\n // ---- Name related fields ----\n name: 'name',\n appname: 'name',\n app_name: 'name',\n application: 'name',\n\n // ---- Time related fields ----\n time: 'time',\n duration: 'time',\n wait_time: 'time',\n waittime: 'time',\n delay: 'time',\n};\n\n// Special mappings based on action type\nconst actionTypeSpecificMappings: Record<string, Record<string, string>> = {\n navigate: {\n content: 'url',\n url: 'url',\n },\n open_app: {\n content: 'name',\n appname: 'name',\n app_name: 'name',\n name: 'name',\n },\n};\n\n/**\n * Standardizes action input field names using mapping tables\n * @param actionType The type of action being performed\n * @param inputName The original input field name\n * @returns The standardized input field name\n */\nexport function unifyActionInputName(actionType: string, inputName: string): string {\n actionType = actionType.toLowerCase();\n inputName = inputName.toLowerCase();\n actionType = unifyActionType(actionType);\n // First check for action type specific mappings\n const typeSpecificMap = actionTypeSpecificMappings[actionType];\n if (typeSpecificMap && typeSpecificMap[inputName]) {\n return typeSpecificMap[inputName];\n }\n // Then check general mappings\n return actionInputNameMap[inputName] || inputName;\n}\n"],"names":["serializeAction","action","type","inputs","params","Object","key","value","actionTypeMap","unifyActionType","name","actionInputNameMap","actionTypeSpecificMappings","unifyActionInputName","actionType","inputName","typeSpecificMap"],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import { BaseAction, NormalizeCoordinates } from '../types';
2
+ /**
3
+ * Normalizes coordinates in a BaseAction object
4
+ * Processes point, start, and end coordinate fields if they exist
5
+ * @param action - The BaseAction object to normalize coordinates for
6
+ * @param normalizeCoordinates - The coordinate normalization function to use
7
+ * @returns The BaseAction object with normalized coordinates added
8
+ */
9
+ export declare function normalizeActionCoords<T extends BaseAction>(action: T, normalizeCoordinates: NormalizeCoordinates): T;
10
+ //# sourceMappingURL=coordinateNormalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinateNormalizer.d.ts","sourceRoot":"","sources":["../../src/utils/coordinateNormalizer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAe,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEzE;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,UAAU,EACxD,MAAM,EAAE,CAAC,EACT,oBAAoB,EAAE,oBAAoB,GACzC,CAAC,CA+BH"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_require__ = {};
7
+ (()=>{
8
+ __webpack_require__.d = (exports1, definition)=>{
9
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
10
+ enumerable: true,
11
+ get: definition[key]
12
+ });
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ normalizeActionCoords: ()=>normalizeActionCoords
32
+ });
33
+ function normalizeActionCoords(action, normalizeCoordinates) {
34
+ const normalizedAction = {
35
+ ...action
36
+ };
37
+ if (normalizedAction.inputs && 'point' in normalizedAction.inputs && normalizedAction.inputs.point) {
38
+ const normalizedResult = normalizeCoordinates(normalizedAction.inputs.point);
39
+ normalizedAction.inputs.point = normalizedResult.normalized;
40
+ }
41
+ if (normalizedAction.inputs && 'start' in normalizedAction.inputs && normalizedAction.inputs.start) {
42
+ const normalizedResult = normalizeCoordinates(normalizedAction.inputs.start);
43
+ normalizedAction.inputs.start = normalizedResult.normalized;
44
+ }
45
+ if (normalizedAction.inputs && 'end' in normalizedAction.inputs && normalizedAction.inputs.end) {
46
+ const normalizedResult = normalizeCoordinates(normalizedAction.inputs.end);
47
+ normalizedAction.inputs.end = normalizedResult.normalized;
48
+ }
49
+ return normalizedAction;
50
+ }
51
+ exports.normalizeActionCoords = __webpack_exports__.normalizeActionCoords;
52
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
53
+ "normalizeActionCoords"
54
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
55
+ Object.defineProperty(exports, '__esModule', {
56
+ value: true
57
+ });
58
+
59
+ //# sourceMappingURL=coordinateNormalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/coordinateNormalizer.js","sources":["webpack://@ui-tars-test/shared/webpack/runtime/define_property_getters","webpack://@ui-tars-test/shared/webpack/runtime/has_own_property","webpack://@ui-tars-test/shared/webpack/runtime/make_namespace_object","webpack://@ui-tars-test/shared/./src/utils/coordinateNormalizer.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseAction, Coordinates, NormalizeCoordinates } from '../types';\n\n/**\n * Normalizes coordinates in a BaseAction object\n * Processes point, start, and end coordinate fields if they exist\n * @param action - The BaseAction object to normalize coordinates for\n * @param normalizeCoordinates - The coordinate normalization function to use\n * @returns The BaseAction object with normalized coordinates added\n */\nexport function normalizeActionCoords<T extends BaseAction>(\n action: T,\n normalizeCoordinates: NormalizeCoordinates,\n): T {\n const normalizedAction = { ...action };\n\n // Normalize point coordinates\n if (\n normalizedAction.inputs &&\n 'point' in normalizedAction.inputs &&\n normalizedAction.inputs.point\n ) {\n const normalizedResult = normalizeCoordinates(normalizedAction.inputs.point as Coordinates);\n normalizedAction.inputs.point = normalizedResult.normalized;\n }\n\n // Normalize start coordinates\n if (\n normalizedAction.inputs &&\n 'start' in normalizedAction.inputs &&\n normalizedAction.inputs.start\n ) {\n const normalizedResult = normalizeCoordinates(normalizedAction.inputs.start as Coordinates);\n normalizedAction.inputs.start = normalizedResult.normalized;\n }\n\n // Normalize end coordinates\n // eslint-disable-next-line prettier/prettier\n if (normalizedAction.inputs && 'end' in normalizedAction.inputs && normalizedAction.inputs.end) {\n const normalizedResult = normalizeCoordinates(normalizedAction.inputs.end as Coordinates);\n normalizedAction.inputs.end = normalizedResult.normalized;\n }\n\n return normalizedAction;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","normalizeActionCoords","action","normalizeCoordinates","normalizedAction","normalizedResult"],"mappings":";;;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACQO,SAASI,sBACdC,MAAS,EACTC,oBAA0C;IAE1C,MAAMC,mBAAmB;QAAE,GAAGF,MAAM;IAAC;IAGrC,IACEE,iBAAiB,MAAM,IACvB,WAAWA,iBAAiB,MAAM,IAClCA,iBAAiB,MAAM,CAAC,KAAK,EAC7B;QACA,MAAMC,mBAAmBF,qBAAqBC,iBAAiB,MAAM,CAAC,KAAK;QAC3EA,iBAAiB,MAAM,CAAC,KAAK,GAAGC,iBAAiB,UAAU;IAC7D;IAGA,IACED,iBAAiB,MAAM,IACvB,WAAWA,iBAAiB,MAAM,IAClCA,iBAAiB,MAAM,CAAC,KAAK,EAC7B;QACA,MAAMC,mBAAmBF,qBAAqBC,iBAAiB,MAAM,CAAC,KAAK;QAC3EA,iBAAiB,MAAM,CAAC,KAAK,GAAGC,iBAAiB,UAAU;IAC7D;IAIA,IAAID,iBAAiB,MAAM,IAAI,SAASA,iBAAiB,MAAM,IAAIA,iBAAiB,MAAM,CAAC,GAAG,EAAE;QAC9F,MAAMC,mBAAmBF,qBAAqBC,iBAAiB,MAAM,CAAC,GAAG;QACzEA,iBAAiB,MAAM,CAAC,GAAG,GAAGC,iBAAiB,UAAU;IAC3D;IAEA,OAAOD;AACT"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ function normalizeActionCoords(action, normalizeCoordinates) {
6
+ const normalizedAction = {
7
+ ...action
8
+ };
9
+ if (normalizedAction.inputs && 'point' in normalizedAction.inputs && normalizedAction.inputs.point) {
10
+ const normalizedResult = normalizeCoordinates(normalizedAction.inputs.point);
11
+ normalizedAction.inputs.point = normalizedResult.normalized;
12
+ }
13
+ if (normalizedAction.inputs && 'start' in normalizedAction.inputs && normalizedAction.inputs.start) {
14
+ const normalizedResult = normalizeCoordinates(normalizedAction.inputs.start);
15
+ normalizedAction.inputs.start = normalizedResult.normalized;
16
+ }
17
+ if (normalizedAction.inputs && 'end' in normalizedAction.inputs && normalizedAction.inputs.end) {
18
+ const normalizedResult = normalizeCoordinates(normalizedAction.inputs.end);
19
+ normalizedAction.inputs.end = normalizedResult.normalized;
20
+ }
21
+ return normalizedAction;
22
+ }
23
+ export { normalizeActionCoords };
24
+
25
+ //# sourceMappingURL=coordinateNormalizer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/coordinateNormalizer.mjs","sources":["webpack://@ui-tars-test/shared/./src/utils/coordinateNormalizer.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BaseAction, Coordinates, NormalizeCoordinates } from '../types';\n\n/**\n * Normalizes coordinates in a BaseAction object\n * Processes point, start, and end coordinate fields if they exist\n * @param action - The BaseAction object to normalize coordinates for\n * @param normalizeCoordinates - The coordinate normalization function to use\n * @returns The BaseAction object with normalized coordinates added\n */\nexport function normalizeActionCoords<T extends BaseAction>(\n action: T,\n normalizeCoordinates: NormalizeCoordinates,\n): T {\n const normalizedAction = { ...action };\n\n // Normalize point coordinates\n if (\n normalizedAction.inputs &&\n 'point' in normalizedAction.inputs &&\n normalizedAction.inputs.point\n ) {\n const normalizedResult = normalizeCoordinates(normalizedAction.inputs.point as Coordinates);\n normalizedAction.inputs.point = normalizedResult.normalized;\n }\n\n // Normalize start coordinates\n if (\n normalizedAction.inputs &&\n 'start' in normalizedAction.inputs &&\n normalizedAction.inputs.start\n ) {\n const normalizedResult = normalizeCoordinates(normalizedAction.inputs.start as Coordinates);\n normalizedAction.inputs.start = normalizedResult.normalized;\n }\n\n // Normalize end coordinates\n // eslint-disable-next-line prettier/prettier\n if (normalizedAction.inputs && 'end' in normalizedAction.inputs && normalizedAction.inputs.end) {\n const normalizedResult = normalizeCoordinates(normalizedAction.inputs.end as Coordinates);\n normalizedAction.inputs.end = normalizedResult.normalized;\n }\n\n return normalizedAction;\n}\n"],"names":["normalizeActionCoords","action","normalizeCoordinates","normalizedAction","normalizedResult"],"mappings":";;;;AAcO,SAASA,sBACdC,MAAS,EACTC,oBAA0C;IAE1C,MAAMC,mBAAmB;QAAE,GAAGF,MAAM;IAAC;IAGrC,IACEE,iBAAiB,MAAM,IACvB,WAAWA,iBAAiB,MAAM,IAClCA,iBAAiB,MAAM,CAAC,KAAK,EAC7B;QACA,MAAMC,mBAAmBF,qBAAqBC,iBAAiB,MAAM,CAAC,KAAK;QAC3EA,iBAAiB,MAAM,CAAC,KAAK,GAAGC,iBAAiB,UAAU;IAC7D;IAGA,IACED,iBAAiB,MAAM,IACvB,WAAWA,iBAAiB,MAAM,IAClCA,iBAAiB,MAAM,CAAC,KAAK,EAC7B;QACA,MAAMC,mBAAmBF,qBAAqBC,iBAAiB,MAAM,CAAC,KAAK;QAC3EA,iBAAiB,MAAM,CAAC,KAAK,GAAGC,iBAAiB,UAAU;IAC7D;IAIA,IAAID,iBAAiB,MAAM,IAAI,SAASA,iBAAiB,MAAM,IAAIA,iBAAiB,MAAM,CAAC,GAAG,EAAE;QAC9F,MAAMC,mBAAmBF,qBAAqBC,iBAAiB,MAAM,CAAC,GAAG;QACzEA,iBAAiB,MAAM,CAAC,GAAG,GAAGC,iBAAiB,UAAU;IAC3D;IAEA,OAAOD;AACT"}
@@ -0,0 +1,5 @@
1
+ export * from './actions';
2
+ export * from './sleep';
3
+ export * from './systemPromptProcessor';
4
+ export * from './coordinateNormalizer';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAKA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_modules__ = {
7
+ "./actions": function(module) {
8
+ module.exports = require("./actions.js");
9
+ },
10
+ "./coordinateNormalizer": function(module) {
11
+ module.exports = require("./coordinateNormalizer.js");
12
+ },
13
+ "./sleep": function(module) {
14
+ module.exports = require("./sleep.js");
15
+ },
16
+ "./systemPromptProcessor": function(module) {
17
+ module.exports = require("./systemPromptProcessor.js");
18
+ }
19
+ };
20
+ var __webpack_module_cache__ = {};
21
+ function __webpack_require__(moduleId) {
22
+ var cachedModule = __webpack_module_cache__[moduleId];
23
+ if (void 0 !== cachedModule) return cachedModule.exports;
24
+ var module = __webpack_module_cache__[moduleId] = {
25
+ exports: {}
26
+ };
27
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
28
+ return module.exports;
29
+ }
30
+ (()=>{
31
+ __webpack_require__.n = (module)=>{
32
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
33
+ __webpack_require__.d(getter, {
34
+ a: getter
35
+ });
36
+ return getter;
37
+ };
38
+ })();
39
+ (()=>{
40
+ __webpack_require__.d = (exports1, definition)=>{
41
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
42
+ enumerable: true,
43
+ get: definition[key]
44
+ });
45
+ };
46
+ })();
47
+ (()=>{
48
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
49
+ })();
50
+ (()=>{
51
+ __webpack_require__.r = (exports1)=>{
52
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
53
+ value: 'Module'
54
+ });
55
+ Object.defineProperty(exports1, '__esModule', {
56
+ value: true
57
+ });
58
+ };
59
+ })();
60
+ var __webpack_exports__ = {};
61
+ (()=>{
62
+ __webpack_require__.r(__webpack_exports__);
63
+ var _actions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./actions");
64
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
65
+ for(var __WEBPACK_IMPORT_KEY__ in _actions__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
66
+ return _actions__WEBPACK_IMPORTED_MODULE_0__[key];
67
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
68
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
69
+ var _sleep__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./sleep");
70
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
71
+ for(var __WEBPACK_IMPORT_KEY__ in _sleep__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
72
+ return _sleep__WEBPACK_IMPORTED_MODULE_1__[key];
73
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
74
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
75
+ var _systemPromptProcessor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./systemPromptProcessor");
76
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
77
+ for(var __WEBPACK_IMPORT_KEY__ in _systemPromptProcessor__WEBPACK_IMPORTED_MODULE_2__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
78
+ return _systemPromptProcessor__WEBPACK_IMPORTED_MODULE_2__[key];
79
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
80
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
81
+ var _coordinateNormalizer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./coordinateNormalizer");
82
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
83
+ for(var __WEBPACK_IMPORT_KEY__ in _coordinateNormalizer__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
84
+ return _coordinateNormalizer__WEBPACK_IMPORTED_MODULE_3__[key];
85
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
86
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
87
+ })();
88
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
89
+ Object.defineProperty(exports, '__esModule', {
90
+ value: true
91
+ });
92
+
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/index.js","sources":["webpack://@ui-tars-test/shared/webpack/runtime/compat_get_default_export","webpack://@ui-tars-test/shared/webpack/runtime/define_property_getters","webpack://@ui-tars-test/shared/webpack/runtime/has_own_property","webpack://@ui-tars-test/shared/webpack/runtime/make_namespace_object"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export * from "./actions.mjs";
6
+ export * from "./sleep.mjs";
7
+ export * from "./systemPromptProcessor.mjs";
8
+ export * from "./coordinateNormalizer.mjs";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Sleeps for a specified duration
3
+ * @param time The duration to sleep
4
+ * @param unit The time unit ('ms' for milliseconds or 's' for seconds), defaults to 'ms'
5
+ *
6
+ * Examples:
7
+ * ```
8
+ * await sleep(1000); // Sleeps for 1000 milliseconds (1 second)
9
+ * await sleep(1, 's'); // Sleeps for 1 second
10
+ * await sleep(500, 'ms'); // Sleeps for 500 milliseconds
11
+ * ```
12
+ */
13
+ export declare function sleep(time: number, unit?: 'ms' | 's'): Promise<void>;
14
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAI,GAAG,GAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhF"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_require__ = {};
7
+ (()=>{
8
+ __webpack_require__.d = (exports1, definition)=>{
9
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
10
+ enumerable: true,
11
+ get: definition[key]
12
+ });
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ sleep: ()=>sleep
32
+ });
33
+ async function sleep(time, unit = 'ms') {
34
+ const ms = 's' === unit ? 1000 * time : time;
35
+ return new Promise((resolve)=>setTimeout(resolve, ms));
36
+ }
37
+ exports.sleep = __webpack_exports__.sleep;
38
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
39
+ "sleep"
40
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
41
+ Object.defineProperty(exports, '__esModule', {
42
+ value: true
43
+ });
44
+
45
+ //# sourceMappingURL=sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/sleep.js","sources":["webpack://@ui-tars-test/shared/webpack/runtime/define_property_getters","webpack://@ui-tars-test/shared/webpack/runtime/has_own_property","webpack://@ui-tars-test/shared/webpack/runtime/make_namespace_object","webpack://@ui-tars-test/shared/./src/utils/sleep.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Sleeps for a specified duration\n * @param time The duration to sleep\n * @param unit The time unit ('ms' for milliseconds or 's' for seconds), defaults to 'ms'\n *\n * Examples:\n * ```\n * await sleep(1000); // Sleeps for 1000 milliseconds (1 second)\n * await sleep(1, 's'); // Sleeps for 1 second\n * await sleep(500, 'ms'); // Sleeps for 500 milliseconds\n * ```\n */\nexport async function sleep(time: number, unit: 'ms' | 's' = 'ms'): Promise<void> {\n const ms = unit === 's' ? time * 1000 : time;\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","sleep","time","unit","ms","Promise","resolve","setTimeout"],"mappings":";;;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACWO,eAAeI,MAAMC,IAAY,EAAEC,OAAmB,IAAI;IAC/D,MAAMC,KAAKD,AAAS,QAATA,OAAeD,AAAO,OAAPA,OAAcA;IACxC,OAAO,IAAIG,QAAQ,CAACC,UAAYC,WAAWD,SAASF;AACtD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ async function sleep(time, unit = 'ms') {
6
+ const ms = 's' === unit ? 1000 * time : time;
7
+ return new Promise((resolve)=>setTimeout(resolve, ms));
8
+ }
9
+ export { sleep };
10
+
11
+ //# sourceMappingURL=sleep.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/sleep.mjs","sources":["webpack://@ui-tars-test/shared/./src/utils/sleep.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Sleeps for a specified duration\n * @param time The duration to sleep\n * @param unit The time unit ('ms' for milliseconds or 's' for seconds), defaults to 'ms'\n *\n * Examples:\n * ```\n * await sleep(1000); // Sleeps for 1000 milliseconds (1 second)\n * await sleep(1, 's'); // Sleeps for 1 second\n * await sleep(500, 'ms'); // Sleeps for 500 milliseconds\n * ```\n */\nexport async function sleep(time: number, unit: 'ms' | 's' = 'ms'): Promise<void> {\n const ms = unit === 's' ? time * 1000 : time;\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"names":["sleep","time","unit","ms","Promise","resolve","setTimeout"],"mappings":";;;;AAiBO,eAAeA,MAAMC,IAAY,EAAEC,OAAmB,IAAI;IAC/D,MAAMC,KAAKD,AAAS,QAATA,OAAeD,AAAO,OAAPA,OAAcA;IACxC,OAAO,IAAIG,QAAQ,CAACC,UAAYC,WAAWD,SAASF;AACtD"}
@@ -0,0 +1,16 @@
1
+ import { SystemPromptTemplate } from '../types/agents';
2
+ import { SupportedActionType } from '../types/actions';
3
+ /**
4
+ * Assemble system prompt template by replacing placeholders with actual values
5
+ * @param template - The system prompt template configuration
6
+ * @param supportedActions - Array of supported action types
7
+ * @returns Assembled system prompt string with placeholders replaced
8
+ */
9
+ export declare function assembleSystemPrompt(template: SystemPromptTemplate, supportedActions: SupportedActionType[]): string;
10
+ /**
11
+ * Type guard to check if a system prompt is a template object
12
+ * @param systemPrompt - The system prompt to check
13
+ * @returns Whether the system prompt is a SystemPromptTemplate
14
+ */
15
+ export declare function isSystemPromptTemplate(systemPrompt: string | SystemPromptTemplate): systemPrompt is SystemPromptTemplate;
16
+ //# sourceMappingURL=systemPromptProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemPromptProcessor.d.ts","sourceRoot":"","sources":["../../src/utils/systemPromptProcessor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAA4B,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,oBAAoB,EAC9B,gBAAgB,EAAE,mBAAmB,EAAE,GACtC,MAAM,CAmBR;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,GAAG,oBAAoB,GAC1C,YAAY,IAAI,oBAAoB,CAEtC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_require__ = {};
7
+ (()=>{
8
+ __webpack_require__.d = (exports1, definition)=>{
9
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
10
+ enumerable: true,
11
+ get: definition[key]
12
+ });
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ isSystemPromptTemplate: ()=>isSystemPromptTemplate,
32
+ assembleSystemPrompt: ()=>assembleSystemPrompt
33
+ });
34
+ const agents_js_namespaceObject = require("../types/agents.js");
35
+ function assembleSystemPrompt(template, supportedActions) {
36
+ let assembledPrompt = template.template;
37
+ if (template.actionsToString) {
38
+ const actionSpacePlaceholder = `{{${agents_js_namespaceObject.ACTION_SPACE_PLACEHOLDER}}}`;
39
+ const realActionSpaces = template.actionsToString(supportedActions);
40
+ assembledPrompt = assembledPrompt.replace(actionSpacePlaceholder, realActionSpaces || '');
41
+ }
42
+ if (template.placeholders) Object.entries(template.placeholders).forEach(([key, value])=>{
43
+ const placeholder = `{{${key}}}`;
44
+ assembledPrompt = assembledPrompt.replace(new RegExp(placeholder, 'g'), String(value));
45
+ });
46
+ return assembledPrompt;
47
+ }
48
+ function isSystemPromptTemplate(systemPrompt) {
49
+ return 'object' == typeof systemPrompt && 'template' in systemPrompt;
50
+ }
51
+ exports.assembleSystemPrompt = __webpack_exports__.assembleSystemPrompt;
52
+ exports.isSystemPromptTemplate = __webpack_exports__.isSystemPromptTemplate;
53
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
54
+ "assembleSystemPrompt",
55
+ "isSystemPromptTemplate"
56
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
57
+ Object.defineProperty(exports, '__esModule', {
58
+ value: true
59
+ });
60
+
61
+ //# sourceMappingURL=systemPromptProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/systemPromptProcessor.js","sources":["webpack://@ui-tars-test/shared/webpack/runtime/define_property_getters","webpack://@ui-tars-test/shared/webpack/runtime/has_own_property","webpack://@ui-tars-test/shared/webpack/runtime/make_namespace_object","webpack://@ui-tars-test/shared/./src/utils/systemPromptProcessor.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { SystemPromptTemplate, ACTION_SPACE_PLACEHOLDER } from '../types/agents';\nimport { SupportedActionType } from '../types/actions';\n\n/**\n * Assemble system prompt template by replacing placeholders with actual values\n * @param template - The system prompt template configuration\n * @param supportedActions - Array of supported action types\n * @returns Assembled system prompt string with placeholders replaced\n */\nexport function assembleSystemPrompt(\n template: SystemPromptTemplate,\n supportedActions: SupportedActionType[],\n): string {\n let assembledPrompt = template.template;\n\n // Replace action space placeholder if actionsToString function is provided\n if (template.actionsToString) {\n const actionSpacePlaceholder = `{{${ACTION_SPACE_PLACEHOLDER}}}`;\n const realActionSpaces = template.actionsToString(supportedActions);\n assembledPrompt = assembledPrompt.replace(actionSpacePlaceholder, realActionSpaces || '');\n }\n\n // Handle other custom placeholders replacement\n if (template.placeholders) {\n Object.entries(template.placeholders).forEach(([key, value]) => {\n const placeholder = `{{${key}}}`;\n assembledPrompt = assembledPrompt.replace(new RegExp(placeholder, 'g'), String(value));\n });\n }\n\n return assembledPrompt;\n}\n\n/**\n * Type guard to check if a system prompt is a template object\n * @param systemPrompt - The system prompt to check\n * @returns Whether the system prompt is a SystemPromptTemplate\n */\nexport function isSystemPromptTemplate(\n systemPrompt: string | SystemPromptTemplate,\n): systemPrompt is SystemPromptTemplate {\n return typeof systemPrompt === 'object' && 'template' in systemPrompt;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","assembleSystemPrompt","template","supportedActions","assembledPrompt","actionSpacePlaceholder","ACTION_SPACE_PLACEHOLDER","realActionSpaces","value","placeholder","RegExp","String","isSystemPromptTemplate","systemPrompt"],"mappings":";;;;;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACQO,SAASI,qBACdC,QAA8B,EAC9BC,gBAAuC;IAEvC,IAAIC,kBAAkBF,SAAS,QAAQ;IAGvC,IAAIA,SAAS,eAAe,EAAE;QAC5B,MAAMG,yBAAyB,CAAC,EAAE,EAAEC,0BAAAA,wBAAwBA,CAAC,EAAE,CAAC;QAChE,MAAMC,mBAAmBL,SAAS,eAAe,CAACC;QAClDC,kBAAkBA,gBAAgB,OAAO,CAACC,wBAAwBE,oBAAoB;IACxF;IAGA,IAAIL,SAAS,YAAY,EACvBL,OAAO,OAAO,CAACK,SAAS,YAAY,EAAE,OAAO,CAAC,CAAC,CAACN,KAAKY,MAAM;QACzD,MAAMC,cAAc,CAAC,EAAE,EAAEb,IAAI,EAAE,CAAC;QAChCQ,kBAAkBA,gBAAgB,OAAO,CAAC,IAAIM,OAAOD,aAAa,MAAME,OAAOH;IACjF;IAGF,OAAOJ;AACT;AAOO,SAASQ,uBACdC,YAA2C;IAE3C,OAAO,AAAwB,YAAxB,OAAOA,gBAA6B,cAAcA;AAC3D"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { ACTION_SPACE_PLACEHOLDER } from "../types/agents.mjs";
6
+ function assembleSystemPrompt(template, supportedActions) {
7
+ let assembledPrompt = template.template;
8
+ if (template.actionsToString) {
9
+ const actionSpacePlaceholder = `{{${ACTION_SPACE_PLACEHOLDER}}}`;
10
+ const realActionSpaces = template.actionsToString(supportedActions);
11
+ assembledPrompt = assembledPrompt.replace(actionSpacePlaceholder, realActionSpaces || '');
12
+ }
13
+ if (template.placeholders) Object.entries(template.placeholders).forEach(([key, value])=>{
14
+ const placeholder = `{{${key}}}`;
15
+ assembledPrompt = assembledPrompt.replace(new RegExp(placeholder, 'g'), String(value));
16
+ });
17
+ return assembledPrompt;
18
+ }
19
+ function isSystemPromptTemplate(systemPrompt) {
20
+ return 'object' == typeof systemPrompt && 'template' in systemPrompt;
21
+ }
22
+ export { assembleSystemPrompt, isSystemPromptTemplate };
23
+
24
+ //# sourceMappingURL=systemPromptProcessor.mjs.map