@nuanu-ai/agentbrowse 0.2.16 → 0.2.18
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/README.md +13 -2
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -6
- package/dist/secrets/backend.d.ts.map +1 -1
- package/dist/secrets/backend.js +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,22 +81,33 @@ agentbrowse status
|
|
|
81
81
|
agentbrowse close
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
Persist AgentPay gateway config for future runs:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
agentbrowse init ap_...
|
|
88
|
+
agentbrowse init ap_... --api-url https://your-project.supabase.co/functions/v1/api
|
|
89
|
+
```
|
|
90
|
+
|
|
84
91
|
## Configure
|
|
85
92
|
|
|
86
93
|
`agentbrowse` uses the AgentPay backend for browser reasoning and gateway-backed
|
|
87
94
|
operations:
|
|
88
95
|
|
|
89
96
|
```bash
|
|
90
|
-
|
|
97
|
+
agentbrowse init ap_...
|
|
91
98
|
```
|
|
92
99
|
|
|
100
|
+
Use `AGENTPAY_API_KEY` and `AGENTPAY_API_URL` only as explicit runtime
|
|
101
|
+
overrides.
|
|
102
|
+
|
|
93
103
|
## Runtime model
|
|
94
104
|
|
|
95
105
|
- `agentbrowse` persists the active browser session under `~/.agentpay`
|
|
96
106
|
- mock stored secrets for live/manual runs come from one canonical file:
|
|
97
107
|
`~/.agentpay/mock-stored-secrets.json`
|
|
98
108
|
- repo JSON fixtures under `src/secrets/` are fallback seeds and test inputs, not an additional runtime config source
|
|
99
|
-
- all commands require `
|
|
109
|
+
- all commands require AgentPay gateway configuration; prefer `agentbrowse init`
|
|
110
|
+
and use env vars only as runtime overrides
|
|
100
111
|
- the external AI agent remains the orchestration owner
|
|
101
112
|
- `agentbrowse` is a single-step browser toolset, not an internal reactive form loop
|
|
102
113
|
- runtime may enrich `observe` output with semantic hints and validation evidence, but it should not silently auto-submit, auto-retry, or maintain hidden durable field-state machines on behalf of the agent
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBzE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { outputJSON } from '../output.js';
|
|
2
|
+
import { getConfigPath, readConfig, writeConfig } from '../solver/config.js';
|
|
3
|
+
function normalizeApiUrl(value) {
|
|
4
|
+
return value.replace(/\/$/, '');
|
|
5
|
+
}
|
|
6
|
+
export async function init(apiKey, apiUrl) {
|
|
7
|
+
const config = readConfig();
|
|
8
|
+
const normalizedApiKey = apiKey.trim();
|
|
9
|
+
const normalizedApiUrl = apiUrl?.trim() ? normalizeApiUrl(apiUrl.trim()) : undefined;
|
|
10
|
+
const nextConfig = {
|
|
11
|
+
...config,
|
|
12
|
+
agentpay: {
|
|
13
|
+
...(config.agentpay ?? {}),
|
|
14
|
+
apiKey: normalizedApiKey,
|
|
15
|
+
...(normalizedApiUrl ? { apiUrl: normalizedApiUrl } : {}),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
writeConfig(nextConfig);
|
|
19
|
+
outputJSON({
|
|
20
|
+
success: true,
|
|
21
|
+
configPath: getConfigPath(),
|
|
22
|
+
agentpay: {
|
|
23
|
+
apiKeyConfigured: true,
|
|
24
|
+
apiUrl: normalizedApiUrl ?? null,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAiPA,iBAAe,IAAI,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4JhE;AAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAWzF"}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ function usageText() {
|
|
|
11
11
|
return `Usage: ${browseCommandName()} <command> [args] [options]
|
|
12
12
|
|
|
13
13
|
Commands:
|
|
14
|
+
init <apiKey> [--api-url <url>] Configure AgentPay gateway access for AgentBrowse
|
|
14
15
|
launch [url] [options] Launch browser, optionally navigate to URL
|
|
15
16
|
solve-captcha [--timeout <s>] Wait for captcha and solve it on current page
|
|
16
17
|
navigate <url> Navigate current tab to URL
|
|
@@ -38,11 +39,12 @@ Options:
|
|
|
38
39
|
--help Show this help message
|
|
39
40
|
|
|
40
41
|
Environment:
|
|
41
|
-
AGENTPAY_API_KEY
|
|
42
|
+
AGENTPAY_API_KEY Optional runtime override; use init for persisted config
|
|
42
43
|
AGENTPAY_API_URL Optional API base URL override`;
|
|
43
44
|
}
|
|
44
45
|
const KNOWN_COMMANDS = new Set([
|
|
45
46
|
'launch',
|
|
47
|
+
'init',
|
|
46
48
|
'navigate',
|
|
47
49
|
'get-secrets-catalog',
|
|
48
50
|
'create-intent',
|
|
@@ -156,6 +158,28 @@ function parseCaptchaTimeout(args) {
|
|
|
156
158
|
}
|
|
157
159
|
return timeout;
|
|
158
160
|
}
|
|
161
|
+
function parseInitArgs(args) {
|
|
162
|
+
const apiKey = getPositional(args, ['--api-url']);
|
|
163
|
+
if (!apiKey) {
|
|
164
|
+
outputError(`Usage: ${browseCommand('init', '<apiKey>', '[--api-url <url>]')}`);
|
|
165
|
+
}
|
|
166
|
+
const apiUrl = getFlag(args, '--api-url');
|
|
167
|
+
const allowedFlags = new Set(['--api-url']);
|
|
168
|
+
for (let i = 0; i < args.length; i++) {
|
|
169
|
+
const arg = args[i];
|
|
170
|
+
if (!arg.startsWith('--')) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (!allowedFlags.has(arg)) {
|
|
174
|
+
outputError(`Unknown init option: ${arg}`);
|
|
175
|
+
}
|
|
176
|
+
i += 1;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
apiKey: apiKey,
|
|
180
|
+
apiUrl,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
159
183
|
/** Require an active browser session. */
|
|
160
184
|
function requireSessionRecord() {
|
|
161
185
|
const session = loadSession();
|
|
@@ -178,13 +202,21 @@ async function main(argv = process.argv) {
|
|
|
178
202
|
if (!KNOWN_COMMANDS.has(command)) {
|
|
179
203
|
outputError(`Unknown command: ${command}\n\n${usageText()}`);
|
|
180
204
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
205
|
+
if (command !== 'init') {
|
|
206
|
+
try {
|
|
207
|
+
await preflightAgentpayGateway();
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
outputError(err instanceof Error ? err.message : String(err));
|
|
211
|
+
}
|
|
186
212
|
}
|
|
187
213
|
switch (command) {
|
|
214
|
+
case 'init': {
|
|
215
|
+
const { init } = await import('./commands/init.js');
|
|
216
|
+
const initArgs = parseInitArgs(args);
|
|
217
|
+
await init(initArgs.apiKey, initArgs.apiUrl);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
188
220
|
case 'launch': {
|
|
189
221
|
const { launch } = await import('./commands/launch.js');
|
|
190
222
|
const launchArgs = parseLaunchArgs(args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/secrets/backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file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
package/dist/secrets/backend.js
CHANGED
|
@@ -3,6 +3,27 @@ import { resolveHostFromInput, resolveMockStoredSecretValues, syncMockSecretCata
|
|
|
3
3
|
import { createOrReuseMockSecretIntent, getMockSecretIntent, markMockSecretIntentCompleted, } from './mock-agentpay-cabinet.js';
|
|
4
4
|
const ENABLE_MOCK_SECRETS_ENV = 'AGENTBROWSE_ENABLE_MOCK_SECRETS';
|
|
5
5
|
const APPROVAL_CHANNEL = 'agentpay-cabinet';
|
|
6
|
+
function tryParseJsonRecord(value) {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = JSON.parse(value);
|
|
9
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
10
|
+
? parsed
|
|
11
|
+
: null;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function formatAgentpayBackendError(status, text) {
|
|
18
|
+
const parsed = text ? tryParseJsonRecord(text) : null;
|
|
19
|
+
if (!parsed) {
|
|
20
|
+
return `agentpay_secret_backend_http_${status}${text ? `:${text}` : ''}`;
|
|
21
|
+
}
|
|
22
|
+
if (typeof parsed.error === 'string' && parsed.error.length > 0) {
|
|
23
|
+
return `agentpay_secret_backend_http_${status}:${parsed.error}`;
|
|
24
|
+
}
|
|
25
|
+
return `agentpay_secret_backend_http_${status}${text ? `:${text}` : ''}`;
|
|
26
|
+
}
|
|
6
27
|
function envFlagEnabled(value) {
|
|
7
28
|
if (!value) {
|
|
8
29
|
return false;
|
|
@@ -79,7 +100,7 @@ async function requestAgentpay(method, path, body) {
|
|
|
79
100
|
});
|
|
80
101
|
if (!response.ok) {
|
|
81
102
|
const text = await response.text().catch(() => '');
|
|
82
|
-
throw new Error(
|
|
103
|
+
throw new Error(formatAgentpayBackendError(response.status, text));
|
|
83
104
|
}
|
|
84
105
|
return (await response.json());
|
|
85
106
|
}
|
package/package.json
CHANGED