httpcat-cli 0.0.15 ā 0.0.17
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 +165 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +48 -11
- package/dist/commands/chat.js.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/chat-state.d.ts.map +1 -0
- package/dist/mcp/chat-state.js +180 -0
- package/dist/mcp/chat-state.js.map +1 -0
- package/dist/mcp/server.js +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +147 -3
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +65 -37
- package/dist/utils/formatting.js.map +1 -1
- package/homebrew-httpcat/Formula/httpcat.rb +3 -3
- package/homebrew-httpcat/homebrew-httpcat/Formula/httpcat.rb +3 -3
- package/httpcat-mcp.json +11 -0
- package/monitor-foobar.js +118 -0
- package/package.json +1 -1
package/dist/utils/formatting.js
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import Table from
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import Table from "cli-table3";
|
|
3
3
|
export function formatCurrency(value, decimals = 6) {
|
|
4
|
-
const num = typeof value ===
|
|
4
|
+
const num = typeof value === "string" ? parseFloat(value) : value;
|
|
5
5
|
if (isNaN(num)) {
|
|
6
|
-
return
|
|
6
|
+
return "$0.00";
|
|
7
7
|
}
|
|
8
8
|
if (decimals === 6) {
|
|
9
9
|
// USDC - detect if value is already in decimal format or needs conversion
|
|
10
|
-
// API responses
|
|
10
|
+
// API responses can be either:
|
|
11
|
+
// - Decimal strings: "0.20", "5.00", "0.002" (already in decimal format)
|
|
12
|
+
// - Micro-USDC integers: "200000", "2000" (need conversion: divide by 10^6)
|
|
11
13
|
// Raw blockchain values are numbers in micro-USDC format (e.g., 200000 = $0.20)
|
|
12
14
|
let formattedNum;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
if (typeof value === "string") {
|
|
16
|
+
// String from API - need to detect format
|
|
17
|
+
// If it contains a decimal point, it's already in decimal format
|
|
18
|
+
// If it's an integer without decimal point, it's in micro-USDC format (needs division by 10^6)
|
|
19
|
+
// Exception: "0" should be treated as decimal 0, not micro-USDC
|
|
20
|
+
if (value.includes(".")) {
|
|
21
|
+
// Has decimal point - already in decimal format
|
|
22
|
+
formattedNum = num;
|
|
23
|
+
}
|
|
24
|
+
else if (value === "0" || num === 0) {
|
|
25
|
+
// Explicit zero - treat as decimal 0
|
|
26
|
+
formattedNum = 0;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Integer without decimal point - in micro-USDC format
|
|
30
|
+
formattedNum = num / 10 ** 6;
|
|
31
|
+
}
|
|
16
32
|
}
|
|
17
33
|
else {
|
|
18
|
-
//
|
|
34
|
+
// Numeric value (not from API) - check if it looks like micro-USDC
|
|
19
35
|
// Values >= 1,000,000 are likely in micro-USDC format and need conversion
|
|
20
36
|
if (num >= 1000000) {
|
|
21
37
|
// Likely in micro-USDC format, convert
|
|
@@ -29,13 +45,21 @@ export function formatCurrency(value, decimals = 6) {
|
|
|
29
45
|
// Format with appropriate decimal places based on value size
|
|
30
46
|
// For very small values (< 0.01), show up to 6 decimal places to avoid rounding to $0.00
|
|
31
47
|
// For larger values, show 2 decimal places
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
// Use a small epsilon to check for zero (accounting for floating point precision)
|
|
49
|
+
if (Math.abs(formattedNum) < 1e-10) {
|
|
50
|
+
return "$0.00";
|
|
34
51
|
}
|
|
35
52
|
else if (formattedNum < 0.01) {
|
|
36
|
-
// Show up to
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
// Show up to 12 decimal places for very small values (like token prices)
|
|
54
|
+
// Use toFixed(12) to ensure we capture very small values, then trim trailing zeros
|
|
55
|
+
const formatted = formattedNum.toFixed(12);
|
|
56
|
+
// Remove trailing zeros and trailing decimal point
|
|
57
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
58
|
+
// If after trimming we have nothing meaningful (just "0"), show $0.00
|
|
59
|
+
if (trimmed === "0" || trimmed === "") {
|
|
60
|
+
return "$0.00";
|
|
61
|
+
}
|
|
62
|
+
return `$${trimmed}`;
|
|
39
63
|
}
|
|
40
64
|
else {
|
|
41
65
|
// Standard 2 decimal places for larger values
|
|
@@ -44,16 +68,20 @@ export function formatCurrency(value, decimals = 6) {
|
|
|
44
68
|
}
|
|
45
69
|
else if (decimals === 18) {
|
|
46
70
|
// Token amount
|
|
47
|
-
return (num / 10 ** 18).toLocaleString(
|
|
71
|
+
return (num / 10 ** 18).toLocaleString("en-US", {
|
|
48
72
|
maximumFractionDigits: 2,
|
|
49
73
|
});
|
|
50
74
|
}
|
|
51
75
|
// Default: treat as already in decimal format
|
|
52
76
|
if (num === 0) {
|
|
53
|
-
return
|
|
77
|
+
return "$0.00";
|
|
54
78
|
}
|
|
55
79
|
else if (num < 0.01) {
|
|
56
|
-
|
|
80
|
+
// Show up to 12 decimal places for very small values
|
|
81
|
+
const formatted = num.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
|
|
82
|
+
if (formatted === "0" || formatted === "") {
|
|
83
|
+
return "$0.00";
|
|
84
|
+
}
|
|
57
85
|
return `$${formatted}`;
|
|
58
86
|
}
|
|
59
87
|
else {
|
|
@@ -61,31 +89,31 @@ export function formatCurrency(value, decimals = 6) {
|
|
|
61
89
|
}
|
|
62
90
|
}
|
|
63
91
|
export function formatEthBalance(wei) {
|
|
64
|
-
const weiValue = typeof wei ===
|
|
92
|
+
const weiValue = typeof wei === "string" ? BigInt(wei) : wei;
|
|
65
93
|
const divisor = BigInt(10 ** 18);
|
|
66
94
|
const eth = Number(weiValue) / Number(divisor);
|
|
67
95
|
if (eth === 0)
|
|
68
|
-
return
|
|
96
|
+
return "0 ETH";
|
|
69
97
|
if (eth < 0.0001)
|
|
70
|
-
return
|
|
98
|
+
return "< 0.0001 ETH";
|
|
71
99
|
return `${eth.toFixed(4)} ETH`;
|
|
72
100
|
}
|
|
73
101
|
export function formatUsdcBalance(amount) {
|
|
74
|
-
const amountValue = typeof amount ===
|
|
102
|
+
const amountValue = typeof amount === "string" ? BigInt(amount) : amount;
|
|
75
103
|
const num = Number(amountValue) / 10 ** 6;
|
|
76
104
|
return `$${num.toFixed(2)} USDC`;
|
|
77
105
|
}
|
|
78
106
|
export function formatTokenAmount(value) {
|
|
79
|
-
const amount = typeof value ===
|
|
107
|
+
const amount = typeof value === "string" ? BigInt(value) : value;
|
|
80
108
|
const divisor = BigInt(10 ** 18);
|
|
81
109
|
const whole = amount / divisor;
|
|
82
110
|
const fraction = amount % divisor;
|
|
83
111
|
if (fraction === 0n) {
|
|
84
|
-
return whole.toLocaleString(
|
|
112
|
+
return whole.toLocaleString("en-US");
|
|
85
113
|
}
|
|
86
114
|
// Show up to 4 decimal places
|
|
87
|
-
const fractionStr = fraction.toString().padStart(18,
|
|
88
|
-
return `${whole.toLocaleString(
|
|
115
|
+
const fractionStr = fraction.toString().padStart(18, "0").slice(0, 4);
|
|
116
|
+
return `${whole.toLocaleString("en-US")}.${fractionStr}`;
|
|
89
117
|
}
|
|
90
118
|
export function formatAddress(address, length = 8) {
|
|
91
119
|
if (address.length <= length)
|
|
@@ -101,7 +129,7 @@ export function createTable(head) {
|
|
|
101
129
|
head: head.map((h) => chalk.cyan.bold(h)),
|
|
102
130
|
style: {
|
|
103
131
|
head: [],
|
|
104
|
-
border: [
|
|
132
|
+
border: ["dim"],
|
|
105
133
|
},
|
|
106
134
|
});
|
|
107
135
|
}
|
|
@@ -109,30 +137,30 @@ export function printBox(title, content) {
|
|
|
109
137
|
const maxKeyLength = Math.max(...Object.keys(content).map((k) => k.length));
|
|
110
138
|
const maxValueLength = Math.max(...Object.values(content).map((v) => v.length));
|
|
111
139
|
const width = Math.max(maxKeyLength + maxValueLength + 5, title.length + 4);
|
|
112
|
-
console.log(
|
|
113
|
-
console.log(
|
|
114
|
-
console.log(
|
|
140
|
+
console.log("ā" + "ā".repeat(width) + "ā");
|
|
141
|
+
console.log("ā " + chalk.bold(title) + " ".repeat(width - title.length - 1) + "ā");
|
|
142
|
+
console.log("ā" + "ā".repeat(width) + "ā¤");
|
|
115
143
|
for (const [key, value] of Object.entries(content)) {
|
|
116
144
|
const padding = width - key.length - value.length - 3;
|
|
117
|
-
console.log(`ā ${chalk.dim(key +
|
|
145
|
+
console.log(`ā ${chalk.dim(key + ":")} ${value}${" ".repeat(padding)}ā`);
|
|
118
146
|
}
|
|
119
|
-
console.log(
|
|
147
|
+
console.log("ā" + "ā".repeat(width) + "ā");
|
|
120
148
|
}
|
|
121
149
|
export function printSuccess(message) {
|
|
122
|
-
console.log(chalk.green(
|
|
150
|
+
console.log(chalk.green("ā
" + message));
|
|
123
151
|
}
|
|
124
152
|
export function printError(message) {
|
|
125
|
-
console.log(chalk.red(
|
|
153
|
+
console.log(chalk.red("ā " + message));
|
|
126
154
|
}
|
|
127
155
|
export function printWarning(message) {
|
|
128
|
-
console.log(chalk.yellow(
|
|
156
|
+
console.log(chalk.yellow("ā ļø " + message));
|
|
129
157
|
}
|
|
130
158
|
export function printInfo(message) {
|
|
131
|
-
console.log(chalk.blue(
|
|
159
|
+
console.log(chalk.blue("ā¹ļø " + message));
|
|
132
160
|
}
|
|
133
161
|
export function printHeader(text) {
|
|
134
|
-
console.log(chalk.cyan(
|
|
162
|
+
console.log(chalk.cyan("=".repeat(80)));
|
|
135
163
|
console.log(chalk.cyan.bold(text));
|
|
136
|
-
console.log(chalk.cyan(
|
|
164
|
+
console.log(chalk.cyan("=".repeat(80)));
|
|
137
165
|
}
|
|
138
166
|
//# sourceMappingURL=formatting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../src/utils/formatting.ts"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,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class Httpcat < Formula
|
|
2
2
|
desc "CLI tool for interacting with httpcat agent - create, buy, and sell tokens with x402 payments"
|
|
3
3
|
homepage "https://github.com/hathbanger/httpcat-cli"
|
|
4
|
-
url "https://registry.npmjs.org/httpcat-cli/-/httpcat-cli-0.0.
|
|
5
|
-
sha256 "
|
|
4
|
+
url "https://registry.npmjs.org/httpcat-cli/-/httpcat-cli-0.0.17.tgz"
|
|
5
|
+
sha256 "PLACEHOLDER_SHA256"
|
|
6
6
|
license "MIT"
|
|
7
7
|
|
|
8
8
|
depends_on "node"
|
|
@@ -13,6 +13,6 @@ class Httpcat < Formula
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
test do
|
|
16
|
-
assert_match "0.0.
|
|
16
|
+
assert_match "0.0.17", shell_output("#{bin}/httpcat --version")
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class Httpcat < Formula
|
|
2
2
|
desc "CLI tool for interacting with httpcat agent - create, buy, and sell tokens with x402 payments"
|
|
3
3
|
homepage "https://github.com/hathbanger/httpcat-cli"
|
|
4
|
-
url "https://registry.npmjs.org/httpcat-cli/-/httpcat-cli-0.0.
|
|
5
|
-
sha256 "
|
|
4
|
+
url "https://registry.npmjs.org/httpcat-cli/-/httpcat-cli-0.0.16.tgz"
|
|
5
|
+
sha256 "36a1314faa8ab72aa7484bc8cbde5bb0e55286c9de7ec7a2522c354af0f11ef1"
|
|
6
6
|
license "MIT"
|
|
7
7
|
|
|
8
8
|
depends_on "node"
|
|
@@ -13,6 +13,6 @@ class Httpcat < Formula
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
test do
|
|
16
|
-
assert_match "0.0.
|
|
16
|
+
assert_match "0.0.16", shell_output("#{bin}/httpcat --version")
|
|
17
17
|
end
|
|
18
18
|
end
|
package/httpcat-mcp.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Monitor FRIDA chat for mentions of "foobar"
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node monitor-foobar.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { dirname } from 'path';
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
|
|
17
|
+
const TOKEN = 'FRIDA';
|
|
18
|
+
const SEARCH_TERM = 'foobar';
|
|
19
|
+
|
|
20
|
+
console.error(`š Monitoring FRIDA chat for mentions of "${SEARCH_TERM}"...`);
|
|
21
|
+
console.error(`Press Ctrl+C to stop monitoring\n`);
|
|
22
|
+
|
|
23
|
+
// Spawn httpcat chat process
|
|
24
|
+
const chatProcess = spawn('httpcat', ['chat', '--json', TOKEN], {
|
|
25
|
+
stdio: ['pipe', 'pipe', 'inherit'],
|
|
26
|
+
shell: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
let outputBuffer = '';
|
|
30
|
+
let seenMessageIds = new Set();
|
|
31
|
+
|
|
32
|
+
chatProcess.stdout.on('data', (data) => {
|
|
33
|
+
outputBuffer += data.toString();
|
|
34
|
+
const lines = outputBuffer.split('\n');
|
|
35
|
+
outputBuffer = lines.pop() || '';
|
|
36
|
+
|
|
37
|
+
for (const line of lines) {
|
|
38
|
+
if (!line.trim()) continue;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const event = JSON.parse(line);
|
|
42
|
+
|
|
43
|
+
switch (event.type) {
|
|
44
|
+
case 'joined':
|
|
45
|
+
console.error(`ā
Joined FRIDA chat. Lease ID: ${event.leaseId}`);
|
|
46
|
+
console.error(`š” Monitoring for "${SEARCH_TERM}" mentions...\n`);
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
case 'message':
|
|
50
|
+
const msg = event.data;
|
|
51
|
+
|
|
52
|
+
// Skip if we've already seen this message
|
|
53
|
+
if (seenMessageIds.has(msg.messageId)) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
seenMessageIds.add(msg.messageId);
|
|
57
|
+
|
|
58
|
+
// Check if message contains search term (case-insensitive)
|
|
59
|
+
if (msg.message.toLowerCase().includes(SEARCH_TERM.toLowerCase())) {
|
|
60
|
+
const author = msg.authorShort || msg.author?.slice(0, 10);
|
|
61
|
+
const time = new Date(msg.timestamp).toLocaleString();
|
|
62
|
+
|
|
63
|
+
console.error('\n' + '='.repeat(60));
|
|
64
|
+
console.error(`šÆ FOUND "${SEARCH_TERM}" MENTION!`);
|
|
65
|
+
console.error('='.repeat(60));
|
|
66
|
+
console.error(`Time: ${time}`);
|
|
67
|
+
console.error(`Author: ${author}`);
|
|
68
|
+
console.error(`Message: ${msg.message}`);
|
|
69
|
+
console.error('='.repeat(60) + '\n');
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 'lease_expired':
|
|
74
|
+
console.error('ā±ļø Lease expired. Sending /renew...');
|
|
75
|
+
if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
|
|
76
|
+
chatProcess.stdin.write('/renew\n');
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case 'error':
|
|
81
|
+
console.error(`ā Error: ${event.error}`);
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
case 'exiting':
|
|
85
|
+
console.error('š Chat session ended');
|
|
86
|
+
process.exit(0);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// Not JSON, ignore
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
chatProcess.on('error', (error) => {
|
|
96
|
+
console.error(`ā Failed to start chat process: ${error.message}`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
chatProcess.on('exit', (code) => {
|
|
101
|
+
if (code !== 0 && code !== null) {
|
|
102
|
+
console.error(`Chat process exited with code ${code}`);
|
|
103
|
+
}
|
|
104
|
+
process.exit(code || 0);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Handle Ctrl+C
|
|
108
|
+
process.on('SIGINT', () => {
|
|
109
|
+
console.error('\nš Stopping monitor...');
|
|
110
|
+
if (chatProcess.stdin && !chatProcess.stdin.destroyed) {
|
|
111
|
+
chatProcess.stdin.write('/exit\n');
|
|
112
|
+
}
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
chatProcess.kill();
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}, 1000);
|
|
117
|
+
});
|
|
118
|
+
|