yiyan-browser-agent 1.0.18 → 1.0.19
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/package.json +2 -2
- package/src/index.js +33 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yiyan-browser-agent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/readfor/yiyan-browser-agent"
|
|
42
|
+
"url": "git+https://github.com/readfor/yiyan-browser-agent.git"
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/readfor/yiyan-browser-agent#readme"
|
|
45
45
|
}
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,8 @@ const path = require('path');
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const config = require('./config');
|
|
8
8
|
const logger = require('./logger');
|
|
9
|
-
const YiyanAgent
|
|
9
|
+
const YiyanAgent = require('./agent');
|
|
10
|
+
const BrowserManager = require('./browser-manager');
|
|
10
11
|
|
|
11
12
|
// ─────────────────────────────────────────────
|
|
12
13
|
// Parse CLI arguments
|
|
@@ -200,12 +201,40 @@ async function main() {
|
|
|
200
201
|
try {
|
|
201
202
|
if (opts.interactive) {
|
|
202
203
|
await agent.runInteractive();
|
|
203
|
-
await shutdown(0, true);
|
|
204
|
+
await shutdown(0, true);
|
|
204
205
|
} else {
|
|
205
206
|
const result = await agent.run(opts.task);
|
|
206
207
|
console.log(JSON.stringify(result, null, 2));
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
|
|
209
|
+
// Success: keep process alive for next task (read from stdin)
|
|
210
|
+
if (result.status === 'success') {
|
|
211
|
+
logger.info('Browser kept open. Enter next task or Ctrl+C to exit...');
|
|
212
|
+
const readline = require('readline');
|
|
213
|
+
const rl = readline.createInterface({
|
|
214
|
+
input : process.stdin,
|
|
215
|
+
output : process.stdout,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Wait for next task
|
|
219
|
+
while (true) {
|
|
220
|
+
const nextTask = await new Promise(resolve => rl.question('', resolve));
|
|
221
|
+
const trimmed = nextTask.trim();
|
|
222
|
+
|
|
223
|
+
if (!trimmed) continue;
|
|
224
|
+
if (['exit', 'quit', 'q'].includes(trimmed.toLowerCase())) break;
|
|
225
|
+
|
|
226
|
+
// Run next task with same browser
|
|
227
|
+
agent.conversation = new ConversationManager();
|
|
228
|
+
await BrowserManager.newChat();
|
|
229
|
+
const nextResult = await agent.run(trimmed);
|
|
230
|
+
console.log(JSON.stringify(nextResult, null, 2));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
rl.close();
|
|
234
|
+
await shutdown(0, true);
|
|
235
|
+
} else {
|
|
236
|
+
await shutdown(0, true); // Error: close browser
|
|
237
|
+
}
|
|
209
238
|
}
|
|
210
239
|
} catch (err) {
|
|
211
240
|
console.log(JSON.stringify({
|