@mercuryo-ai/magicpay-cli 0.1.1 → 0.1.3
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/commands/attach.d.ts.map +1 -1
- package/dist/commands/attach.js +33 -1
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +4 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -7
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../src/commands/attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAQlC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../src/commands/attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAQlC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AAwB5C,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA6B3F"}
|
package/dist/commands/attach.js
CHANGED
|
@@ -1,7 +1,39 @@
|
|
|
1
1
|
import { attach as attachBrowser, close as closeBrowser, } from '@mercuryo-ai/agentbrowse';
|
|
2
2
|
import { loadMagicPayBrowserSession, loadMagicPaySession, saveMagicPaySession, } from '../workflow-state.js';
|
|
3
|
+
function currentPageMetadata(session) {
|
|
4
|
+
const runtime = session.runtime;
|
|
5
|
+
if (!runtime) {
|
|
6
|
+
return { url: '', title: '' };
|
|
7
|
+
}
|
|
8
|
+
const currentPageRef = runtime.currentPageRef;
|
|
9
|
+
const currentPage = (currentPageRef ? runtime.pages?.[currentPageRef] : undefined) ??
|
|
10
|
+
Object.values(runtime.pages ?? {})[0];
|
|
11
|
+
return {
|
|
12
|
+
url: currentPage?.url ?? '',
|
|
13
|
+
title: currentPage?.title ?? '',
|
|
14
|
+
};
|
|
15
|
+
}
|
|
3
16
|
export async function attach(cdpUrl, options) {
|
|
4
|
-
|
|
17
|
+
const existingSession = loadMagicPaySession() ?? loadMagicPayBrowserSession();
|
|
18
|
+
const normalizedCdpUrl = cdpUrl.trim();
|
|
19
|
+
if (existingSession?.cdpUrl?.trim() === normalizedCdpUrl) {
|
|
20
|
+
const session = existingSession;
|
|
21
|
+
const { url, title } = currentPageMetadata(session);
|
|
22
|
+
saveMagicPaySession(session);
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
runtime: 'attached',
|
|
26
|
+
session,
|
|
27
|
+
cdpUrl: session.cdpUrl,
|
|
28
|
+
url,
|
|
29
|
+
title,
|
|
30
|
+
...(options?.provider ? { provider: options.provider } : {}),
|
|
31
|
+
captchaSolveCapable: options?.capabilities?.captchaSolve === true ||
|
|
32
|
+
(session.capabilities?.captchaSolve ===
|
|
33
|
+
true),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
await closeBrowser(existingSession);
|
|
5
37
|
const result = await attachBrowser(cdpUrl, options);
|
|
6
38
|
if (result.success) {
|
|
7
39
|
saveMagicPaySession(result.session);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAEnG,wBAAgB,MAAM,IAAI,0BAA0B,CAEnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,gBAAgB,EAAE,IAAI,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,gBAAgB,EAAE,IAAI,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAwBhE"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { getConfigPath, readConfig, writeConfig } from '../config.js';
|
|
1
|
+
import { getConfigPath, normalizeMagicPayApiUrl, readConfig, writeConfig } from '../config.js';
|
|
2
2
|
import { DEFAULT_MAGICPAY_API_URL } from '../generated/build-config.js';
|
|
3
|
-
function normalizeApiUrl(value) {
|
|
4
|
-
return value.replace(/\/$/, '');
|
|
5
|
-
}
|
|
6
3
|
export function init(apiKey, apiUrl) {
|
|
7
4
|
const config = readConfig();
|
|
8
5
|
const normalizedApiKey = apiKey.trim();
|
|
9
|
-
const normalizedApiUrl = apiUrl?.trim()
|
|
10
|
-
? normalizeApiUrl(apiUrl.trim())
|
|
11
|
-
: DEFAULT_MAGICPAY_API_URL;
|
|
6
|
+
const normalizedApiUrl = normalizeMagicPayApiUrl(apiUrl?.trim() ? apiUrl.trim() : DEFAULT_MAGICPAY_API_URL);
|
|
12
7
|
writeConfig({
|
|
13
8
|
...config,
|
|
14
9
|
gateway: {
|
package/dist/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getMagicPayConfigPath as getConfigPath, getMagicPayHomeDir as getStateDir, readMagicPayConfig as readConfig, writeMagicPayConfig as writeConfig, type MagicPaySharedConfig as MagicPayCliConfig, } from '@mercuryo-ai/magicpay-home';
|
|
1
|
+
export { getMagicPayConfigPath as getConfigPath, getMagicPayHomeDir as getStateDir, normalizeMagicPayApiUrl, readMagicPayConfig as readConfig, writeMagicPayConfig as writeConfig, type MagicPaySharedConfig as MagicPayCliConfig, } from '@mercuryo-ai/magicpay-home';
|
|
2
2
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,aAAa,EACtC,kBAAkB,IAAI,WAAW,EACjC,kBAAkB,IAAI,UAAU,EAChC,mBAAmB,IAAI,WAAW,EAClC,KAAK,oBAAoB,IAAI,iBAAiB,GAC/C,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,aAAa,EACtC,kBAAkB,IAAI,WAAW,EACjC,uBAAuB,EACvB,kBAAkB,IAAI,UAAU,EAChC,mBAAmB,IAAI,WAAW,EAClC,KAAK,oBAAoB,IAAI,iBAAiB,GAC/C,MAAM,4BAA4B,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getMagicPayConfigPath as getConfigPath, getMagicPayHomeDir as getStateDir, readMagicPayConfig as readConfig, writeMagicPayConfig as writeConfig, } from '@mercuryo-ai/magicpay-home';
|
|
1
|
+
export { getMagicPayConfigPath as getConfigPath, getMagicPayHomeDir as getStateDir, normalizeMagicPayApiUrl, readMagicPayConfig as readConfig, writeMagicPayConfig as writeConfig, } from '@mercuryo-ai/magicpay-home';
|
package/dist/gateway.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAE3B,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAE3B,MAAM,mCAAmC,CAAC;AAyB3C,wBAAgB,+BAA+B,IAAI,qBAAqB,GAAG,IAAI,CAiB9E;AAED,wBAAgB,4BAA4B,IAAI,qBAAqB,CAMpE;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;AAE3D,wBAAsB,qBAAqB,CACzC,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CAAO,GACzC,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
package/dist/gateway.js
CHANGED
|
@@ -13,11 +13,8 @@ function trimOrUndefined(value) {
|
|
|
13
13
|
}
|
|
14
14
|
return trimmed;
|
|
15
15
|
}
|
|
16
|
-
function normalizeApiUrl(value) {
|
|
17
|
-
return value.replace(/\/$/, '');
|
|
18
|
-
}
|
|
19
16
|
function appendApiPath(apiUrl, suffix) {
|
|
20
|
-
return `${
|
|
17
|
+
return `${apiUrl}${suffix.startsWith('/') ? suffix : `/${suffix}`}`;
|
|
21
18
|
}
|
|
22
19
|
export function tryResolveMagicPayGatewayConfig() {
|
|
23
20
|
const config = readConfig();
|
|
@@ -30,7 +27,7 @@ export function tryResolveMagicPayGatewayConfig() {
|
|
|
30
27
|
}
|
|
31
28
|
return {
|
|
32
29
|
apiKey,
|
|
33
|
-
apiUrl
|
|
30
|
+
apiUrl,
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
33
|
export function resolveMagicPayGatewayConfig() {
|
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":";AA6VA,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiIvE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAWzF"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { config as loadEnv } from 'dotenv';
|
|
|
3
3
|
import { realpathSync } from 'node:fs';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { attach } from './commands/attach.js';
|
|
6
|
+
import { doctor } from './commands/doctor.js';
|
|
6
7
|
import { endSession } from './commands/end-session.js';
|
|
7
8
|
import { fillSecret } from './commands/fill-secret.js';
|
|
8
9
|
import { findForm } from './commands/find-form.js';
|
|
@@ -21,6 +22,7 @@ import { loadMagicPayBrowserSession, loadMagicPaySession, } from './workflow-sta
|
|
|
21
22
|
loadEnv();
|
|
22
23
|
const KNOWN_COMMANDS = new Set([
|
|
23
24
|
'init',
|
|
25
|
+
'doctor',
|
|
24
26
|
'status',
|
|
25
27
|
'attach',
|
|
26
28
|
'start-session',
|
|
@@ -39,6 +41,7 @@ function usageText() {
|
|
|
39
41
|
|
|
40
42
|
Commands:
|
|
41
43
|
init <apiKey> [--api-url <url>] Configure MagicPay gateway access for the payment CLI
|
|
44
|
+
doctor Check persisted MagicPay config and gateway URL
|
|
42
45
|
status Check gateway health and authenticated agent identity
|
|
43
46
|
attach <cdp-url> [options] Attach the payment CLI to an already prepared browser over CDP
|
|
44
47
|
start-session [name] [--merchant-name <name>]
|
|
@@ -294,6 +297,10 @@ export async function main(argv = process.argv) {
|
|
|
294
297
|
outputJSON(init(initArgs.apiKey, initArgs.apiUrl));
|
|
295
298
|
return;
|
|
296
299
|
}
|
|
300
|
+
case 'doctor': {
|
|
301
|
+
outputJSON(doctor());
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
297
304
|
case 'status': {
|
|
298
305
|
outputJSON(await status());
|
|
299
306
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercuryo-ai/magicpay-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "MagicPay CLI — payment/session/secrets shell with narrow protected-form completion",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,20 @@
|
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=18.0.0"
|
|
28
28
|
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@browserbasehq/stagehand": "^3.0.0",
|
|
31
|
+
"dotenv": "^16.4.0",
|
|
32
|
+
"@mercuryo-ai/captcha-solver": "0.1.1",
|
|
33
|
+
"@mercuryo-ai/magicpay-sdk": "0.1.0-test.3",
|
|
34
|
+
"@mercuryo-ai/magicpay-home": "0.1.4",
|
|
35
|
+
"@mercuryo-ai/agentbrowse": "0.2.50"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.0.0",
|
|
39
|
+
"tsx": "^4.19.0",
|
|
40
|
+
"typescript": "5.9.2",
|
|
41
|
+
"vitest": "^4.0.18"
|
|
42
|
+
},
|
|
29
43
|
"scripts": {
|
|
30
44
|
"build:config:dev": "node scripts/write-build-config.mjs https://durcottggsiesxxqzvbb.supabase.co/functions/v1/api",
|
|
31
45
|
"build:config:prod": "node scripts/write-build-config.mjs https://agents-api.mercuryo.io/functions/v1/api",
|
|
@@ -40,19 +54,5 @@
|
|
|
40
54
|
"test:unit:bare": "MAGICPAY_DISABLE_TELEMETRY=1 vitest run --exclude \"src/__tests__/*.e2e.test.ts\" --exclude \"dist/**\"",
|
|
41
55
|
"test:e2e": "npm run test:deps && npm run test:e2e:bare",
|
|
42
56
|
"test:e2e:bare": "MAGICPAY_DISABLE_TELEMETRY=1 vitest run --no-file-parallelism --maxWorkers=1 src/__tests__/protected-fill.e2e.test.ts"
|
|
43
|
-
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@browserbasehq/stagehand": "^3.0.0",
|
|
46
|
-
"@mercuryo-ai/captcha-solver": "workspace:*",
|
|
47
|
-
"@mercuryo-ai/magicpay-sdk": "workspace:*",
|
|
48
|
-
"@mercuryo-ai/magicpay-home": "workspace:*",
|
|
49
|
-
"@mercuryo-ai/agentbrowse": "workspace:*",
|
|
50
|
-
"dotenv": "^16.4.0"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@types/node": "^22.0.0",
|
|
54
|
-
"tsx": "^4.19.0",
|
|
55
|
-
"typescript": "5.9.2",
|
|
56
|
-
"vitest": "^4.0.18"
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|