yiyan-browser-agent 1.4.6 → 1.4.8

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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 doubao-browser-agent contributors
3
+ Copyright (c) 2026 Omar Azam
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,228 +1,316 @@
1
- # yiyan-browser-agent
1
+ <div align="center">
2
2
 
3
- NPM package for interacting with Yiyan (文心一言) web version via Playwright. No API key required.
3
+ <img src="https://img.shields.io/badge/status-in%20development-orange?style=for-the-badge" alt="Status: In Development"/>
4
+ <img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen?style=for-the-badge" alt="Node.js"/>
5
+ <img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge" alt="License"/>
6
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen?style=for-the-badge" alt="PRs Welcome"/>
4
7
 
5
- ## Features
8
+ # 🤖 Yiyan Browser Agent (文心一言)
6
9
 
7
- - 🤖 Automated browser interaction with Yiyan web version
8
- - 🔐 Login persistence via Playwright session
9
- - 🌍 Cross-platform: Windows / Ubuntu / macOS
10
- - 📦 Auto-download Chromium (~150MB)
11
- - 🛠️ CLI and Node.js API support
12
- - 📝 TypeScript support with full type definitions
10
+ **An autonomous AI coding agent that runs entirely for free — no API key required.**
13
11
 
14
- ## Installation
12
+ It drives a real browser to talk to [Yiyan (文心一言)](https://yiyan.baidu.com), giving you a Claude Code / Cursor-style coding agent powered by Baidu's AI models at zero cost.
15
13
 
16
- ```bash
17
- npm install yiyan-browser-agent
18
- ```
19
-
20
- Chromium will be automatically downloaded after installation.
14
+ [Installation](#-installation) · [Quick Start](#-quick-start) · [Usage](#-usage) · [Configuration](#-configuration) · [Tools](#-available-tools) · [Contributing](#-contributing)
21
15
 
22
- ### Ubuntu Additional Step
23
-
24
- ```bash
25
- npx playwright install-deps chromium
26
- ```
16
+ ---
27
17
 
28
- This installs required system libraries for Chromium on Ubuntu.
18
+ > ⚠️ **This project is currently in active development.**
19
+ > Core functionality works, but you may encounter rough edges. Bug reports and contributions are very welcome — see [Contributing](#-contributing).
29
20
 
30
- ## Quick Start
21
+ </div>
31
22
 
32
- ### CLI Usage
23
+ ---
33
24
 
34
- ```bash
35
- # First time: login to Yiyan
36
- yiyan-browser-agent login
25
+ ## 🧠 How It Works
37
26
 
38
- # Ask a question (headless mode)
39
- yiyan-browser-agent ask "济宁天气情况"
27
+ Most AI coding agents talk to a paid API. This one doesn't.
40
28
 
41
- # With verbose output
42
- yiyan-browser-agent ask "什么是 TypeScript?" --verbose
29
+ Instead, it uses **Playwright** to control a real Chromium browser, navigates to `yiyan.baidu.com`, sends your task, waits for the response, and parses it to extract tool calls — all automatically. Your local files and terminal are wired up as tools the AI can use, so it can read code, write files, run commands, and and build complete projects step by step.
43
30
 
44
- # Headful mode (visible browser window)
45
- yiyan-browser-agent ask "解释 Promise" --headful
31
+ ```
32
+ Your Terminal
33
+
34
+
35
+ Agent Core ← orchestrates the loop
36
+
37
+ ├──► Browser (Playwright) ← talks to yiyan.baidu.com
38
+ │ │
39
+ │ Yiyan AI (文心一言) ← thinks, decides what tool to use
40
+ │ │
41
+ └──► Tool Executor ← reads/writes files, runs commands
42
+
43
+ Your Project
44
+ ```
46
45
 
47
- # Check login status
48
- yiyan-browser-agent status
46
+ ---
49
47
 
50
- # Clear saved session
51
- yiyan-browser-agent reset
48
+ ## 📦 Installation
52
49
 
53
- # Debug mode (output DOM info for troubleshooting)
54
- yiyan-browser-agent debug
50
+ ```bash
51
+ npm install -g yiyan-browser-agent
55
52
  ```
56
53
 
57
- ### Node.js API
54
+ > Chromium downloads automatically after install (~150 MB, one time only).
55
+
56
+ **Requirements:** Node.js ≥ 18
58
57
 
59
- ```typescript
60
- import { YiyanAgent } from 'yiyan-browser-agent';
58
+ ---
61
59
 
62
- // Create agent instance
63
- const agent = new YiyanAgent({
64
- timeout: 120000, // Timeout in milliseconds (default: 120000)
65
- });
60
+ ## 🚀 Quick Start
66
61
 
67
- // Login first time
68
- await agent.login();
62
+ **1. First run — log in to Yiyan:**
63
+ ```bash
64
+ yiyan-agent --interactive
65
+ ```
66
+ A browser window opens. Log in to your Yiyan (文心一言) account, then come back to the terminal and press **Enter**. Your session is saved — you only do this once.
69
67
 
70
- // Ask a question
71
- const answer = await agent.ask('What is TypeScript?');
72
- console.log('Answer:', answer);
68
+ **2. Give it a task:**
69
+ ```bash
70
+ yiyan-agent "build a REST API in Express with user authentication"
71
+ ```
73
72
 
74
- // Headful mode (visible browser)
75
- const answer2 = await agent.ask('Explain Promise', true);
73
+ **3. Use the short alias `ya` from any project folder:**
74
+ ```bash
75
+ cd ~/my-project
76
+ ya "add input validation to all my API routes"
77
+ ```
76
78
 
77
- // Check login status
78
- const status = agent.status();
79
- console.log('Logged in:', status.loggedIn);
80
- console.log('Session path:', status.sessionPath);
79
+ ---
81
80
 
82
- // Clear saved session
83
- await agent.reset();
81
+ ## 💻 Usage
84
82
 
85
- // Debug mode (for troubleshooting selectors)
86
- await agent.debug();
83
+ ```
84
+ yiyan-agent [OPTIONS] [TASK]
85
+
86
+ -t, --task <task> Task to run (or just type it as the last argument)
87
+ -i, --interactive Keep browser open, run multiple tasks in a session
88
+ -d, --dir <path> Set working directory (default: current directory)
89
+ --debug Print raw AI responses to the terminal
90
+ --headless Run browser invisibly (requires prior login)
91
+ --save-log Save full session log to ~/.yiyan-agent/logs/
92
+ --calibrate Auto-detect DOM selectors (run if agent breaks)
93
+ -h, --help Show help
94
+
95
+ Aliases:
96
+ ya Short form of yiyan-agent
87
97
  ```
88
98
 
89
- ## CLI Commands
99
+ ### Examples
90
100
 
91
- | Command | Description |
92
- |---------|-------------|
93
- | `login` | Open browser for manual login (required first time) |
94
- | `ask "question"` | Send question and get answer |
95
- | `status` | Check login status |
96
- | `reset` | Clear saved session |
97
- | `debug` | Debug mode: output DOM info for troubleshooting |
101
+ ```bash
102
+ # Single task — runs and exits
103
+ yiyan-agent "create a Python script that scrapes Hacker News"
98
104
 
99
- ## CLI Options
105
+ # Interactive mode — keeps browser open between tasks
106
+ yiyan-agent --interactive
100
107
 
101
- | Option | Description |
102
- |--------|-------------|
103
- | `--timeout <ms>` | Timeout in milliseconds (default: 120000) |
104
- | `--headful` | Show browser window (for debugging/captcha) |
105
- | `--verbose` | Show detailed logs |
106
- | `--help` | Show help message |
108
+ # Run on a specific project
109
+ ya --dir ~/projects/my-app "refactor all callbacks to async/await"
107
110
 
108
- ## API Documentation
111
+ # Debug mode (shows what Yiyan is actually outputting)
112
+ ya --debug "build a calculator"
109
113
 
110
- ### `YiyanAgent`
114
+ # Headless mode (faster — browser runs in background)
115
+ ya --headless "write unit tests for utils.js"
111
116
 
112
- Main class for interacting with Yiyan.
117
+ # In interactive mode, type 'new' to start a fresh chat:
118
+ ❯ Task: new
119
+ ```
113
120
 
114
- #### Constructor
121
+ ---
115
122
 
116
- ```typescript
117
- new YiyanAgent(options?: YiyanAgentOptions)
118
- ```
123
+ ## ⚙️ Configuration
119
124
 
120
- **Options:**
121
- - `timeout?: number` - Timeout in milliseconds (default: 120000)
122
- - `profileDir?: string` - Custom session directory
123
- - `verbose?: boolean` - Enable verbose logging (default: false)
125
+ ### Global config — applies everywhere
124
126
 
125
- #### Methods
127
+ Create `~/.yiyan-agent/config.json`:
126
128
 
127
- ##### `login(): Promise<void>`
129
+ ```json
130
+ {
131
+ "HEADLESS": true,
132
+ "MAX_ITERATIONS": 50,
133
+ "STABLE_DELAY": 3000,
134
+ "DEBUG": false
135
+ }
136
+ ```
128
137
 
129
- Open browser window for manual login. Login state is saved automatically.
138
+ ### Per-project config overrides global
130
139
 
131
- ##### `ask(question: string, headful?: boolean): Promise<string>`
140
+ Drop `yiyan-agent.config.json` in your project root:
132
141
 
133
- Send question and return answer.
134
- - `headful: false` (default) - Headless mode
135
- - `headful: true` - Visible browser window
142
+ ```json
143
+ {
144
+ "MAX_ITERATIONS": 60,
145
+ "MAX_OUTPUT_LENGTH": 12000
146
+ }
147
+ ```
136
148
 
137
- ##### `status(): { loggedIn: boolean; sessionPath: string }`
149
+ ### All settings
150
+
151
+ | Setting | Default | Description |
152
+ |---|---|---|
153
+ | `HEADLESS` | `false` | Hide the browser window |
154
+ | `MAX_ITERATIONS` | `40` | Max agent steps per task before stopping |
155
+ | `RESPONSE_TIMEOUT` | `180000` | Max ms to wait for a response (3 min) |
156
+ | `STABLE_DELAY` | `2500` | Ms of silence that means Yiyan is done |
157
+ | `SEND_DELAY` | `400` | Ms between typing and pressing Enter |
158
+ | `MAX_OUTPUT_LENGTH` | `8000` | Truncate long command outputs sent to AI |
159
+ | `DEBUG` | `false` | Print raw AI responses to terminal |
160
+ | `SESSION_DIR` | `~/.yiyan-agent/session` | Where browser cookies are saved |
161
+
162
+ ---
163
+
164
+ ## 🛠️ Available Tools
165
+
166
+ The agent can use these tools autonomously to complete your task:
167
+
168
+ | Tool | Description |
169
+ |---|---|
170
+ | `read_file` | Read a file's contents, optionally by line range |
171
+ | `write_file` | Create or overwrite a file (auto-creates directories) |
172
+ | `append_to_file` | Append text to an existing file |
173
+ | `replace_in_file` | Find and replace text in a file (regex supported) |
174
+ | `delete_file` | Permanently delete a file |
175
+ | `list_directory` | List directory contents, optionally recursive |
176
+ | `create_directory` | Create a directory and all parents |
177
+ | `move_file` | Move or rename a file or directory |
178
+ | `copy_file` | Copy a file to a new location |
179
+ | `get_file_info` | Get file metadata (size, line count, dates) |
180
+ | `run_command` | Execute any shell command |
181
+ | `find_files` | Find files by name pattern (e.g. `*.ts`) |
182
+ | `search_in_files` | Search text inside files (like `grep -r`) |
183
+ | `read_url` | Fetch and read the content of a URL |
184
+ | `write_files` | Write multiple files at once (batch scaffold) |
185
+
186
+ ---
187
+
188
+ ## 📂 Where Data is Stored
189
+
190
+ Everything lives in `~/.yiyan-agent/` in your home directory:
138
191
 
139
- Check login status.
192
+ ```
193
+ ~/.yiyan-agent/
194
+ ├── session/ ← Browser cookies (login once, runs forever)
195
+ ├── logs/ ← Session logs (only saved with --save-log)
196
+ └── config.json ← Your global settings
197
+ ```
140
198
 
141
- ##### `reset(): Promise<void>`
199
+ ---
142
200
 
143
- Clear saved session.
201
+ ## 🔧 Troubleshooting
144
202
 
145
- ##### `debug(): Promise<void>`
203
+ ### Agent responds but creates no files
204
+ The browser DOM rendered the AI's response in a way the parser didn't catch. Run with `--debug` to see exactly what's being received:
205
+ ```bash
206
+ yiyan-agent --debug "build a calculator"
207
+ ```
146
208
 
147
- Start browser in debug mode, output DOM information for troubleshooting selectors.
209
+ ### Agent stops responding / loops
210
+ Yiyan's UI may have changed. Run the calibration tool — it inspects the live DOM and prints updated selectors:
211
+ ```bash
212
+ yiyan-agent --calibrate
213
+ ```
148
214
 
149
- ### Error Types
215
+ ### Login session expired
216
+ Just run without `--headless` — the browser opens and you log in again:
217
+ ```bash
218
+ yiyan-agent --interactive
219
+ ```
150
220
 
151
- | Type | Description |
152
- |------|-------------|
153
- | `BROWSER_LAUNCH` | Failed to launch Chromium |
154
- | `TIMEOUT` | Timeout while waiting for response |
155
- | `NETWORK` | Network or connection error |
156
- | `CAPTCHA` | Captcha detected (use --headful) |
221
+ ### Chromium didn't download automatically
222
+ ```bash
223
+ npx playwright install chromium
224
+ ```
157
225
 
158
- ## How It Works
226
+ ### Response times out on long tasks
227
+ Increase the timeout in your config:
228
+ ```json
229
+ { "RESPONSE_TIMEOUT": 300000, "STABLE_DELAY": 4000 }
230
+ ```
159
231
 
160
- 1. Uses Playwright's built-in Chromium (auto-download)
161
- 2. Launches browser with persistent session context
162
- 3. Navigates to Yiyan chat page
163
- 4. Sends question and waits for response
164
- 5. Extracts response using multiple strategies
165
- 6. Closes browser (session saved for next use)
232
+ ---
166
233
 
167
- ## Session Storage
234
+ ## 🗂️ Project Structure
168
235
 
169
- Session data is stored in:
170
- - Windows: `C:\Users\<user>\.yiyan-browser-agent\session`
171
- - Linux/macOS: `~/.yiyan-browser-agent/session`
236
+ ```
237
+ yiyan-browser-agent/
238
+ ├── src/
239
+ │ ├── index.js ← CLI entry point and argument parsing
240
+ │ ├── agent.js ← Core agent loop (send → wait → parse → execute)
241
+ │ ├── browser.js ← Playwright controller for yiyan.baidu.com
242
+ │ ├── tools.js ← All 15 filesystem and shell tools
243
+ │ ├── parser.js ← Extracts tool calls from AI responses (6 strategies)
244
+ │ ├── prompt.js ← System prompt and conversation history manager
245
+ │ ├── config.js ← Configuration loader (global + per-project)
246
+ │ ├── logger.js ← ANSI-colored terminal output
247
+ │ ├── calibrate.js ← DOM selector inspector / auto-fix tool
248
+ │ └── postinstall.js ← Auto-downloads Chromium after npm install
249
+ ├── LICENSE
250
+ ├── README.md
251
+ └── package.json
252
+ ```
172
253
 
173
- ## Supported Platforms
254
+ ---
174
255
 
175
- | Platform | Status | Notes |
176
- |----------|--------|-------|
177
- | Windows | ✅ | Direct use |
178
- | Ubuntu | ✅ | Run `npx playwright install-deps chromium` first |
179
- | macOS | ✅ | Direct use |
256
+ ## 🤝 Contributing
180
257
 
181
- ## Troubleshooting
258
+ Contributions are very welcome — this project is in active development and there's plenty of room to grow.
182
259
 
183
- ### Ubuntu: Browser doesn't start
260
+ ### Setting up locally
184
261
 
185
262
  ```bash
263
+ git clone https://github.com/YOUR_USERNAME/yiyan-browser-agent
264
+ cd yiyan-browser-agent
265
+ npm install
186
266
  npx playwright install chromium
187
- npx playwright install-deps chromium
188
- yiyan-browser-agent login --verbose
267
+ node src/index.js --interactive
189
268
  ```
190
269
 
191
- ### Timeout in headless mode
270
+ ### Areas that need work
192
271
 
193
- ```bash
194
- # Use headful mode to see what's happening
195
- yiyan-browser-agent ask "question" --headful --verbose
196
- ```
272
+ - 🧪 **Tests** — there are currently no automated tests; a test suite would be a great contribution
273
+ - 🎨 **UI selector resilience** Yiyan updates their UI occasionally; better selector strategies are welcome
274
+ - 🔌 **More tools** — image generation, browser control, database tools, etc.
275
+ - 🌐 **Other AI frontends** — adapting the browser layer to work with other free AI chats
276
+ - 📦 **Windows support** — currently tested on Linux; Windows path handling may need fixes
277
+ - 📝 **Better error messages** — making failures easier to diagnose
197
278
 
198
- ### Captcha detected
279
+ ### How to contribute
199
280
 
200
- ```bash
201
- # Use headful mode to manually solve captcha
202
- yiyan-browser-agent ask "question" --headful
203
- ```
281
+ 1. Fork the repo
282
+ 2. Create a branch: `git checkout -b feature/my-improvement`
283
+ 3. Make your changes
284
+ 4. Open a Pull Request with a clear description
204
285
 
205
- ### Selectors not working
286
+ Please keep PRs focused — one feature or fix per PR makes review much faster.
206
287
 
207
- ```bash
208
- # Use debug mode to see DOM structure
209
- yiyan-browser-agent debug
210
- ```
288
+ ### Reporting bugs
289
+
290
+ Open an issue on GitHub with:
291
+ - What you ran
292
+ - What you expected
293
+ - What actually happened
294
+ - Output of `yiyan-agent --debug "your task"` if relevant
295
+
296
+ ---
297
+
298
+ ## ⚠️ Disclaimer
299
+
300
+ This project automates a web browser to interact with yiyan.baidu.com. Automating web UIs may violate the terms of service of the website being automated. Use this tool for **personal and development purposes only**. The authors take no responsibility for account suspensions or other consequences of use.
301
+
302
+ ---
211
303
 
212
- ## Comparison with deepseek-browser-agent
304
+ ## 📄 License
213
305
 
214
- This package follows similar architecture to [deepseek-browser-agent](https://github.com/Omar-Azam/deepseek-browser-agent):
306
+ MIT see [LICENSE](./LICENSE) for details.
215
307
 
216
- | Feature | yiyan-browser-agent | deepseek-browser-agent |
217
- |---------|---------------------|------------------------|
218
- | Browser | Playwright Chromium | Playwright Chromium |
219
- | Login | Persistent session | Persistent session |
220
- | Platform | Win/Ubuntu/macOS | Linux |
308
+ ---
221
309
 
222
- ## License
310
+ <div align="center">
223
311
 
224
- MIT
312
+ **Built with Playwright · Powered by Yiyan (文心一言) · Free forever**
225
313
 
226
- ## Repository
314
+ If this project helped you, consider giving it a ⭐ on GitHub!
227
315
 
228
- https://github.com/picha/yiyan-browser-agent
316
+ </div>
package/package.json CHANGED
@@ -1,50 +1,45 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.4.6",
4
- "description": "NPM package for interacting with Yiyan (文心一言) web version via Playwright. No API key required.",
3
+ "version": "1.4.8",
4
+ "description": "AI coding agent powered by Yiyan (文心一言) via browser automation no API key needed",
5
+ "main": "src/index.js",
5
6
  "bin": {
6
- "yiyan-browser-agent": "./dist/cli.js"
7
+ "yiyan-agent": "src/index.js",
8
+ "ya": "src/index.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node src/index.js",
12
+ "postinstall": "node src/postinstall.js",
13
+ "debug": "node src/index.js --debug",
14
+ "calibrate": "node src/calibrate.js"
7
15
  },
8
- "main": "./dist/index.js",
9
16
  "files": [
10
- "dist",
17
+ "src/",
11
18
  "README.md",
12
19
  "LICENSE"
13
20
  ],
14
- "scripts": {
15
- "build": "tsup",
16
- "test": "vitest run",
17
- "test:watch": "vitest",
18
- "typecheck": "tsc --noEmit",
19
- "postinstall": "node dist/postinstall.js",
20
- "prepublishOnly": "npm run build && npm run test"
21
- },
22
21
  "dependencies": {
23
22
  "playwright": "^1.45.0"
24
23
  },
25
- "devDependencies": {
26
- "typescript": "^5.0.0",
27
- "vitest": "^3.2.4",
28
- "tsup": "^8.0.0",
29
- "@types/node": "^20.0.0"
24
+ "engines": {
25
+ "node": ">=18.0.0"
30
26
  },
31
27
  "keywords": [
28
+ "ai",
29
+ "agent",
32
30
  "yiyan",
33
- "文心一言",
31
+ "wenxin",
34
32
  "baidu",
35
- "playwright",
36
- "browser",
37
- "agent",
38
- "ai",
39
- "chatbot"
33
+ "browser-automation",
34
+ "coding-agent",
35
+ "cli",
36
+ "llm"
40
37
  ],
38
+ "author": "readfor",
41
39
  "license": "MIT",
42
40
  "repository": {
43
41
  "type": "git",
44
- "url": "https://github.com/picha/yiyan-browser-agent"
45
- },
46
- "bugs": {
47
- "url": "https://github.com/picha/yiyan-browser-agent/issues"
42
+ "url": "git+https://github.com/readfor/yiyan-browser-agent.git"
48
43
  },
49
- "homepage": "https://github.com/picha/yiyan-browser-agent#readme"
50
- }
44
+ "homepage": "https://github.com/readfor/yiyan-browser-agent#readme"
45
+ }
package/src/agent.js ADDED
@@ -0,0 +1,80 @@
1
+ // src/agent.js — Simple agent, one browser per process
2
+ 'use strict';
3
+
4
+ const config = require('./config');
5
+ const logger = require('./logger');
6
+ const YiyanBrowser = require('./browser');
7
+ const { AgentServer } = require('./server');
8
+
9
+ class YiyanAgent {
10
+ constructor(options = {}) {
11
+ this.browser = new YiyanBrowser();
12
+ this.options = options;
13
+ this.server = null; // TCP server for accepting remote tasks
14
+ }
15
+
16
+ async init() {
17
+ await this.browser.launch();
18
+ }
19
+
20
+ async shutdown() {
21
+ if (this.server) {
22
+ await this.server.stop();
23
+ }
24
+ await this.browser.close();
25
+ }
26
+
27
+ async run(task) {
28
+ const startTime = Date.now();
29
+
30
+ logger.info('Sending task to Yiyan...');
31
+ await this.browser.sendMessage(task);
32
+
33
+ logger.info('Waiting for response...');
34
+ const answer = await this.browser.waitForResponse();
35
+
36
+ const duration = Date.now() - startTime;
37
+
38
+ return {
39
+ question: task,
40
+ answer: answer || 'No response',
41
+ duration,
42
+ status: answer ? 'success' : 'error'
43
+ };
44
+ }
45
+
46
+ async runInteractive() {
47
+ // 启动 TCP 服务,接收其他进程的任务
48
+ this.server = new AgentServer(this);
49
+ try {
50
+ await this.server.start();
51
+ logger.info(`Server listening on port ${this.server.port} — other processes can send tasks here`);
52
+ } catch (err) {
53
+ logger.warn(`Failed to start server: ${err.message}`);
54
+ // 继续运行,只是不能接收远程任务
55
+ }
56
+
57
+ const readline = require('readline');
58
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
59
+ const ask = () => new Promise(resolve => rl.question('', resolve));
60
+
61
+ logger.info('Interactive mode — type task and press Enter (exit/quit/q to quit)');
62
+
63
+ while (true) {
64
+ const task = (await ask()).trim();
65
+ if (!task) continue;
66
+ if (['exit', 'quit', 'q'].includes(task.toLowerCase())) break;
67
+
68
+ try {
69
+ await this.browser.newChat();
70
+ const result = await this.run(task);
71
+ console.log(JSON.stringify(result, null, 2));
72
+ } catch (err) {
73
+ console.log(JSON.stringify({ question: task, answer: `Error: ${err.message}`, duration: 0, status: 'error' }, null, 2));
74
+ }
75
+ }
76
+ rl.close();
77
+ }
78
+ }
79
+
80
+ module.exports = YiyanAgent;