@nuanu-ai/agentbrowse 0.1.0 → 0.2.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.
- package/dist/command-name.d.ts +3 -0
- package/dist/command-name.d.ts.map +1 -0
- package/dist/command-name.js +11 -0
- package/dist/index.js +12 -29
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +2 -5
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-name.d.ts","sourceRoot":"","sources":["../src/command-name.ts"],"names":[],"mappings":"AAOA,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,aAAa,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const DEFAULT_BROWSE_COMMAND = 'agentbrowse';
|
|
2
|
+
function normalizeCommandName(value, fallback) {
|
|
3
|
+
const normalized = value?.trim().replace(/\s+/g, ' ');
|
|
4
|
+
return normalized && normalized.length > 0 ? normalized : fallback;
|
|
5
|
+
}
|
|
6
|
+
export function browseCommandName() {
|
|
7
|
+
return normalizeCommandName(process.env.AGENTBROWSE_COMMAND, DEFAULT_BROWSE_COMMAND);
|
|
8
|
+
}
|
|
9
|
+
export function browseCommand(...args) {
|
|
10
|
+
return [browseCommandName(), ...args].join(' ');
|
|
11
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { config as loadEnv } from 'dotenv';
|
|
3
3
|
loadEnv();
|
|
4
|
+
import { browseCommand, browseCommandName } from './command-name.js';
|
|
4
5
|
import { loadSession } from './session.js';
|
|
5
6
|
import { outputError, fatal, info } from './output.js';
|
|
6
|
-
|
|
7
|
+
function usageText() {
|
|
8
|
+
return `Usage: ${browseCommandName()} <command> [args] [options]
|
|
7
9
|
|
|
8
10
|
Commands:
|
|
9
11
|
launch [url] [options] Launch browser, optionally navigate to URL
|
|
@@ -32,12 +34,11 @@ Environment:
|
|
|
32
34
|
AGENTBROWSE_MODEL Optional model override for browsing commands
|
|
33
35
|
AGENTPAY_API_KEY Required only for solve-captcha / gateway-backed solve
|
|
34
36
|
AGENTPAY_API_URL Optional API base URL override for solve-captcha`;
|
|
37
|
+
}
|
|
35
38
|
const KNOWN_COMMANDS = new Set([
|
|
36
39
|
'launch',
|
|
37
40
|
'navigate',
|
|
38
41
|
'solve-captcha',
|
|
39
|
-
'solve',
|
|
40
|
-
'captcha-solve',
|
|
41
42
|
'act',
|
|
42
43
|
'extract',
|
|
43
44
|
'observe',
|
|
@@ -48,7 +49,7 @@ const KNOWN_COMMANDS = new Set([
|
|
|
48
49
|
function getCommand() {
|
|
49
50
|
const rawArgs = process.argv.slice(2);
|
|
50
51
|
if (rawArgs.length === 0 || rawArgs[0] === '--help') {
|
|
51
|
-
info(
|
|
52
|
+
info(usageText());
|
|
52
53
|
process.exit(0);
|
|
53
54
|
}
|
|
54
55
|
const command = rawArgs[0];
|
|
@@ -102,7 +103,7 @@ function parseLaunchArgs(args) {
|
|
|
102
103
|
if (arg === '--profile') {
|
|
103
104
|
const value = args[i + 1];
|
|
104
105
|
if (!value || value.startsWith('--')) {
|
|
105
|
-
outputError(
|
|
106
|
+
outputError(`Usage: ${browseCommand('launch', '[url]', '[--profile <name>]', '[--headless]')}`);
|
|
106
107
|
}
|
|
107
108
|
profile = value;
|
|
108
109
|
i += 1;
|
|
@@ -112,7 +113,7 @@ function parseLaunchArgs(args) {
|
|
|
112
113
|
outputError(`Unknown launch option: ${arg}`);
|
|
113
114
|
}
|
|
114
115
|
if (url) {
|
|
115
|
-
outputError(
|
|
116
|
+
outputError(`Usage: ${browseCommand('launch', '[url]', '[--profile <name>]', '[--headless]')}`);
|
|
116
117
|
}
|
|
117
118
|
url = arg;
|
|
118
119
|
}
|
|
@@ -142,7 +143,7 @@ async function main() {
|
|
|
142
143
|
process.exit(1);
|
|
143
144
|
const { command, args } = parsed;
|
|
144
145
|
if (!KNOWN_COMMANDS.has(command)) {
|
|
145
|
-
outputError(`Unknown command: ${command}\n\n${
|
|
146
|
+
outputError(`Unknown command: ${command}\n\n${usageText()}`);
|
|
146
147
|
}
|
|
147
148
|
switch (command) {
|
|
148
149
|
case 'launch': {
|
|
@@ -158,7 +159,7 @@ async function main() {
|
|
|
158
159
|
case 'navigate': {
|
|
159
160
|
const url = getPositional(args);
|
|
160
161
|
if (!url)
|
|
161
|
-
outputError(
|
|
162
|
+
outputError(`Usage: ${browseCommand('navigate', '<url>')}`);
|
|
162
163
|
const { navigate } = await import('./commands/navigate.js');
|
|
163
164
|
await navigate(requireSession(), url);
|
|
164
165
|
break;
|
|
@@ -169,28 +170,10 @@ async function main() {
|
|
|
169
170
|
await captchaSolve(loadSession(), timeout);
|
|
170
171
|
break;
|
|
171
172
|
}
|
|
172
|
-
// Backward-compatible alias.
|
|
173
|
-
case 'solve': {
|
|
174
|
-
const target = getPositional(args, ['--timeout']);
|
|
175
|
-
if (target !== 'captcha') {
|
|
176
|
-
outputError('Usage: agentbrowse solve captcha [--timeout <seconds>]');
|
|
177
|
-
}
|
|
178
|
-
const timeout = parseCaptchaTimeout(args);
|
|
179
|
-
const { captchaSolve } = await import('./commands/captcha-solve.js');
|
|
180
|
-
await captchaSolve(loadSession(), timeout);
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
// Backward-compatible alias.
|
|
184
|
-
case 'captcha-solve': {
|
|
185
|
-
const timeout = parseCaptchaTimeout(args);
|
|
186
|
-
const { captchaSolve } = await import('./commands/captcha-solve.js');
|
|
187
|
-
await captchaSolve(loadSession(), timeout);
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
173
|
case 'act': {
|
|
191
174
|
const instruction = getPositional(args, ['--variables']);
|
|
192
175
|
if (!instruction)
|
|
193
|
-
outputError(
|
|
176
|
+
outputError(`Usage: ${browseCommand('act', '"<instruction>"')}`);
|
|
194
177
|
let variables;
|
|
195
178
|
const varsJson = getFlag(args, '--variables');
|
|
196
179
|
if (varsJson) {
|
|
@@ -208,7 +191,7 @@ async function main() {
|
|
|
208
191
|
case 'extract': {
|
|
209
192
|
const instruction = getPositional(args, ['--schema']);
|
|
210
193
|
if (!instruction)
|
|
211
|
-
outputError(
|
|
194
|
+
outputError(`Usage: ${browseCommand('extract', '"<instruction>"')}`);
|
|
212
195
|
const schemaJson = getFlag(args, '--schema');
|
|
213
196
|
const { extract } = await import('./commands/extract.js');
|
|
214
197
|
await extract(requireSession(), instruction, schemaJson);
|
|
@@ -222,7 +205,7 @@ async function main() {
|
|
|
222
205
|
}
|
|
223
206
|
case 'screenshot': {
|
|
224
207
|
if (hasFlag(args, '--help')) {
|
|
225
|
-
info(
|
|
208
|
+
info(`Usage: ${browseCommand('screenshot', '[--path <file>]')}`);
|
|
226
209
|
process.exit(0);
|
|
227
210
|
}
|
|
228
211
|
const filePath = getFlag(args, '--path');
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AASD,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,KAAK,CAsBtD;AAED,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAEhD;AAED,+CAA+C;AAC/C,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,6CAA6C;AAC7C,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAG5C"}
|
package/dist/output.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Structured output helpers.
|
|
3
|
-
* Human-readable text to stdout/stderr.
|
|
4
|
-
*/
|
|
1
|
+
import { browseCommandName } from './command-name.js';
|
|
5
2
|
/** Format a value for display. Objects/arrays → indented JSON, rest → string. */
|
|
6
3
|
function formatValue(value) {
|
|
7
4
|
if (value === null || value === undefined)
|
|
@@ -43,6 +40,6 @@ export function info(message) {
|
|
|
43
40
|
}
|
|
44
41
|
/** Fatal crash — unhandled error, exit 1. */
|
|
45
42
|
export function fatal(message) {
|
|
46
|
-
process.stderr.write(`[
|
|
43
|
+
process.stderr.write(`[${browseCommandName()}] Fatal: ${message}\n`);
|
|
47
44
|
process.exit(1);
|
|
48
45
|
}
|