@ui-tars/sdk
Version:
A powerful cross-platform(ANY device/platform) toolkit for building GUI automation agents for UI-TARS
133 lines (124 loc) • 4.95 kB
JavaScript
/**
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
DEFAULT_ACTION_SPACES: ()=>DEFAULT_ACTION_SPACES,
DEFAULT_CONTEXT: ()=>DEFAULT_CONTEXT,
DEFAULT_FACTORS: ()=>DEFAULT_FACTORS,
INTERNAL_ACTION_SPACES_ENUM: ()=>INTERNAL_ACTION_SPACES_ENUM,
MAX_PIXELS: ()=>MAX_PIXELS,
MAX_SNAPSHOT_ERR_CNT: ()=>MAX_SNAPSHOT_ERR_CNT,
SYSTEM_PROMPT: ()=>SYSTEM_PROMPT,
SYSTEM_PROMPT_TEMPLATE: ()=>SYSTEM_PROMPT_TEMPLATE
});
const MAX_SNAPSHOT_ERR_CNT = 10;
const DEFAULT_FACTORS = [
1000,
1000
];
const MAX_PIXELS = 1058400;
const SYSTEM_PROMPT = `You are a GUI agent. You are given a task and your action history, with screenshots. You need to perform the next action to complete the task.
## Output Format
\`\`\`
Thought: ...
Action: ...
\`\`\`
## Action Space
click(start_box='[x1, y1, x2, y2]')
left_double(start_box='[x1, y1, x2, y2]')
right_single(start_box='[x1, y1, x2, y2]')
drag(start_box='[x1, y1, x2, y2]', end_box='[x3, y3, x4, y4]')
hotkey(key='')
type(content='') #If you want to submit your input, use "\\n" at the end of \`content\`.
scroll(start_box='[x1, y1, x2, y2]', direction='down or up or right or left')
wait() #Sleep for 5s and take a screenshot to check for any changes.
finished()
call_user() # Submit the task and call the user when the task is unsolvable, or when you need the user's help.
## Note
- Write a small plan and finally summarize your next action (with its target element) in one sentence in \`Thought\` part.
## User Instruction
`;
const SYSTEM_PROMPT_TEMPLATE = `You are a GUI agent. You are given a task and your action history, with screenshots. You need to perform the next action to complete the task.
## Output Format
\`\`\`
Thought: ...
Action: ...
\`\`\`
## Action Space
{{action_spaces_holder}}
## Note
- Write a small plan and finally summarize your next action (with its target element) in one sentence in \`Thought\` part.
## User Instruction
`;
const DEFAULT_ACTION_SPACES = `
click(start_box='[x1, y1, x2, y2]')
left_double(start_box='[x1, y1, x2, y2]')
right_single(start_box='[x1, y1, x2, y2]')
drag(start_box='[x1, y1, x2, y2]', end_box='[x3, y3, x4, y4]')
hotkey(key='')
type(content='') #If you want to submit your input, use "\\n" at the end of \`content\`.
scroll(start_box='[x1, y1, x2, y2]', direction='down or up or right or left')
wait() #Sleep for 5s and take a screenshot to check for any changes.
finished()
call_user() # Submit the task and call the user when the task is unsolvable, or when you need the user's help.
`;
const DEFAULT_CONTEXT = {
logger: console,
factors: DEFAULT_FACTORS,
systemPrompt: SYSTEM_PROMPT
};
var INTERNAL_ACTION_SPACES_ENUM = /*#__PURE__*/ function(INTERNAL_ACTION_SPACES_ENUM) {
INTERNAL_ACTION_SPACES_ENUM["CALL_USER"] = "call_user";
INTERNAL_ACTION_SPACES_ENUM["MAX_LOOP"] = "max_loop";
INTERNAL_ACTION_SPACES_ENUM["ERROR_ENV"] = "error_env";
INTERNAL_ACTION_SPACES_ENUM["FINISHED"] = "finished";
return INTERNAL_ACTION_SPACES_ENUM;
}({});
exports.DEFAULT_ACTION_SPACES = __webpack_exports__.DEFAULT_ACTION_SPACES;
exports.DEFAULT_CONTEXT = __webpack_exports__.DEFAULT_CONTEXT;
exports.DEFAULT_FACTORS = __webpack_exports__.DEFAULT_FACTORS;
exports.INTERNAL_ACTION_SPACES_ENUM = __webpack_exports__.INTERNAL_ACTION_SPACES_ENUM;
exports.MAX_PIXELS = __webpack_exports__.MAX_PIXELS;
exports.MAX_SNAPSHOT_ERR_CNT = __webpack_exports__.MAX_SNAPSHOT_ERR_CNT;
exports.SYSTEM_PROMPT = __webpack_exports__.SYSTEM_PROMPT;
exports.SYSTEM_PROMPT_TEMPLATE = __webpack_exports__.SYSTEM_PROMPT_TEMPLATE;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"DEFAULT_ACTION_SPACES",
"DEFAULT_CONTEXT",
"DEFAULT_FACTORS",
"INTERNAL_ACTION_SPACES_ENUM",
"MAX_PIXELS",
"MAX_SNAPSHOT_ERR_CNT",
"SYSTEM_PROMPT",
"SYSTEM_PROMPT_TEMPLATE"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});
//# sourceMappingURL=constants.js.map