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.
Files changed (37) hide show
  1. package/README.md +195 -0
  2. package/dist/cjs/run-server.cjs +112199 -0
  3. package/dist/esm/chunk-3MUBKDR7.js +95 -0
  4. package/dist/esm/chunk-3MUBKDR7.js.map +1 -0
  5. package/dist/esm/chunk-A2KI7TKE.js +59 -0
  6. package/dist/esm/chunk-A2KI7TKE.js.map +1 -0
  7. package/dist/esm/chunk-FYIUFEVS.js +36 -0
  8. package/dist/esm/chunk-FYIUFEVS.js.map +1 -0
  9. package/dist/esm/chunk-HIR4VH7V.js +197 -0
  10. package/dist/esm/chunk-HIR4VH7V.js.map +1 -0
  11. package/dist/esm/chunk-J3LUL7DB.js +23 -0
  12. package/dist/esm/chunk-J3LUL7DB.js.map +1 -0
  13. package/dist/esm/chunk-PBZIKECT.js +46013 -0
  14. package/dist/esm/chunk-PBZIKECT.js.map +1 -0
  15. package/dist/esm/chunk-U6HC4IE3.js +119 -0
  16. package/dist/esm/chunk-U6HC4IE3.js.map +1 -0
  17. package/dist/esm/chunk-WW65CMHP.js +826 -0
  18. package/dist/esm/chunk-WW65CMHP.js.map +1 -0
  19. package/dist/esm/chunk-XCVCGASL.js +57 -0
  20. package/dist/esm/chunk-XCVCGASL.js.map +1 -0
  21. package/dist/esm/cli-context-2MKOXVXU.js +10 -0
  22. package/dist/esm/cli-context-2MKOXVXU.js.map +1 -0
  23. package/dist/esm/commands-EOBZV2HH.js +536 -0
  24. package/dist/esm/commands-EOBZV2HH.js.map +1 -0
  25. package/dist/esm/fund-GUW4GKZT.js +37 -0
  26. package/dist/esm/fund-GUW4GKZT.js.map +1 -0
  27. package/dist/esm/index.d.ts +1 -0
  28. package/dist/esm/index.js +249 -0
  29. package/dist/esm/index.js.map +1 -0
  30. package/dist/esm/install-OYN36YE4.js +720 -0
  31. package/dist/esm/install-OYN36YE4.js.map +1 -0
  32. package/dist/esm/server-BEEIW53K.js +1814 -0
  33. package/dist/esm/server-BEEIW53K.js.map +1 -0
  34. package/dist/esm/shared/operations/index.d.ts +194 -0
  35. package/dist/esm/shared/operations/index.js +19 -0
  36. package/dist/esm/shared/operations/index.js.map +1 -0
  37. package/package.json +82 -0
@@ -0,0 +1,720 @@
1
+ import {
2
+ Clients,
3
+ clientMetadata
4
+ } from "./chunk-3MUBKDR7.js";
5
+ import {
6
+ DIST_TAG,
7
+ getBalance
8
+ } from "./chunk-XCVCGASL.js";
9
+ import {
10
+ promptDeposit,
11
+ wait
12
+ } from "./chunk-U6HC4IE3.js";
13
+ import {
14
+ getWallet,
15
+ redeemInviteCode
16
+ } from "./chunk-HIR4VH7V.js";
17
+ import {
18
+ err,
19
+ log,
20
+ resultFromThrowable,
21
+ safeReadFile,
22
+ safeWriteFile
23
+ } from "./chunk-WW65CMHP.js";
24
+ import "./chunk-J3LUL7DB.js";
25
+ import {
26
+ init_esm_shims
27
+ } from "./chunk-A2KI7TKE.js";
28
+
29
+ // src/cli/install/index.ts
30
+ init_esm_shims();
31
+ import chalk5 from "chalk";
32
+ import { intro, outro as outro3 } from "@clack/prompts";
33
+
34
+ // src/cli/install/1-get-client/index.ts
35
+ init_esm_shims();
36
+ import z from "zod";
37
+ import { select, log as log2, outro } from "@clack/prompts";
38
+ import chalk from "chalk";
39
+ var getClient = async ({ client: flagClient, yes }) => {
40
+ if (yes) {
41
+ if (!flagClient) {
42
+ throw new Error(
43
+ `Client is required when yes is true. Pass --client as one of these values: ${Object.values(Clients).join(", ")}`
44
+ );
45
+ }
46
+ const parsedClient2 = z.enum(Clients).safeParse(flagClient);
47
+ if (!parsedClient2.success) {
48
+ throw new Error(
49
+ `${flagClient} is not a valid client. Valid options are: ${Object.values(Clients).join(", ")}`
50
+ );
51
+ }
52
+ return parsedClient2.data;
53
+ }
54
+ const parsedClient = z.enum(Clients).safeParse(flagClient);
55
+ if (parsedClient.success) {
56
+ return parsedClient.data;
57
+ }
58
+ if (flagClient) {
59
+ log2.error(`${flagClient} is not a valid client. Please select a client`);
60
+ }
61
+ const client = await select({
62
+ message: "Where would you like to install the agentcash MCP server?",
63
+ options: Object.values(Clients).map((client2) => {
64
+ const metadata = clientMetadata[client2];
65
+ return {
66
+ label: metadata.name,
67
+ value: client2
68
+ };
69
+ }),
70
+ maxItems: 7
71
+ });
72
+ const parsedClientSelection = z.enum(Clients).safeParse(client);
73
+ if (parsedClientSelection.success) {
74
+ return parsedClientSelection.data;
75
+ }
76
+ outro(chalk.bold.red("No MCP client selected"));
77
+ process.exit(0);
78
+ };
79
+
80
+ // src/cli/install/2-add-server/index.ts
81
+ init_esm_shims();
82
+ import fs2 from "fs";
83
+ import chalk2 from "chalk";
84
+ import { log as clackLog, confirm, outro as outro2, stream } from "@clack/prompts";
85
+
86
+ // src/cli/install/2-add-server/lib/index.ts
87
+ init_esm_shims();
88
+
89
+ // src/cli/install/2-add-server/lib/client-config-file.ts
90
+ init_esm_shims();
91
+ import os2 from "os";
92
+ import path2 from "path";
93
+ import process3 from "process";
94
+ import fs from "fs";
95
+
96
+ // src/cli/install/2-add-server/lib/platforms.ts
97
+ init_esm_shims();
98
+ import os from "os";
99
+ import path from "path";
100
+ import process2 from "process";
101
+ import z2 from "zod";
102
+ var Platforms = /* @__PURE__ */ ((Platforms2) => {
103
+ Platforms2["Windows"] = "win32";
104
+ Platforms2["MacOS"] = "darwin";
105
+ Platforms2["Linux"] = "linux";
106
+ return Platforms2;
107
+ })(Platforms || {});
108
+ var getPlatformPath = () => {
109
+ const platform = z2.enum(Platforms).safeParse(process2.platform);
110
+ if (!platform.success) {
111
+ throw new Error(`Invalid platform: ${process2.platform}`);
112
+ }
113
+ const homeDir = os.homedir();
114
+ switch (platform.data) {
115
+ case "win32" /* Windows */:
116
+ return {
117
+ baseDir: process2.env.APPDATA ?? path.join(homeDir, "AppData", "Roaming"),
118
+ vscodePath: path.join("Code", "User")
119
+ };
120
+ case "darwin" /* MacOS */:
121
+ return {
122
+ baseDir: path.join(homeDir, "Library", "Application Support"),
123
+ vscodePath: path.join("Code", "User")
124
+ };
125
+ case "linux" /* Linux */:
126
+ return {
127
+ baseDir: process2.env.XDG_CONFIG_HOME ?? path.join(homeDir, ".config"),
128
+ vscodePath: path.join("Code/User")
129
+ };
130
+ default:
131
+ throw new Error(`Invalid platform: ${process2.platform}`);
132
+ }
133
+ };
134
+
135
+ // src/cli/install/2-add-server/lib/file-types.ts
136
+ init_esm_shims();
137
+ import * as TOML from "@iarna/toml";
138
+ import yaml from "js-yaml";
139
+ import * as jsonc from "jsonc-parser";
140
+
141
+ // src/cli/install/2-add-server/lib/result.ts
142
+ init_esm_shims();
143
+ var errorType = "config";
144
+ var surface = "config_file";
145
+ var configResultFromThrowable = (fn, error) => resultFromThrowable(errorType, surface, fn, error);
146
+
147
+ // src/cli/install/2-add-server/lib/file-types.ts
148
+ var parseContent = (fileContent, format, path3) => {
149
+ return configResultFromThrowable(
150
+ () => {
151
+ let config;
152
+ if (format === "yaml" /* YAML */) {
153
+ config = yaml.load(fileContent);
154
+ } else if (format === "toml" /* TOML */) {
155
+ config = TOML.parse(fileContent);
156
+ } else if (path3.endsWith(".jsonc")) {
157
+ config = jsonc.parse(fileContent);
158
+ } else {
159
+ config = JSON.parse(fileContent);
160
+ }
161
+ return {
162
+ config,
163
+ fileContent
164
+ };
165
+ },
166
+ (e) => ({
167
+ cause: "parse_config",
168
+ message: e instanceof Error ? e.message : "Failed to parse config file"
169
+ })
170
+ );
171
+ };
172
+ var parseClientConfig = async ({ format, path: path3 }) => {
173
+ const readResult = await safeReadFile("config_file", path3);
174
+ if (readResult.isErr()) return readResult;
175
+ const parseResult = parseContent(readResult.value, format, path3);
176
+ if (parseResult.isErr()) return parseResult;
177
+ return parseResult;
178
+ };
179
+ var serializeJsonc = (config, originalContent) => {
180
+ return configResultFromThrowable(
181
+ () => {
182
+ const modifications = [];
183
+ for (const key of Object.keys(config)) {
184
+ const keyPath = [key];
185
+ const edits = jsonc.modify(originalContent, keyPath, config[key], {
186
+ formattingOptions: { tabSize: 2, insertSpaces: true }
187
+ });
188
+ modifications.push(...edits);
189
+ }
190
+ return jsonc.applyEdits(originalContent, modifications);
191
+ },
192
+ (e) => ({
193
+ cause: "serialize_config",
194
+ message: e instanceof Error ? e.message : "Failed to serialize JSONC"
195
+ })
196
+ );
197
+ };
198
+ var serializeClientConfig = ({ format, path: path3 }, config, originalContent) => {
199
+ if (format === "yaml" /* YAML */) {
200
+ return yaml.dump(config, {
201
+ indent: 2,
202
+ lineWidth: -1,
203
+ noRefs: true
204
+ });
205
+ }
206
+ if (format === "toml" /* TOML */) {
207
+ return TOML.stringify(config);
208
+ }
209
+ if (path3.endsWith(".jsonc") && originalContent) {
210
+ const result = serializeJsonc(config, originalContent);
211
+ if (result.isOk()) {
212
+ return result.value;
213
+ }
214
+ console.log(`Error applying JSONC edits: ${result.error.message}`);
215
+ console.log("Falling back to JSON.stringify (comments will be lost)");
216
+ return JSON.stringify(config, null, 2);
217
+ }
218
+ return JSON.stringify(config, null, 2);
219
+ };
220
+ var stringifyObject = (config, format) => {
221
+ if (format === "yaml" /* YAML */) {
222
+ return yaml.dump(config, {
223
+ indent: 2,
224
+ lineWidth: -1,
225
+ noRefs: true
226
+ });
227
+ }
228
+ if (format === "toml" /* TOML */) {
229
+ return TOML.stringify(config);
230
+ }
231
+ return JSON.stringify(config, null, 2);
232
+ };
233
+
234
+ // src/cli/install/2-add-server/lib/client-config-file.ts
235
+ var getClientConfigFile = (client) => {
236
+ const homeDir = os2.homedir();
237
+ const { baseDir, vscodePath } = getPlatformPath();
238
+ switch (client) {
239
+ case "claude" /* Claude */:
240
+ return {
241
+ path: path2.join(baseDir, "Claude", "claude_desktop_config.json"),
242
+ configKey: "mcpServers",
243
+ format: "json" /* JSON */
244
+ };
245
+ case "cline" /* Cline */:
246
+ return {
247
+ path: path2.join(
248
+ baseDir,
249
+ vscodePath,
250
+ "globalStorage",
251
+ "saoudrizwan.claude-dev",
252
+ "settings",
253
+ "cline_mcp_settings.json"
254
+ ),
255
+ configKey: "mcpServers",
256
+ format: "json" /* JSON */
257
+ };
258
+ case "roo-cline" /* RooCline */:
259
+ return {
260
+ path: path2.join(
261
+ baseDir,
262
+ vscodePath,
263
+ "globalStorage",
264
+ "rooveterinaryinc.roo-cline",
265
+ "settings",
266
+ "mcp_settings.json"
267
+ ),
268
+ configKey: "mcpServers",
269
+ format: "json" /* JSON */
270
+ };
271
+ case "windsurf" /* Windsurf */:
272
+ return {
273
+ path: path2.join(homeDir, ".codeium", "windsurf", "mcp_config.json"),
274
+ configKey: "mcpServers",
275
+ format: "json" /* JSON */
276
+ };
277
+ case "cursor" /* Cursor */:
278
+ return {
279
+ path: path2.join(homeDir, ".cursor", "mcp.json"),
280
+ configKey: "mcpServers",
281
+ format: "json" /* JSON */
282
+ };
283
+ case "warp" /* Warp */:
284
+ return {
285
+ path: "no-local-config",
286
+ // it's okay this isn't a real path, we never use it
287
+ configKey: "mcpServers",
288
+ format: "json" /* JSON */
289
+ };
290
+ case "gemini-cli" /* GeminiCli */:
291
+ return {
292
+ path: path2.join(homeDir, ".gemini", "settings.json"),
293
+ configKey: "mcpServers",
294
+ format: "json" /* JSON */
295
+ };
296
+ case "vscode" /* Vscode */:
297
+ return {
298
+ path: path2.join(baseDir, vscodePath, "mcp.json"),
299
+ configKey: "mcpServers",
300
+ format: "json" /* JSON */
301
+ };
302
+ case "claude-code" /* ClaudeCode */:
303
+ return {
304
+ path: path2.join(homeDir, ".claude.json"),
305
+ configKey: "mcpServers",
306
+ format: "json" /* JSON */
307
+ };
308
+ case "goose" /* Goose */:
309
+ return {
310
+ path: path2.join(homeDir, ".config", "goose", "config.yaml"),
311
+ configKey: "extensions",
312
+ format: "yaml" /* YAML */
313
+ };
314
+ case "zed" /* Zed */:
315
+ return {
316
+ path: process3.platform === "win32" ? path2.join(
317
+ process3.env.APPDATA ?? path2.join(homeDir, "AppData", "Roaming"),
318
+ "Zed",
319
+ "settings.json"
320
+ ) : path2.join(homeDir, ".config", "zed", "settings.json"),
321
+ configKey: "context_servers",
322
+ format: "json" /* JSON */
323
+ };
324
+ case "codex" /* Codex */:
325
+ return {
326
+ path: path2.join(
327
+ process3.env.CODEX_HOME ?? path2.join(homeDir, ".codex"),
328
+ "config.toml"
329
+ ),
330
+ configKey: "mcp_servers",
331
+ format: "toml" /* TOML */
332
+ };
333
+ case "opencode" /* Opencode */: {
334
+ const jsonPath = path2.join(
335
+ homeDir,
336
+ ".config",
337
+ "opencode",
338
+ "opencode.json"
339
+ );
340
+ const jsoncPath = jsonPath.replace(".json", ".jsonc");
341
+ if (fs.existsSync(jsoncPath)) {
342
+ log.info(`Found .jsonc file for OpenCode, using: ${jsoncPath}`);
343
+ return {
344
+ path: jsoncPath,
345
+ configKey: "mcp",
346
+ format: "json" /* JSON */
347
+ };
348
+ }
349
+ return {
350
+ path: jsonPath,
351
+ configKey: "mcp",
352
+ format: "json" /* JSON */
353
+ };
354
+ }
355
+ default:
356
+ throw new Error(`Unknown client: ${String(client)}`);
357
+ }
358
+ };
359
+
360
+ // src/cli/install/2-add-server/lib/nested-values.ts
361
+ init_esm_shims();
362
+ var getNestedValue = (obj, path3) => {
363
+ const keys = path3.split(".");
364
+ let current = obj;
365
+ for (const key of keys) {
366
+ if (current && typeof current === "object" && key in current) {
367
+ current = current[key];
368
+ } else {
369
+ return void 0;
370
+ }
371
+ }
372
+ return current;
373
+ };
374
+ var setNestedValue = (obj, path3, value) => {
375
+ const keys = path3.split(".");
376
+ const lastKey = keys.pop();
377
+ if (!lastKey) return;
378
+ const target = keys.reduce((current, key) => {
379
+ current[key] ??= {};
380
+ return current[key];
381
+ }, obj);
382
+ target[lastKey] = value;
383
+ };
384
+
385
+ // src/cli/install/2-add-server/index.ts
386
+ var getMcpConfig = (globalFlags) => {
387
+ if (globalFlags.dev) {
388
+ return {
389
+ serverName: "x402",
390
+ command: "node",
391
+ args: [`${process.cwd()}/dist/esm/index.js`, "--dev"]
392
+ };
393
+ }
394
+ return {
395
+ serverName: "x402",
396
+ command: "npx",
397
+ args: ["-y", `agentcash@${DIST_TAG}`]
398
+ };
399
+ };
400
+ var addServer = async (client, globalFlags) => {
401
+ const { serverName, command, args } = getMcpConfig(globalFlags);
402
+ if (client === "warp" /* Warp */) {
403
+ clackLog.info(
404
+ chalk2.bold.yellow("Warp requires a manual installation through their UI.")
405
+ );
406
+ clackLog.message(
407
+ "Please copy the following configuration object and add it to your Warp MCP config:"
408
+ );
409
+ console.log();
410
+ console.log(
411
+ JSON.stringify(
412
+ {
413
+ [serverName]: {
414
+ command,
415
+ args,
416
+ working_directory: null,
417
+ start_on_launch: true
418
+ }
419
+ },
420
+ null,
421
+ 2
422
+ )
423
+ );
424
+ console.log();
425
+ clackLog.message(
426
+ `Read Warp's documentation at https://docs.warp.dev/knowledge-and-collaboration/mcp`
427
+ );
428
+ const addedToWarp = await confirm({
429
+ message: "Did you add the MCP server to your Warp config?"
430
+ });
431
+ if (!addedToWarp) {
432
+ return err("user", "install", {
433
+ cause: "warp_mcp_server_not_added",
434
+ message: "Warp MCP server not added"
435
+ });
436
+ }
437
+ }
438
+ const clientFileTarget = getClientConfigFile(client);
439
+ const { name } = clientMetadata[client];
440
+ let config = {};
441
+ let content = void 0;
442
+ log.info(`Checking if config file exists at: ${clientFileTarget.path}`);
443
+ if (!fs2.existsSync(clientFileTarget.path)) {
444
+ log.info("Config file not found, creating default empty config");
445
+ setNestedValue(config, clientFileTarget.configKey, {});
446
+ log.info("Config created successfully");
447
+ if (!globalFlags.yes) {
448
+ await wait({
449
+ startText: "Locating config file",
450
+ stopText: `No config found, creating default empty config`,
451
+ ms: 1e3
452
+ });
453
+ }
454
+ } else {
455
+ log.info("Config file found, reading config file content");
456
+ const parseResult = await parseClientConfig(clientFileTarget);
457
+ if (parseResult.isErr()) {
458
+ clackLog.error(
459
+ chalk2.bold.red(`Error reading config: ${parseResult.error.message}`)
460
+ );
461
+ outro2(chalk2.bold.red(`Error adding agentcash MCP to ${name}`));
462
+ process.exit(1);
463
+ }
464
+ const { config: rawConfig, fileContent } = parseResult.value;
465
+ config = rawConfig;
466
+ content = fileContent;
467
+ const existingValue = getNestedValue(rawConfig, clientFileTarget.configKey);
468
+ if (!existingValue) {
469
+ setNestedValue(rawConfig, clientFileTarget.configKey, {});
470
+ }
471
+ if (!globalFlags.yes) {
472
+ await wait({
473
+ startText: `Locating config file`,
474
+ stopText: `Config loaded from ${clientFileTarget.path}`,
475
+ ms: 1e3
476
+ });
477
+ }
478
+ }
479
+ const servers = getNestedValue(config, clientFileTarget.configKey);
480
+ if (!servers || typeof servers !== "object") {
481
+ log.error(`Invalid ${clientFileTarget.configKey} structure in config`);
482
+ clackLog.error(
483
+ chalk2.bold.red(
484
+ `Invalid ${clientFileTarget.configKey} structure in config`
485
+ )
486
+ );
487
+ outro2(chalk2.bold.red(`Error adding agentcash MCP to ${name}`));
488
+ process.exit(1);
489
+ }
490
+ if (client === "goose" /* Goose */) {
491
+ servers[serverName] = {
492
+ name: serverName,
493
+ cmd: command,
494
+ args,
495
+ enabled: true,
496
+ envs: {},
497
+ type: "stdio",
498
+ timeout: 300
499
+ };
500
+ } else if (client === "zed" /* Zed */) {
501
+ servers[serverName] = {
502
+ source: "custom",
503
+ command,
504
+ args,
505
+ env: {}
506
+ };
507
+ } else if (client === "opencode" /* Opencode */) {
508
+ servers[serverName] = {
509
+ type: "local",
510
+ command,
511
+ args,
512
+ enabled: true,
513
+ environment: {}
514
+ };
515
+ } else {
516
+ servers[serverName] = {
517
+ command,
518
+ args
519
+ };
520
+ }
521
+ if (!globalFlags.yes) {
522
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
523
+ clackLog.step(
524
+ `The following will be added to ${chalk2.bold.underline(clientFileTarget.path)}`
525
+ );
526
+ }
527
+ const configStr = formatDiffByFormat(
528
+ {
529
+ [clientFileTarget.configKey]: {
530
+ [serverName]: servers[serverName]
531
+ }
532
+ },
533
+ clientFileTarget.format
534
+ );
535
+ if (!globalFlags.yes) {
536
+ await stream.message(
537
+ (async function* () {
538
+ for (const num of Array.from(
539
+ { length: configStr.length },
540
+ (_, i) => i
541
+ )) {
542
+ const char = configStr[num];
543
+ yield char;
544
+ if (!["\n", " ", "\u2500", "\u256E", "\u256D", "\u2570", "\u256F", "\u2502"].includes(char)) {
545
+ await new Promise((resolve) => setTimeout(resolve, 5));
546
+ } else {
547
+ await new Promise((resolve) => setTimeout(resolve, 2));
548
+ }
549
+ }
550
+ })()
551
+ );
552
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
553
+ }
554
+ const isConfirmed = globalFlags.yes ? true : await confirm({
555
+ message: `Would you like to proceed?`,
556
+ active: "Install MCP",
557
+ inactive: "Cancel"
558
+ });
559
+ if (isConfirmed !== true) {
560
+ outro2(chalk2.bold.red("Installation cancelled"));
561
+ process.exit(0);
562
+ }
563
+ const configContent = serializeClientConfig(
564
+ clientFileTarget,
565
+ config,
566
+ content
567
+ );
568
+ const writeResult = await safeWriteFile(
569
+ "config_file",
570
+ clientFileTarget.path,
571
+ configContent
572
+ );
573
+ if (writeResult.isErr()) {
574
+ clackLog.error(
575
+ chalk2.bold.red(`Error writing config: ${writeResult.error.message}`)
576
+ );
577
+ outro2(chalk2.bold.red(`Error adding agentcash MCP to ${name}`));
578
+ process.exit(1);
579
+ }
580
+ clackLog.success(chalk2.bold.green(`Added agentcash MCP to ${name}`));
581
+ };
582
+ var formatDiffByFormat = (obj, format) => {
583
+ const str = stringifyObject(obj, format);
584
+ switch (format) {
585
+ case "json" /* JSON */: {
586
+ const numLines = str.split("\n").length;
587
+ return str.split("\n").map((line, index) => {
588
+ const diffLines = [0, 1, numLines - 2, numLines - 1];
589
+ const isDiffLine = !diffLines.includes(index);
590
+ if (isDiffLine) {
591
+ return `${chalk2.bold.green(`+ ${line.slice(2)}`)}`;
592
+ }
593
+ return line;
594
+ }).join("\n");
595
+ }
596
+ case "yaml" /* YAML */: {
597
+ return str.split("\n").map((line, index) => {
598
+ const diffLines = [0, 1, str.length - 2, str.length - 1];
599
+ const isDiffLine = !diffLines.includes(index);
600
+ if (isDiffLine) {
601
+ return `${chalk2.bold.green(`+ ${line.slice(2)}`)}`;
602
+ }
603
+ return line;
604
+ }).join("\n");
605
+ }
606
+ case "toml" /* TOML */: {
607
+ return str.split("\n").filter((line) => line.trim() !== "").map((line) => {
608
+ return `${chalk2.bold.green(`+ ${line.trim()}`)}`;
609
+ }).join("\n");
610
+ }
611
+ }
612
+ };
613
+
614
+ // src/cli/install/3-redeem-invite/index.ts
615
+ init_esm_shims();
616
+ import chalk3 from "chalk";
617
+ import { log as log3, spinner } from "@clack/prompts";
618
+ var redeemInviteCode2 = async (props, flags) => {
619
+ const s = spinner();
620
+ if (!flags.yes) {
621
+ s.start("Redeeming invite code...");
622
+ }
623
+ const result = await redeemInviteCode(props);
624
+ return result.match(
625
+ async ({ amount, txHash }) => {
626
+ if (!flags.yes) {
627
+ s.stop("Invite code redeemed successfully!");
628
+ await wait({
629
+ startText: "Processing...",
630
+ stopText: chalk3.green(
631
+ `${chalk3.bold(amount)} USDC has been sent to your wallet!`
632
+ ),
633
+ ms: 1e3
634
+ });
635
+ }
636
+ log3.info(chalk3.dim(`Transaction: https://basescan.org/tx/${txHash}`));
637
+ return true;
638
+ },
639
+ (error) => {
640
+ if (!flags.yes) {
641
+ s.stop("Invite code redemption failed");
642
+ }
643
+ log3.warning(
644
+ chalk3.yellow(`Failed to redeem invite code: ${error.message}`)
645
+ );
646
+ return false;
647
+ }
648
+ );
649
+ };
650
+
651
+ // src/cli/install/4-add-funds/index.ts
652
+ init_esm_shims();
653
+ import chalk4 from "chalk";
654
+ import { log as log4, spinner as spinner2 } from "@clack/prompts";
655
+ var addFunds = async ({ flags, address, isNew }) => {
656
+ if (isNew) {
657
+ if (!flags.yes) {
658
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
659
+ }
660
+ log4.info("To use paid API tools, you will need USDC in your wallet.");
661
+ await promptDeposit({ address, flags, surface: "add-funds" });
662
+ } else {
663
+ const { start, stop } = spinner2();
664
+ start("Checking balance...");
665
+ const balanceResult = await getBalance({
666
+ address,
667
+ flags,
668
+ surface: "add-funds"
669
+ });
670
+ if (balanceResult.isOk()) {
671
+ stop(`Balance: ${chalk4.bold(`${balanceResult.value.balance} USDC`)} `);
672
+ } else {
673
+ stop(`Error: ${balanceResult.error.message}`);
674
+ return;
675
+ }
676
+ const balance = balanceResult.value;
677
+ if (balance.balance < 1) {
678
+ log4.warning(
679
+ chalk4.bold(
680
+ `Your balance is low (${balance.balance} USDC). Consider topping up.`
681
+ )
682
+ );
683
+ await promptDeposit({ address, flags, surface: "install" });
684
+ }
685
+ }
686
+ };
687
+
688
+ // src/cli/install/index.ts
689
+ var installMcpServer = async (flags) => {
690
+ intro(chalk5.green.bold(`Install agentcash MCP`));
691
+ const walletResult = await getWallet();
692
+ if (walletResult.isErr()) {
693
+ log.error(JSON.stringify(walletResult.error, null, 2));
694
+ outro3(chalk5.bold.red("Failed to get wallet"));
695
+ process.exit(1);
696
+ }
697
+ const {
698
+ account: { address },
699
+ isNew
700
+ } = walletResult.value;
701
+ const client = await getClient(flags);
702
+ await addServer(client, flags);
703
+ const inviteRedeemed = flags.invite ? await redeemInviteCode2(
704
+ {
705
+ code: flags.invite,
706
+ dev: flags.dev,
707
+ address,
708
+ surface: "install"
709
+ },
710
+ flags
711
+ ) : false;
712
+ if (!inviteRedeemed) {
713
+ await addFunds({ flags, address, isNew });
714
+ }
715
+ outro3(chalk5.bold.green("Your agentcash MCP server is ready to use!"));
716
+ };
717
+ export {
718
+ installMcpServer
719
+ };
720
+ //# sourceMappingURL=install-OYN36YE4.js.map