UNPKG

@ui-tars/sdk

Version:

A powerful cross-platform(ANY device/platform) toolkit for building GUI automation agents for UI-TARS

117 lines (108 loc) 4.27 kB
/** * 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 = function(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; }({}); var __webpack_export_target__ = exports; for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__]; if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', { value: true }); //# sourceMappingURL=constants.js.map