yiyan-browser-agent 1.0.29 → 1.0.30

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +20 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "AI coding agent powered by Yiyan (文心一言) via browser automation — no API key needed",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -10,13 +10,14 @@ const YiyanAgent = require('./agent');
10
10
 
11
11
  function parseArgs(argv) {
12
12
  const args = argv.slice(2);
13
- const opts = { task: null, interactive: false, debug: false, headless: false, workingDir: null, calibrate: false, help: false };
13
+ const opts = { task: null, interactive: false, debug: false, headless: false, showBrowser: false, workingDir: null, calibrate: false, help: false };
14
14
 
15
15
  for (let i = 0; i < args.length; i++) {
16
16
  const a = args[i];
17
17
  if (a === '-i' || a === '--interactive') opts.interactive = true;
18
18
  else if (a === '--debug') opts.debug = true;
19
19
  else if (a === '--headless') opts.headless = true;
20
+ else if (a === '--show-browser') opts.showBrowser = true;
20
21
  else if (a === '--calibrate') opts.calibrate = true;
21
22
  else if (a === '-h' || a === '--help') opts.help = true;
22
23
  else if (a === '-d' || a === '--dir') opts.workingDir = args[++i];
@@ -31,19 +32,20 @@ function printHelp() {
31
32
  \x1b[1mYIYAN AGENT\x1b[0m — AI Coding Agent via Browser
32
33
 
33
34
  \x1b[33mUSAGE\x1b[0m
34
- yiyan-agent [TASK]
35
- yiyan-agent --interactive
35
+ yiyan-agent [TASK] # Headless mode (no browser window)
36
+ yiyan-agent -i # Interactive mode (shows browser for login)
36
37
 
37
38
  \x1b[33mOPTIONS\x1b[0m
38
- -i, --interactive Interactive mode
39
- --headless Run without visible browser
40
- --debug Show debug info
41
- --calibrate Debug DOM selectors
42
- -h, --help Show help
39
+ -i, --interactive Interactive mode (shows browser)
40
+ --show-browser Show browser window for single task
41
+ --debug Show debug info
42
+ --calibrate Debug DOM selectors
43
+ -h, --help Show help
43
44
 
44
45
  \x1b[33mEXAMPLES\x1b[0m
45
- yiyan-agent "济宁天气"
46
- yiyan-agent -i
46
+ yiyan-agent "济宁天气" # Runs headless (fast)
47
+ yiyan-agent -i # Login first time
48
+ yiyan-agent "写个脚本" --show-browser # Watch browser work
47
49
  `);
48
50
  }
49
51
 
@@ -53,7 +55,14 @@ async function main() {
53
55
  if (opts.help) { printHelp(); process.exit(0); }
54
56
 
55
57
  if (opts.debug) config.DEBUG = true;
56
- if (opts.headless) config.HEADLESS = true;
58
+
59
+ // Headless logic: interactive mode shows browser, single task runs headless by default
60
+ // User can override with --show-browser to watch single task
61
+ if (opts.interactive || opts.calibrate || opts.showBrowser) {
62
+ config.HEADLESS = false; // Show browser
63
+ } else {
64
+ config.HEADLESS = true; // Single task: headless by default (faster)
65
+ }
57
66
  if (opts.workingDir) {
58
67
  const resolved = path.resolve(opts.workingDir);
59
68
  if (!fs.existsSync(resolved)) { logger.error(`Dir not found: ${resolved}`); process.exit(1); }