@ui-tars-test/cli 0.3.0

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 (49) hide show
  1. package/README.md +231 -0
  2. package/bin/index.js +13 -0
  3. package/dist/337.js +1396 -0
  4. package/dist/337.js.LICENSE.txt +14 -0
  5. package/dist/337.js.map +1 -0
  6. package/dist/337.mjs +1395 -0
  7. package/dist/337.mjs.LICENSE.txt +14 -0
  8. package/dist/337.mjs.map +1 -0
  9. package/dist/597.js +19 -0
  10. package/dist/597.mjs +18 -0
  11. package/dist/663.js +98 -0
  12. package/dist/663.js.map +1 -0
  13. package/dist/663.mjs +97 -0
  14. package/dist/663.mjs.map +1 -0
  15. package/dist/760.js +2957 -0
  16. package/dist/760.js.map +1 -0
  17. package/dist/760.mjs +2956 -0
  18. package/dist/760.mjs.map +1 -0
  19. package/dist/940.js +1013 -0
  20. package/dist/940.js.map +1 -0
  21. package/dist/940.mjs +1011 -0
  22. package/dist/940.mjs.map +1 -0
  23. package/dist/955.js +317 -0
  24. package/dist/955.js.map +1 -0
  25. package/dist/955.mjs +317 -0
  26. package/dist/955.mjs.map +1 -0
  27. package/dist/bundle/index.js +299060 -0
  28. package/dist/cli/commands.js +75 -0
  29. package/dist/cli/commands.js.map +1 -0
  30. package/dist/cli/commands.mjs +41 -0
  31. package/dist/cli/commands.mjs.map +1 -0
  32. package/dist/cli/start.js +447 -0
  33. package/dist/cli/start.js.map +1 -0
  34. package/dist/cli/start.mjs +396 -0
  35. package/dist/cli/start.mjs.map +1 -0
  36. package/dist/gui-agent-macos +0 -0
  37. package/dist/index.js +14 -0
  38. package/dist/index.js.LICENSE.txt +471 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/index.mjs +8 -0
  41. package/dist/index.mjs.LICENSE.txt +471 -0
  42. package/dist/index.mjs.map +1 -0
  43. package/dist/src/cli/commands.d.ts +2 -0
  44. package/dist/src/cli/commands.d.ts.map +1 -0
  45. package/dist/src/cli/start.d.ts +11 -0
  46. package/dist/src/cli/start.d.ts.map +1 -0
  47. package/dist/src/index.d.ts +2 -0
  48. package/dist/src/index.d.ts.map +1 -0
  49. package/package.json +59 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli/start.js","sources":["webpack://@gui-agent/cli/webpack/runtime/compat_get_default_export","webpack://@gui-agent/cli/webpack/runtime/define_property_getters","webpack://@gui-agent/cli/webpack/runtime/has_own_property","webpack://@gui-agent/cli/webpack/runtime/make_namespace_object","webpack://@gui-agent/cli/./src/cli/start.ts"],"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};","/*\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 fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\n\nimport fetch from 'node-fetch';\nimport { GUIAgent } from '@gui-agent/agent-sdk';\nimport * as p from '@clack/prompts';\nimport yaml from 'js-yaml';\n\nimport { NutJSOperator } from '@gui-agent/operator-nutjs';\nimport { AdbOperator } from '@gui-agent/operator-adb';\nimport { BrowserOperator } from '@gui-agent/operator-browser';\n\nexport interface CliOptions {\n presets?: string;\n target?: string;\n query?: string;\n config?: string;\n output?: string;\n tasks?: string;\n}\n\nexport const start = async (options: CliOptions) => {\n const CONFIG_PATH = options.config || path.join(os.homedir(), '.gui-agent-cli.json');\n\n // read config file\n let config = {\n baseURL: '',\n apiKey: '', // secretlint-disable-line\n model: '',\n provider: 'openai', // Default provider\n useResponsesApi: false,\n maxLoopCount: 1000,\n };\n\n if (options.presets) {\n const response = await fetch(options.presets);\n if (!response.ok) {\n throw new Error(`Failed to fetch preset: ${response.status}`);\n }\n\n const yamlText = await response.text();\n const preset = yaml.load(yamlText) as any;\n\n config.apiKey = preset?.vlmApiKey; // secretlint-disable-line\n config.baseURL = preset?.vlmBaseUrl;\n config.model = preset?.vlmModelName;\n config.useResponsesApi = preset?.useResponsesApi ?? false;\n } else if (fs.existsSync(CONFIG_PATH)) {\n try {\n config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));\n } catch (error) {\n console.warn('read config file failed', error);\n }\n }\n\n if (!config.baseURL || !config.apiKey || !config.model) {\n const configAnswers = await p.group(\n {\n provider: () =>\n p.select({\n message: 'Select model provider:',\n options: [\n { value: 'volcengine', label: 'VolcEngine' },\n { value: 'anthropic', label: 'Anthropic Claude' },\n { value: 'openai', label: 'OpenAI' },\n { value: 'lm-studio', label: 'LM Studio' },\n { value: 'deepseek', label: 'DeepSeek' },\n { value: 'ollama', label: 'Ollama' },\n ],\n }),\n baseURL: () => p.text({ message: 'please input vlm model baseURL:' }),\n apiKey: () => p.text({ message: 'please input vlm model apiKey:' }), // secretlint-disable-line\n model: () => p.text({ message: 'please input vlm model name:' }),\n },\n {\n onCancel: () => {\n p.cancel('operation cancelled');\n process.exit(0);\n },\n },\n );\n\n config = { ...config, ...configAnswers };\n\n // save config to file\n try {\n fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));\n console.log('model config file saved to:', CONFIG_PATH);\n } catch (error) {\n console.error('save model config file failed', error);\n }\n }\n\n // Diagnostic: print model config loaded\n try {\n const maskedKey = config.apiKey\n ? `${config.apiKey.slice(0, 6)}...${config.apiKey.slice(-4)}`\n : '(empty)';\n console.log('[CLI] Loaded model config:');\n console.log(` provider: ${config.provider}`);\n console.log(` baseURL: ${config.baseURL}`);\n console.log(` model: ${config.model}`);\n console.log(` apiKey: ${maskedKey}`); // secretlint-disable-line\n console.log(` useResponsesApi: ${Boolean((config as any).useResponsesApi)}`);\n } catch (e) {\n console.warn('[CLI] Failed to print model config diagnostics:', e);\n }\n\n // Basic baseURL validation and hints for OpenAI-compatible servers\n try {\n if (config.baseURL) {\n let parsed: URL | null = null;\n try {\n parsed = new URL(config.baseURL);\n } catch (_) {\n console.warn('[CLI] Warning: baseURL is not a valid URL:', config.baseURL);\n }\n if (parsed) {\n const endsWithV1 = /\\/v1\\/?$/.test(parsed.pathname);\n if (!endsWithV1) {\n console.warn(\n '[CLI] Hint: OpenAI-compatible endpoints typically end with \"/v1\" (e.g. https://host/v1).',\n );\n }\n if (parsed.protocol !== 'https:') {\n console.warn('[CLI] Hint: use HTTPS for most providers. Current:', parsed.protocol);\n }\n }\n }\n } catch (e) {\n console.warn('[CLI] baseURL validation failed:', e);\n }\n\n // Preflight: check Chat Completions non-streaming response shape for OpenAI-compatible servers\n try {\n if (config.provider === 'openai' && config.baseURL && config.model) {\n const url = new URL(config.baseURL.replace(/\\/$/, ''));\n url.pathname = url.pathname.replace(/\\/$/, '') + '/chat/completions';\n console.log('[CLI] Preflight: POST', url.toString());\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 16000);\n const resp = await fetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${config.apiKey}`,\n },\n body: JSON.stringify({\n model: config.model,\n messages: [{ role: 'user', content: 'ping' }],\n stream: false,\n }),\n signal: controller.signal,\n } as any);\n clearTimeout(timeout);\n const text = await resp.text();\n if (!resp.ok) {\n console.warn('[CLI] Preflight failed:', resp.status, resp.statusText);\n console.warn('[CLI] Preflight response body:', text.slice(0, 500));\n } else {\n try {\n const json = JSON.parse(text);\n const hasChoices = Array.isArray(json?.choices) && json.choices.length > 0;\n console.log('[CLI] Preflight ok. choices[0] exists:', hasChoices);\n if (!hasChoices) {\n console.warn(\n '[CLI] Preflight: response does not contain choices[]. Service may not implement Chat Completions.',\n );\n }\n } catch (_) {\n console.warn('[CLI] Preflight ok but response is not JSON:', text.slice(0, 200));\n }\n }\n }\n } catch (e: any) {\n if (e?.name === 'AbortError') {\n console.warn('[CLI] Preflight check timed out (16s). Proceeding without preflight.');\n } else {\n console.warn('[CLI] Preflight check error:', e);\n }\n }\n\n let targetOperator = null;\n const targetType =\n options.target ||\n ((await p.select({\n message: 'Please select your operator target:',\n options: [\n { value: 'computer', label: 'computer (Desktop automation)' },\n { value: 'android', label: 'android (Android automation)' },\n { value: 'browser', label: 'browser (Web automation)' },\n ],\n })) as string);\n\n switch (targetType) {\n case 'android':\n // Note: AdbOperator will auto-detect connected devices\n console.log('Initializing ADB operator...');\n targetOperator = new AdbOperator();\n break;\n case 'browser':\n // Use default browser options\n targetOperator = new BrowserOperator({\n browserType: 'chrome' as any,\n browser: null as any, // Will be initialized internally\n });\n break;\n case 'computer':\n default:\n targetOperator = new NutJSOperator();\n break;\n }\n\n const useTasksFile = Boolean(options.tasks);\n const answers = useTasksFile\n ? { instruction: '' }\n : options.query\n ? { instruction: options.query }\n : await p.group(\n {\n instruction: () => p.text({ message: 'Input your instruction' }),\n },\n {\n onCancel: () => {\n p.cancel('操作已取消');\n process.exit(0);\n },\n },\n );\n\n const abortController = new AbortController();\n process.on('SIGINT', () => {\n abortController.abort();\n });\n\n const systemPrompts = [\n 'You are provided with a task description, a history of previous actions, and corresponding screenshots. Your goal is to perform the next action to complete the task. Please note that if performing the same action multiple times results in a static screen with no changes, you should attempt a modified or alternative action.',\n '## Function Definition\\n\\n- You have access to the following functions:\\n{\"type\": \"function\", \"name\": \"call_user\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Message or information displayed to the user to request their input, feedback, or guidance.\"}}, \"required\": []}, \"description\": \"This function is used to interact with the user by displaying a message and requesting their input, feedback, or guidance.\"}\\n{\"type\": \"function\", \"name\": \"click\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Click coordinates. The format is: <point>x y</point>\"}}, \"required\": [\"point\"]}, \"description\": \"Mouse left single click action.\"}\\n{\"type\": \"function\", \"name\": \"drag\", \"parameters\": {\"type\": \"object\", \"properties\": {\"start_point\": {\"type\": \"string\", \"description\": \"Drag start point. The format is: <point>x y</point>\"}, \"end_point\": {\"type\": \"string\", \"description\": \"Drag end point. The format is: <point>x y</point>\"}}, \"required\": [\"start_point\", \"end_point\"]}, \"description\": \"Mouse left button drag action.\"}\\n{\"type\": \"function\", \"name\": \"finished\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Provide the final answer or response to complete the task.\"}}, \"required\": []}, \"description\": \"This function is used to indicate the completion of a task by providing the final answer or response.\"}\\n{\"type\": \"function\", \"name\": \"hotkey\", \"parameters\": {\"type\": \"object\", \"properties\": {\"key\": {\"type\": \"string\", \"description\": \"Hotkeys you want to press. Split keys with a space and use lowercase.\"}}, \"required\": [\"key\"]}, \"description\": \"Press hotkey.\"}\\n{\"type\": \"function\", \"function\": {\"name\": \"infeasible\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Message or information displayed to the user to explain why the current task is infeasible.\"}}, \"required\": [\"content\"]}, \"description\": \"This function is used to indicate that the current task is infeasible thus agent ends the task.\"}\\n{\"type\": \"function\", \"name\": \"left_double\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Click coordinates. The format is: <point>x y</point>\"}}, \"required\": [\"point\"]}, \"description\": \"Mouse left double click action.\"}\\n{\"type\": \"function\", \"name\": \"right_single\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Click coordinates. The format is: <point>x y</point>\"}}, \"required\": [\"point\"]}, \"description\": \"Mouse right single click action.\"}\\n{\"type\": \"function\", \"name\": \"scroll\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Scroll start position. If not specified, default to execute on the current mouse position. The format is: <point>x y</point>\"}, \"direction\": {\"type\": \"string\", \"description\": \"Scroll direction.\", \"enum\": [\"up\", \"down\", \"left\", \"right\"]}}, \"required\": [\"direction\", \"point\"]}, \"description\": \"Scroll action.\"}\\n{\"type\": \"function\", \"name\": \"type\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Type content. If you want to submit your input, use \\\\n at the end of content.\"}}, \"required\": [\"content\"]}, \"description\": \"Type content.\"}\\n{\"type\": \"function\", \"name\": \"wait\", \"parameters\": {\"type\": \"object\", \"properties\": {\"time\": {\"type\": \"integer\", \"description\": \"Wait time in seconds.\"}}, \"required\": []}, \"description\": \"Wait for a while.\"}\\n\\n- To call a function, use the following structure without any suffix:\\n\\n<think_never_used_51bce0c785ca2f68081bfa7d91973934> reasoning process </think_never_used_51bce0c785ca2f68081bfa7d91973934>\\n<seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_name><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_1>value_1</parameter_never_used_51bce0c785ca2f68081bfa7d91973934><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934></seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934>\\n\\n## Important Notes\\n- Function calls must begin with <function_never_used_51bce0c785ca2f68081bfa7d91973934= and end with </function_never_used_51bce0c785ca2f68081bfa7d91973934>.\\n- All required parameters must be explicitly provided.\\n\\n## Additional Notes\\n- You can execute multiple actions within a single tool call. For example:\\n<seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_1><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_1>value_1</parameter_never_used_51bce0c785ca2f68081bfa7d91973934><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_2><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_3>value_4</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934></seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934>\\n- 当你判断任务请求是无法执行的时候,你应该调用Infeasible工具结束任务并解释原因。\\n 判断标准:当一个请求符合以下任何一条标准时,应被归类为“无法执行”。\\n 1. 技术/物理层面的矛盾: 指令本身包含逻辑上或物理上无法实现的要求。\\n 2. 工具/功能错配: 指令要求在一个软件中执行另一个软件的功能,或者执行该软件根本不具备的功能。\\n 3. 超出操作边界/范围: 指令要求执行的操作超出了当前用户会话、权限或应用程序的逻辑边界,涉及未告知的隐私信息或者未授权的操作。\\n 4. 依赖隐性知识或外部条件: 任务的完成依赖于Agent无法获取的外部硬件、物理环境、未声明的插件/扩展、或特定的文件/数据。\\n\\n 输出指令:\\n 如果请求被判断为“无法执行”,你应该向用户解释为什么这个任务超出了你的能力范围(例如,指出它需要直接操作某个硬件),并尽可能提供一个指导性的替代方案,让用户可以自己完成该任务。\\n 你应该非常非常谨慎地使用Infeasible工具,因为它会直接结束任务并降低用户体验。所以非必要的时候,你不应该调用Infeasible工具,尽量以finish工具结束任务并向用户提示原因就好。',\n ];\n\n const guiAgent = new GUIAgent({\n model: {\n id: config.model,\n provider: config.provider as any, // Type assertion to avoid TypeScript error\n baseURL: config.baseURL,\n apiKey: config.apiKey, // secretlint-disable-line\n },\n operator: targetOperator,\n systemPrompt: systemPrompts.join('\\n\\n'),\n });\n\n if (useTasksFile) {\n const demoDir = path.resolve(path.join(__dirname, '..', '..', 'demo'));\n const tasksPath =\n options.tasks === 'demo' ? path.join(demoDir, 'tasks.json') : path.resolve(options.tasks!);\n try {\n const dirOfTasks = path.dirname(tasksPath);\n fs.mkdirSync(dirOfTasks, { recursive: true });\n if (!fs.existsSync(tasksPath)) {\n const sample = [\n { taskId: 'task-1', query: 'Open Chrome and go to github.com' },\n { taskId: 'task-2', query: \"Search for 'GUI Agent automation' on Google\" },\n ];\n fs.writeFileSync(tasksPath, JSON.stringify(sample, null, 2));\n console.log(`[CLI] Sample tasks.json created: ${tasksPath}`);\n }\n } catch (e) {\n console.warn('[CLI] Failed to prepare tasks file directory', e);\n }\n\n let tasks: Array<{ taskId: string; query: string }> = [];\n try {\n const raw = fs.readFileSync(tasksPath, 'utf-8');\n const parsed = JSON.parse(raw);\n if (Array.isArray(parsed)) tasks = parsed;\n else console.warn('[CLI] tasks file is not an array');\n } catch (e) {\n console.error('[CLI] Failed to read tasks file', e);\n process.exit(1);\n }\n\n const targetOutputDir = options.output\n ? path.resolve(options.output)\n : options.tasks === 'demo'\n ? path.join(demoDir, 'results')\n : path.join(os.homedir(), '.gui-agent-results');\n console.log(`[CLI] Output directory (resolved): ${targetOutputDir}`);\n fs.mkdirSync(targetOutputDir, { recursive: true });\n\n for (const task of tasks) {\n try {\n const resultEvent = await guiAgent.run(task.query);\n const eventStream = guiAgent.getEventStream();\n const allEvents = eventStream.getEvents();\n const runStartEvents = allEvents.filter((e: any) => e.type === 'agent_run_start');\n const lastRunStart = runStartEvents[runStartEvents.length - 1] as any;\n const startIndex = allEvents.findIndex((e: any) => e.id === lastRunStart?.id);\n const endIndex = allEvents.findIndex(\n (e: any, idx: number) => idx > startIndex && e.type === 'agent_run_end',\n );\n const rangeEvents =\n startIndex >= 0\n ? endIndex >= 0\n ? allEvents.slice(startIndex, endIndex + 1)\n : allEvents.slice(startIndex)\n : allEvents;\n const envEvents = rangeEvents.filter((e: any) => e.type === 'environment_input');\n const screenshotEvents = envEvents.filter(\n (e: any) => e.metadata && e.metadata.type === 'screenshot',\n );\n const lastScreenshot =\n screenshotEvents.length > 0\n ? (screenshotEvents[screenshotEvents.length - 1] as any)\n : null;\n\n let resultPicPath = '';\n if (lastScreenshot && Array.isArray(lastScreenshot.content)) {\n const imgPart = (lastScreenshot.content as any[]).find(\n (c: any) => c.type === 'image_url' && c.image_url && c.image_url.url,\n );\n const dataUri: string | undefined = imgPart?.image_url?.url;\n if (dataUri && typeof dataUri === 'string' && dataUri.startsWith('data:')) {\n const commaIndex = dataUri.indexOf(',');\n const base64Data = commaIndex >= 0 ? dataUri.substring(commaIndex + 1) : dataUri;\n const buffer = Buffer.from(base64Data, 'base64');\n resultPicPath = path.join(targetOutputDir, `${task.taskId}.png`);\n fs.writeFileSync(resultPicPath, buffer);\n console.log(`[CLI] Screenshot saved: ${resultPicPath}`);\n }\n }\n if (!resultPicPath) {\n console.log('[CLI] No screenshot captured; resultPic will be empty.');\n }\n\n const finalAnswer = (resultEvent as any)?.content ?? '';\n const report = {\n taskId: task.taskId,\n resultPic: resultPicPath,\n finalAnswer,\n };\n const reportPath = path.join(targetOutputDir, `${task.taskId}.json`);\n fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));\n console.log(`Result saved: ${reportPath}`);\n console.log(`[CLI] Report JSON path: ${reportPath}`);\n } catch (taskErr) {\n console.error(`[CLI] Task failed: ${task.taskId}`, taskErr);\n }\n }\n return;\n }\n\n // Enhanced error logging around agent run\n let resultEvent: any;\n try {\n console.log(\n '[CLI] Starting GUIAgent run with instruction:',\n answers.instruction || options.query,\n );\n resultEvent = await guiAgent.run(answers.instruction);\n console.log('[CLI] GUIAgent run completed.');\n } catch (err: any) {\n console.error('[CLI] GUIAgent run failed.');\n const errMsg = err?.message || String(err);\n console.error('[CLI] Error message:', errMsg);\n if (err?.status) console.error('[CLI] HTTP status:', err.status);\n if (err?.code) console.error('[CLI] Error code:', err.code);\n const respData = err?.response?.data || err?.response?.body || err?.data;\n if (respData) {\n try {\n const text = typeof respData === 'string' ? respData : JSON.stringify(respData);\n console.error('[CLI] Response body:', text.slice(0, 500));\n } catch (_) {\n console.error('[CLI] Response body: [unprintable]');\n }\n }\n throw err;\n }\n\n try {\n const eventStream = guiAgent.getEventStream();\n const allEvents = eventStream.getEvents();\n const runStartEvents = allEvents.filter((e: any) => e.type === 'agent_run_start');\n const sessionId =\n runStartEvents.length > 0\n ? (runStartEvents[runStartEvents.length - 1] as any).sessionId\n : `${Date.now()}`;\n\n const envEvents = allEvents.filter((e: any) => e.type === 'environment_input');\n const screenshotEvents = envEvents.filter(\n (e: any) => e.metadata && e.metadata.type === 'screenshot',\n );\n const lastScreenshot =\n screenshotEvents.length > 0 ? (screenshotEvents[screenshotEvents.length - 1] as any) : null;\n\n const targetOutputDir = options.output\n ? path.resolve(options.output)\n : path.join(os.homedir(), '.gui-agent-results');\n console.log(`[CLI] Output directory (resolved): ${targetOutputDir}`);\n fs.mkdirSync(targetOutputDir, { recursive: true });\n console.log(`[CLI] TaskId/SessionId: ${sessionId}`);\n\n let resultPicPath = '';\n if (lastScreenshot && Array.isArray(lastScreenshot.content)) {\n const imgPart = (lastScreenshot.content as any[]).find(\n (c: any) => c.type === 'image_url' && c.image_url && c.image_url.url,\n );\n const dataUri: string | undefined = imgPart?.image_url?.url;\n if (dataUri && typeof dataUri === 'string' && dataUri.startsWith('data:')) {\n const commaIndex = dataUri.indexOf(',');\n const base64Data = commaIndex >= 0 ? dataUri.substring(commaIndex + 1) : dataUri;\n const buffer = Buffer.from(base64Data, 'base64');\n resultPicPath = path.join(targetOutputDir, `${sessionId}.png`);\n fs.writeFileSync(resultPicPath, buffer);\n console.log(`[CLI] Screenshot saved: ${resultPicPath}`);\n }\n }\n if (!resultPicPath) {\n console.log('[CLI] No screenshot captured; resultPic will be empty.');\n }\n\n const finalAnswer = (resultEvent as any)?.content ?? '';\n const report = {\n taskId: sessionId,\n resultPic: resultPicPath,\n finalAnswer,\n };\n const reportPath = path.join(targetOutputDir, `${sessionId}.json`);\n fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));\n console.log(`Result saved: ${reportPath}`);\n console.log(`[CLI] Report JSON path: ${reportPath}`);\n } catch (err) {\n console.warn('Failed to generate result report:', err);\n }\n};\n\nexport const resetConfig = async (configPath?: string) => {\n const CONFIG_PATH = configPath || path.join(os.homedir(), '.gui-agent-cli.json');\n\n try {\n if (fs.existsSync(CONFIG_PATH)) {\n fs.unlinkSync(CONFIG_PATH);\n console.log(`✓ Configuration file removed: ${CONFIG_PATH}`);\n } else {\n console.log(`No configuration file found at: ${CONFIG_PATH}`);\n }\n\n console.log(\n 'Configuration has been reset. The next time you run gui-agent, you will be prompted to configure your settings again.',\n );\n } catch (error) {\n console.error('Failed to reset configuration:', error);\n process.exit(1);\n }\n};\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","start","options","CONFIG_PATH","path","os","config","response","fetch","Error","yamlText","preset","yaml","fs","JSON","error","console","configAnswers","p","process","maskedKey","Boolean","e","parsed","URL","_","endsWithV1","url","controller","AbortController","timeout","setTimeout","resp","clearTimeout","text","json","hasChoices","Array","targetOperator","targetType","AdbOperator","BrowserOperator","NutJSOperator","useTasksFile","answers","abortController","systemPrompts","guiAgent","GUIAgent","demoDir","__dirname","tasksPath","dirOfTasks","sample","tasks","raw","targetOutputDir","task","resultEvent","eventStream","allEvents","runStartEvents","lastRunStart","startIndex","endIndex","idx","rangeEvents","envEvents","screenshotEvents","lastScreenshot","resultPicPath","_imgPart_image_url","imgPart","c","dataUri","commaIndex","base64Data","buffer","Buffer","finalAnswer","report","reportPath","taskErr","err","_err_response","_err_response1","errMsg","String","respData","sessionId","Date","_imgPart_image_url1","resetConfig","configPath"],"mappings":";;;;;;;IACAA,oBAAoB,CAA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AAa,CAACV;YACda,QAAQ,GAAG,CAAC,CAAC,qCAA8B,EAAEb,aAAa;QAC5D,OACEa,QAAQ,GAAG,CAAC,CAAC,gCAAgC,EAAEb,aAAa;QAG9Da,QAAQ,GAAG,CACT;IAEJ,EAAE,OAAOD,OAAO;QACdC,QAAQ,KAAK,CAAC,kCAAkCD;QAChDI,QAAQ,IAAI,CAAC;IACf;AACF"}
@@ -0,0 +1,396 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import node_fs from "node:fs";
6
+ import node_path from "node:path";
7
+ import node_os from "node:os";
8
+ import node_fetch from "node-fetch";
9
+ import { GUIAgent } from "@gui-agent/agent-sdk";
10
+ import { cancel, group, select as prompts_select, text as prompts_text } from "@clack/prompts";
11
+ import js_yaml from "js-yaml";
12
+ import { NutJSOperator } from "@gui-agent/operator-nutjs";
13
+ import { AdbOperator } from "@gui-agent/operator-adb";
14
+ import { BrowserOperator } from "@gui-agent/operator-browser";
15
+ const start = async (options)=>{
16
+ const CONFIG_PATH = options.config || node_path.join(node_os.homedir(), '.gui-agent-cli.json');
17
+ let config = {
18
+ baseURL: '',
19
+ apiKey: '',
20
+ model: '',
21
+ provider: 'openai',
22
+ useResponsesApi: false,
23
+ maxLoopCount: 1000
24
+ };
25
+ if (options.presets) {
26
+ const response = await node_fetch(options.presets);
27
+ if (!response.ok) throw new Error(`Failed to fetch preset: ${response.status}`);
28
+ const yamlText = await response.text();
29
+ const preset = js_yaml.load(yamlText);
30
+ config.apiKey = null == preset ? void 0 : preset.vlmApiKey;
31
+ config.baseURL = null == preset ? void 0 : preset.vlmBaseUrl;
32
+ config.model = null == preset ? void 0 : preset.vlmModelName;
33
+ config.useResponsesApi = (null == preset ? void 0 : preset.useResponsesApi) ?? false;
34
+ } else if (node_fs.existsSync(CONFIG_PATH)) try {
35
+ config = JSON.parse(node_fs.readFileSync(CONFIG_PATH, 'utf-8'));
36
+ } catch (error) {
37
+ console.warn('read config file failed', error);
38
+ }
39
+ if (!config.baseURL || !config.apiKey || !config.model) {
40
+ const configAnswers = await group({
41
+ provider: ()=>prompts_select({
42
+ message: 'Select model provider:',
43
+ options: [
44
+ {
45
+ value: 'volcengine',
46
+ label: 'VolcEngine'
47
+ },
48
+ {
49
+ value: 'anthropic',
50
+ label: 'Anthropic Claude'
51
+ },
52
+ {
53
+ value: 'openai',
54
+ label: 'OpenAI'
55
+ },
56
+ {
57
+ value: 'lm-studio',
58
+ label: 'LM Studio'
59
+ },
60
+ {
61
+ value: 'deepseek',
62
+ label: 'DeepSeek'
63
+ },
64
+ {
65
+ value: 'ollama',
66
+ label: 'Ollama'
67
+ }
68
+ ]
69
+ }),
70
+ baseURL: ()=>prompts_text({
71
+ message: 'please input vlm model baseURL:'
72
+ }),
73
+ apiKey: ()=>prompts_text({
74
+ message: 'please input vlm model apiKey:'
75
+ }),
76
+ model: ()=>prompts_text({
77
+ message: 'please input vlm model name:'
78
+ })
79
+ }, {
80
+ onCancel: ()=>{
81
+ cancel('operation cancelled');
82
+ process.exit(0);
83
+ }
84
+ });
85
+ config = {
86
+ ...config,
87
+ ...configAnswers
88
+ };
89
+ try {
90
+ node_fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
91
+ console.log('model config file saved to:', CONFIG_PATH);
92
+ } catch (error) {
93
+ console.error('save model config file failed', error);
94
+ }
95
+ }
96
+ try {
97
+ const maskedKey = config.apiKey ? `${config.apiKey.slice(0, 6)}...${config.apiKey.slice(-4)}` : '(empty)';
98
+ console.log('[CLI] Loaded model config:');
99
+ console.log(` provider: ${config.provider}`);
100
+ console.log(` baseURL: ${config.baseURL}`);
101
+ console.log(` model: ${config.model}`);
102
+ console.log(` apiKey: ${maskedKey}`);
103
+ console.log(` useResponsesApi: ${Boolean(config.useResponsesApi)}`);
104
+ } catch (e) {
105
+ console.warn('[CLI] Failed to print model config diagnostics:', e);
106
+ }
107
+ try {
108
+ if (config.baseURL) {
109
+ let parsed = null;
110
+ try {
111
+ parsed = new URL(config.baseURL);
112
+ } catch (_) {
113
+ console.warn('[CLI] Warning: baseURL is not a valid URL:', config.baseURL);
114
+ }
115
+ if (parsed) {
116
+ const endsWithV1 = /\/v1\/?$/.test(parsed.pathname);
117
+ if (!endsWithV1) console.warn('[CLI] Hint: OpenAI-compatible endpoints typically end with "/v1" (e.g. https://host/v1).');
118
+ if ('https:' !== parsed.protocol) console.warn('[CLI] Hint: use HTTPS for most providers. Current:', parsed.protocol);
119
+ }
120
+ }
121
+ } catch (e) {
122
+ console.warn('[CLI] baseURL validation failed:', e);
123
+ }
124
+ try {
125
+ if ('openai' === config.provider && config.baseURL && config.model) {
126
+ const url = new URL(config.baseURL.replace(/\/$/, ''));
127
+ url.pathname = url.pathname.replace(/\/$/, '') + '/chat/completions';
128
+ console.log('[CLI] Preflight: POST', url.toString());
129
+ const controller = new AbortController();
130
+ const timeout = setTimeout(()=>controller.abort(), 16000);
131
+ const resp = await node_fetch(url.toString(), {
132
+ method: 'POST',
133
+ headers: {
134
+ 'Content-Type': 'application/json',
135
+ Authorization: `Bearer ${config.apiKey}`
136
+ },
137
+ body: JSON.stringify({
138
+ model: config.model,
139
+ messages: [
140
+ {
141
+ role: 'user',
142
+ content: 'ping'
143
+ }
144
+ ],
145
+ stream: false
146
+ }),
147
+ signal: controller.signal
148
+ });
149
+ clearTimeout(timeout);
150
+ const text = await resp.text();
151
+ if (resp.ok) try {
152
+ const json = JSON.parse(text);
153
+ const hasChoices = Array.isArray(null == json ? void 0 : json.choices) && json.choices.length > 0;
154
+ console.log('[CLI] Preflight ok. choices[0] exists:', hasChoices);
155
+ if (!hasChoices) console.warn('[CLI] Preflight: response does not contain choices[]. Service may not implement Chat Completions.');
156
+ } catch (_) {
157
+ console.warn('[CLI] Preflight ok but response is not JSON:', text.slice(0, 200));
158
+ }
159
+ else {
160
+ console.warn('[CLI] Preflight failed:', resp.status, resp.statusText);
161
+ console.warn('[CLI] Preflight response body:', text.slice(0, 500));
162
+ }
163
+ }
164
+ } catch (e) {
165
+ if ((null == e ? void 0 : e.name) === 'AbortError') console.warn('[CLI] Preflight check timed out (16s). Proceeding without preflight.');
166
+ else console.warn('[CLI] Preflight check error:', e);
167
+ }
168
+ let targetOperator = null;
169
+ const targetType = options.target || await prompts_select({
170
+ message: 'Please select your operator target:',
171
+ options: [
172
+ {
173
+ value: 'computer',
174
+ label: 'computer (Desktop automation)'
175
+ },
176
+ {
177
+ value: 'android',
178
+ label: 'android (Android automation)'
179
+ },
180
+ {
181
+ value: 'browser',
182
+ label: 'browser (Web automation)'
183
+ }
184
+ ]
185
+ });
186
+ switch(targetType){
187
+ case 'android':
188
+ console.log('Initializing ADB operator...');
189
+ targetOperator = new AdbOperator();
190
+ break;
191
+ case 'browser':
192
+ targetOperator = new BrowserOperator({
193
+ browserType: 'chrome',
194
+ browser: null
195
+ });
196
+ break;
197
+ case 'computer':
198
+ default:
199
+ targetOperator = new NutJSOperator();
200
+ break;
201
+ }
202
+ const useTasksFile = Boolean(options.tasks);
203
+ const answers = useTasksFile ? {
204
+ instruction: ''
205
+ } : options.query ? {
206
+ instruction: options.query
207
+ } : await group({
208
+ instruction: ()=>prompts_text({
209
+ message: 'Input your instruction'
210
+ })
211
+ }, {
212
+ onCancel: ()=>{
213
+ cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
214
+ process.exit(0);
215
+ }
216
+ });
217
+ const abortController = new AbortController();
218
+ process.on('SIGINT', ()=>{
219
+ abortController.abort();
220
+ });
221
+ const systemPrompts = [
222
+ "You are provided with a task description, a history of previous actions, and corresponding screenshots. Your goal is to perform the next action to complete the task. Please note that if performing the same action multiple times results in a static screen with no changes, you should attempt a modified or alternative action.",
223
+ '## Function Definition\n\n- You have access to the following functions:\n{"type": "function", "name": "call_user", "parameters": {"type": "object", "properties": {"content": {"type": "string", "description": "Message or information displayed to the user to request their input, feedback, or guidance."}}, "required": []}, "description": "This function is used to interact with the user by displaying a message and requesting their input, feedback, or guidance."}\n{"type": "function", "name": "click", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Click coordinates. The format is: <point>x y</point>"}}, "required": ["point"]}, "description": "Mouse left single click action."}\n{"type": "function", "name": "drag", "parameters": {"type": "object", "properties": {"start_point": {"type": "string", "description": "Drag start point. The format is: <point>x y</point>"}, "end_point": {"type": "string", "description": "Drag end point. The format is: <point>x y</point>"}}, "required": ["start_point", "end_point"]}, "description": "Mouse left button drag action."}\n{"type": "function", "name": "finished", "parameters": {"type": "object", "properties": {"content": {"type": "string", "description": "Provide the final answer or response to complete the task."}}, "required": []}, "description": "This function is used to indicate the completion of a task by providing the final answer or response."}\n{"type": "function", "name": "hotkey", "parameters": {"type": "object", "properties": {"key": {"type": "string", "description": "Hotkeys you want to press. Split keys with a space and use lowercase."}}, "required": ["key"]}, "description": "Press hotkey."}\n{"type": "function", "function": {"name": "infeasible", "parameters": {"type": "object", "properties": {"content": {"type": "string", "description": "Message or information displayed to the user to explain why the current task is infeasible."}}, "required": ["content"]}, "description": "This function is used to indicate that the current task is infeasible thus agent ends the task."}\n{"type": "function", "name": "left_double", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Click coordinates. The format is: <point>x y</point>"}}, "required": ["point"]}, "description": "Mouse left double click action."}\n{"type": "function", "name": "right_single", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Click coordinates. The format is: <point>x y</point>"}}, "required": ["point"]}, "description": "Mouse right single click action."}\n{"type": "function", "name": "scroll", "parameters": {"type": "object", "properties": {"point": {"type": "string", "description": "Scroll start position. If not specified, default to execute on the current mouse position. The format is: <point>x y</point>"}, "direction": {"type": "string", "description": "Scroll direction.", "enum": ["up", "down", "left", "right"]}}, "required": ["direction", "point"]}, "description": "Scroll action."}\n{"type": "function", "name": "type", "parameters": {"type": "object", "properties": {"content": {"type": "string", "description": "Type content. If you want to submit your input, use \\n at the end of content."}}, "required": ["content"]}, "description": "Type content."}\n{"type": "function", "name": "wait", "parameters": {"type": "object", "properties": {"time": {"type": "integer", "description": "Wait time in seconds."}}, "required": []}, "description": "Wait for a while."}\n\n- To call a function, use the following structure without any suffix:\n\n<think_never_used_51bce0c785ca2f68081bfa7d91973934> reasoning process </think_never_used_51bce0c785ca2f68081bfa7d91973934>\n<seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_name><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_1>value_1</parameter_never_used_51bce0c785ca2f68081bfa7d91973934><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934></seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934>\n\n## Important Notes\n- Function calls must begin with <function_never_used_51bce0c785ca2f68081bfa7d91973934= and end with </function_never_used_51bce0c785ca2f68081bfa7d91973934>.\n- All required parameters must be explicitly provided.\n\n## Additional Notes\n- You can execute multiple actions within a single tool call. For example:\n<seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_1><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_1>value_1</parameter_never_used_51bce0c785ca2f68081bfa7d91973934><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_2><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_3>value_4</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934></seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934>\n- 当你判断任务请求是无法执行的时候,你应该调用Infeasible工具结束任务并解释原因。\n 判断标准:当一个请求符合以下任何一条标准时,应被归类为“无法执行”。\n 1. 技术/物理层面的矛盾: 指令本身包含逻辑上或物理上无法实现的要求。\n 2. 工具/功能错配: 指令要求在一个软件中执行另一个软件的功能,或者执行该软件根本不具备的功能。\n 3. 超出操作边界/范围: 指令要求执行的操作超出了当前用户会话、权限或应用程序的逻辑边界,涉及未告知的隐私信息或者未授权的操作。\n 4. 依赖隐性知识或外部条件: 任务的完成依赖于Agent无法获取的外部硬件、物理环境、未声明的插件/扩展、或特定的文件/数据。\n\n 输出指令:\n 如果请求被判断为“无法执行”,你应该向用户解释为什么这个任务超出了你的能力范围(例如,指出它需要直接操作某个硬件),并尽可能提供一个指导性的替代方案,让用户可以自己完成该任务。\n 你应该非常非常谨慎地使用Infeasible工具,因为它会直接结束任务并降低用户体验。所以非必要的时候,你不应该调用Infeasible工具,尽量以finish工具结束任务并向用户提示原因就好。'
224
+ ];
225
+ const guiAgent = new GUIAgent({
226
+ model: {
227
+ id: config.model,
228
+ provider: config.provider,
229
+ baseURL: config.baseURL,
230
+ apiKey: config.apiKey
231
+ },
232
+ operator: targetOperator,
233
+ systemPrompt: systemPrompts.join('\n\n')
234
+ });
235
+ if (useTasksFile) {
236
+ const demoDir = node_path.resolve(node_path.join(__dirname, '..', '..', 'demo'));
237
+ const tasksPath = 'demo' === options.tasks ? node_path.join(demoDir, 'tasks.json') : node_path.resolve(options.tasks);
238
+ try {
239
+ const dirOfTasks = node_path.dirname(tasksPath);
240
+ node_fs.mkdirSync(dirOfTasks, {
241
+ recursive: true
242
+ });
243
+ if (!node_fs.existsSync(tasksPath)) {
244
+ const sample = [
245
+ {
246
+ taskId: 'task-1',
247
+ query: 'Open Chrome and go to github.com'
248
+ },
249
+ {
250
+ taskId: 'task-2',
251
+ query: "Search for 'GUI Agent automation' on Google"
252
+ }
253
+ ];
254
+ node_fs.writeFileSync(tasksPath, JSON.stringify(sample, null, 2));
255
+ console.log(`[CLI] Sample tasks.json created: ${tasksPath}`);
256
+ }
257
+ } catch (e) {
258
+ console.warn('[CLI] Failed to prepare tasks file directory', e);
259
+ }
260
+ let tasks = [];
261
+ try {
262
+ const raw = node_fs.readFileSync(tasksPath, 'utf-8');
263
+ const parsed = JSON.parse(raw);
264
+ if (Array.isArray(parsed)) tasks = parsed;
265
+ else console.warn('[CLI] tasks file is not an array');
266
+ } catch (e) {
267
+ console.error('[CLI] Failed to read tasks file', e);
268
+ process.exit(1);
269
+ }
270
+ const targetOutputDir = options.output ? node_path.resolve(options.output) : 'demo' === options.tasks ? node_path.join(demoDir, 'results') : node_path.join(node_os.homedir(), '.gui-agent-results');
271
+ console.log(`[CLI] Output directory (resolved): ${targetOutputDir}`);
272
+ node_fs.mkdirSync(targetOutputDir, {
273
+ recursive: true
274
+ });
275
+ for (const task of tasks)try {
276
+ const resultEvent = await guiAgent.run(task.query);
277
+ const eventStream = guiAgent.getEventStream();
278
+ const allEvents = eventStream.getEvents();
279
+ const runStartEvents = allEvents.filter((e)=>'agent_run_start' === e.type);
280
+ const lastRunStart = runStartEvents[runStartEvents.length - 1];
281
+ const startIndex = allEvents.findIndex((e)=>e.id === (null == lastRunStart ? void 0 : lastRunStart.id));
282
+ const endIndex = allEvents.findIndex((e, idx)=>idx > startIndex && 'agent_run_end' === e.type);
283
+ const rangeEvents = startIndex >= 0 ? endIndex >= 0 ? allEvents.slice(startIndex, endIndex + 1) : allEvents.slice(startIndex) : allEvents;
284
+ const envEvents = rangeEvents.filter((e)=>'environment_input' === e.type);
285
+ const screenshotEvents = envEvents.filter((e)=>e.metadata && 'screenshot' === e.metadata.type);
286
+ const lastScreenshot = screenshotEvents.length > 0 ? screenshotEvents[screenshotEvents.length - 1] : null;
287
+ let resultPicPath = '';
288
+ if (lastScreenshot && Array.isArray(lastScreenshot.content)) {
289
+ var _imgPart_image_url;
290
+ const imgPart = lastScreenshot.content.find((c)=>'image_url' === c.type && c.image_url && c.image_url.url);
291
+ const dataUri = null == imgPart ? void 0 : null == (_imgPart_image_url = imgPart.image_url) ? void 0 : _imgPart_image_url.url;
292
+ if (dataUri && 'string' == typeof dataUri && dataUri.startsWith('data:')) {
293
+ const commaIndex = dataUri.indexOf(',');
294
+ const base64Data = commaIndex >= 0 ? dataUri.substring(commaIndex + 1) : dataUri;
295
+ const buffer = Buffer.from(base64Data, 'base64');
296
+ resultPicPath = node_path.join(targetOutputDir, `${task.taskId}.png`);
297
+ node_fs.writeFileSync(resultPicPath, buffer);
298
+ console.log(`[CLI] Screenshot saved: ${resultPicPath}`);
299
+ }
300
+ }
301
+ if (!resultPicPath) console.log('[CLI] No screenshot captured; resultPic will be empty.');
302
+ const finalAnswer = (null == resultEvent ? void 0 : resultEvent.content) ?? '';
303
+ const report = {
304
+ taskId: task.taskId,
305
+ resultPic: resultPicPath,
306
+ finalAnswer
307
+ };
308
+ const reportPath = node_path.join(targetOutputDir, `${task.taskId}.json`);
309
+ node_fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
310
+ console.log(`Result saved: ${reportPath}`);
311
+ console.log(`[CLI] Report JSON path: ${reportPath}`);
312
+ } catch (taskErr) {
313
+ console.error(`[CLI] Task failed: ${task.taskId}`, taskErr);
314
+ }
315
+ return;
316
+ }
317
+ let resultEvent;
318
+ try {
319
+ console.log('[CLI] Starting GUIAgent run with instruction:', answers.instruction || options.query);
320
+ resultEvent = await guiAgent.run(answers.instruction);
321
+ console.log('[CLI] GUIAgent run completed.');
322
+ } catch (err) {
323
+ var _err_response, _err_response1;
324
+ console.error('[CLI] GUIAgent run failed.');
325
+ const errMsg = (null == err ? void 0 : err.message) || String(err);
326
+ console.error('[CLI] Error message:', errMsg);
327
+ if (null == err ? void 0 : err.status) console.error('[CLI] HTTP status:', err.status);
328
+ if (null == err ? void 0 : err.code) console.error('[CLI] Error code:', err.code);
329
+ const respData = (null == err ? void 0 : null == (_err_response = err.response) ? void 0 : _err_response.data) || (null == err ? void 0 : null == (_err_response1 = err.response) ? void 0 : _err_response1.body) || (null == err ? void 0 : err.data);
330
+ if (respData) try {
331
+ const text = 'string' == typeof respData ? respData : JSON.stringify(respData);
332
+ console.error('[CLI] Response body:', text.slice(0, 500));
333
+ } catch (_) {
334
+ console.error('[CLI] Response body: [unprintable]');
335
+ }
336
+ throw err;
337
+ }
338
+ try {
339
+ const eventStream = guiAgent.getEventStream();
340
+ const allEvents = eventStream.getEvents();
341
+ const runStartEvents = allEvents.filter((e)=>'agent_run_start' === e.type);
342
+ const sessionId = runStartEvents.length > 0 ? runStartEvents[runStartEvents.length - 1].sessionId : `${Date.now()}`;
343
+ const envEvents = allEvents.filter((e)=>'environment_input' === e.type);
344
+ const screenshotEvents = envEvents.filter((e)=>e.metadata && 'screenshot' === e.metadata.type);
345
+ const lastScreenshot = screenshotEvents.length > 0 ? screenshotEvents[screenshotEvents.length - 1] : null;
346
+ const targetOutputDir = options.output ? node_path.resolve(options.output) : node_path.join(node_os.homedir(), '.gui-agent-results');
347
+ console.log(`[CLI] Output directory (resolved): ${targetOutputDir}`);
348
+ node_fs.mkdirSync(targetOutputDir, {
349
+ recursive: true
350
+ });
351
+ console.log(`[CLI] TaskId/SessionId: ${sessionId}`);
352
+ let resultPicPath = '';
353
+ if (lastScreenshot && Array.isArray(lastScreenshot.content)) {
354
+ var _imgPart_image_url1;
355
+ const imgPart = lastScreenshot.content.find((c)=>'image_url' === c.type && c.image_url && c.image_url.url);
356
+ const dataUri = null == imgPart ? void 0 : null == (_imgPart_image_url1 = imgPart.image_url) ? void 0 : _imgPart_image_url1.url;
357
+ if (dataUri && 'string' == typeof dataUri && dataUri.startsWith('data:')) {
358
+ const commaIndex = dataUri.indexOf(',');
359
+ const base64Data = commaIndex >= 0 ? dataUri.substring(commaIndex + 1) : dataUri;
360
+ const buffer = Buffer.from(base64Data, 'base64');
361
+ resultPicPath = node_path.join(targetOutputDir, `${sessionId}.png`);
362
+ node_fs.writeFileSync(resultPicPath, buffer);
363
+ console.log(`[CLI] Screenshot saved: ${resultPicPath}`);
364
+ }
365
+ }
366
+ if (!resultPicPath) console.log('[CLI] No screenshot captured; resultPic will be empty.');
367
+ const finalAnswer = (null == resultEvent ? void 0 : resultEvent.content) ?? '';
368
+ const report = {
369
+ taskId: sessionId,
370
+ resultPic: resultPicPath,
371
+ finalAnswer
372
+ };
373
+ const reportPath = node_path.join(targetOutputDir, `${sessionId}.json`);
374
+ node_fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
375
+ console.log(`Result saved: ${reportPath}`);
376
+ console.log(`[CLI] Report JSON path: ${reportPath}`);
377
+ } catch (err) {
378
+ console.warn('Failed to generate result report:', err);
379
+ }
380
+ };
381
+ const resetConfig = async (configPath)=>{
382
+ const CONFIG_PATH = configPath || node_path.join(node_os.homedir(), '.gui-agent-cli.json');
383
+ try {
384
+ if (node_fs.existsSync(CONFIG_PATH)) {
385
+ node_fs.unlinkSync(CONFIG_PATH);
386
+ console.log(`\u{2713} Configuration file removed: ${CONFIG_PATH}`);
387
+ } else console.log(`No configuration file found at: ${CONFIG_PATH}`);
388
+ console.log('Configuration has been reset. The next time you run gui-agent, you will be prompted to configure your settings again.');
389
+ } catch (error) {
390
+ console.error('Failed to reset configuration:', error);
391
+ process.exit(1);
392
+ }
393
+ };
394
+ export { resetConfig, start };
395
+
396
+ //# sourceMappingURL=start.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli/start.mjs","sources":["webpack://@gui-agent/cli/./src/cli/start.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 fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\n\nimport fetch from 'node-fetch';\nimport { GUIAgent } from '@gui-agent/agent-sdk';\nimport * as p from '@clack/prompts';\nimport yaml from 'js-yaml';\n\nimport { NutJSOperator } from '@gui-agent/operator-nutjs';\nimport { AdbOperator } from '@gui-agent/operator-adb';\nimport { BrowserOperator } from '@gui-agent/operator-browser';\n\nexport interface CliOptions {\n presets?: string;\n target?: string;\n query?: string;\n config?: string;\n output?: string;\n tasks?: string;\n}\n\nexport const start = async (options: CliOptions) => {\n const CONFIG_PATH = options.config || path.join(os.homedir(), '.gui-agent-cli.json');\n\n // read config file\n let config = {\n baseURL: '',\n apiKey: '', // secretlint-disable-line\n model: '',\n provider: 'openai', // Default provider\n useResponsesApi: false,\n maxLoopCount: 1000,\n };\n\n if (options.presets) {\n const response = await fetch(options.presets);\n if (!response.ok) {\n throw new Error(`Failed to fetch preset: ${response.status}`);\n }\n\n const yamlText = await response.text();\n const preset = yaml.load(yamlText) as any;\n\n config.apiKey = preset?.vlmApiKey; // secretlint-disable-line\n config.baseURL = preset?.vlmBaseUrl;\n config.model = preset?.vlmModelName;\n config.useResponsesApi = preset?.useResponsesApi ?? false;\n } else if (fs.existsSync(CONFIG_PATH)) {\n try {\n config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));\n } catch (error) {\n console.warn('read config file failed', error);\n }\n }\n\n if (!config.baseURL || !config.apiKey || !config.model) {\n const configAnswers = await p.group(\n {\n provider: () =>\n p.select({\n message: 'Select model provider:',\n options: [\n { value: 'volcengine', label: 'VolcEngine' },\n { value: 'anthropic', label: 'Anthropic Claude' },\n { value: 'openai', label: 'OpenAI' },\n { value: 'lm-studio', label: 'LM Studio' },\n { value: 'deepseek', label: 'DeepSeek' },\n { value: 'ollama', label: 'Ollama' },\n ],\n }),\n baseURL: () => p.text({ message: 'please input vlm model baseURL:' }),\n apiKey: () => p.text({ message: 'please input vlm model apiKey:' }), // secretlint-disable-line\n model: () => p.text({ message: 'please input vlm model name:' }),\n },\n {\n onCancel: () => {\n p.cancel('operation cancelled');\n process.exit(0);\n },\n },\n );\n\n config = { ...config, ...configAnswers };\n\n // save config to file\n try {\n fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));\n console.log('model config file saved to:', CONFIG_PATH);\n } catch (error) {\n console.error('save model config file failed', error);\n }\n }\n\n // Diagnostic: print model config loaded\n try {\n const maskedKey = config.apiKey\n ? `${config.apiKey.slice(0, 6)}...${config.apiKey.slice(-4)}`\n : '(empty)';\n console.log('[CLI] Loaded model config:');\n console.log(` provider: ${config.provider}`);\n console.log(` baseURL: ${config.baseURL}`);\n console.log(` model: ${config.model}`);\n console.log(` apiKey: ${maskedKey}`); // secretlint-disable-line\n console.log(` useResponsesApi: ${Boolean((config as any).useResponsesApi)}`);\n } catch (e) {\n console.warn('[CLI] Failed to print model config diagnostics:', e);\n }\n\n // Basic baseURL validation and hints for OpenAI-compatible servers\n try {\n if (config.baseURL) {\n let parsed: URL | null = null;\n try {\n parsed = new URL(config.baseURL);\n } catch (_) {\n console.warn('[CLI] Warning: baseURL is not a valid URL:', config.baseURL);\n }\n if (parsed) {\n const endsWithV1 = /\\/v1\\/?$/.test(parsed.pathname);\n if (!endsWithV1) {\n console.warn(\n '[CLI] Hint: OpenAI-compatible endpoints typically end with \"/v1\" (e.g. https://host/v1).',\n );\n }\n if (parsed.protocol !== 'https:') {\n console.warn('[CLI] Hint: use HTTPS for most providers. Current:', parsed.protocol);\n }\n }\n }\n } catch (e) {\n console.warn('[CLI] baseURL validation failed:', e);\n }\n\n // Preflight: check Chat Completions non-streaming response shape for OpenAI-compatible servers\n try {\n if (config.provider === 'openai' && config.baseURL && config.model) {\n const url = new URL(config.baseURL.replace(/\\/$/, ''));\n url.pathname = url.pathname.replace(/\\/$/, '') + '/chat/completions';\n console.log('[CLI] Preflight: POST', url.toString());\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 16000);\n const resp = await fetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${config.apiKey}`,\n },\n body: JSON.stringify({\n model: config.model,\n messages: [{ role: 'user', content: 'ping' }],\n stream: false,\n }),\n signal: controller.signal,\n } as any);\n clearTimeout(timeout);\n const text = await resp.text();\n if (!resp.ok) {\n console.warn('[CLI] Preflight failed:', resp.status, resp.statusText);\n console.warn('[CLI] Preflight response body:', text.slice(0, 500));\n } else {\n try {\n const json = JSON.parse(text);\n const hasChoices = Array.isArray(json?.choices) && json.choices.length > 0;\n console.log('[CLI] Preflight ok. choices[0] exists:', hasChoices);\n if (!hasChoices) {\n console.warn(\n '[CLI] Preflight: response does not contain choices[]. Service may not implement Chat Completions.',\n );\n }\n } catch (_) {\n console.warn('[CLI] Preflight ok but response is not JSON:', text.slice(0, 200));\n }\n }\n }\n } catch (e: any) {\n if (e?.name === 'AbortError') {\n console.warn('[CLI] Preflight check timed out (16s). Proceeding without preflight.');\n } else {\n console.warn('[CLI] Preflight check error:', e);\n }\n }\n\n let targetOperator = null;\n const targetType =\n options.target ||\n ((await p.select({\n message: 'Please select your operator target:',\n options: [\n { value: 'computer', label: 'computer (Desktop automation)' },\n { value: 'android', label: 'android (Android automation)' },\n { value: 'browser', label: 'browser (Web automation)' },\n ],\n })) as string);\n\n switch (targetType) {\n case 'android':\n // Note: AdbOperator will auto-detect connected devices\n console.log('Initializing ADB operator...');\n targetOperator = new AdbOperator();\n break;\n case 'browser':\n // Use default browser options\n targetOperator = new BrowserOperator({\n browserType: 'chrome' as any,\n browser: null as any, // Will be initialized internally\n });\n break;\n case 'computer':\n default:\n targetOperator = new NutJSOperator();\n break;\n }\n\n const useTasksFile = Boolean(options.tasks);\n const answers = useTasksFile\n ? { instruction: '' }\n : options.query\n ? { instruction: options.query }\n : await p.group(\n {\n instruction: () => p.text({ message: 'Input your instruction' }),\n },\n {\n onCancel: () => {\n p.cancel('操作已取消');\n process.exit(0);\n },\n },\n );\n\n const abortController = new AbortController();\n process.on('SIGINT', () => {\n abortController.abort();\n });\n\n const systemPrompts = [\n 'You are provided with a task description, a history of previous actions, and corresponding screenshots. Your goal is to perform the next action to complete the task. Please note that if performing the same action multiple times results in a static screen with no changes, you should attempt a modified or alternative action.',\n '## Function Definition\\n\\n- You have access to the following functions:\\n{\"type\": \"function\", \"name\": \"call_user\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Message or information displayed to the user to request their input, feedback, or guidance.\"}}, \"required\": []}, \"description\": \"This function is used to interact with the user by displaying a message and requesting their input, feedback, or guidance.\"}\\n{\"type\": \"function\", \"name\": \"click\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Click coordinates. The format is: <point>x y</point>\"}}, \"required\": [\"point\"]}, \"description\": \"Mouse left single click action.\"}\\n{\"type\": \"function\", \"name\": \"drag\", \"parameters\": {\"type\": \"object\", \"properties\": {\"start_point\": {\"type\": \"string\", \"description\": \"Drag start point. The format is: <point>x y</point>\"}, \"end_point\": {\"type\": \"string\", \"description\": \"Drag end point. The format is: <point>x y</point>\"}}, \"required\": [\"start_point\", \"end_point\"]}, \"description\": \"Mouse left button drag action.\"}\\n{\"type\": \"function\", \"name\": \"finished\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Provide the final answer or response to complete the task.\"}}, \"required\": []}, \"description\": \"This function is used to indicate the completion of a task by providing the final answer or response.\"}\\n{\"type\": \"function\", \"name\": \"hotkey\", \"parameters\": {\"type\": \"object\", \"properties\": {\"key\": {\"type\": \"string\", \"description\": \"Hotkeys you want to press. Split keys with a space and use lowercase.\"}}, \"required\": [\"key\"]}, \"description\": \"Press hotkey.\"}\\n{\"type\": \"function\", \"function\": {\"name\": \"infeasible\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Message or information displayed to the user to explain why the current task is infeasible.\"}}, \"required\": [\"content\"]}, \"description\": \"This function is used to indicate that the current task is infeasible thus agent ends the task.\"}\\n{\"type\": \"function\", \"name\": \"left_double\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Click coordinates. The format is: <point>x y</point>\"}}, \"required\": [\"point\"]}, \"description\": \"Mouse left double click action.\"}\\n{\"type\": \"function\", \"name\": \"right_single\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Click coordinates. The format is: <point>x y</point>\"}}, \"required\": [\"point\"]}, \"description\": \"Mouse right single click action.\"}\\n{\"type\": \"function\", \"name\": \"scroll\", \"parameters\": {\"type\": \"object\", \"properties\": {\"point\": {\"type\": \"string\", \"description\": \"Scroll start position. If not specified, default to execute on the current mouse position. The format is: <point>x y</point>\"}, \"direction\": {\"type\": \"string\", \"description\": \"Scroll direction.\", \"enum\": [\"up\", \"down\", \"left\", \"right\"]}}, \"required\": [\"direction\", \"point\"]}, \"description\": \"Scroll action.\"}\\n{\"type\": \"function\", \"name\": \"type\", \"parameters\": {\"type\": \"object\", \"properties\": {\"content\": {\"type\": \"string\", \"description\": \"Type content. If you want to submit your input, use \\\\n at the end of content.\"}}, \"required\": [\"content\"]}, \"description\": \"Type content.\"}\\n{\"type\": \"function\", \"name\": \"wait\", \"parameters\": {\"type\": \"object\", \"properties\": {\"time\": {\"type\": \"integer\", \"description\": \"Wait time in seconds.\"}}, \"required\": []}, \"description\": \"Wait for a while.\"}\\n\\n- To call a function, use the following structure without any suffix:\\n\\n<think_never_used_51bce0c785ca2f68081bfa7d91973934> reasoning process </think_never_used_51bce0c785ca2f68081bfa7d91973934>\\n<seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_name><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_1>value_1</parameter_never_used_51bce0c785ca2f68081bfa7d91973934><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934></seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934>\\n\\n## Important Notes\\n- Function calls must begin with <function_never_used_51bce0c785ca2f68081bfa7d91973934= and end with </function_never_used_51bce0c785ca2f68081bfa7d91973934>.\\n- All required parameters must be explicitly provided.\\n\\n## Additional Notes\\n- You can execute multiple actions within a single tool call. For example:\\n<seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_1><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_1>value_1</parameter_never_used_51bce0c785ca2f68081bfa7d91973934><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934><function_never_used_51bce0c785ca2f68081bfa7d91973934=example_function_2><parameter_never_used_51bce0c785ca2f68081bfa7d91973934=example_parameter_3>value_4</parameter_never_used_51bce0c785ca2f68081bfa7d91973934></function_never_used_51bce0c785ca2f68081bfa7d91973934></seed:tool_call_never_used_51bce0c785ca2f68081bfa7d91973934>\\n- 当你判断任务请求是无法执行的时候,你应该调用Infeasible工具结束任务并解释原因。\\n 判断标准:当一个请求符合以下任何一条标准时,应被归类为“无法执行”。\\n 1. 技术/物理层面的矛盾: 指令本身包含逻辑上或物理上无法实现的要求。\\n 2. 工具/功能错配: 指令要求在一个软件中执行另一个软件的功能,或者执行该软件根本不具备的功能。\\n 3. 超出操作边界/范围: 指令要求执行的操作超出了当前用户会话、权限或应用程序的逻辑边界,涉及未告知的隐私信息或者未授权的操作。\\n 4. 依赖隐性知识或外部条件: 任务的完成依赖于Agent无法获取的外部硬件、物理环境、未声明的插件/扩展、或特定的文件/数据。\\n\\n 输出指令:\\n 如果请求被判断为“无法执行”,你应该向用户解释为什么这个任务超出了你的能力范围(例如,指出它需要直接操作某个硬件),并尽可能提供一个指导性的替代方案,让用户可以自己完成该任务。\\n 你应该非常非常谨慎地使用Infeasible工具,因为它会直接结束任务并降低用户体验。所以非必要的时候,你不应该调用Infeasible工具,尽量以finish工具结束任务并向用户提示原因就好。',\n ];\n\n const guiAgent = new GUIAgent({\n model: {\n id: config.model,\n provider: config.provider as any, // Type assertion to avoid TypeScript error\n baseURL: config.baseURL,\n apiKey: config.apiKey, // secretlint-disable-line\n },\n operator: targetOperator,\n systemPrompt: systemPrompts.join('\\n\\n'),\n });\n\n if (useTasksFile) {\n const demoDir = path.resolve(path.join(__dirname, '..', '..', 'demo'));\n const tasksPath =\n options.tasks === 'demo' ? path.join(demoDir, 'tasks.json') : path.resolve(options.tasks!);\n try {\n const dirOfTasks = path.dirname(tasksPath);\n fs.mkdirSync(dirOfTasks, { recursive: true });\n if (!fs.existsSync(tasksPath)) {\n const sample = [\n { taskId: 'task-1', query: 'Open Chrome and go to github.com' },\n { taskId: 'task-2', query: \"Search for 'GUI Agent automation' on Google\" },\n ];\n fs.writeFileSync(tasksPath, JSON.stringify(sample, null, 2));\n console.log(`[CLI] Sample tasks.json created: ${tasksPath}`);\n }\n } catch (e) {\n console.warn('[CLI] Failed to prepare tasks file directory', e);\n }\n\n let tasks: Array<{ taskId: string; query: string }> = [];\n try {\n const raw = fs.readFileSync(tasksPath, 'utf-8');\n const parsed = JSON.parse(raw);\n if (Array.isArray(parsed)) tasks = parsed;\n else console.warn('[CLI] tasks file is not an array');\n } catch (e) {\n console.error('[CLI] Failed to read tasks file', e);\n process.exit(1);\n }\n\n const targetOutputDir = options.output\n ? path.resolve(options.output)\n : options.tasks === 'demo'\n ? path.join(demoDir, 'results')\n : path.join(os.homedir(), '.gui-agent-results');\n console.log(`[CLI] Output directory (resolved): ${targetOutputDir}`);\n fs.mkdirSync(targetOutputDir, { recursive: true });\n\n for (const task of tasks) {\n try {\n const resultEvent = await guiAgent.run(task.query);\n const eventStream = guiAgent.getEventStream();\n const allEvents = eventStream.getEvents();\n const runStartEvents = allEvents.filter((e: any) => e.type === 'agent_run_start');\n const lastRunStart = runStartEvents[runStartEvents.length - 1] as any;\n const startIndex = allEvents.findIndex((e: any) => e.id === lastRunStart?.id);\n const endIndex = allEvents.findIndex(\n (e: any, idx: number) => idx > startIndex && e.type === 'agent_run_end',\n );\n const rangeEvents =\n startIndex >= 0\n ? endIndex >= 0\n ? allEvents.slice(startIndex, endIndex + 1)\n : allEvents.slice(startIndex)\n : allEvents;\n const envEvents = rangeEvents.filter((e: any) => e.type === 'environment_input');\n const screenshotEvents = envEvents.filter(\n (e: any) => e.metadata && e.metadata.type === 'screenshot',\n );\n const lastScreenshot =\n screenshotEvents.length > 0\n ? (screenshotEvents[screenshotEvents.length - 1] as any)\n : null;\n\n let resultPicPath = '';\n if (lastScreenshot && Array.isArray(lastScreenshot.content)) {\n const imgPart = (lastScreenshot.content as any[]).find(\n (c: any) => c.type === 'image_url' && c.image_url && c.image_url.url,\n );\n const dataUri: string | undefined = imgPart?.image_url?.url;\n if (dataUri && typeof dataUri === 'string' && dataUri.startsWith('data:')) {\n const commaIndex = dataUri.indexOf(',');\n const base64Data = commaIndex >= 0 ? dataUri.substring(commaIndex + 1) : dataUri;\n const buffer = Buffer.from(base64Data, 'base64');\n resultPicPath = path.join(targetOutputDir, `${task.taskId}.png`);\n fs.writeFileSync(resultPicPath, buffer);\n console.log(`[CLI] Screenshot saved: ${resultPicPath}`);\n }\n }\n if (!resultPicPath) {\n console.log('[CLI] No screenshot captured; resultPic will be empty.');\n }\n\n const finalAnswer = (resultEvent as any)?.content ?? '';\n const report = {\n taskId: task.taskId,\n resultPic: resultPicPath,\n finalAnswer,\n };\n const reportPath = path.join(targetOutputDir, `${task.taskId}.json`);\n fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));\n console.log(`Result saved: ${reportPath}`);\n console.log(`[CLI] Report JSON path: ${reportPath}`);\n } catch (taskErr) {\n console.error(`[CLI] Task failed: ${task.taskId}`, taskErr);\n }\n }\n return;\n }\n\n // Enhanced error logging around agent run\n let resultEvent: any;\n try {\n console.log(\n '[CLI] Starting GUIAgent run with instruction:',\n answers.instruction || options.query,\n );\n resultEvent = await guiAgent.run(answers.instruction);\n console.log('[CLI] GUIAgent run completed.');\n } catch (err: any) {\n console.error('[CLI] GUIAgent run failed.');\n const errMsg = err?.message || String(err);\n console.error('[CLI] Error message:', errMsg);\n if (err?.status) console.error('[CLI] HTTP status:', err.status);\n if (err?.code) console.error('[CLI] Error code:', err.code);\n const respData = err?.response?.data || err?.response?.body || err?.data;\n if (respData) {\n try {\n const text = typeof respData === 'string' ? respData : JSON.stringify(respData);\n console.error('[CLI] Response body:', text.slice(0, 500));\n } catch (_) {\n console.error('[CLI] Response body: [unprintable]');\n }\n }\n throw err;\n }\n\n try {\n const eventStream = guiAgent.getEventStream();\n const allEvents = eventStream.getEvents();\n const runStartEvents = allEvents.filter((e: any) => e.type === 'agent_run_start');\n const sessionId =\n runStartEvents.length > 0\n ? (runStartEvents[runStartEvents.length - 1] as any).sessionId\n : `${Date.now()}`;\n\n const envEvents = allEvents.filter((e: any) => e.type === 'environment_input');\n const screenshotEvents = envEvents.filter(\n (e: any) => e.metadata && e.metadata.type === 'screenshot',\n );\n const lastScreenshot =\n screenshotEvents.length > 0 ? (screenshotEvents[screenshotEvents.length - 1] as any) : null;\n\n const targetOutputDir = options.output\n ? path.resolve(options.output)\n : path.join(os.homedir(), '.gui-agent-results');\n console.log(`[CLI] Output directory (resolved): ${targetOutputDir}`);\n fs.mkdirSync(targetOutputDir, { recursive: true });\n console.log(`[CLI] TaskId/SessionId: ${sessionId}`);\n\n let resultPicPath = '';\n if (lastScreenshot && Array.isArray(lastScreenshot.content)) {\n const imgPart = (lastScreenshot.content as any[]).find(\n (c: any) => c.type === 'image_url' && c.image_url && c.image_url.url,\n );\n const dataUri: string | undefined = imgPart?.image_url?.url;\n if (dataUri && typeof dataUri === 'string' && dataUri.startsWith('data:')) {\n const commaIndex = dataUri.indexOf(',');\n const base64Data = commaIndex >= 0 ? dataUri.substring(commaIndex + 1) : dataUri;\n const buffer = Buffer.from(base64Data, 'base64');\n resultPicPath = path.join(targetOutputDir, `${sessionId}.png`);\n fs.writeFileSync(resultPicPath, buffer);\n console.log(`[CLI] Screenshot saved: ${resultPicPath}`);\n }\n }\n if (!resultPicPath) {\n console.log('[CLI] No screenshot captured; resultPic will be empty.');\n }\n\n const finalAnswer = (resultEvent as any)?.content ?? '';\n const report = {\n taskId: sessionId,\n resultPic: resultPicPath,\n finalAnswer,\n };\n const reportPath = path.join(targetOutputDir, `${sessionId}.json`);\n fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));\n console.log(`Result saved: ${reportPath}`);\n console.log(`[CLI] Report JSON path: ${reportPath}`);\n } catch (err) {\n console.warn('Failed to generate result report:', err);\n }\n};\n\nexport const resetConfig = async (configPath?: string) => {\n const CONFIG_PATH = configPath || path.join(os.homedir(), '.gui-agent-cli.json');\n\n try {\n if (fs.existsSync(CONFIG_PATH)) {\n fs.unlinkSync(CONFIG_PATH);\n console.log(`✓ Configuration file removed: ${CONFIG_PATH}`);\n } else {\n console.log(`No configuration file found at: ${CONFIG_PATH}`);\n }\n\n console.log(\n 'Configuration has been reset. The next time you run gui-agent, you will be prompted to configure your settings again.',\n );\n } catch (error) {\n console.error('Failed to reset configuration:', error);\n process.exit(1);\n }\n};\n"],"names":["start","options","CONFIG_PATH","path","os","config","response","fetch","Error","yamlText","preset","yaml","fs","JSON","error","console","configAnswers","p","process","maskedKey","Boolean","e","parsed","URL","_","endsWithV1","url","controller","AbortController","timeout","setTimeout","resp","clearTimeout","text","json","hasChoices","Array","targetOperator","targetType","AdbOperator","BrowserOperator","NutJSOperator","useTasksFile","answers","abortController","systemPrompts","guiAgent","GUIAgent","demoDir","__dirname","tasksPath","dirOfTasks","sample","tasks","raw","targetOutputDir","task","resultEvent","eventStream","allEvents","runStartEvents","lastRunStart","startIndex","endIndex","idx","rangeEvents","envEvents","screenshotEvents","lastScreenshot","resultPicPath","_imgPart_image_url","imgPart","c","dataUri","commaIndex","base64Data","buffer","Buffer","finalAnswer","report","reportPath","taskErr","err","_err_response","_err_response1","errMsg","String","respData","sessionId","Date","_imgPart_image_url1","resetConfig","configPath"],"mappings":";;;;;;;;;;;;;;AA6BO,MAAMA,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AQ,IAAI,CAAC,qCAAqCmE;IACpD;AACF;AAEO,MAAMS,cAAc,OAAOC;IAChC,MAAM1F,cAAc0F,cAAczF,UAAAA,IAAS,CAACC,QAAAA,OAAU,IAAI;IAE1D,IAAI;QACF,IAAIQ,QAAAA,UAAa,CAACV,cAAc;YAC9BU,QAAAA,UAAa,CAACV;YACda,QAAQ,GAAG,CAAC,CAAC,qCAA8B,EAAEb,aAAa;QAC5D,OACEa,QAAQ,GAAG,CAAC,CAAC,gCAAgC,EAAEb,aAAa;QAG9Da,QAAQ,GAAG,CACT;IAEJ,EAAE,OAAOD,OAAO;QACdC,QAAQ,KAAK,CAAC,kCAAkCD;QAChDI,QAAQ,IAAI,CAAC;IACf;AACF"}
Binary file
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ "use strict";
6
+ var __webpack_exports__ = {};
7
+ const commands_js_namespaceObject = require("./cli/commands.js");
8
+ (0, commands_js_namespaceObject.run)();
9
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
10
+ Object.defineProperty(exports, '__esModule', {
11
+ value: true
12
+ });
13
+
14
+ //# sourceMappingURL=index.js.map