UNPKG

@ui-tars/shared

Version:
1 lines 2.81 kB
{"version":3,"file":"types/agent.mjs","sources":["webpack://@ui-tars/shared/./src/types/agent.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface Message {\n from: 'gpt' | 'human';\n value: string; // <image>\n}\n\nexport enum ErrorStatusEnum {\n /** 100000 */\n SCREENSHOT_RETRY_ERROR = -100000,\n /** 100001 */\n INVOKE_RETRY_ERROR = -100001,\n /** 100002 */\n EXECUTE_RETRY_ERROR = -100002,\n /** 100003 */\n MODEL_SERVICE_ERROR = -100003,\n /** 100004 */\n REACH_MAXLOOP_ERROR = -100004,\n /** 100005 */\n ENVIRONMENT_ERROR = -100005,\n /** 100099 */\n UNKNOWN_ERROR = -100099,\n}\n\nexport class GUIAgentError extends Error {\n status: ErrorStatusEnum;\n message: string;\n stack?: string;\n\n constructor(status: ErrorStatusEnum, message: string, stack?: string) {\n super(message);\n this.status = status;\n this.message = message;\n this.stack = stack;\n }\n}\n\nexport type Status = `${StatusEnum}`;\nexport enum StatusEnum {\n INIT = 'init',\n RUNNING = 'running',\n PAUSE = 'pause',\n END = 'end',\n CALL_USER = 'call_user',\n /**\n * @deprecated kept for backward compatibility\n */\n MAX_LOOP = 'max_loop',\n USER_STOPPED = 'user_stopped',\n ERROR = 'error',\n}\nexport interface VlmResponse {\n generate_resp: {\n input: string;\n prediction: string;\n uid: string;\n }[];\n}\n\nexport interface ScreenshotResult {\n /** screenshot base64, `keep screenshot size as physical pixels` */\n base64: string;\n /** screenshot scale factor(DPR), physical_pixels = logical_resolution * scaleFactor */\n scaleFactor: number;\n}\n\nexport type Coords = [number, number] | [];\nexport type ActionInputs = Partial<{\n content: string;\n start_box: string;\n end_box: string;\n key: string;\n hotkey: string;\n direction: string;\n start_coords: Coords;\n end_coords: Coords;\n}>;\n\nexport interface PredictionParsed {\n /** `<action_inputs>` parsed from action_type(`action_inputs`) */\n action_inputs: ActionInputs;\n /** `<reflection>` parsed from Reflection: `<reflection>` */\n reflection: string | null;\n /** `<action_type>` parsed from `<action_type>`(action_inputs) */\n action_type: string;\n /** `<thought>` parsed from Thought: `<thought>` */\n thought: string;\n}\n"],"names":["ErrorStatusEnum","GUIAgentError","Error","status","message","stack","StatusEnum"],"mappings":";;;;AAGC;;;;;;;;;;AAMM,IAAKA,wBAAeA,WAAAA,GAAAA,SAAfA,eAAe;IACd;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;WAbDA;;AAiBL,MAAMC,sBAAsBC;IAKjC,YAAYC,MAAuB,EAAEC,OAAe,EAAEC,KAAc,CAAE;QACpE,KAAK,CAACD,UALR,0CACA,2CACA;QAIE,IAAI,CAAC,MAAM,GAAGD;QACd,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,KAAK,GAAGC;IACf;AACF;AAGO,IAAKC,mBAAUA,WAAAA,GAAAA,SAAVA,UAAU;;;;;;IAQnB;;;WARSA"}