nanoparse-mcp 1.0.2 → 1.0.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/README.md +16 -1
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +9 -2
- package/dist/fetch.js.map +1 -1
- package/dist/index.js +120 -30
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +2 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +34 -0
- package/dist/session.js.map +1 -0
- package/dist/status.d.ts +18 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +14 -0
- package/dist/status.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# NanoParse MCP
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/nanoparse-mcp)
|
|
4
3
|
[](./LICENSE)
|
|
5
4
|
|
|
5
|
+
> ⚠️ **npm package not published yet** — coming soon. Until then, use the hosted MCP server at `https://nanoparse.app/mcp` (add it to your MCP client config, no install needed) or run this repo from source. See [github.com/NanoParse/nanoparse-mcp](https://github.com/NanoParse/nanoparse-mcp).
|
|
6
|
+
|
|
6
7
|
MCP client for [NanoParse](https://nanoparse.app) — pay-per-parse web content extraction for AI agents. No accounts, no API keys. Just paste a URL and get clean, structured Markdown back.
|
|
7
8
|
|
|
8
9
|
## What this is
|
|
@@ -17,6 +18,8 @@ The browser rendering, content scoring, and Markdown conversion stay on NanoPars
|
|
|
17
18
|
|
|
18
19
|
## Install
|
|
19
20
|
|
|
21
|
+
Coming soon to npm. Once published:
|
|
22
|
+
|
|
20
23
|
```bash
|
|
21
24
|
npx nanoparse-mcp
|
|
22
25
|
```
|
|
@@ -27,6 +30,18 @@ Or install globally:
|
|
|
27
30
|
npm install -g nanoparse-mcp
|
|
28
31
|
```
|
|
29
32
|
|
|
33
|
+
**Meanwhile:** point your MCP client at the hosted server instead:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"nanoparse": {
|
|
39
|
+
"url": "https://nanoparse.app/mcp"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
30
45
|
### Prerequisites
|
|
31
46
|
|
|
32
47
|
- Node.js 18+
|
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAqBA,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE;QACN,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE;YAAE,aAAa,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC;QACzD,MAAM,CAAC,EAAE;YAAE,eAAe,EAAE,MAAM,CAAC;YAAC,eAAe,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/D,CAAC;CACH;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,MAAM,EACX,KAAK,UAAQ,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAiD5B"}
|
package/dist/fetch.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { signPayment } from "./payment.js";
|
|
2
|
+
import { getSessionId } from "./session.js";
|
|
2
3
|
const FETCH_ENDPOINT = "https://nanoparse.app/fetch";
|
|
3
4
|
export async function fetchPage(url, debug = false) {
|
|
4
5
|
const body = { url };
|
|
@@ -7,14 +8,19 @@ export async function fetchPage(url, debug = false) {
|
|
|
7
8
|
// First attempt — may return 402 if payment is required
|
|
8
9
|
let res = await fetch(FETCH_ENDPOINT, {
|
|
9
10
|
method: "POST",
|
|
10
|
-
headers: {
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
"X-NanoParse-Session": getSessionId(),
|
|
14
|
+
},
|
|
11
15
|
body: JSON.stringify(body),
|
|
12
16
|
});
|
|
13
17
|
// Handle x402 payment flow
|
|
14
18
|
if (res.status === 402) {
|
|
15
19
|
const paymentTerms = await res.json();
|
|
16
20
|
if (paymentTerms.error !== "payment_required") {
|
|
17
|
-
|
|
21
|
+
// Forward the structured error with guidance if available
|
|
22
|
+
const guidance = paymentTerms.message || paymentTerms.next_step || "";
|
|
23
|
+
throw new Error(`Payment failed: ${paymentTerms.error_code || paymentTerms.error}. ${guidance}`.trim());
|
|
18
24
|
}
|
|
19
25
|
const signature = await signPayment(paymentTerms);
|
|
20
26
|
// Retry with payment signature
|
|
@@ -23,6 +29,7 @@ export async function fetchPage(url, debug = false) {
|
|
|
23
29
|
headers: {
|
|
24
30
|
"Content-Type": "application/json",
|
|
25
31
|
"Payment-Signature": signature,
|
|
32
|
+
"X-NanoParse-Session": getSessionId(),
|
|
26
33
|
},
|
|
27
34
|
body: JSON.stringify(body),
|
|
28
35
|
});
|
package/dist/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,cAAc,GAAG,6BAA6B,CAAC;AA4CrD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAW,EACX,KAAK,GAAG,KAAK;IAEb,MAAM,IAAI,GAA4B,EAAE,GAAG,EAAE,CAAC;IAC9C,IAAI,KAAK;QAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAE7B,wDAAwD;IACxD,IAAI,GAAG,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE;QACpC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,qBAAqB,EAAE,YAAY,EAAE;SACtC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IAEH,2BAA2B;IAC3B,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,YAAY,GAAqB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAExD,IAAI,YAAY,CAAC,KAAK,KAAK,kBAAkB,EAAE,CAAC;YAC9C,0DAA0D;YAC1D,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC;YACtE,MAAM,IAAI,KAAK,CACb,mBAAmB,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC,IAAI,EAAE,CACvF,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,CAAC;QAElD,+BAA+B;QAC/B,GAAG,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE;YAChC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,mBAAmB,EAAE,SAAS;gBAC9B,qBAAqB,EAAE,YAAY,EAAE;aACtC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,0BAA0B,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CACrD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAsB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACjD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,14 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { fetchPage } from "./fetch.js";
|
|
6
|
+
import { getStatus } from "./status.js";
|
|
7
|
+
const PKG_VERSION = "1.0.4";
|
|
8
|
+
const FETCH_DESC = "Fetch a web page and return clean, structured Markdown with metadata. " +
|
|
9
|
+
"First 10 parses free per IP. After that, pay $0.0175 USDC on Base via x402. " +
|
|
10
|
+
"No account or API key required.";
|
|
6
11
|
const server = new Server({
|
|
7
12
|
name: "nanoparse-mcp",
|
|
8
|
-
version:
|
|
13
|
+
version: PKG_VERSION,
|
|
9
14
|
}, {
|
|
10
15
|
capabilities: {
|
|
11
16
|
tools: {},
|
|
@@ -15,9 +20,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
15
20
|
tools: [
|
|
16
21
|
{
|
|
17
22
|
name: "nanoparse_fetch",
|
|
18
|
-
description:
|
|
19
|
-
"First 50 parses free per IP. After that, pay $0.0175 USDC on Base via x402. " +
|
|
20
|
-
"No account or API key required.",
|
|
23
|
+
description: FETCH_DESC,
|
|
21
24
|
inputSchema: {
|
|
22
25
|
type: "object",
|
|
23
26
|
properties: {
|
|
@@ -34,42 +37,129 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
34
37
|
required: ["url"],
|
|
35
38
|
},
|
|
36
39
|
},
|
|
40
|
+
{
|
|
41
|
+
name: "nanoparse_status",
|
|
42
|
+
description: "Check wallet balance, USDC balance, quota state, and whether the next /fetch call will succeed without payment. " +
|
|
43
|
+
"Use before spending — tells the agent exactly how much to fund. " +
|
|
44
|
+
"Provide the wallet address to query (0x...).",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
address: {
|
|
49
|
+
type: "string",
|
|
50
|
+
description: "The Ethereum wallet address to check (0x...)",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: ["address"],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
37
56
|
],
|
|
38
57
|
}));
|
|
39
58
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
40
|
-
|
|
41
|
-
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
42
|
-
}
|
|
59
|
+
const toolName = request.params.name;
|
|
43
60
|
const args = request.params.arguments;
|
|
44
|
-
if (
|
|
45
|
-
|
|
61
|
+
if (toolName === "nanoparse_fetch") {
|
|
62
|
+
const url = args.url;
|
|
63
|
+
if (!url || typeof url !== "string") {
|
|
64
|
+
throw new Error('Missing required parameter: "url"');
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const result = await fetchPage(url, args.debug ?? false);
|
|
68
|
+
return {
|
|
69
|
+
content: [
|
|
70
|
+
{
|
|
71
|
+
type: "text",
|
|
72
|
+
text: result.markdown,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
structuredContent: result,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
80
|
+
return {
|
|
81
|
+
content: [
|
|
82
|
+
{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: `NanoParse error: ${message}`,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
46
90
|
}
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
if (toolName === "nanoparse_status") {
|
|
92
|
+
const addr = args.address || "";
|
|
93
|
+
if (!addr || !/^0x[a-fA-F0-9]{40}$/.test(addr)) {
|
|
94
|
+
throw new Error("Missing or invalid address parameter. Provide a valid Ethereum address (0x...).");
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const status = await getStatus(addr);
|
|
98
|
+
const lines = [
|
|
99
|
+
`Wallet: ${status.wallet_address}`,
|
|
100
|
+
`USDC Balance: $${status.usdc_balance}${status.balance_error ? ` (RPC error: ${status.balance_error})` : ""}`,
|
|
101
|
+
`Price per parse: $${status.price_per_parse}`,
|
|
102
|
+
`Estimated parses from balance: ${status.estimated_parses_remaining}`,
|
|
103
|
+
`Free tier: ${status.quota.free_calls_used}/${status.quota.free_calls_limit} used — ${status.quota.is_free_available ? "AVAILABLE" : "EXHAUSTED"}`,
|
|
104
|
+
`Next call will succeed: ${status.next_call_will_succeed ? "YES" : "NO — fund wallet or wait for free tier reset"}`,
|
|
105
|
+
`To fund: send USDC on Base to ${status.wallet_address}`,
|
|
106
|
+
`Funding URI: ${status.funding_uri}`,
|
|
107
|
+
];
|
|
108
|
+
return {
|
|
109
|
+
content: [
|
|
110
|
+
{
|
|
111
|
+
type: "text",
|
|
112
|
+
text: lines.join("\n"),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
structuredContent: status,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
120
|
+
return {
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: `NanoParse status error: ${message}`,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
isError: true,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
58
130
|
}
|
|
59
|
-
|
|
60
|
-
|
|
131
|
+
throw new Error(`Unknown tool: ${toolName}`);
|
|
132
|
+
});
|
|
133
|
+
// ── Startup self-check ──
|
|
134
|
+
function startupCheck() {
|
|
135
|
+
const key = process.env.NANOPARSE_WALLET_KEY;
|
|
136
|
+
if (key) {
|
|
137
|
+
const truncated = key.startsWith("0x") ? key.slice(0, 10) + "..." : "0x" + key.slice(0, 8) + "...";
|
|
61
138
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
type: "text",
|
|
65
|
-
text: `NanoParse error: ${message}`,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
isError: true,
|
|
139
|
+
ok: true,
|
|
140
|
+
message: `✅ Wallet configured (${truncated}). Ready for x402 payments.`,
|
|
69
141
|
};
|
|
70
142
|
}
|
|
71
|
-
|
|
143
|
+
return {
|
|
144
|
+
ok: false,
|
|
145
|
+
message: [
|
|
146
|
+
"❌ NANOPARSE_WALLET_KEY not set.",
|
|
147
|
+
"",
|
|
148
|
+
"One-command setup:",
|
|
149
|
+
" npx nanoparse-mcp-setup",
|
|
150
|
+
"",
|
|
151
|
+
"Or manually:",
|
|
152
|
+
" 1. Generate a Base wallet (use your coding agent with the prompt at https://github.com/NanoParse/agent-wallet-prompt)",
|
|
153
|
+
" 2. Copy the private key to .env: NANOPARSE_WALLET_KEY=0x...",
|
|
154
|
+
" 3. Fund the wallet with USDC on Base (scan QR at https://nanoparse.app/#wallet)",
|
|
155
|
+
" 4. Restart the MCP server",
|
|
156
|
+
].join("\n"),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
72
159
|
async function main() {
|
|
160
|
+
// Startup self-check — always print, never block startup
|
|
161
|
+
const check = startupCheck();
|
|
162
|
+
console.error(check.message);
|
|
73
163
|
const transport = new StdioServerTransport();
|
|
74
164
|
await server.connect(transport);
|
|
75
165
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,MAAM,UAAU,GAAG,wEAAwE;IACzF,8EAA8E;IAC9E,iCAAiC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AAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;QACnG,OAAO;YACL,EAAE,EAAE,IAAI;YACR,OAAO,EAAE,wBAAwB,SAAS,6BAA6B;SACxE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,OAAO,EAAE;YACP,iCAAiC;YACjC,EAAE;YACF,oBAAoB;YACpB,2BAA2B;YAC3B,EAAE;YACF,cAAc;YACd,yHAAyH;YACzH,+DAA+D;YAC/D,mFAAmF;YACnF,6BAA6B;SAC9B,CAAC,IAAI,CAAC,IAAI,CAAC;KACb,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,yDAAyD;IACzD,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAUA,wBAAgB,YAAY,IAAI,MAAM,CAwBrC"}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
const SESSION_DIR = join(homedir(), ".nanoparse");
|
|
6
|
+
const SESSION_FILE = join(SESSION_DIR, "session");
|
|
7
|
+
let cachedSessionId = null;
|
|
8
|
+
export function getSessionId() {
|
|
9
|
+
if (cachedSessionId)
|
|
10
|
+
return cachedSessionId;
|
|
11
|
+
try {
|
|
12
|
+
if (existsSync(SESSION_FILE)) {
|
|
13
|
+
cachedSessionId = readFileSync(SESSION_FILE, "utf-8").trim();
|
|
14
|
+
if (cachedSessionId && cachedSessionId.length >= 8) {
|
|
15
|
+
return cachedSessionId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// File missing or unreadable — generate new
|
|
21
|
+
}
|
|
22
|
+
// Generate and persist
|
|
23
|
+
cachedSessionId = randomUUID();
|
|
24
|
+
try {
|
|
25
|
+
if (!existsSync(SESSION_DIR))
|
|
26
|
+
mkdirSync(SESSION_DIR, { recursive: true });
|
|
27
|
+
writeFileSync(SESSION_FILE, cachedSessionId, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Non-fatal — session just won't persist across restarts
|
|
31
|
+
}
|
|
32
|
+
return cachedSessionId;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAClD,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAElD,IAAI,eAAe,GAAkB,IAAI,CAAC;AAE1C,MAAM,UAAU,YAAY;IAC1B,IAAI,eAAe;QAAE,OAAO,eAAe,CAAC;IAE5C,IAAI,CAAC;QACH,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC7B,eAAe,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7D,IAAI,eAAe,IAAI,eAAe,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACnD,OAAO,eAAe,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;IAC9C,CAAC;IAED,uBAAuB;IACvB,eAAe,GAAG,UAAU,EAAE,CAAC;IAC/B,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;YAAE,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1E,aAAa,CAAC,YAAY,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,yDAAyD;IAC3D,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AccountStatus {
|
|
2
|
+
wallet_address: string;
|
|
3
|
+
usdc_balance: string;
|
|
4
|
+
usdc_balance_raw: string;
|
|
5
|
+
balance_error: string | null;
|
|
6
|
+
estimated_parses_remaining: number;
|
|
7
|
+
price_per_parse: string;
|
|
8
|
+
quota: {
|
|
9
|
+
free_calls_used: number;
|
|
10
|
+
free_calls_limit: number;
|
|
11
|
+
is_free_available: boolean;
|
|
12
|
+
};
|
|
13
|
+
next_call_will_succeed: boolean;
|
|
14
|
+
funding_uri: string;
|
|
15
|
+
docs_url?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function getStatus(address: string): Promise<AccountStatus>;
|
|
18
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0BAA0B,EAAE,MAAM,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,iBAAiB,EAAE,OAAO,CAAC;KAC5B,CAAC;IACF,sBAAsB,EAAE,OAAO,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAavE"}
|
package/dist/status.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const STATUS_ENDPOINT = "https://nanoparse.app/status/account";
|
|
2
|
+
export async function getStatus(address) {
|
|
3
|
+
const res = await fetch(`${STATUS_ENDPOINT}?address=${encodeURIComponent(address)}`, {
|
|
4
|
+
method: "GET",
|
|
5
|
+
headers: { "Content-Type": "application/json" },
|
|
6
|
+
});
|
|
7
|
+
if (!res.ok) {
|
|
8
|
+
const errorText = await res.text().catch(() => "Unknown error");
|
|
9
|
+
throw new Error(`Status endpoint returned ${res.status}: ${errorText}`);
|
|
10
|
+
}
|
|
11
|
+
const data = await res.json();
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,sCAAsC,CAAC;AAmB/D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAe;IAC7C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,eAAe,YAAY,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAAE;QACnF,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,IAAI,GAAkB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC7C,OAAO,IAAI,CAAC;AACd,CAAC"}
|