agentcash 0.4.3 → 0.4.4
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/cjs/run-server.cjs +2 -2
- package/dist/esm/check-endpoint-BGFpMl2m.d.ts +109 -0
- package/dist/esm/{chunk-I2B7IMZG.js → chunk-HQLNY2IE.js} +2 -2
- package/dist/esm/chunk-KPHAAIVC.js +38 -0
- package/dist/esm/chunk-KPHAAIVC.js.map +1 -0
- package/dist/esm/{chunk-ODPRAJOO.js → chunk-KROBM6NS.js} +2 -2
- package/dist/esm/{chunk-HHZMUAUM.js → chunk-QN7XSHXI.js} +2 -2
- package/dist/esm/{commands-DOUM3W6U.js → commands-VG6VWHCX.js} +35 -10
- package/dist/esm/commands-VG6VWHCX.js.map +1 -0
- package/dist/esm/index.js +23 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{install-36NUKANM.js → install-5XIW6VXW.js} +2 -2
- package/dist/esm/lib.d.ts +17 -101
- package/dist/esm/lib.js +12 -1
- package/dist/esm/lib.js.map +1 -1
- package/dist/esm/{server-T5JCB7MM.js → server-ZLH7QOUF.js} +5 -5
- package/dist/esm/shared/operations/index.d.ts +1 -1
- package/dist/esm/shared/operations/index.js +2 -2
- package/package.json +3 -3
- package/dist/esm/commands-DOUM3W6U.js.map +0 -1
- /package/dist/esm/{chunk-I2B7IMZG.js.map → chunk-HQLNY2IE.js.map} +0 -0
- /package/dist/esm/{chunk-ODPRAJOO.js.map → chunk-KROBM6NS.js.map} +0 -0
- /package/dist/esm/{chunk-HHZMUAUM.js.map → chunk-QN7XSHXI.js.map} +0 -0
- /package/dist/esm/{install-36NUKANM.js.map → install-5XIW6VXW.js.map} +0 -0
- /package/dist/esm/{server-T5JCB7MM.js.map → server-ZLH7QOUF.js.map} +0 -0
package/dist/cjs/run-server.cjs
CHANGED
|
@@ -110778,7 +110778,7 @@ var import_path2 = require("path");
|
|
|
110778
110778
|
var import_url = require("url");
|
|
110779
110779
|
function getVersion2() {
|
|
110780
110780
|
if (true) {
|
|
110781
|
-
return "0.4.
|
|
110781
|
+
return "0.4.4";
|
|
110782
110782
|
}
|
|
110783
110783
|
const __dirname3 = (0, import_path2.dirname)((0, import_url.fileURLToPath)(importMetaUrl));
|
|
110784
110784
|
const pkg = JSON.parse(
|
|
@@ -111518,7 +111518,7 @@ var import_path3 = require("path");
|
|
|
111518
111518
|
var import_url2 = require("url");
|
|
111519
111519
|
function getVersion3() {
|
|
111520
111520
|
if (true) {
|
|
111521
|
-
return "0.4.
|
|
111521
|
+
return "0.4.4";
|
|
111522
111522
|
}
|
|
111523
111523
|
const __dirname3 = (0, import_path3.dirname)((0, import_url2.fileURLToPath)(importMetaUrl));
|
|
111524
111524
|
const pkg = JSON.parse(
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
2
|
+
interface JsonObject {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
}
|
|
5
|
+
type JsonArray = JsonValue[];
|
|
6
|
+
|
|
7
|
+
interface EndpointSummary {
|
|
8
|
+
path: string;
|
|
9
|
+
method: string;
|
|
10
|
+
summary: string;
|
|
11
|
+
price?: string;
|
|
12
|
+
protocols?: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface OpenApiInfo {
|
|
16
|
+
title: string;
|
|
17
|
+
version?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
interface DiscoveryResult {
|
|
21
|
+
origin: string;
|
|
22
|
+
source: 'openapi';
|
|
23
|
+
info?: OpenApiInfo;
|
|
24
|
+
endpoints: EndpointSummary[];
|
|
25
|
+
instructions?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Discover payment-protected resources on an origin.
|
|
29
|
+
* Fetches OpenAPI spec, builds endpoint index, and fetches llms.txt instructions.
|
|
30
|
+
*
|
|
31
|
+
* Returns DiscoveryResult on success, null if no spec/endpoints found.
|
|
32
|
+
*/
|
|
33
|
+
declare function discoverResources(surface: string, url: string): Promise<DiscoveryResult | null>;
|
|
34
|
+
|
|
35
|
+
type PaymentProtocol = 'x402' | 'mpp';
|
|
36
|
+
|
|
37
|
+
declare const SUPPORTED_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
38
|
+
type SupportedMethod = (typeof SUPPORTED_METHODS)[number];
|
|
39
|
+
/** Fields common to every payment option regardless of protocol. */
|
|
40
|
+
interface PaymentOptionBase {
|
|
41
|
+
/** Protocol that issued this payment option. */
|
|
42
|
+
protocol: PaymentProtocol;
|
|
43
|
+
/** Human-readable price in dollars (e.g., 0.02). */
|
|
44
|
+
price: number;
|
|
45
|
+
/** CAIP-2 style chain identifier (e.g., "eip155:8453", "tempo:4217"). */
|
|
46
|
+
network: string;
|
|
47
|
+
/** Token / asset contract address. */
|
|
48
|
+
asset: string;
|
|
49
|
+
/** Payment destination address. */
|
|
50
|
+
recipient?: string;
|
|
51
|
+
/** Human-readable description of the resource being paid for. */
|
|
52
|
+
description?: string;
|
|
53
|
+
}
|
|
54
|
+
/** MPP (Machine Payments Protocol) payment option. */
|
|
55
|
+
interface MppPaymentOption extends PaymentOptionBase {
|
|
56
|
+
protocol: 'mpp';
|
|
57
|
+
/** Payment method identifier (e.g., "tempo", "stripe"). */
|
|
58
|
+
paymentMethod: string;
|
|
59
|
+
/** Payment intent type (e.g., "charge", "session"). */
|
|
60
|
+
intent: string;
|
|
61
|
+
/** Server protection realm. */
|
|
62
|
+
realm: string;
|
|
63
|
+
}
|
|
64
|
+
/** x402 payment option. */
|
|
65
|
+
interface X402PaymentOption extends PaymentOptionBase {
|
|
66
|
+
protocol: 'x402';
|
|
67
|
+
/** Response MIME type from the x402 resource descriptor. */
|
|
68
|
+
mimeType?: string;
|
|
69
|
+
}
|
|
70
|
+
/** A single payment option extracted from a 402 response. */
|
|
71
|
+
type PaymentOption = MppPaymentOption | X402PaymentOption;
|
|
72
|
+
/** A single method's probe outcome (only 402 or 2xx responses are kept). */
|
|
73
|
+
interface ProbeMethodResult {
|
|
74
|
+
method: SupportedMethod;
|
|
75
|
+
requiresPayment: boolean;
|
|
76
|
+
statusCode: number;
|
|
77
|
+
protocols?: PaymentProtocol[];
|
|
78
|
+
paymentOptions?: PaymentOption[];
|
|
79
|
+
/** OpenAPI operation schema when available. */
|
|
80
|
+
schema?: JsonObject;
|
|
81
|
+
/** Advisory price string from the OpenAPI x-payment-info extension. */
|
|
82
|
+
estimatedPrice?: string;
|
|
83
|
+
/** Human-readable summary from the OpenAPI spec. */
|
|
84
|
+
summary?: string;
|
|
85
|
+
}
|
|
86
|
+
interface CheckEndpointResult {
|
|
87
|
+
url: string;
|
|
88
|
+
results: ProbeMethodResult[];
|
|
89
|
+
}
|
|
90
|
+
interface CheckEndpointOptions {
|
|
91
|
+
surface: string;
|
|
92
|
+
url: string;
|
|
93
|
+
/** Methods to probe. Defaults to spec-defined methods, or all if no spec / probeAllMethods is set. */
|
|
94
|
+
methods?: SupportedMethod[];
|
|
95
|
+
body?: unknown;
|
|
96
|
+
headers?: Record<string, string>;
|
|
97
|
+
/** When true, include 404/405 responses in results. Useful when a specific method is targeted. */
|
|
98
|
+
includeMethodErrors?: boolean;
|
|
99
|
+
/** When true, probe all HTTP methods regardless of what the OpenAPI spec declares. */
|
|
100
|
+
probeAllMethods?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Probe an endpoint across one or more HTTP methods in parallel.
|
|
104
|
+
* Returns only the methods that responded with 402 or 2xx.
|
|
105
|
+
* Does not make any payment.
|
|
106
|
+
*/
|
|
107
|
+
declare function checkEndpoint({ surface, url, methods, body, headers, includeMethodErrors, probeAllMethods, }: CheckEndpointOptions): Promise<CheckEndpointResult>;
|
|
108
|
+
|
|
109
|
+
export { type CheckEndpointOptions as C, type DiscoveryResult as D, type MppPaymentOption as M, type OpenApiInfo as O, type PaymentOption as P, SUPPORTED_METHODS as S, type X402PaymentOption as X, type CheckEndpointResult as a, type ProbeMethodResult as b, type SupportedMethod as c, checkEndpoint as d, discoverResources as e };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MCP_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KROBM6NS.js";
|
|
4
4
|
import {
|
|
5
5
|
getBalance,
|
|
6
6
|
getBaseUrl,
|
|
@@ -115,4 +115,4 @@ export {
|
|
|
115
115
|
getWalletInfo,
|
|
116
116
|
submitErrorReport
|
|
117
117
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-HQLNY2IE.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ok,
|
|
3
|
+
safeFetchJson
|
|
4
|
+
} from "./chunk-TRPO7BKD.js";
|
|
5
|
+
|
|
6
|
+
// src/shared/operations/register.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var AGENTCASH_BASE_URL = "https://agentcash.dev";
|
|
9
|
+
var AGENTCASH_DEV_URL = "http://localhost:3000";
|
|
10
|
+
var getRegisterUrl = (dev) => `${dev ? AGENTCASH_DEV_URL : AGENTCASH_BASE_URL}/api/register`;
|
|
11
|
+
var registerResponseSchema = z.object({
|
|
12
|
+
origin: z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
origin: z.string(),
|
|
15
|
+
name: z.string()
|
|
16
|
+
}),
|
|
17
|
+
resourceCount: z.number()
|
|
18
|
+
});
|
|
19
|
+
async function registerOrigin(surface, input, dev) {
|
|
20
|
+
const result = await safeFetchJson(
|
|
21
|
+
surface,
|
|
22
|
+
new Request(getRegisterUrl(dev), {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: { "Content-Type": "application/json" },
|
|
25
|
+
body: JSON.stringify({ url: input.url })
|
|
26
|
+
}),
|
|
27
|
+
registerResponseSchema
|
|
28
|
+
);
|
|
29
|
+
if (result.isErr()) {
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
return ok(result.value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
registerOrigin
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-KPHAAIVC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/operations/register.ts"],"sourcesContent":["import { z } from 'zod';\nimport { ok } from '@agentcash/neverthrow';\n\nimport { safeFetchJson } from '@/shared/neverthrow/fetch';\n\nconst AGENTCASH_BASE_URL = 'https://agentcash.dev';\nconst AGENTCASH_DEV_URL = 'http://localhost:3000';\n\nconst getRegisterUrl = (dev: boolean) =>\n `${dev ? AGENTCASH_DEV_URL : AGENTCASH_BASE_URL}/api/register`;\n\n/**\n * Input for registering an origin with agentcash.\n */\nexport interface RegisterInput {\n url: string;\n}\n\n/**\n * Result returned from a successful registration.\n */\nexport interface RegisterResult {\n origin: {\n id: string;\n origin: string;\n name: string;\n };\n resourceCount: number;\n}\n\nconst registerResponseSchema = z.object({\n origin: z.object({\n id: z.string(),\n origin: z.string(),\n name: z.string(),\n }),\n resourceCount: z.number(),\n});\n\n/**\n * Register an origin with agentcash by POSTing to agentcash.dev/api/register.\n */\nexport async function registerOrigin(\n surface: string,\n input: RegisterInput,\n dev: boolean\n) {\n const result = await safeFetchJson(\n surface,\n new Request(getRegisterUrl(dev), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ url: input.url }),\n }),\n registerResponseSchema\n );\n\n if (result.isErr()) {\n return result;\n }\n\n return ok<RegisterResult>(result.value);\n}\n"],"mappings":";;;;;;AAAA,SAAS,SAAS;AAKlB,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB;AAE1B,IAAM,iBAAiB,CAAC,QACtB,GAAG,MAAM,oBAAoB,kBAAkB;AAqBjD,IAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,QAAQ,EAAE,OAAO;AAAA,IACf,IAAI,EAAE,OAAO;AAAA,IACb,QAAQ,EAAE,OAAO;AAAA,IACjB,MAAM,EAAE,OAAO;AAAA,EACjB,CAAC;AAAA,EACD,eAAe,EAAE,OAAO;AAC1B,CAAC;AAKD,eAAsB,eACpB,SACA,OACA,KACA;AACA,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA,IAAI,QAAQ,eAAe,GAAG,GAAG;AAAA,MAC/B,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,EAAE,KAAK,MAAM,IAAI,CAAC;AAAA,IACzC,CAAC;AAAA,IACD;AAAA,EACF;AAEA,MAAI,OAAO,MAAM,GAAG;AAClB,WAAO;AAAA,EACT;AAEA,SAAO,GAAmB,OAAO,KAAK;AACxC;","names":[]}
|
|
@@ -4,7 +4,7 @@ import { dirname, join } from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
function getVersion() {
|
|
6
6
|
if (true) {
|
|
7
|
-
return "0.4.
|
|
7
|
+
return "0.4.4";
|
|
8
8
|
}
|
|
9
9
|
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
const pkg = JSON.parse(
|
|
@@ -19,4 +19,4 @@ export {
|
|
|
19
19
|
MCP_VERSION,
|
|
20
20
|
DIST_TAG
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-KROBM6NS.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTempoBalance
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HQLNY2IE.js";
|
|
4
4
|
import {
|
|
5
5
|
detectPaymentProtocols,
|
|
6
6
|
safeCreatePaymentPayload,
|
|
@@ -358,4 +358,4 @@ export {
|
|
|
358
358
|
safeGetMppChallenge,
|
|
359
359
|
createFetchWithPayment
|
|
360
360
|
};
|
|
361
|
-
//# sourceMappingURL=chunk-
|
|
361
|
+
//# sourceMappingURL=chunk-QN7XSHXI.js.map
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerOrigin
|
|
3
|
+
} from "./chunk-KPHAAIVC.js";
|
|
1
4
|
import {
|
|
2
5
|
buildRequest,
|
|
3
6
|
createFetchWithPayment,
|
|
4
7
|
requestSchema
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QN7XSHXI.js";
|
|
6
9
|
import {
|
|
7
10
|
TEMPO_RPC_URL,
|
|
8
11
|
getWalletInfo,
|
|
9
12
|
submitErrorReport
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-HQLNY2IE.js";
|
|
11
14
|
import {
|
|
12
15
|
checkEndpoint,
|
|
13
16
|
discoverResources
|
|
14
17
|
} from "./chunk-RBBAPXT5.js";
|
|
15
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-KROBM6NS.js";
|
|
16
19
|
import {
|
|
17
20
|
DEFAULT_NETWORK,
|
|
18
21
|
getWallet,
|
|
@@ -382,11 +385,32 @@ async function discoverCommand(args, flags) {
|
|
|
382
385
|
);
|
|
383
386
|
}
|
|
384
387
|
|
|
388
|
+
// src/cli/commands/register.ts
|
|
389
|
+
var SURFACE3 = "cli:register";
|
|
390
|
+
async function registerCommand(args, flags) {
|
|
391
|
+
const result = await registerOrigin(SURFACE3, { url: args.url }, flags.dev);
|
|
392
|
+
if (result.isErr()) {
|
|
393
|
+
return outputAndExit(fromNeverthrowError(result), flags);
|
|
394
|
+
}
|
|
395
|
+
const { origin, resourceCount } = result.value;
|
|
396
|
+
return outputAndExit(
|
|
397
|
+
successResponse({
|
|
398
|
+
origin: {
|
|
399
|
+
id: origin.id,
|
|
400
|
+
origin: origin.origin,
|
|
401
|
+
name: origin.name
|
|
402
|
+
},
|
|
403
|
+
resourceCount
|
|
404
|
+
}),
|
|
405
|
+
flags
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
385
409
|
// src/cli/commands/wallet.ts
|
|
386
|
-
var
|
|
410
|
+
var SURFACE4 = "cli:wallet";
|
|
387
411
|
async function walletInfoCommand(_args, flags) {
|
|
388
412
|
const { account } = await getWalletOrExit(flags);
|
|
389
|
-
const result = await getWalletInfo(
|
|
413
|
+
const result = await getWalletInfo(SURFACE4, account.address, flags);
|
|
390
414
|
if (result.isErr()) {
|
|
391
415
|
return outputAndExit(fromNeverthrowError(result), flags);
|
|
392
416
|
}
|
|
@@ -411,7 +435,7 @@ async function walletRedeemCommand(args, flags) {
|
|
|
411
435
|
code: args.code,
|
|
412
436
|
dev: flags.dev,
|
|
413
437
|
address: account.address,
|
|
414
|
-
surface:
|
|
438
|
+
surface: SURFACE4
|
|
415
439
|
});
|
|
416
440
|
if (result.isErr()) {
|
|
417
441
|
return outputAndExit(fromNeverthrowError(result), flags);
|
|
@@ -427,11 +451,11 @@ async function walletRedeemCommand(args, flags) {
|
|
|
427
451
|
}
|
|
428
452
|
|
|
429
453
|
// src/cli/commands/report-error.ts
|
|
430
|
-
var
|
|
454
|
+
var SURFACE5 = "cli:report-error";
|
|
431
455
|
async function reportErrorCommand(args, flags) {
|
|
432
456
|
const { account } = await getWalletOrExit(flags);
|
|
433
457
|
const result = await submitErrorReport(
|
|
434
|
-
|
|
458
|
+
SURFACE5,
|
|
435
459
|
{
|
|
436
460
|
tool: args.tool,
|
|
437
461
|
summary: args.summary,
|
|
@@ -458,16 +482,17 @@ async function reportErrorCommand(args, flags) {
|
|
|
458
482
|
|
|
459
483
|
// src/cli/commands/server.ts
|
|
460
484
|
async function serverCommand(flags) {
|
|
461
|
-
const { startServer } = await import("./server-
|
|
485
|
+
const { startServer } = await import("./server-ZLH7QOUF.js");
|
|
462
486
|
await startServer(flags);
|
|
463
487
|
}
|
|
464
488
|
export {
|
|
465
489
|
checkCommand,
|
|
466
490
|
discoverCommand,
|
|
467
491
|
fetchCommand,
|
|
492
|
+
registerCommand,
|
|
468
493
|
reportErrorCommand,
|
|
469
494
|
serverCommand,
|
|
470
495
|
walletInfoCommand,
|
|
471
496
|
walletRedeemCommand
|
|
472
497
|
};
|
|
473
|
-
//# sourceMappingURL=commands-
|
|
498
|
+
//# sourceMappingURL=commands-VG6VWHCX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/fetch.ts","../../src/cli/output/types.ts","../../src/cli/output/format.ts","../../src/cli/output/response.ts","../../src/cli/commands/lib/get-wallet-or-exit.ts","../../src/cli/commands/lib/parse-request-input.ts","../../src/cli/commands/check.ts","../../src/cli/commands/discover.ts","../../src/cli/commands/register.ts","../../src/cli/commands/wallet.ts","../../src/cli/commands/report-error.ts","../../src/cli/commands/server.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nimport { x402Client, x402HTTPClient } from '@x402/core/client';\nimport { ExactEvmScheme } from '@x402/evm/exact/client';\nimport { Mppx, tempo as tempoMethod } from 'mppx/client';\nimport { createClient, http } from 'viem';\nimport { tempo } from 'viem/chains';\n\nimport {\n successResponse,\n errorResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { buildRequest } from '@/server/tools/lib/request';\nimport { DEFAULT_NETWORK } from '@/shared/networks';\nimport { TEMPO_RPC_URL } from '@/shared/tempo';\nimport { safeParseResponse } from '@/shared/neverthrow/fetch';\nimport { createFetchWithPayment } from '@/shared/operations/fetch-with-payment';\nimport { getWalletOrExit, parseRequestInput } from './lib';\n\nimport type { GlobalFlags } from '@/types';\nimport type { JsonObject } from '@/shared/neverthrow/json/types';\n\nconst SURFACE = 'cli:fetch';\n\ninterface FetchArgs {\n url: string;\n method?: string;\n body?: string;\n headers?: string;\n paymentMethod?: string;\n}\n\nexport async function fetchCommand(\n args: FetchArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n const sessionId = randomBytes(16).toString('hex');\n\n const input = parseRequestInput(SURFACE, args, flags);\n\n // Set up x402 client\n const coreClient = x402Client.fromConfig({\n schemes: [\n { network: DEFAULT_NETWORK, client: new ExactEvmScheme(account) },\n ],\n });\n const x402HttpClient = new x402HTTPClient(coreClient);\n\n // Set up MPP client (polyfill: false — we handle 402 retries ourselves)\n const mppxClient = Mppx.create({\n polyfill: false,\n methods: [\n tempoMethod({\n account,\n getClient: () =>\n createClient({ chain: tempo, transport: http(TEMPO_RPC_URL) }),\n }),\n ],\n });\n\n const provider = flags.provider ?? account.address;\n const paymentMethod = (args.paymentMethod ?? 'auto') as\n | 'x402'\n | 'mpp'\n | 'auto';\n\n const request = buildRequest({\n input,\n address: account.address,\n sessionId,\n provider,\n });\n\n const fetchResult = await createFetchWithPayment({\n surface: SURFACE,\n clients: { x402: x402HttpClient, mpp: mppxClient },\n paymentMethod,\n account,\n flags,\n })(request);\n\n if (fetchResult.isErr()) {\n return outputAndExit(fromNeverthrowError(fetchResult), flags);\n }\n\n const { response, paymentInfo } = fetchResult.value;\n\n if (!response.ok) {\n const parseResult = await safeParseResponse(SURFACE, response);\n const details: JsonObject = { statusCode: response.status };\n if (parseResult.isOk()) {\n const { type } = parseResult.value;\n if (type === 'json') {\n details.body = parseResult.value.data;\n } else if (type === 'text') {\n details.body = parseResult.value.data;\n } else {\n details.bodyType = type;\n }\n }\n return outputAndExit(\n errorResponse({\n code: 'HTTP_ERROR',\n message: `HTTP ${response.status}: ${response.statusText}`,\n surface: SURFACE,\n cause: 'http',\n details,\n }),\n flags\n );\n }\n\n const parseResponseResult = await safeParseResponse(SURFACE, response);\n if (parseResponseResult.isErr()) {\n return outputAndExit(fromNeverthrowError(parseResponseResult), flags);\n }\n\n // Build response data\n const data =\n parseResponseResult.value.type === 'json'\n ? parseResponseResult.value.data\n : parseResponseResult.value.type === 'text'\n ? parseResponseResult.value.data\n : { type: parseResponseResult.value.type };\n\n // Build metadata from paymentInfo\n const metadata = paymentInfo\n ? {\n protocol: paymentInfo.protocol,\n ...(paymentInfo.price ? { price: paymentInfo.price } : {}),\n ...(paymentInfo.payment ? { payment: paymentInfo.payment } : {}),\n }\n : undefined;\n\n outputAndExit(successResponse(data, metadata), flags);\n}\n","import type { JsonObject } from '@/shared/neverthrow/json/types';\n\n/**\n * Exit codes for CLI commands\n * Allows agents to programmatically determine error types\n */\nexport enum ExitCode {\n Success = 0,\n GeneralError = 1,\n InsufficientBalance = 2,\n NetworkError = 3,\n PaymentFailed = 4,\n InvalidInput = 5,\n}\n\n/**\n * Error codes for structured error responses\n */\nexport type ErrorCode =\n | 'GENERAL_ERROR'\n | 'INSUFFICIENT_BALANCE'\n | 'NETWORK_ERROR'\n | 'PAYMENT_FAILED'\n | 'INVALID_INPUT'\n | 'WALLET_ERROR'\n | 'PARSE_ERROR'\n | 'HTTP_ERROR'\n | 'X402_ERROR';\n\n/**\n * Maps error codes to exit codes\n */\nexport const errorCodeToExitCode: Record<ErrorCode, ExitCode> = {\n GENERAL_ERROR: ExitCode.GeneralError,\n INSUFFICIENT_BALANCE: ExitCode.InsufficientBalance,\n NETWORK_ERROR: ExitCode.NetworkError,\n PAYMENT_FAILED: ExitCode.PaymentFailed,\n INVALID_INPUT: ExitCode.InvalidInput,\n WALLET_ERROR: ExitCode.GeneralError,\n PARSE_ERROR: ExitCode.InvalidInput,\n HTTP_ERROR: ExitCode.NetworkError,\n X402_ERROR: ExitCode.PaymentFailed,\n};\n\n/**\n * Payment metadata included in successful paid responses\n */\nexport interface PaymentMetadata {\n success: boolean;\n transactionHash?: string;\n}\n\n/**\n * Metadata included in CLI responses\n */\nexport interface ResponseMetadata {\n price?: string;\n payment?: PaymentMetadata;\n}\n\n/**\n * Successful CLI response\n */\nexport interface CliSuccessResponse {\n success: true;\n data: JsonObject | string;\n metadata?: ResponseMetadata;\n}\n\n/**\n * Error details in CLI response\n */\nexport interface CliErrorDetails {\n code: ErrorCode;\n message: string;\n surface?: string;\n cause?: string;\n details?: JsonObject;\n}\n\n/**\n * Failed CLI response\n */\nexport interface CliErrorResponse {\n success: false;\n error: CliErrorDetails;\n}\n\n/**\n * Union type for all CLI responses\n */\nexport type CliResponse = CliSuccessResponse | CliErrorResponse;\n\n/**\n * Output format options\n */\nexport type OutputFormat = 'json' | 'pretty';\n","import type { OutputFormat } from './types';\n\n/**\n * Detect if stdout is a TTY (interactive terminal)\n */\nfunction isTTY(): boolean {\n return process.stdout.isTTY ?? false;\n}\n\n/**\n * Determine output format based on flags and environment\n * - Explicit --format flag takes precedence\n * - Non-TTY (piped) defaults to json\n * - TTY (interactive) defaults to pretty\n */\nexport function getOutputFormat(formatFlag?: string): OutputFormat {\n if (formatFlag === 'json' || formatFlag === 'pretty') {\n return formatFlag;\n }\n return isTTY() ? 'pretty' : 'json';\n}\n\n/**\n * Check if quiet mode is enabled (suppress stderr)\n */\nexport function isQuiet(quietFlag?: boolean): boolean {\n return quietFlag ?? false;\n}\n","import chalk from 'chalk';\n\nimport { getOutputFormat, isQuiet } from './format';\nimport {\n ExitCode,\n errorCodeToExitCode,\n type CliErrorDetails,\n type CliErrorResponse,\n type CliResponse,\n type CliSuccessResponse,\n type ErrorCode,\n type OutputFormat,\n type ResponseMetadata,\n} from './types';\n\nimport type { JsonObject } from '@/shared/neverthrow/json/types';\nimport type { BaseError, Err } from '@agentcash/neverthrow/types';\n\n/**\n * Output flags that can be passed to commands\n */\nexport interface OutputFlags {\n format?: string;\n quiet?: boolean;\n verbose?: boolean;\n}\n\n/**\n * Create a success response\n */\nexport function successResponse(\n data: JsonObject | string,\n metadata?: ResponseMetadata\n): CliSuccessResponse {\n return {\n success: true,\n data,\n ...(metadata ? { metadata } : {}),\n };\n}\n\n/**\n * Create an error response\n */\nexport function errorResponse(error: CliErrorDetails): CliErrorResponse {\n return {\n success: false,\n error,\n };\n}\n\n/**\n * Convert a neverthrow error to a CLI error response\n */\nexport function fromNeverthrowError(\n err: Err<unknown, BaseError<string>>,\n codeOverride?: ErrorCode\n): CliErrorResponse {\n const { error } = err;\n const code = codeOverride ?? mapCauseToErrorCode(error.cause);\n\n return errorResponse({\n code,\n message: error.message,\n surface: error.surface,\n cause: error.cause,\n });\n}\n\n/**\n * Map error cause to error code\n */\nfunction mapCauseToErrorCode(cause: string): ErrorCode {\n switch (cause) {\n case 'network':\n return 'NETWORK_ERROR';\n case 'http':\n return 'HTTP_ERROR';\n case 'parse':\n return 'PARSE_ERROR';\n case 'insufficient_balance':\n return 'INSUFFICIENT_BALANCE';\n case 'payment_failed':\n case 'payment_already_attempted':\n return 'PAYMENT_FAILED';\n case 'invalid_input':\n case 'validation':\n return 'INVALID_INPUT';\n case 'wallet':\n case 'file_not_readable':\n return 'WALLET_ERROR';\n default:\n return 'GENERAL_ERROR';\n }\n}\n\n/**\n * Format response as JSON string\n */\nfunction formatJson(response: CliResponse): string {\n return JSON.stringify(response, null, 2);\n}\n\n/**\n * Format response as pretty output for TTY\n */\nfunction formatPretty(response: CliResponse): string {\n if (response.success) {\n const lines: string[] = [];\n\n // Data\n if (typeof response.data === 'string') {\n lines.push(response.data);\n } else {\n lines.push(JSON.stringify(response.data, null, 2));\n }\n\n // Metadata\n if (response.metadata) {\n lines.push('');\n if (response.metadata.price) {\n lines.push(chalk.dim(`Price: ${response.metadata.price}`));\n }\n if (response.metadata.payment) {\n const { success, transactionHash } = response.metadata.payment;\n lines.push(\n chalk.dim(\n `Payment: ${success ? chalk.green('✓') : chalk.red('✗')}${transactionHash ? ` (${transactionHash.slice(0, 10)}...)` : ''}`\n )\n );\n }\n }\n\n return lines.join('\\n');\n } else {\n const { error } = response;\n const lines = [\n chalk.red(`Error: ${error.message}`),\n chalk.dim(`Code: ${error.code}`),\n ];\n\n if (error.surface) {\n lines.push(chalk.dim(`Surface: ${error.surface}`));\n }\n if (error.cause) {\n lines.push(chalk.dim(`Cause: ${error.cause}`));\n }\n\n return lines.join('\\n');\n }\n}\n\n/**\n * Output a response to stdout and exit with appropriate code\n */\nexport function outputAndExit(\n response: CliResponse,\n flags: OutputFlags = {}\n): never {\n const format = getOutputFormat(flags.format);\n const quiet = isQuiet(flags.quiet);\n\n output(response, format, quiet);\n\n const exitCode = response.success\n ? ExitCode.Success\n : errorCodeToExitCode[response.error.code];\n\n process.exit(exitCode);\n}\n\n/**\n * Output a response to stdout without exiting\n */\nfunction output(\n response: CliResponse,\n format: OutputFormat = 'json',\n quiet = false\n): void {\n const formatted =\n format === 'json' ? formatJson(response) : formatPretty(response);\n\n // Always output to stdout (machine-readable)\n console.log(formatted);\n\n // Optionally suppress stderr output\n if (!quiet && !response.success && format === 'pretty') {\n // Additional debug info could go to stderr\n }\n}\n","import {\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\nimport { getWallet } from '@/shared/wallet';\n\nimport type { GlobalFlags } from '@/types';\nimport type { PrivateKeyAccount } from 'viem/accounts';\n\ninterface WalletInfo {\n account: PrivateKeyAccount;\n}\n\n/**\n * Get wallet or exit with error.\n * This function always returns a valid wallet - if getting the wallet fails,\n * it exits the process with an appropriate error.\n */\nexport async function getWalletOrExit(\n flags: GlobalFlags<OutputFlags>\n): Promise<WalletInfo> {\n const walletResult = await getWallet();\n\n if (walletResult.isErr()) {\n outputAndExit(fromNeverthrowError(walletResult, 'WALLET_ERROR'), flags);\n }\n\n return walletResult.value;\n}\n","import type { z } from 'zod';\n\nimport { errorResponse, outputAndExit, type OutputFlags } from '@/cli/output';\nimport { requestSchema } from '@/server/tools/lib/request';\nimport { safeParseJson } from '@/shared/neverthrow/json';\n\nimport type { GlobalFlags } from '@/types';\n\ninterface RawRequestArgs {\n url: string;\n method?: string;\n body?: string;\n headers?: string;\n}\n\ntype RequestInput = z.infer<typeof requestSchema>;\n\n/**\n * Parse and validate CLI request arguments into a typed RequestInput.\n * Exits with error response if parsing fails.\n */\nexport function parseRequestInput(\n surface: string,\n args: RawRequestArgs,\n flags: GlobalFlags<OutputFlags>\n): RequestInput {\n // Parse body JSON if provided\n let parsedBody: unknown;\n if (args.body) {\n const bodyResult = safeParseJson(surface, args.body);\n if (bodyResult.isErr()) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: `Invalid JSON body: ${args.body}`,\n surface,\n cause: 'invalid_json',\n }),\n flags\n );\n }\n parsedBody = bodyResult.value;\n }\n\n // Parse headers JSON if provided\n let parsedHeaders: Record<string, string> | undefined;\n if (args.headers) {\n const headersResult = safeParseJson(surface, args.headers);\n if (headersResult.isErr()) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: `Invalid JSON headers: ${args.headers}`,\n surface,\n cause: 'invalid_json',\n }),\n flags\n );\n }\n\n // Validate headers is an object with string values\n const headersValue = headersResult.value;\n if (\n typeof headersValue !== 'object' ||\n headersValue === null ||\n Array.isArray(headersValue)\n ) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: 'Headers must be an object',\n surface,\n cause: 'invalid_headers',\n }),\n flags\n );\n }\n\n // Validate all values are strings\n const headers: Record<string, string> = {};\n for (const [key, value] of Object.entries(headersValue)) {\n if (typeof value !== 'string') {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: `Header \"${key}\" must be a string, got ${typeof value}`,\n surface,\n cause: 'invalid_headers',\n }),\n flags\n );\n }\n headers[key] = value;\n }\n parsedHeaders = headers;\n }\n\n // Validate full request input\n const inputResult = requestSchema.safeParse({\n url: args.url,\n method: args.method,\n body: parsedBody,\n headers: parsedHeaders ?? {},\n });\n\n if (!inputResult.success) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: inputResult.error.message,\n surface,\n cause: 'validation',\n }),\n flags\n );\n }\n\n return inputResult.data;\n}\n","import { randomBytes } from 'crypto';\n\nimport { successResponse, outputAndExit, type OutputFlags } from '@/cli/output';\n\nimport { checkEndpoint } from '@/shared/operations/check-endpoint';\nimport { toJsonObject } from '@/shared/neverthrow/json';\nimport { getWalletOrExit, parseRequestInput } from './lib';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:check';\n\ninterface CheckArgs {\n url: string;\n method?: string;\n body?: string;\n headers?: string;\n}\n\nexport async function checkCommand(\n args: CheckArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n const sessionId = randomBytes(16).toString('hex');\n\n const input = parseRequestInput(SURFACE, args, flags);\n\n const result = await checkEndpoint({\n surface: SURFACE,\n url: input.url,\n methods: input.method ? [input.method] : undefined,\n body: input.body,\n headers: {\n ...(input.headers ?? {}),\n 'X-Wallet-Address': account.address,\n 'X-Session-ID': sessionId,\n },\n includeMethodErrors: !!input.method,\n });\n\n return outputAndExit(successResponse(toJsonObject(result)), flags);\n}\n","import {\n successResponse,\n errorResponse,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { discoverResources } from '@/shared/operations/discover';\n\nimport type { GlobalFlags } from '@/types';\nimport type { JsonObject } from '@/shared/neverthrow/json/types';\n\ninterface DiscoverArgs {\n url: string;\n}\n\nexport async function discoverCommand(\n args: DiscoverArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const result = await discoverResources('cli:discover', args.url);\n\n if (result) {\n return outputAndExit(\n successResponse({\n found: true,\n origin: result.origin,\n source: result.source,\n ...(result.info ? { info: result.info as unknown as JsonObject } : {}),\n endpoints: result.endpoints.map(e => ({ ...e })),\n ...(result.instructions ? { instructions: result.instructions } : {}),\n }),\n flags\n );\n }\n\n const origin = URL.canParse(args.url) ? new URL(args.url).origin : args.url;\n return outputAndExit(\n errorResponse({\n code: 'GENERAL_ERROR',\n message: `No OpenAPI spec found for ${origin}. Tried: /openapi.json, /.well-known/openapi.json`,\n surface: 'cli:discover',\n cause: 'not_found',\n details: { origin },\n }),\n flags\n );\n}\n","import {\n successResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { registerOrigin } from '@/shared/operations/register';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:register';\n\ninterface RegisterArgs {\n url: string;\n}\n\nexport async function registerCommand(\n args: RegisterArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const result = await registerOrigin(SURFACE, { url: args.url }, flags.dev);\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n const { origin, resourceCount } = result.value;\n\n return outputAndExit(\n successResponse({\n origin: {\n id: origin.id,\n origin: origin.origin,\n name: origin.name,\n },\n resourceCount,\n }),\n flags\n );\n}\n","import {\n successResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { getWalletInfo } from '@/shared/operations/wallet-info';\nimport { redeemInviteCode } from '@/shared/redeem-invite';\nimport { getWalletOrExit } from './lib';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:wallet';\n\nexport async function walletInfoCommand(\n _args: object,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n\n const result = await getWalletInfo(SURFACE, account.address, flags);\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n return outputAndExit(\n successResponse({\n address: result.value.address,\n balance: result.value.balance,\n chains: result.value.chains.map(c => ({\n chain: c.chain,\n balance: c.balance,\n })),\n isNewWallet: result.value.isNewWallet,\n depositLink: result.value.depositLink,\n ...(result.value.message ? { message: result.value.message } : {}),\n }),\n flags\n );\n}\n\ninterface WalletRedeemArgs {\n code: string;\n}\n\nexport async function walletRedeemCommand(\n args: WalletRedeemArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n\n const result = await redeemInviteCode({\n code: args.code,\n dev: flags.dev,\n address: account.address,\n surface: SURFACE,\n });\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n return outputAndExit(\n successResponse({\n redeemed: true,\n amount: `${result.value.amount} USDC`,\n txHash: result.value.txHash,\n }),\n flags\n );\n}\n","import {\n successResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { submitErrorReport } from '@/shared/operations/report-error';\nimport { getWalletOrExit } from './lib';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:report-error';\n\ninterface ReportErrorArgs {\n tool: string;\n summary: string;\n errorMessage: string;\n resource?: string;\n stack?: string;\n fullReport?: string;\n}\n\nexport async function reportErrorCommand(\n args: ReportErrorArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n\n const result = await submitErrorReport(\n SURFACE,\n {\n tool: args.tool,\n summary: args.summary,\n errorMessage: args.errorMessage,\n resource: args.resource,\n stack: args.stack,\n fullReport: args.fullReport,\n },\n account.address,\n flags.dev\n );\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n return outputAndExit(\n successResponse({\n submitted: result.value.submitted,\n reportId: result.value.reportId,\n message: result.value.message,\n }),\n flags\n );\n}\n","import type { GlobalFlags } from '@/types';\n\n/**\n * Start the MCP server\n * This is a wrapper that imports and calls the existing server implementation\n */\nexport async function serverCommand(flags: GlobalFlags): Promise<void> {\n const { startServer } = await import('@/server');\n await startServer(flags);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,mBAAmB;AAE5B,SAAS,YAAY,sBAAsB;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,MAAM,SAAS,mBAAmB;AAC3C,SAAS,cAAc,YAAY;AACnC,SAAS,aAAa;;;AC0Bf,IAAM,sBAAmD;AAAA,EAC9D,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AACd;;;ACrCA,SAAS,QAAiB;AACxB,SAAO,QAAQ,OAAO,SAAS;AACjC;AAQO,SAAS,gBAAgB,YAAmC;AACjE,MAAI,eAAe,UAAU,eAAe,UAAU;AACpD,WAAO;AAAA,EACT;AACA,SAAO,M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;AAAA,IACD;AAAA,EACF;AACF;;;ACjDA,eAAsB,cAAc,OAAmC;AACrE,QAAM,EAAE,YAAY,IAAI,MAAM,OAAO,sBAAU;AAC/C,QAAM,YAAY,KAAK;AACzB;","names":["randomBytes","SURFACE","randomBytes","SURFACE","SURFACE","SURFACE"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -75,7 +75,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
75
75
|
default: "auto"
|
|
76
76
|
}),
|
|
77
77
|
async (args) => {
|
|
78
|
-
const { fetchCommand } = await import("./commands-
|
|
78
|
+
const { fetchCommand } = await import("./commands-VG6VWHCX.js");
|
|
79
79
|
await fetchCommand(
|
|
80
80
|
{
|
|
81
81
|
url: args.url,
|
|
@@ -109,7 +109,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
109
109
|
description: "Additional headers as JSON object"
|
|
110
110
|
}),
|
|
111
111
|
async (args) => {
|
|
112
|
-
const { checkCommand } = await import("./commands-
|
|
112
|
+
const { checkCommand } = await import("./commands-VG6VWHCX.js");
|
|
113
113
|
await checkCommand(
|
|
114
114
|
{
|
|
115
115
|
url: args.url,
|
|
@@ -129,9 +129,21 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
129
129
|
demandOption: true
|
|
130
130
|
}),
|
|
131
131
|
async (args) => {
|
|
132
|
-
const { discoverCommand } = await import("./commands-
|
|
132
|
+
const { discoverCommand } = await import("./commands-VG6VWHCX.js");
|
|
133
133
|
await discoverCommand({ url: args.url }, args);
|
|
134
134
|
}
|
|
135
|
+
).command(
|
|
136
|
+
"register <url>",
|
|
137
|
+
"Register an origin with agentcash (discover + index endpoints)",
|
|
138
|
+
(yargs2) => yargs2.positional("url", {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "The origin URL to register",
|
|
141
|
+
demandOption: true
|
|
142
|
+
}),
|
|
143
|
+
async (args) => {
|
|
144
|
+
const { registerCommand } = await import("./commands-VG6VWHCX.js");
|
|
145
|
+
await registerCommand({ url: args.url }, args);
|
|
146
|
+
}
|
|
135
147
|
).command(
|
|
136
148
|
"wallet",
|
|
137
149
|
"Wallet management commands",
|
|
@@ -140,7 +152,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
140
152
|
"Get wallet address, balance, and deposit link",
|
|
141
153
|
(yargs3) => yargs3,
|
|
142
154
|
async (args) => {
|
|
143
|
-
const { walletInfoCommand } = await import("./commands-
|
|
155
|
+
const { walletInfoCommand } = await import("./commands-VG6VWHCX.js");
|
|
144
156
|
await walletInfoCommand({}, args);
|
|
145
157
|
}
|
|
146
158
|
).command(
|
|
@@ -152,7 +164,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
152
164
|
demandOption: true
|
|
153
165
|
}),
|
|
154
166
|
async (args) => {
|
|
155
|
-
const { walletRedeemCommand } = await import("./commands-
|
|
167
|
+
const { walletRedeemCommand } = await import("./commands-VG6VWHCX.js");
|
|
156
168
|
await walletRedeemCommand({ code: args.code }, args);
|
|
157
169
|
}
|
|
158
170
|
).demandCommand(1, "You must specify a wallet subcommand").strict(),
|
|
@@ -184,7 +196,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
184
196
|
description: "Detailed report with context and repro steps"
|
|
185
197
|
}),
|
|
186
198
|
async (args) => {
|
|
187
|
-
const { reportErrorCommand } = await import("./commands-
|
|
199
|
+
const { reportErrorCommand } = await import("./commands-VG6VWHCX.js");
|
|
188
200
|
await reportErrorCommand(
|
|
189
201
|
{
|
|
190
202
|
tool: args.tool,
|
|
@@ -202,7 +214,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
202
214
|
"Start the MCP server (default when no command specified)",
|
|
203
215
|
(yargs2) => yargs2,
|
|
204
216
|
async (args) => {
|
|
205
|
-
const { serverCommand } = await import("./commands-
|
|
217
|
+
const { serverCommand } = await import("./commands-VG6VWHCX.js");
|
|
206
218
|
await serverCommand(args);
|
|
207
219
|
}
|
|
208
220
|
).command(
|
|
@@ -215,7 +227,7 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
215
227
|
default: isClaudeCode ? "claude-code" /* ClaudeCode */ : void 0
|
|
216
228
|
}),
|
|
217
229
|
async (args) => {
|
|
218
|
-
const { installMcpServer } = await import("./install-
|
|
230
|
+
const { installMcpServer } = await import("./install-5XIW6VXW.js");
|
|
219
231
|
await installMcpServer(args);
|
|
220
232
|
}
|
|
221
233
|
).command(
|
|
@@ -235,6 +247,9 @@ void yargs(hideBin(process.argv)).scriptName("agentcash").usage("$0 [command] [o
|
|
|
235
247
|
).example(
|
|
236
248
|
'$0 discover "https://enrichx402.com"',
|
|
237
249
|
"Discover endpoints on origin"
|
|
250
|
+
).example(
|
|
251
|
+
'$0 register "https://enrichx402.com"',
|
|
252
|
+
"Register origin with agentcash"
|
|
238
253
|
).example("$0 wallet info", "Get wallet balance").example("$0 wallet redeem ABC123", "Redeem invite code").example("$0", "Start MCP server (default)").example("$0 install --client cursor", "Install MCP for Cursor").strict().help().version().parseAsync().catch((err) => {
|
|
239
254
|
const response = {
|
|
240
255
|
success: false,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { Clients } from './cli/install/clients';\n\nconst isClaudeCode = Boolean(process.env.CLAUDECODE);\nconst defaultYes = isClaudeCode || Boolean(process.env.CI);\n\nvoid yargs(hideBin(process.argv))\n .scriptName('agentcash')\n .usage('$0 [command] [options]')\n .option('dev', {\n type: 'boolean',\n description: 'Enable dev mode (use localhost endpoints)',\n default: false,\n })\n .option('invite', {\n type: 'string',\n description: 'Invite code to redeem for starter money',\n required: false,\n })\n .option('yes', {\n alias: 'y',\n type: 'boolean',\n description: 'Yes to all prompts',\n default: defaultYes ? true : undefined,\n })\n .option('sessionId', {\n type: 'string',\n description:\n 'Session ID for matching requests (auto-generated if not provided)',\n required: false,\n })\n .option('provider', {\n type: 'string',\n description: 'Provider to use for the MCP server',\n required: false,\n })\n .option('format', {\n type: 'string',\n description:\n 'Output format: json (default for pipes) or pretty (default for TTY)',\n choices: ['json', 'pretty'],\n })\n .option('quiet', {\n alias: 'q',\n type: 'boolean',\n description: 'Suppress stderr output',\n default: false,\n })\n .option('verbose', {\n alias: 'v',\n type: 'boolean',\n description: 'Enable verbose logging (debug output to stderr)',\n default: false,\n })\n .middleware(async argv => {\n // Configure CLI context for shared modules (like logging)\n if (argv.verbose) {\n const { configureCliContext } = await import('@/shared/cli-context');\n configureCliContext({ verbose: true });\n }\n })\n // ============================================================\n // Core CLI Commands (for agent/programmatic use)\n // ============================================================\n .command(\n 'fetch <url>',\n 'HTTP fetch with automatic x402 payment handling',\n yargs =>\n yargs\n .positional('url', {\n type: 'string',\n description: 'The endpoint URL to fetch',\n demandOption: true,\n })\n .option('method', {\n alias: 'm',\n type: 'string',\n description: 'HTTP method',\n choices: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],\n default: 'GET',\n })\n .option('body', {\n alias: 'b',\n type: 'string',\n description: 'Request body as JSON string',\n })\n .option('headers', {\n alias: 'H',\n type: 'string',\n description: 'Additional headers as JSON object',\n })\n .option('payment-method', {\n alias: 'p',\n type: 'string',\n description: 'Payment protocol to use',\n choices: ['x402', 'mpp', 'auto'],\n default: 'auto',\n }),\n async args => {\n const { fetchCommand } = await import('@/cli/commands');\n await fetchCommand(\n {\n url: args.url,\n method: args.method,\n body: args.body,\n headers: args.headers,\n paymentMethod: args.paymentMethod,\n },\n args\n );\n }\n )\n .command(\n 'check <url>',\n 'Check endpoint for x402 pricing and schema without making payment',\n yargs =>\n yargs\n .positional('url', {\n type: 'string',\n description: 'The endpoint URL to check',\n demandOption: true,\n })\n .option('method', {\n alias: 'm',\n type: 'string',\n description:\n 'HTTP method to check. If omitted, all methods are probed in parallel.',\n choices: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],\n })\n .option('body', {\n alias: 'b',\n type: 'string',\n description: 'Request body as JSON string',\n })\n .option('headers', {\n alias: 'H',\n type: 'string',\n description: 'Additional headers as JSON object',\n }),\n async args => {\n const { checkCommand } = await import('@/cli/commands');\n await checkCommand(\n {\n url: args.url,\n method: args.method,\n body: args.body,\n headers: args.headers,\n },\n args\n );\n }\n )\n .command(\n 'discover <url>',\n 'Discover x402-protected endpoints on an origin',\n yargs =>\n yargs.positional('url', {\n type: 'string',\n description: 'The origin URL to discover endpoints from',\n demandOption: true,\n }),\n async args => {\n const { discoverCommand } = await import('@/cli/commands');\n await discoverCommand({ url: args.url }, args);\n }\n )\n .command(\n 'wallet',\n 'Wallet management commands',\n yargs =>\n yargs\n .command(\n 'info',\n 'Get wallet address, balance, and deposit link',\n yargs => yargs,\n async args => {\n const { walletInfoCommand } = await import('@/cli/commands');\n await walletInfoCommand({}, args);\n }\n )\n .command(\n 'redeem <code>',\n 'Redeem an invite code for free USDC',\n yargs =>\n yargs.positional('code', {\n type: 'string',\n description: 'The invite code to redeem',\n demandOption: true,\n }),\n async args => {\n const { walletRedeemCommand } = await import('@/cli/commands');\n await walletRedeemCommand({ code: args.code }, args);\n }\n )\n .demandCommand(1, 'You must specify a wallet subcommand')\n .strict(),\n () => {\n // Show help for wallet command\n }\n )\n .command(\n 'report-error',\n 'Report a critical bug to the agentcash team (emergency only)',\n yargs =>\n yargs\n .option('tool', {\n type: 'string',\n description: 'The tool/command that failed',\n demandOption: true,\n })\n .option('summary', {\n type: 'string',\n description: '1-2 sentence summary of the issue',\n demandOption: true,\n })\n .option('error-message', {\n type: 'string',\n description: 'The error message',\n demandOption: true,\n })\n .option('resource', {\n type: 'string',\n description: 'The x402 resource URL (if applicable)',\n })\n .option('stack', {\n type: 'string',\n description: 'Stack trace (if available)',\n })\n .option('full-report', {\n type: 'string',\n description: 'Detailed report with context and repro steps',\n }),\n async args => {\n const { reportErrorCommand } = await import('@/cli/commands');\n await reportErrorCommand(\n {\n tool: args.tool,\n summary: args.summary,\n errorMessage: args.errorMessage,\n resource: args.resource,\n stack: args.stack,\n fullReport: args.fullReport,\n },\n args\n );\n }\n )\n // ============================================================\n // Server & Installation Commands\n // ============================================================\n .command(\n ['$0', 'server'],\n 'Start the MCP server (default when no command specified)',\n yargs => yargs,\n async args => {\n const { serverCommand } = await import('@/cli/commands');\n await serverCommand(args);\n }\n )\n .command(\n 'install',\n 'Install the MCP server configuration for a client',\n yargs =>\n yargs.option('client', {\n type: 'string',\n description: 'The client name',\n required: false,\n default: isClaudeCode ? Clients.ClaudeCode : undefined,\n }),\n async args => {\n const { installMcpServer } = await import('@/cli/install');\n await installMcpServer(args);\n }\n )\n .command(\n 'fund',\n 'Open the funding page to add USDC to your wallet',\n yargs => yargs,\n async args => {\n const { fundMcpServer } = await import('@/cli/fund');\n await fundMcpServer(args);\n }\n )\n .example(\n '$0 fetch \"https://enrichx402.com/api/apollo/people-enrich\" -m POST -b \\'{\"email\":\"user@example.com\"}\\'',\n 'Fetch with x402 payment'\n )\n .example(\n '$0 check \"https://enrichx402.com/api/apollo/people-enrich\"',\n 'Check endpoint pricing'\n )\n .example(\n '$0 discover \"https://enrichx402.com\"',\n 'Discover endpoints on origin'\n )\n .example('$0 wallet info', 'Get wallet balance')\n .example('$0 wallet redeem ABC123', 'Redeem invite code')\n .example('$0', 'Start MCP server (default)')\n .example('$0 install --client cursor', 'Install MCP for Cursor')\n .strict()\n .help()\n .version()\n .parseAsync()\n .catch(err => {\n // Output error in JSON format for agent consumption\n const response = {\n success: false,\n error: {\n code: 'GENERAL_ERROR',\n message: err instanceof Error ? err.message : String(err),\n surface: 'cli',\n cause: 'unknown',\n },\n };\n console.log(JSON.stringify(response, null, 2));\n process.exit(1);\n });\n"],"mappings":";;;;AAEA,OAAO,WAAW;AAClB,S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IAAI,MAAM,OAAO,oBAAY;AACnD,UAAM,cAAc,IAAI;AAAA,EAC1B;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC,QAAQ,kBAAkB,oBAAoB,EAC9C,QAAQ,2BAA2B,oBAAoB,EACvD,QAAQ,MAAM,4BAA4B,EAC1C,QAAQ,8BAA8B,wBAAwB,EAC9D,OAAO,EACP,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,SAAO;AAEZ,QAAM,WAAW;AAAA,IACf,SAAS;AAAA,IACT,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MACxD,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACA,UAAQ,IAAI,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["yargs"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { Clients } from './cli/install/clients';\n\nconst isClaudeCode = Boolean(process.env.CLAUDECODE);\nconst defaultYes = isClaudeCode || Boolean(process.env.CI);\n\nvoid yargs(hideBin(process.argv))\n .scriptName('agentcash')\n .usage('$0 [command] [options]')\n .option('dev', {\n type: 'boolean',\n description: 'Enable dev mode (use localhost endpoints)',\n default: false,\n })\n .option('invite', {\n type: 'string',\n description: 'Invite code to redeem for starter money',\n required: false,\n })\n .option('yes', {\n alias: 'y',\n type: 'boolean',\n description: 'Yes to all prompts',\n default: defaultYes ? true : undefined,\n })\n .option('sessionId', {\n type: 'string',\n description:\n 'Session ID for matching requests (auto-generated if not provided)',\n required: false,\n })\n .option('provider', {\n type: 'string',\n description: 'Provider to use for the MCP server',\n required: false,\n })\n .option('format', {\n type: 'string',\n description:\n 'Output format: json (default for pipes) or pretty (default for TTY)',\n choices: ['json', 'pretty'],\n })\n .option('quiet', {\n alias: 'q',\n type: 'boolean',\n description: 'Suppress stderr output',\n default: false,\n })\n .option('verbose', {\n alias: 'v',\n type: 'boolean',\n description: 'Enable verbose logging (debug output to stderr)',\n default: false,\n })\n .middleware(async argv => {\n // Configure CLI context for shared modules (like logging)\n if (argv.verbose) {\n const { configureCliContext } = await import('@/shared/cli-context');\n configureCliContext({ verbose: true });\n }\n })\n // ============================================================\n // Core CLI Commands (for agent/programmatic use)\n // ============================================================\n .command(\n 'fetch <url>',\n 'HTTP fetch with automatic x402 payment handling',\n yargs =>\n yargs\n .positional('url', {\n type: 'string',\n description: 'The endpoint URL to fetch',\n demandOption: true,\n })\n .option('method', {\n alias: 'm',\n type: 'string',\n description: 'HTTP method',\n choices: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],\n default: 'GET',\n })\n .option('body', {\n alias: 'b',\n type: 'string',\n description: 'Request body as JSON string',\n })\n .option('headers', {\n alias: 'H',\n type: 'string',\n description: 'Additional headers as JSON object',\n })\n .option('payment-method', {\n alias: 'p',\n type: 'string',\n description: 'Payment protocol to use',\n choices: ['x402', 'mpp', 'auto'],\n default: 'auto',\n }),\n async args => {\n const { fetchCommand } = await import('@/cli/commands');\n await fetchCommand(\n {\n url: args.url,\n method: args.method,\n body: args.body,\n headers: args.headers,\n paymentMethod: args.paymentMethod,\n },\n args\n );\n }\n )\n .command(\n 'check <url>',\n 'Check endpoint for x402 pricing and schema without making payment',\n yargs =>\n yargs\n .positional('url', {\n type: 'string',\n description: 'The endpoint URL to check',\n demandOption: true,\n })\n .option('method', {\n alias: 'm',\n type: 'string',\n description:\n 'HTTP method to check. If omitted, all methods are probed in parallel.',\n choices: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],\n })\n .option('body', {\n alias: 'b',\n type: 'string',\n description: 'Request body as JSON string',\n })\n .option('headers', {\n alias: 'H',\n type: 'string',\n description: 'Additional headers as JSON object',\n }),\n async args => {\n const { checkCommand } = await import('@/cli/commands');\n await checkCommand(\n {\n url: args.url,\n method: args.method,\n body: args.body,\n headers: args.headers,\n },\n args\n );\n }\n )\n .command(\n 'discover <url>',\n 'Discover x402-protected endpoints on an origin',\n yargs =>\n yargs.positional('url', {\n type: 'string',\n description: 'The origin URL to discover endpoints from',\n demandOption: true,\n }),\n async args => {\n const { discoverCommand } = await import('@/cli/commands');\n await discoverCommand({ url: args.url }, args);\n }\n )\n .command(\n 'register <url>',\n 'Register an origin with agentcash (discover + index endpoints)',\n yargs =>\n yargs.positional('url', {\n type: 'string',\n description: 'The origin URL to register',\n demandOption: true,\n }),\n async args => {\n const { registerCommand } = await import('@/cli/commands');\n await registerCommand({ url: args.url }, args);\n }\n )\n .command(\n 'wallet',\n 'Wallet management commands',\n yargs =>\n yargs\n .command(\n 'info',\n 'Get wallet address, balance, and deposit link',\n yargs => yargs,\n async args => {\n const { walletInfoCommand } = await import('@/cli/commands');\n await walletInfoCommand({}, args);\n }\n )\n .command(\n 'redeem <code>',\n 'Redeem an invite code for free USDC',\n yargs =>\n yargs.positional('code', {\n type: 'string',\n description: 'The invite code to redeem',\n demandOption: true,\n }),\n async args => {\n const { walletRedeemCommand } = await import('@/cli/commands');\n await walletRedeemCommand({ code: args.code }, args);\n }\n )\n .demandCommand(1, 'You must specify a wallet subcommand')\n .strict(),\n () => {\n // Show help for wallet command\n }\n )\n .command(\n 'report-error',\n 'Report a critical bug to the agentcash team (emergency only)',\n yargs =>\n yargs\n .option('tool', {\n type: 'string',\n description: 'The tool/command that failed',\n demandOption: true,\n })\n .option('summary', {\n type: 'string',\n description: '1-2 sentence summary of the issue',\n demandOption: true,\n })\n .option('error-message', {\n type: 'string',\n description: 'The error message',\n demandOption: true,\n })\n .option('resource', {\n type: 'string',\n description: 'The x402 resource URL (if applicable)',\n })\n .option('stack', {\n type: 'string',\n description: 'Stack trace (if available)',\n })\n .option('full-report', {\n type: 'string',\n description: 'Detailed report with context and repro steps',\n }),\n async args => {\n const { reportErrorCommand } = await import('@/cli/commands');\n await reportErrorCommand(\n {\n tool: args.tool,\n summary: args.summary,\n errorMessage: args.errorMessage,\n resource: args.resource,\n stack: args.stack,\n fullReport: args.fullReport,\n },\n args\n );\n }\n )\n // ============================================================\n // Server & Installation Commands\n // ============================================================\n .command(\n ['$0', 'server'],\n 'Start the MCP server (default when no command specified)',\n yargs => yargs,\n async args => {\n const { serverCommand } = await import('@/cli/commands');\n await serverCommand(args);\n }\n )\n .command(\n 'install',\n 'Install the MCP server configuration for a client',\n yargs =>\n yargs.option('client', {\n type: 'string',\n description: 'The client name',\n required: false,\n default: isClaudeCode ? Clients.ClaudeCode : undefined,\n }),\n async args => {\n const { installMcpServer } = await import('@/cli/install');\n await installMcpServer(args);\n }\n )\n .command(\n 'fund',\n 'Open the funding page to add USDC to your wallet',\n yargs => yargs,\n async args => {\n const { fundMcpServer } = await import('@/cli/fund');\n await fundMcpServer(args);\n }\n )\n .example(\n '$0 fetch \"https://enrichx402.com/api/apollo/people-enrich\" -m POST -b \\'{\"email\":\"user@example.com\"}\\'',\n 'Fetch with x402 payment'\n )\n .example(\n '$0 check \"https://enrichx402.com/api/apollo/people-enrich\"',\n 'Check endpoint pricing'\n )\n .example(\n '$0 discover \"https://enrichx402.com\"',\n 'Discover endpoints on origin'\n )\n .example(\n '$0 register \"https://enrichx402.com\"',\n 'Register origin with agentcash'\n )\n .example('$0 wallet info', 'Get wallet balance')\n .example('$0 wallet redeem ABC123', 'Redeem invite code')\n .example('$0', 'Start MCP server (default)')\n .example('$0 install --client cursor', 'Install MCP for Cursor')\n .strict()\n .help()\n .version()\n .parseAsync()\n .catch(err => {\n // Output error in JSON format for agent consumption\n const response = {\n success: false,\n error: {\n code: 'GENERAL_ERROR',\n message: err instanceof Error ? err.message : String(err),\n surface: 'cli',\n cause: 'unknown',\n },\n };\n console.log(JSON.stringify(response, null, 2));\n process.exit(1);\n });\n"],"mappings":";;;;AAEA,OAAO,WAAW;A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AAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,IACV,SAAS,gDAAoC;AAAA,EAC/C,CAAC;AAAA,EACH,OAAM,SAAQ;AACZ,UAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,uBAAe;AACzD,UAAM,iBAAiB,IAAI;AAAA,EAC7B;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAAA,WAASA;AAAA,EACT,OAAM,SAAQ;AACZ,UAAM,EAAE,cAAc,IAAI,MAAM,OAAO,oBAAY;AACnD,UAAM,cAAc,IAAI;AAAA,EAC1B;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC,QAAQ,kBAAkB,oBAAoB,EAC9C,QAAQ,2BAA2B,oBAAoB,EACvD,QAAQ,MAAM,4BAA4B,EAC1C,QAAQ,8BAA8B,wBAAwB,EAC9D,OAAO,EACP,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,SAAO;AAEZ,QAAM,WAAW;AAAA,IACf,SAAS;AAAA,IACT,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MACxD,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACA,UAAQ,IAAI,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["yargs"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-KPEJO3KV.js";
|
|
5
5
|
import {
|
|
6
6
|
DIST_TAG
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KROBM6NS.js";
|
|
8
8
|
import {
|
|
9
9
|
promptDeposit,
|
|
10
10
|
wait
|
|
@@ -703,4 +703,4 @@ var installMcpServer = async (flags) => {
|
|
|
703
703
|
export {
|
|
704
704
|
installMcpServer
|
|
705
705
|
};
|
|
706
|
-
//# sourceMappingURL=install-
|
|
706
|
+
//# sourceMappingURL=install-5XIW6VXW.js.map
|
package/dist/esm/lib.d.ts
CHANGED
|
@@ -1,109 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
interface JsonObject {
|
|
3
|
-
[key: string]: JsonValue;
|
|
4
|
-
}
|
|
5
|
-
type JsonArray = JsonValue[];
|
|
6
|
-
|
|
7
|
-
interface EndpointSummary {
|
|
8
|
-
path: string;
|
|
9
|
-
method: string;
|
|
10
|
-
summary: string;
|
|
11
|
-
price?: string;
|
|
12
|
-
protocols?: string[];
|
|
13
|
-
}
|
|
1
|
+
export { C as CheckEndpointOptions, a as CheckEndpointResult, D as DiscoveryResult, M as MppPaymentOption, O as OpenApiInfo, P as PaymentOption, b as ProbeMethodResult, S as SUPPORTED_METHODS, c as SupportedMethod, X as X402PaymentOption, d as checkEndpoint, e as discoverResources } from './check-endpoint-BGFpMl2m.js';
|
|
14
2
|
|
|
15
|
-
interface OpenApiInfo {
|
|
16
|
-
title: string;
|
|
17
|
-
version?: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
}
|
|
20
|
-
interface DiscoveryResult {
|
|
21
|
-
origin: string;
|
|
22
|
-
source: 'openapi';
|
|
23
|
-
info?: OpenApiInfo;
|
|
24
|
-
endpoints: EndpointSummary[];
|
|
25
|
-
instructions?: string;
|
|
26
|
-
}
|
|
27
3
|
/**
|
|
28
|
-
*
|
|
29
|
-
* Fetches OpenAPI spec, builds endpoint index, and fetches llms.txt instructions.
|
|
30
|
-
*
|
|
31
|
-
* Returns DiscoveryResult on success, null if no spec/endpoints found.
|
|
4
|
+
* Input for registering an origin with agentcash.
|
|
32
5
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type PaymentProtocol = 'x402' | 'mpp';
|
|
36
|
-
|
|
37
|
-
declare const SUPPORTED_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
38
|
-
type SupportedMethod = (typeof SUPPORTED_METHODS)[number];
|
|
39
|
-
/** Fields common to every payment option regardless of protocol. */
|
|
40
|
-
interface PaymentOptionBase {
|
|
41
|
-
/** Protocol that issued this payment option. */
|
|
42
|
-
protocol: PaymentProtocol;
|
|
43
|
-
/** Human-readable price in dollars (e.g., 0.02). */
|
|
44
|
-
price: number;
|
|
45
|
-
/** CAIP-2 style chain identifier (e.g., "eip155:8453", "tempo:4217"). */
|
|
46
|
-
network: string;
|
|
47
|
-
/** Token / asset contract address. */
|
|
48
|
-
asset: string;
|
|
49
|
-
/** Payment destination address. */
|
|
50
|
-
recipient?: string;
|
|
51
|
-
/** Human-readable description of the resource being paid for. */
|
|
52
|
-
description?: string;
|
|
53
|
-
}
|
|
54
|
-
/** MPP (Machine Payments Protocol) payment option. */
|
|
55
|
-
interface MppPaymentOption extends PaymentOptionBase {
|
|
56
|
-
protocol: 'mpp';
|
|
57
|
-
/** Payment method identifier (e.g., "tempo", "stripe"). */
|
|
58
|
-
paymentMethod: string;
|
|
59
|
-
/** Payment intent type (e.g., "charge", "session"). */
|
|
60
|
-
intent: string;
|
|
61
|
-
/** Server protection realm. */
|
|
62
|
-
realm: string;
|
|
63
|
-
}
|
|
64
|
-
/** x402 payment option. */
|
|
65
|
-
interface X402PaymentOption extends PaymentOptionBase {
|
|
66
|
-
protocol: 'x402';
|
|
67
|
-
/** Response MIME type from the x402 resource descriptor. */
|
|
68
|
-
mimeType?: string;
|
|
69
|
-
}
|
|
70
|
-
/** A single payment option extracted from a 402 response. */
|
|
71
|
-
type PaymentOption = MppPaymentOption | X402PaymentOption;
|
|
72
|
-
/** A single method's probe outcome (only 402 or 2xx responses are kept). */
|
|
73
|
-
interface ProbeMethodResult {
|
|
74
|
-
method: SupportedMethod;
|
|
75
|
-
requiresPayment: boolean;
|
|
76
|
-
statusCode: number;
|
|
77
|
-
protocols?: PaymentProtocol[];
|
|
78
|
-
paymentOptions?: PaymentOption[];
|
|
79
|
-
/** OpenAPI operation schema when available. */
|
|
80
|
-
schema?: JsonObject;
|
|
81
|
-
/** Advisory price string from the OpenAPI x-payment-info extension. */
|
|
82
|
-
estimatedPrice?: string;
|
|
83
|
-
/** Human-readable summary from the OpenAPI spec. */
|
|
84
|
-
summary?: string;
|
|
85
|
-
}
|
|
86
|
-
interface CheckEndpointResult {
|
|
87
|
-
url: string;
|
|
88
|
-
results: ProbeMethodResult[];
|
|
89
|
-
}
|
|
90
|
-
interface CheckEndpointOptions {
|
|
91
|
-
surface: string;
|
|
6
|
+
interface RegisterInput {
|
|
92
7
|
url: string;
|
|
93
|
-
/** Methods to probe. Defaults to spec-defined methods, or all if no spec / probeAllMethods is set. */
|
|
94
|
-
methods?: SupportedMethod[];
|
|
95
|
-
body?: unknown;
|
|
96
|
-
headers?: Record<string, string>;
|
|
97
|
-
/** When true, include 404/405 responses in results. Useful when a specific method is targeted. */
|
|
98
|
-
includeMethodErrors?: boolean;
|
|
99
|
-
/** When true, probe all HTTP methods regardless of what the OpenAPI spec declares. */
|
|
100
|
-
probeAllMethods?: boolean;
|
|
101
8
|
}
|
|
102
9
|
/**
|
|
103
|
-
*
|
|
104
|
-
* Returns only the methods that responded with 402 or 2xx.
|
|
105
|
-
* Does not make any payment.
|
|
10
|
+
* Result returned from a successful registration.
|
|
106
11
|
*/
|
|
107
|
-
|
|
12
|
+
interface RegisterResult {
|
|
13
|
+
origin: {
|
|
14
|
+
id: string;
|
|
15
|
+
origin: string;
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
resourceCount: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare function registerOrigin(surface: string, input: {
|
|
22
|
+
url: string;
|
|
23
|
+
}, dev: boolean): Promise<RegisterResult>;
|
|
108
24
|
|
|
109
|
-
export { type
|
|
25
|
+
export { type RegisterInput, type RegisterResult, registerOrigin };
|
package/dist/esm/lib.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerOrigin
|
|
3
|
+
} from "./chunk-KPHAAIVC.js";
|
|
1
4
|
import {
|
|
2
5
|
SUPPORTED_METHODS,
|
|
3
6
|
checkEndpoint,
|
|
@@ -5,9 +8,17 @@ import {
|
|
|
5
8
|
} from "./chunk-RBBAPXT5.js";
|
|
6
9
|
import "./chunk-TRPO7BKD.js";
|
|
7
10
|
import "./chunk-ISR6DJ53.js";
|
|
11
|
+
|
|
12
|
+
// src/lib.ts
|
|
13
|
+
async function registerOrigin2(surface, input, dev) {
|
|
14
|
+
const result = await registerOrigin(surface, input, dev);
|
|
15
|
+
if (result.isErr()) throw new Error(result.error.message);
|
|
16
|
+
return result.value;
|
|
17
|
+
}
|
|
8
18
|
export {
|
|
9
19
|
SUPPORTED_METHODS,
|
|
10
20
|
checkEndpoint,
|
|
11
|
-
discoverResources
|
|
21
|
+
discoverResources,
|
|
22
|
+
registerOrigin2 as registerOrigin
|
|
12
23
|
};
|
|
13
24
|
//# sourceMappingURL=lib.js.map
|
package/dist/esm/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib.ts"],"sourcesContent":["/**\n * Library entry point for programmatic use (e.g. importing into a Next.js app).\n * The CLI entry point is src/index.ts (used by the `bin` field).\n *\n * All exports return plain types (no Result<> from neverthrow) to avoid\n * leaking internal @agentcash/neverthrow/types into published .d.ts files.\n *\n * IMPORTANT: Import directly from the individual operation modules — NOT\n * the operations barrel — so that CLI-only modules (wallet-info, report-error)\n * and their transitive filesystem dependencies are never pulled into the\n * bundle for Next.js / serverless consumers.\n */\nexport {\n discoverResources,\n type DiscoveryResult,\n type OpenApiInfo,\n} from '@/shared/operations/discover';\n\nexport {\n checkEndpoint,\n type CheckEndpointOptions,\n type CheckEndpointResult,\n type ProbeMethodResult,\n type PaymentOption,\n type MppPaymentOption,\n type X402PaymentOption,\n type SupportedMethod,\n SUPPORTED_METHODS,\n} from '@/shared/operations/check-endpoint';\n\nimport { registerOrigin as _registerOrigin } from '@/shared/operations/register';\nexport type {\n RegisterInput,\n RegisterResult,\n} from '@/shared/operations/register';\n\nexport async function registerOrigin(\n surface: string,\n input: { url: string },\n dev: boolean\n) {\n const result = await _registerOrigin(surface, input, dev);\n if (result.isErr()) throw new Error(result.error.message);\n return result.value;\n}\n"],"mappings":";;;;;;;;;;;;AAoCA,eAAsBA,gBACpB,SACA,OACA,KACA;AACA,QAAM,SAAS,MAAM,eAAgB,SAAS,OAAO,GAAG;AACxD,MAAI,OAAO,MAAM,EAAG,OAAM,IAAI,MAAM,OAAO,MAAM,OAAO;AACxD,SAAO,OAAO;AAChB;","names":["registerOrigin"]}
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
createFetchWithPayment,
|
|
4
4
|
requestSchema,
|
|
5
5
|
safeGetMppChallenge
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QN7XSHXI.js";
|
|
7
7
|
import {
|
|
8
8
|
TEMPO_RPC_URL,
|
|
9
9
|
getTempoBalance,
|
|
10
10
|
getWalletInfo,
|
|
11
11
|
submitErrorReport
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HQLNY2IE.js";
|
|
13
13
|
import {
|
|
14
14
|
checkEndpoint,
|
|
15
15
|
detectPaymentProtocols,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
safeCreateSIWxPayload,
|
|
20
20
|
safeGetPaymentRequired
|
|
21
21
|
} from "./chunk-RBBAPXT5.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-KROBM6NS.js";
|
|
23
23
|
import {
|
|
24
24
|
DEFAULT_NETWORK,
|
|
25
25
|
getWallet,
|
|
@@ -1235,7 +1235,7 @@ import { dirname, join } from "path";
|
|
|
1235
1235
|
import { fileURLToPath } from "url";
|
|
1236
1236
|
function getVersion() {
|
|
1237
1237
|
if (true) {
|
|
1238
|
-
return "0.4.
|
|
1238
|
+
return "0.4.4";
|
|
1239
1239
|
}
|
|
1240
1240
|
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
1241
1241
|
const pkg = JSON.parse(
|
|
@@ -1332,4 +1332,4 @@ var startServer = async (flags) => {
|
|
|
1332
1332
|
export {
|
|
1333
1333
|
startServer
|
|
1334
1334
|
};
|
|
1335
|
-
//# sourceMappingURL=server-
|
|
1335
|
+
//# sourceMappingURL=server-ZLH7QOUF.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address } from 'viem';
|
|
2
|
-
export { CheckEndpointOptions, CheckEndpointResult, DiscoveryResult, MppPaymentOption, OpenApiInfo, PaymentOption, ProbeMethodResult, SUPPORTED_METHODS, SupportedMethod, X402PaymentOption, checkEndpoint, discoverResources } from '../../
|
|
2
|
+
export { C as CheckEndpointOptions, a as CheckEndpointResult, D as DiscoveryResult, M as MppPaymentOption, O as OpenApiInfo, P as PaymentOption, b as ProbeMethodResult, S as SUPPORTED_METHODS, c as SupportedMethod, X as X402PaymentOption, d as checkEndpoint, e as discoverResources } from '../../check-endpoint-BGFpMl2m.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Error report result
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getWalletInfo,
|
|
3
3
|
submitErrorReport
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-HQLNY2IE.js";
|
|
5
5
|
import {
|
|
6
6
|
SUPPORTED_METHODS,
|
|
7
7
|
checkEndpoint,
|
|
8
8
|
discoverResources
|
|
9
9
|
} from "../../chunk-RBBAPXT5.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-KROBM6NS.js";
|
|
11
11
|
import "../../chunk-77BBSEYX.js";
|
|
12
12
|
import "../../chunk-TRPO7BKD.js";
|
|
13
13
|
import "../../chunk-ISR6DJ53.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentcash",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Generic MCP server for calling x402-protected APIs with automatic payment handling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/lib.js",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"tsx": "^4.21.0",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
50
|
"vitest": "^4.0.18",
|
|
51
|
-
"@agentcash/eslint-config": "0.0.0",
|
|
52
51
|
"@agentcash/neverthrow": "1.0.0",
|
|
53
|
-
"@agentcash/typescript-config": "0.0.0"
|
|
52
|
+
"@agentcash/typescript-config": "0.0.0",
|
|
53
|
+
"@agentcash/eslint-config": "0.0.0"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=20"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/fetch.ts","../../src/cli/output/types.ts","../../src/cli/output/format.ts","../../src/cli/output/response.ts","../../src/cli/commands/lib/get-wallet-or-exit.ts","../../src/cli/commands/lib/parse-request-input.ts","../../src/cli/commands/check.ts","../../src/cli/commands/discover.ts","../../src/cli/commands/wallet.ts","../../src/cli/commands/report-error.ts","../../src/cli/commands/server.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nimport { x402Client, x402HTTPClient } from '@x402/core/client';\nimport { ExactEvmScheme } from '@x402/evm/exact/client';\nimport { Mppx, tempo as tempoMethod } from 'mppx/client';\nimport { createClient, http } from 'viem';\nimport { tempo } from 'viem/chains';\n\nimport {\n successResponse,\n errorResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { buildRequest } from '@/server/tools/lib/request';\nimport { DEFAULT_NETWORK } from '@/shared/networks';\nimport { TEMPO_RPC_URL } from '@/shared/tempo';\nimport { safeParseResponse } from '@/shared/neverthrow/fetch';\nimport { createFetchWithPayment } from '@/shared/operations/fetch-with-payment';\nimport { getWalletOrExit, parseRequestInput } from './lib';\n\nimport type { GlobalFlags } from '@/types';\nimport type { JsonObject } from '@/shared/neverthrow/json/types';\n\nconst SURFACE = 'cli:fetch';\n\ninterface FetchArgs {\n url: string;\n method?: string;\n body?: string;\n headers?: string;\n paymentMethod?: string;\n}\n\nexport async function fetchCommand(\n args: FetchArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n const sessionId = randomBytes(16).toString('hex');\n\n const input = parseRequestInput(SURFACE, args, flags);\n\n // Set up x402 client\n const coreClient = x402Client.fromConfig({\n schemes: [\n { network: DEFAULT_NETWORK, client: new ExactEvmScheme(account) },\n ],\n });\n const x402HttpClient = new x402HTTPClient(coreClient);\n\n // Set up MPP client (polyfill: false — we handle 402 retries ourselves)\n const mppxClient = Mppx.create({\n polyfill: false,\n methods: [\n tempoMethod({\n account,\n getClient: () =>\n createClient({ chain: tempo, transport: http(TEMPO_RPC_URL) }),\n }),\n ],\n });\n\n const provider = flags.provider ?? account.address;\n const paymentMethod = (args.paymentMethod ?? 'auto') as\n | 'x402'\n | 'mpp'\n | 'auto';\n\n const request = buildRequest({\n input,\n address: account.address,\n sessionId,\n provider,\n });\n\n const fetchResult = await createFetchWithPayment({\n surface: SURFACE,\n clients: { x402: x402HttpClient, mpp: mppxClient },\n paymentMethod,\n account,\n flags,\n })(request);\n\n if (fetchResult.isErr()) {\n return outputAndExit(fromNeverthrowError(fetchResult), flags);\n }\n\n const { response, paymentInfo } = fetchResult.value;\n\n if (!response.ok) {\n const parseResult = await safeParseResponse(SURFACE, response);\n const details: JsonObject = { statusCode: response.status };\n if (parseResult.isOk()) {\n const { type } = parseResult.value;\n if (type === 'json') {\n details.body = parseResult.value.data;\n } else if (type === 'text') {\n details.body = parseResult.value.data;\n } else {\n details.bodyType = type;\n }\n }\n return outputAndExit(\n errorResponse({\n code: 'HTTP_ERROR',\n message: `HTTP ${response.status}: ${response.statusText}`,\n surface: SURFACE,\n cause: 'http',\n details,\n }),\n flags\n );\n }\n\n const parseResponseResult = await safeParseResponse(SURFACE, response);\n if (parseResponseResult.isErr()) {\n return outputAndExit(fromNeverthrowError(parseResponseResult), flags);\n }\n\n // Build response data\n const data =\n parseResponseResult.value.type === 'json'\n ? parseResponseResult.value.data\n : parseResponseResult.value.type === 'text'\n ? parseResponseResult.value.data\n : { type: parseResponseResult.value.type };\n\n // Build metadata from paymentInfo\n const metadata = paymentInfo\n ? {\n protocol: paymentInfo.protocol,\n ...(paymentInfo.price ? { price: paymentInfo.price } : {}),\n ...(paymentInfo.payment ? { payment: paymentInfo.payment } : {}),\n }\n : undefined;\n\n outputAndExit(successResponse(data, metadata), flags);\n}\n","import type { JsonObject } from '@/shared/neverthrow/json/types';\n\n/**\n * Exit codes for CLI commands\n * Allows agents to programmatically determine error types\n */\nexport enum ExitCode {\n Success = 0,\n GeneralError = 1,\n InsufficientBalance = 2,\n NetworkError = 3,\n PaymentFailed = 4,\n InvalidInput = 5,\n}\n\n/**\n * Error codes for structured error responses\n */\nexport type ErrorCode =\n | 'GENERAL_ERROR'\n | 'INSUFFICIENT_BALANCE'\n | 'NETWORK_ERROR'\n | 'PAYMENT_FAILED'\n | 'INVALID_INPUT'\n | 'WALLET_ERROR'\n | 'PARSE_ERROR'\n | 'HTTP_ERROR'\n | 'X402_ERROR';\n\n/**\n * Maps error codes to exit codes\n */\nexport const errorCodeToExitCode: Record<ErrorCode, ExitCode> = {\n GENERAL_ERROR: ExitCode.GeneralError,\n INSUFFICIENT_BALANCE: ExitCode.InsufficientBalance,\n NETWORK_ERROR: ExitCode.NetworkError,\n PAYMENT_FAILED: ExitCode.PaymentFailed,\n INVALID_INPUT: ExitCode.InvalidInput,\n WALLET_ERROR: ExitCode.GeneralError,\n PARSE_ERROR: ExitCode.InvalidInput,\n HTTP_ERROR: ExitCode.NetworkError,\n X402_ERROR: ExitCode.PaymentFailed,\n};\n\n/**\n * Payment metadata included in successful paid responses\n */\nexport interface PaymentMetadata {\n success: boolean;\n transactionHash?: string;\n}\n\n/**\n * Metadata included in CLI responses\n */\nexport interface ResponseMetadata {\n price?: string;\n payment?: PaymentMetadata;\n}\n\n/**\n * Successful CLI response\n */\nexport interface CliSuccessResponse {\n success: true;\n data: JsonObject | string;\n metadata?: ResponseMetadata;\n}\n\n/**\n * Error details in CLI response\n */\nexport interface CliErrorDetails {\n code: ErrorCode;\n message: string;\n surface?: string;\n cause?: string;\n details?: JsonObject;\n}\n\n/**\n * Failed CLI response\n */\nexport interface CliErrorResponse {\n success: false;\n error: CliErrorDetails;\n}\n\n/**\n * Union type for all CLI responses\n */\nexport type CliResponse = CliSuccessResponse | CliErrorResponse;\n\n/**\n * Output format options\n */\nexport type OutputFormat = 'json' | 'pretty';\n","import type { OutputFormat } from './types';\n\n/**\n * Detect if stdout is a TTY (interactive terminal)\n */\nfunction isTTY(): boolean {\n return process.stdout.isTTY ?? false;\n}\n\n/**\n * Determine output format based on flags and environment\n * - Explicit --format flag takes precedence\n * - Non-TTY (piped) defaults to json\n * - TTY (interactive) defaults to pretty\n */\nexport function getOutputFormat(formatFlag?: string): OutputFormat {\n if (formatFlag === 'json' || formatFlag === 'pretty') {\n return formatFlag;\n }\n return isTTY() ? 'pretty' : 'json';\n}\n\n/**\n * Check if quiet mode is enabled (suppress stderr)\n */\nexport function isQuiet(quietFlag?: boolean): boolean {\n return quietFlag ?? false;\n}\n","import chalk from 'chalk';\n\nimport { getOutputFormat, isQuiet } from './format';\nimport {\n ExitCode,\n errorCodeToExitCode,\n type CliErrorDetails,\n type CliErrorResponse,\n type CliResponse,\n type CliSuccessResponse,\n type ErrorCode,\n type OutputFormat,\n type ResponseMetadata,\n} from './types';\n\nimport type { JsonObject } from '@/shared/neverthrow/json/types';\nimport type { BaseError, Err } from '@agentcash/neverthrow/types';\n\n/**\n * Output flags that can be passed to commands\n */\nexport interface OutputFlags {\n format?: string;\n quiet?: boolean;\n verbose?: boolean;\n}\n\n/**\n * Create a success response\n */\nexport function successResponse(\n data: JsonObject | string,\n metadata?: ResponseMetadata\n): CliSuccessResponse {\n return {\n success: true,\n data,\n ...(metadata ? { metadata } : {}),\n };\n}\n\n/**\n * Create an error response\n */\nexport function errorResponse(error: CliErrorDetails): CliErrorResponse {\n return {\n success: false,\n error,\n };\n}\n\n/**\n * Convert a neverthrow error to a CLI error response\n */\nexport function fromNeverthrowError(\n err: Err<unknown, BaseError<string>>,\n codeOverride?: ErrorCode\n): CliErrorResponse {\n const { error } = err;\n const code = codeOverride ?? mapCauseToErrorCode(error.cause);\n\n return errorResponse({\n code,\n message: error.message,\n surface: error.surface,\n cause: error.cause,\n });\n}\n\n/**\n * Map error cause to error code\n */\nfunction mapCauseToErrorCode(cause: string): ErrorCode {\n switch (cause) {\n case 'network':\n return 'NETWORK_ERROR';\n case 'http':\n return 'HTTP_ERROR';\n case 'parse':\n return 'PARSE_ERROR';\n case 'insufficient_balance':\n return 'INSUFFICIENT_BALANCE';\n case 'payment_failed':\n case 'payment_already_attempted':\n return 'PAYMENT_FAILED';\n case 'invalid_input':\n case 'validation':\n return 'INVALID_INPUT';\n case 'wallet':\n case 'file_not_readable':\n return 'WALLET_ERROR';\n default:\n return 'GENERAL_ERROR';\n }\n}\n\n/**\n * Format response as JSON string\n */\nfunction formatJson(response: CliResponse): string {\n return JSON.stringify(response, null, 2);\n}\n\n/**\n * Format response as pretty output for TTY\n */\nfunction formatPretty(response: CliResponse): string {\n if (response.success) {\n const lines: string[] = [];\n\n // Data\n if (typeof response.data === 'string') {\n lines.push(response.data);\n } else {\n lines.push(JSON.stringify(response.data, null, 2));\n }\n\n // Metadata\n if (response.metadata) {\n lines.push('');\n if (response.metadata.price) {\n lines.push(chalk.dim(`Price: ${response.metadata.price}`));\n }\n if (response.metadata.payment) {\n const { success, transactionHash } = response.metadata.payment;\n lines.push(\n chalk.dim(\n `Payment: ${success ? chalk.green('✓') : chalk.red('✗')}${transactionHash ? ` (${transactionHash.slice(0, 10)}...)` : ''}`\n )\n );\n }\n }\n\n return lines.join('\\n');\n } else {\n const { error } = response;\n const lines = [\n chalk.red(`Error: ${error.message}`),\n chalk.dim(`Code: ${error.code}`),\n ];\n\n if (error.surface) {\n lines.push(chalk.dim(`Surface: ${error.surface}`));\n }\n if (error.cause) {\n lines.push(chalk.dim(`Cause: ${error.cause}`));\n }\n\n return lines.join('\\n');\n }\n}\n\n/**\n * Output a response to stdout and exit with appropriate code\n */\nexport function outputAndExit(\n response: CliResponse,\n flags: OutputFlags = {}\n): never {\n const format = getOutputFormat(flags.format);\n const quiet = isQuiet(flags.quiet);\n\n output(response, format, quiet);\n\n const exitCode = response.success\n ? ExitCode.Success\n : errorCodeToExitCode[response.error.code];\n\n process.exit(exitCode);\n}\n\n/**\n * Output a response to stdout without exiting\n */\nfunction output(\n response: CliResponse,\n format: OutputFormat = 'json',\n quiet = false\n): void {\n const formatted =\n format === 'json' ? formatJson(response) : formatPretty(response);\n\n // Always output to stdout (machine-readable)\n console.log(formatted);\n\n // Optionally suppress stderr output\n if (!quiet && !response.success && format === 'pretty') {\n // Additional debug info could go to stderr\n }\n}\n","import {\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\nimport { getWallet } from '@/shared/wallet';\n\nimport type { GlobalFlags } from '@/types';\nimport type { PrivateKeyAccount } from 'viem/accounts';\n\ninterface WalletInfo {\n account: PrivateKeyAccount;\n}\n\n/**\n * Get wallet or exit with error.\n * This function always returns a valid wallet - if getting the wallet fails,\n * it exits the process with an appropriate error.\n */\nexport async function getWalletOrExit(\n flags: GlobalFlags<OutputFlags>\n): Promise<WalletInfo> {\n const walletResult = await getWallet();\n\n if (walletResult.isErr()) {\n outputAndExit(fromNeverthrowError(walletResult, 'WALLET_ERROR'), flags);\n }\n\n return walletResult.value;\n}\n","import type { z } from 'zod';\n\nimport { errorResponse, outputAndExit, type OutputFlags } from '@/cli/output';\nimport { requestSchema } from '@/server/tools/lib/request';\nimport { safeParseJson } from '@/shared/neverthrow/json';\n\nimport type { GlobalFlags } from '@/types';\n\ninterface RawRequestArgs {\n url: string;\n method?: string;\n body?: string;\n headers?: string;\n}\n\ntype RequestInput = z.infer<typeof requestSchema>;\n\n/**\n * Parse and validate CLI request arguments into a typed RequestInput.\n * Exits with error response if parsing fails.\n */\nexport function parseRequestInput(\n surface: string,\n args: RawRequestArgs,\n flags: GlobalFlags<OutputFlags>\n): RequestInput {\n // Parse body JSON if provided\n let parsedBody: unknown;\n if (args.body) {\n const bodyResult = safeParseJson(surface, args.body);\n if (bodyResult.isErr()) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: `Invalid JSON body: ${args.body}`,\n surface,\n cause: 'invalid_json',\n }),\n flags\n );\n }\n parsedBody = bodyResult.value;\n }\n\n // Parse headers JSON if provided\n let parsedHeaders: Record<string, string> | undefined;\n if (args.headers) {\n const headersResult = safeParseJson(surface, args.headers);\n if (headersResult.isErr()) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: `Invalid JSON headers: ${args.headers}`,\n surface,\n cause: 'invalid_json',\n }),\n flags\n );\n }\n\n // Validate headers is an object with string values\n const headersValue = headersResult.value;\n if (\n typeof headersValue !== 'object' ||\n headersValue === null ||\n Array.isArray(headersValue)\n ) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: 'Headers must be an object',\n surface,\n cause: 'invalid_headers',\n }),\n flags\n );\n }\n\n // Validate all values are strings\n const headers: Record<string, string> = {};\n for (const [key, value] of Object.entries(headersValue)) {\n if (typeof value !== 'string') {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: `Header \"${key}\" must be a string, got ${typeof value}`,\n surface,\n cause: 'invalid_headers',\n }),\n flags\n );\n }\n headers[key] = value;\n }\n parsedHeaders = headers;\n }\n\n // Validate full request input\n const inputResult = requestSchema.safeParse({\n url: args.url,\n method: args.method,\n body: parsedBody,\n headers: parsedHeaders ?? {},\n });\n\n if (!inputResult.success) {\n outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: inputResult.error.message,\n surface,\n cause: 'validation',\n }),\n flags\n );\n }\n\n return inputResult.data;\n}\n","import { randomBytes } from 'crypto';\n\nimport { successResponse, outputAndExit, type OutputFlags } from '@/cli/output';\n\nimport { checkEndpoint } from '@/shared/operations/check-endpoint';\nimport { toJsonObject } from '@/shared/neverthrow/json';\nimport { getWalletOrExit, parseRequestInput } from './lib';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:check';\n\ninterface CheckArgs {\n url: string;\n method?: string;\n body?: string;\n headers?: string;\n}\n\nexport async function checkCommand(\n args: CheckArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n const sessionId = randomBytes(16).toString('hex');\n\n const input = parseRequestInput(SURFACE, args, flags);\n\n const result = await checkEndpoint({\n surface: SURFACE,\n url: input.url,\n methods: input.method ? [input.method] : undefined,\n body: input.body,\n headers: {\n ...(input.headers ?? {}),\n 'X-Wallet-Address': account.address,\n 'X-Session-ID': sessionId,\n },\n includeMethodErrors: !!input.method,\n });\n\n return outputAndExit(successResponse(toJsonObject(result)), flags);\n}\n","import {\n successResponse,\n errorResponse,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { discoverResources } from '@/shared/operations/discover';\n\nimport type { GlobalFlags } from '@/types';\nimport type { JsonObject } from '@/shared/neverthrow/json/types';\n\ninterface DiscoverArgs {\n url: string;\n}\n\nexport async function discoverCommand(\n args: DiscoverArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const result = await discoverResources('cli:discover', args.url);\n\n if (result) {\n return outputAndExit(\n successResponse({\n found: true,\n origin: result.origin,\n source: result.source,\n ...(result.info ? { info: result.info as unknown as JsonObject } : {}),\n endpoints: result.endpoints.map(e => ({ ...e })),\n ...(result.instructions ? { instructions: result.instructions } : {}),\n }),\n flags\n );\n }\n\n const origin = URL.canParse(args.url) ? new URL(args.url).origin : args.url;\n return outputAndExit(\n errorResponse({\n code: 'GENERAL_ERROR',\n message: `No OpenAPI spec found for ${origin}. Tried: /openapi.json, /.well-known/openapi.json`,\n surface: 'cli:discover',\n cause: 'not_found',\n details: { origin },\n }),\n flags\n );\n}\n","import {\n successResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { getWalletInfo } from '@/shared/operations/wallet-info';\nimport { redeemInviteCode } from '@/shared/redeem-invite';\nimport { getWalletOrExit } from './lib';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:wallet';\n\nexport async function walletInfoCommand(\n _args: object,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n\n const result = await getWalletInfo(SURFACE, account.address, flags);\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n return outputAndExit(\n successResponse({\n address: result.value.address,\n balance: result.value.balance,\n chains: result.value.chains.map(c => ({\n chain: c.chain,\n balance: c.balance,\n })),\n isNewWallet: result.value.isNewWallet,\n depositLink: result.value.depositLink,\n ...(result.value.message ? { message: result.value.message } : {}),\n }),\n flags\n );\n}\n\ninterface WalletRedeemArgs {\n code: string;\n}\n\nexport async function walletRedeemCommand(\n args: WalletRedeemArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n\n const result = await redeemInviteCode({\n code: args.code,\n dev: flags.dev,\n address: account.address,\n surface: SURFACE,\n });\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n return outputAndExit(\n successResponse({\n redeemed: true,\n amount: `${result.value.amount} USDC`,\n txHash: result.value.txHash,\n }),\n flags\n );\n}\n","import {\n successResponse,\n fromNeverthrowError,\n outputAndExit,\n type OutputFlags,\n} from '@/cli/output';\n\nimport { submitErrorReport } from '@/shared/operations/report-error';\nimport { getWalletOrExit } from './lib';\n\nimport type { GlobalFlags } from '@/types';\n\nconst SURFACE = 'cli:report-error';\n\ninterface ReportErrorArgs {\n tool: string;\n summary: string;\n errorMessage: string;\n resource?: string;\n stack?: string;\n fullReport?: string;\n}\n\nexport async function reportErrorCommand(\n args: ReportErrorArgs,\n flags: GlobalFlags<OutputFlags>\n): Promise<void> {\n const { account } = await getWalletOrExit(flags);\n\n const result = await submitErrorReport(\n SURFACE,\n {\n tool: args.tool,\n summary: args.summary,\n errorMessage: args.errorMessage,\n resource: args.resource,\n stack: args.stack,\n fullReport: args.fullReport,\n },\n account.address,\n flags.dev\n );\n\n if (result.isErr()) {\n return outputAndExit(fromNeverthrowError(result), flags);\n }\n\n return outputAndExit(\n successResponse({\n submitted: result.value.submitted,\n reportId: result.value.reportId,\n message: result.value.message,\n }),\n flags\n );\n}\n","import type { GlobalFlags } from '@/types';\n\n/**\n * Start the MCP server\n * This is a wrapper that imports and calls the existing server implementation\n */\nexport async function serverCommand(flags: GlobalFlags): Promise<void> {\n const { startServer } = await import('@/server');\n await startServer(flags);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,mBAAmB;AAE5B,SAAS,YAAY,sBAAsB;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,MAAM,SAAS,mBAAmB;AAC3C,SAAS,cAAc,YAAY;AACnC,SAAS,aAAa;;;AC0Bf,IAAM,sBAAmD;AAAA,EAC9D,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AACd;;;ACrCA,SAAS,QAAiB;AACxB,SAAO,QAAQ,OAAO,SAAS;AACjC;AAQO,SAAS,gBAAgB,YAAmC;AACjE,MAAI,eAAe,UAAU,eAAe,UAAU;AACpD,WAAO;AAAA,EACT;AACA,SAAO,MAAM,IAAI,WAAW;AAC9B;AAKO,SAAS,QAAQ,WAA8B;AACpD,SAAO,aAAa;AACtB;;;A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ACd,UAAU;AAAA,MACV,QAAQ,GAAG,OAAO,MAAM,MAAM;AAAA,MAC9B,QAAQ,OAAO,MAAM;AAAA,IACvB,CAAC;AAAA,IACD;AAAA,EACF;AACF;;;AC5DA,IAAMC,WAAU;AAWhB,eAAsB,mBACpB,MACA,OACe;AACf,QAAM,EAAE,QAAQ,IAAI,MAAM,gBAAgB,KAAK;AAE/C,QAAM,SAAS,MAAM;AAAA,IACnBA;AAAA,IACA;AAAA,MACE,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,cAAc,KAAK;AAAA,MACnB,UAAU,KAAK;AAAA,MACf,OAAO,KAAK;AAAA,MACZ,YAAY,KAAK;AAAA,IACnB;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AAEA,MAAI,OAAO,MAAM,GAAG;AAClB,WAAO,cAAc,oBAAoB,MAAM,GAAG,KAAK;AAAA,EACzD;AAEA,SAAO;AAAA,IACL,gBAAgB;AAAA,MACd,WAAW,OAAO,MAAM;AAAA,MACxB,UAAU,OAAO,MAAM;AAAA,MACvB,SAAS,OAAO,MAAM;AAAA,IACxB,CAAC;AAAA,IACD;AAAA,EACF;AACF;;;ACjDA,eAAsB,cAAc,OAAmC;AACrE,QAAM,EAAE,YAAY,IAAI,MAAM,OAAO,sBAAU;AAC/C,QAAM,YAAY,KAAK;AACzB;","names":["randomBytes","SURFACE","randomBytes","SURFACE","SURFACE"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|