agentcash 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -0
- package/dist/cjs/run-server.cjs +112199 -0
- package/dist/esm/chunk-3MUBKDR7.js +95 -0
- package/dist/esm/chunk-3MUBKDR7.js.map +1 -0
- package/dist/esm/chunk-A2KI7TKE.js +59 -0
- package/dist/esm/chunk-A2KI7TKE.js.map +1 -0
- package/dist/esm/chunk-FYIUFEVS.js +36 -0
- package/dist/esm/chunk-FYIUFEVS.js.map +1 -0
- package/dist/esm/chunk-HIR4VH7V.js +197 -0
- package/dist/esm/chunk-HIR4VH7V.js.map +1 -0
- package/dist/esm/chunk-J3LUL7DB.js +23 -0
- package/dist/esm/chunk-J3LUL7DB.js.map +1 -0
- package/dist/esm/chunk-PBZIKECT.js +46013 -0
- package/dist/esm/chunk-PBZIKECT.js.map +1 -0
- package/dist/esm/chunk-U6HC4IE3.js +119 -0
- package/dist/esm/chunk-U6HC4IE3.js.map +1 -0
- package/dist/esm/chunk-WW65CMHP.js +826 -0
- package/dist/esm/chunk-WW65CMHP.js.map +1 -0
- package/dist/esm/chunk-XCVCGASL.js +57 -0
- package/dist/esm/chunk-XCVCGASL.js.map +1 -0
- package/dist/esm/cli-context-2MKOXVXU.js +10 -0
- package/dist/esm/cli-context-2MKOXVXU.js.map +1 -0
- package/dist/esm/commands-EOBZV2HH.js +536 -0
- package/dist/esm/commands-EOBZV2HH.js.map +1 -0
- package/dist/esm/fund-GUW4GKZT.js +37 -0
- package/dist/esm/fund-GUW4GKZT.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +249 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/install-OYN36YE4.js +720 -0
- package/dist/esm/install-OYN36YE4.js.map +1 -0
- package/dist/esm/server-BEEIW53K.js +1814 -0
- package/dist/esm/server-BEEIW53K.js.map +1 -0
- package/dist/esm/shared/operations/index.d.ts +194 -0
- package/dist/esm/shared/operations/index.js +19 -0
- package/dist/esm/shared/operations/index.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-A2KI7TKE.js";
|
|
4
|
+
|
|
5
|
+
// src/cli/install/clients.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
var Clients = /* @__PURE__ */ ((Clients2) => {
|
|
8
|
+
Clients2["ClaudeCode"] = "claude-code";
|
|
9
|
+
Clients2["Cursor"] = "cursor";
|
|
10
|
+
Clients2["Claude"] = "claude";
|
|
11
|
+
Clients2["Codex"] = "codex";
|
|
12
|
+
Clients2["Vscode"] = "vscode";
|
|
13
|
+
Clients2["Cline"] = "cline";
|
|
14
|
+
Clients2["RooCline"] = "roo-cline";
|
|
15
|
+
Clients2["Windsurf"] = "windsurf";
|
|
16
|
+
Clients2["Warp"] = "warp";
|
|
17
|
+
Clients2["GeminiCli"] = "gemini-cli";
|
|
18
|
+
Clients2["Goose"] = "goose";
|
|
19
|
+
Clients2["Zed"] = "zed";
|
|
20
|
+
Clients2["Opencode"] = "opencode";
|
|
21
|
+
return Clients2;
|
|
22
|
+
})(Clients || {});
|
|
23
|
+
var clientMetadata = {
|
|
24
|
+
["claude-code" /* ClaudeCode */]: {
|
|
25
|
+
name: "Claude Code",
|
|
26
|
+
description: "Claude Code is a code editor that uses the Claude API.",
|
|
27
|
+
website: "https://claude.com"
|
|
28
|
+
},
|
|
29
|
+
["cursor" /* Cursor */]: {
|
|
30
|
+
name: "Cursor",
|
|
31
|
+
description: "Cursor is a code editor that uses the Cursor API.",
|
|
32
|
+
website: "https://cursor.com"
|
|
33
|
+
},
|
|
34
|
+
["claude" /* Claude */]: {
|
|
35
|
+
name: "Claude Desktop",
|
|
36
|
+
description: "Claude is a code editor that uses the Claude API.",
|
|
37
|
+
website: "https://claude.com"
|
|
38
|
+
},
|
|
39
|
+
["codex" /* Codex */]: {
|
|
40
|
+
name: "Codex",
|
|
41
|
+
description: "Codex is a code editor that uses the Codex API.",
|
|
42
|
+
website: "https://codex.com"
|
|
43
|
+
},
|
|
44
|
+
["vscode" /* Vscode */]: {
|
|
45
|
+
name: "VSCode",
|
|
46
|
+
description: "VSCode is a code editor that uses the VSCode API.",
|
|
47
|
+
website: "https://vscode.com"
|
|
48
|
+
},
|
|
49
|
+
["cline" /* Cline */]: {
|
|
50
|
+
name: "Cline",
|
|
51
|
+
description: "Cline is a code editor that uses the Cline API.",
|
|
52
|
+
website: "https://cline.com"
|
|
53
|
+
},
|
|
54
|
+
["roo-cline" /* RooCline */]: {
|
|
55
|
+
name: "RooCline",
|
|
56
|
+
description: "RooCline is a code editor that uses the RooCline API.",
|
|
57
|
+
website: "https://roo-cline.com"
|
|
58
|
+
},
|
|
59
|
+
["windsurf" /* Windsurf */]: {
|
|
60
|
+
name: "Windsurf",
|
|
61
|
+
description: "Windsurf is a code editor that uses the Windsurf API.",
|
|
62
|
+
website: "https://windsurf.com"
|
|
63
|
+
},
|
|
64
|
+
["warp" /* Warp */]: {
|
|
65
|
+
name: "Warp",
|
|
66
|
+
description: "Warp is a code editor that uses the Warp API.",
|
|
67
|
+
website: "https://warp.com"
|
|
68
|
+
},
|
|
69
|
+
["gemini-cli" /* GeminiCli */]: {
|
|
70
|
+
name: "Gemini CLI",
|
|
71
|
+
description: "Gemini CLI is a code editor that uses the Gemini CLI API.",
|
|
72
|
+
website: "https://gemini-cli.com"
|
|
73
|
+
},
|
|
74
|
+
["goose" /* Goose */]: {
|
|
75
|
+
name: "Goose",
|
|
76
|
+
description: "Goose is a code editor that uses the Goose API.",
|
|
77
|
+
website: "https://goose.com"
|
|
78
|
+
},
|
|
79
|
+
["zed" /* Zed */]: {
|
|
80
|
+
name: "Zed",
|
|
81
|
+
description: "Zed is a code editor that uses the Zed API.",
|
|
82
|
+
website: "https://zed.com"
|
|
83
|
+
},
|
|
84
|
+
["opencode" /* Opencode */]: {
|
|
85
|
+
name: "Opencode",
|
|
86
|
+
description: "Opencode is a code editor that uses the Opencode API.",
|
|
87
|
+
website: "https://opencode.com"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
Clients,
|
|
93
|
+
clientMetadata
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=chunk-3MUBKDR7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/install/clients.ts"],"sourcesContent":["export enum Clients {\n ClaudeCode = 'claude-code',\n Cursor = 'cursor',\n Claude = 'claude',\n Codex = 'codex',\n Vscode = 'vscode',\n Cline = 'cline',\n RooCline = 'roo-cline',\n Windsurf = 'windsurf',\n Warp = 'warp',\n GeminiCli = 'gemini-cli',\n Goose = 'goose',\n Zed = 'zed',\n Opencode = 'opencode',\n}\n\ninterface ClientMetadata {\n name: string;\n description: string;\n website: string;\n}\n\nexport const clientMetadata: Record<Clients, ClientMetadata> = {\n [Clients.ClaudeCode]: {\n name: 'Claude Code',\n description: 'Claude Code is a code editor that uses the Claude API.',\n website: 'https://claude.com',\n },\n [Clients.Cursor]: {\n name: 'Cursor',\n description: 'Cursor is a code editor that uses the Cursor API.',\n website: 'https://cursor.com',\n },\n [Clients.Claude]: {\n name: 'Claude Desktop',\n description: 'Claude is a code editor that uses the Claude API.',\n website: 'https://claude.com',\n },\n [Clients.Codex]: {\n name: 'Codex',\n description: 'Codex is a code editor that uses the Codex API.',\n website: 'https://codex.com',\n },\n [Clients.Vscode]: {\n name: 'VSCode',\n description: 'VSCode is a code editor that uses the VSCode API.',\n website: 'https://vscode.com',\n },\n [Clients.Cline]: {\n name: 'Cline',\n description: 'Cline is a code editor that uses the Cline API.',\n website: 'https://cline.com',\n },\n [Clients.RooCline]: {\n name: 'RooCline',\n description: 'RooCline is a code editor that uses the RooCline API.',\n website: 'https://roo-cline.com',\n },\n [Clients.Windsurf]: {\n name: 'Windsurf',\n description: 'Windsurf is a code editor that uses the Windsurf API.',\n website: 'https://windsurf.com',\n },\n [Clients.Warp]: {\n name: 'Warp',\n description: 'Warp is a code editor that uses the Warp API.',\n website: 'https://warp.com',\n },\n [Clients.GeminiCli]: {\n name: 'Gemini CLI',\n description: 'Gemini CLI is a code editor that uses the Gemini CLI API.',\n website: 'https://gemini-cli.com',\n },\n [Clients.Goose]: {\n name: 'Goose',\n description: 'Goose is a code editor that uses the Goose API.',\n website: 'https://goose.com',\n },\n [Clients.Zed]: {\n name: 'Zed',\n description: 'Zed is a code editor that uses the Zed API.',\n website: 'https://zed.com',\n },\n [Clients.Opencode]: {\n name: 'Opencode',\n description: 'Opencode is a code editor that uses the Opencode API.',\n website: 'https://opencode.com',\n },\n};\n"],"mappings":";;;;;AAAA;AAAO,IAAK,UAAL,kBAAKA,aAAL;AACL,EAAAA,SAAA,gBAAa;AACb,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,WAAQ;AACR,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,WAAQ;AACR,EAAAA,SAAA,cAAW;AACX,EAAAA,SAAA,cAAW;AACX,EAAAA,SAAA,UAAO;AACP,EAAAA,SAAA,eAAY;AACZ,EAAAA,SAAA,WAAQ;AACR,EAAAA,SAAA,SAAM;AACN,EAAAA,SAAA,cAAW;AAbD,SAAAA;AAAA,GAAA;AAsBL,IAAM,iBAAkD;AAAA,EAC7D,CAAC,8BAAkB,GAAG;AAAA,IACpB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,qBAAc,GAAG;AAAA,IAChB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,qBAAc,GAAG;AAAA,IAChB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,mBAAa,GAAG;AAAA,IACf,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,qBAAc,GAAG;AAAA,IAChB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,mBAAa,GAAG;AAAA,IACf,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,0BAAgB,GAAG;AAAA,IAClB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,yBAAgB,GAAG;AAAA,IAClB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,iBAAY,GAAG;AAAA,IACd,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,4BAAiB,GAAG;AAAA,IACnB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,mBAAa,GAAG;AAAA,IACf,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,eAAW,GAAG;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,CAAC,yBAAgB,GAAG;AAAA,IAClB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;","names":["Clients"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __esm = (fn, res) => function __init() {
|
|
14
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
+
};
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
+
|
|
41
|
+
// ../../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
42
|
+
import path from "path";
|
|
43
|
+
import { fileURLToPath } from "url";
|
|
44
|
+
var init_esm_shims = __esm({
|
|
45
|
+
"../../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
46
|
+
"use strict";
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
__require,
|
|
52
|
+
__esm,
|
|
53
|
+
__commonJS,
|
|
54
|
+
__export,
|
|
55
|
+
__toESM,
|
|
56
|
+
__toCommonJS,
|
|
57
|
+
init_esm_shims
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=chunk-A2KI7TKE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-A2KI7TKE.js";
|
|
4
|
+
|
|
5
|
+
// src/server/tools/lib/request.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
import z from "zod";
|
|
8
|
+
var requestSchema = z.object({
|
|
9
|
+
url: z.url().describe("The endpoint URL"),
|
|
10
|
+
method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).default("GET").describe("HTTP method"),
|
|
11
|
+
body: z.unknown().optional().describe("Request body for POST/PUT/PATCH methods"),
|
|
12
|
+
headers: z.record(z.string(), z.string()).optional().describe("Additional headers to include").default({})
|
|
13
|
+
});
|
|
14
|
+
var buildRequest = ({
|
|
15
|
+
input,
|
|
16
|
+
address,
|
|
17
|
+
sessionId,
|
|
18
|
+
provider
|
|
19
|
+
}) => {
|
|
20
|
+
return new Request(input.url, {
|
|
21
|
+
method: input.method,
|
|
22
|
+
body: input.body ? typeof input.body === "string" ? input.body : JSON.stringify(input.body) : void 0,
|
|
23
|
+
headers: {
|
|
24
|
+
...input.body ? { "Content-Type": "application/json" } : {},
|
|
25
|
+
...input.headers,
|
|
26
|
+
...address ? { "X-Wallet-Address": address, "X-Client-ID": provider } : {},
|
|
27
|
+
...sessionId ? { "X-Session-ID": sessionId } : {}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
requestSchema,
|
|
34
|
+
buildRequest
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-FYIUFEVS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/server/tools/lib/request.ts"],"sourcesContent":["import z from 'zod';\n\nimport type { Address } from 'viem';\n\nexport const requestSchema = z.object({\n url: z.url().describe('The endpoint URL'),\n method: z\n .enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])\n .default('GET')\n .describe('HTTP method'),\n body: z\n .unknown()\n .optional()\n .describe('Request body for POST/PUT/PATCH methods'),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe('Additional headers to include')\n .default({}),\n});\n\ninterface BuildRequestProps {\n input: z.infer<typeof requestSchema>;\n address?: Address;\n sessionId?: string;\n provider?: string;\n}\n\nexport const buildRequest = ({\n input,\n address,\n sessionId,\n provider,\n}: BuildRequestProps) => {\n return new Request(input.url, {\n method: input.method,\n body: input.body\n ? typeof input.body === 'string'\n ? input.body\n : JSON.stringify(input.body)\n : undefined,\n headers: {\n ...(input.body ? { 'Content-Type': 'application/json' } : {}),\n ...input.headers,\n ...(address\n ? { 'X-Wallet-Address': address, 'X-Client-ID': provider }\n : {}),\n ...(sessionId ? { 'X-Session-ID': sessionId } : {}),\n },\n });\n};\n"],"mappings":";;;;;AAAA;AAAA,OAAO,OAAO;AAIP,IAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,KAAK,EAAE,IAAI,EAAE,SAAS,kBAAkB;AAAA,EACxC,QAAQ,EACL,KAAK,CAAC,OAAO,QAAQ,OAAO,UAAU,OAAO,CAAC,EAC9C,QAAQ,KAAK,EACb,SAAS,aAAa;AAAA,EACzB,MAAM,EACH,QAAQ,EACR,SAAS,EACT,SAAS,yCAAyC;AAAA,EACrD,SAAS,EACN,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,EACT,SAAS,+BAA+B,EACxC,QAAQ,CAAC,CAAC;AACf,CAAC;AASM,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,SAAO,IAAI,QAAQ,MAAM,KAAK;AAAA,IAC5B,QAAQ,MAAM;AAAA,IACd,MAAM,MAAM,OACR,OAAO,MAAM,SAAS,WACpB,MAAM,OACN,KAAK,UAAU,MAAM,IAAI,IAC3B;AAAA,IACJ,SAAS;AAAA,MACP,GAAI,MAAM,OAAO,EAAE,gBAAgB,mBAAmB,IAAI,CAAC;AAAA,MAC3D,GAAG,MAAM;AAAA,MACT,GAAI,UACA,EAAE,oBAAoB,SAAS,eAAe,SAAS,IACvD,CAAC;AAAA,MACL,GAAI,YAAY,EAAE,gBAAgB,UAAU,IAAI,CAAC;AAAA,IACnD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configFile,
|
|
3
|
+
err,
|
|
4
|
+
fsErr,
|
|
5
|
+
getBaseUrl,
|
|
6
|
+
log,
|
|
7
|
+
ok,
|
|
8
|
+
resultFromThrowable,
|
|
9
|
+
safeChmod,
|
|
10
|
+
safeFetchJson,
|
|
11
|
+
safeParse,
|
|
12
|
+
safeReadFile,
|
|
13
|
+
safeWriteFile
|
|
14
|
+
} from "./chunk-WW65CMHP.js";
|
|
15
|
+
import {
|
|
16
|
+
init_esm_shims
|
|
17
|
+
} from "./chunk-A2KI7TKE.js";
|
|
18
|
+
|
|
19
|
+
// src/shared/wallet.ts
|
|
20
|
+
init_esm_shims();
|
|
21
|
+
import { existsSync } from "fs";
|
|
22
|
+
import { getAddress } from "viem";
|
|
23
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
24
|
+
import z from "zod";
|
|
25
|
+
|
|
26
|
+
// src/shared/neverthrow/json/index.ts
|
|
27
|
+
init_esm_shims();
|
|
28
|
+
var type = "json";
|
|
29
|
+
var jsonErr = (surface, error) => {
|
|
30
|
+
return err(type, surface, error);
|
|
31
|
+
};
|
|
32
|
+
var safeStringifyJson = (surface, value) => {
|
|
33
|
+
return resultFromThrowable(
|
|
34
|
+
type,
|
|
35
|
+
surface,
|
|
36
|
+
() => JSON.stringify(value, null, 2),
|
|
37
|
+
() => ({
|
|
38
|
+
cause: "stringify",
|
|
39
|
+
message: "Could not stringify JSON"
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
var safeParseJson = (surface, value) => {
|
|
44
|
+
return resultFromThrowable(
|
|
45
|
+
type,
|
|
46
|
+
surface,
|
|
47
|
+
() => JSON.parse(value),
|
|
48
|
+
(e) => ({
|
|
49
|
+
cause: "parse",
|
|
50
|
+
message: e instanceof Error ? e.message : "Could not parse JSON"
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/shared/wallet.ts
|
|
56
|
+
var WALLET_FILE = configFile("wallet.json");
|
|
57
|
+
var storedWalletSchema = z.object({
|
|
58
|
+
privateKey: z.string().regex(/^0x[a-fA-F0-9]{64}$/, "Invalid Ethereum private key").transform((privateKey) => privateKey),
|
|
59
|
+
address: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address").transform((address) => getAddress(address)),
|
|
60
|
+
createdAt: z.string()
|
|
61
|
+
});
|
|
62
|
+
var walletSurface = "wallet";
|
|
63
|
+
async function getWallet() {
|
|
64
|
+
if (process.env.X402_PRIVATE_KEY) {
|
|
65
|
+
const account2 = privateKeyToAccount(process.env.X402_PRIVATE_KEY);
|
|
66
|
+
log.info(`Using wallet from env: ${account2.address}`);
|
|
67
|
+
return ok({ account: account2, isNew: false });
|
|
68
|
+
}
|
|
69
|
+
const readFileResult = await safeReadFile(walletSurface, WALLET_FILE);
|
|
70
|
+
if (!readFileResult.isOk()) {
|
|
71
|
+
const fileExistsResult = existsSync(WALLET_FILE);
|
|
72
|
+
if (fileExistsResult) {
|
|
73
|
+
return fsErr(walletSurface, {
|
|
74
|
+
cause: "file_not_readable",
|
|
75
|
+
message: `The file exists but is not readable. Fix corrupted state file: ${WALLET_FILE}`
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (readFileResult.isOk()) {
|
|
80
|
+
const data = readFileResult.value;
|
|
81
|
+
const jsonParseResult = safeParseJson(walletSurface, data);
|
|
82
|
+
if (jsonParseResult.isErr()) {
|
|
83
|
+
return jsonErr(walletSurface, {
|
|
84
|
+
cause: "parse",
|
|
85
|
+
message: `The data in ${WALLET_FILE} is not valid JSON`
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const parseResult = safeParse(
|
|
89
|
+
walletSurface,
|
|
90
|
+
storedWalletSchema,
|
|
91
|
+
jsonParseResult.value
|
|
92
|
+
);
|
|
93
|
+
if (parseResult.isErr()) {
|
|
94
|
+
return parseResult;
|
|
95
|
+
}
|
|
96
|
+
const account2 = privateKeyToAccount(parseResult.value.privateKey);
|
|
97
|
+
log.info(`Loaded wallet: ${account2.address}`);
|
|
98
|
+
return ok({ account: account2, isNew: false });
|
|
99
|
+
}
|
|
100
|
+
const privateKey = generatePrivateKey();
|
|
101
|
+
const account = privateKeyToAccount(privateKey);
|
|
102
|
+
const stored = {
|
|
103
|
+
privateKey,
|
|
104
|
+
address: account.address,
|
|
105
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
106
|
+
};
|
|
107
|
+
const saveResult = await safeWriteFile(
|
|
108
|
+
walletSurface,
|
|
109
|
+
WALLET_FILE,
|
|
110
|
+
JSON.stringify(stored, null, 2)
|
|
111
|
+
).andThen(() => safeChmod(walletSurface, WALLET_FILE, 384));
|
|
112
|
+
if (saveResult.isErr()) {
|
|
113
|
+
return saveResult;
|
|
114
|
+
}
|
|
115
|
+
log.info(`Created wallet: ${account.address}`);
|
|
116
|
+
log.info(`Saved to: ${WALLET_FILE}`);
|
|
117
|
+
return ok({ account, isNew: true });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/shared/redeem-invite.ts
|
|
121
|
+
init_esm_shims();
|
|
122
|
+
import z3 from "zod";
|
|
123
|
+
|
|
124
|
+
// src/shared/state.ts
|
|
125
|
+
init_esm_shims();
|
|
126
|
+
import z2 from "zod";
|
|
127
|
+
import fs from "fs";
|
|
128
|
+
var STATE_FILE = configFile("state.json");
|
|
129
|
+
var stateSchema = z2.looseObject({
|
|
130
|
+
redeemedCodes: z2.array(z2.string())
|
|
131
|
+
}).partial();
|
|
132
|
+
var getState = () => {
|
|
133
|
+
const stateFileExists = fs.existsSync(STATE_FILE);
|
|
134
|
+
if (!stateFileExists) {
|
|
135
|
+
fs.writeFileSync(STATE_FILE, "{}");
|
|
136
|
+
return {};
|
|
137
|
+
}
|
|
138
|
+
const stateFileContent = fs.readFileSync(STATE_FILE, "utf-8");
|
|
139
|
+
const result = stateSchema.safeParse(JSON.parse(stateFileContent));
|
|
140
|
+
if (!result.success) {
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
return result.data;
|
|
144
|
+
};
|
|
145
|
+
var setState = (state) => {
|
|
146
|
+
const existing = getState();
|
|
147
|
+
const newState = stateSchema.parse({ ...existing, ...state });
|
|
148
|
+
fs.writeFileSync(STATE_FILE, JSON.stringify(newState, null, 2));
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/shared/redeem-invite.ts
|
|
152
|
+
var redeemInviteCode = async ({
|
|
153
|
+
code,
|
|
154
|
+
dev,
|
|
155
|
+
address,
|
|
156
|
+
surface
|
|
157
|
+
}) => {
|
|
158
|
+
const state = getState();
|
|
159
|
+
if (state.redeemedCodes?.includes(code)) {
|
|
160
|
+
return err("user", surface, {
|
|
161
|
+
cause: "conflict",
|
|
162
|
+
message: "This invite code has already been redeemed"
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const result = await safeFetchJson(
|
|
166
|
+
surface,
|
|
167
|
+
new Request(`${getBaseUrl(dev)}/api/invite/redeem`, {
|
|
168
|
+
method: "POST",
|
|
169
|
+
headers: {
|
|
170
|
+
"Content-Type": "application/json"
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
code,
|
|
174
|
+
recipientAddr: address
|
|
175
|
+
})
|
|
176
|
+
}),
|
|
177
|
+
z3.object({
|
|
178
|
+
redemptionId: z3.string(),
|
|
179
|
+
txHash: z3.string(),
|
|
180
|
+
amount: z3.coerce.number()
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
if (result.isOk()) {
|
|
184
|
+
setState({
|
|
185
|
+
redeemedCodes: [...state.redeemedCodes ?? [], code]
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
safeStringifyJson,
|
|
193
|
+
safeParseJson,
|
|
194
|
+
getWallet,
|
|
195
|
+
redeemInviteCode
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=chunk-HIR4VH7V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/wallet.ts","../../src/shared/neverthrow/json/index.ts","../../src/shared/redeem-invite.ts","../../src/shared/state.ts"],"sourcesContent":["import { existsSync } from 'fs';\n\nimport { getAddress } from 'viem';\nimport { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';\n\nimport z from 'zod';\n\nimport { ok } from '@x402scan/neverthrow';\n\nimport {\n fsErr,\n safeChmod,\n safeReadFile,\n safeWriteFile,\n} from '@/shared/neverthrow/fs';\nimport { jsonErr, safeParseJson } from '@/shared/neverthrow/json';\nimport { safeParse } from '@/shared/neverthrow/parse';\n\nimport { log } from './log';\nimport { configFile } from './fs';\n\nimport type { Hex } from 'viem';\n\nconst WALLET_FILE = configFile('wallet.json');\n\nconst storedWalletSchema = z.object({\n privateKey: z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'Invalid Ethereum private key')\n .transform(privateKey => privateKey as Hex),\n address: z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid Ethereum address')\n .transform(address => getAddress(address)),\n createdAt: z.string(),\n});\n\nconst walletSurface = 'wallet';\n\nexport async function getWallet() {\n if (process.env.X402_PRIVATE_KEY) {\n const account = privateKeyToAccount(process.env.X402_PRIVATE_KEY as Hex);\n log.info(`Using wallet from env: ${account.address}`);\n return ok({ account, isNew: false });\n }\n\n const readFileResult = await safeReadFile(walletSurface, WALLET_FILE);\n\n if (!readFileResult.isOk()) {\n const fileExistsResult = existsSync(WALLET_FILE);\n // file exists but is not readable\n if (fileExistsResult) {\n return fsErr(walletSurface, {\n cause: 'file_not_readable',\n message: `The file exists but is not readable. Fix corrupted state file: ${WALLET_FILE}`,\n });\n }\n }\n\n if (readFileResult.isOk()) {\n const data = readFileResult.value;\n const jsonParseResult = safeParseJson(walletSurface, data);\n\n // file exists but is not valid JSON\n if (jsonParseResult.isErr()) {\n return jsonErr(walletSurface, {\n cause: 'parse',\n message: `The data in ${WALLET_FILE} is not valid JSON`,\n });\n }\n\n const parseResult = safeParse(\n walletSurface,\n storedWalletSchema,\n jsonParseResult.value\n );\n\n // file has valid JSON but is not a valid wallet configuration\n if (parseResult.isErr()) {\n return parseResult;\n }\n\n const account = privateKeyToAccount(parseResult.value.privateKey);\n log.info(`Loaded wallet: ${account.address}`);\n return ok({ account, isNew: false });\n }\n\n // Generate new\n const privateKey = generatePrivateKey();\n const account = privateKeyToAccount(privateKey);\n const stored = {\n privateKey,\n address: account.address,\n createdAt: new Date().toISOString(),\n };\n\n const saveResult = await safeWriteFile(\n walletSurface,\n WALLET_FILE,\n JSON.stringify(stored, null, 2)\n ).andThen(() => safeChmod(walletSurface, WALLET_FILE, 0o600));\n\n if (saveResult.isErr()) {\n return saveResult;\n }\n\n log.info(`Created wallet: ${account.address}`);\n log.info(`Saved to: ${WALLET_FILE}`);\n\n return ok({ account, isNew: true });\n}\n","import { err, resultFromThrowable } from '@x402scan/neverthrow';\n\nimport type { BaseJsonError, JsonObject } from './types';\n\nconst type = 'json';\n\nexport const jsonErr = (surface: string, error: BaseJsonError) => {\n return err(type, surface, error);\n};\n\nexport const safeStringifyJson = (surface: string, value: JsonObject) => {\n return resultFromThrowable(\n type,\n surface,\n () => JSON.stringify(value, null, 2),\n () => ({\n cause: 'stringify' as const,\n message: 'Could not stringify JSON',\n })\n );\n};\n\nexport const safeParseJson = (surface: string, value: string) => {\n return resultFromThrowable(\n type,\n surface,\n () => JSON.parse(value) as JsonObject,\n e => ({\n cause: 'parse' as const,\n message: e instanceof Error ? e.message : 'Could not parse JSON',\n })\n );\n};\n","import z from 'zod';\n\nimport { safeFetchJson } from '@/shared/neverthrow/fetch';\nimport { err } from '@x402scan/neverthrow';\n\nimport { getBaseUrl } from './utils';\nimport { getState, setState } from './state';\n\nimport type { Address } from 'viem';\n\nexport interface RedeemInviteProps {\n code: string;\n dev: boolean;\n address: Address;\n surface: string;\n}\n\nexport const redeemInviteCode = async ({\n code,\n dev,\n address,\n surface,\n}: RedeemInviteProps) => {\n const state = getState();\n\n if (state.redeemedCodes?.includes(code)) {\n return err('user', surface, {\n cause: 'conflict',\n message: 'This invite code has already been redeemed',\n });\n }\n\n const result = await safeFetchJson(\n surface,\n new Request(`${getBaseUrl(dev)}/api/invite/redeem`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n code,\n recipientAddr: address,\n }),\n }),\n z.object({\n redemptionId: z.string(),\n txHash: z.string(),\n amount: z.coerce.number(),\n })\n );\n\n if (result.isOk()) {\n setState({\n redeemedCodes: [...(state.redeemedCodes ?? []), code],\n });\n }\n\n return result;\n};\n","import z from 'zod';\nimport fs from 'fs';\n\nimport { configFile } from './fs';\n\nconst STATE_FILE = configFile('state.json');\n\nconst stateSchema = z\n .looseObject({\n redeemedCodes: z.array(z.string()),\n })\n .partial();\n\nexport const getState = () => {\n const stateFileExists = fs.existsSync(STATE_FILE);\n if (!stateFileExists) {\n fs.writeFileSync(STATE_FILE, '{}');\n return {};\n }\n\n const stateFileContent = fs.readFileSync(STATE_FILE, 'utf-8');\n const result = stateSchema.safeParse(JSON.parse(stateFileContent));\n if (!result.success) {\n return {};\n }\n return result.data;\n};\n\nexport const setState = (state: z.infer<typeof stateSchema>) => {\n const existing = getState();\n const newState = stateSchema.parse({ ...existing, ...state });\n fs.writeFileSync(STATE_FILE, JSON.stringify(newState, null, 2));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB,2BAA2B;AAExD,OAAO,OAAO;;;ACLd;AAIA,IAAM,OAAO;AAEN,IAAM,UAAU,CAAC,SAAiB,UAAyB;AAChE,SAAO,IAAI,MAAM,SAAS,KAAK;AACjC;AAEO,IAAM,oBAAoB,CAAC,SAAiB,UAAsB;AACvE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,KAAK,UAAU,OAAO,MAAM,CAAC;A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+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-A2KI7TKE.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/cli-context.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
var context = {
|
|
8
|
+
verbose: false
|
|
9
|
+
};
|
|
10
|
+
function configureCliContext(options) {
|
|
11
|
+
if (options.verbose !== void 0) {
|
|
12
|
+
context.verbose = options.verbose;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isVerbose() {
|
|
16
|
+
return context.verbose || process.env.X402_DEBUG === "true";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
configureCliContext,
|
|
21
|
+
isVerbose
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-J3LUL7DB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/cli-context.ts"],"sourcesContent":["/**\n * Global CLI context for shared state that needs to be accessed\n * across modules without passing through every function parameter.\n *\n * Set once at CLI startup, read anywhere.\n */\n\ninterface CliContext {\n verbose: boolean;\n}\n\nconst context: CliContext = {\n verbose: false,\n};\n\n/**\n * Configure CLI context (call once at startup)\n */\nexport function configureCliContext(options: Partial<CliContext>): void {\n if (options.verbose !== undefined) {\n context.verbose = options.verbose;\n }\n}\n\n/**\n * Check if verbose/debug mode is enabled\n * Checks both CLI context and X402_DEBUG env var\n */\nexport function isVerbose(): boolean {\n return context.verbose || process.env.X402_DEBUG === 'true';\n}\n"],"mappings":";;;;;AAAA;AAWA,IAAM,UAAsB;AAAA,EAC1B,SAAS;AACX;AAKO,SAAS,oBAAoB,SAAoC;AACtE,MAAI,QAAQ,YAAY,QAAW;AACjC,YAAQ,UAAU,QAAQ;AAAA,EAC5B;AACF;AAMO,SAAS,YAAqB;AACnC,SAAO,QAAQ,WAAW,QAAQ,IAAI,eAAe;AACvD;","names":[]}
|